blob: a432226b2050e11d1066d4ae6d27ef3ef16f1a51 [file] [log] [blame]
Rod Whitby3145d8a2006-01-04 17:17:11 +00001/*
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 Whitbyb7edc842008-02-02 00:04:05 +010015#include <linux/if_ether.h>
Rod Whitby3145d8a2006-01-04 17:17:11 +000016#include <linux/kernel.h>
17#include <linux/serial.h>
18#include <linux/serial_8250.h>
Rod Whitbydf6934b2006-06-22 22:21:01 +010019#include <linux/leds.h>
Rod Whitby400d8232008-01-29 00:38:44 +010020#include <linux/i2c.h>
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010021#include <linux/i2c-gpio.h>
Rod Whitby3145d8a2006-01-04 17:17:11 +000022
23#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
25#include <asm/mach/flash.h>
Rod Whitbyb7edc842008-02-02 00:04:05 +010026#include <asm/io.h>
Rod Whitby3145d8a2006-01-04 17:17:11 +000027
28static struct flash_platform_data nas100d_flash_data = {
29 .map_name = "cfi_probe",
30 .width = 2,
31};
32
33static struct resource nas100d_flash_resource = {
Rod Whitby3145d8a2006-01-04 17:17:11 +000034 .flags = IORESOURCE_MEM,
35};
36
37static 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 Whitby400d8232008-01-29 00:38:44 +010045static struct i2c_board_info __initdata nas100d_i2c_board_info [] = {
46 {
47 I2C_BOARD_INFO("rtc-pcf8563", 0x51),
48 },
49};
50
Rod Whitby1208ebf2008-02-02 00:03:56 +010051static struct gpio_led nas100d_led_pins[] = {
Rod Whitbydf6934b2006-06-22 22:21:01 +010052 {
53 .name = "wlan", /* green led */
Rod Whitby1208ebf2008-02-02 00:03:56 +010054 .gpio = NAS100D_LED_WLAN_GPIO,
55 .active_low = true,
Rod Whitbydf6934b2006-06-22 22:21:01 +010056 },
57 {
Rod Whitby14645eb2008-01-29 00:29:38 +010058 .name = "power", /* blue power led (off=flashing) */
Rod Whitby1208ebf2008-02-02 00:03:56 +010059 .gpio = NAS100D_LED_PWR_GPIO,
60 .active_low = true,
Rod Whitbydf6934b2006-06-22 22:21:01 +010061 },
62 {
63 .name = "disk", /* yellow led */
Rod Whitby1208ebf2008-02-02 00:03:56 +010064 .gpio = NAS100D_LED_DISK_GPIO,
65 .active_low = true,
Rod Whitbydf6934b2006-06-22 22:21:01 +010066 },
67};
68
Rod Whitby1208ebf2008-02-02 00:03:56 +010069static struct gpio_led_platform_data nas100d_led_data = {
70 .num_leds = ARRAY_SIZE(nas100d_led_pins),
71 .leds = nas100d_led_pins,
Rod Whitbydf6934b2006-06-22 22:21:01 +010072};
Rod Whitby1208ebf2008-02-02 00:03:56 +010073
74static struct platform_device nas100d_leds = {
75 .name = "leds-gpio",
76 .id = -1,
77 .dev.platform_data = &nas100d_led_data,
78};
Rod Whitbydf6934b2006-06-22 22:21:01 +010079
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010080static struct i2c_gpio_platform_data nas100d_i2c_gpio_data = {
Rod Whitby3145d8a2006-01-04 17:17:11 +000081 .sda_pin = NAS100D_SDA_PIN,
82 .scl_pin = NAS100D_SCL_PIN,
83};
84
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010085static struct platform_device nas100d_i2c_gpio = {
86 .name = "i2c-gpio",
Rod Whitby3145d8a2006-01-04 17:17:11 +000087 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010088 .dev = {
89 .platform_data = &nas100d_i2c_gpio_data,
90 },
Rod Whitby3145d8a2006-01-04 17:17:11 +000091};
92
93static 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
106static 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
128static 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 Whitbyb7edc842008-02-02 00:04:05 +0100136/* Built-in 10/100 Ethernet MAC interfaces */
137static struct eth_plat_info nas100d_plat_eth[] = {
138 {
139 .phy = 0,
140 .rxq = 3,
141 .txreadyq = 20,
142 }
143};
144
145static 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 Whitby3145d8a2006-01-04 17:17:11 +0000153static struct platform_device *nas100d_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100154 &nas100d_i2c_gpio,
Rod Whitby3145d8a2006-01-04 17:17:11 +0000155 &nas100d_flash,
Rod Whitbydf6934b2006-06-22 22:21:01 +0100156 &nas100d_leds,
Rod Whitbyb7edc842008-02-02 00:04:05 +0100157 &nas100d_eth[0],
Rod Whitby3145d8a2006-01-04 17:17:11 +0000158};
159
160static 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
171static void __init nas100d_init(void)
172{
Rod Whitbyb7edc842008-02-02 00:04:05 +0100173 DECLARE_MAC_BUF(mac_buf);
174 uint8_t __iomem *f;
175 int i;
176
Rod Whitby3145d8a2006-01-04 17:17:11 +0000177 ixp4xx_sys_init();
178
Alessandro Zummodcc8fa52006-03-08 23:45:10 +0000179 /* gpio 14 and 15 are _not_ clocks */
180 *IXP4XX_GPIO_GPCLKR = 0;
181
Deepak Saxena54e269e2006-01-05 20:59:29 +0000182 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 Whitby3145d8a2006-01-04 17:17:11 +0000186 pm_power_off = nas100d_power_off;
187
Rod Whitby400d8232008-01-29 00:38:44 +0100188 i2c_register_board_info(0, nas100d_i2c_board_info,
189 ARRAY_SIZE(nas100d_i2c_board_info));
190
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +0100191 /*
192 * This is only useful on a modified machine, but it is valuable
Rod Whitbydf6934b2006-06-22 22:21:01 +0100193 * 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 Whitby3145d8a2006-01-04 17:17:11 +0000198 platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
Rod Whitbyb7edc842008-02-02 00:04:05 +0100199
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 Whitby3145d8a2006-01-04 17:17:11 +0000218}
219
220MACHINE_START(NAS100D, "Iomega NAS 100d")
221 /* Maintainer: www.nslu2-linux.org */
Rod Whitby3145d8a2006-01-04 17:17:11 +0000222 .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,
229MACHINE_END