Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: tegra: Have EMC clock implement determine_rate()

As opposed to round_rate(), determine_rate() can take rate constraints
into account when choosing the best rate.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Tomeu Vizoso and committed by
Thierry Reding
890d6a54 ac67477f

+23 -12
+23 -12
drivers/clk/tegra/clk-emc.c
··· 116 116 * safer since things have EMC rate floors. Also don't touch parent_rate 117 117 * since we don't want the CCF to play with our parent clocks. 118 118 */ 119 - static long emc_round_rate(struct clk_hw *hw, unsigned long rate, 120 - unsigned long *parent_rate) 119 + static long emc_determine_rate(struct clk_hw *hw, unsigned long rate, 120 + unsigned long min_rate, 121 + unsigned long max_rate, 122 + unsigned long *best_parent_rate, 123 + struct clk_hw **best_parent_hw) 121 124 { 122 125 struct tegra_clk_emc *tegra; 123 126 u8 ram_code = tegra_read_ram_code(); ··· 129 126 130 127 tegra = container_of(hw, struct tegra_clk_emc, hw); 131 128 132 - for (i = 0; i < tegra->num_timings; i++) { 133 - if (tegra->timings[i].ram_code != ram_code) 134 - continue; 129 + for (i = 0; i < tegra->num_timings; i++) { 130 + if (tegra->timings[i].ram_code != ram_code) 131 + continue; 135 132 136 - timing = tegra->timings + i; 133 + timing = tegra->timings + i; 137 134 138 - if (timing->rate >= rate) 139 - return timing->rate; 140 - } 135 + if (timing->rate > max_rate) { 136 + i = min(i, 1); 137 + return tegra->timings[i - 1].rate; 138 + } 141 139 142 - if (timing) 143 - return timing->rate; 140 + if (timing->rate < min_rate) 141 + continue; 142 + 143 + if (timing->rate >= rate) 144 + return timing->rate; 145 + } 146 + 147 + if (timing) 148 + return timing->rate; 144 149 145 150 return __clk_get_rate(hw->clk); 146 151 } ··· 462 451 463 452 static const struct clk_ops tegra_clk_emc_ops = { 464 453 .recalc_rate = emc_recalc_rate, 465 - .round_rate = emc_round_rate, 454 + .determine_rate = emc_determine_rate, 466 455 .set_rate = emc_set_rate, 467 456 .get_parent = emc_get_parent, 468 457 };