History

clk: gate: add explicit big endian support

Add a clock specific flag to switch register accesses to big endian, to allow runtime configuration of big endian gated clocks.

Jonas Gorski committed 7 years ago

Commit d1c8a501 parent 58a2b4c2 files · +23 −3Browse files

Unified · Split

2 files
  1. drivers/clk/clk-gate.c +19 −3
  2. include/linux/clk-provider.h +4 −0
drivers/clk/clk-gate.c+19−3
@@ -23,6 +23,22 @@ · 22 unmodified lines
2323 * parent - fixed parent. No clk_set_parent support
2424 */
2525
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+
2642 /*
2743 * It works on following logic:
2844 *
@@ -55,7 +71,7 @@ static void clk_gate_endisable(struct clk_hw *hw, int enable) · 26 unmodified lines
5571 if (set)
5672 reg |= BIT(gate->bit_idx);
5773 } else {
58− reg = clk_readl(gate->reg);
74+ reg = clk_gate_readl(gate);
5975
6076 if (set)
6177 reg |= BIT(gate->bit_idx);
@@ -63,7 +79,7 @@ static void clk_gate_endisable(struct clk_hw *hw, int enable) · 1 unmodified line
6379 reg &= ~BIT(gate->bit_idx);
6480 }
6581
66− clk_writel(reg, gate->reg);
82+ clk_gate_writel(gate, reg);
6783
6884 if (gate->lock)
6985 spin_unlock_irqrestore(gate->lock, flags);
@@ -88,7 +104,7 @@ int clk_gate_is_enabled(struct clk_hw *hw) · 18 unmodified lines
88104 u32 reg;
89105 struct clk_gate *gate = to_clk_gate(hw);
90106
91− reg = clk_readl(gate->reg);
107+ reg = clk_gate_readl(gate);
92108
93109 /* if a set bit disables this clk, flip it before masking */
94110 if (gate->flags & CLK_GATE_SET_TO_DISABLE)
include/linux/clk-provider.h+4−0
@@ -349,6 +349,9 @@ void of_fixed_clk_setup(struct device_node *np); · 348 unmodified lines
349349 * of this register, and mask of gate bits are in higher 16-bit of this
350350 * register. While setting the gate bits, higher 16-bit should also be
351351 * 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.
352355 */
353356 struct clk_gate {
354357 struct clk_hw hw;
@@ -362,6 +365,7 @@ struct clk_gate { · 7 unmodified lines
362365
363366 #define CLK_GATE_SET_TO_DISABLE BIT(0)
364367 #define CLK_GATE_HIWORD_MASK BIT(1)
368+#define CLK_GATE_BIG_ENDIAN BIT(2)
365369
366370 extern const struct clk_ops clk_gate_ops;
367371 struct clk *clk_register_gate(struct device *dev, const char *name,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t