linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V10] add 88pm80x onkey driver
@ 2012-07-17  7:17 Qiao Zhou
  2012-07-17  7:17 ` [PATCH V10] input: add onkey support to 88PM80X PMIC Qiao Zhou
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Qiao Zhou @ 2012-07-17  7:17 UTC (permalink / raw)
  To: dmitry.torokhov, sameo, linux-input; +Cc: Qiao Zhou

change log [v10->v9]:
1, change pr_err to dev_err.
2, add device_init_wakeup(,0) when device removes.
3, add ack by Dmitry.

change log [v9->v8]:
1, remove devm_xxx api.
2, fix the potential oops issue.
3, use __set_bit to set key_bit.

change log [v8->v7]:
1, remove file name in comments.
2, add error handling to regmap_read.
3, remove unnecessary onkey suspend/resume wrapper api.
4, remove the pm80x_chip cast by directly define the struct type.
5, fix the double free input device issue.

change log [v7->v6]:
1, add the ack by Arnd for the first two patches.
2, add NULL terminater for id_table in 88pm800.c & 88pm805.c.

change log [v6->v5]:
export_symbol_gpl for pm80x_regmap_config to fix build issue for module.

change log [v5->v4]:
1, change the file name, from 88pm800-core.c, 88pm805-core.c, 88pm80x-i2c.c
to 88pm800.c, 88pm805.c, 88pm80x.c, and modified Makefile accordingly.
2, replace the spinlock used to protect wakeup flag, with using set_bit/
clear_bit, which is suitable adn enough in SMP env.
3, add the version number in each patch.

change log [v4->v3]:
1, provide unified suspend/resume api for all sub-devices, and add
protection for 800 & 805 wakeup flag in SMP case.
2, clean register definition in 88pm80x.h, and thanks Arnd's help.
3, some minor changes in mfd Kconfig/Makefile.

change log [v3->v2]:
1, dynamically get the irq_base, for both regmap_add_irq_chip and
mfd_add_devices. add pm80x_request_irq & pm80x_free_irq for sub-driver
facility, and modify related irq thread operation. remove irq_base member
from 80x_chip & platform data.
2, split 88pm80x.o into 3 separate modules.
3, remove the 88pm80x r/w API, and directly use open-coded regmap api.
4, minor change: move pm80x_id_table from 80x-i2c.c to 800/805-core.c,
exported pm80x_init, pm80x_deinit, and pm80x_bulk_read, add callback in
pdata.

change log [v2->v1]:
1, split 88pm80x-core.c into 88pm800-core.c and 88pm805.c, per Arnd's
suggestion. after the re-arch, 88pm80x-i2c handles the 800 & 805 common
parts, while 800-core.c & 805-core.c handle the specific parts in each
chip.
2, add details about the workaround adding a i2c companion between 800 &
805, and make a separate patch for it, per Arnd's suggestion.
3, remove callback in pdata. but still keep the pdata currently.
4, only keep necessary register in 88pm80x.h, including registers for
regulator/rtc/onkey/power/codec etc, and remove other registers from global
visibility.
5, exported r/w API which requires regmap handle. as currently the pm800
chip has 3 i2c device, only passing a pm80x_chip info can't ensure r/w the
register in correct i2c device.

change log [v1]:
1, pm800 and pm805 are decoupled and probed separately;
2, re-used the most of API for pm800 and pm805 per Arnd's comments;
3, use regmap_irq, instead of previous 88pm80x_irq_data per Mark's comments.
use regmap_add_irq_chip, and remove previous 88pm80x irq handling.
4, remove callback function in rtc pdata per Arnd's comments.
5, updated some coding style issue.

Qiao Zhou (1):
  input: add onkey support to 88PM80X PMIC

 drivers/input/misc/88pm80x_onkey.c |  168 ++++++++++++++++++++++++++++++++++++
 drivers/input/misc/Kconfig         |   10 ++
 drivers/input/misc/Makefile        |    1 +
 3 files changed, 179 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/88pm80x_onkey.c


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V10] input: add onkey support to 88PM80X PMIC
  2012-07-17  7:17 [PATCH V10] add 88pm80x onkey driver Qiao Zhou
@ 2012-07-17  7:17 ` Qiao Zhou
       [not found] ` <500591FB.3020600@marvell.com>
  2012-07-24 22:30 ` Samuel Ortiz
  2 siblings, 0 replies; 5+ messages in thread
From: Qiao Zhou @ 2012-07-17  7:17 UTC (permalink / raw)
  To: dmitry.torokhov, sameo, linux-input; +Cc: Qiao Zhou

add onkey support to MARVELL 88PM80X PMIC.

Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/misc/88pm80x_onkey.c |  168 ++++++++++++++++++++++++++++++++++++
 drivers/input/misc/Kconfig         |   10 ++
 drivers/input/misc/Makefile        |    1 +
 3 files changed, 179 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/88pm80x_onkey.c

