Skip to content

Commit fc953d4

Browse files
MrVanbebarino
authored andcommitted
clk: scmi: add is_prepared hook
Some clocks maybe default enabled by hardware. For clocks that don't have users, that will be left in hardware default state, because prepare count and enable count is zero,if there is no is_prepared hook to get the hardware state. So add is_prepared hook to detect the hardware state. Then when disabling the unused clocks, they can be simply turned OFF to save power during kernel boot. Reviewed-by: Dhruva Gole <[email protected]> Signed-off-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Sudeep Holla <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 8400291 commit fc953d4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/clk/clk-scmi.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,30 @@ static void scmi_clk_atomic_disable(struct clk_hw *hw)
156156
scmi_proto_clk_ops->disable(clk->ph, clk->id, ATOMIC);
157157
}
158158

159-
static int scmi_clk_atomic_is_enabled(struct clk_hw *hw)
159+
static int __scmi_clk_is_enabled(struct clk_hw *hw, bool atomic)
160160
{
161161
int ret;
162162
bool enabled = false;
163163
struct scmi_clk *clk = to_scmi_clk(hw);
164164

165-
ret = scmi_proto_clk_ops->state_get(clk->ph, clk->id, &enabled, ATOMIC);
165+
ret = scmi_proto_clk_ops->state_get(clk->ph, clk->id, &enabled, atomic);
166166
if (ret)
167167
dev_warn(clk->dev,
168168
"Failed to get state for clock ID %d\n", clk->id);
169169

170170
return !!enabled;
171171
}
172172

173+
static int scmi_clk_atomic_is_enabled(struct clk_hw *hw)
174+
{
175+
return __scmi_clk_is_enabled(hw, ATOMIC);
176+
}
177+
178+
static int scmi_clk_is_enabled(struct clk_hw *hw)
179+
{
180+
return __scmi_clk_is_enabled(hw, NOT_ATOMIC);
181+
}
182+
173183
static int scmi_clk_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)
174184
{
175185
int ret;
@@ -285,6 +295,8 @@ scmi_clk_ops_alloc(struct device *dev, unsigned long feats_key)
285295

286296
if (feats_key & BIT(SCMI_CLK_ATOMIC_SUPPORTED))
287297
ops->is_enabled = scmi_clk_atomic_is_enabled;
298+
else
299+
ops->is_prepared = scmi_clk_is_enabled;
288300

289301
/* Rate ops */
290302
ops->recalc_rate = scmi_clk_recalc_rate;

0 commit comments

Comments
 (0)