Merge branch 'master' of git://git.kernel.org/pub/scm/fs/xfs/xfs
[pandora-kernel.git] / arch / m68knommu / platform / 520x / config.c
1 /***************************************************************************/
2
3 /*
4  *  linux/arch/m68knommu/platform/520x/config.c
5  *
6  *  Copyright (C) 2005,      Freescale (www.freescale.com)
7  *  Copyright (C) 2005,      Intec Automation (mike@steroidmicros.com)
8  *  Copyright (C) 1999-2007, Greg Ungerer (gerg@snapgear.com)
9  *  Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
10  */
11
12 /***************************************************************************/
13
14 #include <linux/kernel.h>
15 #include <linux/param.h>
16 #include <linux/init.h>
17 #include <linux/interrupt.h>
18 #include <linux/io.h>
19 #include <asm/machdep.h>
20 #include <asm/coldfire.h>
21 #include <asm/mcfsim.h>
22 #include <asm/mcfuart.h>
23
24 /***************************************************************************/
25
26 void coldfire_reset(void);
27
28 /***************************************************************************/
29
30 static struct mcf_platform_uart m520x_uart_platform[] = {
31         {
32                 .mapbase        = MCF_MBAR + MCFUART_BASE1,
33                 .irq            = MCFINT_VECBASE + MCFINT_UART0,
34         },
35         {
36                 .mapbase        = MCF_MBAR + MCFUART_BASE2,
37                 .irq            = MCFINT_VECBASE + MCFINT_UART1,
38         },
39         {
40                 .mapbase        = MCF_MBAR + MCFUART_BASE3,
41                 .irq            = MCFINT_VECBASE + MCFINT_UART2,
42         },
43         { },
44 };
45
46 static struct platform_device m520x_uart = {
47         .name                   = "mcfuart",
48         .id                     = 0,
49         .dev.platform_data      = m520x_uart_platform,
50 };
51
52 static struct resource m520x_fec_resources[] = {
53         {
54                 .start          = MCF_MBAR + 0x30000,
55                 .end            = MCF_MBAR + 0x30000 + 0x7ff,
56                 .flags          = IORESOURCE_MEM,
57         },
58         {
59                 .start          = 64 + 36,
60                 .end            = 64 + 36,
61                 .flags          = IORESOURCE_IRQ,
62         },
63         {
64                 .start          = 64 + 40,
65                 .end            = 64 + 40,
66                 .flags          = IORESOURCE_IRQ,
67         },
68         {
69                 .start          = 64 + 42,
70                 .end            = 64 + 42,
71                 .flags          = IORESOURCE_IRQ,
72         },
73 };
74
75 static struct platform_device m520x_fec = {
76         .name                   = "fec",
77         .id                     = 0,
78         .num_resources          = ARRAY_SIZE(m520x_fec_resources),
79         .resource               = m520x_fec_resources,
80 };
81
82 static struct platform_device *m520x_devices[] __initdata = {
83         &m520x_uart,
84         &m520x_fec,
85 };
86
87 /***************************************************************************/
88
89 #define INTC0   (MCF_MBAR + MCFICM_INTC0)
90
91 static void __init m520x_uart_init_line(int line, int irq)
92 {
93         u32 imr;
94         u16 par;
95         u8 par2;
96
97         writeb(0x03, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
98
99         imr = readl(INTC0 + MCFINTC_IMRL);
100         imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
101         writel(imr, INTC0 + MCFINTC_IMRL);
102
103         switch (line) {
104         case 0:
105                 par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
106                 par |= MCF_GPIO_PAR_UART_PAR_UTXD0 |
107                        MCF_GPIO_PAR_UART_PAR_URXD0;
108                 writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
109                 break;
110         case 1:
111                 par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
112                 par |= MCF_GPIO_PAR_UART_PAR_UTXD1 |
113                        MCF_GPIO_PAR_UART_PAR_URXD1;
114                 writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
115                 break;
116         case 2:
117                 par2 = readb(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
118                 par2 &= ~0x0F;
119                 par2 |= MCF_GPIO_PAR_FECI2C_PAR_SCL_UTXD2 |
120                         MCF_GPIO_PAR_FECI2C_PAR_SDA_URXD2;
121                 writeb(par2, MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
122                 break;
123         }
124 }
125
126 static void __init m520x_uarts_init(void)
127 {
128         const int nrlines = ARRAY_SIZE(m520x_uart_platform);
129         int line;
130
131         for (line = 0; (line < nrlines); line++)
132                 m520x_uart_init_line(line, m520x_uart_platform[line].irq);
133 }
134
135 /***************************************************************************/
136
137 static void __init m520x_fec_init(void)
138 {
139         u32 imr;
140         u8 v;
141
142         /* Unmask FEC interrupts at ColdFire interrupt controller */
143         writeb(0x4, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 36);
144         writeb(0x4, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 40);
145         writeb(0x4, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 42);
146
147         imr = readl(MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
148         imr &= ~0x0001FFF0;
149         writel(imr, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
150
151         /* Set multi-function pins to ethernet mode */
152         v = readb(MCF_IPSBAR + MCF_GPIO_PAR_FEC);
153         writeb(v | 0xf0, MCF_IPSBAR + MCF_GPIO_PAR_FEC);
154
155         v = readb(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
156         writeb(v | 0x0f, MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
157 }
158
159 /***************************************************************************/
160
161 /*
162  *  Program the vector to be an auto-vectored.
163  */
164
165 void mcf_autovector(unsigned int vec)
166 {
167     /* Everything is auto-vectored on the 520x devices */
168 }
169
170 /***************************************************************************/
171
172 void __init config_BSP(char *commandp, int size)
173 {
174         mach_reset = coldfire_reset;
175         m520x_uarts_init();
176         m520x_fec_init();
177 }
178
179 /***************************************************************************/
180
181 static int __init init_BSP(void)
182 {
183         platform_add_devices(m520x_devices, ARRAY_SIZE(m520x_devices));
184         return 0;
185 }
186
187 arch_initcall(init_BSP);
188
189 /***************************************************************************/