Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.git] / arch / m68knommu / platform / 5272 / config.c
1 /***************************************************************************/
2
3 /*
4  *      linux/arch/m68knommu/platform/5272/config.c
5  *
6  *      Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
7  *      Copyright (C) 2001-2002, SnapGear Inc. (www.snapgear.com)
8  */
9
10 /***************************************************************************/
11
12 #include <linux/kernel.h>
13 #include <linux/param.h>
14 #include <linux/init.h>
15 #include <linux/interrupt.h>
16 #include <linux/io.h>
17 #include <asm/machdep.h>
18 #include <asm/coldfire.h>
19 #include <asm/mcfsim.h>
20 #include <asm/mcfuart.h>
21
22 /***************************************************************************/
23
24 void coldfire_reset(void);
25
26 extern unsigned int mcf_timervector;
27 extern unsigned int mcf_profilevector;
28 extern unsigned int mcf_timerlevel;
29
30 /***************************************************************************/
31
32 /*
33  *      Some platforms need software versions of the GPIO data registers.
34  */
35 unsigned short ppdata;
36 unsigned char ledbank = 0xff;
37
38 /***************************************************************************/
39
40 static struct mcf_platform_uart m5272_uart_platform[] = {
41         {
42                 .mapbase        = MCF_MBAR + MCFUART_BASE1,
43                 .irq            = 73,
44         },
45         {
46                 .mapbase        = MCF_MBAR + MCFUART_BASE2,
47                 .irq            = 74,
48         },
49         { },
50 };
51
52 static struct platform_device m5272_uart = {
53         .name                   = "mcfuart",
54         .id                     = 0,
55         .dev.platform_data      = m5272_uart_platform,
56 };
57
58 static struct resource m5272_fec_resources[] = {
59         {
60                 .start          = MCF_MBAR + 0x840,
61                 .end            = MCF_MBAR + 0x840 + 0x1cf,
62                 .flags          = IORESOURCE_MEM,
63         },
64         {
65                 .start          = 86,
66                 .end            = 86,
67                 .flags          = IORESOURCE_IRQ,
68         },
69         {
70                 .start          = 87,
71                 .end            = 87,
72                 .flags          = IORESOURCE_IRQ,
73         },
74         {
75                 .start          = 88,
76                 .end            = 88,
77                 .flags          = IORESOURCE_IRQ,
78         },
79 };
80
81 static struct platform_device m5272_fec = {
82         .name                   = "fec",
83         .id                     = 0,
84         .num_resources          = ARRAY_SIZE(m5272_fec_resources),
85         .resource               = m5272_fec_resources,
86 };
87
88 static struct platform_device *m5272_devices[] __initdata = {
89         &m5272_uart,
90         &m5272_fec,
91 };
92
93 /***************************************************************************/
94
95 static void __init m5272_uart_init_line(int line, int irq)
96 {
97         u32 v;
98
99         if ((line >= 0) && (line < 2)) {
100                 v = (line) ? 0x0e000000 : 0xe0000000;
101                 writel(v, MCF_MBAR + MCFSIM_ICR2);
102
103                 /* Enable the output lines for the serial ports */
104                 v = readl(MCF_MBAR + MCFSIM_PBCNT);
105                 v = (v & ~0x000000ff) | 0x00000055;
106                 writel(v, MCF_MBAR + MCFSIM_PBCNT);
107
108                 v = readl(MCF_MBAR + MCFSIM_PDCNT);
109                 v = (v & ~0x000003fc) | 0x000002a8;
110                 writel(v, MCF_MBAR + MCFSIM_PDCNT);
111         }
112 }
113
114 static void __init m5272_uarts_init(void)
115 {
116         const int nrlines = ARRAY_SIZE(m5272_uart_platform);
117         int line;
118
119         for (line = 0; (line < nrlines); line++)
120                 m5272_uart_init_line(line, m5272_uart_platform[line].irq);
121 }
122
123 /***************************************************************************/
124
125 static void __init m5272_fec_init(void)
126 {
127         u32 imr;
128
129         /* Unmask FEC interrupts at ColdFire interrupt controller */
130         imr = readl(MCF_MBAR + MCFSIM_ICR3);
131         imr = (imr & ~0x00000fff) | 0x00000ddd;
132         writel(imr, MCF_MBAR + MCFSIM_ICR3);
133
134         imr = readl(MCF_MBAR + MCFSIM_ICR1);
135         imr = (imr & ~0x0f000000) | 0x0d000000;
136         writel(imr, MCF_MBAR + MCFSIM_ICR1);
137 }
138
139 /***************************************************************************/
140
141 void mcf_disableall(void)
142 {
143         volatile unsigned long  *icrp;
144
145         icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
146         icrp[0] = 0x88888888;
147         icrp[1] = 0x88888888;
148         icrp[2] = 0x88888888;
149         icrp[3] = 0x88888888;
150 }
151
152 /***************************************************************************/
153
154 void mcf_autovector(unsigned int vec)
155 {
156         /* Everything is auto-vectored on the 5272 */
157 }
158
159 /***************************************************************************/
160
161 void mcf_settimericr(int timer, int level)
162 {
163         volatile unsigned long *icrp;
164
165         if ((timer >= 1 ) && (timer <= 4)) {
166                 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
167                 *icrp = (0x8 | level) << ((4 - timer) * 4);
168         }
169 }
170
171 /***************************************************************************/
172
173 void __init config_BSP(char *commandp, int size)
174 {
175 #if defined (CONFIG_MOD5272)
176         volatile unsigned char  *pivrp;
177
178         /* Set base of device vectors to be 64 */
179         pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR);
180         *pivrp = 0x40;
181 #endif
182
183         mcf_disableall();
184
185 #if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
186         /* Copy command line from FLASH to local buffer... */
187         memcpy(commandp, (char *) 0xf0004000, size);
188         commandp[size-1] = 0;
189 #elif defined(CONFIG_CANCam)
190         /* Copy command line from FLASH to local buffer... */
191         memcpy(commandp, (char *) 0xf0010000, size);
192         commandp[size-1] = 0;
193 #endif
194
195         mcf_timervector = 69;
196         mcf_profilevector = 70;
197         mach_reset = coldfire_reset;
198 }
199
200 /***************************************************************************/
201
202 static int __init init_BSP(void)
203 {
204         m5272_uarts_init();
205         m5272_fec_init();
206         platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices));
207         return 0;
208 }
209
210 arch_initcall(init_BSP);
211
212 /***************************************************************************/