Ok, second try.
-- wbr, Ilya ICQ: none, Jabber: ilya.muro...@jabber.ru
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 3556168..8ad4e9d 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -332,4 +332,10 @@ config KEYBOARD_SH_KEYSC To compile this driver as a module, choose M here: the module will be called sh_keysc. +config KEYBOARD_PCAP + tristate "Motorola EZX PCAP events" + depends on EZX_PCAP + help + Say Y here if you want to use power key and jack events + on Motorola EZX 2nd generation phones endif diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 36351e1..5aa77f0 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -28,3 +28,4 @@ obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o +obj-$(CONFIG_KEYBOARD_PCAP) += pcap_keys.o diff --git a/drivers/input/keyboard/pcap_keys.c b/drivers/input/keyboard/pcap_keys.c new file mode 100644 index 0000000..698858f --- /dev/null +++ b/drivers/input/keyboard/pcap_keys.c @@ -0,0 +1,113 @@ +/* + * Inpit driver for PCAP events: + * * Power key + * * Jack plug/unplug + * + * Copyright (c) 2008 Ily Petrov <ilya.muro...@gmail.co> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <linux/input.h> +#include <linux/mfd/ezx-pcap.h> + +#include <asm/io.h> + +static struct input_dev *pcap_input; + + +/* PCAP2 interrupts us on keypress */ +static irqreturn_t pcap_pwrkey_event(u32 event, void *unused) +{ + + u32 pstat; + ezx_pcap_read(PCAP_REG_PSTAT, &pstat); + pstat &= PCAP_IRQ_ONOFF; + + input_report_key(pcap_input, KEY_POWER, (pstat ? 0 : 1) ); + input_sync(pcap_input); + + return IRQ_HANDLED; + +} + +/* PCAP2 interrupts us on plug/unplug */ +static irqreturn_t pcap_jack_event(u32 event, void *unused) +{ + + u32 pstat; + ezx_pcap_read(PCAP_REG_PSTAT, &pstat); + pstat &= PCAP_IRQ_A1 ; + + input_report_switch(pcap_input,SW_HEADPHONE_INSERT, (pstat ? 0 : 1) ); + input_sync(pcap_input); + + return IRQ_HANDLED; + +} + + + +static int __init ezx_pwrkey_init(void) +{ + int err; + + ezx_pcap_register_event(PCAP_IRQ_ONOFF, pcap_pwrkey_event, NULL, "Power key"); + ezx_pcap_register_event(PCAP_IRQ_A1, pcap_jack_event, NULL, "HP/MIC"); + + pcap_input = input_allocate_device(); + if (! pcap_input) { + printk(KERN_ERR "pcap_powerkey: No mem\n"); + err = -ENOMEM; + goto fail_dev; + } + + printk(KERN_INFO "pcap events initializing\n"); + pcap_input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_SW); + pcap_input->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER); + set_bit(SW_HEADPHONE_INSERT, pcap_input->swbit); + + + err = input_register_device(pcap_input); + if (err) { + printk(KERN_ERR "pcap_powerkey: Failed to register device\n"); + goto fail_irq; + } + return 0; + + +fail_dev: + input_free_device(pcap_input); + +fail_irq: + ezx_pcap_unregister_event(PCAP_IRQ_ONOFF); + ezx_pcap_unregister_event(PCAP_IRQ_MB2 | PCAP_IRQ_A1); + + return err; +} + +static void __exit ezx_pwrkey_exit() +{ + + ezx_pcap_unregister_event(PCAP_IRQ_ONOFF); + ezx_pcap_unregister_event(PCAP_IRQ_MB2 | PCAP_IRQ_A1); + + input_unregister_device(pcap_input); + +} + + + +module_init(ezx_pwrkey_init); +module_exit(ezx_pwrkey_exit); + +MODULE_DESCRIPTION("Motorola PCAP2 powerkey driver"); +MODULE_AUTHOR("Ilya Petrov <ilya.muro...@gmail.com>"); +MODULE_LICENSE("GPL");