Pull osi-now into release branch
[pandora-kernel.git] / arch / arm / mach-ixp4xx / dsmg600-setup.c
1 /*
2  * DSM-G600 board-setup
3  *
4  * Copyright (C) 2006 Tower Technologies
5  * Author: Alessandro Zummo <a.zummo@towertech.it>
6  *
7  * based ixdp425-setup.c:
8  *      Copyright (C) 2003-2004 MontaVista Software, Inc.
9  *
10  * Author: Alessandro Zummo <a.zummo@towertech.it>
11  * Maintainers: http://www.nslu2-linux.org/
12  */
13
14 #include <linux/kernel.h>
15 #include <linux/serial.h>
16 #include <linux/serial_8250.h>
17
18 #include <asm/mach-types.h>
19 #include <asm/mach/arch.h>
20 #include <asm/mach/flash.h>
21 #include <asm/mach/time.h>
22
23 static struct flash_platform_data dsmg600_flash_data = {
24         .map_name               = "cfi_probe",
25         .width                  = 2,
26 };
27
28 static struct resource dsmg600_flash_resource = {
29         .flags                  = IORESOURCE_MEM,
30 };
31
32 static struct platform_device dsmg600_flash = {
33         .name                   = "IXP4XX-Flash",
34         .id                     = 0,
35         .dev.platform_data      = &dsmg600_flash_data,
36         .num_resources          = 1,
37         .resource               = &dsmg600_flash_resource,
38 };
39
40 static struct ixp4xx_i2c_pins dsmg600_i2c_gpio_pins = {
41         .sda_pin                = DSMG600_SDA_PIN,
42         .scl_pin                = DSMG600_SCL_PIN,
43 };
44
45 static struct platform_device dsmg600_i2c_controller = {
46         .name                   = "IXP4XX-I2C",
47         .id                     = 0,
48         .dev.platform_data      = &dsmg600_i2c_gpio_pins,
49 };
50
51 #ifdef CONFIG_LEDS_CLASS
52 static struct resource dsmg600_led_resources[] = {
53         {
54                 .name           = "power",
55                 .start          = DSMG600_LED_PWR_GPIO,
56                 .end            = DSMG600_LED_PWR_GPIO,
57                 .flags          = IXP4XX_GPIO_HIGH,
58         },
59         {
60                 .name           = "wlan",
61                 .start          = DSMG600_LED_WLAN_GPIO,
62                 .end            = DSMG600_LED_WLAN_GPIO,
63                 .flags          = IXP4XX_GPIO_LOW,
64         },
65 };
66
67 static struct platform_device dsmg600_leds = {
68         .name                   = "IXP4XX-GPIO-LED",
69         .id                     = -1,
70         .num_resources          = ARRAY_SIZE(dsmg600_led_resources),
71         .resource               = dsmg600_led_resources,
72 };
73 #endif
74
75 static struct resource dsmg600_uart_resources[] = {
76         {
77                 .start          = IXP4XX_UART1_BASE_PHYS,
78                 .end            = IXP4XX_UART1_BASE_PHYS + 0x0fff,
79                 .flags          = IORESOURCE_MEM,
80         },
81         {
82                 .start          = IXP4XX_UART2_BASE_PHYS,
83                 .end            = IXP4XX_UART2_BASE_PHYS + 0x0fff,
84                 .flags          = IORESOURCE_MEM,
85         }
86 };
87
88 static struct plat_serial8250_port dsmg600_uart_data[] = {
89         {
90                 .mapbase        = IXP4XX_UART1_BASE_PHYS,
91                 .membase        = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
92                 .irq            = IRQ_IXP4XX_UART1,
93                 .flags          = UPF_BOOT_AUTOCONF,
94                 .iotype         = UPIO_MEM,
95                 .regshift       = 2,
96                 .uartclk        = IXP4XX_UART_XTAL,
97         },
98         {
99                 .mapbase        = IXP4XX_UART2_BASE_PHYS,
100                 .membase        = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
101                 .irq            = IRQ_IXP4XX_UART2,
102                 .flags          = UPF_BOOT_AUTOCONF,
103                 .iotype         = UPIO_MEM,
104                 .regshift       = 2,
105                 .uartclk        = IXP4XX_UART_XTAL,
106         },
107         { }
108 };
109
110 static struct platform_device dsmg600_uart = {
111         .name                   = "serial8250",
112         .id                     = PLAT8250_DEV_PLATFORM,
113         .dev.platform_data      = dsmg600_uart_data,
114         .num_resources          = ARRAY_SIZE(dsmg600_uart_resources),
115         .resource               = dsmg600_uart_resources,
116 };
117
118 static struct platform_device *dsmg600_devices[] __initdata = {
119         &dsmg600_i2c_controller,
120         &dsmg600_flash,
121 };
122
123 static void dsmg600_power_off(void)
124 {
125         /* enable the pwr cntl gpio */
126         gpio_line_config(DSMG600_PO_GPIO, IXP4XX_GPIO_OUT);
127
128         /* poweroff */
129         gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
130 }
131
132 static void __init dsmg600_timer_init(void)
133 {
134     /* The xtal on this machine is non-standard. */
135     ixp4xx_timer_freq = DSMG600_FREQ;
136
137     /* Call standard timer_init function. */
138     ixp4xx_timer_init();
139 }
140
141 static struct sys_timer dsmg600_timer = {
142     .init   = dsmg600_timer_init,
143 };
144
145 static void __init dsmg600_init(void)
146 {
147         ixp4xx_sys_init();
148
149         /* Make sure that GPIO14 and GPIO15 are not used as clocks */
150         *IXP4XX_GPIO_GPCLKR = 0;
151
152         dsmg600_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
153         dsmg600_flash_resource.end =
154                 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
155
156         pm_power_off = dsmg600_power_off;
157
158         /* The UART is required on the DSM-G600 (Redboot cannot use the
159          * NIC) -- do it here so that it does *not* get removed if
160          * platform_add_devices fails!
161          */
162         (void)platform_device_register(&dsmg600_uart);
163
164         platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
165
166 #ifdef CONFIG_LEDS_CLASS
167         /* We don't care whether or not this works. */
168         (void)platform_device_register(&dsmg600_leds);
169 #endif
170 }
171
172 MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
173         /* Maintainer: www.nslu2-linux.org */
174         .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
175         .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
176         .boot_params    = 0x00000100,
177         .map_io         = ixp4xx_map_io,
178         .init_irq       = ixp4xx_init_irq,
179         .timer          = &dsmg600_timer,
180         .init_machine   = dsmg600_init,
181 MACHINE_END