2 * arch/arm/mach-ixp4xx/nslu2-setup.c
6 * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
8 * based on ixdp425-setup.c:
9 * Copyright (C) 2003-2004 MontaVista Software, Inc.
10 * based on nslu2-power.c:
11 * Copyright (C) 2005 Tower Technologies
13 * Author: Mark Rakes <mrakes at mac.com>
14 * Author: Rod Whitby <rod@whitby.id.au>
15 * Author: Alessandro Zummo <a.zummo@towertech.it>
16 * Maintainers: http://www.nslu2-linux.org/
20 #include <linux/if_ether.h>
21 #include <linux/irq.h>
22 #include <linux/serial.h>
23 #include <linux/serial_8250.h>
24 #include <linux/leds.h>
25 #include <linux/reboot.h>
26 #include <linux/i2c.h>
27 #include <linux/i2c-gpio.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/flash.h>
33 #include <asm/mach/time.h>
36 static struct flash_platform_data nslu2_flash_data = {
37 .map_name = "cfi_probe",
41 static struct resource nslu2_flash_resource = {
42 .flags = IORESOURCE_MEM,
45 static struct platform_device nslu2_flash = {
46 .name = "IXP4XX-Flash",
48 .dev.platform_data = &nslu2_flash_data,
50 .resource = &nslu2_flash_resource,
53 static struct i2c_gpio_platform_data nslu2_i2c_gpio_data = {
54 .sda_pin = NSLU2_SDA_PIN,
55 .scl_pin = NSLU2_SCL_PIN,
58 static struct i2c_board_info __initdata nslu2_i2c_board_info [] = {
60 I2C_BOARD_INFO("x1205", 0x6f),
64 static struct gpio_led nslu2_led_pins[] = {
66 .name = "nslu2:green:ready",
67 .gpio = NSLU2_LED_GRN_GPIO,
70 .name = "nslu2:red:status",
71 .gpio = NSLU2_LED_RED_GPIO,
74 .name = "nslu2:green:disk-1",
75 .gpio = NSLU2_LED_DISK1_GPIO,
79 .name = "nslu2:green:disk-2",
80 .gpio = NSLU2_LED_DISK2_GPIO,
85 static struct gpio_led_platform_data nslu2_led_data = {
86 .num_leds = ARRAY_SIZE(nslu2_led_pins),
87 .leds = nslu2_led_pins,
90 static struct platform_device nslu2_leds = {
93 .dev.platform_data = &nslu2_led_data,
96 static struct platform_device nslu2_i2c_gpio = {
100 .platform_data = &nslu2_i2c_gpio_data,
104 static struct platform_device nslu2_beeper = {
105 .name = "ixp4xx-beeper",
106 .id = NSLU2_GPIO_BUZZ,
110 static struct resource nslu2_uart_resources[] = {
112 .start = IXP4XX_UART1_BASE_PHYS,
113 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
114 .flags = IORESOURCE_MEM,
117 .start = IXP4XX_UART2_BASE_PHYS,
118 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
119 .flags = IORESOURCE_MEM,
123 static struct plat_serial8250_port nslu2_uart_data[] = {
125 .mapbase = IXP4XX_UART1_BASE_PHYS,
126 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
127 .irq = IRQ_IXP4XX_UART1,
128 .flags = UPF_BOOT_AUTOCONF,
131 .uartclk = IXP4XX_UART_XTAL,
134 .mapbase = IXP4XX_UART2_BASE_PHYS,
135 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
136 .irq = IRQ_IXP4XX_UART2,
137 .flags = UPF_BOOT_AUTOCONF,
140 .uartclk = IXP4XX_UART_XTAL,
145 static struct platform_device nslu2_uart = {
146 .name = "serial8250",
147 .id = PLAT8250_DEV_PLATFORM,
148 .dev.platform_data = nslu2_uart_data,
150 .resource = nslu2_uart_resources,
153 /* Built-in 10/100 Ethernet MAC interfaces */
154 static struct eth_plat_info nslu2_plat_eth[] = {
162 static struct platform_device nslu2_eth[] = {
164 .name = "ixp4xx_eth",
165 .id = IXP4XX_ETH_NPEB,
166 .dev.platform_data = nslu2_plat_eth,
170 static struct platform_device *nslu2_devices[] __initdata = {
178 static void nslu2_power_off(void)
180 /* This causes the box to drop the power and go dead. */
182 /* enable the pwr cntl gpio */
183 gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT);
186 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
189 static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
191 /* Signal init to do the ctrlaltdel action, this will bypass init if
192 * it hasn't started and do a kernel_restart.
199 static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
201 /* This is the paper-clip reset, it shuts the machine down directly.
208 static void __init nslu2_timer_init(void)
210 /* The xtal on this machine is non-standard. */
211 ixp4xx_timer_freq = NSLU2_FREQ;
213 /* Call standard timer_init function. */
217 static struct sys_timer nslu2_timer = {
218 .init = nslu2_timer_init,
221 static void __init nslu2_init(void)
223 DECLARE_MAC_BUF(mac_buf);
229 nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
230 nslu2_flash_resource.end =
231 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
233 i2c_register_board_info(0, nslu2_i2c_board_info,
234 ARRAY_SIZE(nslu2_i2c_board_info));
237 * This is only useful on a modified machine, but it is valuable
238 * to have it first in order to see debug messages, and so that
239 * it does *not* get removed if platform_add_devices fails!
241 (void)platform_device_register(&nslu2_uart);
243 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
245 pm_power_off = nslu2_power_off;
247 if (request_irq(gpio_to_irq(NSLU2_RB_GPIO), &nslu2_reset_handler,
248 IRQF_DISABLED | IRQF_TRIGGER_LOW,
249 "NSLU2 reset button", NULL) < 0) {
251 printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
252 gpio_to_irq(NSLU2_RB_GPIO));
255 if (request_irq(gpio_to_irq(NSLU2_PB_GPIO), &nslu2_power_handler,
256 IRQF_DISABLED | IRQF_TRIGGER_HIGH,
257 "NSLU2 power button", NULL) < 0) {
259 printk(KERN_DEBUG "Power Button IRQ %d not available\n",
260 gpio_to_irq(NSLU2_PB_GPIO));
264 * Map in a portion of the flash and read the MAC address.
265 * Since it is stored in BE in the flash itself, we need to
266 * byteswap it if we're in LE mode.
268 f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x40000);
270 for (i = 0; i < 6; i++)
272 nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + i);
274 nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + (i^3));
278 printk(KERN_INFO "NSLU2: Using MAC address %s for port 0\n",
279 print_mac(mac_buf, nslu2_plat_eth[0].hwaddr));
283 MACHINE_START(NSLU2, "Linksys NSLU2")
284 /* Maintainer: www.nslu2-linux.org */
285 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
286 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
287 .boot_params = 0x00000100,
288 .map_io = ixp4xx_map_io,
289 .init_irq = ixp4xx_init_irq,
290 .timer = &nslu2_timer,
291 .init_machine = nslu2_init,