xref: /linux/arch/m68k/coldfire/m5441x.c (revision f86b9e03837beafb4b48d53a76ee4b88559226de)
1*f86b9e03SGreg Ungerer /*
2*f86b9e03SGreg Ungerer  *	m5441x.c -- support for Coldfire m5441x processors
3*f86b9e03SGreg Ungerer  *
4*f86b9e03SGreg Ungerer  *	(C) Copyright Steven King <sfking@fdwdc.com>
5*f86b9e03SGreg Ungerer  */
6*f86b9e03SGreg Ungerer 
7*f86b9e03SGreg Ungerer #include <linux/kernel.h>
8*f86b9e03SGreg Ungerer #include <linux/param.h>
9*f86b9e03SGreg Ungerer #include <linux/init.h>
10*f86b9e03SGreg Ungerer #include <linux/io.h>
11*f86b9e03SGreg Ungerer #include <linux/clk.h>
12*f86b9e03SGreg Ungerer #include <asm/machdep.h>
13*f86b9e03SGreg Ungerer #include <asm/coldfire.h>
14*f86b9e03SGreg Ungerer #include <asm/mcfsim.h>
15*f86b9e03SGreg Ungerer #include <asm/mcfuart.h>
16*f86b9e03SGreg Ungerer #include <asm/mcfdma.h>
17*f86b9e03SGreg Ungerer #include <asm/mcfclk.h>
18*f86b9e03SGreg Ungerer 
19*f86b9e03SGreg Ungerer DEFINE_CLK(0, "flexbus", 2, MCF_CLK);
20*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfcan.0", 8, MCF_CLK);
21*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfcan.1", 9, MCF_CLK);
22*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfi2c.1", 14, MCF_CLK);
23*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfdspi.1", 15, MCF_CLK);
24*f86b9e03SGreg Ungerer DEFINE_CLK(0, "edma", 17, MCF_CLK);
25*f86b9e03SGreg Ungerer DEFINE_CLK(0, "intc.0", 18, MCF_CLK);
26*f86b9e03SGreg Ungerer DEFINE_CLK(0, "intc.1", 19, MCF_CLK);
27*f86b9e03SGreg Ungerer DEFINE_CLK(0, "intc.2", 20, MCF_CLK);
28*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfi2c.0", 22, MCF_CLK);
29*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfdspi.0", 23, MCF_CLK);
30*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfuart.0", 24, MCF_BUSCLK);
31*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfuart.1", 25, MCF_BUSCLK);
32*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfuart.2", 26, MCF_BUSCLK);
33*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfuart.3", 27, MCF_BUSCLK);
34*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcftmr.0", 28, MCF_CLK);
35*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcftmr.1", 29, MCF_CLK);
36*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcftmr.2", 30, MCF_CLK);
37*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcftmr.3", 31, MCF_CLK);
38*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfpit.0", 32, MCF_CLK);
39*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfpit.1", 33, MCF_CLK);
40*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfpit.2", 34, MCF_CLK);
41*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfpit.3", 35, MCF_CLK);
42*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfeport.0", 37, MCF_CLK);
43*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfadc.0", 38, MCF_CLK);
44*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfdac.0", 39, MCF_CLK);
45*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfrtc.0", 42, MCF_CLK);
46*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfsim.0", 43, MCF_CLK);
47*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfusb-otg.0", 44, MCF_CLK);
48*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfusb-host.0", 45, MCF_CLK);
49*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfddr-sram.0", 46, MCF_CLK);
50*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfssi.0", 47, MCF_CLK);
51*f86b9e03SGreg Ungerer DEFINE_CLK(0, "pll.0", 48, MCF_CLK);
52*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfrng.0", 49, MCF_CLK);
53*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfssi.1", 50, MCF_CLK);
54*f86b9e03SGreg Ungerer DEFINE_CLK(0, "mcfsdhc.0", 51, MCF_CLK);
55*f86b9e03SGreg Ungerer DEFINE_CLK(0, "enet-fec.0", 53, MCF_CLK);
56*f86b9e03SGreg Ungerer DEFINE_CLK(0, "enet-fec.1", 54, MCF_CLK);
57*f86b9e03SGreg Ungerer DEFINE_CLK(0, "switch.0", 55, MCF_CLK);
58*f86b9e03SGreg Ungerer DEFINE_CLK(0, "switch.1", 56, MCF_CLK);
59*f86b9e03SGreg Ungerer DEFINE_CLK(0, "nand.0", 63, MCF_CLK);
60*f86b9e03SGreg Ungerer 
61*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfow.0", 2, MCF_CLK);
62*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfi2c.2", 4, MCF_CLK);
63*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfi2c.3", 5, MCF_CLK);
64*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfi2c.4", 6, MCF_CLK);
65*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfi2c.5", 7, MCF_CLK);
66*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfuart.4", 24, MCF_BUSCLK);
67*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfuart.5", 25, MCF_BUSCLK);
68*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfuart.6", 26, MCF_BUSCLK);
69*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfuart.7", 27, MCF_BUSCLK);
70*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfuart.8", 28, MCF_BUSCLK);
71*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfuart.9", 29, MCF_BUSCLK);
72*f86b9e03SGreg Ungerer DEFINE_CLK(1, "mcfpwm.0", 34, MCF_BUSCLK);
73*f86b9e03SGreg Ungerer DEFINE_CLK(1, "sys.0", 36, MCF_BUSCLK);
74*f86b9e03SGreg Ungerer DEFINE_CLK(1, "gpio.0", 37, MCF_BUSCLK);
75*f86b9e03SGreg Ungerer 
76*f86b9e03SGreg Ungerer struct clk *mcf_clks[] = {
77*f86b9e03SGreg Ungerer 	&__clk_0_2,
78*f86b9e03SGreg Ungerer 	&__clk_0_8,
79*f86b9e03SGreg Ungerer 	&__clk_0_9,
80*f86b9e03SGreg Ungerer 	&__clk_0_14,
81*f86b9e03SGreg Ungerer 	&__clk_0_15,
82*f86b9e03SGreg Ungerer 	&__clk_0_17,
83*f86b9e03SGreg Ungerer 	&__clk_0_18,
84*f86b9e03SGreg Ungerer 	&__clk_0_19,
85*f86b9e03SGreg Ungerer 	&__clk_0_20,
86*f86b9e03SGreg Ungerer 	&__clk_0_22,
87*f86b9e03SGreg Ungerer 	&__clk_0_23,
88*f86b9e03SGreg Ungerer 	&__clk_0_24,
89*f86b9e03SGreg Ungerer 	&__clk_0_25,
90*f86b9e03SGreg Ungerer 	&__clk_0_26,
91*f86b9e03SGreg Ungerer 	&__clk_0_27,
92*f86b9e03SGreg Ungerer 	&__clk_0_28,
93*f86b9e03SGreg Ungerer 	&__clk_0_29,
94*f86b9e03SGreg Ungerer 	&__clk_0_30,
95*f86b9e03SGreg Ungerer 	&__clk_0_31,
96*f86b9e03SGreg Ungerer 	&__clk_0_32,
97*f86b9e03SGreg Ungerer 	&__clk_0_33,
98*f86b9e03SGreg Ungerer 	&__clk_0_34,
99*f86b9e03SGreg Ungerer 	&__clk_0_35,
100*f86b9e03SGreg Ungerer 	&__clk_0_37,
101*f86b9e03SGreg Ungerer 	&__clk_0_38,
102*f86b9e03SGreg Ungerer 	&__clk_0_39,
103*f86b9e03SGreg Ungerer 	&__clk_0_42,
104*f86b9e03SGreg Ungerer 	&__clk_0_43,
105*f86b9e03SGreg Ungerer 	&__clk_0_44,
106*f86b9e03SGreg Ungerer 	&__clk_0_45,
107*f86b9e03SGreg Ungerer 	&__clk_0_46,
108*f86b9e03SGreg Ungerer 	&__clk_0_47,
109*f86b9e03SGreg Ungerer 	&__clk_0_48,
110*f86b9e03SGreg Ungerer 	&__clk_0_49,
111*f86b9e03SGreg Ungerer 	&__clk_0_50,
112*f86b9e03SGreg Ungerer 	&__clk_0_51,
113*f86b9e03SGreg Ungerer 	&__clk_0_53,
114*f86b9e03SGreg Ungerer 	&__clk_0_54,
115*f86b9e03SGreg Ungerer 	&__clk_0_55,
116*f86b9e03SGreg Ungerer 	&__clk_0_56,
117*f86b9e03SGreg Ungerer 	&__clk_0_63,
118*f86b9e03SGreg Ungerer 
119*f86b9e03SGreg Ungerer 	&__clk_1_2,
120*f86b9e03SGreg Ungerer 	&__clk_1_4,
121*f86b9e03SGreg Ungerer 	&__clk_1_5,
122*f86b9e03SGreg Ungerer 	&__clk_1_6,
123*f86b9e03SGreg Ungerer 	&__clk_1_7,
124*f86b9e03SGreg Ungerer 	&__clk_1_24,
125*f86b9e03SGreg Ungerer 	&__clk_1_25,
126*f86b9e03SGreg Ungerer 	&__clk_1_26,
127*f86b9e03SGreg Ungerer 	&__clk_1_27,
128*f86b9e03SGreg Ungerer 	&__clk_1_28,
129*f86b9e03SGreg Ungerer 	&__clk_1_29,
130*f86b9e03SGreg Ungerer 	&__clk_1_34,
131*f86b9e03SGreg Ungerer 	&__clk_1_36,
132*f86b9e03SGreg Ungerer 	&__clk_1_37,
133*f86b9e03SGreg Ungerer 	NULL,
134*f86b9e03SGreg Ungerer };
135*f86b9e03SGreg Ungerer 
136*f86b9e03SGreg Ungerer 
137*f86b9e03SGreg Ungerer static struct clk * const enable_clks[] __initconst = {
138*f86b9e03SGreg Ungerer 	/* make sure these clocks are enabled */
139*f86b9e03SGreg Ungerer 	&__clk_0_18, /* intc0 */
140*f86b9e03SGreg Ungerer 	&__clk_0_19, /* intc0 */
141*f86b9e03SGreg Ungerer 	&__clk_0_20, /* intc0 */
142*f86b9e03SGreg Ungerer 	&__clk_0_24, /* uart0 */
143*f86b9e03SGreg Ungerer 	&__clk_0_25, /* uart1 */
144*f86b9e03SGreg Ungerer 	&__clk_0_26, /* uart2 */
145*f86b9e03SGreg Ungerer 	&__clk_0_27, /* uart3 */
146*f86b9e03SGreg Ungerer 
147*f86b9e03SGreg Ungerer 	&__clk_0_33, /* pit.1 */
148*f86b9e03SGreg Ungerer 	&__clk_0_37, /* eport */
149*f86b9e03SGreg Ungerer 	&__clk_0_48, /* pll */
150*f86b9e03SGreg Ungerer 
151*f86b9e03SGreg Ungerer 	&__clk_1_36, /* CCM/reset module/Power management */
152*f86b9e03SGreg Ungerer 	&__clk_1_37, /* gpio */
153*f86b9e03SGreg Ungerer };
154*f86b9e03SGreg Ungerer static struct clk * const disable_clks[] __initconst = {
155*f86b9e03SGreg Ungerer 	&__clk_0_8, /* can.0 */
156*f86b9e03SGreg Ungerer 	&__clk_0_9, /* can.1 */
157*f86b9e03SGreg Ungerer 	&__clk_0_14, /* i2c.1 */
158*f86b9e03SGreg Ungerer 	&__clk_0_15, /* dspi.1 */
159*f86b9e03SGreg Ungerer 	&__clk_0_17, /* eDMA */
160*f86b9e03SGreg Ungerer 	&__clk_0_22, /* i2c.0 */
161*f86b9e03SGreg Ungerer 	&__clk_0_23, /* dspi.0 */
162*f86b9e03SGreg Ungerer 	&__clk_0_28, /* tmr.1 */
163*f86b9e03SGreg Ungerer 	&__clk_0_29, /* tmr.2 */
164*f86b9e03SGreg Ungerer 	&__clk_0_30, /* tmr.2 */
165*f86b9e03SGreg Ungerer 	&__clk_0_31, /* tmr.3 */
166*f86b9e03SGreg Ungerer 	&__clk_0_32, /* pit.0 */
167*f86b9e03SGreg Ungerer 	&__clk_0_34, /* pit.2 */
168*f86b9e03SGreg Ungerer 	&__clk_0_35, /* pit.3 */
169*f86b9e03SGreg Ungerer 	&__clk_0_38, /* adc */
170*f86b9e03SGreg Ungerer 	&__clk_0_39, /* dac */
171*f86b9e03SGreg Ungerer 	&__clk_0_44, /* usb otg */
172*f86b9e03SGreg Ungerer 	&__clk_0_45, /* usb host */
173*f86b9e03SGreg Ungerer 	&__clk_0_47, /* ssi.0 */
174*f86b9e03SGreg Ungerer 	&__clk_0_49, /* rng */
175*f86b9e03SGreg Ungerer 	&__clk_0_50, /* ssi.1 */
176*f86b9e03SGreg Ungerer 	&__clk_0_51, /* eSDHC */
177*f86b9e03SGreg Ungerer 	&__clk_0_53, /* enet-fec */
178*f86b9e03SGreg Ungerer 	&__clk_0_54, /* enet-fec */
179*f86b9e03SGreg Ungerer 	&__clk_0_55, /* switch.0 */
180*f86b9e03SGreg Ungerer 	&__clk_0_56, /* switch.1 */
181*f86b9e03SGreg Ungerer 
182*f86b9e03SGreg Ungerer 	&__clk_1_2, /* 1-wire */
183*f86b9e03SGreg Ungerer 	&__clk_1_4, /* i2c.2 */
184*f86b9e03SGreg Ungerer 	&__clk_1_5, /* i2c.3 */
185*f86b9e03SGreg Ungerer 	&__clk_1_6, /* i2c.4 */
186*f86b9e03SGreg Ungerer 	&__clk_1_7, /* i2c.5 */
187*f86b9e03SGreg Ungerer 	&__clk_1_24, /* uart 4 */
188*f86b9e03SGreg Ungerer 	&__clk_1_25, /* uart 5 */
189*f86b9e03SGreg Ungerer 	&__clk_1_26, /* uart 6 */
190*f86b9e03SGreg Ungerer 	&__clk_1_27, /* uart 7 */
191*f86b9e03SGreg Ungerer 	&__clk_1_28, /* uart 8 */
192*f86b9e03SGreg Ungerer 	&__clk_1_29, /* uart 9 */
193*f86b9e03SGreg Ungerer };
194*f86b9e03SGreg Ungerer 
195*f86b9e03SGreg Ungerer static void __init m5441x_clk_init(void)
196*f86b9e03SGreg Ungerer {
197*f86b9e03SGreg Ungerer 	unsigned i;
198*f86b9e03SGreg Ungerer 
199*f86b9e03SGreg Ungerer 	for (i = 0; i < ARRAY_SIZE(enable_clks); ++i)
200*f86b9e03SGreg Ungerer 		__clk_init_enabled(enable_clks[i]);
201*f86b9e03SGreg Ungerer 	/* make sure these clocks are disabled */
202*f86b9e03SGreg Ungerer 	for (i = 0; i < ARRAY_SIZE(disable_clks); ++i)
203*f86b9e03SGreg Ungerer 		__clk_init_disabled(disable_clks[i]);
204*f86b9e03SGreg Ungerer }
205*f86b9e03SGreg Ungerer 
206*f86b9e03SGreg Ungerer static void __init m5441x_uarts_init(void)
207*f86b9e03SGreg Ungerer {
208*f86b9e03SGreg Ungerer 	__raw_writeb(0x0f, MCFGPIO_PAR_UART0);
209*f86b9e03SGreg Ungerer 	__raw_writeb(0x00, MCFGPIO_PAR_UART1);
210*f86b9e03SGreg Ungerer 	__raw_writeb(0x00, MCFGPIO_PAR_UART2);
211*f86b9e03SGreg Ungerer }
212*f86b9e03SGreg Ungerer 
213*f86b9e03SGreg Ungerer static void __init m5441x_fec_init(void)
214*f86b9e03SGreg Ungerer {
215*f86b9e03SGreg Ungerer 	__raw_writeb(0x03, MCFGPIO_PAR_FEC);
216*f86b9e03SGreg Ungerer }
217*f86b9e03SGreg Ungerer 
218*f86b9e03SGreg Ungerer void __init config_BSP(char *commandp, int size)
219*f86b9e03SGreg Ungerer {
220*f86b9e03SGreg Ungerer 	m5441x_clk_init();
221*f86b9e03SGreg Ungerer 	mach_sched_init = hw_timer_init;
222*f86b9e03SGreg Ungerer 	m5441x_uarts_init();
223*f86b9e03SGreg Ungerer 	m5441x_fec_init();
224*f86b9e03SGreg Ungerer }
225*f86b9e03SGreg Ungerer 
226*f86b9e03SGreg Ungerer 
227*f86b9e03SGreg Ungerer #if IS_ENABLED(CONFIG_RTC_DRV_M5441x)
228*f86b9e03SGreg Ungerer static struct resource m5441x_rtc_resources[] = {
229*f86b9e03SGreg Ungerer 	{
230*f86b9e03SGreg Ungerer 		.start		= MCFRTC_BASE,
231*f86b9e03SGreg Ungerer 		.end		= MCFRTC_BASE + MCFRTC_SIZE - 1,
232*f86b9e03SGreg Ungerer 		.flags		= IORESOURCE_MEM,
233*f86b9e03SGreg Ungerer 	},
234*f86b9e03SGreg Ungerer 	{
235*f86b9e03SGreg Ungerer 		.start		= MCF_IRQ_RTC,
236*f86b9e03SGreg Ungerer 		.end		= MCF_IRQ_RTC,
237*f86b9e03SGreg Ungerer 		.flags		= IORESOURCE_IRQ,
238*f86b9e03SGreg Ungerer 	},
239*f86b9e03SGreg Ungerer };
240*f86b9e03SGreg Ungerer 
241*f86b9e03SGreg Ungerer static struct platform_device m5441x_rtc = {
242*f86b9e03SGreg Ungerer 	.name			= "mcfrtc",
243*f86b9e03SGreg Ungerer 	.id			= 0,
244*f86b9e03SGreg Ungerer 	.resource		= m5441x_rtc_resources,
245*f86b9e03SGreg Ungerer 	.num_resources		= ARRAY_SIZE(m5441x_rtc_resources),
246*f86b9e03SGreg Ungerer };
247*f86b9e03SGreg Ungerer #endif
248*f86b9e03SGreg Ungerer 
249*f86b9e03SGreg Ungerer static struct platform_device *m5441x_devices[] __initdata = {
250*f86b9e03SGreg Ungerer #if IS_ENABLED(CONFIG_RTC_DRV_M5441x)
251*f86b9e03SGreg Ungerer 	&m5441x_rtc,
252*f86b9e03SGreg Ungerer #endif
253*f86b9e03SGreg Ungerer };
254*f86b9e03SGreg Ungerer 
255*f86b9e03SGreg Ungerer static int __init init_BSP(void)
256*f86b9e03SGreg Ungerer {
257*f86b9e03SGreg Ungerer 	platform_add_devices(m5441x_devices, ARRAY_SIZE(m5441x_devices));
258*f86b9e03SGreg Ungerer 	return 0;
259*f86b9e03SGreg Ungerer }
260*f86b9e03SGreg Ungerer 
261*f86b9e03SGreg Ungerer arch_initcall(init_BSP);
262