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

clk: tegra: cclk: Handle thermal DIV2 CPU frequency throttling

Check whether thermal DIV2 throttle is active in order to report
the CPU frequency properly. This very useful for userspace tools
like cpufreq-info which show actual frequency asserted from hardware.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Dmitry Osipenko and committed by
Thierry Reding
344d5df3 78086386

+16 -4
+15 -3
drivers/clk/tegra/clk-tegra-super-cclk.c
··· 25 25 26 26 #define SUPER_CDIV_ENB BIT(31) 27 27 28 + #define TSENSOR_SLOWDOWN BIT(23) 29 + 28 30 static struct tegra_clk_super_mux *cclk_super; 29 31 static bool cclk_on_pllx; 30 32 ··· 49 47 static unsigned long cclk_super_recalc_rate(struct clk_hw *hw, 50 48 unsigned long parent_rate) 51 49 { 52 - if (cclk_super_get_parent(hw) == PLLX_INDEX) 53 - return parent_rate; 50 + struct tegra_clk_super_mux *super = to_clk_super_mux(hw); 51 + u32 val = readl_relaxed(super->reg); 52 + unsigned int div2; 54 53 55 - return tegra_clk_super_ops.recalc_rate(hw, parent_rate); 54 + /* check whether thermal throttling is active */ 55 + if (val & TSENSOR_SLOWDOWN) 56 + div2 = 1; 57 + else 58 + div2 = 0; 59 + 60 + if (cclk_super_get_parent(hw) == PLLX_INDEX) 61 + return parent_rate >> div2; 62 + 63 + return tegra_clk_super_ops.recalc_rate(hw, parent_rate) >> div2; 56 64 } 57 65 58 66 static int cclk_super_determine_rate(struct clk_hw *hw,
+1 -1
drivers/clk/tegra/clk-tegra30.c
··· 930 930 /* CCLKG */ 931 931 clk = tegra_clk_register_super_cclk("cclk_g", cclk_g_parents, 932 932 ARRAY_SIZE(cclk_g_parents), 933 - CLK_SET_RATE_PARENT, 933 + CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE, 934 934 clk_base + CCLKG_BURST_POLICY, 935 935 0, NULL); 936 936 clks[TEGRA30_CLK_CCLK_G] = clk;