blob: 41d55c84164a9acc4c66ea09101ca2e56bbf5251 [file] [log] [blame]
Alessandro Zummoa7918f32005-11-10 14:05:04 +00001/*
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 Whitbye22b04f2006-06-22 22:21:02 +010010 * Author: Rod Whitby <rod@whitby.id.au>
Alessandro Zummoa7918f32005-11-10 14:05:04 +000011 * 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
17#include <linux/kernel.h>
18#include <linux/serial.h>
19#include <linux/serial_8250.h>
Rod Whitbye22b04f2006-06-22 22:21:02 +010020#include <linux/leds.h>
Rod Whitbye28067d2008-01-29 00:36:12 +010021#include <linux/i2c.h>
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010022#include <linux/i2c-gpio.h>
Alessandro Zummoa7918f32005-11-10 14:05:04 +000023
24#include <asm/mach-types.h>
25#include <asm/mach/arch.h>
26#include <asm/mach/flash.h>
Michael-Luke Jones435c5da2007-05-23 22:38:45 +010027#include <asm/mach/time.h>
Alessandro Zummoa7918f32005-11-10 14:05:04 +000028
29static struct flash_platform_data nslu2_flash_data = {
30 .map_name = "cfi_probe",
31 .width = 2,
32};
33
34static struct resource nslu2_flash_resource = {
Alessandro Zummoa7918f32005-11-10 14:05:04 +000035 .flags = IORESOURCE_MEM,
36};
37
38static struct platform_device nslu2_flash = {
39 .name = "IXP4XX-Flash",
40 .id = 0,
41 .dev.platform_data = &nslu2_flash_data,
42 .num_resources = 1,
43 .resource = &nslu2_flash_resource,
44};
45
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010046static struct i2c_gpio_platform_data nslu2_i2c_gpio_data = {
Alessandro Zummoa7918f32005-11-10 14:05:04 +000047 .sda_pin = NSLU2_SDA_PIN,
48 .scl_pin = NSLU2_SCL_PIN,
49};
50
Rod Whitbye28067d2008-01-29 00:36:12 +010051static struct i2c_board_info __initdata nslu2_i2c_board_info [] = {
52 {
53 I2C_BOARD_INFO("rtc-x1205", 0x6f),
54 },
55};
56
Rod Whitby1208ebf2008-02-02 00:03:56 +010057static struct gpio_led nslu2_led_pins[] = {
Rod Whitbye22b04f2006-06-22 22:21:02 +010058 {
59 .name = "ready", /* green led */
Rod Whitby1208ebf2008-02-02 00:03:56 +010060 .gpio = NSLU2_LED_GRN_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010061 },
62 {
63 .name = "status", /* red led */
Rod Whitby1208ebf2008-02-02 00:03:56 +010064 .gpio = NSLU2_LED_RED_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010065 },
66 {
67 .name = "disk-1",
Rod Whitby1208ebf2008-02-02 00:03:56 +010068 .gpio = NSLU2_LED_DISK1_GPIO,
69 .active_low = true,
Rod Whitbye22b04f2006-06-22 22:21:02 +010070 },
71 {
72 .name = "disk-2",
Rod Whitby1208ebf2008-02-02 00:03:56 +010073 .gpio = NSLU2_LED_DISK2_GPIO,
74 .active_low = true,
Rod Whitbye22b04f2006-06-22 22:21:02 +010075 },
76};
77
Rod Whitby1208ebf2008-02-02 00:03:56 +010078static struct gpio_led_platform_data nslu2_led_data = {
79 .num_leds = ARRAY_SIZE(nslu2_led_pins),
80 .leds = nslu2_led_pins,
Rod Whitbye22b04f2006-06-22 22:21:02 +010081};
Rod Whitby1208ebf2008-02-02 00:03:56 +010082
83static struct platform_device nslu2_leds = {
84 .name = "leds-gpio",
85 .id = -1,
86 .dev.platform_data = &nslu2_led_data,
87};
Rod Whitbye22b04f2006-06-22 22:21:02 +010088
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010089static struct platform_device nslu2_i2c_gpio = {
90 .name = "i2c-gpio",
Alessandro Zummoa7918f32005-11-10 14:05:04 +000091 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010092 .dev = {
93 .platform_data = &nslu2_i2c_gpio_data,
94 },
Alessandro Zummoa7918f32005-11-10 14:05:04 +000095};
96
Alessandro Zummobc66d442006-02-22 21:12:06 +000097static struct platform_device nslu2_beeper = {
98 .name = "ixp4xx-beeper",
99 .id = NSLU2_GPIO_BUZZ,
100 .num_resources = 0,
101};
102
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000103static struct resource nslu2_uart_resources[] = {
104 {
105 .start = IXP4XX_UART1_BASE_PHYS,
106 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
107 .flags = IORESOURCE_MEM,
108 },
109 {
110 .start = IXP4XX_UART2_BASE_PHYS,
111 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
112 .flags = IORESOURCE_MEM,
113 }
114};
115
116static struct plat_serial8250_port nslu2_uart_data[] = {
117 {
118 .mapbase = IXP4XX_UART1_BASE_PHYS,
119 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
120 .irq = IRQ_IXP4XX_UART1,
121 .flags = UPF_BOOT_AUTOCONF,
122 .iotype = UPIO_MEM,
123 .regshift = 2,
124 .uartclk = IXP4XX_UART_XTAL,
125 },
126 {
127 .mapbase = IXP4XX_UART2_BASE_PHYS,
128 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
129 .irq = IRQ_IXP4XX_UART2,
130 .flags = UPF_BOOT_AUTOCONF,
131 .iotype = UPIO_MEM,
132 .regshift = 2,
133 .uartclk = IXP4XX_UART_XTAL,
134 },
135 { }
136};
137
138static struct platform_device nslu2_uart = {
139 .name = "serial8250",
140 .id = PLAT8250_DEV_PLATFORM,
141 .dev.platform_data = nslu2_uart_data,
142 .num_resources = 2,
143 .resource = nslu2_uart_resources,
144};
145
146static struct platform_device *nslu2_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100147 &nslu2_i2c_gpio,
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000148 &nslu2_flash,
Alessandro Zummobc66d442006-02-22 21:12:06 +0000149 &nslu2_beeper,
Rod Whitbye22b04f2006-06-22 22:21:02 +0100150 &nslu2_leds,
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000151};
152
153static void nslu2_power_off(void)
154{
155 /* This causes the box to drop the power and go dead. */
156
157 /* enable the pwr cntl gpio */
158 gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT);
159
160 /* do the deed */
161 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
162}
163
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100164static void __init nslu2_timer_init(void)
165{
166 /* The xtal on this machine is non-standard. */
167 ixp4xx_timer_freq = NSLU2_FREQ;
168
169 /* Call standard timer_init function. */
170 ixp4xx_timer_init();
171}
172
173static struct sys_timer nslu2_timer = {
174 .init = nslu2_timer_init,
175};
176
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000177static void __init nslu2_init(void)
178{
179 ixp4xx_sys_init();
180
Martin Michlmayr3dfaf7a2006-02-16 22:36:12 +0000181 nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
182 nslu2_flash_resource.end =
183 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
184
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000185 pm_power_off = nslu2_power_off;
186
Rod Whitbye28067d2008-01-29 00:36:12 +0100187 i2c_register_board_info(0, nslu2_i2c_board_info,
188 ARRAY_SIZE(nslu2_i2c_board_info));
189
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +0100190 /*
191 * This is only useful on a modified machine, but it is valuable
Rod Whitbye22b04f2006-06-22 22:21:02 +0100192 * to have it first in order to see debug messages, and so that
193 * it does *not* get removed if platform_add_devices fails!
194 */
195 (void)platform_device_register(&nslu2_uart);
196
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000197 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
198}
199
200MACHINE_START(NSLU2, "Linksys NSLU2")
201 /* Maintainer: www.nslu2-linux.org */
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000202 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
203 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
204 .boot_params = 0x00000100,
205 .map_io = ixp4xx_map_io,
206 .init_irq = ixp4xx_init_irq,
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100207 .timer = &nslu2_timer,
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000208 .init_machine = nslu2_init,
209MACHINE_END