[ARM] 4806/1: ixp4xx: Ethernet support for the nslu2 and nas100d boards
[deliverable/linux.git] / arch / arm / mach-ixp4xx / nslu2-setup.c
CommitLineData
a7918f39
AZ
1/*
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>
e22b04fb 10 * Author: Rod Whitby <rod@whitby.id.au>
a7918f39
AZ
11 * 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
b7edc84a 17#include <linux/if_ether.h>
a7918f39
AZ
18#include <linux/kernel.h>
19#include <linux/serial.h>
20#include <linux/serial_8250.h>
e22b04fb 21#include <linux/leds.h>
e28067d5 22#include <linux/i2c.h>
5a4a2387 23#include <linux/i2c-gpio.h>
a7918f39
AZ
24
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27#include <asm/mach/flash.h>
435c5da0 28#include <asm/mach/time.h>
b7edc84a 29#include <asm/io.h>
a7918f39
AZ
30
31static struct flash_platform_data nslu2_flash_data = {
32 .map_name = "cfi_probe",
33 .width = 2,
34};
35
36static struct resource nslu2_flash_resource = {
a7918f39
AZ
37 .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
5a4a2387 48static struct i2c_gpio_platform_data nslu2_i2c_gpio_data = {
a7918f39
AZ
49 .sda_pin = NSLU2_SDA_PIN,
50 .scl_pin = NSLU2_SCL_PIN,
51};
52
e28067d5
RW
53static struct i2c_board_info __initdata nslu2_i2c_board_info [] = {
54 {
55 I2C_BOARD_INFO("rtc-x1205", 0x6f),
56 },
57};
58
1208ebf2 59static struct gpio_led nslu2_led_pins[] = {
e22b04fb
RW
60 {
61 .name = "ready", /* green led */
1208ebf2 62 .gpio = NSLU2_LED_GRN_GPIO,
e22b04fb
RW
63 },
64 {
65 .name = "status", /* red led */
1208ebf2 66 .gpio = NSLU2_LED_RED_GPIO,
e22b04fb
RW
67 },
68 {
69 .name = "disk-1",
1208ebf2
RW
70 .gpio = NSLU2_LED_DISK1_GPIO,
71 .active_low = true,
e22b04fb
RW
72 },
73 {
74 .name = "disk-2",
1208ebf2
RW
75 .gpio = NSLU2_LED_DISK2_GPIO,
76 .active_low = true,
e22b04fb
RW
77 },
78};
79
1208ebf2
RW
80static struct gpio_led_platform_data nslu2_led_data = {
81 .num_leds = ARRAY_SIZE(nslu2_led_pins),
82 .leds = nslu2_led_pins,
83};
84
e22b04fb 85static struct platform_device nslu2_leds = {
1208ebf2 86 .name = "leds-gpio",
e22b04fb 87 .id = -1,
1208ebf2 88 .dev.platform_data = &nslu2_led_data,
e22b04fb 89};
e22b04fb 90
5a4a2387
MLJ
91static struct platform_device nslu2_i2c_gpio = {
92 .name = "i2c-gpio",
a7918f39 93 .id = 0,
5a4a2387
MLJ
94 .dev = {
95 .platform_data = &nslu2_i2c_gpio_data,
96 },
a7918f39
AZ
97};
98
bc66d449
AZ
99static struct platform_device nslu2_beeper = {
100 .name = "ixp4xx-beeper",
101 .id = NSLU2_GPIO_BUZZ,
102 .num_resources = 0,
103};
104
a7918f39
AZ
105static 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
b7edc84a
RW
148/* 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
a7918f39 165static struct platform_device *nslu2_devices[] __initdata = {
5a4a2387 166 &nslu2_i2c_gpio,
a7918f39 167 &nslu2_flash,
bc66d449 168 &nslu2_beeper,
e22b04fb 169 &nslu2_leds,
b7edc84a 170 &nslu2_eth[0],
a7918f39
AZ
171};
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
435c5da0 184static void __init nslu2_timer_init(void)
a7918f39 185{
435c5da0
MLJ
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}
84904d0e 192
435c5da0
MLJ
193static struct sys_timer nslu2_timer = {
194 .init = nslu2_timer_init,
195};
196
197static void __init nslu2_init(void)
198{
b7edc84a
RW
199 DECLARE_MAC_BUF(mac_buf);
200 uint8_t __iomem *f;
201 int i;
202
a7918f39
AZ
203 ixp4xx_sys_init();
204
3dfaf7a6
MM
205 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
a7918f39
AZ
209 pm_power_off = nslu2_power_off;
210
e28067d5
RW
211 i2c_register_board_info(0, nslu2_i2c_board_info,
212 ARRAY_SIZE(nslu2_i2c_board_info));
213
cc50a0df
MLJ
214 /*
215 * This is only useful on a modified machine, but it is valuable
e22b04fb
RW
216 * 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
a7918f39 221 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
b7edc84a
RW
222
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
a7918f39
AZ
242}
243
244MACHINE_START(NSLU2, "Linksys NSLU2")
245 /* Maintainer: www.nslu2-linux.org */
a7918f39
AZ
246 .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,
435c5da0 251 .timer = &nslu2_timer,
a7918f39
AZ
252 .init_machine = nslu2_init,
253MACHINE_END
This page took 0.244119 seconds and 5 git commands to generate.