diff --git a/drivers/input/misc/88pm80x_onkey.c b/drivers/input/misc/88pm80x_onkey.c
new file mode 100644
index 0000000..7f26e7b
--- /dev/null
+++ b/drivers/input/misc/88pm80x_onkey.c
@@ -0,0 +1,168 @@
+/*
+ * Marvell 88PM80x ONKEY driver
+ *
+ * Copyright (C) 2012 Marvell International Ltd.
+ * Haojian Zhuang <haojian.zhuang@marvell.com>
+ * Qiao Zhou <zhouqiao@marvell.com>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * 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 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/input.h>
+#include <linux/mfd/88pm80x.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#define PM800_LONG_ONKEY_EN		(1 << 0)
+#define PM800_LONG_KEY_DELAY		(8)	/* 1 .. 16 seconds */
+#define PM800_LONKEY_PRESS_TIME		((PM800_LONG_KEY_DELAY-1) << 4)
+#define PM800_LONKEY_PRESS_TIME_MASK	(0xF0)
+#define PM800_SW_PDOWN			(1 << 5)
+
+struct pm80x_onkey_info {
+	struct input_dev *idev;
+	struct pm80x_chip *pm80x;
+	struct regmap *map;
+	int irq;
+};
+
+/* 88PM80x gives us an interrupt when ONKEY is held */
+static irqreturn_t pm80x_onkey_handler(int irq, void *data)
+{
+	struct pm80x_onkey_info *info = data;
+	int ret = 0;
+	unsigned int val;
+
+	ret = regmap_read(info->map, PM800_STATUS_1, &val);
+	if (ret < 0) {
+		dev_err(info->idev->dev.parent, "failed to read status: %d\n", ret);
+		return IRQ_NONE;
+	}
+	val &= PM800_ONKEY_STS1;
+
+	input_report_key(info->idev, KEY_POWER, val);
+	input_sync(info->idev);
+
+	return IRQ_HANDLED;
+}
+
+static SIMPLE_DEV_PM_OPS(pm80x_onkey_pm_ops, pm80x_dev_suspend,
+			 pm80x_dev_resume);
+
+static int __devinit pm80x_onkey_probe(struct platform_device *pdev)
+{
+
+	struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
+	struct pm80x_onkey_info *info;
+	int err;
+
+	info = kzalloc(sizeof(struct pm80x_onkey_info), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	info->pm80x = chip;
+
+	info->irq = platform_get_irq(pdev, 0);
+	if (info->irq < 0) {
+		dev_err(&pdev->dev, "No IRQ resource!\n");
+		err = -EINVAL;
+		goto out;
+	}
+
+	info->map = info->pm80x->regmap;
+	if (!info->map) {
+		dev_err(&pdev->dev, "no regmap!\n");
+		err = -EINVAL;
+		goto out;
+	}
+
+	info->idev = input_allocate_device();
+	if (!info->idev) {
+		dev_err(&pdev->dev, "Failed to allocate input dev\n");
+		err = -ENOMEM;
+		goto out;
+	}
+
+	info->idev->name = "88pm80x_on";
+	info->idev->phys = "88pm80x_on/input0";
+	info->idev->id.bustype = BUS_I2C;
+	info->idev->dev.parent = &pdev->dev;
+	info->idev->evbit[0] = BIT_MASK(EV_KEY);
+	__set_bit(KEY_POWER, info->idev->keybit);
+
+	err = pm80x_request_irq(info->pm80x, info->irq, pm80x_onkey_handler,
+					    IRQF_ONESHOT, "onkey", info);
+	if (err < 0) {
+		dev_err(&pdev->dev, "Failed to request IRQ: #%d: %d\n",
+			info->irq, err);
+		goto out_reg;
+	}
+
+	err = input_register_device(info->idev);
+	if (err) {
+		dev_err(&pdev->dev, "Can't register input device: %d\n", err);
+		goto out_irq;
+	}
+
+	platform_set_drvdata(pdev, info);
+
+	/* Enable long onkey detection */
+	regmap_update_bits(info->map, PM800_RTC_MISC4, PM800_LONG_ONKEY_EN,
+			   PM800_LONG_ONKEY_EN);
+	/* Set 8-second interval */
+	regmap_update_bits(info->map, PM800_RTC_MISC3,
+			   PM800_LONKEY_PRESS_TIME_MASK,
+			   PM800_LONKEY_PRESS_TIME);
+
+	device_init_wakeup(&pdev->dev, 1);
+	return 0;
+
+out_irq:
+	pm80x_free_irq(info->pm80x, info->irq, info);
+out_reg:
+	input_free_device(info->idev);
+out:
+	kfree(info);
+	return err;
+}
+
+static int __devexit pm80x_onkey_remove(struct platform_device *pdev)
+{
+	struct pm80x_onkey_info *info = platform_get_drvdata(pdev);
+
+	device_init_wakeup(&pdev->dev, 0);
+	pm80x_free_irq(info->pm80x, info->irq, info);
+	input_unregister_device(info->idev);
+	kfree(info);
+	return 0;
+}
+
+static struct platform_driver pm80x_onkey_driver = {
+	.driver = {
+		   .name = "88pm80x-onkey",
+		   .owner = THIS_MODULE,
+		   .pm = &pm80x_onkey_pm_ops,
+		   },
+	.probe = pm80x_onkey_probe,
+	.remove = __devexit_p(pm80x_onkey_remove),
+};
+
+module_platform_driver(pm80x_onkey_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Marvell 88PM80x ONKEY driver");
+MODULE_AUTHOR("Qiao Zhou <zhouqiao@marvell.com>");
+MODULE_ALIAS("platform:88pm80x-onkey");
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7faf4a7..7c0f1ec 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -22,6 +22,16 @@ config INPUT_88PM860X_ONKEY
 	  To compile this driver as a module, choose M here: the module
 	  will be called 88pm860x_onkey.
 
+config INPUT_88PM80X_ONKEY
+	tristate "88PM80x ONKEY support"
+	depends on MFD_88PM800
+	help
+	  Support the ONKEY of Marvell 88PM80x PMICs as an input device
+	  reporting power button status.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called 88pm80x_onkey.
+
 config INPUT_AB8500_PONKEY
 	tristate "AB8500 Pon (PowerOn) Key"
 	depends on AB8500_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index f55cdf4..83fe6f5 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -5,6 +5,7 @@
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_INPUT_88PM860X_ONKEY)	+= 88pm860x_onkey.o
+obj-$(CONFIG_INPUT_88PM80X_ONKEY)	+= 88pm80x_onkey.o
 obj-$(CONFIG_INPUT_AB8500_PONKEY)	+= ab8500-ponkey.o
 obj-$(CONFIG_INPUT_AD714X)		+= ad714x.o
 obj-$(CONFIG_INPUT_AD714X_I2C)		+= ad714x-i2c.o
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V10] add 88pm80x onkey driver
       [not found] ` <500591FB.3020600@marvell.com>
@ 2012-07-24  6:44   ` Qiao Zhou
  0 siblings, 0 replies; 5+ messages in thread
