hh.org updates
[hh.org.git] / arch / arm / mach-pxa / htcsable / htcsable_kbd.c
blob22a6805df1d338ca067d9da3b9254fbbf27a3162
1 /*
2 * htcsable_kbd.c
3 * Keyboard support for the h4350 ipaq
5 * (c) Shawn Anderson, March, 2006
6 * This code is released under the GNU General Public License
8 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10 #include <linux/platform_device.h>
11 #include <linux/delay.h>
12 #include <linux/input.h>
13 #include <linux/input_pda.h>
14 #include <linux/interrupt.h>
15 #include <linux/irq.h>
16 #include <asm/arch/h4000-gpio.h>
17 #include <asm/arch/h4000-asic.h>
18 #include <asm/arch/pxa-regs.h>
19 #include <asm/hardware.h>
20 #include <asm/arch/bitfield.h>
21 #include <asm/mach-types.h> /* machine_is_hw6900 */
23 static struct input_dev *htcsable_kbd;
25 #define KEY_FUNC 0x32
27 static irqreturn_t htcsable_pwr_btn(int irq, void* data, struct pt_regs *regs)
29 int pressed;
30 pressed = !GET_H4000_GPIO(POWER_BUTTON_N);
32 input_report_key(htcsable_kbd, _KEY_POWER, pressed);
33 input_sync(htcsable_kbd);
35 return IRQ_HANDLED;
38 static int __init htcsable_kbd_probe(struct platform_device * pdev)
40 if (!machine_is_hw6900())
41 return -ENODEV;
43 if (!(htcsable_kbd = input_allocate_device()))
44 return -ENOMEM;
46 htcsable_kbd->name = "HP iPAQ hw6915 power key driver";
47 htcsable_kbd->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
49 set_bit(_KEY_POWER, htcsable_kbd->keybit);
50 request_irq(IRQ_GPIO(GPIO_NR_H4000_POWER_BUTTON_N), htcsable_pwr_btn,
51 SA_SAMPLE_RANDOM, "Power button", NULL);
52 set_irq_type(IRQ_GPIO(GPIO_NR_H4000_POWER_BUTTON_N), IRQT_BOTHEDGE);
54 input_register_device(htcsable_kbd);
56 return 0;
59 static int htcsable_kbd_remove(struct platform_device * pdev)
61 input_unregister_device(htcsable_kbd);
62 free_irq(IRQ_GPIO(GPIO_NR_H4000_POWER_BUTTON_N), NULL);
64 return 0;
67 static struct platform_driver htcsable_kbd_driver = {
68 .probe = htcsable_kbd_probe,
69 .remove = htcsable_kbd_remove,
70 .driver = {
71 .name = "htcsable_kbd",
75 static int __init htcsable_kbd_init(void)
77 return platform_driver_register(&htcsable_kbd_driver);
80 static void __exit htcsable_kbd_exit(void)
82 platform_driver_unregister(&htcsable_kbd_driver);
85 module_init(htcsable_kbd_init);
86 module_exit(htcsable_kbd_exit);
88 MODULE_AUTHOR("Shawn Anderson");
89 MODULE_DESCRIPTION("Keyboard support for the iPAQ h43xx");
90 MODULE_LICENSE("GPL");