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