xref: /linux/arch/sh/kernel/cpu/sh4a/clock-sh7723.c (revision 9e1985e13d42b4b66af94637346849565174309d)
1c521dc02SMagnus Damm /*
2c521dc02SMagnus Damm  * arch/sh/kernel/cpu/sh4a/clock-sh7723.c
3c521dc02SMagnus Damm  *
4c521dc02SMagnus Damm  * SH7723 clock framework support
5c521dc02SMagnus Damm  *
6c521dc02SMagnus Damm  * Copyright (C) 2009 Magnus Damm
7c521dc02SMagnus Damm  *
8c521dc02SMagnus Damm  * This program is free software; you can redistribute it and/or modify
9c521dc02SMagnus Damm  * it under the terms of the GNU General Public License as published by
10c521dc02SMagnus Damm  * the Free Software Foundation; either version 2 of the License
11c521dc02SMagnus Damm  *
12c521dc02SMagnus Damm  * This program is distributed in the hope that it will be useful,
13c521dc02SMagnus Damm  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14c521dc02SMagnus Damm  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15c521dc02SMagnus Damm  * GNU General Public License for more details.
16c521dc02SMagnus Damm  *
17c521dc02SMagnus Damm  * You should have received a copy of the GNU General Public License
18c521dc02SMagnus Damm  * along with this program; if not, write to the Free Software
19c521dc02SMagnus Damm  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20c521dc02SMagnus Damm  */
21c521dc02SMagnus Damm #include <linux/init.h>
22c521dc02SMagnus Damm #include <linux/kernel.h>
23c521dc02SMagnus Damm #include <linux/io.h>
24f4221802SPaul Mundt #include <linux/clk.h>
25f4221802SPaul Mundt #include <asm/clkdev.h>
26c521dc02SMagnus Damm #include <asm/clock.h>
272094e504SMagnus Damm #include <asm/hwblk.h>
282094e504SMagnus Damm #include <cpu/sh7723.h>
29c521dc02SMagnus Damm 
30c521dc02SMagnus Damm /* SH7723 registers */
31c521dc02SMagnus Damm #define FRQCR		0xa4150000
32c521dc02SMagnus Damm #define VCLKCR		0xa4150004
33c521dc02SMagnus Damm #define SCLKACR		0xa4150008
34c521dc02SMagnus Damm #define SCLKBCR		0xa415000c
35c521dc02SMagnus Damm #define IRDACLKCR	0xa4150018
36c521dc02SMagnus Damm #define PLLCR		0xa4150024
37c521dc02SMagnus Damm #define DLLFRQ		0xa4150050
38c521dc02SMagnus Damm 
39c521dc02SMagnus Damm /* Fixed 32 KHz root clock for RTC and Power Management purposes */
40c521dc02SMagnus Damm static struct clk r_clk = {
41c521dc02SMagnus Damm 	.name           = "rclk",
42c521dc02SMagnus Damm 	.id             = -1,
43c521dc02SMagnus Damm 	.rate           = 32768,
44c521dc02SMagnus Damm };
45c521dc02SMagnus Damm 
46c521dc02SMagnus Damm /*
47c521dc02SMagnus Damm  * Default rate for the root input clock, reset this with clk_set_rate()
48c521dc02SMagnus Damm  * from the platform code.
49c521dc02SMagnus Damm  */
50c521dc02SMagnus Damm struct clk extal_clk = {
51c521dc02SMagnus Damm 	.name		= "extal",
52c521dc02SMagnus Damm 	.id		= -1,
53c521dc02SMagnus Damm 	.rate		= 33333333,
54c521dc02SMagnus Damm };
55c521dc02SMagnus Damm 
56c521dc02SMagnus Damm /* The dll multiplies the 32khz r_clk, may be used instead of extal */
57c521dc02SMagnus Damm static unsigned long dll_recalc(struct clk *clk)
58c521dc02SMagnus Damm {
59c521dc02SMagnus Damm 	unsigned long mult;
60c521dc02SMagnus Damm 
61c521dc02SMagnus Damm 	if (__raw_readl(PLLCR) & 0x1000)
62c521dc02SMagnus Damm 		mult = __raw_readl(DLLFRQ);
63c521dc02SMagnus Damm 	else
64c521dc02SMagnus Damm 		mult = 0;
65c521dc02SMagnus Damm 
66c521dc02SMagnus Damm 	return clk->parent->rate * mult;
67c521dc02SMagnus Damm }
68c521dc02SMagnus Damm 
69c521dc02SMagnus Damm static struct clk_ops dll_clk_ops = {
70c521dc02SMagnus Damm 	.recalc		= dll_recalc,
71c521dc02SMagnus Damm };
72c521dc02SMagnus Damm 
73c521dc02SMagnus Damm static struct clk dll_clk = {
74c521dc02SMagnus Damm 	.name           = "dll_clk",
75c521dc02SMagnus Damm 	.id             = -1,
76c521dc02SMagnus Damm 	.ops		= &dll_clk_ops,
77c521dc02SMagnus Damm 	.parent		= &r_clk,
78c521dc02SMagnus Damm 	.flags		= CLK_ENABLE_ON_INIT,
79c521dc02SMagnus Damm };
80c521dc02SMagnus Damm 
81c521dc02SMagnus Damm static unsigned long pll_recalc(struct clk *clk)
82c521dc02SMagnus Damm {
83c521dc02SMagnus Damm 	unsigned long mult = 1;
84c521dc02SMagnus Damm 	unsigned long div = 1;
85c521dc02SMagnus Damm 
86c521dc02SMagnus Damm 	if (__raw_readl(PLLCR) & 0x4000)
87c521dc02SMagnus Damm 		mult = (((__raw_readl(FRQCR) >> 24) & 0x1f) + 1);
88c521dc02SMagnus Damm 	else
89c521dc02SMagnus Damm 		div = 2;
90c521dc02SMagnus Damm 
91c521dc02SMagnus Damm 	return (clk->parent->rate * mult) / div;
92c521dc02SMagnus Damm }
93c521dc02SMagnus Damm 
94c521dc02SMagnus Damm static struct clk_ops pll_clk_ops = {
95c521dc02SMagnus Damm 	.recalc		= pll_recalc,
96c521dc02SMagnus Damm };
97c521dc02SMagnus Damm 
98c521dc02SMagnus Damm static struct clk pll_clk = {
99c521dc02SMagnus Damm 	.name		= "pll_clk",
100c521dc02SMagnus Damm 	.id		= -1,
101c521dc02SMagnus Damm 	.ops		= &pll_clk_ops,
102c521dc02SMagnus Damm 	.flags		= CLK_ENABLE_ON_INIT,
103c521dc02SMagnus Damm };
104c521dc02SMagnus Damm 
105c521dc02SMagnus Damm struct clk *main_clks[] = {
106c521dc02SMagnus Damm 	&r_clk,
107c521dc02SMagnus Damm 	&extal_clk,
108c521dc02SMagnus Damm 	&dll_clk,
109c521dc02SMagnus Damm 	&pll_clk,
110c521dc02SMagnus Damm };
111c521dc02SMagnus Damm 
112c521dc02SMagnus Damm static int multipliers[] = { 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
113c521dc02SMagnus Damm static int divisors[] = { 1, 3, 2, 5, 3, 4, 5, 6, 8, 10, 12, 16, 20 };
114c521dc02SMagnus Damm 
1150a5f337eSMagnus Damm static struct clk_div_mult_table div4_div_mult_table = {
116c521dc02SMagnus Damm 	.divisors = divisors,
117c521dc02SMagnus Damm 	.nr_divisors = ARRAY_SIZE(divisors),
118c521dc02SMagnus Damm 	.multipliers = multipliers,
119c521dc02SMagnus Damm 	.nr_multipliers = ARRAY_SIZE(multipliers),
120c521dc02SMagnus Damm };
121c521dc02SMagnus Damm 
1220a5f337eSMagnus Damm static struct clk_div4_table div4_table = {
1230a5f337eSMagnus Damm 	.div_mult_table = &div4_div_mult_table,
1240a5f337eSMagnus Damm };
1250a5f337eSMagnus Damm 
126801cd56eSMagnus Damm enum { DIV4_I, DIV4_U, DIV4_SH, DIV4_B, DIV4_B3, DIV4_P, DIV4_NR };
127c521dc02SMagnus Damm 
128c521dc02SMagnus Damm #define DIV4(_str, _reg, _bit, _mask, _flags) \
129c521dc02SMagnus Damm   SH_CLK_DIV4(_str, &pll_clk, _reg, _bit, _mask, _flags)
130c521dc02SMagnus Damm 
131c521dc02SMagnus Damm struct clk div4_clks[DIV4_NR] = {
132c521dc02SMagnus Damm 	[DIV4_I] = DIV4("cpu_clk", FRQCR, 20, 0x0dbf, CLK_ENABLE_ON_INIT),
133c521dc02SMagnus Damm 	[DIV4_U] = DIV4("umem_clk", FRQCR, 16, 0x0dbf, CLK_ENABLE_ON_INIT),
134c521dc02SMagnus Damm 	[DIV4_SH] = DIV4("shyway_clk", FRQCR, 12, 0x0dbf, CLK_ENABLE_ON_INIT),
135c521dc02SMagnus Damm 	[DIV4_B] = DIV4("bus_clk", FRQCR, 8, 0x0dbf, CLK_ENABLE_ON_INIT),
136c521dc02SMagnus Damm 	[DIV4_B3] = DIV4("b3_clk", FRQCR, 4, 0x0db4, CLK_ENABLE_ON_INIT),
137c521dc02SMagnus Damm 	[DIV4_P] = DIV4("peripheral_clk", FRQCR, 0, 0x0dbf, 0),
138801cd56eSMagnus Damm };
139801cd56eSMagnus Damm 
140801cd56eSMagnus Damm enum { DIV4_IRDA, DIV4_ENABLE_NR };
141801cd56eSMagnus Damm 
142801cd56eSMagnus Damm struct clk div4_enable_clks[DIV4_ENABLE_NR] = {
143c521dc02SMagnus Damm 	[DIV4_IRDA] = DIV4("irda_clk", IRDACLKCR, 0, 0x0dbf, 0),
144c521dc02SMagnus Damm };
145c521dc02SMagnus Damm 
146801cd56eSMagnus Damm enum { DIV4_SIUA, DIV4_SIUB, DIV4_REPARENT_NR };
147801cd56eSMagnus Damm 
148801cd56eSMagnus Damm struct clk div4_reparent_clks[DIV4_REPARENT_NR] = {
149801cd56eSMagnus Damm 	[DIV4_SIUA] = DIV4("siua_clk", SCLKACR, 0, 0x0dbf, 0),
150801cd56eSMagnus Damm 	[DIV4_SIUB] = DIV4("siub_clk", SCLKBCR, 0, 0x0dbf, 0),
151801cd56eSMagnus Damm };
152098ec49bSMagnus Damm enum { DIV6_V, DIV6_NR };
153098ec49bSMagnus Damm 
154098ec49bSMagnus Damm struct clk div6_clks[DIV6_NR] = {
155*9e1985e1SMagnus Damm 	[DIV6_V] = SH_CLK_DIV6(&pll_clk, VCLKCR, 0),
156c521dc02SMagnus Damm };
157c521dc02SMagnus Damm 
158c521dc02SMagnus Damm static struct clk mstp_clks[] = {
159c521dc02SMagnus Damm 	/* See page 60 of Datasheet V1.0: Overview -> Block Diagram */
16008134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_TLB, &div4_clks[DIV4_I], CLK_ENABLE_ON_INIT),
16108134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_IC, &div4_clks[DIV4_I], CLK_ENABLE_ON_INIT),
16208134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_OC, &div4_clks[DIV4_I], CLK_ENABLE_ON_INIT),
16308134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_L2C, &div4_clks[DIV4_SH], CLK_ENABLE_ON_INIT),
16408134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_ILMEM, &div4_clks[DIV4_I], CLK_ENABLE_ON_INIT),
16508134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_FPU, &div4_clks[DIV4_I], CLK_ENABLE_ON_INIT),
16608134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_INTC, &div4_clks[DIV4_I], CLK_ENABLE_ON_INIT),
16708134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_DMAC0, &div4_clks[DIV4_B], 0),
16808134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_SHYWAY, &div4_clks[DIV4_SH], CLK_ENABLE_ON_INIT),
16908134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_HUDI, &div4_clks[DIV4_P], 0),
17008134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_UBC, &div4_clks[DIV4_I], 0),
17108134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_TMU0, &div4_clks[DIV4_P], 0),
17208134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_CMT, &r_clk, 0),
17308134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_RWDT, &r_clk, 0),
17408134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_DMAC1, &div4_clks[DIV4_B], 0),
17508134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_TMU1, &div4_clks[DIV4_P], 0),
17608134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_FLCTL, &div4_clks[DIV4_P], 0),
17708134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_SCIF0, &div4_clks[DIV4_P], 0),
17808134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_SCIF1, &div4_clks[DIV4_P], 0),
17908134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_SCIF2, &div4_clks[DIV4_P], 0),
18008134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_SCIF3, &div4_clks[DIV4_B], 0),
18108134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_SCIF4, &div4_clks[DIV4_B], 0),
18208134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_SCIF5, &div4_clks[DIV4_B], 0),
18308134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_MSIOF0, &div4_clks[DIV4_B], 0),
18408134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_MSIOF1, &div4_clks[DIV4_B], 0),
18508134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_MERAM, &div4_clks[DIV4_SH], 0),
186c521dc02SMagnus Damm 
18708134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_IIC, &div4_clks[DIV4_P], 0),
18808134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_RTC, &r_clk, 0),
189c521dc02SMagnus Damm 
19008134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_ATAPI, &div4_clks[DIV4_SH], 0),
19108134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_ADC, &div4_clks[DIV4_P], 0),
19208134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_TPU, &div4_clks[DIV4_B], 0),
19308134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_IRDA, &div4_clks[DIV4_P], 0),
19408134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_TSIF, &div4_clks[DIV4_B], 0),
19508134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_ICB, &div4_clks[DIV4_B], CLK_ENABLE_ON_INIT),
19608134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_SDHI0, &div4_clks[DIV4_B], 0),
19708134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_SDHI1, &div4_clks[DIV4_B], 0),
19808134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_KEYSC, &r_clk, 0),
19908134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_USB, &div4_clks[DIV4_B], 0),
20008134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_2DG, &div4_clks[DIV4_B], 0),
20108134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_SIU, &div4_clks[DIV4_B], 0),
20208134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_VEU2H1, &div4_clks[DIV4_B], 0),
20308134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_VOU, &div4_clks[DIV4_B], 0),
20408134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_BEU, &div4_clks[DIV4_B], 0),
20508134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_CEU, &div4_clks[DIV4_B], 0),
20608134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_VEU2H0, &div4_clks[DIV4_B], 0),
20708134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_VPU, &div4_clks[DIV4_B], 0),
20808134c3cSMagnus Damm 	SH_HWBLK_CLK(HWBLK_LCDC, &div4_clks[DIV4_B], 0),
209c521dc02SMagnus Damm };
210c521dc02SMagnus Damm 
211fd30401bSMagnus Damm #define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }
212fd30401bSMagnus Damm 
213f4221802SPaul Mundt static struct clk_lookup lookups[] = {
214098ec49bSMagnus Damm 	/* DIV6 clocks */
215098ec49bSMagnus Damm 	CLKDEV_CON_ID("video_clk", &div6_clks[DIV6_V]),
216098ec49bSMagnus Damm 
217fd30401bSMagnus Damm 	/* MSTP clocks */
218fd30401bSMagnus Damm 	CLKDEV_CON_ID("tlb0", &mstp_clks[HWBLK_TLB]),
219fd30401bSMagnus Damm 	CLKDEV_CON_ID("ic0", &mstp_clks[HWBLK_IC]),
220fd30401bSMagnus Damm 	CLKDEV_CON_ID("oc0", &mstp_clks[HWBLK_OC]),
221fd30401bSMagnus Damm 	CLKDEV_CON_ID("l2c0", &mstp_clks[HWBLK_L2C]),
222fd30401bSMagnus Damm 	CLKDEV_CON_ID("ilmem0", &mstp_clks[HWBLK_ILMEM]),
223fd30401bSMagnus Damm 	CLKDEV_CON_ID("fpu0", &mstp_clks[HWBLK_FPU]),
224fd30401bSMagnus Damm 	CLKDEV_CON_ID("intc0", &mstp_clks[HWBLK_INTC]),
225fd30401bSMagnus Damm 	CLKDEV_CON_ID("dmac0", &mstp_clks[HWBLK_DMAC0]),
226fd30401bSMagnus Damm 	CLKDEV_CON_ID("sh0", &mstp_clks[HWBLK_SHYWAY]),
227fd30401bSMagnus Damm 	CLKDEV_CON_ID("hudi0", &mstp_clks[HWBLK_HUDI]),
228fd30401bSMagnus Damm 	CLKDEV_CON_ID("ubc0", &mstp_clks[HWBLK_UBC]),
229f4221802SPaul Mundt 	{
230f4221802SPaul Mundt 		/* TMU0 */
231f4221802SPaul Mundt 		.dev_id		= "sh_tmu.0",
232f4221802SPaul Mundt 		.con_id		= "tmu_fck",
233f3d51e13SMagnus Damm 		.clk		= &mstp_clks[HWBLK_TMU0],
234f4221802SPaul Mundt 	}, {
235f4221802SPaul Mundt 		/* TMU1 */
236f4221802SPaul Mundt 		.dev_id		= "sh_tmu.1",
237f4221802SPaul Mundt 		.con_id		= "tmu_fck",
238f3d51e13SMagnus Damm 		.clk		= &mstp_clks[HWBLK_TMU0],
239f4221802SPaul Mundt 	}, {
240f4221802SPaul Mundt 		/* TMU2 */
241f4221802SPaul Mundt 		.dev_id		= "sh_tmu.2",
242f4221802SPaul Mundt 		.con_id		= "tmu_fck",
243f3d51e13SMagnus Damm 		.clk		= &mstp_clks[HWBLK_TMU0],
244fd30401bSMagnus Damm 	},
245fd30401bSMagnus Damm 	CLKDEV_CON_ID("cmt_fck", &mstp_clks[HWBLK_CMT]),
246fd30401bSMagnus Damm 	CLKDEV_CON_ID("rwdt0", &mstp_clks[HWBLK_RWDT]),
247fd30401bSMagnus Damm 	CLKDEV_CON_ID("dmac1", &mstp_clks[HWBLK_DMAC1]),
248fd30401bSMagnus Damm 	{
249f4221802SPaul Mundt 		/* TMU3 */
250f4221802SPaul Mundt 		.dev_id		= "sh_tmu.3",
251f4221802SPaul Mundt 		.con_id		= "tmu_fck",
252f3d51e13SMagnus Damm 		.clk		= &mstp_clks[HWBLK_TMU1],
253f4221802SPaul Mundt 	}, {
254f4221802SPaul Mundt 		/* TMU4 */
255f4221802SPaul Mundt 		.dev_id		= "sh_tmu.4",
256f4221802SPaul Mundt 		.con_id		= "tmu_fck",
257f3d51e13SMagnus Damm 		.clk		= &mstp_clks[HWBLK_TMU1],
258f4221802SPaul Mundt 	}, {
259f4221802SPaul Mundt 		/* TMU5 */
260f4221802SPaul Mundt 		.dev_id		= "sh_tmu.5",
261f4221802SPaul Mundt 		.con_id		= "tmu_fck",
262f3d51e13SMagnus Damm 		.clk		= &mstp_clks[HWBLK_TMU1],
263fd30401bSMagnus Damm 	},
264fd30401bSMagnus Damm 	CLKDEV_CON_ID("flctl0", &mstp_clks[HWBLK_FLCTL]),
265fd30401bSMagnus Damm 	{
266e4e06697SMagnus Damm 		/* SCIF0 */
267e4e06697SMagnus Damm 		.dev_id		= "sh-sci.0",
268e4e06697SMagnus Damm 		.con_id		= "sci_fck",
269e4e06697SMagnus Damm 		.clk		= &mstp_clks[HWBLK_SCIF0],
270e4e06697SMagnus Damm 	}, {
271e4e06697SMagnus Damm 		/* SCIF1 */
272e4e06697SMagnus Damm 		.dev_id		= "sh-sci.1",
273e4e06697SMagnus Damm 		.con_id		= "sci_fck",
274e4e06697SMagnus Damm 		.clk		= &mstp_clks[HWBLK_SCIF1],
275e4e06697SMagnus Damm 	}, {
276e4e06697SMagnus Damm 		/* SCIF2 */
277e4e06697SMagnus Damm 		.dev_id		= "sh-sci.2",
278e4e06697SMagnus Damm 		.con_id		= "sci_fck",
279e4e06697SMagnus Damm 		.clk		= &mstp_clks[HWBLK_SCIF2],
280e4e06697SMagnus Damm 	}, {
281e4e06697SMagnus Damm 		/* SCIF3 */
282e4e06697SMagnus Damm 		.dev_id		= "sh-sci.3",
283e4e06697SMagnus Damm 		.con_id		= "sci_fck",
284e4e06697SMagnus Damm 		.clk		= &mstp_clks[HWBLK_SCIF3],
285e4e06697SMagnus Damm 	}, {
286e4e06697SMagnus Damm 		/* SCIF4 */
287e4e06697SMagnus Damm 		.dev_id		= "sh-sci.4",
288e4e06697SMagnus Damm 		.con_id		= "sci_fck",
289e4e06697SMagnus Damm 		.clk		= &mstp_clks[HWBLK_SCIF4],
290e4e06697SMagnus Damm 	}, {
291e4e06697SMagnus Damm 		/* SCIF5 */
292e4e06697SMagnus Damm 		.dev_id		= "sh-sci.5",
293e4e06697SMagnus Damm 		.con_id		= "sci_fck",
294e4e06697SMagnus Damm 		.clk		= &mstp_clks[HWBLK_SCIF5],
295f4221802SPaul Mundt 	},
296fd30401bSMagnus Damm 	CLKDEV_CON_ID("msiof0", &mstp_clks[HWBLK_MSIOF0]),
297fd30401bSMagnus Damm 	CLKDEV_CON_ID("msiof1", &mstp_clks[HWBLK_MSIOF1]),
298fd30401bSMagnus Damm 	CLKDEV_CON_ID("meram0", &mstp_clks[HWBLK_MERAM]),
299fd30401bSMagnus Damm 	CLKDEV_CON_ID("i2c0", &mstp_clks[HWBLK_IIC]),
300fd30401bSMagnus Damm 	CLKDEV_CON_ID("rtc0", &mstp_clks[HWBLK_RTC]),
301fd30401bSMagnus Damm 	CLKDEV_CON_ID("atapi0", &mstp_clks[HWBLK_ATAPI]),
302fd30401bSMagnus Damm 	CLKDEV_CON_ID("adc0", &mstp_clks[HWBLK_ADC]),
303fd30401bSMagnus Damm 	CLKDEV_CON_ID("tpu0", &mstp_clks[HWBLK_TPU]),
304fd30401bSMagnus Damm 	CLKDEV_CON_ID("irda0", &mstp_clks[HWBLK_IRDA]),
305fd30401bSMagnus Damm 	CLKDEV_CON_ID("tsif0", &mstp_clks[HWBLK_TSIF]),
306fd30401bSMagnus Damm 	CLKDEV_CON_ID("icb0", &mstp_clks[HWBLK_ICB]),
307fd30401bSMagnus Damm 	CLKDEV_CON_ID("sdhi0", &mstp_clks[HWBLK_SDHI0]),
308fd30401bSMagnus Damm 	CLKDEV_CON_ID("sdhi1", &mstp_clks[HWBLK_SDHI1]),
309fd30401bSMagnus Damm 	CLKDEV_CON_ID("keysc0", &mstp_clks[HWBLK_KEYSC]),
310fd30401bSMagnus Damm 	CLKDEV_CON_ID("usb0", &mstp_clks[HWBLK_USB]),
311fd30401bSMagnus Damm 	CLKDEV_CON_ID("2dg0", &mstp_clks[HWBLK_2DG]),
312fd30401bSMagnus Damm 	CLKDEV_CON_ID("siu0", &mstp_clks[HWBLK_SIU]),
313fd30401bSMagnus Damm 	CLKDEV_CON_ID("veu1", &mstp_clks[HWBLK_VEU2H1]),
314fd30401bSMagnus Damm 	CLKDEV_CON_ID("vou0", &mstp_clks[HWBLK_VOU]),
315fd30401bSMagnus Damm 	CLKDEV_CON_ID("beu0", &mstp_clks[HWBLK_BEU]),
316fd30401bSMagnus Damm 	CLKDEV_CON_ID("ceu0", &mstp_clks[HWBLK_CEU]),
317fd30401bSMagnus Damm 	CLKDEV_CON_ID("veu0", &mstp_clks[HWBLK_VEU2H0]),
318fd30401bSMagnus Damm 	CLKDEV_CON_ID("vpu0", &mstp_clks[HWBLK_VPU]),
319fd30401bSMagnus Damm 	CLKDEV_CON_ID("lcdc0", &mstp_clks[HWBLK_LCDC]),
320f4221802SPaul Mundt };
321f4221802SPaul Mundt 
322c521dc02SMagnus Damm int __init arch_clk_init(void)
323c521dc02SMagnus Damm {
324c521dc02SMagnus Damm 	int k, ret = 0;
325c521dc02SMagnus Damm 
326c521dc02SMagnus Damm 	/* autodetect extal or dll configuration */
327c521dc02SMagnus Damm 	if (__raw_readl(PLLCR) & 0x1000)
328c521dc02SMagnus Damm 		pll_clk.parent = &dll_clk;
329c521dc02SMagnus Damm 	else
330c521dc02SMagnus Damm 		pll_clk.parent = &extal_clk;
331c521dc02SMagnus Damm 
332c521dc02SMagnus Damm 	for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
333f4221802SPaul Mundt 		ret |= clk_register(main_clks[k]);
334f4221802SPaul Mundt 
335f4221802SPaul Mundt 	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
336c521dc02SMagnus Damm 
337c521dc02SMagnus Damm 	if (!ret)
338c521dc02SMagnus Damm 		ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
339c521dc02SMagnus Damm 
340c521dc02SMagnus Damm 	if (!ret)
341801cd56eSMagnus Damm 		ret = sh_clk_div4_enable_register(div4_enable_clks,
342801cd56eSMagnus Damm 					DIV4_ENABLE_NR, &div4_table);
343801cd56eSMagnus Damm 
344801cd56eSMagnus Damm 	if (!ret)
345801cd56eSMagnus Damm 		ret = sh_clk_div4_reparent_register(div4_reparent_clks,
346801cd56eSMagnus Damm 					DIV4_REPARENT_NR, &div4_table);
347801cd56eSMagnus Damm 
348801cd56eSMagnus Damm 	if (!ret)
349098ec49bSMagnus Damm 		ret = sh_clk_div6_register(div6_clks, DIV6_NR);
350c521dc02SMagnus Damm 
351c521dc02SMagnus Damm 	if (!ret)
352f3d51e13SMagnus Damm 		ret = sh_hwblk_clk_register(mstp_clks, HWBLK_NR);
353c521dc02SMagnus Damm 
354c521dc02SMagnus Damm 	return ret;
355c521dc02SMagnus Damm }
356