Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ixp4xx/nas100d-setup.c |
| 3 | * |
| 4 | * NAS 100d board-setup |
| 5 | * |
| 6 | * based ixdp425-setup.c: |
| 7 | * Copyright (C) 2003-2004 MontaVista Software, Inc. |
| 8 | * |
| 9 | * Author: Alessandro Zummo <a.zummo@towertech.it> |
| 10 | * Author: Rod Whitby <rod@whitby.id.au> |
| 11 | * Maintainers: http://www.nslu2-linux.org/ |
| 12 | * |
| 13 | */ |
| 14 | |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 15 | #include <linux/if_ether.h> |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/serial.h> |
| 18 | #include <linux/serial_8250.h> |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 19 | #include <linux/leds.h> |
Rod Whitby | 400d823 | 2008-01-29 00:38:44 +0100 | [diff] [blame] | 20 | #include <linux/i2c.h> |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 21 | #include <linux/i2c-gpio.h> |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 22 | |
| 23 | #include <asm/mach-types.h> |
| 24 | #include <asm/mach/arch.h> |
| 25 | #include <asm/mach/flash.h> |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 26 | #include <asm/io.h> |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 27 | |
| 28 | static struct flash_platform_data nas100d_flash_data = { |
| 29 | .map_name = "cfi_probe", |
| 30 | .width = 2, |
| 31 | }; |
| 32 | |
| 33 | static struct resource nas100d_flash_resource = { |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 34 | .flags = IORESOURCE_MEM, |
| 35 | }; |
| 36 | |
| 37 | static struct platform_device nas100d_flash = { |
| 38 | .name = "IXP4XX-Flash", |
| 39 | .id = 0, |
| 40 | .dev.platform_data = &nas100d_flash_data, |
| 41 | .num_resources = 1, |
| 42 | .resource = &nas100d_flash_resource, |
| 43 | }; |
| 44 | |
Rod Whitby | 400d823 | 2008-01-29 00:38:44 +0100 | [diff] [blame] | 45 | static struct i2c_board_info __initdata nas100d_i2c_board_info [] = { |
| 46 | { |
| 47 | I2C_BOARD_INFO("rtc-pcf8563", 0x51), |
| 48 | }, |
| 49 | }; |
| 50 | |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 51 | static struct gpio_led nas100d_led_pins[] = { |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 52 | { |
| 53 | .name = "wlan", /* green led */ |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 54 | .gpio = NAS100D_LED_WLAN_GPIO, |
| 55 | .active_low = true, |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 56 | }, |
| 57 | { |
Rod Whitby | 14645eb | 2008-01-29 00:29:38 +0100 | [diff] [blame] | 58 | .name = "power", /* blue power led (off=flashing) */ |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 59 | .gpio = NAS100D_LED_PWR_GPIO, |
| 60 | .active_low = true, |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 61 | }, |
| 62 | { |
| 63 | .name = "disk", /* yellow led */ |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 64 | .gpio = NAS100D_LED_DISK_GPIO, |
| 65 | .active_low = true, |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 66 | }, |
| 67 | }; |
| 68 | |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 69 | static struct gpio_led_platform_data nas100d_led_data = { |
| 70 | .num_leds = ARRAY_SIZE(nas100d_led_pins), |
| 71 | .leds = nas100d_led_pins, |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 72 | }; |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame] | 73 | |
| 74 | static struct platform_device nas100d_leds = { |
| 75 | .name = "leds-gpio", |
| 76 | .id = -1, |
| 77 | .dev.platform_data = &nas100d_led_data, |
| 78 | }; |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 79 | |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 80 | static struct i2c_gpio_platform_data nas100d_i2c_gpio_data = { |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 81 | .sda_pin = NAS100D_SDA_PIN, |
| 82 | .scl_pin = NAS100D_SCL_PIN, |
| 83 | }; |
| 84 | |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 85 | static struct platform_device nas100d_i2c_gpio = { |
| 86 | .name = "i2c-gpio", |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 87 | .id = 0, |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 88 | .dev = { |
| 89 | .platform_data = &nas100d_i2c_gpio_data, |
| 90 | }, |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | static struct resource nas100d_uart_resources[] = { |
| 94 | { |
| 95 | .start = IXP4XX_UART1_BASE_PHYS, |
| 96 | .end = IXP4XX_UART1_BASE_PHYS + 0x0fff, |
| 97 | .flags = IORESOURCE_MEM, |
| 98 | }, |
| 99 | { |
| 100 | .start = IXP4XX_UART2_BASE_PHYS, |
| 101 | .end = IXP4XX_UART2_BASE_PHYS + 0x0fff, |
| 102 | .flags = IORESOURCE_MEM, |
| 103 | } |
| 104 | }; |
| 105 | |
| 106 | static struct plat_serial8250_port nas100d_uart_data[] = { |
| 107 | { |
| 108 | .mapbase = IXP4XX_UART1_BASE_PHYS, |
| 109 | .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET, |
| 110 | .irq = IRQ_IXP4XX_UART1, |
| 111 | .flags = UPF_BOOT_AUTOCONF, |
| 112 | .iotype = UPIO_MEM, |
| 113 | .regshift = 2, |
| 114 | .uartclk = IXP4XX_UART_XTAL, |
| 115 | }, |
| 116 | { |
| 117 | .mapbase = IXP4XX_UART2_BASE_PHYS, |
| 118 | .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET, |
| 119 | .irq = IRQ_IXP4XX_UART2, |
| 120 | .flags = UPF_BOOT_AUTOCONF, |
| 121 | .iotype = UPIO_MEM, |
| 122 | .regshift = 2, |
| 123 | .uartclk = IXP4XX_UART_XTAL, |
| 124 | }, |
| 125 | { } |
| 126 | }; |
| 127 | |
| 128 | static struct platform_device nas100d_uart = { |
| 129 | .name = "serial8250", |
| 130 | .id = PLAT8250_DEV_PLATFORM, |
| 131 | .dev.platform_data = nas100d_uart_data, |
| 132 | .num_resources = 2, |
| 133 | .resource = nas100d_uart_resources, |
| 134 | }; |
| 135 | |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 136 | /* Built-in 10/100 Ethernet MAC interfaces */ |
| 137 | static struct eth_plat_info nas100d_plat_eth[] = { |
| 138 | { |
| 139 | .phy = 0, |
| 140 | .rxq = 3, |
| 141 | .txreadyq = 20, |
| 142 | } |
| 143 | }; |
| 144 | |
| 145 | static struct platform_device nas100d_eth[] = { |
| 146 | { |
| 147 | .name = "ixp4xx_eth", |
| 148 | .id = IXP4XX_ETH_NPEB, |
| 149 | .dev.platform_data = nas100d_plat_eth, |
| 150 | } |
| 151 | }; |
| 152 | |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 153 | static struct platform_device *nas100d_devices[] __initdata = { |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 154 | &nas100d_i2c_gpio, |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 155 | &nas100d_flash, |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 156 | &nas100d_leds, |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 157 | &nas100d_eth[0], |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | static void nas100d_power_off(void) |
| 161 | { |
| 162 | /* This causes the box to drop the power and go dead. */ |
| 163 | |
| 164 | /* enable the pwr cntl gpio */ |
| 165 | gpio_line_config(NAS100D_PO_GPIO, IXP4XX_GPIO_OUT); |
| 166 | |
| 167 | /* do the deed */ |
| 168 | gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH); |
| 169 | } |
| 170 | |
| 171 | static void __init nas100d_init(void) |
| 172 | { |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 173 | DECLARE_MAC_BUF(mac_buf); |
| 174 | uint8_t __iomem *f; |
| 175 | int i; |
| 176 | |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 177 | ixp4xx_sys_init(); |
| 178 | |
Alessandro Zummo | dcc8fa5 | 2006-03-08 23:45:10 +0000 | [diff] [blame] | 179 | /* gpio 14 and 15 are _not_ clocks */ |
| 180 | *IXP4XX_GPIO_GPCLKR = 0; |
| 181 | |
Deepak Saxena | 54e269e | 2006-01-05 20:59:29 +0000 | [diff] [blame] | 182 | nas100d_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); |
| 183 | nas100d_flash_resource.end = |
| 184 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; |
| 185 | |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 186 | pm_power_off = nas100d_power_off; |
| 187 | |
Rod Whitby | 400d823 | 2008-01-29 00:38:44 +0100 | [diff] [blame] | 188 | i2c_register_board_info(0, nas100d_i2c_board_info, |
| 189 | ARRAY_SIZE(nas100d_i2c_board_info)); |
| 190 | |
Michael-Luke Jones | cc50a0d | 2007-05-23 22:41:53 +0100 | [diff] [blame] | 191 | /* |
| 192 | * This is only useful on a modified machine, but it is valuable |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 193 | * to have it first in order to see debug messages, and so that |
| 194 | * it does *not* get removed if platform_add_devices fails! |
| 195 | */ |
| 196 | (void)platform_device_register(&nas100d_uart); |
| 197 | |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 198 | platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices)); |
Rod Whitby | b7edc84 | 2008-02-02 00:04:05 +0100 | [diff] [blame^] | 199 | |
| 200 | /* |
| 201 | * Map in a portion of the flash and read the MAC address. |
| 202 | * Since it is stored in BE in the flash itself, we need to |
| 203 | * byteswap it if we're in LE mode. |
| 204 | */ |
| 205 | f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x1000000); |
| 206 | if (f) { |
| 207 | for (i = 0; i < 6; i++) |
| 208 | #ifdef __ARMEB__ |
| 209 | nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + i); |
| 210 | #else |
| 211 | nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + (i^3)); |
| 212 | #endif |
| 213 | iounmap(f); |
| 214 | } |
| 215 | printk(KERN_INFO "NAS100D: Using MAC address %s for port 0\n", |
| 216 | print_mac(mac_buf, nas100d_plat_eth[0].hwaddr)); |
| 217 | |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | MACHINE_START(NAS100D, "Iomega NAS 100d") |
| 221 | /* Maintainer: www.nslu2-linux.org */ |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 222 | .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS, |
| 223 | .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC, |
| 224 | .boot_params = 0x00000100, |
| 225 | .map_io = ixp4xx_map_io, |
| 226 | .init_irq = ixp4xx_init_irq, |
| 227 | .timer = &ixp4xx_timer, |
| 228 | .init_machine = nas100d_init, |
| 229 | MACHINE_END |