blob: fd9ec17c8b86280dfacd4d7c1c37477d45e5a64c [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
Rod Whitbyb7edc842008-02-02 00:04:05 +010017#include <linux/if_ether.h>
Alessandro Zummoa7918f32005-11-10 14:05:04 +000018#include <linux/kernel.h>
19#include <linux/serial.h>
20#include <linux/serial_8250.h>
Rod Whitbye22b04f2006-06-22 22:21:02 +010021#include <linux/leds.h>
Rod Whitbye28067d2008-01-29 00:36:12 +010022#include <linux/i2c.h>
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010023#include <linux/i2c-gpio.h>
Alessandro Zummoa7918f32005-11-10 14:05:04 +000024
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27#include <asm/mach/flash.h>
Michael-Luke Jones435c5da2007-05-23 22:38:45 +010028#include <asm/mach/time.h>
Rod Whitbyb7edc842008-02-02 00:04:05 +010029#include <asm/io.h>
Alessandro Zummoa7918f32005-11-10 14:05:04 +000030
31static struct flash_platform_data nslu2_flash_data = {
32 .map_name = "cfi_probe",
33 .width = 2,
34};
35
36static struct resource nslu2_flash_resource = {
Alessandro Zummoa7918f32005-11-10 14:05:04 +000037 .flags = IORESOURCE_MEM,
38};
39
40static struct platform_device nslu2_flash = {
41 .name = "IXP4XX-Flash",
42 .id = 0,
43 .dev.platform_data = &nslu2_flash_data,
44 .num_resources = 1,
45 .resource = &nslu2_flash_resource,
46};
47
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010048static struct i2c_gpio_platform_data nslu2_i2c_gpio_data = {
Alessandro Zummoa7918f32005-11-10 14:05:04 +000049 .sda_pin = NSLU2_SDA_PIN,
50 .scl_pin = NSLU2_SCL_PIN,
51};
52
Rod Whitbye28067d2008-01-29 00:36:12 +010053static struct i2c_board_info __initdata nslu2_i2c_board_info [] = {
54 {
55 I2C_BOARD_INFO("rtc-x1205", 0x6f),
56 },
57};
58
Rod Whitby1208ebf2008-02-02 00:03:56 +010059static struct gpio_led nslu2_led_pins[] = {
Rod Whitbye22b04f2006-06-22 22:21:02 +010060 {
61 .name = "ready", /* green led */
Rod Whitby1208ebf2008-02-02 00:03:56 +010062 .gpio = NSLU2_LED_GRN_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010063 },
64 {
65 .name = "status", /* red led */
Rod Whitby1208ebf2008-02-02 00:03:56 +010066 .gpio = NSLU2_LED_RED_GPIO,
Rod Whitbye22b04f2006-06-22 22:21:02 +010067 },
68 {
69 .name = "disk-1",
Rod Whitby1208ebf2008-02-02 00:03:56 +010070 .gpio = NSLU2_LED_DISK1_GPIO,
71 .active_low = true,
Rod Whitbye22b04f2006-06-22 22:21:02 +010072 },
73 {
74 .name = "disk-2",
Rod Whitby1208ebf2008-02-02 00:03:56 +010075 .gpio = NSLU2_LED_DISK2_GPIO,
76 .active_low = true,
Rod Whitbye22b04f2006-06-22 22:21:02 +010077 },
78};
79
Rod Whitby1208ebf2008-02-02 00:03:56 +010080static struct gpio_led_platform_data nslu2_led_data = {
81 .num_leds = ARRAY_SIZE(nslu2_led_pins),
82 .leds = nslu2_led_pins,
Rod Whitbye22b04f2006-06-22 22:21:02 +010083};
Rod Whitby1208ebf2008-02-02 00:03:56 +010084
85static struct platform_device nslu2_leds = {
86 .name = "leds-gpio",
87 .id = -1,
88 .dev.platform_data = &nslu2_led_data,
89};
Rod Whitbye22b04f2006-06-22 22:21:02 +010090
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010091static struct platform_device nslu2_i2c_gpio = {
92 .name = "i2c-gpio",
Alessandro Zummoa7918f32005-11-10 14:05:04 +000093 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010094 .dev = {
95 .platform_data = &nslu2_i2c_gpio_data,
96 },
Alessandro Zummoa7918f32005-11-10 14:05:04 +000097};
98
Alessandro Zummobc66d442006-02-22 21:12:06 +000099static struct platform_device nslu2_beeper = {
100 .name = "ixp4xx-beeper",
101 .id = NSLU2_GPIO_BUZZ,
102 .num_resources = 0,
103};
104
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000105static struct resource nslu2_uart_resources[] = {
106 {
107 .start = IXP4XX_UART1_BASE_PHYS,
108 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
109 .flags = IORESOURCE_MEM,
110 },
111 {
112 .start = IXP4XX_UART2_BASE_PHYS,
113 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
114 .flags = IORESOURCE_MEM,
115 }
116};
117
118static struct plat_serial8250_port nslu2_uart_data[] = {
119 {
120 .mapbase = IXP4XX_UART1_BASE_PHYS,
121 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
122 .irq = IRQ_IXP4XX_UART1,
123 .flags = UPF_BOOT_AUTOCONF,
124 .iotype = UPIO_MEM,
125 .regshift = 2,
126 .uartclk = IXP4XX_UART_XTAL,
127 },
128 {
129 .mapbase = IXP4XX_UART2_BASE_PHYS,
130 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
131 .irq = IRQ_IXP4XX_UART2,
132 .flags = UPF_BOOT_AUTOCONF,
133 .iotype = UPIO_MEM,
134 .regshift = 2,
135 .uartclk = IXP4XX_UART_XTAL,
136 },
137 { }
138};
139
140static struct platform_device nslu2_uart = {
141 .name = "serial8250",
142 .id = PLAT8250_DEV_PLATFORM,
143 .dev.platform_data = nslu2_uart_data,
144 .num_resources = 2,
145 .resource = nslu2_uart_resources,
146};
147
Rod Whitbyb7edc842008-02-02 00:04:05 +0100148/* Built-in 10/100 Ethernet MAC interfaces */
149static struct eth_plat_info nslu2_plat_eth[] = {
150 {
151 .phy = 1,
152 .rxq = 3,
153 .txreadyq = 20,
154 }
155};
156
157static struct platform_device nslu2_eth[] = {
158 {
159 .name = "ixp4xx_eth",
160 .id = IXP4XX_ETH_NPEB,
161 .dev.platform_data = nslu2_plat_eth,
162 }
163};
164
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000165static struct platform_device *nslu2_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100166 &nslu2_i2c_gpio,
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000167 &nslu2_flash,
Alessandro Zummobc66d442006-02-22 21:12:06 +0000168 &nslu2_beeper,
Rod Whitbye22b04f2006-06-22 22:21:02 +0100169 &nslu2_leds,
Rod Whitbyb7edc842008-02-02 00:04:05 +0100170 &nslu2_eth[0],
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000171};
172
173static void nslu2_power_off(void)
174{
175 /* This causes the box to drop the power and go dead. */
176
177 /* enable the pwr cntl gpio */
178 gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT);
179
180 /* do the deed */
181 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
182}
183
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100184static void __init nslu2_timer_init(void)
185{
186 /* The xtal on this machine is non-standard. */
187 ixp4xx_timer_freq = NSLU2_FREQ;
188
189 /* Call standard timer_init function. */
190 ixp4xx_timer_init();
191}
192
193static struct sys_timer nslu2_timer = {
194 .init = nslu2_timer_init,
195};
196
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000197static void __init nslu2_init(void)
198{
Rod Whitbyb7edc842008-02-02 00:04:05 +0100199 DECLARE_MAC_BUF(mac_buf);
200 uint8_t __iomem *f;
201 int i;
202
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000203 ixp4xx_sys_init();
204
Martin Michlmayr3dfaf7a2006-02-16 22:36:12 +0000205 nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
206 nslu2_flash_resource.end =
207 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
208
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000209 pm_power_off = nslu2_power_off;
210
Rod Whitbye28067d2008-01-29 00:36:12 +0100211 i2c_register_board_info(0, nslu2_i2c_board_info,
212 ARRAY_SIZE(nslu2_i2c_board_info));
213
Michael-Luke Jonescc50a0d2007-05-23 22:41:53 +0100214 /*
215 * This is only useful on a modified machine, but it is valuable
Rod Whitbye22b04f2006-06-22 22:21:02 +0100216 * to have it first in order to see debug messages, and so that
217 * it does *not* get removed if platform_add_devices fails!
218 */
219 (void)platform_device_register(&nslu2_uart);
220
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000221 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
Rod Whitbyb7edc842008-02-02 00:04:05 +0100222
223
224 /*
225 * Map in a portion of the flash and read the MAC address.
226 * Since it is stored in BE in the flash itself, we need to
227 * byteswap it if we're in LE mode.
228 */
229 f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x40000);
230 if (f) {
231 for (i = 0; i < 6; i++)
232#ifdef __ARMEB__
233 nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + i);
234#else
235 nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + (i^3));
236#endif
237 iounmap(f);
238 }
239 printk(KERN_INFO "NSLU2: Using MAC address %s for port 0\n",
240 print_mac(mac_buf, nslu2_plat_eth[0].hwaddr));
241
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000242}
243
244MACHINE_START(NSLU2, "Linksys NSLU2")
245 /* Maintainer: www.nslu2-linux.org */
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000246 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
247 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
248 .boot_params = 0x00000100,
249 .map_io = ixp4xx_map_io,
250 .init_irq = ixp4xx_init_irq,
Michael-Luke Jones435c5da2007-05-23 22:38:45 +0100251 .timer = &nslu2_timer,
Alessandro Zummoa7918f32005-11-10 14:05:04 +0000252 .init_machine = nslu2_init,
253MACHINE_END