]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/m68knommu/platform/528x/config.c
Merge branch 'topic/docbook-fix' into for-linus
[linux-2.6-omap-h63xx.git] / arch / m68knommu / platform / 528x / config.c
1 /***************************************************************************/
2
3 /*
4  *      linux/arch/m68knommu/platform/528x/config.c
5  *
6  *      Sub-architcture dependant initialization code for the Motorola
7  *      5280 and 5282 CPUs.
8  *
9  *      Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
10  *      Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
11  */
12
13 /***************************************************************************/
14
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>
22 #include <linux/io.h>
23 #include <asm/machdep.h>
24 #include <asm/coldfire.h>
25 #include <asm/mcfsim.h>
26 #include <asm/mcfuart.h>
27
28 #ifdef CONFIG_MTD_PARTITIONS
29 #include <linux/mtd/partitions.h>
30 #endif
31
32 /***************************************************************************/
33
34 void coldfire_reset(void);
35
36 /***************************************************************************/
37
38 static struct mcf_platform_uart m528x_uart_platform[] = {
39         {
40                 .mapbase        = MCF_MBAR + MCFUART_BASE1,
41                 .irq            = MCFINT_VECBASE + MCFINT_UART0,
42         },
43         {
44                 .mapbase        = MCF_MBAR + MCFUART_BASE2,
45                 .irq            = MCFINT_VECBASE + MCFINT_UART0 + 1,
46         },
47         {
48                 .mapbase        = MCF_MBAR + MCFUART_BASE3,
49                 .irq            = MCFINT_VECBASE + MCFINT_UART0 + 2,
50         },
51         { },
52 };
53
54 static struct platform_device m528x_uart = {
55         .name                   = "mcfuart",
56         .id                     = 0,
57         .dev.platform_data      = m528x_uart_platform,
58 };
59
60 static struct platform_device *m528x_devices[] __initdata = {
61         &m528x_uart,
62 };
63
64 /***************************************************************************/
65
66 #define INTC0   (MCF_MBAR + MCFICM_INTC0)
67
68 static void __init m528x_uart_init_line(int line, int irq)
69 {
70         u8 port;
71         u32 imr;
72
73         if ((line < 0) || (line > 2))
74                 return;
75
76         /* level 6, line based priority */
77         writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
78
79         imr = readl(INTC0 + MCFINTC_IMRL);
80         imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
81         writel(imr, INTC0 + MCFINTC_IMRL);
82
83         /* make sure PUAPAR is set for UART0 and UART1 */
84         if (line < 2) {
85                 port = readb(MCF_MBAR + MCF5282_GPIO_PUAPAR);
86                 port |= (0x03 << (line * 2));
87                 writeb(port, MCF_MBAR + MCF5282_GPIO_PUAPAR);
88         }
89 }
90
91 static void __init m528x_uarts_init(void)
92 {
93         const int nrlines = ARRAY_SIZE(m528x_uart_platform);
94         int line;
95
96         for (line = 0; (line < nrlines); line++)
97                 m528x_uart_init_line(line, m528x_uart_platform[line].irq);
98 }
99
100 /***************************************************************************/
101
102 void mcf_disableall(void)
103 {
104         *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
105         *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
106 }
107
108 /***************************************************************************/
109
110 void mcf_autovector(unsigned int vec)
111 {
112         /* Everything is auto-vectored on the 5272 */
113 }
114
115 /***************************************************************************/
116
117 #ifdef CONFIG_WILDFIRE
118 void wildfire_halt(void)
119 {
120         writeb(0, 0x30000007);
121         writeb(0x2, 0x30000007);
122 }
123 #endif
124
125 #ifdef CONFIG_WILDFIREMOD
126 void wildfiremod_halt(void)
127 {
128         printk(KERN_INFO "WildFireMod hibernating...\n");
129
130         /* Set portE.5 to Digital IO */
131         MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2));
132
133         /* Make portE.5 an output */
134         MCF5282_GPIO_DDRE |= (1 << 5);
135
136         /* Now toggle portE.5 from low to high */
137         MCF5282_GPIO_PORTE &= ~(1 << 5);
138         MCF5282_GPIO_PORTE |= (1 << 5);
139
140         printk(KERN_EMERG "Failed to hibernate. Halting!\n");
141 }
142 #endif
143
144 void __init config_BSP(char *commandp, int size)
145 {
146         mcf_disableall();
147
148 #ifdef CONFIG_WILDFIRE
149         mach_halt = wildfire_halt;
150 #endif
151 #ifdef CONFIG_WILDFIREMOD
152         mach_halt = wildfiremod_halt;
153 #endif
154 }
155
156 /***************************************************************************/
157
158 static int __init init_BSP(void)
159 {
160         m528x_uarts_init();
161         platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices));
162         return 0;
163 }
164
165 arch_initcall(init_BSP);
166
167 /***************************************************************************/