Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * linux/arch/m68knommu/platform/5249/config.c |
| 5 | * |
| 6 | * Copyright (C) 2002, Greg Ungerer (gerg@snapgear.com) |
| 7 | */ |
| 8 | |
| 9 | /***************************************************************************/ |
| 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/param.h> |
| 13 | #include <linux/init.h> |
Greg Ungerer | eaefd5f | 2007-02-07 12:03:19 +1000 | [diff] [blame] | 14 | #include <linux/interrupt.h> |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 15 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/machdep.h> |
| 17 | #include <asm/coldfire.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/mcfsim.h> |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 19 | #include <asm/mcfuart.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
| 21 | /***************************************************************************/ |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | void coldfire_reset(void); |
| 24 | |
| 25 | /***************************************************************************/ |
| 26 | |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 27 | static struct mcf_platform_uart m5249_uart_platform[] = { |
| 28 | { |
| 29 | .mapbase = MCF_MBAR + MCFUART_BASE1, |
| 30 | .irq = 73, |
| 31 | }, |
| 32 | { |
| 33 | .mapbase = MCF_MBAR + MCFUART_BASE2, |
| 34 | .irq = 74, |
| 35 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | }; |
| 37 | |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 38 | static struct platform_device m5249_uart = { |
| 39 | .name = "mcfuart", |
| 40 | .id = 0, |
| 41 | .dev.platform_data = m5249_uart_platform, |
| 42 | }; |
| 43 | |
| 44 | static struct platform_device *m5249_devices[] __initdata = { |
| 45 | &m5249_uart, |
| 46 | }; |
| 47 | |
| 48 | /***************************************************************************/ |
| 49 | |
| 50 | static void __init m5249_uart_init_line(int line, int irq) |
| 51 | { |
| 52 | if (line == 0) { |
| 53 | writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR); |
| 54 | writeb(irq, MCFUART_BASE1 + MCFUART_UIVR); |
| 55 | mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1); |
| 56 | } else if (line == 1) { |
| 57 | writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR); |
| 58 | writeb(irq, MCFUART_BASE2 + MCFUART_UIVR); |
| 59 | mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | static void __init m5249_uarts_init(void) |
| 64 | { |
| 65 | const int nrlines = ARRAY_SIZE(m5249_uart_platform); |
| 66 | int line; |
| 67 | |
| 68 | for (line = 0; (line < nrlines); line++) |
| 69 | m5249_uart_init_line(line, m5249_uart_platform[line].irq); |
| 70 | } |
| 71 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | /***************************************************************************/ |
| 74 | |
| 75 | void mcf_autovector(unsigned int vec) |
| 76 | { |
| 77 | volatile unsigned char *mbar; |
| 78 | |
| 79 | if ((vec >= 25) && (vec <= 31)) { |
| 80 | mbar = (volatile unsigned char *) MCF_MBAR; |
| 81 | vec = 0x1 << (vec - 24); |
| 82 | *(mbar + MCFSIM_AVR) |= vec; |
| 83 | mcf_setimr(mcf_getimr() & ~vec); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /***************************************************************************/ |
| 88 | |
| 89 | void mcf_settimericr(unsigned int timer, unsigned int level) |
| 90 | { |
| 91 | volatile unsigned char *icrp; |
| 92 | unsigned int icr, imr; |
| 93 | |
| 94 | if (timer <= 2) { |
| 95 | switch (timer) { |
| 96 | case 2: icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break; |
| 97 | default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break; |
| 98 | } |
| 99 | |
| 100 | icrp = (volatile unsigned char *) (MCF_MBAR + icr); |
| 101 | *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3; |
| 102 | mcf_setimr(mcf_getimr() & ~imr); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /***************************************************************************/ |
| 107 | |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 108 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | { |
| 110 | mcf_setimr(MCFSIM_IMR_MASKALL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | mach_reset = coldfire_reset; |
| 112 | } |
| 113 | |
| 114 | /***************************************************************************/ |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 115 | |
| 116 | static int __init init_BSP(void) |
| 117 | { |
| 118 | m5249_uarts_init(); |
| 119 | platform_add_devices(m5249_devices, ARRAY_SIZE(m5249_devices)); |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | arch_initcall(init_BSP); |
| 124 | |
| 125 | /***************************************************************************/ |