Skip to content

Commit 294770d

Browse files
finley1226wzyy2
authored andcommitted
MINIARM: clk: rockchip: add safe frequency support
Change-Id: Ib03dc12414295fec8e5a71d2b57ebacbff8e04e3 Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
1 parent 3896eba commit 294770d

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

drivers/clk/rockchip/clk-pll.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#define PLL_MODE_DEEP 0x2
3333
#define PLL_RK3328_MODE_MASK 0x1
3434

35+
unsigned long apll_safefreq = ULONG_MAX;
36+
unsigned long apll_maxfreq;
37+
3538
struct rockchip_clk_pll {
3639
struct clk_hw hw;
3740

@@ -52,6 +55,7 @@ struct rockchip_clk_pll {
5255
spinlock_t *lock;
5356

5457
struct rockchip_clk_provider *ctx;
58+
u8 id;
5559
};
5660

5761
#define to_rockchip_clk_pll(_hw) container_of(_hw, struct rockchip_clk_pll, hw)
@@ -645,6 +649,8 @@ static unsigned long rockchip_rk3066_pll_recalc_rate(struct clk_hw *hw,
645649

646650
if (pll->sel && pll->scaling)
647651
return pll->scaling;
652+
if (pll->id == 1 && apll_maxfreq)
653+
return apll_maxfreq;
648654

649655
rockchip_rk3066_pll_get_params(pll, &cur);
650656

@@ -720,6 +726,7 @@ static int rockchip_rk3066_pll_set_rate(struct clk_hw *hw, unsigned long drate,
720726
struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
721727
const struct rockchip_pll_rate_table *rate;
722728
unsigned long old_rate = rockchip_rk3066_pll_recalc_rate(hw, prate);
729+
unsigned long temp_rate = drate;
723730
struct regmap *grf = rockchip_clk_get_grf(pll->ctx);
724731
int ret;
725732

@@ -729,6 +736,9 @@ static int rockchip_rk3066_pll_set_rate(struct clk_hw *hw, unsigned long drate,
729736
return PTR_ERR(grf);
730737
}
731738

739+
if (pll->id == 1 && drate > apll_safefreq)
740+
drate = apll_safefreq;
741+
732742
pr_debug("%s: changing %s from %lu to %lu with a parent rate of %lu\n",
733743
__func__, clk_hw_get_name(hw), old_rate, drate, prate);
734744

@@ -743,6 +753,10 @@ static int rockchip_rk3066_pll_set_rate(struct clk_hw *hw, unsigned long drate,
743753
ret = rockchip_rk3066_pll_set_params(pll, rate);
744754
if (ret)
745755
pll->scaling = 0;
756+
if (!ret && pll->id == 1 && drate == apll_safefreq)
757+
apll_maxfreq = temp_rate;
758+
else
759+
apll_maxfreq = 0;
746760

747761
return ret;
748762
}
@@ -1268,7 +1282,7 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
12681282
u8 num_parents, int con_offset, int grf_lock_offset,
12691283
int lock_shift, int mode_offset, int mode_shift,
12701284
struct rockchip_pll_rate_table *rate_table,
1271-
unsigned long flags, u8 clk_pll_flags)
1285+
unsigned long flags, u8 clk_pll_flags, u8 id)
12721286
{
12731287
const char *pll_parents[3];
12741288
struct clk_init_data init;
@@ -1393,6 +1407,7 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
13931407
pll->flags = clk_pll_flags;
13941408
pll->lock = &ctx->lock;
13951409
pll->ctx = ctx;
1410+
pll->id = id;
13961411

13971412
pll_clk = clk_register(NULL, &pll->hw);
13981413
if (IS_ERR(pll_clk)) {

drivers/clk/rockchip/clk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void __init rockchip_clk_register_plls(struct rockchip_clk_provider *ctx,
393393
list->con_offset, grf_lock_offset,
394394
list->lock_shift, list->mode_offset,
395395
list->mode_shift, list->rate_table,
396-
list->flags, list->pll_flags);
396+
list->flags, list->pll_flags, list->id);
397397
if (IS_ERR(clk)) {
398398
pr_err("%s: failed to register clock %s\n", __func__,
399399
list->name);

drivers/clk/rockchip/clk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
261261
u8 num_parents, int con_offset, int grf_lock_offset,
262262
int lock_shift, int mode_offset, int mode_shift,
263263
struct rockchip_pll_rate_table *rate_table,
264-
unsigned long flags, u8 clk_pll_flags);
264+
unsigned long flags, u8 clk_pll_flags, u8 id);
265265

266266
struct rockchip_cpuclk_clksel {
267267
int reg;

0 commit comments

Comments
 (0)