]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-ixp4xx/nas100d-setup.c
[ARM] 4806/1: ixp4xx: Ethernet support for the nslu2 and nas100d boards
[linux-2.6-omap-h63xx.git] / arch / arm / mach-ixp4xx / nas100d-setup.c
1 /*
2  * arch/arm/mach-ixp4xx/nas100d-setup.c
3  *
4  * NAS 100d board-setup
5  *
6  * based ixdp425-setup.c:
7  *      Copyright (C) 2003-2004 MontaVista Software, Inc.
8  *
9  * Author: Alessandro Zummo <a.zummo@towertech.it>
10  * Author: Rod Whitby <rod@whitby.id.au>
11  * Maintainers: http://www.nslu2-linux.org/
12  *
13  */
14
15 #include <linux/if_ether.h>
16 #include <linux/kernel.h>
17 #include <linux/serial.h>
18 #include <linux/serial_8250.h>
19 #include <linux/leds.h>
20 #include <linux/i2c.h>
21 #include <linux/i2c-gpio.h>
22
23 #include <asm/mach-types.h>
24 #include <asm/mach/arch.h>
25 #include <asm/mach/flash.h>
26 #include <asm/io.h>
27
28 static struct flash_platform_data nas100d_flash_data = {
29         .map_name               = "cfi_probe",
30         .width                  = 2,
31 };
32
33 static struct resource nas100d_flash_resource = {
34         .flags                  = IORESOURCE_MEM,
35 };
36
37 static struct platform_device nas100d_flash = {
38         .name                   = "IXP4XX-Flash",
39         .id                     = 0,
40         .dev.platform_data      = &nas100d_flash_data,
41         .num_resources          = 1,
42         .resource               = &nas100d_flash_resource,
43 };
44
45 static struct i2c_board_info __initdata nas100d_i2c_board_info [] = {
46         {
47                 I2C_BOARD_INFO("rtc-pcf8563", 0x51),
48         },
49 };
50
51 static struct gpio_led nas100d_led_pins[] = {
52         {
53                 .name           = "wlan",   /* green led */
54                 .gpio           = NAS100D_LED_WLAN_GPIO,
55                 .active_low     = true,
56         },
57         {
58                 .name           = "power",  /* blue power led (off=flashing) */
59                 .gpio           = NAS100D_LED_PWR_GPIO,
60                 .active_low     = true,
61         },
62         {
63                 .name           = "disk",   /* yellow led */
64                 .gpio           = NAS100D_LED_DISK_GPIO,
65                 .active_low     = true,
66         },
67 };
68
69 static struct gpio_led_platform_data nas100d_led_data = {
70         .num_leds               = ARRAY_SIZE(nas100d_led_pins),
71         .leds                   = nas100d_led_pins,
72 };
73
74 static struct platform_device nas100d_leds = {
75         .name                   = "leds-gpio",
76         .id                     = -1,
77         .dev.platform_data      = &nas100d_led_data,
78 };
79
80 static struct i2c_gpio_platform_data nas100d_i2c_gpio_data = {
81         .sda_pin                = NAS100D_SDA_PIN,
82         .scl_pin                = NAS100D_SCL_PIN,
83 };
84
85 static struct platform_device nas100d_i2c_gpio = {
86         .name                   = "i2c-gpio",
87         .id                     = 0,
88         .dev     = {
89                 .platform_data  = &nas100d_i2c_gpio_data,
90         },
91 };
92
93 static struct resource nas100d_uart_resources[] = {
94         {
95                 .start          = IXP4XX_UART1_BASE_PHYS,
96                 .end            = IXP4XX_UART1_BASE_PHYS + 0x0fff,
97                 .flags          = IORESOURCE_MEM,
98         },
99         {
100                 .start          = IXP4XX_UART2_BASE_PHYS,
101                 .end            = IXP4XX_UART2_BASE_PHYS + 0x0fff,
102                 .flags          = IORESOURCE_MEM,
103         }
104 };
105
106 static struct plat_serial8250_port nas100d_uart_data[] = {
107         {
108                 .mapbase        = IXP4XX_UART1_BASE_PHYS,
109                 .membase        = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
110                 .irq            = IRQ_IXP4XX_UART1,
111                 .flags          = UPF_BOOT_AUTOCONF,
112                 .iotype         = UPIO_MEM,
113                 .regshift       = 2,
114                 .uartclk        = IXP4XX_UART_XTAL,
115         },
116         {
117                 .mapbase        = IXP4XX_UART2_BASE_PHYS,
118                 .membase        = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
119                 .irq            = IRQ_IXP4XX_UART2,
120                 .flags          = UPF_BOOT_AUTOCONF,
121                 .iotype         = UPIO_MEM,
122                 .regshift       = 2,
123                 .uartclk        = IXP4XX_UART_XTAL,
124         },
125         { }
126 };
127
128 static struct platform_device nas100d_uart = {
129         .name                   = "serial8250",
130         .id                     = PLAT8250_DEV_PLATFORM,
131         .dev.platform_data      = nas100d_uart_data,
132         .num_resources          = 2,
133         .resource               = nas100d_uart_resources,
134 };
135
136 /* Built-in 10/100 Ethernet MAC interfaces */
137 static struct eth_plat_info nas100d_plat_eth[] = {
138         {
139                 .phy            = 0,
140                 .rxq            = 3,
141                 .txreadyq       = 20,
142         }
143 };
144
145 static struct platform_device nas100d_eth[] = {
146         {
147                 .name                   = "ixp4xx_eth",
148                 .id                     = IXP4XX_ETH_NPEB,
149                 .dev.platform_data      = nas100d_plat_eth,
150         }
151 };
152
153 static struct platform_device *nas100d_devices[] __initdata = {
154         &nas100d_i2c_gpio,
155         &nas100d_flash,
156         &nas100d_leds,
157         &nas100d_eth[0],
158 };
159
160 static void nas100d_power_off(void)
161 {
162         /* This causes the box to drop the power and go dead. */
163
164         /* enable the pwr cntl gpio */
165         gpio_line_config(NAS100D_PO_GPIO, IXP4XX_GPIO_OUT);
166
167         /* do the deed */
168         gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH);
169 }
170
171 static void __init nas100d_init(void)
172 {
173         DECLARE_MAC_BUF(mac_buf);
174         uint8_t __iomem *f;
175         int i;
176
177         ixp4xx_sys_init();
178
179         /* gpio 14 and 15 are _not_ clocks */
180         *IXP4XX_GPIO_GPCLKR = 0;
181
182         nas100d_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
183         nas100d_flash_resource.end =
184                 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
185
186         pm_power_off = nas100d_power_off;
187
188         i2c_register_board_info(0, nas100d_i2c_board_info,
189                                 ARRAY_SIZE(nas100d_i2c_board_info));
190
191         /*
192          * This is only useful on a modified machine, but it is valuable
193          * to have it first in order to see debug messages, and so that
194          * it does *not* get removed if platform_add_devices fails!
195          */
196         (void)platform_device_register(&nas100d_uart);
197
198         platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
199
200         /*
201          * Map in a portion of the flash and read the MAC address.
202          * Since it is stored in BE in the flash itself, we need to
203          * byteswap it if we're in LE mode.
204          */
205         f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x1000000);
206         if (f) {
207                 for (i = 0; i < 6; i++)
208 #ifdef __ARMEB__
209                         nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + i);
210 #else
211                         nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + (i^3));
212 #endif
213                 iounmap(f);
214         }
215         printk(KERN_INFO "NAS100D: Using MAC address %s for port 0\n",
216                print_mac(mac_buf, nas100d_plat_eth[0].hwaddr));
217
218 }
219
220 MACHINE_START(NAS100D, "Iomega NAS 100d")
221         /* Maintainer: www.nslu2-linux.org */
222         .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
223         .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
224         .boot_params    = 0x00000100,
225         .map_io         = ixp4xx_map_io,
226         .init_irq       = ixp4xx_init_irq,
227         .timer          = &ixp4xx_timer,
228         .init_machine   = nas100d_init,
229 MACHINE_END