Skip to content

Commit aec8c0e

Browse files
lumagandersson
authored andcommitted
clk: qcom: rcg2: add clk_rcg2_shared_floor_ops
Generally SDCC clocks use clk_rcg2_floor_ops, however on SAR2130P platform it's recommended to use rcg2_shared_ops for all Root Clock Generators to park them instead of disabling. Implement a mix of those, clk_rcg2_shared_floor_ops. Signed-off-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent f93cea4 commit aec8c0e

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

drivers/clk/qcom/clk-rcg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ extern const struct clk_ops clk_byte2_ops;
198198
extern const struct clk_ops clk_pixel_ops;
199199
extern const struct clk_ops clk_gfx3d_ops;
200200
extern const struct clk_ops clk_rcg2_shared_ops;
201+
extern const struct clk_ops clk_rcg2_shared_floor_ops;
201202
extern const struct clk_ops clk_rcg2_shared_no_init_park_ops;
202203
extern const struct clk_ops clk_dp_ops;
203204

drivers/clk/qcom/clk-rcg2.c

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
12101224
static 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

12161242
static int clk_rcg2_shared_enable(struct clk_hw *hw)
@@ -1348,6 +1374,18 @@ const struct clk_ops clk_rcg2_shared_ops = {
13481374
};
13491375
EXPORT_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+
13511389
static int clk_rcg2_shared_no_init_park(struct clk_hw *hw)
13521390
{
13531391
struct clk_rcg2 *rcg = to_clk_rcg2(hw);

0 commit comments

Comments
 (0)