blob: 77277d27fcc51bef387520c3fea32d88cf7b3f22 [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>
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010021#include <linux/i2c-gpio.h>
Alessandro Zummoa7918f32005-11-10 14:05:04 +000022
23#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
25#include <asm/mach/flash.h>
Michael-Luke Jones435c5da2007-05-23 22:38:45 +010026#include <asm/mach/time.h>
Alessandro Zummoa7918f32005-11-10 14:05:04 +000027
28static struct flash_platform_data nslu2_flash_data = {
29 .map_name = "cfi_probe",
30 .width = 2,
31};
32
33static struct resource nslu2_flash_resource = {
Alessandro Zummoa7918f32005-11-10 14:05:04 +000034 .flags = IORESOURCE_MEM,
35};
36
37static struct platform_device nslu2_flash = {
38 .name = "IXP4XX-Flash",
39 .id = 0,
40 .dev.platform_data = &nslu2_flash_data,
41 .num_resources = 1,
42 .resource = &nslu2_flash_resource,
43};
44
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010045static struct i2c_gpio_platform_data nslu2_i2c_gpio_data = {
Alessandro Zummoa7918f32005-11-10 14:05:04 +000046 .sda_pin = NSLU2_SDA_PIN,
47 .scl_pin = NSLU2_SCL_PIN,
48};
49
Rod Whitbye22b04f2006-06-22 22:21:02 +010050#ifdef CONFIG_LEDS_IXP4XX
51static struct resource nslu2_led_resources[] = {
52 {
53 .name = "ready", /* green led */
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +010054 .start = NSLU2_LED_GRN_GPIO,
55 .end = NSLU2_LED_GRN_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010056 .flags = IXP4XX_GPIO_HIGH,
57 },
58 {
59 .name = "status", /* red led */
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +010060 .start = NSLU2_LED_RED_GPIO,
61 .end = NSLU2_LED_RED_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010062 .flags = IXP4XX_GPIO_HIGH,
63 },
64 {
65 .name = "disk-1",
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +010066 .start = NSLU2_LED_DISK1_GPIO,
67 .end = NSLU2_LED_DISK1_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010068 .flags = IXP4XX_GPIO_LOW,
69 },
70 {
71 .name = "disk-2",
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +010072 .start = NSLU2_LED_DISK2_GPIO,
73 .end = NSLU2_LED_DISK2_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010074 .flags = IXP4XX_GPIO_LOW,
75 },
76};
77
78static struct platform_device nslu2_leds = {
79 .name = "IXP4XX-GPIO-LED",
80 .id = -1,
81 .num_resources = ARRAY_SIZE(nslu2_led_resources),
82 .resource = nslu2_led_resources,
83};
84#endif
85
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010086static struct platform_device nslu2_i2c_gpio = {
87 .name = "i2c-gpio",
Alessandro Zummoa7918f32005-11-10 14:05:04 +000088 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010089 .dev = {
90 .platform_data = &nslu2_i2c_gpio_data,
91 },
Alessandro Zummoa7918f32005-11-10 14:05:04 +000092};
93
Alessandro Zummobc66d442006-02-22 21:12:06 +000094static struct platform_device nslu2_beeper = {
95 .name = "ixp4xx-beeper",
96 .id = NSLU2_GPIO_BUZZ,
97 .num_resources = 0,
98};
99
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000100static struct resource nslu2_uart_resources[] = {
101 {
102 .start = IXP4XX_UART1_BASE_PHYS,
103 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
104 .flags = IORESOURCE_MEM,
105 },
106 {
107 .start = IXP4XX_UART2_BASE_PHYS,
108 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
109 .flags = IORESOURCE_MEM,
110 }
111};
112
113static struct plat_serial8250_port nslu2_uart_data[] = {
114 {
115 .mapbase = IXP4XX_UART1_BASE_PHYS,
116 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
117 .irq = IRQ_IXP4XX_UART1,
118 .flags = UPF_BOOT_AUTOCONF,
119 .iotype = UPIO_MEM,
120 .regshift = 2,
121 .uartclk = IXP4XX_UART_XTAL,
122 },
123 {
124 .mapbase = IXP4XX_UART2_BASE_PHYS,
125 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
126 .irq = IRQ_IXP4XX_UART2,
127 .flags = UPF_BOOT_AUTOCONF,
128 .iotype = UPIO_MEM,
129 .regshift = 2,
130 .uartclk = IXP4XX_UART_XTAL,
131 },
132 { }
133};
134
135static struct platform_device nslu2_uart = {
136 .name = "serial8250",
137 .id = PLAT8250_DEV_PLATFORM,
138 .dev.platform_data = nslu2_uart_data,
139 .num_resources = 2,
140 .resource = nslu2_uart_resources,
141};
142
143static struct platform_device *nslu2_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100144 &nslu2_i2c_gpio,
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000145 &nslu2_flash,
Alessandro Zummobc66d442006-02-22 21:12:06 +0000146 &nslu2_beeper,
Rod Whitbye22b04f2006-06-22 22:21:02 +0100147#ifdef CONFIG_LEDS_IXP4XX
148 &nslu2_leds,
149#endif
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000150};
151
152static void nslu2_power_off(void)
153{
154 /* This causes the box to drop the power and go dead. */
155
156 /* enable the pwr cntl gpio */
157 gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT);
158
159 /* do the deed */
160 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
161}
162
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100163static void __init nslu2_timer_init(void)
164{
165 /* The xtal on this machine is non-standard. */
166 ixp4xx_timer_freq = NSLU2_FREQ;
167
168 /* Call standard timer_init function. */
169 ixp4xx_timer_init();
170}
171
172static struct sys_timer nslu2_timer = {
173 .init = nslu2_timer_init,
174};
175
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000176static void __init nslu2_init(void)
177{
178 ixp4xx_sys_init();
179
Martin Michlmayr3dfaf7a2006-02-16 22:36:12 +0000180 nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
181 nslu2_flash_resource.end =
182 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
183
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000184 pm_power_off = nslu2_power_off;
185
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +0100186 /*
187 * This is only useful on a modified machine, but it is valuable
Rod Whitbye22b04f2006-06-22 22:21:02 +0100188 * to have it first in order to see debug messages, and so that
189 * it does *not* get removed if platform_add_devices fails!
190 */
191 (void)platform_device_register(&nslu2_uart);
192
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000193 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
194}
195
196MACHINE_START(NSLU2, "Linksys NSLU2")
197 /* Maintainer: www.nslu2-linux.org */
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000198 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
199 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
200 .boot_params = 0x00000100,
201 .map_io = ixp4xx_map_io,
202 .init_irq = ixp4xx_init_irq,
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100203 .timer = &nslu2_timer,
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000204 .init_machine = nslu2_init,
205MACHINE_END