Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * linux/arch/m68knommu/platform/5206e/config.c |
| 5 | * |
| 6 | * Copyright (C) 1999-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> |
Greg Ungerer | cf64c23 | 2008-02-01 17:34:08 +1000 | [diff] [blame] | 13 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/interrupt.h> |
Greg Ungerer | cf64c23 | 2008-02-01 17:34:08 +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> |
| 19 | #include <asm/mcfdma.h> |
Steven King | 9333d82 | 2009-03-10 12:55:57 -0700 | [diff] [blame] | 20 | #include <asm/mcfuart.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | /***************************************************************************/ |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | void coldfire_reset(void); |
| 25 | |
| 26 | /***************************************************************************/ |
| 27 | |
Greg Ungerer | cf64c23 | 2008-02-01 17:34:08 +1000 | [diff] [blame] | 28 | static struct mcf_platform_uart m5206e_uart_platform[] = { |
| 29 | { |
| 30 | .mapbase = MCF_MBAR + MCFUART_BASE1, |
| 31 | .irq = 73, |
| 32 | }, |
| 33 | { |
| 34 | .mapbase = MCF_MBAR + MCFUART_BASE2, |
| 35 | .irq = 74, |
| 36 | }, |
| 37 | { }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
Greg Ungerer | cf64c23 | 2008-02-01 17:34:08 +1000 | [diff] [blame] | 40 | static struct platform_device m5206e_uart = { |
| 41 | .name = "mcfuart", |
| 42 | .id = 0, |
| 43 | .dev.platform_data = m5206e_uart_platform, |
| 44 | }; |
| 45 | |
| 46 | static struct platform_device *m5206e_devices[] __initdata = { |
| 47 | &m5206e_uart, |
| 48 | }; |
| 49 | |
| 50 | /***************************************************************************/ |
| 51 | |
Greg Ungerer | d259c32 | 2008-05-01 12:16:53 +1000 | [diff] [blame] | 52 | static void __init m5206e_uart_init_line(int line, int irq) |
Greg Ungerer | cf64c23 | 2008-02-01 17:34:08 +1000 | [diff] [blame] | 53 | { |
| 54 | if (line == 0) { |
| 55 | writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR); |
| 56 | writeb(irq, MCFUART_BASE1 + MCFUART_UIVR); |
| 57 | mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1); |
| 58 | } else if (line == 1) { |
| 59 | writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR); |
| 60 | writeb(irq, MCFUART_BASE2 + MCFUART_UIVR); |
| 61 | mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | static void __init m5206e_uarts_init(void) |
| 66 | { |
| 67 | const int nrlines = ARRAY_SIZE(m5206e_uart_platform); |
| 68 | int line; |
| 69 | |
| 70 | for (line = 0; (line < nrlines); line++) |
| 71 | m5206e_uart_init_line(line, m5206e_uart_platform[line].irq); |
| 72 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | /***************************************************************************/ |
| 75 | |
| 76 | void mcf_autovector(unsigned int vec) |
| 77 | { |
| 78 | volatile unsigned char *mbar; |
| 79 | unsigned char icr; |
| 80 | |
| 81 | if ((vec >= 25) && (vec <= 31)) { |
| 82 | vec -= 25; |
| 83 | mbar = (volatile unsigned char *) MCF_MBAR; |
| 84 | icr = MCFSIM_ICR_AUTOVEC | (vec << 3); |
| 85 | *(mbar + MCFSIM_ICR1 + vec) = icr; |
| 86 | vec = 0x1 << (vec + 1); |
| 87 | mcf_setimr(mcf_getimr() & ~vec); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /***************************************************************************/ |
| 92 | |
| 93 | void mcf_settimericr(unsigned int timer, unsigned int level) |
| 94 | { |
| 95 | volatile unsigned char *icrp; |
| 96 | unsigned int icr, imr; |
| 97 | |
| 98 | if (timer <= 2) { |
| 99 | switch (timer) { |
| 100 | case 2: icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break; |
| 101 | default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break; |
| 102 | } |
| 103 | |
| 104 | icrp = (volatile unsigned char *) (MCF_MBAR + icr); |
| 105 | *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3; |
| 106 | mcf_setimr(mcf_getimr() & ~imr); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | /***************************************************************************/ |
| 111 | |
Greg Ungerer | cf64c23 | 2008-02-01 17:34:08 +1000 | [diff] [blame] | 112 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | { |
| 114 | mcf_setimr(MCFSIM_IMR_MASKALL); |
| 115 | |
Greg Ungerer | bc72450 | 2007-07-25 22:07:20 +1000 | [diff] [blame] | 116 | #if defined(CONFIG_NETtel) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | /* Copy command line from FLASH to local buffer... */ |
| 118 | memcpy(commandp, (char *) 0xf0004000, size); |
| 119 | commandp[size-1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | #endif /* CONFIG_NETtel */ |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | mach_reset = coldfire_reset; |
| 123 | } |
| 124 | |
| 125 | /***************************************************************************/ |
Greg Ungerer | cf64c23 | 2008-02-01 17:34:08 +1000 | [diff] [blame] | 126 | |
| 127 | static int __init init_BSP(void) |
| 128 | { |
| 129 | m5206e_uarts_init(); |
| 130 | platform_add_devices(m5206e_devices, ARRAY_SIZE(m5206e_devices)); |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | arch_initcall(init_BSP); |
| 135 | |
| 136 | /***************************************************************************/ |