Merge branch 'linus' into locking-for-linus
[sfrench/cifs-2.6.git] / arch / m68knommu / platform / 523x / config.c
1 /***************************************************************************/
2
3 /*
4  *      linux/arch/m68knommu/platform/523x/config.c
5  *
6  *      Sub-architcture dependant initialization code for the Freescale
7  *      523x CPUs.
8  *
9  *      Copyright (C) 1999-2005, 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/io.h>
20 #include <asm/machdep.h>
21 #include <asm/coldfire.h>
22 #include <asm/mcfsim.h>
23 #include <asm/mcfuart.h>
24
25 /***************************************************************************/
26
27 void coldfire_reset(void);
28
29 /***************************************************************************/
30
31 static struct mcf_platform_uart m523x_uart_platform[] = {
32         {
33                 .mapbase        = MCF_MBAR + MCFUART_BASE1,
34                 .irq            = MCFINT_VECBASE + MCFINT_UART0,
35         },
36         {
37                 .mapbase        = MCF_MBAR + MCFUART_BASE2,
38                 .irq            = MCFINT_VECBASE + MCFINT_UART0 + 1,
39         },
40         {
41                 .mapbase        = MCF_MBAR + MCFUART_BASE3,
42                 .irq            = MCFINT_VECBASE + MCFINT_UART0 + 2,
43         },
44         { },
45 };
46
47 static struct platform_device m523x_uart = {
48         .name                   = "mcfuart",
49         .id                     = 0,
50         .dev.platform_data      = m523x_uart_platform,
51 };
52
53 static struct resource m523x_fec_resources[] = {
54         {
55                 .start          = MCF_MBAR + 0x1000,
56                 .end            = MCF_MBAR + 0x1000 + 0x7ff,
57                 .flags          = IORESOURCE_MEM,
58         },
59         {
60                 .start          = 64 + 23,
61                 .end            = 64 + 23,
62                 .flags          = IORESOURCE_IRQ,
63         },
64         {
65                 .start          = 64 + 27,
66                 .end            = 64 + 27,
67                 .flags          = IORESOURCE_IRQ,
68         },
69         {
70                 .start          = 64 + 29,
71                 .end            = 64 + 29,
72                 .flags          = IORESOURCE_IRQ,
73         },
74 };
75
76 static struct platform_device m523x_fec = {
77         .name                   = "fec",
78         .id                     = 0,
79         .num_resources          = ARRAY_SIZE(m523x_fec_resources),
80         .resource               = m523x_fec_resources,
81 };
82
83 static struct platform_device *m523x_devices[] __initdata = {
84         &m523x_uart,
85         &m523x_fec,
86 };
87
88 /***************************************************************************/
89
90 #define INTC0   (MCF_MBAR + MCFICM_INTC0)
91
92 static void __init m523x_uart_init_line(int line, int irq)
93 {
94         u32 imr;
95
96         if ((line < 0) || (line > 2))
97                 return;
98
99         writeb(0x30+line, (INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line));
100
101         imr = readl(INTC0 + MCFINTC_IMRL);
102         imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
103         writel(imr, INTC0 + MCFINTC_IMRL);
104 }
105
106 static void __init m523x_uarts_init(void)
107 {
108         const int nrlines = ARRAY_SIZE(m523x_uart_platform);
109         int line;
110
111         for (line = 0; (line < nrlines); line++)
112                 m523x_uart_init_line(line, m523x_uart_platform[line].irq);
113 }
114
115 /***************************************************************************/
116
117 static void __init m523x_fec_init(void)
118 {
119         u32 imr;
120
121         /* Unmask FEC interrupts at ColdFire interrupt controller */
122         writeb(0x28, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 23);
123         writeb(0x27, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 27);
124         writeb(0x26, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 29);
125
126         imr = readl(MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
127         imr &= ~0xf;
128         writel(imr, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
129         imr = readl(MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);
130         imr &= ~0xff800001;
131         writel(imr, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);
132 }
133
134 /***************************************************************************/
135
136 void mcf_disableall(void)
137 {
138         *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
139         *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
140 }
141
142 /***************************************************************************/
143
144 void mcf_autovector(unsigned int vec)
145 {
146         /* Everything is auto-vectored on the 523x */
147 }
148
149 /***************************************************************************/
150
151 void __init config_BSP(char *commandp, int size)
152 {
153         mcf_disableall();
154         mach_reset = coldfire_reset;
155         m523x_uarts_init();
156         m523x_fec_init();
157 }
158
159 /***************************************************************************/
160
161 static int __init init_BSP(void)
162 {
163         platform_add_devices(m523x_devices, ARRAY_SIZE(m523x_devices));
164         return 0;
165 }
166
167 arch_initcall(init_BSP);
168
169 /***************************************************************************/