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 static struct mcf_platform_uart m528x_uart_platform
[] = {
36 .mapbase
= MCF_MBAR
+ MCFUART_BASE1
,
37 .irq
= MCFINT_VECBASE
+ MCFINT_UART0
,
40 .mapbase
= MCF_MBAR
+ MCFUART_BASE2
,
41 .irq
= MCFINT_VECBASE
+ MCFINT_UART0
+ 1,
44 .mapbase
= MCF_MBAR
+ MCFUART_BASE3
,
45 .irq
= MCFINT_VECBASE
+ MCFINT_UART0
+ 2,
50 static struct platform_device m528x_uart
= {
53 .dev
.platform_data
= m528x_uart_platform
,
56 static struct resource m528x_fec_resources
[] = {
58 .start
= MCF_MBAR
+ 0x1000,
59 .end
= MCF_MBAR
+ 0x1000 + 0x7ff,
60 .flags
= IORESOURCE_MEM
,
65 .flags
= IORESOURCE_IRQ
,
70 .flags
= IORESOURCE_IRQ
,
75 .flags
= IORESOURCE_IRQ
,
79 static struct platform_device m528x_fec
= {
82 .num_resources
= ARRAY_SIZE(m528x_fec_resources
),
83 .resource
= m528x_fec_resources
,
87 static struct platform_device
*m528x_devices
[] __initdata
= {
92 /***************************************************************************/
94 #define INTC0 (MCF_MBAR + MCFICM_INTC0)
96 static void __init
m528x_uart_init_line(int line
, int irq
)
101 if ((line
< 0) || (line
> 2))
104 /* level 6, line based priority */
105 writeb(0x30+line
, INTC0
+ MCFINTC_ICR0
+ MCFINT_UART0
+ line
);
107 imr
= readl(INTC0
+ MCFINTC_IMRL
);
108 imr
&= ~((1 << (irq
- MCFINT_VECBASE
)) | 1);
109 writel(imr
, INTC0
+ MCFINTC_IMRL
);
111 /* make sure PUAPAR is set for UART0 and UART1 */
113 port
= readb(MCF_MBAR
+ MCF5282_GPIO_PUAPAR
);
114 port
|= (0x03 << (line
* 2));
115 writeb(port
, MCF_MBAR
+ MCF5282_GPIO_PUAPAR
);
119 static void __init
m528x_uarts_init(void)
121 const int nrlines
= ARRAY_SIZE(m528x_uart_platform
);
124 for (line
= 0; (line
< nrlines
); line
++)
125 m528x_uart_init_line(line
, m528x_uart_platform
[line
].irq
);
128 /***************************************************************************/
130 static void __init
m528x_fec_init(void)
135 /* Unmask FEC interrupts at ColdFire interrupt controller */
136 writeb(0x28, MCF_IPSBAR
+ MCFICM_INTC0
+ MCFINTC_ICR0
+ 23);
137 writeb(0x27, MCF_IPSBAR
+ MCFICM_INTC0
+ MCFINTC_ICR0
+ 27);
138 writeb(0x26, MCF_IPSBAR
+ MCFICM_INTC0
+ MCFINTC_ICR0
+ 29);
140 imr
= readl(MCF_IPSBAR
+ MCFICM_INTC0
+ MCFINTC_IMRH
);
142 writel(imr
, MCF_IPSBAR
+ MCFICM_INTC0
+ MCFINTC_IMRH
);
143 imr
= readl(MCF_IPSBAR
+ MCFICM_INTC0
+ MCFINTC_IMRL
);
145 writel(imr
, MCF_IPSBAR
+ MCFICM_INTC0
+ MCFINTC_IMRL
);
147 /* Set multi-function pins to ethernet mode for fec0 */
148 v16
= readw(MCF_IPSBAR
+ 0x100056);
149 writew(v16
| 0xf00, MCF_IPSBAR
+ 0x100056);
150 writeb(0xc0, MCF_IPSBAR
+ 0x100058);
153 /***************************************************************************/
155 void mcf_disableall(void)
157 *((volatile unsigned long *) (MCF_IPSBAR
+ MCFICM_INTC0
+ MCFINTC_IMRH
)) = 0xffffffff;
158 *((volatile unsigned long *) (MCF_IPSBAR
+ MCFICM_INTC0
+ MCFINTC_IMRL
)) = 0xffffffff;
161 /***************************************************************************/
163 void mcf_autovector(unsigned int vec
)
165 /* Everything is auto-vectored on the 5272 */
168 /***************************************************************************/
170 static void m528x_cpu_reset(void)
173 __raw_writeb(MCF_RCR_SWRESET
, MCF_IPSBAR
+ MCF_RCR
);
176 /***************************************************************************/
178 #ifdef CONFIG_WILDFIRE
179 void wildfire_halt(void)
181 writeb(0, 0x30000007);
182 writeb(0x2, 0x30000007);
186 #ifdef CONFIG_WILDFIREMOD
187 void wildfiremod_halt(void)
189 printk(KERN_INFO
"WildFireMod hibernating...\n");
191 /* Set portE.5 to Digital IO */
192 MCF5282_GPIO_PEPAR
&= ~(1 << (5 * 2));
194 /* Make portE.5 an output */
195 MCF5282_GPIO_DDRE
|= (1 << 5);
197 /* Now toggle portE.5 from low to high */
198 MCF5282_GPIO_PORTE
&= ~(1 << 5);
199 MCF5282_GPIO_PORTE
|= (1 << 5);
201 printk(KERN_EMERG
"Failed to hibernate. Halting!\n");
205 void __init
config_BSP(char *commandp
, int size
)
209 #ifdef CONFIG_WILDFIRE
210 mach_halt
= wildfire_halt
;
212 #ifdef CONFIG_WILDFIREMOD
213 mach_halt
= wildfiremod_halt
;
217 /***************************************************************************/
219 static int __init
init_BSP(void)
221 mach_reset
= m528x_cpu_reset
;
224 platform_add_devices(m528x_devices
, ARRAY_SIZE(m528x_devices
));
228 arch_initcall(init_BSP
);
230 /***************************************************************************/