Skip to content

Commit 6671507

Browse files
ozbenhbebarino
authored andcommitted
clk: aspeed: Handle inverse polarity of USB port 1 clock gate
The USB port 1 clock gate control has an inversed polarity from all the other clock gates in the chip. This makes the aspeed_clk_{enable,disable} functions honor the flag CLK_GATE_SET_TO_DISABLE and set that flag appropriately so it's set for all clocks except USB port 1. Signed-off-by: Benjamin Herrenschmidt <[email protected]> Reviewed-by: Joel Stanley <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent accf475 commit 6671507

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/clk/clk-aspeed.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ static int aspeed_clk_enable(struct clk_hw *hw)
211211
unsigned long flags;
212212
u32 clk = BIT(gate->clock_idx);
213213
u32 rst = BIT(gate->reset_idx);
214+
u32 enval;
214215

215216
spin_lock_irqsave(gate->lock, flags);
216217

@@ -223,7 +224,8 @@ static int aspeed_clk_enable(struct clk_hw *hw)
223224
}
224225

225226
/* Enable clock */
226-
regmap_update_bits(gate->map, ASPEED_CLK_STOP_CTRL, clk, 0);
227+
enval = (gate->flags & CLK_GATE_SET_TO_DISABLE) ? 0 : clk;
228+
regmap_update_bits(gate->map, ASPEED_CLK_STOP_CTRL, clk, enval);
227229

228230
if (gate->reset_idx >= 0) {
229231
/* A delay of 10ms is specified by the ASPEED docs */
@@ -243,10 +245,12 @@ static void aspeed_clk_disable(struct clk_hw *hw)
243245
struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw);
244246
unsigned long flags;
245247
u32 clk = BIT(gate->clock_idx);
248+
u32 enval;
246249

247250
spin_lock_irqsave(gate->lock, flags);
248251

249-
regmap_update_bits(gate->map, ASPEED_CLK_STOP_CTRL, clk, clk);
252+
enval = (gate->flags & CLK_GATE_SET_TO_DISABLE) ? clk : 0;
253+
regmap_update_bits(gate->map, ASPEED_CLK_STOP_CTRL, clk, enval);
250254

251255
spin_unlock_irqrestore(gate->lock, flags);
252256
}
@@ -478,15 +482,20 @@ static int aspeed_clk_probe(struct platform_device *pdev)
478482

479483
for (i = 0; i < ARRAY_SIZE(aspeed_gates); i++) {
480484
const struct aspeed_gate_data *gd = &aspeed_gates[i];
485+
u32 gate_flags;
481486

487+
/* Special case: the USB port 1 clock (bit 14) is always
488+
* working the opposite way from the other ones.
489+
*/
490+
gate_flags = (gd->clock_idx == 14) ? 0 : CLK_GATE_SET_TO_DISABLE;
482491
hw = aspeed_clk_hw_register_gate(dev,
483492
gd->name,
484493
gd->parent_name,
485494
gd->flags,
486495
map,
487496
gd->clock_idx,
488497
gd->reset_idx,
489-
CLK_GATE_SET_TO_DISABLE,
498+
gate_flags,
490499
&aspeed_clk_lock);
491500
if (IS_ERR(hw))
492501
return PTR_ERR(hw);

0 commit comments

Comments
 (0)