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
23 * parent - fixed parent. No clk_set_parent support23 * parent - fixed parent. No clk_set_parent support
24 */24 */
25 25
26static 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
34static 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 * It works on following logic: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 if (set)71 if (set)
56 reg |= BIT(gate->bit_idx);72 reg |= BIT(gate->bit_idx);
57 } else {73 } else {
58 reg = clk_readl(gate->reg);74 reg = clk_gate_readl(gate);
59 75
60 if (set)76 if (set)
61 reg |= BIT(gate->bit_idx);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 reg &= ~BIT(gate->bit_idx);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 if (gate->lock)84 if (gate->lock)
69 spin_unlock_irqrestore(gate->lock, flags);85 spin_unlock_irqrestore(gate->lock, flags);
@@ -88,7 +104,7 @@ int clk_gate_is_enabled(struct clk_hw *hw) · 18 unmodified lines
88 u32 reg;104 u32 reg;
89 struct clk_gate *gate = to_clk_gate(hw);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 /* if a set bit disables this clk, flip it before masking */109 /* if a set bit disables this clk, flip it before masking */
94 if (gate->flags & CLK_GATE_SET_TO_DISABLE)110 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
349 * of this register, and mask of gate bits are in higher 16-bit of this349 * of this register, and mask of gate bits are in higher 16-bit of this
350 * register. While setting the gate bits, higher 16-bit should also be350 * register. While setting the gate bits, higher 16-bit should also be
351 * updated to indicate changing gate bits.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 */
353struct clk_gate {356struct clk_gate {
354 struct clk_hw hw;357 struct clk_hw hw;
@@ -362,6 +365,7 @@ struct clk_gate { · 7 unmodified lines
362 365
363#define CLK_GATE_SET_TO_DISABLE BIT(0)366#define CLK_GATE_SET_TO_DISABLE BIT(0)
364#define CLK_GATE_HIWORD_MASK BIT(1)367#define CLK_GATE_HIWORD_MASK BIT(1)
368#define CLK_GATE_BIG_ENDIAN BIT(2)
365 369
366extern const struct clk_ops clk_gate_ops;370extern const struct clk_ops clk_gate_ops;
367struct clk *clk_register_gate(struct device *dev, const char *name,371struct 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