aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-06 18:35:27 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-06 18:35:27 -0500
commitd72f0ded89cc78598b8eb0570890234eba167588 (patch)
tree0af9aeb1eb47d93ff2cc3e0d26669caec58fa9d2
parentbaaf031521b7f67be45f07593023b6ba47f07d15 (diff)
parent3868f132cce6abab089fd6b12d6a7333712ade83 (diff)
Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
Pull clk fixes from Stephen Boyd: "One fix for a broken driver on Renesas RZ/A1 SoCs with bootloaders that don't turn all the clks on and another fix for stm32f4 SoCs where we have multiple drivers attaching to the same DT node" * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: clk: stm32f4: Use CLK_OF_DECLARE_DRIVER initialization method clk: renesas: mstp: Support 8-bit registers for r7s72100
-rw-r--r--drivers/clk/clk-stm32f4.c4
-rw-r--r--drivers/clk/renesas/clk-mstp.c27
2 files changed, 24 insertions, 7 deletions
diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c
index 5eb05dbf59b8..fc585f370549 100644
--- a/drivers/clk/clk-stm32f4.c
+++ b/drivers/clk/clk-stm32f4.c
@@ -768,5 +768,5 @@ fail:
768 kfree(clks); 768 kfree(clks);
769 iounmap(base); 769 iounmap(base);
770} 770}
771CLK_OF_DECLARE(stm32f42xx_rcc, "st,stm32f42xx-rcc", stm32f4_rcc_init); 771CLK_OF_DECLARE_DRIVER(stm32f42xx_rcc, "st,stm32f42xx-rcc", stm32f4_rcc_init);
772CLK_OF_DECLARE(stm32f46xx_rcc, "st,stm32f469-rcc", stm32f4_rcc_init); 772CLK_OF_DECLARE_DRIVER(stm32f46xx_rcc, "st,stm32f469-rcc", stm32f4_rcc_init);
diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
index 9375777776d9..b533f99550e1 100644
--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -37,12 +37,14 @@
37 * @smstpcr: module stop control register 37 * @smstpcr: module stop control register
38 * @mstpsr: module stop status register (optional) 38 * @mstpsr: module stop status register (optional)
39 * @lock: protects writes to SMSTPCR 39 * @lock: protects writes to SMSTPCR
40 * @width_8bit: registers are 8-bit, not 32-bit
40 */ 41 */
41struct mstp_clock_group { 42struct mstp_clock_group {
42 struct clk_onecell_data data; 43 struct clk_onecell_data data;
43 void __iomem *smstpcr; 44 void __iomem *smstpcr;
44 void __iomem *mstpsr; 45 void __iomem *mstpsr;
45 spinlock_t lock; 46 spinlock_t lock;
47 bool width_8bit;
46}; 48};
47 49
48/** 50/**
@@ -59,6 +61,18 @@ struct mstp_clock {
59 61
60#define to_mstp_clock(_hw) container_of(_hw, struct mstp_clock, hw) 62#define to_mstp_clock(_hw) container_of(_hw, struct mstp_clock, hw)
61 63
64static inline u32 cpg_mstp_read(struct mstp_clock_group *group,
65 u32 __iomem *reg)
66{
67 return group->width_8bit ? readb(reg) : clk_readl(reg);
68}
69
70static inline void cpg_mstp_write(struct mstp_clock_group *group, u32 val,
71 u32 __iomem *reg)
72{
73 group->width_8bit ? writeb(val, reg) : clk_writel(val, reg);
74}
75
62static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable) 76static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
63{ 77{
64 struct mstp_clock *clock = to_mstp_clock(hw); 78 struct mstp_clock *clock = to_mstp_clock(hw);
@@ -70,12 +84,12 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
70 84
71 spin_lock_irqsave(&group->lock, flags); 85 spin_lock_irqsave(&group->lock, flags);
72 86
73 value = clk_readl(group->smstpcr); 87 value = cpg_mstp_read(group, group->smstpcr);
74 if (enable) 88 if (enable)
75 value &= ~bitmask; 89 value &= ~bitmask;
76 else 90 else
77 value |= bitmask; 91 value |= bitmask;
78 clk_writel(value, group->smstpcr); 92 cpg_mstp_write(group, value, group->smstpcr);
79 93
80 spin_unlock_irqrestore(&group->lock, flags); 94 spin_unlock_irqrestore(&group->lock, flags);
81 95
@@ -83,7 +97,7 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
83 return 0; 97 return 0;
84 98
85 for (i = 1000; i > 0; --i) { 99 for (i = 1000; i > 0; --i) {
86 if (!(clk_readl(group->mstpsr) & bitmask)) 100 if (!(cpg_mstp_read(group, group->mstpsr) & bitmask))
87 break; 101 break;
88 cpu_relax(); 102 cpu_relax();
89 } 103 }
@@ -114,9 +128,9 @@ static int cpg_mstp_clock_is_enabled(struct clk_hw *hw)
114 u32 value; 128 u32 value;
115 129
116 if (group->mstpsr) 130 if (group->mstpsr)
117 value = clk_readl(group->mstpsr); 131 value = cpg_mstp_read(group, group->mstpsr);
118 else 132 else
119 value = clk_readl(group->smstpcr); 133 value = cpg_mstp_read(group, group->smstpcr);
120 134
121 return !(value & BIT(clock->bit_index)); 135 return !(value & BIT(clock->bit_index));
122} 136}
@@ -188,6 +202,9 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
188 return; 202 return;
189 } 203 }
190 204
205 if (of_device_is_compatible(np, "renesas,r7s72100-mstp-clocks"))
206 group->width_8bit = true;
207
191 for (i = 0; i < MSTP_MAX_CLOCKS; ++i) 208 for (i = 0; i < MSTP_MAX_CLOCKS; ++i)
192 clks[i] = ERR_PTR(-ENOENT); 209 clks[i] = ERR_PTR(-ENOENT);
193 210