Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * linux/arch/m68knommu/platform/528x/config.c |
| 5 | * |
Greg Ungerer | 980f923 | 2009-04-28 14:24:25 +1000 | [diff] [blame^] | 6 | * Sub-architcture dependant initialization code for the Freescale |
| 7 | * 5280, 5281 and 5282 CPUs. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 18 | #include <linux/platform_device.h> |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +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 | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 23 | #include <asm/mcfuart.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | /***************************************************************************/ |
| 26 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 27 | static struct mcf_platform_uart m528x_uart_platform[] = { |
| 28 | { |
| 29 | .mapbase = MCF_MBAR + MCFUART_BASE1, |
| 30 | .irq = MCFINT_VECBASE + MCFINT_UART0, |
| 31 | }, |
| 32 | { |
| 33 | .mapbase = MCF_MBAR + MCFUART_BASE2, |
| 34 | .irq = MCFINT_VECBASE + MCFINT_UART0 + 1, |
| 35 | }, |
| 36 | { |
| 37 | .mapbase = MCF_MBAR + MCFUART_BASE3, |
| 38 | .irq = MCFINT_VECBASE + MCFINT_UART0 + 2, |
| 39 | }, |
| 40 | { }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 43 | static struct platform_device m528x_uart = { |
| 44 | .name = "mcfuart", |
| 45 | .id = 0, |
| 46 | .dev.platform_data = m528x_uart_platform, |
| 47 | }; |
| 48 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 49 | static struct resource m528x_fec_resources[] = { |
| 50 | { |
| 51 | .start = MCF_MBAR + 0x1000, |
| 52 | .end = MCF_MBAR + 0x1000 + 0x7ff, |
| 53 | .flags = IORESOURCE_MEM, |
| 54 | }, |
| 55 | { |
| 56 | .start = 64 + 23, |
| 57 | .end = 64 + 23, |
| 58 | .flags = IORESOURCE_IRQ, |
| 59 | }, |
| 60 | { |
| 61 | .start = 64 + 27, |
| 62 | .end = 64 + 27, |
| 63 | .flags = IORESOURCE_IRQ, |
| 64 | }, |
| 65 | { |
| 66 | .start = 64 + 29, |
| 67 | .end = 64 + 29, |
| 68 | .flags = IORESOURCE_IRQ, |
| 69 | }, |
| 70 | }; |
| 71 | |
| 72 | static struct platform_device m528x_fec = { |
| 73 | .name = "fec", |
| 74 | .id = 0, |
| 75 | .num_resources = ARRAY_SIZE(m528x_fec_resources), |
| 76 | .resource = m528x_fec_resources, |
| 77 | }; |
| 78 | |
| 79 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 80 | static struct platform_device *m528x_devices[] __initdata = { |
| 81 | &m528x_uart, |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 82 | &m528x_fec, |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | /***************************************************************************/ |
| 86 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 87 | static void __init m528x_uart_init_line(int line, int irq) |
| 88 | { |
| 89 | u8 port; |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 90 | |
| 91 | if ((line < 0) || (line > 2)) |
| 92 | return; |
| 93 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 94 | /* make sure PUAPAR is set for UART0 and UART1 */ |
| 95 | if (line < 2) { |
| 96 | port = readb(MCF_MBAR + MCF5282_GPIO_PUAPAR); |
| 97 | port |= (0x03 << (line * 2)); |
| 98 | writeb(port, MCF_MBAR + MCF5282_GPIO_PUAPAR); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | static void __init m528x_uarts_init(void) |
| 103 | { |
| 104 | const int nrlines = ARRAY_SIZE(m528x_uart_platform); |
| 105 | int line; |
| 106 | |
| 107 | for (line = 0; (line < nrlines); line++) |
| 108 | m528x_uart_init_line(line, m528x_uart_platform[line].irq); |
| 109 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
| 111 | /***************************************************************************/ |
| 112 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 113 | static void __init m528x_fec_init(void) |
| 114 | { |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 115 | u16 v16; |
| 116 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 117 | /* Set multi-function pins to ethernet mode for fec0 */ |
| 118 | v16 = readw(MCF_IPSBAR + 0x100056); |
| 119 | writew(v16 | 0xf00, MCF_IPSBAR + 0x100056); |
| 120 | writeb(0xc0, MCF_IPSBAR + 0x100058); |
| 121 | } |
| 122 | |
| 123 | /***************************************************************************/ |
| 124 | |
Greg Ungerer | dd65b1d | 2009-04-30 23:15:56 +1000 | [diff] [blame] | 125 | static void m528x_cpu_reset(void) |
| 126 | { |
| 127 | local_irq_disable(); |
| 128 | __raw_writeb(MCF_RCR_SWRESET, MCF_IPSBAR + MCF_RCR); |
| 129 | } |
| 130 | |
| 131 | /***************************************************************************/ |
| 132 | |
Steve Bennett | 188a9a4 | 2008-05-01 12:17:08 +1000 | [diff] [blame] | 133 | #ifdef CONFIG_WILDFIRE |
| 134 | void wildfire_halt(void) |
| 135 | { |
| 136 | writeb(0, 0x30000007); |
| 137 | writeb(0x2, 0x30000007); |
| 138 | } |
| 139 | #endif |
| 140 | |
| 141 | #ifdef CONFIG_WILDFIREMOD |
| 142 | void wildfiremod_halt(void) |
| 143 | { |
| 144 | printk(KERN_INFO "WildFireMod hibernating...\n"); |
| 145 | |
| 146 | /* Set portE.5 to Digital IO */ |
| 147 | MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2)); |
| 148 | |
| 149 | /* Make portE.5 an output */ |
| 150 | MCF5282_GPIO_DDRE |= (1 << 5); |
| 151 | |
| 152 | /* Now toggle portE.5 from low to high */ |
| 153 | MCF5282_GPIO_PORTE &= ~(1 << 5); |
| 154 | MCF5282_GPIO_PORTE |= (1 << 5); |
| 155 | |
| 156 | printk(KERN_EMERG "Failed to hibernate. Halting!\n"); |
| 157 | } |
| 158 | #endif |
| 159 | |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 160 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | { |
Steve Bennett | 188a9a4 | 2008-05-01 12:17:08 +1000 | [diff] [blame] | 162 | #ifdef CONFIG_WILDFIRE |
| 163 | mach_halt = wildfire_halt; |
| 164 | #endif |
| 165 | #ifdef CONFIG_WILDFIREMOD |
| 166 | mach_halt = wildfiremod_halt; |
| 167 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | /***************************************************************************/ |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 171 | |
| 172 | static int __init init_BSP(void) |
| 173 | { |
Greg Ungerer | dd65b1d | 2009-04-30 23:15:56 +1000 | [diff] [blame] | 174 | mach_reset = m528x_cpu_reset; |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 175 | m528x_uarts_init(); |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 176 | m528x_fec_init(); |
Greg Ungerer | eb49e90 | 2008-02-01 17:34:50 +1000 | [diff] [blame] | 177 | platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices)); |
| 178 | return 0; |
| 179 | } |
| 180 | |
| 181 | arch_initcall(init_BSP); |
| 182 | |
| 183 | /***************************************************************************/ |