x86/mm/pat: Don't report PAT on CPUs that don't support it
[linux/fpc-iii.git] / arch / arm / mach-ixp4xx / dsmg600-setup.c
blobb3bd0e137f6d1dec8d76e5305197002c7bf831fa
1 /*
2 * DSM-G600 board-setup
4 * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
5 * Copyright (C) 2006 Tower Technologies
7 * based on ixdp425-setup.c:
8 * Copyright (C) 2003-2004 MontaVista Software, Inc.
9 * based on nslu2-power.c:
10 * Copyright (C) 2005 Tower Technologies
11 * based on nslu2-io.c:
12 * Copyright (C) 2004 Karen Spearel
14 * Author: Alessandro Zummo <a.zummo@towertech.it>
15 * Author: Michael Westerhof <mwester@dls.net>
16 * Author: Rod Whitby <rod@whitby.id.au>
17 * Maintainers: http://www.nslu2-linux.org/
19 #include <linux/gpio.h>
20 #include <linux/irq.h>
21 #include <linux/jiffies.h>
22 #include <linux/timer.h>
23 #include <linux/serial.h>
24 #include <linux/serial_8250.h>
25 #include <linux/leds.h>
26 #include <linux/reboot.h>
27 #include <linux/i2c.h>
28 #include <linux/i2c-gpio.h>
30 #include <mach/hardware.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/flash.h>
35 #include <asm/mach/time.h>
37 #define DSMG600_SDA_PIN 5
38 #define DSMG600_SCL_PIN 4
40 /* DSM-G600 Timer Setting */
41 #define DSMG600_FREQ 66000000
43 /* Buttons */
44 #define DSMG600_PB_GPIO 15 /* power button */
45 #define DSMG600_RB_GPIO 3 /* reset button */
47 /* Power control */
48 #define DSMG600_PO_GPIO 2 /* power off */
50 /* LEDs */
51 #define DSMG600_LED_PWR_GPIO 0
52 #define DSMG600_LED_WLAN_GPIO 14
54 static struct flash_platform_data dsmg600_flash_data = {
55 .map_name = "cfi_probe",
56 .width = 2,
59 static struct resource dsmg600_flash_resource = {
60 .flags = IORESOURCE_MEM,
63 static struct platform_device dsmg600_flash = {
64 .name = "IXP4XX-Flash",
65 .id = 0,
66 .dev.platform_data = &dsmg600_flash_data,
67 .num_resources = 1,
68 .resource = &dsmg600_flash_resource,
71 static struct i2c_gpio_platform_data dsmg600_i2c_gpio_data = {
72 .sda_pin = DSMG600_SDA_PIN,
73 .scl_pin = DSMG600_SCL_PIN,
76 static struct platform_device dsmg600_i2c_gpio = {
77 .name = "i2c-gpio",
78 .id = 0,
79 .dev = {
80 .platform_data = &dsmg600_i2c_gpio_data,
84 static struct i2c_board_info __initdata dsmg600_i2c_board_info [] = {
86 I2C_BOARD_INFO("pcf8563", 0x51),
90 static struct gpio_led dsmg600_led_pins[] = {
92 .name = "dsmg600:green:power",
93 .gpio = DSMG600_LED_PWR_GPIO,
96 .name = "dsmg600:green:wlan",
97 .gpio = DSMG600_LED_WLAN_GPIO,
98 .active_low = true,
102 static struct gpio_led_platform_data dsmg600_led_data = {
103 .num_leds = ARRAY_SIZE(dsmg600_led_pins),
104 .leds = dsmg600_led_pins,
107 static struct platform_device dsmg600_leds = {
108 .name = "leds-gpio",
109 .id = -1,
110 .dev.platform_data = &dsmg600_led_data,
113 static struct resource dsmg600_uart_resources[] = {
115 .start = IXP4XX_UART1_BASE_PHYS,
116 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
117 .flags = IORESOURCE_MEM,
120 .start = IXP4XX_UART2_BASE_PHYS,
121 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
122 .flags = IORESOURCE_MEM,
126 static struct plat_serial8250_port dsmg600_uart_data[] = {
128 .mapbase = IXP4XX_UART1_BASE_PHYS,
129 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
130 .irq = IRQ_IXP4XX_UART1,
131 .flags = UPF_BOOT_AUTOCONF,
132 .iotype = UPIO_MEM,
133 .regshift = 2,
134 .uartclk = IXP4XX_UART_XTAL,
137 .mapbase = IXP4XX_UART2_BASE_PHYS,
138 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
139 .irq = IRQ_IXP4XX_UART2,
140 .flags = UPF_BOOT_AUTOCONF,
141 .iotype = UPIO_MEM,
142 .regshift = 2,
143 .uartclk = IXP4XX_UART_XTAL,
148 static struct platform_device dsmg600_uart = {
149 .name = "serial8250",
150 .id = PLAT8250_DEV_PLATFORM,
151 .dev.platform_data = dsmg600_uart_data,
152 .num_resources = ARRAY_SIZE(dsmg600_uart_resources),
153 .resource = dsmg600_uart_resources,
156 static struct platform_device *dsmg600_devices[] __initdata = {
157 &dsmg600_i2c_gpio,
158 &dsmg600_flash,
159 &dsmg600_leds,
162 static void dsmg600_power_off(void)
164 /* enable the pwr cntl and drive it high */
165 gpio_direction_output(DSMG600_PO_GPIO, 1);
168 /* This is used to make sure the power-button pusher is serious. The button
169 * must be held until the value of this counter reaches zero.
171 static int power_button_countdown;
173 /* Must hold the button down for at least this many counts to be processed */
174 #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
176 static void dsmg600_power_handler(unsigned long data);
177 static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
179 static void dsmg600_power_handler(unsigned long data)
181 /* This routine is called twice per second to check the
182 * state of the power button.
185 if (gpio_get_value(DSMG600_PB_GPIO)) {
187 /* IO Pin is 1 (button pushed) */
188 if (power_button_countdown > 0)
189 power_button_countdown--;
191 } else {
193 /* Done on button release, to allow for auto-power-on mods. */
194 if (power_button_countdown == 0) {
195 /* Signal init to do the ctrlaltdel action,
196 * this will bypass init if it hasn't started
197 * and do a kernel_restart.
199 ctrl_alt_del();
201 /* Change the state of the power LED to "blink" */
202 gpio_set_value(DSMG600_LED_PWR_GPIO, 0);
203 } else {
204 power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
208 mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
211 static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
213 /* This is the paper-clip reset, it shuts the machine down directly. */
214 machine_power_off();
216 return IRQ_HANDLED;
219 static void __init dsmg600_timer_init(void)
221 /* The xtal on this machine is non-standard. */
222 ixp4xx_timer_freq = DSMG600_FREQ;
224 /* Call standard timer_init function. */
225 ixp4xx_timer_init();
228 static int __init dsmg600_gpio_init(void)
230 if (!machine_is_dsmg600())
231 return 0;
233 gpio_request(DSMG600_RB_GPIO, "reset button");
234 if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
235 IRQF_TRIGGER_LOW, "DSM-G600 reset button", NULL) < 0) {
237 printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
238 gpio_to_irq(DSMG600_RB_GPIO));
242 * The power button on the D-Link DSM-G600 is on GPIO 15, but
243 * it cannot handle interrupts on that GPIO line. So we'll
244 * have to poll it with a kernel timer.
247 /* Make sure that the power button GPIO is set up as an input */
248 gpio_request(DSMG600_PB_GPIO, "power button");
249 gpio_direction_input(DSMG600_PB_GPIO);
250 /* Request poweroff GPIO line */
251 gpio_request(DSMG600_PO_GPIO, "power off button");
253 /* Set the initial value for the power button IRQ handler */
254 power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
256 mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
257 return 0;
259 device_initcall(dsmg600_gpio_init);
261 static void __init dsmg600_init(void)
263 ixp4xx_sys_init();
265 /* Make sure that GPIO14 and GPIO15 are not used as clocks */
266 *IXP4XX_GPIO_GPCLKR = 0;
268 dsmg600_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
269 dsmg600_flash_resource.end =
270 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
272 i2c_register_board_info(0, dsmg600_i2c_board_info,
273 ARRAY_SIZE(dsmg600_i2c_board_info));
275 /* The UART is required on the DSM-G600 (Redboot cannot use the
276 * NIC) -- do it here so that it does *not* get removed if
277 * platform_add_devices fails!
279 (void)platform_device_register(&dsmg600_uart);
281 platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
283 pm_power_off = dsmg600_power_off;
286 MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
287 /* Maintainer: www.nslu2-linux.org */
288 .atag_offset = 0x100,
289 .map_io = ixp4xx_map_io,
290 .init_early = ixp4xx_init_early,
291 .init_irq = ixp4xx_init_irq,
292 .init_time = dsmg600_timer_init,
293 .init_machine = dsmg600_init,
294 #if defined(CONFIG_PCI)
295 .dma_zone_size = SZ_64M,
296 #endif
297 .restart = ixp4xx_restart,
298 MACHINE_END