From: Krystian Garbaciak <krystian.garbaciak@diasemi.com> To: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, lm-sensors@lm-sensors.org, linux-input@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-leds@vger.kernel.org Cc: Alessandro Zummo <a.zummo@towertech.it>, Andrew Jones <drjones@redhat.com>, Dmitry Torokhov <dmitry.torokhov@gmail.com>, Samuel Ortiz <sameo@linux.intel.com>, Ashish Jangam <ashish.jangam@kpitcummins.com>, Mark Brown <broonie@opensource.wolfsonmicro.com>, Donggeun Kim <dg77.kim@samsung.com>, Wim Van Sebroeck <wim@iguana.be>, Richard Purdie <rpurdie@rpsys.net>, Bryan Wu <bryan.wu@canonical.com>, Liam Girdwood <lrg@ti.com> Subject: [PATCH 5/8] input: Add support for DA906x PMIC OnKey detection. Date: Fri, 24 Aug 2012 09:32:00 +0100 [thread overview] Message-ID: <201208240835@sw-eng-lt-dc-vm2> (raw) In-Reply-To: <201208240834@sw-eng-lt-dc-vm2> This driver creates input device that reports a key event on an OnKey button release. The reported key code depends on the time, the button was holded for. If holding time < 2 seconds - KEY_SLEEP is reported on button release, otherwise KEY_POWER is reported after 2 seconds. Signed-off-by: Krystian Garbaciak <krystian.garbaciak@diasemi.com> --- drivers/input/misc/Kconfig | 6 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/da906x-onkey.c | 139 +++++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+), 0 deletions(-) create mode 100644 drivers/input/misc/da906x-onkey.c diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 7c0f1ec..fd8d951 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -486,6 +486,12 @@ config INPUT_DA9052_ONKEY To compile this driver as a module, choose M here: the module will be called da9052_onkey. +config INPUT_DA906X_ONKEY + tristate "Dialog DA906x OnKey" + depends on MFD_DA906X + help + Support for Dialog Semiconductor input onkey device. + config INPUT_DM355EVM tristate "TI DaVinci DM355 EVM Keypad and IR Remote" depends on MFD_DM355EVM_MSP diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 83fe6f5..73406ac 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_INPUT_CMA3000) += cma3000_d0x.o obj-$(CONFIG_INPUT_CMA3000_I2C) += cma3000_d0x_i2c.o obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o obj-$(CONFIG_INPUT_DA9052_ONKEY) += da9052_onkey.o +obj-$(CONFIG_INPUT_DA906X_ONKEY) += da906x-onkey.o obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o obj-$(CONFIG_INPUT_GPIO_TILT_POLLED) += gpio_tilt_polled.o diff --git a/drivers/input/misc/da906x-onkey.c b/drivers/input/misc/da906x-onkey.c new file mode 100644 index 0000000..477c554 --- /dev/null +++ b/drivers/input/misc/da906x-onkey.c @@ -0,0 +1,139 @@ +/* + * OnKey device driver for Dialog DA906x PMIC + * + * Copyright 2012 Dialog Semiconductors Ltd. + * + * Author: <michal.hajduk@diasemi.com> + * + * 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. + * + */ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/input.h> +#include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <linux/workqueue.h> + +#include <linux/mfd/da906x/core.h> +#include <linux/mfd/da906x/registers.h> + + +struct da906x_onkey { + struct da906x *da906x; + struct input_dev *input; + int irq; +}; + +static irqreturn_t da906x_onkey_irq_handler(int irq, void *data) +{ + struct da906x_onkey *onkey = data; + unsigned int code; + int ret; + + ret = da906x_reg_read(onkey->da906x, DA906X_REG_STATUS_A); + if ((ret >= 0) && (ret & DA906X_NONKEY)) { + dev_notice(&onkey->input->dev, "KEY_POWER pressed.\n"); + code = KEY_POWER; + } else { + dev_notice(&onkey->input->dev, "KEY_SLEEP pressed.\n"); + code = KEY_SLEEP; + } + + /* Interrupt raised for key release only, + so report consecutive button press and release. */ + input_report_key(onkey->input, code, 1); + input_report_key(onkey->input, code, 0); + input_sync(onkey->input); + + return IRQ_HANDLED; +} + +static int __devinit da906x_onkey_probe(struct platform_device *pdev) +{ + struct da906x *da906x = dev_get_drvdata(pdev->dev.parent); + struct da906x_onkey *onkey; + int ret = 0; + + onkey = devm_kzalloc(&pdev->dev, sizeof(struct da906x_onkey), + GFP_KERNEL); + if (!onkey) { + dev_err(&pdev->dev, "Failed to allocate memory.\n"); + return -ENOMEM; + } + + onkey->input = input_allocate_device(); + if (!onkey->input) { + dev_err(&pdev->dev, "Failed to allocated inpute device.\n"); + return -ENOMEM; + } + + onkey->irq = platform_get_irq_byname(pdev, DA906X_DRVNAME_ONKEY); + onkey->da906x = da906x; + + onkey->input->evbit[0] = BIT_MASK(EV_KEY); + onkey->input->name = DA906X_DRVNAME_ONKEY; + onkey->input->phys = DA906X_DRVNAME_ONKEY "/input0"; + onkey->input->dev.parent = &pdev->dev; + input_set_capability(onkey->input, EV_KEY, KEY_POWER); + input_set_capability(onkey->input, EV_KEY, KEY_SLEEP); + + ret = request_threaded_irq(onkey->irq, NULL, da906x_onkey_irq_handler, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, "ONKEY", onkey); + if (ret) { + dev_err(&pdev->dev, "Failed to request IRQ.\n"); + goto err_input; + } + + ret = input_register_device(onkey->input); + if (ret) { + dev_err(&pdev->dev, "Failed to request IRQ.\n"); + goto err_irq; + } + + platform_set_drvdata(pdev, onkey); + + /* Interrupt reacts on button release */ + da906x_reg_update(da906x, DA906X_REG_CONFIG_I, + DA906X_NONKEY_PIN_MASK, DA906X_NONKEY_PIN_SWDOWN); + + return 0; + +err_irq: + free_irq(onkey->da906x->irq_base + onkey->irq , onkey); +err_input: + input_free_device(onkey->input); + return ret; +} + +static int __devexit da906x_onkey_remove(struct platform_device *pdev) +{ + struct da906x_onkey *onkey = platform_get_drvdata(pdev); + + free_irq(onkey->irq, onkey); + input_unregister_device(onkey->input); + return 0; +} + +static struct platform_driver da906x_onkey_driver = { + .probe = da906x_onkey_probe, + .remove = __devexit_p(da906x_onkey_remove), + .driver = { + .name = DA906X_DRVNAME_ONKEY, + .owner = THIS_MODULE, + }, +}; + +module_platform_driver(da906x_onkey_driver); + +MODULE_AUTHOR("Dialog Semiconductor <michal.hajduk@diasemi.com>"); +MODULE_DESCRIPTION("Onkey driver for DA906X"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("paltform:" DA906X_DRVNAME_ONKEY); -- 1.7.0.4 _______________________________________________ lm-sensors mailing list lm-sensors@lm-sensors.org http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
WARNING: multiple messages have this Message-ID (diff)
From: Krystian Garbaciak <krystian.garbaciak@diasemi.com> To: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, lm-sensors@lm-sensors.org, linux-input@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-leds@vger.kernel.org Cc: Alessandro Zummo <a.zummo@towertech.it>, Andrew Jones <drjones@redhat.com>, Dmitry Torokhov <dmitry.torokhov@gmail.com>, Samuel Ortiz <sameo@linux.intel.com>, Ashish Jangam <ashish.jangam@kpitcummins.com>, Mark Brown <broonie@opensource.wolfsonmicro.com>, Donggeun Kim <dg77.kim@samsung.com>, Wim Van Sebroeck <wim@iguana.be>, Richard Purdie <rpurdie@rpsys.net>, Bryan Wu <bryan.wu@canonical.com>, Liam Girdwood <lrg@ti.com> Subject: [lm-sensors] [PATCH 5/8] input: Add support for DA906x PMIC OnKey detection. Date: Fri, 24 Aug 2012 08:32:00 +0000 [thread overview] Message-ID: <201208240835@sw-eng-lt-dc-vm2> (raw) In-Reply-To: <201208240834@sw-eng-lt-dc-vm2> This driver creates input device that reports a key event on an OnKey button release. The reported key code depends on the time, the button was holded for. If holding time < 2 seconds - KEY_SLEEP is reported on button release, otherwise KEY_POWER is reported after 2 seconds. Signed-off-by: Krystian Garbaciak <krystian.garbaciak@diasemi.com> --- drivers/input/misc/Kconfig | 6 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/da906x-onkey.c | 139 +++++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+), 0 deletions(-) create mode 100644 drivers/input/misc/da906x-onkey.c diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 7c0f1ec..fd8d951 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -486,6 +486,12 @@ config INPUT_DA9052_ONKEY To compile this driver as a module, choose M here: the module will be called da9052_onkey. +config INPUT_DA906X_ONKEY + tristate "Dialog DA906x OnKey" + depends on MFD_DA906X + help + Support for Dialog Semiconductor input onkey device. + config INPUT_DM355EVM tristate "TI DaVinci DM355 EVM Keypad and IR Remote" depends on MFD_DM355EVM_MSP diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 83fe6f5..73406ac 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_INPUT_CMA3000) += cma3000_d0x.o obj-$(CONFIG_INPUT_CMA3000_I2C) += cma3000_d0x_i2c.o obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o obj-$(CONFIG_INPUT_DA9052_ONKEY) += da9052_onkey.o +obj-$(CONFIG_INPUT_DA906X_ONKEY) += da906x-onkey.o obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o obj-$(CONFIG_INPUT_GPIO_TILT_POLLED) += gpio_tilt_polled.o diff --git a/drivers/input/misc/da906x-onkey.c b/drivers/input/misc/da906x-onkey.c new file mode 100644 index 0000000..477c554 --- /dev/null +++ b/drivers/input/misc/da906x-onkey.c @@ -0,0 +1,139 @@ +/* + * OnKey device driver for Dialog DA906x PMIC + * + * Copyright 2012 Dialog Semiconductors Ltd. + * + * Author: <michal.hajduk@diasemi.com> + * + * 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. + * + */ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/input.h> +#include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <linux/workqueue.h> + +#include <linux/mfd/da906x/core.h> +#include <linux/mfd/da906x/registers.h> + + +struct da906x_onkey { + struct da906x *da906x; + struct input_dev *input; + int irq; +}; + +static irqreturn_t da906x_onkey_irq_handler(int irq, void *data) +{ + struct da906x_onkey *onkey = data; + unsigned int code; + int ret; + + ret = da906x_reg_read(onkey->da906x, DA906X_REG_STATUS_A); + if ((ret >= 0) && (ret & DA906X_NONKEY)) { + dev_notice(&onkey->input->dev, "KEY_POWER pressed.\n"); + code = KEY_POWER; + } else { + dev_notice(&onkey->input->dev, "KEY_SLEEP pressed.\n"); + code = KEY_SLEEP; + } + + /* Interrupt raised for key release only, + so report consecutive button press and release. */ + input_report_key(onkey->input, code, 1); + input_report_key(onkey->input, code, 0); + input_sync(onkey->input); + + return IRQ_HANDLED; +} + +static int __devinit da906x_onkey_probe(struct platform_device *pdev) +{ + struct da906x *da906x = dev_get_drvdata(pdev->dev.parent); + struct da906x_onkey *onkey; + int ret = 0; + + onkey = devm_kzalloc(&pdev->dev, sizeof(struct da906x_onkey), + GFP_KERNEL); + if (!onkey) { + dev_err(&pdev->dev, "Failed to allocate memory.\n"); + return -ENOMEM; + } + + onkey->input = input_allocate_device(); + if (!onkey->input) { + dev_err(&pdev->dev, "Failed to allocated inpute device.\n"); + return -ENOMEM; + } + + onkey->irq = platform_get_irq_byname(pdev, DA906X_DRVNAME_ONKEY); + onkey->da906x = da906x; + + onkey->input->evbit[0] = BIT_MASK(EV_KEY); + onkey->input->name = DA906X_DRVNAME_ONKEY; + onkey->input->phys = DA906X_DRVNAME_ONKEY "/input0"; + onkey->input->dev.parent = &pdev->dev; + input_set_capability(onkey->input, EV_KEY, KEY_POWER); + input_set_capability(onkey->input, EV_KEY, KEY_SLEEP); + + ret = request_threaded_irq(onkey->irq, NULL, da906x_onkey_irq_handler, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, "ONKEY", onkey); + if (ret) { + dev_err(&pdev->dev, "Failed to request IRQ.\n"); + goto err_input; + } + + ret = input_register_device(onkey->input); + if (ret) { + dev_err(&pdev->dev, "Failed to request IRQ.\n"); + goto err_irq; + } + + platform_set_drvdata(pdev, onkey); + + /* Interrupt reacts on button release */ + da906x_reg_update(da906x, DA906X_REG_CONFIG_I, + DA906X_NONKEY_PIN_MASK, DA906X_NONKEY_PIN_SWDOWN); + + return 0; + +err_irq: + free_irq(onkey->da906x->irq_base + onkey->irq , onkey); +err_input: + input_free_device(onkey->input); + return ret; +} + +static int __devexit da906x_onkey_remove(struct platform_device *pdev) +{ + struct da906x_onkey *onkey = platform_get_drvdata(pdev); + + free_irq(onkey->irq, onkey); + input_unregister_device(onkey->input); + return 0; +} + +static struct platform_driver da906x_onkey_driver = { + .probe = da906x_onkey_probe, + .remove = __devexit_p(da906x_onkey_remove), + .driver = { + .name = DA906X_DRVNAME_ONKEY, + .owner = THIS_MODULE, + }, +}; + +module_platform_driver(da906x_onkey_driver); + +MODULE_AUTHOR("Dialog Semiconductor <michal.hajduk@diasemi.com>"); +MODULE_DESCRIPTION("Onkey driver for DA906X"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("paltform:" DA906X_DRVNAME_ONKEY); -- 1.7.0.4 _______________________________________________ lm-sensors mailing list lm-sensors@lm-sensors.org http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2012-08-24 8:32 UTC|newest] Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-08-24 8:32 [RFC PATCH 0/8] DA906x PMIC driver Krystian Garbaciak 2012-08-24 8:32 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 8:32 ` [PATCH 1/8] mfd: Add Dialog DA906x core driver Krystian Garbaciak 2012-08-24 8:32 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 8:32 ` [PATCH 2/8] regulator: Add Dialog DA906x voltage regulators support Krystian Garbaciak 2012-08-24 8:32 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 8:32 ` [PATCH 3/8] rtc: Add RTC driver for DA906x PMIC Krystian Garbaciak 2012-08-24 8:32 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 8:32 ` [PATCH 4/8] hwmon: Add DA906x hardware monitoring support Krystian Garbaciak 2012-08-24 8:32 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 8:32 ` Krystian Garbaciak [this message] 2012-08-24 8:32 ` [lm-sensors] [PATCH 5/8] input: Add support for DA906x PMIC OnKey detection Krystian Garbaciak 2012-08-24 13:45 [RFC PATCH 0/8] DA906x PMIC driver Krystian Garbaciak 2012-08-24 13:45 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 13:50 ` [PATCH 1/8] mfd: Add Dialog DA906x core driver Krystian Garbaciak 2012-08-24 13:50 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 13:55 ` [RFC PATCH 2/8] regulator: Add Dialog DA906x voltage regulators support Krystian Garbaciak 2012-08-24 13:55 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 14:00 ` [RFC PATCH 3/8] rtc: Add RTC driver for DA906x PMIC Krystian Garbaciak 2012-08-24 14:00 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 14:05 ` [RFC PATCH 4/8] hwmon: Add DA906x hardware monitoring support Krystian Garbaciak 2012-08-24 14:05 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 14:10 ` [RFC PATCH 5/8] input: Add support for DA906x PMIC OnKey detection Krystian Garbaciak 2012-08-24 14:10 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 14:15 ` [RFC PATCH 6/8] input: Add support for DA906x vibration motor driver Krystian Garbaciak 2012-08-24 14:15 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 14:20 ` [RFC PATCH 7/8] watchdog: Add DA906x PMIC watchdog driver Krystian Garbaciak 2012-08-24 14:20 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 14:25 ` [RFC PATCH 8/8] leds: Add DA906x PMIC LED driver Krystian Garbaciak 2012-08-24 14:25 ` [lm-sensors] " Krystian Garbaciak 2012-08-24 18:45 ` [RFC PATCH 4/8] hwmon: Add DA906x hardware monitoring support Guenter Roeck 2012-08-24 18:45 ` [lm-sensors] " Guenter Roeck 2012-08-29 13:25 ` [PATCH] regulator: Fix bug in regulator_mode_to_status() core function Krystian Garbaciak 2012-08-29 13:25 ` [lm-sensors] " Krystian Garbaciak 2012-08-25 15:10 ` [RFC PATCH 2/8] regulator: Add Dialog DA906x voltage regulators support Mark Brown 2012-08-25 15:10 ` [lm-sensors] " Mark Brown 2012-08-29 14:50 ` Krystian Garbaciak 2012-08-29 14:50 ` [lm-sensors] " Krystian Garbaciak 2012-08-29 14:50 ` Krystian Garbaciak 2012-08-30 17:47 ` Mark Brown 2012-08-30 17:47 ` [lm-sensors] " Mark Brown 2012-08-31 10:00 ` Krystian Garbaciak 2012-08-31 10:00 ` [lm-sensors] " Krystian Garbaciak 2012-08-31 10:00 ` Krystian Garbaciak 2013-05-09 14:05 ` Guennadi Liakhovetski 2013-05-09 14:18 ` Anthony Olech 2013-05-09 14:28 ` Guennadi Liakhovetski 2013-05-09 14:42 ` Anthony Olech 2013-05-09 14:50 ` Guennadi Liakhovetski 2012-08-25 18:31 ` [PATCH 1/8] mfd: Add Dialog DA906x core driver Mark Brown 2012-08-25 18:31 ` [lm-sensors] " Mark Brown 2012-08-31 11:20 ` Krystian Garbaciak 2012-08-31 11:20 ` [lm-sensors] " Krystian Garbaciak 2012-08-31 11:20 ` Krystian Garbaciak 2012-08-31 11:37 ` Philippe Rétornaz 2012-08-31 11:37 ` [lm-sensors] " Philippe Rétornaz 2012-08-31 11:37 ` Philippe Rétornaz 2012-08-31 11:37 ` Philippe Rétornaz 2012-08-31 17:16 ` Mark Brown 2012-08-31 17:16 ` [lm-sensors] " Mark Brown
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=201208240835@sw-eng-lt-dc-vm2 \ --to=krystian.garbaciak@diasemi.com \ --cc=a.zummo@towertech.it \ --cc=ashish.jangam@kpitcummins.com \ --cc=broonie@opensource.wolfsonmicro.com \ --cc=bryan.wu@canonical.com \ --cc=dg77.kim@samsung.com \ --cc=dmitry.torokhov@gmail.com \ --cc=drjones@redhat.com \ --cc=linux-input@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-leds@vger.kernel.org \ --cc=linux-watchdog@vger.kernel.org \ --cc=lm-sensors@lm-sensors.org \ --cc=lrg@ti.com \ --cc=rpurdie@rpsys.net \ --cc=rtc-linux@googlegroups.com \ --cc=sameo@linux.intel.com \ --cc=wim@iguana.be \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.