diff options
Diffstat (limited to 'arch/arm/mach-ixp4xx/dsmg600-power.c')
| -rw-r--r-- | arch/arm/mach-ixp4xx/dsmg600-power.c | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/arch/arm/mach-ixp4xx/dsmg600-power.c b/arch/arm/mach-ixp4xx/dsmg600-power.c deleted file mode 100644 index db6398777124..000000000000 --- a/arch/arm/mach-ixp4xx/dsmg600-power.c +++ /dev/null | |||
| @@ -1,129 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * arch/arm/mach-ixp4xx/dsmg600-power.c | ||
| 3 | * | ||
| 4 | * DSM-G600 Power/Reset driver | ||
| 5 | * Author: Michael Westerhof <mwester@dls.net> | ||
| 6 | * | ||
| 7 | * Based on nslu2-power.c | ||
| 8 | * Copyright (C) 2005 Tower Technologies | ||
| 9 | * Author: Alessandro Zummo <a.zummo@towertech.it> | ||
| 10 | * | ||
| 11 | * which was based on nslu2-io.c | ||
| 12 | * Copyright (C) 2004 Karen Spearel | ||
| 13 | * | ||
| 14 | * Maintainers: http://www.nslu2-linux.org/ | ||
| 15 | * | ||
| 16 | * This program is free software; you can redistribute it and/or modify | ||
| 17 | * it under the terms of the GNU General Public License version 2 as | ||
| 18 | * published by the Free Software Foundation. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/reboot.h> | ||
| 24 | #include <linux/interrupt.h> | ||
| 25 | #include <linux/irq.h> | ||
| 26 | #include <linux/jiffies.h> | ||
| 27 | #include <linux/timer.h> | ||
| 28 | |||
| 29 | #include <asm/gpio.h> | ||
| 30 | #include <asm/mach-types.h> | ||
| 31 | |||
| 32 | /* This is used to make sure the power-button pusher is serious. The button | ||
| 33 | * must be held until the value of this counter reaches zero. | ||
| 34 | */ | ||
| 35 | static int power_button_countdown; | ||
| 36 | |||
| 37 | /* Must hold the button down for at least this many counts to be processed */ | ||
| 38 | #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */ | ||
| 39 | |||
| 40 | static void dsmg600_power_handler(unsigned long data); | ||
| 41 | static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0); | ||
| 42 | |||
| 43 | static void dsmg600_power_handler(unsigned long data) | ||
| 44 | { | ||
| 45 | /* This routine is called twice per second to check the | ||
| 46 | * state of the power button. | ||
| 47 | */ | ||
| 48 | |||
| 49 | if (gpio_get_value(DSMG600_PB_GPIO)) { | ||
| 50 | |||
| 51 | /* IO Pin is 1 (button pushed) */ | ||
| 52 | if (power_button_countdown > 0) | ||
| 53 | power_button_countdown--; | ||
| 54 | |||
| 55 | } else { | ||
| 56 | |||
| 57 | /* Done on button release, to allow for auto-power-on mods. */ | ||
| 58 | if (power_button_countdown == 0) { | ||
| 59 | /* Signal init to do the ctrlaltdel action, | ||
| 60 | * this will bypass init if it hasn't started | ||
| 61 | * and do a kernel_restart. | ||
| 62 | */ | ||
| 63 | ctrl_alt_del(); | ||
| 64 | |||
| 65 | /* Change the state of the power LED to "blink" */ | ||
| 66 | gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW); | ||
| 67 | } else { | ||
| 68 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500)); | ||
| 73 | } | ||
| 74 | |||
| 75 | static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id) | ||
| 76 | { | ||
| 77 | /* This is the paper-clip reset, it shuts the machine down directly. */ | ||
| 78 | machine_power_off(); | ||
| 79 | |||
| 80 | return IRQ_HANDLED; | ||
| 81 | } | ||
| 82 | |||
| 83 | static int __init dsmg600_power_init(void) | ||
| 84 | { | ||
| 85 | if (!(machine_is_dsmg600())) | ||
| 86 | return 0; | ||
| 87 | |||
| 88 | if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler, | ||
| 89 | IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button", | ||
| 90 | NULL) < 0) { | ||
| 91 | |||
| 92 | printk(KERN_DEBUG "Reset Button IRQ %d not available\n", | ||
| 93 | gpio_to_irq(DSMG600_RB_GPIO)); | ||
| 94 | |||
| 95 | return -EIO; | ||
| 96 | } | ||
| 97 | |||
| 98 | /* The power button on the D-Link DSM-G600 is on GPIO 15, but | ||
| 99 | * it cannot handle interrupts on that GPIO line. So we'll | ||
| 100 | * have to poll it with a kernel timer. | ||
| 101 | */ | ||
| 102 | |||
| 103 | /* Make sure that the power button GPIO is set up as an input */ | ||
| 104 | gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN); | ||
| 105 | |||
| 106 | /* Set the initial value for the power button IRQ handler */ | ||
| 107 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
| 108 | |||
| 109 | mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500)); | ||
| 110 | |||
| 111 | return 0; | ||
| 112 | } | ||
| 113 | |||
| 114 | static void __exit dsmg600_power_exit(void) | ||
| 115 | { | ||
| 116 | if (!(machine_is_dsmg600())) | ||
| 117 | return; | ||
| 118 | |||
| 119 | del_timer_sync(&dsmg600_power_timer); | ||
| 120 | |||
| 121 | free_irq(gpio_to_irq(DSMG600_RB_GPIO), NULL); | ||
| 122 | } | ||
| 123 | |||
| 124 | module_init(dsmg600_power_init); | ||
| 125 | module_exit(dsmg600_power_exit); | ||
| 126 | |||
| 127 | MODULE_AUTHOR("Michael Westerhof <mwester@dls.net>"); | ||
| 128 | MODULE_DESCRIPTION("DSM-G600 Power/Reset driver"); | ||
| 129 | MODULE_LICENSE("GPL"); | ||
