1 /***************************************************************************/
4 * linux/arch/m68knommu/platform/528x/config.c
6 * Sub-architcture dependant initialization code for the Motorola
9 * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
10 * Copyright (C) 2001-2003, 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>
19 #include <linux/platform_device.h>
20 #include <linux/spi/spi.h>
21 #include <linux/spi/flash.h>
23 #include <asm/machdep.h>
24 #include <asm/coldfire.h>
25 #include <asm/mcfsim.h>
26 #include <asm/mcfuart.h>
28 #ifdef CONFIG_MTD_PARTITIONS
29 #include <linux/mtd/partitions.h>
32 /***************************************************************************/
34 void coldfire_reset(void);
36 /***************************************************************************/
38 static struct mcf_platform_uart m528x_uart_platform[] = {
40 .mapbase = MCF_MBAR + MCFUART_BASE1,
41 .irq = MCFINT_VECBASE + MCFINT_UART0,
44 .mapbase = MCF_MBAR + MCFUART_BASE2,
45 .irq = MCFINT_VECBASE + MCFINT_UART0 + 1,
48 .mapbase = MCF_MBAR + MCFUART_BASE3,
49 .irq = MCFINT_VECBASE + MCFINT_UART0 + 2,
54 static struct platform_device m528x_uart = {
57 .dev.platform_data = m528x_uart_platform,
60 static struct resource m528x_fec_resources[] = {
62 .start = MCF_MBAR + 0x1000,
63 .end = MCF_MBAR + 0x1000 + 0x7ff,
64 .flags = IORESOURCE_MEM,
69 .flags = IORESOURCE_IRQ,
74 .flags = IORESOURCE_IRQ,
79 .flags = IORESOURCE_IRQ,
83 static struct platform_device m528x_fec = {
86 .num_resources = ARRAY_SIZE(m528x_fec_resources),
87 .resource = m528x_fec_resources,
91 static struct platform_device *m528x_devices[] __initdata = {
96 /***************************************************************************/
98 #define INTC0 (MCF_MBAR + MCFICM_INTC0)
100 static void __init m528x_uart_init_line(int line, int irq)
105 if ((line < 0) || (line > 2))
108 /* level 6, line based priority */
109 writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
111 imr = readl(INTC0 + MCFINTC_IMRL);
112 imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
113 writel(imr, INTC0 + MCFINTC_IMRL);
115 /* make sure PUAPAR is set for UART0 and UART1 */
117 port = readb(MCF_MBAR + MCF5282_GPIO_PUAPAR);
118 port |= (0x03 << (line * 2));
119 writeb(port, MCF_MBAR + MCF5282_GPIO_PUAPAR);
123 static void __init m528x_uarts_init(void)
125 const int nrlines = ARRAY_SIZE(m528x_uart_platform);
128 for (line = 0; (line < nrlines); line++)
129 m528x_uart_init_line(line, m528x_uart_platform[line].irq);
132 /***************************************************************************/
134 static void __init m528x_fec_init(void)
139 /* Unmask FEC interrupts at ColdFire interrupt controller */
140 writeb(0x28, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 23);
141 writeb(0x27, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 27);
142 writeb(0x26, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 29);
144 imr = readl(MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
146 writel(imr, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
147 imr = readl(MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);
149 writel(imr, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);
151 /* Set multi-function pins to ethernet mode for fec0 */
152 v16 = readw(MCF_IPSBAR + 0x100056);
153 writew(v16 | 0xf00, MCF_IPSBAR + 0x100056);
154 writeb(0xc0, MCF_IPSBAR + 0x100058);
157 /***************************************************************************/
159 void mcf_disableall(void)
161 *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
162 *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
165 /***************************************************************************/
167 void mcf_autovector(unsigned int vec)
169 /* Everything is auto-vectored on the 5272 */
172 /***************************************************************************/
174 #ifdef CONFIG_WILDFIRE
175 void wildfire_halt(void)
177 writeb(0, 0x30000007);
178 writeb(0x2, 0x30000007);
182 #ifdef CONFIG_WILDFIREMOD
183 void wildfiremod_halt(void)
185 printk(KERN_INFO "WildFireMod hibernating...\n");
187 /* Set portE.5 to Digital IO */
188 MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2));
190 /* Make portE.5 an output */
191 MCF5282_GPIO_DDRE |= (1 << 5);
193 /* Now toggle portE.5 from low to high */
194 MCF5282_GPIO_PORTE &= ~(1 << 5);
195 MCF5282_GPIO_PORTE |= (1 << 5);
197 printk(KERN_EMERG "Failed to hibernate. Halting!\n");
201 void __init config_BSP(char *commandp, int size)
205 #ifdef CONFIG_WILDFIRE
206 mach_halt = wildfire_halt;
208 #ifdef CONFIG_WILDFIREMOD
209 mach_halt = wildfiremod_halt;
213 /***************************************************************************/
215 static int __init init_BSP(void)
219 platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices));
223 arch_initcall(init_BSP);
225 /***************************************************************************/