blob: 16d091c98ea690cf017199bbeda91f44e9850c22 [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 Whitbye22b04f2006-06-22 22:21:02 +010057#ifdef CONFIG_LEDS_IXP4XX
58static struct resource nslu2_led_resources[] = {
59 {
60 .name = "ready", /* green led */
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +010061 .start = NSLU2_LED_GRN_GPIO,
62 .end = NSLU2_LED_GRN_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010063 .flags = IXP4XX_GPIO_HIGH,
64 },
65 {
66 .name = "status", /* red led */
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +010067 .start = NSLU2_LED_RED_GPIO,
68 .end = NSLU2_LED_RED_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010069 .flags = IXP4XX_GPIO_HIGH,
70 },
71 {
72 .name = "disk-1",
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +010073 .start = NSLU2_LED_DISK1_GPIO,
74 .end = NSLU2_LED_DISK1_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010075 .flags = IXP4XX_GPIO_LOW,
76 },
77 {
78 .name = "disk-2",
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +010079 .start = NSLU2_LED_DISK2_GPIO,
80 .end = NSLU2_LED_DISK2_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010081 .flags = IXP4XX_GPIO_LOW,
82 },
83};
84
85static struct platform_device nslu2_leds = {
86 .name = "IXP4XX-GPIO-LED",
87 .id = -1,
88 .num_resources = ARRAY_SIZE(nslu2_led_resources),
89 .resource = nslu2_led_resources,
90};
91#endif
92
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010093static struct platform_device nslu2_i2c_gpio = {
94 .name = "i2c-gpio",
Alessandro Zummoa7918f32005-11-10 14:05:04 +000095 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010096 .dev = {
97 .platform_data = &nslu2_i2c_gpio_data,
98 },
Alessandro Zummoa7918f32005-11-10 14:05:04 +000099};
100
Alessandro Zummobc66d442006-02-22 21:12:06 +0000101static struct platform_device nslu2_beeper = {
102 .name = "ixp4xx-beeper",
103 .id = NSLU2_GPIO_BUZZ,
104 .num_resources = 0,
105};
106
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000107static struct resource nslu2_uart_resources[] = {
108 {
109 .start = IXP4XX_UART1_BASE_PHYS,
110 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
111 .flags = IORESOURCE_MEM,
112 },
113 {
114 .start = IXP4XX_UART2_BASE_PHYS,
115 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
116 .flags = IORESOURCE_MEM,
117 }
118};
119
120static struct plat_serial8250_port nslu2_uart_data[] = {
121 {
122 .mapbase = IXP4XX_UART1_BASE_PHYS,
123 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
124 .irq = IRQ_IXP4XX_UART1,
125 .flags = UPF_BOOT_AUTOCONF,
126 .iotype = UPIO_MEM,
127 .regshift = 2,
128 .uartclk = IXP4XX_UART_XTAL,
129 },
130 {
131 .mapbase = IXP4XX_UART2_BASE_PHYS,
132 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
133 .irq = IRQ_IXP4XX_UART2,
134 .flags = UPF_BOOT_AUTOCONF,
135 .iotype = UPIO_MEM,
136 .regshift = 2,
137 .uartclk = IXP4XX_UART_XTAL,
138 },
139 { }
140};
141
142static struct platform_device nslu2_uart = {
143 .name = "serial8250",
144 .id = PLAT8250_DEV_PLATFORM,
145 .dev.platform_data = nslu2_uart_data,
146 .num_resources = 2,
147 .resource = nslu2_uart_resources,
148};
149
150static struct platform_device *nslu2_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100151 &nslu2_i2c_gpio,
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000152 &nslu2_flash,
Alessandro Zummobc66d442006-02-22 21:12:06 +0000153 &nslu2_beeper,
Rod Whitbye22b04f2006-06-22 22:21:02 +0100154#ifdef CONFIG_LEDS_IXP4XX
155 &nslu2_leds,
156#endif
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000157};
158
159static void nslu2_power_off(void)
160{
161 /* This causes the box to drop the power and go dead. */
162
163 /* enable the pwr cntl gpio */
164 gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT);
165
166 /* do the deed */
167 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
168}
169
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100170static void __init nslu2_timer_init(void)
171{
172 /* The xtal on this machine is non-standard. */
173 ixp4xx_timer_freq = NSLU2_FREQ;
174
175 /* Call standard timer_init function. */
176 ixp4xx_timer_init();
177}
178
179static struct sys_timer nslu2_timer = {
180 .init = nslu2_timer_init,
181};
182
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000183static void __init nslu2_init(void)
184{
185 ixp4xx_sys_init();
186
Martin Michlmayr3dfaf7a2006-02-16 22:36:12 +0000187 nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
188 nslu2_flash_resource.end =
189 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
190
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000191 pm_power_off = nslu2_power_off;
192
Rod Whitbye28067d2008-01-29 00:36:12 +0100193 i2c_register_board_info(0, nslu2_i2c_board_info,
194 ARRAY_SIZE(nslu2_i2c_board_info));
195
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +0100196 /*
197 * This is only useful on a modified machine, but it is valuable
Rod Whitbye22b04f2006-06-22 22:21:02 +0100198 * to have it first in order to see debug messages, and so that
199 * it does *not* get removed if platform_add_devices fails!
200 */
201 (void)platform_device_register(&nslu2_uart);
202
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000203 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
204}
205
206MACHINE_START(NSLU2, "Linksys NSLU2")
207 /* Maintainer: www.nslu2-linux.org */
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000208 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
209 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
210 .boot_params = 0x00000100,
211 .map_io = ixp4xx_map_io,
212 .init_irq = ixp4xx_init_irq,
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100213 .timer = &nslu2_timer,
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000214 .init_machine = nslu2_init,
215MACHINE_END