Loading...
1/*
2 * arch/sh/kernel/cpu/sh4a/clock-sh7722.c
3 *
4 * SH7722 clock framework support
5 *
6 * Copyright (C) 2009 Magnus Damm
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21#include <linux/init.h>
22#include <linux/kernel.h>
23#include <linux/io.h>
24#include <linux/clkdev.h>
25#include <linux/sh_clk.h>
26#include <asm/clock.h>
27#include <cpu/sh7722.h>
28
29/* SH7722 registers */
30#define FRQCR 0xa4150000
31#define VCLKCR 0xa4150004
32#define SCLKACR 0xa4150008
33#define SCLKBCR 0xa415000c
34#define IRDACLKCR 0xa4150018
35#define PLLCR 0xa4150024
36#define MSTPCR0 0xa4150030
37#define MSTPCR1 0xa4150034
38#define MSTPCR2 0xa4150038
39#define DLLFRQ 0xa4150050
40
41/* Fixed 32 KHz root clock for RTC and Power Management purposes */
42static struct clk r_clk = {
43 .rate = 32768,
44};
45
46/*
47 * Default rate for the root input clock, reset this with clk_set_rate()
48 * from the platform code.
49 */
50struct clk extal_clk = {
51 .rate = 33333333,
52};
53
54/* The dll block multiplies the 32khz r_clk, may be used instead of extal */
55static unsigned long dll_recalc(struct clk *clk)
56{
57 unsigned long mult;
58
59 if (__raw_readl(PLLCR) & 0x1000)
60 mult = __raw_readl(DLLFRQ);
61 else
62 mult = 0;
63
64 return clk->parent->rate * mult;
65}
66
67static struct sh_clk_ops dll_clk_ops = {
68 .recalc = dll_recalc,
69};
70
71static struct clk dll_clk = {
72 .ops = &dll_clk_ops,
73 .parent = &r_clk,
74 .flags = CLK_ENABLE_ON_INIT,
75};
76
77static unsigned long pll_recalc(struct clk *clk)
78{
79 unsigned long mult = 1;
80 unsigned long div = 1;
81
82 if (__raw_readl(PLLCR) & 0x4000)
83 mult = (((__raw_readl(FRQCR) >> 24) & 0x1f) + 1);
84 else
85 div = 2;
86
87 return (clk->parent->rate * mult) / div;
88}
89
90static struct sh_clk_ops pll_clk_ops = {
91 .recalc = pll_recalc,
92};
93
94static struct clk pll_clk = {
95 .ops = &pll_clk_ops,
96 .flags = CLK_ENABLE_ON_INIT,
97};
98
99struct clk *main_clks[] = {
100 &r_clk,
101 &extal_clk,
102 &dll_clk,
103 &pll_clk,
104};
105
106static int multipliers[] = { 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
107static int divisors[] = { 1, 3, 2, 5, 3, 4, 5, 6, 8, 10, 12, 16, 20 };
108
109static struct clk_div_mult_table div4_div_mult_table = {
110 .divisors = divisors,
111 .nr_divisors = ARRAY_SIZE(divisors),
112 .multipliers = multipliers,
113 .nr_multipliers = ARRAY_SIZE(multipliers),
114};
115
116static struct clk_div4_table div4_table = {
117 .div_mult_table = &div4_div_mult_table,
118};
119
120#define DIV4(_reg, _bit, _mask, _flags) \
121 SH_CLK_DIV4(&pll_clk, _reg, _bit, _mask, _flags)
122
123enum { DIV4_I, DIV4_U, DIV4_SH, DIV4_B, DIV4_B3, DIV4_P, DIV4_NR };
124
125struct clk div4_clks[DIV4_NR] = {
126 [DIV4_I] = DIV4(FRQCR, 20, 0x1fef, CLK_ENABLE_ON_INIT),
127 [DIV4_U] = DIV4(FRQCR, 16, 0x1fff, CLK_ENABLE_ON_INIT),
128 [DIV4_SH] = DIV4(FRQCR, 12, 0x1fff, CLK_ENABLE_ON_INIT),
129 [DIV4_B] = DIV4(FRQCR, 8, 0x1fff, CLK_ENABLE_ON_INIT),
130 [DIV4_B3] = DIV4(FRQCR, 4, 0x1fff, CLK_ENABLE_ON_INIT),
131 [DIV4_P] = DIV4(FRQCR, 0, 0x1fff, 0),
132};
133
134enum { DIV4_IRDA, DIV4_ENABLE_NR };
135
136struct clk div4_enable_clks[DIV4_ENABLE_NR] = {
137 [DIV4_IRDA] = DIV4(IRDACLKCR, 0, 0x1fff, 0),
138};
139
140enum { DIV4_SIUA, DIV4_SIUB, DIV4_REPARENT_NR };
141
142struct clk div4_reparent_clks[DIV4_REPARENT_NR] = {
143 [DIV4_SIUA] = DIV4(SCLKACR, 0, 0x1fff, 0),
144 [DIV4_SIUB] = DIV4(SCLKBCR, 0, 0x1fff, 0),
145};
146
147enum { DIV6_V, DIV6_NR };
148
149struct clk div6_clks[DIV6_NR] = {
150 [DIV6_V] = SH_CLK_DIV6(&pll_clk, VCLKCR, 0),
151};
152
153static struct clk mstp_clks[HWBLK_NR] = {
154 [HWBLK_URAM] = SH_CLK_MSTP32(&div4_clks[DIV4_U], MSTPCR0, 28, CLK_ENABLE_ON_INIT),
155 [HWBLK_XYMEM] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR0, 26, CLK_ENABLE_ON_INIT),
156 [HWBLK_TMU] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 15, 0),
157 [HWBLK_CMT] = SH_CLK_MSTP32(&r_clk, MSTPCR0, 14, 0),
158 [HWBLK_RWDT] = SH_CLK_MSTP32(&r_clk, MSTPCR0, 13, 0),
159 [HWBLK_FLCTL] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 10, 0),
160 [HWBLK_SCIF0] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 7, 0),
161 [HWBLK_SCIF1] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 6, 0),
162 [HWBLK_SCIF2] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 5, 0),
163
164 [HWBLK_IIC] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 9, 0),
165 [HWBLK_RTC] = SH_CLK_MSTP32(&r_clk, MSTPCR1, 8, 0),
166
167 [HWBLK_SDHI] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR2, 18, 0),
168 [HWBLK_KEYSC] = SH_CLK_MSTP32(&r_clk, MSTPCR2, 14, 0),
169 [HWBLK_USBF] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR2, 11, 0),
170 [HWBLK_2DG] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 9, 0),
171 [HWBLK_SIU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 8, 0),
172 [HWBLK_JPU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 6, 0),
173 [HWBLK_VOU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 5, 0),
174 [HWBLK_BEU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 4, 0),
175 [HWBLK_CEU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 3, 0),
176 [HWBLK_VEU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 2, 0),
177 [HWBLK_VPU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 1, 0),
178 [HWBLK_LCDC] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR2, 0, 0),
179};
180
181static struct clk_lookup lookups[] = {
182 /* main clocks */
183 CLKDEV_CON_ID("rclk", &r_clk),
184 CLKDEV_CON_ID("extal", &extal_clk),
185 CLKDEV_CON_ID("dll_clk", &dll_clk),
186 CLKDEV_CON_ID("pll_clk", &pll_clk),
187
188 /* DIV4 clocks */
189 CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]),
190 CLKDEV_CON_ID("umem_clk", &div4_clks[DIV4_U]),
191 CLKDEV_CON_ID("shyway_clk", &div4_clks[DIV4_SH]),
192 CLKDEV_CON_ID("bus_clk", &div4_clks[DIV4_B]),
193 CLKDEV_CON_ID("b3_clk", &div4_clks[DIV4_B3]),
194 CLKDEV_CON_ID("peripheral_clk", &div4_clks[DIV4_P]),
195 CLKDEV_CON_ID("irda_clk", &div4_enable_clks[DIV4_IRDA]),
196 CLKDEV_CON_ID("siua_clk", &div4_reparent_clks[DIV4_SIUA]),
197 CLKDEV_CON_ID("siub_clk", &div4_reparent_clks[DIV4_SIUB]),
198
199 /* DIV6 clocks */
200 CLKDEV_CON_ID("video_clk", &div6_clks[DIV6_V]),
201
202 /* MSTP clocks */
203 CLKDEV_CON_ID("uram0", &mstp_clks[HWBLK_URAM]),
204 CLKDEV_CON_ID("xymem0", &mstp_clks[HWBLK_XYMEM]),
205
206 CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[HWBLK_TMU]),
207
208 CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[HWBLK_CMT]),
209 CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]),
210 CLKDEV_CON_ID("flctl0", &mstp_clks[HWBLK_FLCTL]),
211
212 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[HWBLK_SCIF0]),
213 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[HWBLK_SCIF1]),
214 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[HWBLK_SCIF2]),
215
216 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[HWBLK_IIC]),
217 CLKDEV_CON_ID("rtc0", &mstp_clks[HWBLK_RTC]),
218 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[HWBLK_SDHI]),
219 CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[HWBLK_KEYSC]),
220 CLKDEV_CON_ID("usbf0", &mstp_clks[HWBLK_USBF]),
221 CLKDEV_CON_ID("2dg0", &mstp_clks[HWBLK_2DG]),
222 CLKDEV_DEV_ID("siu-pcm-audio", &mstp_clks[HWBLK_SIU]),
223 CLKDEV_DEV_ID("sh-vou.0", &mstp_clks[HWBLK_VOU]),
224 CLKDEV_CON_ID("jpu0", &mstp_clks[HWBLK_JPU]),
225 CLKDEV_CON_ID("beu0", &mstp_clks[HWBLK_BEU]),
226 CLKDEV_DEV_ID("sh_mobile_ceu.0", &mstp_clks[HWBLK_CEU]),
227 CLKDEV_CON_ID("veu0", &mstp_clks[HWBLK_VEU]),
228 CLKDEV_CON_ID("vpu0", &mstp_clks[HWBLK_VPU]),
229 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[HWBLK_LCDC]),
230};
231
232int __init arch_clk_init(void)
233{
234 int k, ret = 0;
235
236 /* autodetect extal or dll configuration */
237 if (__raw_readl(PLLCR) & 0x1000)
238 pll_clk.parent = &dll_clk;
239 else
240 pll_clk.parent = &extal_clk;
241
242 for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
243 ret = clk_register(main_clks[k]);
244
245 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
246
247 if (!ret)
248 ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
249
250 if (!ret)
251 ret = sh_clk_div4_enable_register(div4_enable_clks,
252 DIV4_ENABLE_NR, &div4_table);
253
254 if (!ret)
255 ret = sh_clk_div4_reparent_register(div4_reparent_clks,
256 DIV4_REPARENT_NR, &div4_table);
257
258 if (!ret)
259 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
260
261 if (!ret)
262 ret = sh_clk_mstp_register(mstp_clks, HWBLK_NR);
263
264 return ret;
265}
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * arch/sh/kernel/cpu/sh4a/clock-sh7722.c
4 *
5 * SH7722 clock framework support
6 *
7 * Copyright (C) 2009 Magnus Damm
8 */
9#include <linux/init.h>
10#include <linux/kernel.h>
11#include <linux/io.h>
12#include <linux/clkdev.h>
13#include <linux/sh_clk.h>
14#include <asm/clock.h>
15#include <cpu/sh7722.h>
16
17/* SH7722 registers */
18#define FRQCR 0xa4150000
19#define VCLKCR 0xa4150004
20#define SCLKACR 0xa4150008
21#define SCLKBCR 0xa415000c
22#define IRDACLKCR 0xa4150018
23#define PLLCR 0xa4150024
24#define MSTPCR0 0xa4150030
25#define MSTPCR1 0xa4150034
26#define MSTPCR2 0xa4150038
27#define DLLFRQ 0xa4150050
28
29/* Fixed 32 KHz root clock for RTC and Power Management purposes */
30static struct clk r_clk = {
31 .rate = 32768,
32};
33
34/*
35 * Default rate for the root input clock, reset this with clk_set_rate()
36 * from the platform code.
37 */
38struct clk extal_clk = {
39 .rate = 33333333,
40};
41
42/* The dll block multiplies the 32khz r_clk, may be used instead of extal */
43static unsigned long dll_recalc(struct clk *clk)
44{
45 unsigned long mult;
46
47 if (__raw_readl(PLLCR) & 0x1000)
48 mult = __raw_readl(DLLFRQ);
49 else
50 mult = 0;
51
52 return clk->parent->rate * mult;
53}
54
55static struct sh_clk_ops dll_clk_ops = {
56 .recalc = dll_recalc,
57};
58
59static struct clk dll_clk = {
60 .ops = &dll_clk_ops,
61 .parent = &r_clk,
62 .flags = CLK_ENABLE_ON_INIT,
63};
64
65static unsigned long pll_recalc(struct clk *clk)
66{
67 unsigned long mult = 1;
68 unsigned long div = 1;
69
70 if (__raw_readl(PLLCR) & 0x4000)
71 mult = (((__raw_readl(FRQCR) >> 24) & 0x1f) + 1);
72 else
73 div = 2;
74
75 return (clk->parent->rate * mult) / div;
76}
77
78static struct sh_clk_ops pll_clk_ops = {
79 .recalc = pll_recalc,
80};
81
82static struct clk pll_clk = {
83 .ops = &pll_clk_ops,
84 .flags = CLK_ENABLE_ON_INIT,
85};
86
87struct clk *main_clks[] = {
88 &r_clk,
89 &extal_clk,
90 &dll_clk,
91 &pll_clk,
92};
93
94static int multipliers[] = { 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
95static int divisors[] = { 1, 3, 2, 5, 3, 4, 5, 6, 8, 10, 12, 16, 20 };
96
97static struct clk_div_mult_table div4_div_mult_table = {
98 .divisors = divisors,
99 .nr_divisors = ARRAY_SIZE(divisors),
100 .multipliers = multipliers,
101 .nr_multipliers = ARRAY_SIZE(multipliers),
102};
103
104static struct clk_div4_table div4_table = {
105 .div_mult_table = &div4_div_mult_table,
106};
107
108#define DIV4(_reg, _bit, _mask, _flags) \
109 SH_CLK_DIV4(&pll_clk, _reg, _bit, _mask, _flags)
110
111enum { DIV4_I, DIV4_U, DIV4_SH, DIV4_B, DIV4_B3, DIV4_P, DIV4_NR };
112
113struct clk div4_clks[DIV4_NR] = {
114 [DIV4_I] = DIV4(FRQCR, 20, 0x1fef, CLK_ENABLE_ON_INIT),
115 [DIV4_U] = DIV4(FRQCR, 16, 0x1fff, CLK_ENABLE_ON_INIT),
116 [DIV4_SH] = DIV4(FRQCR, 12, 0x1fff, CLK_ENABLE_ON_INIT),
117 [DIV4_B] = DIV4(FRQCR, 8, 0x1fff, CLK_ENABLE_ON_INIT),
118 [DIV4_B3] = DIV4(FRQCR, 4, 0x1fff, CLK_ENABLE_ON_INIT),
119 [DIV4_P] = DIV4(FRQCR, 0, 0x1fff, 0),
120};
121
122enum { DIV4_IRDA, DIV4_ENABLE_NR };
123
124struct clk div4_enable_clks[DIV4_ENABLE_NR] = {
125 [DIV4_IRDA] = DIV4(IRDACLKCR, 0, 0x1fff, 0),
126};
127
128enum { DIV4_SIUA, DIV4_SIUB, DIV4_REPARENT_NR };
129
130struct clk div4_reparent_clks[DIV4_REPARENT_NR] = {
131 [DIV4_SIUA] = DIV4(SCLKACR, 0, 0x1fff, 0),
132 [DIV4_SIUB] = DIV4(SCLKBCR, 0, 0x1fff, 0),
133};
134
135enum { DIV6_V, DIV6_NR };
136
137struct clk div6_clks[DIV6_NR] = {
138 [DIV6_V] = SH_CLK_DIV6(&pll_clk, VCLKCR, 0),
139};
140
141static struct clk mstp_clks[HWBLK_NR] = {
142 [HWBLK_URAM] = SH_CLK_MSTP32(&div4_clks[DIV4_U], MSTPCR0, 28, CLK_ENABLE_ON_INIT),
143 [HWBLK_XYMEM] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR0, 26, CLK_ENABLE_ON_INIT),
144 [HWBLK_TMU] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 15, 0),
145 [HWBLK_CMT] = SH_CLK_MSTP32(&r_clk, MSTPCR0, 14, 0),
146 [HWBLK_RWDT] = SH_CLK_MSTP32(&r_clk, MSTPCR0, 13, 0),
147 [HWBLK_FLCTL] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 10, 0),
148 [HWBLK_SCIF0] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 7, 0),
149 [HWBLK_SCIF1] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 6, 0),
150 [HWBLK_SCIF2] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 5, 0),
151
152 [HWBLK_IIC] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 9, 0),
153 [HWBLK_RTC] = SH_CLK_MSTP32(&r_clk, MSTPCR1, 8, 0),
154
155 [HWBLK_SDHI] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR2, 18, 0),
156 [HWBLK_KEYSC] = SH_CLK_MSTP32(&r_clk, MSTPCR2, 14, 0),
157 [HWBLK_USBF] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR2, 11, 0),
158 [HWBLK_2DG] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 9, 0),
159 [HWBLK_SIU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 8, 0),
160 [HWBLK_JPU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 6, 0),
161 [HWBLK_VOU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 5, 0),
162 [HWBLK_BEU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 4, 0),
163 [HWBLK_CEU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 3, 0),
164 [HWBLK_VEU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 2, 0),
165 [HWBLK_VPU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 1, 0),
166 [HWBLK_LCDC] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR2, 0, 0),
167};
168
169static struct clk_lookup lookups[] = {
170 /* main clocks */
171 CLKDEV_CON_ID("rclk", &r_clk),
172 CLKDEV_CON_ID("extal", &extal_clk),
173 CLKDEV_CON_ID("dll_clk", &dll_clk),
174 CLKDEV_CON_ID("pll_clk", &pll_clk),
175
176 /* DIV4 clocks */
177 CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]),
178 CLKDEV_CON_ID("umem_clk", &div4_clks[DIV4_U]),
179 CLKDEV_CON_ID("shyway_clk", &div4_clks[DIV4_SH]),
180 CLKDEV_CON_ID("bus_clk", &div4_clks[DIV4_B]),
181 CLKDEV_CON_ID("b3_clk", &div4_clks[DIV4_B3]),
182 CLKDEV_CON_ID("peripheral_clk", &div4_clks[DIV4_P]),
183 CLKDEV_CON_ID("irda_clk", &div4_enable_clks[DIV4_IRDA]),
184 CLKDEV_CON_ID("siua_clk", &div4_reparent_clks[DIV4_SIUA]),
185 CLKDEV_CON_ID("siub_clk", &div4_reparent_clks[DIV4_SIUB]),
186
187 /* DIV6 clocks */
188 CLKDEV_CON_ID("video_clk", &div6_clks[DIV6_V]),
189
190 /* MSTP clocks */
191 CLKDEV_CON_ID("uram0", &mstp_clks[HWBLK_URAM]),
192 CLKDEV_CON_ID("xymem0", &mstp_clks[HWBLK_XYMEM]),
193
194 CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[HWBLK_TMU]),
195
196 CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[HWBLK_CMT]),
197 CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]),
198 CLKDEV_CON_ID("flctl0", &mstp_clks[HWBLK_FLCTL]),
199
200 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[HWBLK_SCIF0]),
201 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[HWBLK_SCIF1]),
202 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[HWBLK_SCIF2]),
203
204 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[HWBLK_IIC]),
205 CLKDEV_CON_ID("rtc0", &mstp_clks[HWBLK_RTC]),
206 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[HWBLK_SDHI]),
207 CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[HWBLK_KEYSC]),
208 CLKDEV_CON_ID("usbf0", &mstp_clks[HWBLK_USBF]),
209 CLKDEV_CON_ID("2dg0", &mstp_clks[HWBLK_2DG]),
210 CLKDEV_DEV_ID("siu-pcm-audio", &mstp_clks[HWBLK_SIU]),
211 CLKDEV_DEV_ID("sh-vou.0", &mstp_clks[HWBLK_VOU]),
212 CLKDEV_CON_ID("jpu0", &mstp_clks[HWBLK_JPU]),
213 CLKDEV_CON_ID("beu0", &mstp_clks[HWBLK_BEU]),
214 CLKDEV_DEV_ID("renesas-ceu.0", &mstp_clks[HWBLK_CEU]),
215 CLKDEV_CON_ID("veu0", &mstp_clks[HWBLK_VEU]),
216 CLKDEV_CON_ID("vpu0", &mstp_clks[HWBLK_VPU]),
217 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[HWBLK_LCDC]),
218};
219
220int __init arch_clk_init(void)
221{
222 int k, ret = 0;
223
224 /* autodetect extal or dll configuration */
225 if (__raw_readl(PLLCR) & 0x1000)
226 pll_clk.parent = &dll_clk;
227 else
228 pll_clk.parent = &extal_clk;
229
230 for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
231 ret = clk_register(main_clks[k]);
232
233 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
234
235 if (!ret)
236 ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
237
238 if (!ret)
239 ret = sh_clk_div4_enable_register(div4_enable_clks,
240 DIV4_ENABLE_NR, &div4_table);
241
242 if (!ret)
243 ret = sh_clk_div4_reparent_register(div4_reparent_clks,
244 DIV4_REPARENT_NR, &div4_table);
245
246 if (!ret)
247 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
248
249 if (!ret)
250 ret = sh_clk_mstp_register(mstp_clks, HWBLK_NR);
251
252 return ret;
253}