1 /***************************************************************************/
4 * linux/arch/m68knommu/platform/527x/config.c
6 * Sub-architcture dependant initialization code for the Freescale
9 * Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com)
10 * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com)
13 /***************************************************************************/
15 #include <linux/kernel.h>
16 #include <linux/param.h>
17 #include <linux/init.h>
18 #include <linux/interrupt.h>
20 #include <asm/machdep.h>
21 #include <asm/coldfire.h>
22 #include <asm/mcfsim.h>
23 #include <asm/mcfuart.h>
25 /***************************************************************************/
27 void coldfire_reset(void);
29 /***************************************************************************/
31 static struct mcf_platform_uart m527x_uart_platform[] = {
33 .mapbase = MCF_MBAR + MCFUART_BASE1,
34 .irq = MCFINT_VECBASE + MCFINT_UART0,
37 .mapbase = MCF_MBAR + MCFUART_BASE2,
38 .irq = MCFINT_VECBASE + MCFINT_UART1,
41 .mapbase = MCF_MBAR + MCFUART_BASE3,
42 .irq = MCFINT_VECBASE + MCFINT_UART2,
47 static struct platform_device m527x_uart = {
50 .dev.platform_data = m527x_uart_platform,
53 static struct resource m527x_fec0_resources[] = {
55 .start = MCF_MBAR + 0x1000,
56 .end = MCF_MBAR + 0x1000 + 0x7ff,
57 .flags = IORESOURCE_MEM,
62 .flags = IORESOURCE_IRQ,
67 .flags = IORESOURCE_IRQ,
72 .flags = IORESOURCE_IRQ,
76 static struct resource m527x_fec1_resources[] = {
78 .start = MCF_MBAR + 0x1800,
79 .end = MCF_MBAR + 0x1800 + 0x7ff,
80 .flags = IORESOURCE_MEM,
85 .flags = IORESOURCE_IRQ,
90 .flags = IORESOURCE_IRQ,
95 .flags = IORESOURCE_IRQ,
99 static struct platform_device m527x_fec[] = {
103 .num_resources = ARRAY_SIZE(m527x_fec0_resources),
104 .resource = m527x_fec0_resources,
109 .num_resources = ARRAY_SIZE(m527x_fec1_resources),
110 .resource = m527x_fec1_resources,
114 static struct platform_device *m527x_devices[] __initdata = {
122 /***************************************************************************/
124 #define INTC0 (MCF_MBAR + MCFICM_INTC0)
126 static void __init m527x_uart_init_line(int line, int irq)
131 if ((line < 0) || (line > 2))
134 /* level 6, line based priority */
135 writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
137 imr = readl(INTC0 + MCFINTC_IMRL);
138 imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
139 writel(imr, INTC0 + MCFINTC_IMRL);
142 * External Pin Mask Setting & Enable External Pin for Interface
144 sepmask = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
146 sepmask |= UART0_ENABLE_MASK;
148 sepmask |= UART1_ENABLE_MASK;
150 sepmask |= UART2_ENABLE_MASK;
151 writew(sepmask, MCF_IPSBAR + MCF_GPIO_PAR_UART);
154 static void __init m527x_uarts_init(void)
156 const int nrlines = ARRAY_SIZE(m527x_uart_platform);
159 for (line = 0; (line < nrlines); line++)
160 m527x_uart_init_line(line, m527x_uart_platform[line].irq);
163 /***************************************************************************/
165 static void __init m527x_fec_irq_init(int nr)
170 base = MCF_IPSBAR + (nr ? MCFICM_INTC1 : MCFICM_INTC0);
172 writeb(0x28, base + MCFINTC_ICR0 + 23);
173 writeb(0x27, base + MCFINTC_ICR0 + 27);
174 writeb(0x26, base + MCFINTC_ICR0 + 29);
176 imr = readl(base + MCFINTC_IMRH);
178 writel(imr, base + MCFINTC_IMRH);
179 imr = readl(base + MCFINTC_IMRL);
181 writel(imr, base + MCFINTC_IMRL);
184 static void __init m527x_fec_init(void)
189 m527x_fec_irq_init(0);
191 /* Set multi-function pins to ethernet mode for fec0 */
192 par = readw(MCF_IPSBAR + 0x100082);
193 writew(par | 0xf00, MCF_IPSBAR + 0x100082);
194 v = readb(MCF_IPSBAR + 0x100078);
195 writeb(v | 0xc0, MCF_IPSBAR + 0x100078);
198 m527x_fec_irq_init(1);
200 /* Set multi-function pins to ethernet mode for fec1 */
201 par = readw(MCF_IPSBAR + 0x100082);
202 writew(par | 0xa0, MCF_IPSBAR + 0x100082);
203 v = readb(MCF_IPSBAR + 0x100079);
204 writeb(v | 0xc0, MCF_IPSBAR + 0x100079);
208 /***************************************************************************/
210 void mcf_disableall(void)
212 *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
213 *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
216 /***************************************************************************/
218 void mcf_autovector(unsigned int vec)
220 /* Everything is auto-vectored on the 5272 */
223 /***************************************************************************/
225 void __init config_BSP(char *commandp, int size)
228 mach_reset = coldfire_reset;
233 /***************************************************************************/
235 static int __init init_BSP(void)
237 platform_add_devices(m527x_devices, ARRAY_SIZE(m527x_devices));
241 arch_initcall(init_BSP);
243 /***************************************************************************/