@@ -1186,15 +1186,23 @@ clk_rcg2_shared_force_enable_clear(struct clk_hw *hw, const struct freq_tbl *f)
11861186 return clk_rcg2_clear_force_enable (hw );
11871187}
11881188
1189- static int clk_rcg2_shared_set_rate (struct clk_hw * hw , unsigned long rate ,
1190- unsigned long parent_rate )
1189+ static int __clk_rcg2_shared_set_rate (struct clk_hw * hw , unsigned long rate ,
1190+ unsigned long parent_rate ,
1191+ enum freq_policy policy )
11911192{
11921193 struct clk_rcg2 * rcg = to_clk_rcg2 (hw );
11931194 const struct freq_tbl * f ;
11941195
1195- f = qcom_find_freq (rcg -> freq_tbl , rate );
1196- if (!f )
1196+ switch (policy ) {
1197+ case FLOOR :
1198+ f = qcom_find_freq_floor (rcg -> freq_tbl , rate );
1199+ break ;
1200+ case CEIL :
1201+ f = qcom_find_freq (rcg -> freq_tbl , rate );
1202+ break ;
1203+ default :
11971204 return - EINVAL ;
1205+ }
11981206
11991207 /*
12001208 * In case clock is disabled, update the M, N and D registers, cache
@@ -1207,10 +1215,28 @@ static int clk_rcg2_shared_set_rate(struct clk_hw *hw, unsigned long rate,
12071215 return clk_rcg2_shared_force_enable_clear (hw , f );
12081216}
12091217
1218+ static int clk_rcg2_shared_set_rate (struct clk_hw * hw , unsigned long rate ,
1219+ unsigned long parent_rate )
1220+ {
1221+ return __clk_rcg2_shared_set_rate (hw , rate , parent_rate , CEIL );
1222+ }
1223+
12101224static int clk_rcg2_shared_set_rate_and_parent (struct clk_hw * hw ,
12111225 unsigned long rate , unsigned long parent_rate , u8 index )
12121226{
1213- return clk_rcg2_shared_set_rate (hw , rate , parent_rate );
1227+ return __clk_rcg2_shared_set_rate (hw , rate , parent_rate , CEIL );
1228+ }
1229+
1230+ static int clk_rcg2_shared_set_floor_rate (struct clk_hw * hw , unsigned long rate ,
1231+ unsigned long parent_rate )
1232+ {
1233+ return __clk_rcg2_shared_set_rate (hw , rate , parent_rate , FLOOR );
1234+ }
1235+
1236+ static int clk_rcg2_shared_set_floor_rate_and_parent (struct clk_hw * hw ,
1237+ unsigned long rate , unsigned long parent_rate , u8 index )
1238+ {
1239+ return __clk_rcg2_shared_set_rate (hw , rate , parent_rate , FLOOR );
12141240}
12151241
12161242static int clk_rcg2_shared_enable (struct clk_hw * hw )
@@ -1348,6 +1374,18 @@ const struct clk_ops clk_rcg2_shared_ops = {
13481374};
13491375EXPORT_SYMBOL_GPL (clk_rcg2_shared_ops );
13501376
1377+ const struct clk_ops clk_rcg2_shared_floor_ops = {
1378+ .enable = clk_rcg2_shared_enable ,
1379+ .disable = clk_rcg2_shared_disable ,
1380+ .get_parent = clk_rcg2_shared_get_parent ,
1381+ .set_parent = clk_rcg2_shared_set_parent ,
1382+ .recalc_rate = clk_rcg2_shared_recalc_rate ,
1383+ .determine_rate = clk_rcg2_determine_floor_rate ,
1384+ .set_rate = clk_rcg2_shared_set_floor_rate ,
1385+ .set_rate_and_parent = clk_rcg2_shared_set_floor_rate_and_parent ,
1386+ };
1387+ EXPORT_SYMBOL_GPL (clk_rcg2_shared_floor_ops );
1388+
13511389static int clk_rcg2_shared_no_init_park (struct clk_hw * hw )
13521390{
13531391 struct clk_rcg2 * rcg = to_clk_rcg2 (hw );
0 commit comments