Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * linux/arch/m68knommu/platform/527x/config.c |
| 5 | * |
| 6 | * Sub-architcture dependant initialization code for the Freescale |
| 7 | * 5270/5271 CPUs. |
| 8 | * |
| 9 | * Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com) |
| 10 | * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com) |
| 11 | */ |
| 12 | |
| 13 | /***************************************************************************/ |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/param.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/interrupt.h> |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 19 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/machdep.h> |
| 21 | #include <asm/coldfire.h> |
| 22 | #include <asm/mcfsim.h> |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 23 | #include <asm/mcfuart.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | /***************************************************************************/ |
| 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | void coldfire_reset(void); |
| 28 | |
| 29 | /***************************************************************************/ |
| 30 | |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 31 | static struct mcf_platform_uart m527x_uart_platform[] = { |
| 32 | { |
| 33 | .mapbase = MCF_MBAR + MCFUART_BASE1, |
| 34 | .irq = MCFINT_VECBASE + MCFINT_UART0, |
| 35 | }, |
| 36 | { |
| 37 | .mapbase = MCF_MBAR + MCFUART_BASE2, |
| 38 | .irq = MCFINT_VECBASE + MCFINT_UART1, |
| 39 | }, |
| 40 | { |
| 41 | .mapbase = MCF_MBAR + MCFUART_BASE3, |
| 42 | .irq = MCFINT_VECBASE + MCFINT_UART2, |
| 43 | }, |
| 44 | { }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 47 | static struct platform_device m527x_uart = { |
| 48 | .name = "mcfuart", |
| 49 | .id = 0, |
| 50 | .dev.platform_data = m527x_uart_platform, |
| 51 | }; |
| 52 | |
| 53 | static struct platform_device *m527x_devices[] __initdata = { |
| 54 | &m527x_uart, |
| 55 | }; |
| 56 | |
| 57 | /***************************************************************************/ |
| 58 | |
| 59 | #define INTC0 (MCF_MBAR + MCFICM_INTC0) |
| 60 | |
| 61 | static void __init m527x_uart_init_line(int line, int irq) |
| 62 | { |
| 63 | u16 sepmask; |
| 64 | u32 imr; |
| 65 | |
| 66 | if ((line < 0) || (line > 2)) |
| 67 | return; |
| 68 | |
| 69 | /* level 6, line based priority */ |
| 70 | writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line); |
| 71 | |
| 72 | imr = readl(INTC0 + MCFINTC_IMRL); |
| 73 | imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1); |
| 74 | writel(imr, INTC0 + MCFINTC_IMRL); |
| 75 | |
| 76 | /* |
| 77 | * External Pin Mask Setting & Enable External Pin for Interface |
| 78 | */ |
| 79 | sepmask = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART); |
| 80 | if (line == 0) |
| 81 | sepmask |= UART0_ENABLE_MASK; |
| 82 | else if (line == 1) |
| 83 | sepmask |= UART1_ENABLE_MASK; |
| 84 | else if (line == 2) |
| 85 | sepmask |= UART2_ENABLE_MASK; |
| 86 | writew(sepmask, MCF_IPSBAR + MCF_GPIO_PAR_UART); |
| 87 | } |
| 88 | |
| 89 | static void __init m527x_uarts_init(void) |
| 90 | { |
| 91 | const int nrlines = ARRAY_SIZE(m527x_uart_platform); |
| 92 | int line; |
| 93 | |
| 94 | for (line = 0; (line < nrlines); line++) |
| 95 | m527x_uart_init_line(line, m527x_uart_platform[line].irq); |
| 96 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
| 98 | /***************************************************************************/ |
| 99 | |
| 100 | void mcf_disableall(void) |
| 101 | { |
| 102 | *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff; |
| 103 | *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff; |
| 104 | } |
| 105 | |
| 106 | /***************************************************************************/ |
| 107 | |
| 108 | void mcf_autovector(unsigned int vec) |
| 109 | { |
| 110 | /* Everything is auto-vectored on the 5272 */ |
| 111 | } |
| 112 | |
| 113 | /***************************************************************************/ |
| 114 | |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 115 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | { |
| 117 | mcf_disableall(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | mach_reset = coldfire_reset; |
| 119 | } |
| 120 | |
| 121 | /***************************************************************************/ |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 122 | |
| 123 | static int __init init_BSP(void) |
| 124 | { |
| 125 | m527x_uarts_init(); |
| 126 | platform_add_devices(m527x_devices, ARRAY_SIZE(m527x_devices)); |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | arch_initcall(init_BSP); |
| 131 | |
| 132 | /***************************************************************************/ |