@@ -1186,15 +1186,23 @@ clk_rcg2_shared_force_enable_clear(struct clk_hw *hw, const struct freq_tbl *f)
1186
1186
return clk_rcg2_clear_force_enable (hw );
1187
1187
}
1188
1188
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 )
1191
1192
{
1192
1193
struct clk_rcg2 * rcg = to_clk_rcg2 (hw );
1193
1194
const struct freq_tbl * f ;
1194
1195
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 :
1197
1204
return - EINVAL ;
1205
+ }
1198
1206
1199
1207
/*
1200
1208
* 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,
1207
1215
return clk_rcg2_shared_force_enable_clear (hw , f );
1208
1216
}
1209
1217
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
+
1210
1224
static int clk_rcg2_shared_set_rate_and_parent (struct clk_hw * hw ,
1211
1225
unsigned long rate , unsigned long parent_rate , u8 index )
1212
1226
{
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 );
1214
1240
}
1215
1241
1216
1242
static int clk_rcg2_shared_enable (struct clk_hw * hw )
@@ -1348,6 +1374,18 @@ const struct clk_ops clk_rcg2_shared_ops = {
1348
1374
};
1349
1375
EXPORT_SYMBOL_GPL (clk_rcg2_shared_ops );
1350
1376
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
+
1351
1389
static int clk_rcg2_shared_no_init_park (struct clk_hw * hw )
1352
1390
{
1353
1391
struct clk_rcg2 * rcg = to_clk_rcg2 (hw );
0 commit comments