Skip to content

Commit 344d5df

Browse files
digetxthierryreding
authored andcommitted
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 <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 7808638 commit 344d5df

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

drivers/clk/tegra/clk-tegra-super-cclk.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
#define SUPER_CDIV_ENB BIT(31)
2727

28+
#define TSENSOR_SLOWDOWN BIT(23)
29+
2830
static struct tegra_clk_super_mux *cclk_super;
2931
static bool cclk_on_pllx;
3032

@@ -47,10 +49,20 @@ static int cclk_super_set_rate(struct clk_hw *hw, unsigned long rate,
4749
static unsigned long cclk_super_recalc_rate(struct clk_hw *hw,
4850
unsigned long parent_rate)
4951
{
52+
struct tegra_clk_super_mux *super = to_clk_super_mux(hw);
53+
u32 val = readl_relaxed(super->reg);
54+
unsigned int div2;
55+
56+
/* check whether thermal throttling is active */
57+
if (val & TSENSOR_SLOWDOWN)
58+
div2 = 1;
59+
else
60+
div2 = 0;
61+
5062
if (cclk_super_get_parent(hw) == PLLX_INDEX)
51-
return parent_rate;
63+
return parent_rate >> div2;
5264

53-
return tegra_clk_super_ops.recalc_rate(hw, parent_rate);
65+
return tegra_clk_super_ops.recalc_rate(hw, parent_rate) >> div2;
5466
}
5567

5668
static int cclk_super_determine_rate(struct clk_hw *hw,

drivers/clk/tegra/clk-tegra30.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ static void __init tegra30_super_clk_init(void)
930930
/* CCLKG */
931931
clk = tegra_clk_register_super_cclk("cclk_g", cclk_g_parents,
932932
ARRAY_SIZE(cclk_g_parents),
933-
CLK_SET_RATE_PARENT,
933+
CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE,
934934
clk_base + CCLKG_BURST_POLICY,
935935
0, NULL);
936936
clks[TEGRA30_CLK_CCLK_G] = clk;

0 commit comments

Comments
 (0)