From: Qiao Zhou @ 2012-07-24  6:44 UTC (permalink / raw)
  To: Samuel Ortiz, Dmitry Torokhov, linux-input@vger.kernel.org

On 07/18/2012 12:25 AM, Qiao Zhou wrote:
> On 07/17/2012 03:17 PM, Qiao Zhou wrote:
>> change log [v10->v9]:
>> 1, change pr_err to dev_err.
>> 2, add device_init_wakeup(,0) when device removes.
>> 3, add ack by Dmitry.
>>
>> change log [v9->v8]:
>> 1, remove devm_xxx api.
>> 2, fix the potential oops issue.
>> 3, use __set_bit to set key_bit.
>>
>> change log [v8->v7]:
>> 1, remove file name in comments.
>> 2, add error handling to regmap_read.
>> 3, remove unnecessary onkey suspend/resume wrapper api.
>> 4, remove the pm80x_chip cast by directly define the struct type.
>> 5, fix the double free input device issue.
>>
>> change log [v7->v6]:
>> 1, add the ack by Arnd for the first two patches.
>> 2, add NULL terminater for id_table in 88pm800.c & 88pm805.c.
>>
>> change log [v6->v5]:
>> export_symbol_gpl for pm80x_regmap_config to fix build issue for module.
>>
>> change log [v5->v4]:
>> 1, change the file name, from 88pm800-core.c, 88pm805-core.c,
>> 88pm80x-i2c.c
>> to 88pm800.c, 88pm805.c, 88pm80x.c, and modified Makefile accordingly.
>> 2, replace the spinlock used to protect wakeup flag, with using set_bit/
>> clear_bit, which is suitable adn enough in SMP env.
>> 3, add the version number in each patch.
>>
>> change log [v4->v3]:
>> 1, provide unified suspend/resume api for all sub-devices, and add
>> protection for 800 & 805 wakeup flag in SMP case.
>> 2, clean register definition in 88pm80x.h, and thanks Arnd's help.
>> 3, some minor changes in mfd Kconfig/Makefile.
>>
>> change log [v3->v2]:
>> 1, dynamically get the irq_base, for both regmap_add_irq_chip and
>> mfd_add_devices. add pm80x_request_irq & pm80x_free_irq for sub-driver
>> facility, and modify related irq thread operation. remove irq_base member
>> from 80x_chip & platform data.
>> 2, split 88pm80x.o into 3 separate modules.
>> 3, remove the 88pm80x r/w API, and directly use open-coded regmap api.
>> 4, minor change: move pm80x_id_table from 80x-i2c.c to 800/805-core.c,
>> exported pm80x_init, pm80x_deinit, and pm80x_bulk_read, add callback in
>> pdata.
>>
>> change log [v2->v1]:
>> 1, split 88pm80x-core.c into 88pm800-core.c and 88pm805.c, per Arnd's
>> suggestion. after the re-arch, 88pm80x-i2c handles the 800 & 805 common
>> parts, while 800-core.c & 805-core.c handle the specific parts in each
>> chip.
>> 2, add details about the workaround adding a i2c companion between 800 &
>> 805, and make a separate patch for it, per Arnd's suggestion.
>> 3, remove callback in pdata. but still keep the pdata currently.
>> 4, only keep necessary register in 88pm80x.h, including registers for
>> regulator/rtc/onkey/power/codec etc, and remove other registers from
>> global
>> visibility.
>> 5, exported r/w API which requires regmap handle. as currently the pm800
>> chip has 3 i2c device, only passing a pm80x_chip info can't ensure r/w
>> the
>> register in correct i2c device.
>>
>> change log [v1]:
>> 1, pm800 and pm805 are decoupled and probed separately;
>> 2, re-used the most of API for pm800 and pm805 per Arnd's comments;
>> 3, use regmap_irq, instead of previous 88pm80x_irq_data per Mark's
>> comments.
>> use regmap_add_irq_chip, and remove previous 88pm80x irq handling.
>> 4, remove callback function in rtc pdata per Arnd's comments.
>> 5, updated some coding style issue.
>>
>> Qiao Zhou (1):
>>    input: add onkey support to 88PM80X PMIC
>>
>>   drivers/input/misc/88pm80x_onkey.c |  168
>> ++++++++++++++++++++++++++++++++++++
>>   drivers/input/misc/Kconfig         |   10 ++
>>   drivers/input/misc/Makefile        |    1 +
>>   3 files changed, 179 insertions(+), 0 deletions(-)
>>   create mode 100644 drivers/input/misc/88pm80x_onkey.c
>>
> Hi Samuel,
>
> would you please help check and apply this patch as it's ACKed by Dmitry?
>
Hi Samuel,

