diff options
author | Balaji Rao <balajirrao@openmoko.org> | 2008-11-20 19:46:51 +0000 |
---|---|---|
committer | Andy Green <agreen@pads.home.warmcat.com> | 2008-11-20 19:46:51 +0000 |
commit | 5557b3223d35dd25366d6ef047299b1dc94b17e6 (patch) | |
tree | 51916c9efabb93c2a337a703abf686accbfdad36 /drivers/input | |
parent | b0c88072f6652fa897d67a4e8c5bea5e09438189 (diff) |
pcf50633_mfd.patch
pcf50633 driver rewritten to use the MFD model.
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/misc/Kconfig | 4 | ||||
-rw-r--r-- | drivers/input/misc/Makefile | 2 | ||||
-rw-r--r-- | drivers/input/misc/pcf50633-input.c | 106 |
3 files changed, 111 insertions, 1 deletions
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 8aa8bc150c9..ffff16dce95 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -229,4 +229,8 @@ config INPUT_LIS302DL The userspece interface is a 3-axis (X/Y/Z) relative movement Linux input device, reporting REL_[XYZ] events. +config INPUT_PCF50633_PMU + tristate "PCF50633 PMU events" + depends on MFD_PCF50633 + endif diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 75a7a2e07b9..f0ef98e23af 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -22,4 +22,4 @@ obj-$(CONFIG_INPUT_UINPUT) += uinput.o obj-$(CONFIG_INPUT_APANEL) += apanel.o obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o obj-$(CONFIG_INPUT_LIS302DL) += lis302dl.o - +obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o diff --git a/drivers/input/misc/pcf50633-input.c b/drivers/input/misc/pcf50633-input.c new file mode 100644 index 00000000000..43451dfa8f0 --- /dev/null +++ b/drivers/input/misc/pcf50633-input.c @@ -0,0 +1,106 @@ +#include <linux/input.h> + +#include <linux/mfd/pcf50633/core.h> +#include <linux/mfd/pcf50633/input.h> + +static void +pcf50633_input_irq(struct pcf50633 *pcf, int irq, void *data) +{ + struct input_dev *input_dev = pcf->input.input_dev; + int onkey_released; + + + /* We report only one event depending on if the key status */ + onkey_released = pcf50633_reg_read(pcf, PCF50633_REG_OOCSTAT) & + PCF50633_OOCSTAT_ONKEY; + + if (irq == PCF50633_IRQ_ONKEYF && !onkey_released) + input_report_key(input_dev, KEY_POWER, 1); + else if (irq == PCF50633_IRQ_ONKEYR && onkey_released) + input_report_key(input_dev, KEY_POWER, 0); + + /* MBC makes sure that only one of USBINS/USBREM will be called */ + if (irq == PCF50633_IRQ_USBINS) + input_report_key(input_dev, KEY_POWER2, 1); + else if (irq == PCF50633_IRQ_USBREM) + input_report_key(input_dev, KEY_POWER2, 0); + + input_sync(input_dev); +} + +int __init pcf50633_input_probe(struct platform_device *pdev) +{ + struct pcf50633 *pcf; + struct input_dev *input_dev; + int ret; + + pcf = platform_get_drvdata(pdev); + + input_dev = input_allocate_device(); + if (!input_dev) + return -ENODEV; + + input_dev->name = "GTA02 PMU events"; + input_dev->phys = "FIXME"; + input_dev->id.bustype = BUS_I2C; + + input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR); + set_bit(KEY_POWER, input_dev->keybit); + set_bit(KEY_POWER2, input_dev->keybit); + + ret = input_register_device(input_dev); + if (ret) + goto out; + + pcf->input.input_dev = input_dev; + + /* Currently we care only about ONKEY and USBINS/USBREM + * + * USBINS/USBREM are told to us by mbc driver as we can't setup + * two handlers for an IRQ + */ + pcf->irq_handler[PCF50633_IRQ_ONKEYR].handler = pcf50633_input_irq; + + pcf->irq_handler[PCF50633_IRQ_ONKEYF].handler = pcf50633_input_irq; + + return 0; + +out: + input_free_device(input_dev); + return ret; +} + +static int __devexit pcf50633_input_remove(struct platform_device *pdev) +{ + struct pcf50633 *pcf; + + pcf = platform_get_drvdata(pdev); + input_unregister_device(pcf->input.input_dev); + + return 0; +} + +struct platform_driver pcf50633_input_driver = { + .driver = { + .name = "pcf50633-input", + }, + .probe = pcf50633_input_probe, + .remove = __devexit_p(pcf50633_input_remove), +}; + +static int __init pcf50633_input_init(void) +{ + return platform_driver_register(&pcf50633_input_driver); +} +module_init(pcf50633_input_init); + +static void __exit pcf50633_input_exit(void) +{ + platform_driver_unregister(&pcf50633_input_driver); +} +module_exit(pcf50633_input_exit); + +MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>"); +MODULE_DESCRIPTION("PCF50633 input driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:pcf50633-input"); |