]> err.no Git - linux-2.6/blob - arch/arm/mach-ixp4xx/nas100d-setup.c
[ARM] 4805/1: ixp4xx: Use leds-gpio driver instead of IXP4XX-GPIO-LED driver
[linux-2.6] / 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/kernel.h>
16 #include <linux/serial.h>
17 #include <linux/serial_8250.h>
18 #include <linux/leds.h>
19 #include <linux/i2c.h>
20 #include <linux/i2c-gpio.h>
21
22 #include <asm/mach-types.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/flash.h>
25
26 static struct flash_platform_data nas100d_flash_data = {
27         .map_name               = "cfi_probe",
28         .width                  = 2,
29 };
30
31 static struct resource nas100d_flash_resource = {
32         .flags                  = IORESOURCE_MEM,
33 };
34
35 static struct platform_device nas100d_flash = {
36         .name                   = "IXP4XX-Flash",
37         .id                     = 0,
38         .dev.platform_data      = &nas100d_flash_data,
39         .num_resources          = 1,
40         .resource               = &nas100d_flash_resource,
41 };
42
43 static struct i2c_board_info __initdata nas100d_i2c_board_info [] = {
44         {
45                 I2C_BOARD_INFO("rtc-pcf8563", 0x51),
46         },
47 };
48
49 static struct gpio_led nas100d_led_pins[] = {
50         {
51                 .name           = "wlan",   /* green led */
52                 .gpio           = NAS100D_LED_WLAN_GPIO,
53                 .active_low     = true,
54         },
55         {
56                 .name           = "power",  /* blue power led (off=flashing) */
57                 .gpio           = NAS100D_LED_PWR_GPIO,
58                 .active_low     = true,
59         },
60         {
61                 .name           = "disk",   /* yellow led */
62                 .gpio           = NAS100D_LED_DISK_GPIO,
63                 .active_low     = true,
64         },
65 };
66
67 static struct gpio_led_platform_data nas100d_led_data = {
68         .num_leds               = ARRAY_SIZE(nas100d_led_pins),
69         .leds                   = nas100d_led_pins,
70 };
71
72 static struct platform_device nas100d_leds = {
73         .name                   = "leds-gpio",
74         .id                     = -1,
75         .dev.platform_data      = &nas100d_led_data,
76 };
77
78 static struct i2c_gpio_platform_data nas100d_i2c_gpio_data = {
79         .sda_pin                = NAS100D_SDA_PIN,
80         .scl_pin                = NAS100D_SCL_PIN,
81 };
82
83 static struct platform_device nas100d_i2c_gpio = {
84         .name                   = "i2c-gpio",
85         .id                     = 0,
86         .dev     = {
87                 .platform_data  = &nas100d_i2c_gpio_data,
88         },
89 };
90
91 static struct resource nas100d_uart_resources[] = {
92         {
93                 .start          = IXP4XX_UART1_BASE_PHYS,
94                 .end            = IXP4XX_UART1_BASE_PHYS + 0x0fff,
95                 .flags          = IORESOURCE_MEM,
96         },
97         {
98                 .start          = IXP4XX_UART2_BASE_PHYS,
99                 .end            = IXP4XX_UART2_BASE_PHYS + 0x0fff,
100                 .flags          = IORESOURCE_MEM,
101         }
102 };
103
104 static struct plat_serial8250_port nas100d_uart_data[] = {
105         {
106                 .mapbase        = IXP4XX_UART1_BASE_PHYS,
107                 .membase        = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
108                 .irq            = IRQ_IXP4XX_UART1,
109                 .flags          = UPF_BOOT_AUTOCONF,
110                 .iotype         = UPIO_MEM,
111                 .regshift       = 2,
112                 .uartclk        = IXP4XX_UART_XTAL,
113         },
114         {
115                 .mapbase        = IXP4XX_UART2_BASE_PHYS,
116                 .membase        = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
117                 .irq            = IRQ_IXP4XX_UART2,
118                 .flags          = UPF_BOOT_AUTOCONF,
119                 .iotype         = UPIO_MEM,
120                 .regshift       = 2,
121                 .uartclk        = IXP4XX_UART_XTAL,
122         },
123         { }
124 };
125
126 static struct platform_device nas100d_uart = {
127         .name                   = "serial8250",
128         .id                     = PLAT8250_DEV_PLATFORM,
129         .dev.platform_data      = nas100d_uart_data,
130         .num_resources          = 2,
131         .resource               = nas100d_uart_resources,
132 };
133
134 static struct platform_device *nas100d_devices[] __initdata = {
135         &nas100d_i2c_gpio,
136         &nas100d_flash,
137         &nas100d_leds,
138 };
139
140 static void nas100d_power_off(void)
141 {
142         /* This causes the box to drop the power and go dead. */
143
144         /* enable the pwr cntl gpio */
145         gpio_line_config(NAS100D_PO_GPIO, IXP4XX_GPIO_OUT);
146
147         /* do the deed */
148         gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH);
149 }
150
151 static void __init nas100d_init(void)
152 {
153         ixp4xx_sys_init();
154
155         /* gpio 14 and 15 are _not_ clocks */
156         *IXP4XX_GPIO_GPCLKR = 0;
157
158         nas100d_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
159         nas100d_flash_resource.end =
160                 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
161
162         pm_power_off = nas100d_power_off;
163
164         i2c_register_board_info(0, nas100d_i2c_board_info,
165                                 ARRAY_SIZE(nas100d_i2c_board_info));
166
167         /*
168          * This is only useful on a modified machine, but it is valuable
169          * to have it first in order to see debug messages, and so that
170          * it does *not* get removed if platform_add_devices fails!
171          */
172         (void)platform_device_register(&nas100d_uart);
173
174         platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
175 }
176
177 MACHINE_START(NAS100D, "Iomega NAS 100d")
178         /* Maintainer: www.nslu2-linux.org */
179         .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
180         .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
181         .boot_params    = 0x00000100,
182         .map_io         = ixp4xx_map_io,
183         .init_irq       = ixp4xx_init_irq,
184         .timer          = &ixp4xx_timer,
185         .init_machine   = nas100d_init,
186 MACHINE_END