From 361fff778b7c4d2c78f28833415335148d86a1aa Mon Sep 17 00:00:00 2001 From: merge Date: Fri, 5 Dec 2008 09:59:34 +0000 Subject: MERGE-via-pending-tracking-hist-MERGE-via-stable-tracking-build-fix-path-to-toolchain-on-1228470136 pending-tracking-hist top was MERGE-via-stable-tracking-build-fix-path-to-toolchain-on-1228470136 / 21b67ab8e79998b0a534263282dab1dda0f11b00 ... parent commitmessage: From: merge MERGE-via-stable-tracking-hist-build-fix-path-to-toolchain-on stable-tracking-hist top was build-fix-path-to-toolchain-on / ca14ba894df9b28822066c578dde48d7dbe931de ... parent commitmessage: From: Andy Green build-fix-path-to-toolchain-one-at-last.patch Signed-off-by: Andy Green --- drivers/input/misc/Kconfig | 6 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/pcf50606-input.c | 123 ++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 drivers/input/misc/pcf50606-input.c (limited to 'drivers/input') diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index cdf0bfcebc7..ab69a5bb98d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -235,4 +235,10 @@ config INPUT_PCF50633_PMU help Say Y to include support for input events on NXP PCF50633. +config INPUT_PCF50606_PMU + tristate "PCF50606 PMU events" + depends on MFD_PCF50606 + help + Say Y to include support for input events on NXP PCF50606. + endif diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index f0ef98e23af..0884b84c29a 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -23,3 +23,4 @@ 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 +obj-$(CONFIG_INPUT_PCF50606_PMU) += pcf50606-input.o diff --git a/drivers/input/misc/pcf50606-input.c b/drivers/input/misc/pcf50606-input.c new file mode 100644 index 00000000000..0e4564c4c82 --- /dev/null +++ b/drivers/input/misc/pcf50606-input.c @@ -0,0 +1,123 @@ +/* Philips PCF50606 Input Driver + * + * (C) 2006-2008 by Openmoko, Inc. + * Author: Balaji Rao + * All rights reserved. + * + * Broken down from monstrous PCF50606 driver mainly by + * Harald Welte, Matt Hsu, Andy Green and Werner Almesberger + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 060, Boston, + * MA 02111-1307 USA + */ + +#include + +#include +#include + +static void +pcf50606_input_irq(struct pcf50606 *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 = pcf50606_reg_read(pcf, PCF50606_REG_OOCS) & + PCF50606_OOCS_ONKEY; + + if (irq == PCF50606_IRQ_ONKEYF && !onkey_released) + input_report_key(input_dev, KEY_POWER, 1); + else if (irq == PCF50606_IRQ_ONKEYR && onkey_released) + input_report_key(input_dev, KEY_POWER, 0); + + input_sync(input_dev); +} + +int __init pcf50606_input_probe(struct platform_device *pdev) +{ + struct pcf50606 *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 = "PCF50606 PMU events"; + 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[PCF50606_IRQ_ONKEYR].handler = pcf50606_input_irq; + + pcf->irq_handler[PCF50606_IRQ_ONKEYF].handler = pcf50606_input_irq; + + return 0; + +out: + input_free_device(input_dev); + return ret; +} + +static int __devexit pcf50606_input_remove(struct platform_device *pdev) +{ + struct pcf50606 *pcf; + + pcf = platform_get_drvdata(pdev); + input_unregister_device(pcf->input.input_dev); + + return 0; +} + +struct platform_driver pcf50606_input_driver = { + .driver = { + .name = "pcf50606-input", + }, + .probe = pcf50606_input_probe, + .remove = __devexit_p(pcf50606_input_remove), +}; + +static int __init pcf50606_input_init(void) +{ + return platform_driver_register(&pcf50606_input_driver); +} +module_init(pcf50606_input_init); + +static void __exit pcf50606_input_exit(void) +{ + platform_driver_unregister(&pcf50606_input_driver); +} +module_exit(pcf50606_input_exit); + +MODULE_AUTHOR("Balaji Rao "); +MODULE_DESCRIPTION("PCF50606 input driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:pcf50606-input"); -- cgit v1.2.3