Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ixp4xx/nslu2-setup.c |
| 3 | * |
| 4 | * NSLU2 board-setup |
| 5 | * |
| 6 | * based ixdp425-setup.c: |
| 7 | * Copyright (C) 2003-2004 MontaVista Software, Inc. |
| 8 | * |
| 9 | * Author: Mark Rakes <mrakes at mac.com> |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 10 | * Author: Rod Whitby <rod@whitby.id.au> |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 11 | * Maintainers: http://www.nslu2-linux.org/ |
| 12 | * |
| 13 | * Fixed missing init_time in MACHINE_START kas11 10/22/04 |
| 14 | * Changed to conform to new style __init ixdp425 kas11 10/22/04 |
| 15 | */ |
| 16 | |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 17 | #include <linux/if_ether.h> |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 18 | #include <linux/kernel.h> |
| 19 | #include <linux/serial.h> |
| 20 | #include <linux/serial_8250.h> |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 21 | #include <linux/leds.h> |
Rod Whitby | e28067d | 2008-01-29 00:36:12 +0100 | [diff] [blame] | 22 | #include <linux/i2c.h> |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 23 | #include <linux/i2c-gpio.h> |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 24 | |
| 25 | #include <asm/mach-types.h> |
| 26 | #include <asm/mach/arch.h> |
| 27 | #include <asm/mach/flash.h> |
Michael-Luke Jones | 435c5da | 2007-05-23 22:38:45 +0100 | [diff] [blame] | 28 | #include <asm/mach/time.h> |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 29 | #include <asm/io.h> |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 30 | |
| 31 | static struct flash_platform_data nslu2_flash_data = { |
| 32 | .map_name = "cfi_probe", |
| 33 | .width = 2, |
| 34 | }; |
| 35 | |
| 36 | static struct resource nslu2_flash_resource = { |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 37 | .flags = IORESOURCE_MEM, |
| 38 | }; |
| 39 | |
| 40 | static struct platform_device nslu2_flash = { |
| 41 | .name = "IXP4XX-Flash", |
| 42 | .id = 0, |
| 43 | .dev.platform_data = &nslu2_flash_data, |
| 44 | .num_resources = 1, |
| 45 | .resource = &nslu2_flash_resource, |
| 46 | }; |
| 47 | |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 48 | static struct i2c_gpio_platform_data nslu2_i2c_gpio_data = { |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 49 | .sda_pin = NSLU2_SDA_PIN, |
| 50 | .scl_pin = NSLU2_SCL_PIN, |
| 51 | }; |
| 52 | |
Rod Whitby | e28067d | 2008-01-29 00:36:12 +0100 | [diff] [blame] | 53 | static struct i2c_board_info __initdata nslu2_i2c_board_info [] = { |
| 54 | { |
| 55 | I2C_BOARD_INFO("rtc-x1205", 0x6f), |
| 56 | }, |
| 57 | }; |
| 58 | |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 59 | static struct gpio_led nslu2_led_pins[] = { |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 60 | { |
| 61 | .name = "ready", /* green led */ |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 62 | .gpio = NSLU2_LED_GRN_GPIO, |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 63 | }, |
| 64 | { |
| 65 | .name = "status", /* red led */ |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 66 | .gpio = NSLU2_LED_RED_GPIO, |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 67 | }, |
| 68 | { |
| 69 | .name = "disk-1", |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 70 | .gpio = NSLU2_LED_DISK1_GPIO, |
| 71 | .active_low = true, |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 72 | }, |
| 73 | { |
| 74 | .name = "disk-2", |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 75 | .gpio = NSLU2_LED_DISK2_GPIO, |
| 76 | .active_low = true, |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 77 | }, |
| 78 | }; |
| 79 | |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 80 | static struct gpio_led_platform_data nslu2_led_data = { |
| 81 | .num_leds = ARRAY_SIZE(nslu2_led_pins), |
| 82 | .leds = nslu2_led_pins, |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 83 | }; |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 84 | |
| 85 | static struct platform_device nslu2_leds = { |
| 86 | .name = "leds-gpio", |
| 87 | .id = -1, |
| 88 | .dev.platform_data = &nslu2_led_data, |
| 89 | }; |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 90 | |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 91 | static struct platform_device nslu2_i2c_gpio = { |
| 92 | .name = "i2c-gpio", |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 93 | .id = 0, |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 94 | .dev = { |
| 95 | .platform_data = &nslu2_i2c_gpio_data, |
| 96 | }, |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 97 | }; |
| 98 | |
Alessandro Zummo | bc66d44 | 2006-02-22 21:12:06 +0000 | [diff] [blame] | 99 | static struct platform_device nslu2_beeper = { |
| 100 | .name = "ixp4xx-beeper", |
| 101 | .id = NSLU2_GPIO_BUZZ, |
| 102 | .num_resources = 0, |
| 103 | }; |
| 104 | |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 105 | static struct resource nslu2_uart_resources[] = { |
| 106 | { |
| 107 | .start = IXP4XX_UART1_BASE_PHYS, |
| 108 | .end = IXP4XX_UART1_BASE_PHYS + 0x0fff, |
| 109 | .flags = IORESOURCE_MEM, |
| 110 | }, |
| 111 | { |
| 112 | .start = IXP4XX_UART2_BASE_PHYS, |
| 113 | .end = IXP4XX_UART2_BASE_PHYS + 0x0fff, |
| 114 | .flags = IORESOURCE_MEM, |
| 115 | } |
| 116 | }; |
| 117 | |
| 118 | static struct plat_serial8250_port nslu2_uart_data[] = { |
| 119 | { |
| 120 | .mapbase = IXP4XX_UART1_BASE_PHYS, |
| 121 | .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET, |
| 122 | .irq = IRQ_IXP4XX_UART1, |
| 123 | .flags = UPF_BOOT_AUTOCONF, |
| 124 | .iotype = UPIO_MEM, |
| 125 | .regshift = 2, |
| 126 | .uartclk = IXP4XX_UART_XTAL, |
| 127 | }, |
| 128 | { |
| 129 | .mapbase = IXP4XX_UART2_BASE_PHYS, |
| 130 | .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET, |
| 131 | .irq = IRQ_IXP4XX_UART2, |
| 132 | .flags = UPF_BOOT_AUTOCONF, |
| 133 | .iotype = UPIO_MEM, |
| 134 | .regshift = 2, |
| 135 | .uartclk = IXP4XX_UART_XTAL, |
| 136 | }, |
| 137 | { } |
| 138 | }; |
| 139 | |
| 140 | static struct platform_device nslu2_uart = { |
| 141 | .name = "serial8250", |
| 142 | .id = PLAT8250_DEV_PLATFORM, |
| 143 | .dev.platform_data = nslu2_uart_data, |
| 144 | .num_resources = 2, |
| 145 | .resource = nslu2_uart_resources, |
| 146 | }; |
| 147 | |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 148 | /* Built-in 10/100 Ethernet MAC interfaces */ |
| 149 | static struct eth_plat_info nslu2_plat_eth[] = { |
| 150 | { |
| 151 | .phy = 1, |
| 152 | .rxq = 3, |
| 153 | .txreadyq = 20, |
| 154 | } |
| 155 | }; |
| 156 | |
| 157 | static struct platform_device nslu2_eth[] = { |
| 158 | { |
| 159 | .name = "ixp4xx_eth", |
| 160 | .id = IXP4XX_ETH_NPEB, |
| 161 | .dev.platform_data = nslu2_plat_eth, |
| 162 | } |
| 163 | }; |
| 164 | |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 165 | static struct platform_device *nslu2_devices[] __initdata = { |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 166 | &nslu2_i2c_gpio, |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 167 | &nslu2_flash, |
Alessandro Zummo | bc66d44 | 2006-02-22 21:12:06 +0000 | [diff] [blame] | 168 | &nslu2_beeper, |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 169 | &nslu2_leds, |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 170 | &nslu2_eth[0], |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | static void nslu2_power_off(void) |
| 174 | { |
| 175 | /* This causes the box to drop the power and go dead. */ |
| 176 | |
| 177 | /* enable the pwr cntl gpio */ |
| 178 | gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT); |
| 179 | |
| 180 | /* do the deed */ |
| 181 | gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH); |
| 182 | } |
| 183 | |
Michael-Luke Jones | 435c5da | 2007-05-23 22:38:45 +0100 | [diff] [blame] | 184 | static void __init nslu2_timer_init(void) |
| 185 | { |
| 186 | /* The xtal on this machine is non-standard. */ |
| 187 | ixp4xx_timer_freq = NSLU2_FREQ; |
| 188 | |
| 189 | /* Call standard timer_init function. */ |
| 190 | ixp4xx_timer_init(); |
| 191 | } |
| 192 | |
| 193 | static struct sys_timer nslu2_timer = { |
| 194 | .init = nslu2_timer_init, |
| 195 | }; |
| 196 | |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 197 | static void __init nslu2_init(void) |
| 198 | { |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 199 | DECLARE_MAC_BUF(mac_buf); |
| 200 | uint8_t __iomem *f; |
| 201 | int i; |
| 202 | |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 203 | ixp4xx_sys_init(); |
| 204 | |
Martin Michlmayr | 3dfaf7a | 2006-02-16 22:36:12 +0000 | [diff] [blame] | 205 | nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); |
| 206 | nslu2_flash_resource.end = |
| 207 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; |
| 208 | |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 209 | pm_power_off = nslu2_power_off; |
| 210 | |
Rod Whitby | e28067d | 2008-01-29 00:36:12 +0100 | [diff] [blame] | 211 | i2c_register_board_info(0, nslu2_i2c_board_info, |
| 212 | ARRAY_SIZE(nslu2_i2c_board_info)); |
| 213 | |
Michael-Luke Jones | cc50a0d | 2007-05-23 22:41:53 +0100 | [diff] [blame] | 214 | /* |
| 215 | * This is only useful on a modified machine, but it is valuable |
Rod Whitby | e22b04f | 2006-06-22 22:21:02 +0100 | [diff] [blame] | 216 | * to have it first in order to see debug messages, and so that |
| 217 | * it does *not* get removed if platform_add_devices fails! |
| 218 | */ |
| 219 | (void)platform_device_register(&nslu2_uart); |
| 220 | |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 221 | platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices)); |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 222 | |
| 223 | |
| 224 | /* |
| 225 | * Map in a portion of the flash and read the MAC address. |
| 226 | * Since it is stored in BE in the flash itself, we need to |
| 227 | * byteswap it if we're in LE mode. |
| 228 | */ |
| 229 | f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x40000); |
| 230 | if (f) { |
| 231 | for (i = 0; i < 6; i++) |
| 232 | #ifdef __ARMEB__ |
| 233 | nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + i); |
| 234 | #else |
| 235 | nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + (i^3)); |
| 236 | #endif |
| 237 | iounmap(f); |
| 238 | } |
| 239 | printk(KERN_INFO "NSLU2: Using MAC address %s for port 0\n", |
| 240 | print_mac(mac_buf, nslu2_plat_eth[0].hwaddr)); |
| 241 | |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | MACHINE_START(NSLU2, "Linksys NSLU2") |
| 245 | /* Maintainer: www.nslu2-linux.org */ |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 246 | .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS, |
| 247 | .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC, |
| 248 | .boot_params = 0x00000100, |
| 249 | .map_io = ixp4xx_map_io, |
| 250 | .init_irq = ixp4xx_init_irq, |
Michael-Luke Jones | 435c5da | 2007-05-23 22:38:45 +0100 | [diff] [blame] | 251 | .timer = &nslu2_timer, |
Alessandro Zummo | a7918f3 | 2005-11-10 14:05:04 +0000 | [diff] [blame] | 252 | .init_machine = nslu2_init, |
| 253 | MACHINE_END |