diff options
Diffstat (limited to 'arch/arm/mach-iop32x/n2100.c')
-rw-r--r-- | arch/arm/mach-iop32x/n2100.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/arch/arm/mach-iop32x/n2100.c b/arch/arm/mach-iop32x/n2100.c index 069144300b77..c1cd80ecc219 100644 --- a/arch/arm/mach-iop32x/n2100.c +++ b/arch/arm/mach-iop32x/n2100.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/reboot.h> | 31 | #include <linux/reboot.h> |
32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
33 | #include <linux/gpio.h> | ||
33 | #include <mach/hardware.h> | 34 | #include <mach/hardware.h> |
34 | #include <asm/irq.h> | 35 | #include <asm/irq.h> |
35 | #include <asm/mach/arch.h> | 36 | #include <asm/mach/arch.h> |
@@ -40,6 +41,7 @@ | |||
40 | #include <asm/page.h> | 41 | #include <asm/page.h> |
41 | #include <asm/pgtable.h> | 42 | #include <asm/pgtable.h> |
42 | #include <mach/time.h> | 43 | #include <mach/time.h> |
44 | #include "gpio-iop32x.h" | ||
43 | 45 | ||
44 | /* | 46 | /* |
45 | * N2100 timer tick configuration. | 47 | * N2100 timer tick configuration. |
@@ -288,8 +290,14 @@ static void n2100_power_off(void) | |||
288 | 290 | ||
289 | static void n2100_restart(enum reboot_mode mode, const char *cmd) | 291 | static void n2100_restart(enum reboot_mode mode, const char *cmd) |
290 | { | 292 | { |
291 | gpio_line_set(N2100_HARDWARE_RESET, GPIO_LOW); | 293 | int ret; |
292 | gpio_line_config(N2100_HARDWARE_RESET, GPIO_OUT); | 294 | |
295 | ret = gpio_direction_output(N2100_HARDWARE_RESET, 0); | ||
296 | if (ret) { | ||
297 | pr_crit("could not drive reset GPIO low\n"); | ||
298 | return; | ||
299 | } | ||
300 | /* Wait for reset to happen */ | ||
293 | while (1) | 301 | while (1) |
294 | ; | 302 | ; |
295 | } | 303 | } |
@@ -299,7 +307,7 @@ static struct timer_list power_button_poll_timer; | |||
299 | 307 | ||
300 | static void power_button_poll(unsigned long dummy) | 308 | static void power_button_poll(unsigned long dummy) |
301 | { | 309 | { |
302 | if (gpio_line_get(N2100_POWER_BUTTON) == 0) { | 310 | if (gpio_get_value(N2100_POWER_BUTTON) == 0) { |
303 | ctrl_alt_del(); | 311 | ctrl_alt_del(); |
304 | return; | 312 | return; |
305 | } | 313 | } |
@@ -308,9 +316,37 @@ static void power_button_poll(unsigned long dummy) | |||
308 | add_timer(&power_button_poll_timer); | 316 | add_timer(&power_button_poll_timer); |
309 | } | 317 | } |
310 | 318 | ||
319 | static int __init n2100_request_gpios(void) | ||
320 | { | ||
321 | int ret; | ||
322 | |||
323 | if (!machine_is_n2100()) | ||
324 | return 0; | ||
325 | |||
326 | ret = gpio_request(N2100_HARDWARE_RESET, "reset"); | ||
327 | if (ret) | ||
328 | pr_err("could not request reset GPIO\n"); | ||
329 | |||
330 | ret = gpio_request(N2100_POWER_BUTTON, "power"); | ||
331 | if (ret) | ||
332 | pr_err("could not request power GPIO\n"); | ||
333 | else { | ||
334 | ret = gpio_direction_input(N2100_POWER_BUTTON); | ||
335 | if (ret) | ||
336 | pr_err("could not set power GPIO as input\n"); | ||
337 | } | ||
338 | /* Set up power button poll timer */ | ||
339 | init_timer(&power_button_poll_timer); | ||
340 | power_button_poll_timer.function = power_button_poll; | ||
341 | power_button_poll_timer.expires = jiffies + (HZ / 10); | ||
342 | add_timer(&power_button_poll_timer); | ||
343 | return 0; | ||
344 | } | ||
345 | device_initcall(n2100_request_gpios); | ||
311 | 346 | ||
312 | static void __init n2100_init_machine(void) | 347 | static void __init n2100_init_machine(void) |
313 | { | 348 | { |
349 | register_iop32x_gpio(); | ||
314 | platform_device_register(&iop3xx_i2c0_device); | 350 | platform_device_register(&iop3xx_i2c0_device); |
315 | platform_device_register(&n2100_flash_device); | 351 | platform_device_register(&n2100_flash_device); |
316 | platform_device_register(&n2100_serial_device); | 352 | platform_device_register(&n2100_serial_device); |
@@ -321,11 +357,6 @@ static void __init n2100_init_machine(void) | |||
321 | ARRAY_SIZE(n2100_i2c_devices)); | 357 | ARRAY_SIZE(n2100_i2c_devices)); |
322 | 358 | ||
323 | pm_power_off = n2100_power_off; | 359 | pm_power_off = n2100_power_off; |
324 | |||
325 | init_timer(&power_button_poll_timer); | ||
326 | power_button_poll_timer.function = power_button_poll; | ||
327 | power_button_poll_timer.expires = jiffies + (HZ / 10); | ||
328 | add_timer(&power_button_poll_timer); | ||
329 | } | 360 | } |
330 | 361 | ||
331 | MACHINE_START(N2100, "Thecus N2100") | 362 | MACHINE_START(N2100, "Thecus N2100") |