x86: fix ioapic bug again
[sfrench/cifs-2.6.git] / arch / m68knommu / platform / 5407 / config.c
1 /***************************************************************************/
2
3 /*
4  *      linux/arch/m68knommu/platform/5407/config.c
5  *
6  *      Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
7  *      Copyright (C) 2000, Lineo (www.lineo.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 static struct mcf_platform_uart m5407_uart_platform[] = {
33         {
34                 .mapbase        = MCF_MBAR + MCFUART_BASE1,
35                 .irq            = 73,
36         },
37         {
38                 .mapbase        = MCF_MBAR + MCFUART_BASE2,
39                 .irq            = 74,
40         },
41         { },
42 };
43
44 static struct platform_device m5407_uart = {
45         .name                   = "mcfuart",
46         .id                     = 0,
47         .dev.platform_data      = m5407_uart_platform,
48 };
49
50 static struct platform_device *m5407_devices[] __initdata = {
51         &m5407_uart,
52 };
53
54 /***************************************************************************/
55
56 static void __init m5407_uart_init_line(int line, int irq)
57 {
58         if (line == 0) {
59                 writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
60                 writeb(irq, MCFUART_BASE1 + MCFUART_UIVR);
61                 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
62         } else if (line == 1) {
63                 writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR);
64                 writeb(irq, MCFUART_BASE2 + MCFUART_UIVR);
65                 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
66         }
67 }
68
69 static void __init m5407_uarts_init(void)
70 {
71         const int nrlines = ARRAY_SIZE(m5407_uart_platform);
72         int line;
73
74         for (line = 0; (line < nrlines); line++)
75                 m5407_uart_init_line(line, m5407_uart_platform[line].irq);
76 }
77
78 /***************************************************************************/
79
80 void mcf_autovector(unsigned int vec)
81 {
82         volatile unsigned char  *mbar;
83
84         if ((vec >= 25) && (vec <= 31)) {
85                 mbar = (volatile unsigned char *) MCF_MBAR;
86                 vec = 0x1 << (vec - 24);
87                 *(mbar + MCFSIM_AVR) |= vec;
88                 mcf_setimr(mcf_getimr() & ~vec);
89         }
90 }
91
92 /***************************************************************************/
93
94 void mcf_settimericr(unsigned int timer, unsigned int level)
95 {
96         volatile unsigned char *icrp;
97         unsigned int icr, imr;
98
99         if (timer <= 2) {
100                 switch (timer) {
101                 case 2:  icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break;
102                 default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break;
103                 }
104
105                 icrp = (volatile unsigned char *) (MCF_MBAR + icr);
106                 *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
107                 mcf_setimr(mcf_getimr() & ~imr);
108         }
109 }
110
111 /***************************************************************************/
112
113 void __init config_BSP(char *commandp, int size)
114 {
115         mcf_setimr(MCFSIM_IMR_MASKALL);
116
117 #if defined(CONFIG_CLEOPATRA)
118         /* Different timer setup - to prevent device clash */
119         mcf_timervector = 30;
120         mcf_profilevector = 31;
121         mcf_timerlevel = 6;
122 #endif
123
124         mach_reset = coldfire_reset;
125 }
126
127 /***************************************************************************/
128
129 static int __init init_BSP(void)
130 {
131         m5407_uarts_init();
132         platform_add_devices(m5407_devices, ARRAY_SIZE(m5407_devices));
133         return 0;
134 }
135
136 arch_initcall(init_BSP);
137
138 /***************************************************************************/