aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/kernel/cpu/sh4a/clock-sh7722.c')
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7722.c207
1 files changed, 149 insertions, 58 deletions
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 40f859354f79..9d23a36f0647 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -21,7 +21,10 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/clkdev.h>
24#include <asm/clock.h> 25#include <asm/clock.h>
26#include <asm/hwblk.h>
27#include <cpu/sh7722.h>
25 28
26/* SH7722 registers */ 29/* SH7722 registers */
27#define FRQCR 0xa4150000 30#define FRQCR 0xa4150000
@@ -30,15 +33,10 @@
30#define SCLKBCR 0xa415000c 33#define SCLKBCR 0xa415000c
31#define IRDACLKCR 0xa4150018 34#define IRDACLKCR 0xa4150018
32#define PLLCR 0xa4150024 35#define PLLCR 0xa4150024
33#define MSTPCR0 0xa4150030
34#define MSTPCR1 0xa4150034
35#define MSTPCR2 0xa4150038
36#define DLLFRQ 0xa4150050 36#define DLLFRQ 0xa4150050
37 37
38/* Fixed 32 KHz root clock for RTC and Power Management purposes */ 38/* Fixed 32 KHz root clock for RTC and Power Management purposes */
39static struct clk r_clk = { 39static struct clk r_clk = {
40 .name = "rclk",
41 .id = -1,
42 .rate = 32768, 40 .rate = 32768,
43}; 41};
44 42
@@ -47,8 +45,6 @@ static struct clk r_clk = {
47 * from the platform code. 45 * from the platform code.
48 */ 46 */
49struct clk extal_clk = { 47struct clk extal_clk = {
50 .name = "extal",
51 .id = -1,
52 .rate = 33333333, 48 .rate = 33333333,
53}; 49};
54 50
@@ -70,8 +66,6 @@ static struct clk_ops dll_clk_ops = {
70}; 66};
71 67
72static struct clk dll_clk = { 68static struct clk dll_clk = {
73 .name = "dll_clk",
74 .id = -1,
75 .ops = &dll_clk_ops, 69 .ops = &dll_clk_ops,
76 .parent = &r_clk, 70 .parent = &r_clk,
77 .flags = CLK_ENABLE_ON_INIT, 71 .flags = CLK_ENABLE_ON_INIT,
@@ -95,8 +89,6 @@ static struct clk_ops pll_clk_ops = {
95}; 89};
96 90
97static struct clk pll_clk = { 91static struct clk pll_clk = {
98 .name = "pll_clk",
99 .id = -1,
100 .ops = &pll_clk_ops, 92 .ops = &pll_clk_ops,
101 .flags = CLK_ENABLE_ON_INIT, 93 .flags = CLK_ENABLE_ON_INIT,
102}; 94};
@@ -111,64 +103,153 @@ struct clk *main_clks[] = {
111static int multipliers[] = { 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; 103static int multipliers[] = { 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
112static int divisors[] = { 1, 3, 2, 5, 3, 4, 5, 6, 8, 10, 12, 16, 20 }; 104static int divisors[] = { 1, 3, 2, 5, 3, 4, 5, 6, 8, 10, 12, 16, 20 };
113 105
114static struct clk_div_mult_table div4_table = { 106static struct clk_div_mult_table div4_div_mult_table = {
115 .divisors = divisors, 107 .divisors = divisors,
116 .nr_divisors = ARRAY_SIZE(divisors), 108 .nr_divisors = ARRAY_SIZE(divisors),
117 .multipliers = multipliers, 109 .multipliers = multipliers,
118 .nr_multipliers = ARRAY_SIZE(multipliers), 110 .nr_multipliers = ARRAY_SIZE(multipliers),
119}; 111};
120 112
121enum { DIV4_I, DIV4_U, DIV4_SH, DIV4_B, DIV4_B3, DIV4_P, 113static struct clk_div4_table div4_table = {
122 DIV4_SIUA, DIV4_SIUB, DIV4_IRDA, DIV4_NR }; 114 .div_mult_table = &div4_div_mult_table,
115};
116
117#define DIV4(_reg, _bit, _mask, _flags) \
118 SH_CLK_DIV4(&pll_clk, _reg, _bit, _mask, _flags)
123 119
124#define DIV4(_str, _reg, _bit, _mask, _flags) \ 120enum { DIV4_I, DIV4_U, DIV4_SH, DIV4_B, DIV4_B3, DIV4_P, DIV4_NR };
125 SH_CLK_DIV4(_str, &pll_clk, _reg, _bit, _mask, _flags)
126 121
127struct clk div4_clks[DIV4_NR] = { 122struct clk div4_clks[DIV4_NR] = {
128 [DIV4_I] = DIV4("cpu_clk", FRQCR, 20, 0x1fef, CLK_ENABLE_ON_INIT), 123 [DIV4_I] = DIV4(FRQCR, 20, 0x1fef, CLK_ENABLE_ON_INIT),
129 [DIV4_U] = DIV4("umem_clk", FRQCR, 16, 0x1fff, CLK_ENABLE_ON_INIT), 124 [DIV4_U] = DIV4(FRQCR, 16, 0x1fff, CLK_ENABLE_ON_INIT),
130 [DIV4_SH] = DIV4("shyway_clk", FRQCR, 12, 0x1fff, CLK_ENABLE_ON_INIT), 125 [DIV4_SH] = DIV4(FRQCR, 12, 0x1fff, CLK_ENABLE_ON_INIT),
131 [DIV4_B] = DIV4("bus_clk", FRQCR, 8, 0x1fff, CLK_ENABLE_ON_INIT), 126 [DIV4_B] = DIV4(FRQCR, 8, 0x1fff, CLK_ENABLE_ON_INIT),
132 [DIV4_B3] = DIV4("b3_clk", FRQCR, 4, 0x1fff, CLK_ENABLE_ON_INIT), 127 [DIV4_B3] = DIV4(FRQCR, 4, 0x1fff, CLK_ENABLE_ON_INIT),
133 [DIV4_P] = DIV4("peripheral_clk", FRQCR, 0, 0x1fff, 0), 128 [DIV4_P] = DIV4(FRQCR, 0, 0x1fff, 0),
134 [DIV4_SIUA] = DIV4("siua_clk", SCLKACR, 0, 0x1fff, 0), 129};
135 [DIV4_SIUB] = DIV4("siub_clk", SCLKBCR, 0, 0x1fff, 0), 130
136 [DIV4_IRDA] = DIV4("irda_clk", IRDACLKCR, 0, 0x1fff, 0), 131enum { DIV4_IRDA, DIV4_ENABLE_NR };
132
133struct clk div4_enable_clks[DIV4_ENABLE_NR] = {
134 [DIV4_IRDA] = DIV4(IRDACLKCR, 0, 0x1fff, 0),
135};
136
137enum { DIV4_SIUA, DIV4_SIUB, DIV4_REPARENT_NR };
138
139struct clk div4_reparent_clks[DIV4_REPARENT_NR] = {
140 [DIV4_SIUA] = DIV4(SCLKACR, 0, 0x1fff, 0),
141 [DIV4_SIUB] = DIV4(SCLKBCR, 0, 0x1fff, 0),
142};
143
144enum { DIV6_V, DIV6_NR };
145
146struct clk div6_clks[DIV6_NR] = {
147 [DIV6_V] = SH_CLK_DIV6(&pll_clk, VCLKCR, 0),
137}; 148};
138 149
139struct clk div6_clks[] = { 150static struct clk mstp_clks[HWBLK_NR] = {
140 SH_CLK_DIV6("video_clk", &pll_clk, VCLKCR, 0), 151 SH_HWBLK_CLK(HWBLK_URAM, &div4_clks[DIV4_U], CLK_ENABLE_ON_INIT),
152 SH_HWBLK_CLK(HWBLK_XYMEM, &div4_clks[DIV4_B], CLK_ENABLE_ON_INIT),
153 SH_HWBLK_CLK(HWBLK_TMU, &div4_clks[DIV4_P], 0),
154 SH_HWBLK_CLK(HWBLK_CMT, &r_clk, 0),
155 SH_HWBLK_CLK(HWBLK_RWDT, &r_clk, 0),
156 SH_HWBLK_CLK(HWBLK_FLCTL, &div4_clks[DIV4_P], 0),
157 SH_HWBLK_CLK(HWBLK_SCIF0, &div4_clks[DIV4_P], 0),
158 SH_HWBLK_CLK(HWBLK_SCIF1, &div4_clks[DIV4_P], 0),
159 SH_HWBLK_CLK(HWBLK_SCIF2, &div4_clks[DIV4_P], 0),
160
161 SH_HWBLK_CLK(HWBLK_IIC, &div4_clks[DIV4_P], 0),
162 SH_HWBLK_CLK(HWBLK_RTC, &r_clk, 0),
163
164 SH_HWBLK_CLK(HWBLK_SDHI, &div4_clks[DIV4_P], 0),
165 SH_HWBLK_CLK(HWBLK_KEYSC, &r_clk, 0),
166 SH_HWBLK_CLK(HWBLK_USBF, &div4_clks[DIV4_P], 0),
167 SH_HWBLK_CLK(HWBLK_2DG, &div4_clks[DIV4_B], 0),
168 SH_HWBLK_CLK(HWBLK_SIU, &div4_clks[DIV4_B], 0),
169 SH_HWBLK_CLK(HWBLK_VOU, &div4_clks[DIV4_B], 0),
170 SH_HWBLK_CLK(HWBLK_JPU, &div4_clks[DIV4_B], 0),
171 SH_HWBLK_CLK(HWBLK_BEU, &div4_clks[DIV4_B], 0),
172 SH_HWBLK_CLK(HWBLK_CEU, &div4_clks[DIV4_B], 0),
173 SH_HWBLK_CLK(HWBLK_VEU, &div4_clks[DIV4_B], 0),
174 SH_HWBLK_CLK(HWBLK_VPU, &div4_clks[DIV4_B], 0),
175 SH_HWBLK_CLK(HWBLK_LCDC, &div4_clks[DIV4_P], 0),
141}; 176};
142 177
143#define MSTP(_str, _parent, _reg, _bit, _flags) \ 178#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }
144 SH_CLK_MSTP32(_str, -1, _parent, _reg, _bit, _flags) 179
145 180static struct clk_lookup lookups[] = {
146static struct clk mstp_clks[] = { 181 /* main clocks */
147 MSTP("uram0", &div4_clks[DIV4_U], MSTPCR0, 28, CLK_ENABLE_ON_INIT), 182 CLKDEV_CON_ID("rclk", &r_clk),
148 MSTP("xymem0", &div4_clks[DIV4_B], MSTPCR0, 26, CLK_ENABLE_ON_INIT), 183 CLKDEV_CON_ID("extal", &extal_clk),
149 MSTP("tmu0", &div4_clks[DIV4_P], MSTPCR0, 15, 0), 184 CLKDEV_CON_ID("dll_clk", &dll_clk),
150 MSTP("cmt0", &r_clk, MSTPCR0, 14, 0), 185 CLKDEV_CON_ID("pll_clk", &pll_clk),
151 MSTP("rwdt0", &r_clk, MSTPCR0, 13, 0), 186
152 MSTP("flctl0", &div4_clks[DIV4_P], MSTPCR0, 10, 0), 187 /* DIV4 clocks */
153 MSTP("scif0", &div4_clks[DIV4_P], MSTPCR0, 7, 0), 188 CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]),
154 MSTP("scif1", &div4_clks[DIV4_P], MSTPCR0, 6, 0), 189 CLKDEV_CON_ID("umem_clk", &div4_clks[DIV4_U]),
155 MSTP("scif2", &div4_clks[DIV4_P], MSTPCR0, 5, 0), 190 CLKDEV_CON_ID("shyway_clk", &div4_clks[DIV4_SH]),
156 191 CLKDEV_CON_ID("bus_clk", &div4_clks[DIV4_B]),
157 MSTP("i2c0", &div4_clks[DIV4_P], MSTPCR1, 9, 0), 192 CLKDEV_CON_ID("b3_clk", &div4_clks[DIV4_B3]),
158 MSTP("rtc0", &r_clk, MSTPCR1, 8, 0), 193 CLKDEV_CON_ID("peripheral_clk", &div4_clks[DIV4_P]),
159 194 CLKDEV_CON_ID("irda_clk", &div4_enable_clks[DIV4_IRDA]),
160 MSTP("sdhi0", &div4_clks[DIV4_P], MSTPCR2, 18, 0), 195 CLKDEV_CON_ID("siua_clk", &div4_reparent_clks[DIV4_SIUA]),
161 MSTP("keysc0", &r_clk, MSTPCR2, 14, 0), 196 CLKDEV_CON_ID("siub_clk", &div4_reparent_clks[DIV4_SIUB]),
162 MSTP("usbf0", &div4_clks[DIV4_P], MSTPCR2, 11, 0), 197
163 MSTP("2dg0", &div4_clks[DIV4_B], MSTPCR2, 9, 0), 198 /* DIV6 clocks */
164 MSTP("siu0", &div4_clks[DIV4_B], MSTPCR2, 8, 0), 199 CLKDEV_CON_ID("video_clk", &div6_clks[DIV6_V]),
165 MSTP("vou0", &div4_clks[DIV4_B], MSTPCR2, 5, 0), 200
166 MSTP("jpu0", &div4_clks[DIV4_B], MSTPCR2, 6, CLK_ENABLE_ON_INIT), 201 /* MSTP clocks */
167 MSTP("beu0", &div4_clks[DIV4_B], MSTPCR2, 4, 0), 202 CLKDEV_CON_ID("uram0", &mstp_clks[HWBLK_URAM]),
168 MSTP("ceu0", &div4_clks[DIV4_B], MSTPCR2, 3, 0), 203 CLKDEV_CON_ID("xymem0", &mstp_clks[HWBLK_XYMEM]),
169 MSTP("veu0", &div4_clks[DIV4_B], MSTPCR2, 2, CLK_ENABLE_ON_INIT), 204 {
170 MSTP("vpu0", &div4_clks[DIV4_B], MSTPCR2, 1, CLK_ENABLE_ON_INIT), 205 /* TMU0 */
171 MSTP("lcdc0", &div4_clks[DIV4_B], MSTPCR2, 0, 0), 206 .dev_id = "sh_tmu.0",
207 .con_id = "tmu_fck",
208 .clk = &mstp_clks[HWBLK_TMU],
209 }, {
210 /* TMU1 */
211 .dev_id = "sh_tmu.1",
212 .con_id = "tmu_fck",
213 .clk = &mstp_clks[HWBLK_TMU],
214 }, {
215 /* TMU2 */
216 .dev_id = "sh_tmu.2",
217 .con_id = "tmu_fck",
218 .clk = &mstp_clks[HWBLK_TMU],
219 },
220 CLKDEV_CON_ID("cmt_fck", &mstp_clks[HWBLK_CMT]),
221 CLKDEV_CON_ID("rwdt0", &mstp_clks[HWBLK_RWDT]),
222 CLKDEV_CON_ID("flctl0", &mstp_clks[HWBLK_FLCTL]),
223 {
224 /* SCIF0 */
225 .dev_id = "sh-sci.0",
226 .con_id = "sci_fck",
227 .clk = &mstp_clks[HWBLK_SCIF0],
228 }, {
229 /* SCIF1 */
230 .dev_id = "sh-sci.1",
231 .con_id = "sci_fck",
232 .clk = &mstp_clks[HWBLK_SCIF1],
233 }, {
234 /* SCIF2 */
235 .dev_id = "sh-sci.2",
236 .con_id = "sci_fck",
237 .clk = &mstp_clks[HWBLK_SCIF2],
238 },
239 CLKDEV_CON_ID("i2c0", &mstp_clks[HWBLK_IIC]),
240 CLKDEV_CON_ID("rtc0", &mstp_clks[HWBLK_RTC]),
241 CLKDEV_CON_ID("sdhi0", &mstp_clks[HWBLK_SDHI]),
242 CLKDEV_CON_ID("keysc0", &mstp_clks[HWBLK_KEYSC]),
243 CLKDEV_CON_ID("usbf0", &mstp_clks[HWBLK_USBF]),
244 CLKDEV_CON_ID("2dg0", &mstp_clks[HWBLK_2DG]),
245 CLKDEV_CON_ID("siu0", &mstp_clks[HWBLK_SIU]),
246 CLKDEV_CON_ID("vou0", &mstp_clks[HWBLK_VOU]),
247 CLKDEV_CON_ID("jpu0", &mstp_clks[HWBLK_JPU]),
248 CLKDEV_CON_ID("beu0", &mstp_clks[HWBLK_BEU]),
249 CLKDEV_CON_ID("ceu0", &mstp_clks[HWBLK_CEU]),
250 CLKDEV_CON_ID("veu0", &mstp_clks[HWBLK_VEU]),
251 CLKDEV_CON_ID("vpu0", &mstp_clks[HWBLK_VPU]),
252 CLKDEV_CON_ID("lcdc0", &mstp_clks[HWBLK_LCDC]),
172}; 253};
173 254
174int __init arch_clk_init(void) 255int __init arch_clk_init(void)
@@ -184,14 +265,24 @@ int __init arch_clk_init(void)
184 for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++) 265 for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
185 ret = clk_register(main_clks[k]); 266 ret = clk_register(main_clks[k]);
186 267
268 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
269
187 if (!ret) 270 if (!ret)
188 ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table); 271 ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
189 272
190 if (!ret) 273 if (!ret)
191 ret = sh_clk_div6_register(div6_clks, ARRAY_SIZE(div6_clks)); 274 ret = sh_clk_div4_enable_register(div4_enable_clks,
275 DIV4_ENABLE_NR, &div4_table);
276
277 if (!ret)
278 ret = sh_clk_div4_reparent_register(div4_reparent_clks,
279 DIV4_REPARENT_NR, &div4_table);
280
281 if (!ret)
282 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
192 283
193 if (!ret) 284 if (!ret)
194 ret = sh_clk_mstp32_register(mstp_clks, ARRAY_SIZE(mstp_clks)); 285 ret = sh_hwblk_clk_register(mstp_clks, HWBLK_NR);
195 286
196 return ret; 287 return ret;
197} 288}