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+
3538struct 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 )) {
0 commit comments