do you have any suggestion about this patch?

-- 

Best Regards
Qiao

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V10] add 88pm80x onkey driver
  2012-07-17  7:17 [PATCH V10] add 88pm80x onkey driver Qiao Zhou
  2012-07-17  7:17 ` [PATCH V10] input: add onkey support to 88PM80X PMIC Qiao Zhou
       [not found] ` <500591FB.3020600@marvell.com>
@ 2012-07-24 22:30 ` Samuel Ortiz
  2012-07-25  1:38   ` Qiao Zhou
  2 siblings, 1 reply; 5+ messages in thread
From: Samuel Ortiz @ 2012-07-24 22:30 UTC (permalink / raw)
  To: Qiao Zhou; +Cc: dmitry.torokhov, linux-input

Hi Zhou

On Tue, Jul 17, 2012 at 03:17:38PM +0800, Qiao Zhou wrote:
> change log [v10->v9]:
> 1, change pr_err to dev_err.
> 2, add device_init_wakeup(,0) when device removes.
> 3, add ack by Dmitry.
Patch applied, sorry for the delay.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V10] add 88pm80x onkey driver
  2012-07-24 22:30 ` Samuel Ortiz
@ 2012-07-25  1:38   ` Qiao Zhou
  0 siblings, 0 replies; 5+ messages in thread
From: Qiao Zhou @ 2012-07-25  1:38 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org

On 07/25/2012 06:30 AM, Samuel Ortiz wrote:
> Hi Zhou
>
> On Tue, Jul 17, 2012 at 03:17:38PM +0800, Qiao Zhou wrote:
>> change log [v10->v9]:
>> 1, change pr_err to dev_err.
>> 2, add device_init_wakeup(,0) when device removes.
>> 3, add ack by Dmitry.
> Patch applied, sorry for the delay.
>
> Cheers,
> Samuel.
>
Samuel,

thanks!

-- 

Best Regards
Qiao

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-07-25  1:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-17  7:17 [PATCH V10] add 88pm80x onkey driver Qiao Zhou
2012-07-17  7:17 ` [PATCH V10] input: add onkey support to 88PM80X PMIC Qiao Zhou
     [not found] ` <500591FB.3020600@marvell.com>
2012-07-24  6:44   ` [PATCH V10] add 88pm80x onkey driver Qiao Zhou
2012-07-24 22:30 ` Samuel Ortiz
2012-07-25  1:38   ` Qiao Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).