Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[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 platform_device *m5272_devices[] __initdata = {
59         &m5272_uart,
60 };
61
62 /***************************************************************************/
63
64 static void __init m5272_uart_init_line(int line, int irq)
65 {
66         u32 v;
67
68         if ((line >= 0) && (line < 2)) {
69                 v = (line) ? 0x0e000000 : 0xe0000000;
70                 writel(v, MCF_MBAR + MCFSIM_ICR2);
71
72                 /* Enable the output lines for the serial ports */
73                 v = readl(MCF_MBAR + MCFSIM_PBCNT);
74                 v = (v & ~0x000000ff) | 0x00000055;
75                 writel(v, MCF_MBAR + MCFSIM_PBCNT);
76
77                 v = readl(MCF_MBAR + MCFSIM_PDCNT);
78                 v = (v & ~0x000003fc) | 0x000002a8;
79                 writel(v, MCF_MBAR + MCFSIM_PDCNT);
80         }
81 }
82
83 static void __init m5272_uarts_init(void)
84 {
85         const int nrlines = ARRAY_SIZE(m5272_uart_platform);
86         int line;
87
88         for (line = 0; (line < nrlines); line++)
89                 m5272_uart_init_line(line, m5272_uart_platform[line].irq);
90 }
91
92 /***************************************************************************/
93
94 void mcf_disableall(void)
95 {
96         volatile unsigned long  *icrp;
97
98         icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
99         icrp[0] = 0x88888888;
100         icrp[1] = 0x88888888;
101         icrp[2] = 0x88888888;
102         icrp[3] = 0x88888888;
103 }
104
105 /***************************************************************************/
106
107 void mcf_autovector(unsigned int vec)
108 {
109         /* Everything is auto-vectored on the 5272 */
110 }
111
112 /***************************************************************************/
113
114 void mcf_settimericr(int timer, int level)
115 {
116         volatile unsigned long *icrp;
117
118         if ((timer >= 1 ) && (timer <= 4)) {
119                 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
120                 *icrp = (0x8 | level) << ((4 - timer) * 4);
121         }
122 }
123
124 /***************************************************************************/
125
126 void __init config_BSP(char *commandp, int size)
127 {
128 #if defined (CONFIG_MOD5272)
129         volatile unsigned char  *pivrp;
130
131         /* Set base of device vectors to be 64 */
132         pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR);
133         *pivrp = 0x40;
134 #endif
135
136         mcf_disableall();
137
138 #if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
139         /* Copy command line from FLASH to local buffer... */
140         memcpy(commandp, (char *) 0xf0004000, size);
141         commandp[size-1] = 0;
142 #elif defined(CONFIG_MTD_KeyTechnology)
143         /* Copy command line from FLASH to local buffer... */
144         memcpy(commandp, (char *) 0xffe06000, size);
145         commandp[size-1] = 0;
146 #elif defined(CONFIG_CANCam)
147         /* Copy command line from FLASH to local buffer... */
148         memcpy(commandp, (char *) 0xf0010000, size);
149         commandp[size-1] = 0;
150 #endif
151
152         mcf_timervector = 69;
153         mcf_profilevector = 70;
154         mach_reset = coldfire_reset;
155 }
156
157 /***************************************************************************/
158
159 static int __init init_BSP(void)
160 {
161         m5272_uarts_init();
162         platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices));
163         return 0;
164 }
165
166 arch_initcall(init_BSP);
167
168 /***************************************************************************/