m68knommu: fix 5407 ColdFire UART vector setup
[linux-2.6/linux-2.6-openrd.git] / arch / m68knommu / platform / 5407 / config.c
blob0ee8c1a200c87d5a4cad4e5e76421526fe947f1e
1 /***************************************************************************/
3 /*
4 * linux/arch/m68knommu/platform/5407/config.c
6 * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
7 * Copyright (C) 2000, Lineo (www.lineo.com)
8 */
10 /***************************************************************************/
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>
22 /***************************************************************************/
24 void coldfire_reset(void);
26 extern unsigned int mcf_timervector;
27 extern unsigned int mcf_profilevector;
28 extern unsigned int mcf_timerlevel;
30 /***************************************************************************/
32 static struct mcf_platform_uart m5407_uart_platform[] = {
34 .mapbase = MCF_MBAR + MCFUART_BASE1,
35 .irq = 73,
38 .mapbase = MCF_MBAR + MCFUART_BASE2,
39 .irq = 74,
41 { },
44 static struct platform_device m5407_uart = {
45 .name = "mcfuart",
46 .id = 0,
47 .dev.platform_data = m5407_uart_platform,
50 static struct platform_device *m5407_devices[] __initdata = {
51 &m5407_uart,
54 /***************************************************************************/
56 static void __init m5407_uart_init_line(int line, int irq)
58 if (line == 0) {
59 writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
60 writeb(irq, MCF_MBAR + MCFUART_BASE1 + MCFUART_UIVR);
61 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
62 } else if (line == 1) {
63 writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR);
64 writeb(irq, MCF_MBAR + MCFUART_BASE2 + MCFUART_UIVR);
65 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
69 static void __init m5407_uarts_init(void)
71 const int nrlines = ARRAY_SIZE(m5407_uart_platform);
72 int line;
74 for (line = 0; (line < nrlines); line++)
75 m5407_uart_init_line(line, m5407_uart_platform[line].irq);
78 /***************************************************************************/
80 void mcf_autovector(unsigned int vec)
82 volatile unsigned char *mbar;
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);
92 /***************************************************************************/
94 void mcf_settimericr(unsigned int timer, unsigned int level)
96 volatile unsigned char *icrp;
97 unsigned int icr, imr;
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;
105 icrp = (volatile unsigned char *) (MCF_MBAR + icr);
106 *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
107 mcf_setimr(mcf_getimr() & ~imr);
111 /***************************************************************************/
113 void __init config_BSP(char *commandp, int size)
115 mcf_setimr(MCFSIM_IMR_MASKALL);
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
124 mach_reset = coldfire_reset;
127 /***************************************************************************/
129 static int __init init_BSP(void)
131 m5407_uarts_init();
132 platform_add_devices(m5407_devices, ARRAY_SIZE(m5407_devices));
133 return 0;
136 arch_initcall(init_BSP);
138 /***************************************************************************/