Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * linux/arch/m68knommu/platform/528x/config.c |
| 5 | * |
| 6 | * Sub-architcture dependant initialization code for the Motorola |
| 7 | * 5280 and 5282 CPUs. |
| 8 | * |
| 9 | * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com) |
| 10 | * Copyright (C) 2001-2003, 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 | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame^] | 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/spi/spi.h> |
| 21 | #include <linux/spi/flash.h> |
| 22 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <asm/machdep.h> |
| 24 | #include <asm/coldfire.h> |
| 25 | #include <asm/mcfsim.h> |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame^] | 26 | #include <asm/mcfuart.h> |
| 27 | #include <asm/mcfqspi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
| 29 | /***************************************************************************/ |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | void coldfire_reset(void); |
| 32 | |
| 33 | /***************************************************************************/ |
| 34 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame^] | 35 | static struct mcf_platform_uart m528x_uart_platform[] = { |
| 36 | { |
| 37 | .mapbase = MCF_MBAR + MCFUART_BASE1, |
| 38 | .irq = MCFINT_VECBASE + MCFINT_UART0, |
| 39 | }, |
| 40 | { |
| 41 | .mapbase = MCF_MBAR + MCFUART_BASE2, |
| 42 | .irq = MCFINT_VECBASE + MCFINT_UART0 + 1, |
| 43 | }, |
| 44 | { |
| 45 | .mapbase = MCF_MBAR + MCFUART_BASE3, |
| 46 | .irq = MCFINT_VECBASE + MCFINT_UART0 + 2, |
| 47 | }, |
| 48 | { }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame^] | 51 | static struct platform_device m528x_uart = { |
| 52 | .name = "mcfuart", |
| 53 | .id = 0, |
| 54 | .dev.platform_data = m528x_uart_platform, |
| 55 | }; |
| 56 | |
| 57 | static struct platform_device *m528x_devices[] __initdata = { |
| 58 | &m528x_uart, |
| 59 | }; |
| 60 | |
| 61 | /***************************************************************************/ |
| 62 | |
| 63 | #define INTC0 (MCF_MBAR + MCFICM_INTC0) |
| 64 | |
| 65 | static void __init m528x_uart_init_line(int line, int irq) |
| 66 | { |
| 67 | u8 port; |
| 68 | u32 imr; |
| 69 | |
| 70 | if ((line < 0) || (line > 2)) |
| 71 | return; |
| 72 | |
| 73 | /* level 6, line based priority */ |
| 74 | writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line); |
| 75 | |
| 76 | imr = readl(INTC0 + MCFINTC_IMRL); |
| 77 | imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1); |
| 78 | writel(imr, INTC0 + MCFINTC_IMRL); |
| 79 | |
| 80 | /* make sure PUAPAR is set for UART0 and UART1 */ |
| 81 | if (line < 2) { |
| 82 | port = readb(MCF_MBAR + MCF5282_GPIO_PUAPAR); |
| 83 | port |= (0x03 << (line * 2)); |
| 84 | writeb(port, MCF_MBAR + MCF5282_GPIO_PUAPAR); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | static void __init m528x_uarts_init(void) |
| 89 | { |
| 90 | const int nrlines = ARRAY_SIZE(m528x_uart_platform); |
| 91 | int line; |
| 92 | |
| 93 | for (line = 0; (line < nrlines); line++) |
| 94 | m528x_uart_init_line(line, m528x_uart_platform[line].irq); |
| 95 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | /***************************************************************************/ |
| 98 | |
| 99 | void mcf_disableall(void) |
| 100 | { |
| 101 | *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff; |
| 102 | *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff; |
| 103 | } |
| 104 | |
| 105 | /***************************************************************************/ |
| 106 | |
| 107 | void mcf_autovector(unsigned int vec) |
| 108 | { |
| 109 | /* Everything is auto-vectored on the 5272 */ |
| 110 | } |
| 111 | |
| 112 | /***************************************************************************/ |
| 113 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame^] | 114 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | { |
| 116 | mcf_disableall(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | mach_reset = coldfire_reset; |
| 118 | } |
| 119 | |
| 120 | /***************************************************************************/ |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame^] | 121 | |
| 122 | static int __init init_BSP(void) |
| 123 | { |
| 124 | m528x_uarts_init(); |
| 125 | platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices)); |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | arch_initcall(init_BSP); |
| 130 | |
| 131 | /***************************************************************************/ |