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 | |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/serial.h> |
| 17 | #include <linux/serial_8250.h> |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 18 | #include <linux/leds.h> |
Rod Whitby | 400d823 | 2008-01-29 00:38:44 +0100 | [diff] [blame] | 19 | #include <linux/i2c.h> |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 20 | #include <linux/i2c-gpio.h> |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 21 | |
| 22 | #include <asm/mach-types.h> |
| 23 | #include <asm/mach/arch.h> |
| 24 | #include <asm/mach/flash.h> |
| 25 | |
| 26 | static struct flash_platform_data nas100d_flash_data = { |
| 27 | .map_name = "cfi_probe", |
| 28 | .width = 2, |
| 29 | }; |
| 30 | |
| 31 | static struct resource nas100d_flash_resource = { |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 32 | .flags = IORESOURCE_MEM, |
| 33 | }; |
| 34 | |
| 35 | static struct platform_device nas100d_flash = { |
| 36 | .name = "IXP4XX-Flash", |
| 37 | .id = 0, |
| 38 | .dev.platform_data = &nas100d_flash_data, |
| 39 | .num_resources = 1, |
| 40 | .resource = &nas100d_flash_resource, |
| 41 | }; |
| 42 | |
Rod Whitby | 400d823 | 2008-01-29 00:38:44 +0100 | [diff] [blame] | 43 | static struct i2c_board_info __initdata nas100d_i2c_board_info [] = { |
| 44 | { |
| 45 | I2C_BOARD_INFO("rtc-pcf8563", 0x51), |
| 46 | }, |
| 47 | }; |
| 48 | |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame^] | 49 | static struct gpio_led nas100d_led_pins[] = { |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 50 | { |
| 51 | .name = "wlan", /* green led */ |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame^] | 52 | .gpio = NAS100D_LED_WLAN_GPIO, |
| 53 | .active_low = true, |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 54 | }, |
| 55 | { |
Rod Whitby | 14645eb | 2008-01-29 00:29:38 +0100 | [diff] [blame] | 56 | .name = "power", /* blue power led (off=flashing) */ |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame^] | 57 | .gpio = NAS100D_LED_PWR_GPIO, |
| 58 | .active_low = true, |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 59 | }, |
| 60 | { |
| 61 | .name = "disk", /* yellow led */ |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame^] | 62 | .gpio = NAS100D_LED_DISK_GPIO, |
| 63 | .active_low = true, |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 64 | }, |
| 65 | }; |
| 66 | |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame^] | 67 | static struct gpio_led_platform_data nas100d_led_data = { |
| 68 | .num_leds = ARRAY_SIZE(nas100d_led_pins), |
| 69 | .leds = nas100d_led_pins, |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 70 | }; |
Rod Whitby | 1208ebf | 2008-02-02 00:03:56 +0100 | [diff] [blame^] | 71 | |
| 72 | static struct platform_device nas100d_leds = { |
| 73 | .name = "leds-gpio", |
| 74 | .id = -1, |
| 75 | .dev.platform_data = &nas100d_led_data, |
| 76 | }; |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 77 | |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 78 | static struct i2c_gpio_platform_data nas100d_i2c_gpio_data = { |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 79 | .sda_pin = NAS100D_SDA_PIN, |
| 80 | .scl_pin = NAS100D_SCL_PIN, |
| 81 | }; |
| 82 | |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 83 | static struct platform_device nas100d_i2c_gpio = { |
| 84 | .name = "i2c-gpio", |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 85 | .id = 0, |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 86 | .dev = { |
| 87 | .platform_data = &nas100d_i2c_gpio_data, |
| 88 | }, |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | static struct resource nas100d_uart_resources[] = { |
| 92 | { |
| 93 | .start = IXP4XX_UART1_BASE_PHYS, |
| 94 | .end = IXP4XX_UART1_BASE_PHYS + 0x0fff, |
| 95 | .flags = IORESOURCE_MEM, |
| 96 | }, |
| 97 | { |
| 98 | .start = IXP4XX_UART2_BASE_PHYS, |
| 99 | .end = IXP4XX_UART2_BASE_PHYS + 0x0fff, |
| 100 | .flags = IORESOURCE_MEM, |
| 101 | } |
| 102 | }; |
| 103 | |
| 104 | static struct plat_serial8250_port nas100d_uart_data[] = { |
| 105 | { |
| 106 | .mapbase = IXP4XX_UART1_BASE_PHYS, |
| 107 | .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET, |
| 108 | .irq = IRQ_IXP4XX_UART1, |
| 109 | .flags = UPF_BOOT_AUTOCONF, |
| 110 | .iotype = UPIO_MEM, |
| 111 | .regshift = 2, |
| 112 | .uartclk = IXP4XX_UART_XTAL, |
| 113 | }, |
| 114 | { |
| 115 | .mapbase = IXP4XX_UART2_BASE_PHYS, |
| 116 | .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET, |
| 117 | .irq = IRQ_IXP4XX_UART2, |
| 118 | .flags = UPF_BOOT_AUTOCONF, |
| 119 | .iotype = UPIO_MEM, |
| 120 | .regshift = 2, |
| 121 | .uartclk = IXP4XX_UART_XTAL, |
| 122 | }, |
| 123 | { } |
| 124 | }; |
| 125 | |
| 126 | static struct platform_device nas100d_uart = { |
| 127 | .name = "serial8250", |
| 128 | .id = PLAT8250_DEV_PLATFORM, |
| 129 | .dev.platform_data = nas100d_uart_data, |
| 130 | .num_resources = 2, |
| 131 | .resource = nas100d_uart_resources, |
| 132 | }; |
| 133 | |
| 134 | static struct platform_device *nas100d_devices[] __initdata = { |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 135 | &nas100d_i2c_gpio, |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 136 | &nas100d_flash, |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 137 | &nas100d_leds, |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | static void nas100d_power_off(void) |
| 141 | { |
| 142 | /* This causes the box to drop the power and go dead. */ |
| 143 | |
| 144 | /* enable the pwr cntl gpio */ |
| 145 | gpio_line_config(NAS100D_PO_GPIO, IXP4XX_GPIO_OUT); |
| 146 | |
| 147 | /* do the deed */ |
| 148 | gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH); |
| 149 | } |
| 150 | |
| 151 | static void __init nas100d_init(void) |
| 152 | { |
| 153 | ixp4xx_sys_init(); |
| 154 | |
Alessandro Zummo | dcc8fa5 | 2006-03-08 23:45:10 +0000 | [diff] [blame] | 155 | /* gpio 14 and 15 are _not_ clocks */ |
| 156 | *IXP4XX_GPIO_GPCLKR = 0; |
| 157 | |
Deepak Saxena | 54e269e | 2006-01-05 20:59:29 +0000 | [diff] [blame] | 158 | nas100d_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); |
| 159 | nas100d_flash_resource.end = |
| 160 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; |
| 161 | |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 162 | pm_power_off = nas100d_power_off; |
| 163 | |
Rod Whitby | 400d823 | 2008-01-29 00:38:44 +0100 | [diff] [blame] | 164 | i2c_register_board_info(0, nas100d_i2c_board_info, |
| 165 | ARRAY_SIZE(nas100d_i2c_board_info)); |
| 166 | |
Michael-Luke Jones | cc50a0d | 2007-05-23 22:41:53 +0100 | [diff] [blame] | 167 | /* |
| 168 | * This is only useful on a modified machine, but it is valuable |
Rod Whitby | df6934b | 2006-06-22 22:21:01 +0100 | [diff] [blame] | 169 | * to have it first in order to see debug messages, and so that |
| 170 | * it does *not* get removed if platform_add_devices fails! |
| 171 | */ |
| 172 | (void)platform_device_register(&nas100d_uart); |
| 173 | |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 174 | platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices)); |
| 175 | } |
| 176 | |
| 177 | MACHINE_START(NAS100D, "Iomega NAS 100d") |
| 178 | /* Maintainer: www.nslu2-linux.org */ |
Rod Whitby | 3145d8a | 2006-01-04 17:17:11 +0000 | [diff] [blame] | 179 | .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS, |
| 180 | .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC, |
| 181 | .boot_params = 0x00000100, |
| 182 | .map_io = ixp4xx_map_io, |
| 183 | .init_irq = ixp4xx_init_irq, |
| 184 | .timer = &ixp4xx_timer, |
| 185 | .init_machine = nas100d_init, |
| 186 | MACHINE_END |