Add a clock specific flag to switch register accesses to big endian, to allow runtime configuration of big endian gated clocks.
Unified · Split
| @@ -23,6 +23,22 @@ · 22 unmodified lines | ||
| 23 | 23 | * parent - fixed parent. No clk_set_parent support |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | +static inline u32 clk_gate_readl(struct clk_gate *gate) | |
| 27 | +{ | |
| 28 | + if (gate->flags & CLK_GATE_BIG_ENDIAN) | |
| 29 | + return ioread32be(gate->reg); | |
| 30 | + | |
| 31 | + return clk_readl(gate->reg); | |
| 32 | +} | |
| 33 | + | |
| 34 | +static inline void clk_gate_writel(struct clk_gate *gate, u32 val) | |
| 35 | +{ | |
| 36 | + if (gate->flags & CLK_GATE_BIG_ENDIAN) | |
| 37 | + iowrite32be(val, gate->reg); | |
| 38 | + else | |
| 39 | + clk_writel(val, gate->reg); | |
| 40 | +} | |
| 41 | + | |
| 26 | 42 | /* |
| 27 | 43 | * It works on following logic: |
| 28 | 44 | * |
| @@ -55,7 +71,7 @@ static void clk_gate_endisable(struct clk_hw *hw, int enable) · 26 unmodified lines | ||
| 55 | 71 | if (set) |
| 56 | 72 | reg |= BIT(gate->bit_idx); |
| 57 | 73 | } else { |
| 58 | − reg = clk_readl(gate->reg); | |
| 74 | + reg = clk_gate_readl(gate); | |
| 59 | 75 | |
| 60 | 76 | if (set) |
| 61 | 77 | reg |= BIT(gate->bit_idx); |
| @@ -63,7 +79,7 @@ static void clk_gate_endisable(struct clk_hw *hw, int enable) · 1 unmodified line | ||
| 63 | 79 | reg &= ~BIT(gate->bit_idx); |
| 64 | 80 | } |
| 65 | 81 | |
| 66 | − clk_writel(reg, gate->reg); | |
| 82 | + clk_gate_writel(gate, reg); | |
| 67 | 83 | |
| 68 | 84 | if (gate->lock) |
| 69 | 85 | spin_unlock_irqrestore(gate->lock, flags); |
| @@ -88,7 +104,7 @@ int clk_gate_is_enabled(struct clk_hw *hw) · 18 unmodified lines | ||
| 88 | 104 | u32 reg; |
| 89 | 105 | struct clk_gate *gate = to_clk_gate(hw); |
| 90 | 106 | |
| 91 | − reg = clk_readl(gate->reg); | |
| 107 | + reg = clk_gate_readl(gate); | |
| 92 | 108 | |
| 93 | 109 | /* if a set bit disables this clk, flip it before masking */ |
| 94 | 110 | if (gate->flags & CLK_GATE_SET_TO_DISABLE) |
| @@ -349,6 +349,9 @@ void of_fixed_clk_setup(struct device_node *np); · 348 unmodified lines | ||
| 349 | 349 | * of this register, and mask of gate bits are in higher 16-bit of this |
| 350 | 350 | * register. While setting the gate bits, higher 16-bit should also be |
| 351 | 351 | * updated to indicate changing gate bits. |
| 352 | + * CLK_GATE_BIG_ENDIAN - by default little endian register accesses are used for | |
| 353 | + * the gate register. Setting this flag makes the register accesses big | |
| 354 | + * endian. | |
| 352 | 355 | */ |
| 353 | 356 | struct clk_gate { |
| 354 | 357 | struct clk_hw hw; |
| @@ -362,6 +365,7 @@ struct clk_gate { · 7 unmodified lines | ||
| 362 | 365 | |
| 363 | 366 | #define CLK_GATE_SET_TO_DISABLE BIT(0) |
| 364 | 367 | #define CLK_GATE_HIWORD_MASK BIT(1) |
| 368 | +#define CLK_GATE_BIG_ENDIAN BIT(2) | |
| 365 | 369 | |
| 366 | 370 | extern const struct clk_ops clk_gate_ops; |
| 367 | 371 | struct clk *clk_register_gate(struct device *dev, const char *name, |