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