History

clk: divider: add explicit big endian support

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

Jonas Gorski committed 7 years ago

Commit 434d69f1 parent 9e98c672 files · +24 −4Browse files

Unified · Split

2 files
  1. drivers/clk/clk-divider.c +20 −4
  2. include/linux/clk-provider.h +4 −0
drivers/clk/clk-divider.c+20−4
@@ -25,6 +25,22 @@ · 24 unmodified lines
2525 * parent - fixed parent. No clk_set_parent support
2626 */
2727
28+static inline u32 clk_div_readl(struct clk_divider *divider)
29+{
30+ if (divider->flags & CLK_DIVIDER_BIG_ENDIAN)
31+ return ioread32be(divider->reg);
32+
33+ return clk_readl(divider->reg);
34+}
35+
36+static inline void clk_div_writel(struct clk_divider *divider, u32 val)
37+{
38+ if (divider->flags & CLK_DIVIDER_BIG_ENDIAN)
39+ iowrite32be(val, divider->reg);
40+ else
41+ clk_writel(val, divider->reg);
42+}
43+
2844 static unsigned int _get_table_maxdiv(const struct clk_div_table *table,
2945 u8 width)
3046 {
@@ -135,7 +151,7 @@ static unsigned long clk_divider_recalc_rate(struct clk_hw *hw, · 104 unmodified lines
135151 struct clk_divider *divider = to_clk_divider(hw);
136152 unsigned int val;
137153
138− val = clk_readl(divider->reg) >> divider->shift;
154+ val = clk_div_readl(divider) >> divider->shift;
139155 val &= clk_div_mask(divider->width);
140156
141157 return divider_recalc_rate(hw, parent_rate, val, divider->table,
@@ -370,7 +386,7 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, · 228 unmodified lines
370386 if (divider->flags & CLK_DIVIDER_READ_ONLY) {
371387 u32 val;
372388
373− val = clk_readl(divider->reg) >> divider->shift;
389+ val = clk_div_readl(divider) >> divider->shift;
374390 val &= clk_div_mask(divider->width);
375391
376392 return divider_ro_round_rate(hw, rate, prate, divider->table,
@@ -420,11 +436,11 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, · 43 unmodified lines
420436 if (divider->flags & CLK_DIVIDER_HIWORD_MASK) {
421437 val = clk_div_mask(divider->width) << (divider->shift + 16);
422438 } else {
423− val = clk_readl(divider->reg);
439+ val = clk_div_readl(divider);
424440 val &= ~(clk_div_mask(divider->width) << divider->shift);
425441 }
426442 val |= (u32)value << divider->shift;
427− clk_writel(val, divider->reg);
443+ clk_div_writel(divider, val);
428444
429445 if (divider->lock)
430446 spin_unlock_irqrestore(divider->lock, flags);
include/linux/clk-provider.h+4−0
@@ -417,6 +417,9 @@ struct clk_div_table { · 416 unmodified lines
417417 * CLK_DIVIDER_MAX_AT_ZERO - For dividers which are like CLK_DIVIDER_ONE_BASED
418418 * except when the value read from the register is zero, the divisor is
419419 * 2^width of the field.
420+ * CLK_DIVIDER_BIG_ENDIAN - By default little endian register accesses are used
421+ * for the divider register. Setting this flag makes the register accesses
422+ * big endian.
420423 */
421424 struct clk_divider {
422425 struct clk_hw hw;
@@ -438,6 +441,7 @@ struct clk_divider { · 15 unmodified lines
438441 #define CLK_DIVIDER_ROUND_CLOSEST BIT(4)
439442 #define CLK_DIVIDER_READ_ONLY BIT(5)
440443 #define CLK_DIVIDER_MAX_AT_ZERO BIT(6)
444+#define CLK_DIVIDER_BIG_ENDIAN BIT(7)
441445
442446 extern const struct clk_ops clk_divider_ops;
443447 extern const struct clk_ops clk_divider_ro_ops;

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