Skip to contentSkip to conversation

clk: aspeed: Prevent reset if clock is enabled

PATCH Superseded Eddie James 1 participant 1 message Mar 7, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 clk: aspeed: Prevent reset if clock is enabled

According to the Aspeed specification, the reset and enable sequence should be done when the clock is stopped. The specification doesn't define behavior if the reset is done while the clock is enabled.

From testing on the AST2500, the LPC Controller has problems if the clock is reset while enabled.

Therefore, check whether the clock is enabled or not before performing the reset and enable sequence in the Aspeed clock driver.

Fixes 9871469d2c6f ("clk: aspeed: Register gated clocks")

---

Changes since v1:
- Check and return before the spinlock

 drivers/clk/clk-aspeed.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/clk/clk-aspeed.c +6 -0
index b67ba14..a26a94f 100644
@@ -221,6 +221,12 @@ static int aspeed_clk_enable(struct clk_hw *hw)
 	u32 clk = BIT(gate->clock_idx);
 	u32 rst = BIT(gate->reset_idx);
 	u32 enval;
+	u32 reg;
+
+	/* Only reset/enable/unreset if clock is stopped */
+	regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, &reg);
+	if (!(reg & clk))
+		return 0;
 
 	spin_lock_irqsave(gate->lock, flags);
 
Signature · 1 line
1.8.3.1