aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Brandt <chris.brandt@renesas.com>2016-12-15 12:00:27 -0500
committerStephen Boyd <sboyd@codeaurora.org>2016-12-21 19:33:14 -0500
commite2a33c34ddff22ee208d80abdd12b88a98d6cb60 (patch)
tree60f1a5bbbcda32a59d06d548c749b4f3f9f7e5f4
parent2aab7a2055a1705c9e30920d95a596226999eb21 (diff)
clk: renesas: mstp: Support 8-bit registers for r7s72100
The RZ/A1 is different than the other Renesas SOCs because the MSTP registers are 8-bit instead of 32-bit and if you try writing values as 32-bit nothing happens...meaning this driver never worked for r7s72100. Fixes: b6face404f38 ("ARM: shmobile: r7s72100: add essential clock nodes to dtsi") Signed-off-by: Chris Brandt <chris.brandt@renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
-rw-r--r--drivers/clk/renesas/clk-mstp.c27
1 files changed, 22 insertions, 5 deletions
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