m68knommu: remove per device interrupt mask setting for ColdFire 520x
[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/io.h>
18 #include <asm/machdep.h>
19 #include <asm/coldfire.h>
20 #include <asm/mcfsim.h>
21 #include <asm/mcfuart.h>
22
23 /***************************************************************************/
24
25 static struct mcf_platform_uart m520x_uart_platform[] = {
26         {
27                 .mapbase        = MCF_MBAR + MCFUART_BASE1,
28                 .irq            = MCFINT_VECBASE + MCFINT_UART0,
29         },
30         {
31                 .mapbase        = MCF_MBAR + MCFUART_BASE2,
32                 .irq            = MCFINT_VECBASE + MCFINT_UART1,
33         },
34         {
35                 .mapbase        = MCF_MBAR + MCFUART_BASE3,
36                 .irq            = MCFINT_VECBASE + MCFINT_UART2,
37         },
38         { },
39 };
40
41 static struct platform_device m520x_uart = {
42         .name                   = "mcfuart",
43         .id                     = 0,
44         .dev.platform_data      = m520x_uart_platform,
45 };
46
47 static struct resource m520x_fec_resources[] = {
48         {
49                 .start          = MCF_MBAR + 0x30000,
50                 .end            = MCF_MBAR + 0x30000 + 0x7ff,
51                 .flags          = IORESOURCE_MEM,
52         },
53         {
54                 .start          = 64 + 36,
55                 .end            = 64 + 36,
56                 .flags          = IORESOURCE_IRQ,
57         },
58         {
59                 .start          = 64 + 40,
60                 .end            = 64 + 40,
61                 .flags          = IORESOURCE_IRQ,
62         },
63         {
64                 .start          = 64 + 42,
65                 .end            = 64 + 42,
66                 .flags          = IORESOURCE_IRQ,
67         },
68 };
69
70 static struct platform_device m520x_fec = {
71         .name                   = "fec",
72         .id                     = 0,
73         .num_resources          = ARRAY_SIZE(m520x_fec_resources),
74         .resource               = m520x_fec_resources,
75 };
76
77 static struct platform_device *m520x_devices[] __initdata = {
78         &m520x_uart,
79         &m520x_fec,
80 };
81
82 /***************************************************************************/
83
84 #define INTC0   (MCF_MBAR + MCFICM_INTC0)
85
86 static void __init m520x_uart_init_line(int line, int irq)
87 {
88         u16 par;
89         u8 par2;
90
91         writeb(0x03, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
92
93         switch (line) {
94         case 0:
95                 par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
96                 par |= MCF_GPIO_PAR_UART_PAR_UTXD0 |
97                        MCF_GPIO_PAR_UART_PAR_URXD0;
98                 writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
99                 break;
100         case 1:
101                 par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
102                 par |= MCF_GPIO_PAR_UART_PAR_UTXD1 |
103                        MCF_GPIO_PAR_UART_PAR_URXD1;
104                 writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
105                 break;
106         case 2:
107                 par2 = readb(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
108                 par2 &= ~0x0F;
109                 par2 |= MCF_GPIO_PAR_FECI2C_PAR_SCL_UTXD2 |
110                         MCF_GPIO_PAR_FECI2C_PAR_SDA_URXD2;
111                 writeb(par2, MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
112                 break;
113         }
114 }
115
116 static void __init m520x_uarts_init(void)
117 {
118         const int nrlines = ARRAY_SIZE(m520x_uart_platform);
119         int line;
120
121         for (line = 0; (line < nrlines); line++)
122                 m520x_uart_init_line(line, m520x_uart_platform[line].irq);
123 }
124
125 /***************************************************************************/
126
127 static void __init m520x_fec_init(void)
128 {
129         u8 v;
130
131         /* Unmask FEC interrupts at ColdFire interrupt controller */
132         writeb(0x4, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 36);
133         writeb(0x4, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 40);
134         writeb(0x4, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 42);
135
136         /* Set multi-function pins to ethernet mode */
137         v = readb(MCF_IPSBAR + MCF_GPIO_PAR_FEC);
138         writeb(v | 0xf0, MCF_IPSBAR + MCF_GPIO_PAR_FEC);
139
140         v = readb(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
141         writeb(v | 0x0f, MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
142 }
143
144 /***************************************************************************/
145
146 static void m520x_cpu_reset(void)
147 {
148         local_irq_disable();
149         __raw_writeb(MCF_RCR_SWRESET, MCF_RCR);
150 }
151
152 /***************************************************************************/
153
154 void __init config_BSP(char *commandp, int size)
155 {
156         mach_reset = m520x_cpu_reset;
157         m520x_uarts_init();
158         m520x_fec_init();
159 }
160
161 /***************************************************************************/
162
163 static int __init init_BSP(void)
164 {
165         platform_add_devices(m520x_devices, ARRAY_SIZE(m520x_devices));
166         return 0;
167 }
168
169 arch_initcall(init_BSP);
170
171 /***************************************************************************/