linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: cpcap-pwrbutton: new driver
@ 2017-02-24  8:59 Sebastian Reichel
  2017-02-25 18:58 ` Dmitry Torokhov
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Sebastian Reichel @ 2017-02-24  8:59 UTC (permalink / raw)
  To: Sebastian Reichel, Tony Lindgren, Dmitry Torokhov
  Cc: Rob Herring, Mark Rutland, linux-input, devicetree, linux-kernel

Motorola CPCAP is a PMIC found in multiple smartphones.
This driver adds support for the power/on button and has
been tested with Droid 4.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 .../devicetree/bindings/input/cpcap-pwrbutton.txt  |  20 ++++
 drivers/input/misc/Kconfig                         |  10 ++
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/cpcap-pwrbutton.c               | 119 +++++++++++++++++++++
 4 files changed, 150 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
 create mode 100644 drivers/input/misc/cpcap-pwrbutton.c

diff --git a/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt b/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
new file mode 100644
index 000000000000..0dd0076daf71
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
@@ -0,0 +1,20 @@
+Motorola CPCAP on key
+
+This module is part of the CPCAP. For more details about the whole
+chip see Documentation/devicetree/bindings/mfd/motorola-cpcap.txt.
+
+This module provides a simple power button event via an Interrupt.
+
+Required properties:
+- compatible: should be one of the following
+   - "motorola,cpcap-pwrbutton"
+- interrupts: irq specifier for CPCAP's ON IRQ
+
+Example:
+
+&cpcap {
+	cpcap_pwrbutton: pwrbutton {
+		compatible = "motorola,cpcap-pwrbutton";
+		interrupts = <23 IRQ_TYPE_NONE>;
+	};
+};
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5b6c52210d20..9f7b72249eac 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -316,6 +316,16 @@ config INPUT_COBALT_BTNS
 	  To compile this driver as a module, choose M here: the
 	  module will be called cobalt_btns.
 
+config INPUT_CPCAP_PWRBUTTON
+	tristate "CPCAP OnKey"
+	depends on MFD_CPCAP
+	help
+	  Say Y here if you want to enable power key reporting via the
+	  Motorola CPCAP chip.
+
+	  To compile this driver as a module, choose M here. The module will
+	  be called cpcap-pwrbutton.
+
 config INPUT_WISTRON_BTNS
 	tristate "x86 Wistron laptop button interface"
 	depends on X86_32
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b10523f2878e..b923a9828c88 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_INPUT_CM109)		+= cm109.o
 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_CPCAP_PWRBUTTON)	+= cpcap-pwrbutton.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)	+= da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)	+= da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)	+= da9063_onkey.o
diff --git a/drivers/input/misc/cpcap-pwrbutton.c b/drivers/input/misc/cpcap-pwrbutton.c
new file mode 100644
index 000000000000..ed6674689e79
--- /dev/null
+++ b/drivers/input/misc/cpcap-pwrbutton.c
@@ -0,0 +1,119 @@
+/**
+ * CPCAP Power Button Input Driver
+ *
+ * Copyright (C) 2017 Sebastian Reichel <sre@kernel.org>
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/regmap.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/mfd/motorola-cpcap.h>
+
+#define CPCAP_IRQ_ON 23
+#define CPCAP_IRQ_ON_BITMASK (1 << (CPCAP_IRQ_ON % 16))
+
+struct cpcap_power_button {
+	struct regmap *regmap;
+	struct input_dev *idev;
+	struct device *dev;
+};
+
+static irqreturn_t powerbutton_irq(int irq, void *_button)
+{
+	struct cpcap_power_button *button = _button;
+	bool key_pressed;
+	int err, val;
+
+	err = regmap_read(button->regmap, CPCAP_REG_INTS2, &val);
+	if (err) {
+		dev_err(button->dev, "read failed: %d", err);
+		return IRQ_HANDLED;
+	}
+	key_pressed = !!(val & CPCAP_IRQ_ON_BITMASK);
+
+	pm_wakeup_event(button->dev, 0);
+	input_report_key(button->idev, KEY_POWER, key_pressed);
+	input_sync(button->idev);
+
+	return IRQ_HANDLED;
+}
+
+static int cpcap_power_button_probe(struct platform_device *pdev)
+{
+	struct cpcap_power_button *button;
+	int irq = platform_get_irq(pdev, 0);
+	int err;
+
+	button = devm_kmalloc(&pdev->dev, sizeof(*button), GFP_KERNEL);
+	if (!button)
+		return -ENOMEM;
+
+	button->idev = devm_input_allocate_device(&pdev->dev);
+	if (!button->idev)
+		return -ENOMEM;
+
+	button->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+	if (!button->regmap)
+		return -ENODEV;
+
+	button->dev = &pdev->dev;
+
+	button->idev->name = "cpcap-pwrbutton";
+	button->idev->phys = "cpcap-pwrbutton/input0";
+	button->idev->dev.parent = button->dev;
+	input_set_capability(button->idev, EV_KEY, KEY_POWER);
+
+	err = devm_request_threaded_irq(&button->idev->dev, irq, NULL,
+		powerbutton_irq, IRQF_ONESHOT, "cpcap_pwrbutton", button);
+	if (err < 0) {
+		dev_err(&pdev->dev, "IRQ request failed: %d\n", err);
+		return err;
+	}
+
+	err = input_register_device(button->idev);
+	if (err) {
+		dev_err(&pdev->dev, "Input register failed: %d\n", err);
+		return err;
+	}
+
+	device_init_wakeup(&pdev->dev, true);
+
+	return 0;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id cpcap_pwrbutton_dt_match_table[] = {
+	{ .compatible = "motorola,cpcap-pwrbutton" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, cpcap_pwrbutton_dt_match_table);
+#endif
+
+static struct platform_driver cpcap_power_button_driver = {
+	.probe		= cpcap_power_button_probe,
+	.driver		= {
+		.name	= "cpcap-pwrbutton",
+		.of_match_table = of_match_ptr(cpcap_pwrbutton_dt_match_table),
+	},
+};
+module_platform_driver(cpcap_power_button_driver);
+
+MODULE_ALIAS("platform:cpcap-pwrbutton");
+MODULE_DESCRIPTION("CPCAP Power Button");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sebastian Reichel <sre@kernel.org>");
-- 
2.11.0

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

* Re: [PATCH] input: cpcap-pwrbutton: new driver
  2017-02-24  8:59 [PATCH] input: cpcap-pwrbutton: new driver Sebastian Reichel
@ 2017-02-25 18:58 ` Dmitry Torokhov
  2017-02-25 19:21   ` Tony Lindgren
  2017-02-28  0:18 ` Rob Herring
  2017-03-02  0:22 ` [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Sebastian Reichel
  2 siblings, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2017-02-25 18:58 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Tony Lindgren, Rob Herring, Mark Rutland, linux-input,
	devicetree, linux-kernel

Hi Sebastian,

On Fri, Feb 24, 2017 at 09:59:09AM +0100, Sebastian Reichel wrote:
> Motorola CPCAP is a PMIC found in multiple smartphones.
> This driver adds support for the power/on button and has
> been tested with Droid 4.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>  .../devicetree/bindings/input/cpcap-pwrbutton.txt  |  20 ++++
>  drivers/input/misc/Kconfig                         |  10 ++
>  drivers/input/misc/Makefile                        |   1 +
>  drivers/input/misc/cpcap-pwrbutton.c               | 119 +++++++++++++++++++++
>  4 files changed, 150 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
>  create mode 100644 drivers/input/misc/cpcap-pwrbutton.c
> 
> diff --git a/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt b/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
> new file mode 100644
> index 000000000000..0dd0076daf71
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
> @@ -0,0 +1,20 @@
> +Motorola CPCAP on key
> +
> +This module is part of the CPCAP. For more details about the whole
> +chip see Documentation/devicetree/bindings/mfd/motorola-cpcap.txt.
> +
> +This module provides a simple power button event via an Interrupt.
> +
> +Required properties:
> +- compatible: should be one of the following
> +   - "motorola,cpcap-pwrbutton"
> +- interrupts: irq specifier for CPCAP's ON IRQ
> +
> +Example:
> +
> +&cpcap {
> +	cpcap_pwrbutton: pwrbutton {
> +		compatible = "motorola,cpcap-pwrbutton";
> +		interrupts = <23 IRQ_TYPE_NONE>;
> +	};
> +};
> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> index 5b6c52210d20..9f7b72249eac 100644
> --- a/drivers/input/misc/Kconfig
> +++ b/drivers/input/misc/Kconfig
> @@ -316,6 +316,16 @@ config INPUT_COBALT_BTNS
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called cobalt_btns.
>  
> +config INPUT_CPCAP_PWRBUTTON
> +	tristate "CPCAP OnKey"
> +	depends on MFD_CPCAP
> +	help
> +	  Say Y here if you want to enable power key reporting via the
> +	  Motorola CPCAP chip.
> +
> +	  To compile this driver as a module, choose M here. The module will
> +	  be called cpcap-pwrbutton.
> +
>  config INPUT_WISTRON_BTNS
>  	tristate "x86 Wistron laptop button interface"
>  	depends on X86_32
> diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
> index b10523f2878e..b923a9828c88 100644
> --- a/drivers/input/misc/Makefile
> +++ b/drivers/input/misc/Makefile
> @@ -24,6 +24,7 @@ obj-$(CONFIG_INPUT_CM109)		+= cm109.o
>  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_CPCAP_PWRBUTTON)	+= cpcap-pwrbutton.o
>  obj-$(CONFIG_INPUT_DA9052_ONKEY)	+= da9052_onkey.o
>  obj-$(CONFIG_INPUT_DA9055_ONKEY)	+= da9055_onkey.o
>  obj-$(CONFIG_INPUT_DA9063_ONKEY)	+= da9063_onkey.o
> diff --git a/drivers/input/misc/cpcap-pwrbutton.c b/drivers/input/misc/cpcap-pwrbutton.c
> new file mode 100644
> index 000000000000..ed6674689e79
> --- /dev/null
> +++ b/drivers/input/misc/cpcap-pwrbutton.c
> @@ -0,0 +1,119 @@
> +/**
> + * CPCAP Power Button Input Driver
> + *
> + * Copyright (C) 2017 Sebastian Reichel <sre@kernel.org>
> + *
> + * 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.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/errno.h>
> +#include <linux/input.h>
> +#include <linux/interrupt.h>
> +#include <linux/regmap.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/mfd/motorola-cpcap.h>
> +
> +#define CPCAP_IRQ_ON 23
> +#define CPCAP_IRQ_ON_BITMASK (1 << (CPCAP_IRQ_ON % 16))

Is this truly static or it could depend= on IRQ returned by
platform_get_irq()?

> +
> +struct cpcap_power_button {
> +	struct regmap *regmap;
> +	struct input_dev *idev;
> +	struct device *dev;
> +};
> +
> +static irqreturn_t powerbutton_irq(int irq, void *_button)
> +{
> +	struct cpcap_power_button *button = _button;
> +	bool key_pressed;
> +	int err, val;
> +
> +	err = regmap_read(button->regmap, CPCAP_REG_INTS2, &val);
> +	if (err) {
> +		dev_err(button->dev, "read failed: %d", err);
> +		return IRQ_HANDLED;
> +	}
> +	key_pressed = !!(val & CPCAP_IRQ_ON_BITMASK);

No need to do this, input_report_key() already "normalizes" the value,
so simply do

	input_report_key(button->idev, KEY_POWER, val & CPCAP_IRQ_ON_BITMASK);

> +
> +	pm_wakeup_event(button->dev, 0);
> +	input_report_key(button->idev, KEY_POWER, key_pressed);
> +	input_sync(button->idev);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static int cpcap_power_button_probe(struct platform_device *pdev)
> +{
> +	struct cpcap_power_button *button;
> +	int irq = platform_get_irq(pdev, 0);
> +	int err;
> +
> +	button = devm_kmalloc(&pdev->dev, sizeof(*button), GFP_KERNEL);
> +	if (!button)
> +		return -ENOMEM;
> +
> +	button->idev = devm_input_allocate_device(&pdev->dev);
> +	if (!button->idev)
> +		return -ENOMEM;
> +
> +	button->regmap = dev_get_regmap(pdev->dev.parent, NULL);
> +	if (!button->regmap)
> +		return -ENODEV;
> +
> +	button->dev = &pdev->dev;
> +
> +	button->idev->name = "cpcap-pwrbutton";
> +	button->idev->phys = "cpcap-pwrbutton/input0";
> +	button->idev->dev.parent = button->dev;
> +	input_set_capability(button->idev, EV_KEY, KEY_POWER);
> +
> +	err = devm_request_threaded_irq(&button->idev->dev, irq, NULL,

This is wrong device to attach devm to: we never bind input device to a
driver, so interrupt will never be released. You want to use &pdev->dev
as with the rest of devm resources.

> +		powerbutton_irq, IRQF_ONESHOT, "cpcap_pwrbutton", button);
> +	if (err < 0) {
> +		dev_err(&pdev->dev, "IRQ request failed: %d\n", err);
> +		return err;
> +	}
> +
> +	err = input_register_device(button->idev);
> +	if (err) {
> +		dev_err(&pdev->dev, "Input register failed: %d\n", err);
> +		return err;
> +	}
> +
> +	device_init_wakeup(&pdev->dev, true);
> +
> +	return 0;
> +}
> +
> +#ifdef CONFIG_OF
> +static const struct of_device_id cpcap_pwrbutton_dt_match_table[] = {
> +	{ .compatible = "motorola,cpcap-pwrbutton" },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, cpcap_pwrbutton_dt_match_table);
> +#endif
> +
> +static struct platform_driver cpcap_power_button_driver = {
> +	.probe		= cpcap_power_button_probe,
> +	.driver		= {
> +		.name	= "cpcap-pwrbutton",
> +		.of_match_table = of_match_ptr(cpcap_pwrbutton_dt_match_table),
> +	},
> +};
> +module_platform_driver(cpcap_power_button_driver);
> +
> +MODULE_ALIAS("platform:cpcap-pwrbutton");
> +MODULE_DESCRIPTION("CPCAP Power Button");
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Sebastian Reichel <sre@kernel.org>");
> -- 
> 2.11.0
> 

Thanks.

-- 
Dmitry

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

* Re: [PATCH] input: cpcap-pwrbutton: new driver
  2017-02-25 18:58 ` Dmitry Torokhov
@ 2017-02-25 19:21   ` Tony Lindgren
  2017-02-28  2:32     ` Tony Lindgren
  0 siblings, 1 reply; 12+ messages in thread
From: Tony Lindgren @ 2017-02-25 19:21 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Sebastian Reichel, Rob Herring, Mark Rutland, linux-input,
	devicetree, linux-kernel

* Dmitry Torokhov <dmitry.torokhov@gmail.com> [170225 11:00]:
> On Fri, Feb 24, 2017 at 09:59:09AM +0100, Sebastian Reichel wrote:
> > +#include <linux/mfd/motorola-cpcap.h>
> > +
> > +#define CPCAP_IRQ_ON 23
> > +#define CPCAP_IRQ_ON_BITMASK (1 << (CPCAP_IRQ_ON % 16))
> 
> Is this truly static or it could depend= on IRQ returned by
> platform_get_irq()?

I suggest we add it to include/linux/mfd/motorola-cpcap.h:

static inline int cpcap_get_irq_status(struct device *dev,
				       struct regmap *regmap,
				       int irq,
				       u16 *status);

Or do you guys have better ideas?

I'll be needing that for the USB PHY driver too for multiple
bits so we want to return the whole bank register in status.

We may want to change to do that later to avoid dependencies
or set up an immutable branch with just that change.

Other than that things work for me based on a quick test.

Regards,

Tony

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

* Re: [PATCH] input: cpcap-pwrbutton: new driver
  2017-02-24  8:59 [PATCH] input: cpcap-pwrbutton: new driver Sebastian Reichel
  2017-02-25 18:58 ` Dmitry Torokhov
@ 2017-02-28  0:18 ` Rob Herring
  2017-03-02  0:22 ` [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Sebastian Reichel
  2 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2017-02-28  0:18 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Tony Lindgren, Dmitry Torokhov, Mark Rutland, linux-input,
	devicetree, linux-kernel

On Fri, Feb 24, 2017 at 09:59:09AM +0100, Sebastian Reichel wrote:
> Motorola CPCAP is a PMIC found in multiple smartphones.
> This driver adds support for the power/on button and has
> been tested with Droid 4.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>  .../devicetree/bindings/input/cpcap-pwrbutton.txt  |  20 ++++

Acked-by: Rob Herring <robh@kernel.org>

>  drivers/input/misc/Kconfig                         |  10 ++
>  drivers/input/misc/Makefile                        |   1 +
>  drivers/input/misc/cpcap-pwrbutton.c               | 119 +++++++++++++++++++++
>  4 files changed, 150 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
>  create mode 100644 drivers/input/misc/cpcap-pwrbutton.c

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

* Re: [PATCH] input: cpcap-pwrbutton: new driver
  2017-02-25 19:21   ` Tony Lindgren
@ 2017-02-28  2:32     ` Tony Lindgren
  0 siblings, 0 replies; 12+ messages in thread
From: Tony Lindgren @ 2017-02-28  2:32 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Sebastian Reichel, Rob Herring, Mark Rutland, linux-input,
	devicetree, linux-kernel

* Tony Lindgren <tony@atomide.com> [170225 11:21]:
> * Dmitry Torokhov <dmitry.torokhov@gmail.com> [170225 11:00]:
> > On Fri, Feb 24, 2017 at 09:59:09AM +0100, Sebastian Reichel wrote:
> > > +#include <linux/mfd/motorola-cpcap.h>
> > > +
> > > +#define CPCAP_IRQ_ON 23
> > > +#define CPCAP_IRQ_ON_BITMASK (1 << (CPCAP_IRQ_ON % 16))
> > 
> > Is this truly static or it could depend= on IRQ returned by
> > platform_get_irq()?
> 
> I suggest we add it to include/linux/mfd/motorola-cpcap.h:
> 
> static inline int cpcap_get_irq_status(struct device *dev,
> 				       struct regmap *regmap,
> 				       int irq,
> 				       u16 *status);
> 
> Or do you guys have better ideas?

Actually after thinking about it, a macro like Sebastian has
is probably better. Otherwise the interface will be confusing
unless we limit it to getting just one bit instead of the whole
bank. So I now suggest let's just keep it in Sebastian's driver,
then we can move it later as it's just a one line.

Regards,

Tony

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

* [PATCHv2 1/2] mfd: cpcap: implement irq sense helper
  2017-02-24  8:59 [PATCH] input: cpcap-pwrbutton: new driver Sebastian Reichel
  2017-02-25 18:58 ` Dmitry Torokhov
  2017-02-28  0:18 ` Rob Herring
@ 2017-03-02  0:22 ` Sebastian Reichel
  2017-03-02  0:22   ` [PATCHv2 2/2] input: cpcap-pwrbutton: new driver Sebastian Reichel
                     ` (2 more replies)
  2 siblings, 3 replies; 12+ messages in thread
From: Sebastian Reichel @ 2017-03-02  0:22 UTC (permalink / raw)
  To: Sebastian Reichel, Tony Lindgren, Dmitry Torokhov, Lee Jones
  Cc: Rob Herring, Mark Rutland, linux-input, devicetree, linux-kernel

CPCAP can sense if IRQ is currently set or not. This
functionality is required for a few subdevices, such
as the power button and usb phy modules.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
Changes since PATCHv1:
 - Newly introduced patch
---
 drivers/mfd/motorola-cpcap.c       | 25 +++++++++++++++++++++++++
 include/linux/mfd/motorola-cpcap.h |  2 ++
 2 files changed, 27 insertions(+)

diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
index 6aeada7d7ce5..b2a53750d579 100644
--- a/drivers/mfd/motorola-cpcap.c
+++ b/drivers/mfd/motorola-cpcap.c
@@ -32,6 +32,31 @@ struct cpcap_ddata {
 	struct regmap *regmap;
 };
 
+static int cpcap_sense_irq(struct regmap *regmap, int irq)
+{
+	int reg = CPCAP_REG_INTS1 + (irq / 16) * 4;
+	int mask = 1 << (irq % 16);
+	int err, val;
+
+	if (irq < 0 || irq > 64)
+		return -EINVAL;
+
+	err = regmap_read(regmap, reg, &val);
+	if (err)
+		return err;
+
+	return !!(val & mask);
+}
+
+int cpcap_sense_virq(struct regmap *regmap, int virq)
+{
+	struct regmap_irq_chip_data *d = irq_get_chip_data(virq);
+	int base = regmap_irq_chip_get_base(d);
+
+	return cpcap_sense_irq(regmap, virq - base);
+}
+EXPORT_SYMBOL_GPL(cpcap_sense_irq);
+
 static int cpcap_check_revision(struct cpcap_ddata *cpcap)
 {
 	u16 vendor, rev;
diff --git a/include/linux/mfd/motorola-cpcap.h b/include/linux/mfd/motorola-cpcap.h
index b4031c2b2214..7629e0d24d26 100644
--- a/include/linux/mfd/motorola-cpcap.h
+++ b/include/linux/mfd/motorola-cpcap.h
@@ -290,3 +290,5 @@ static inline int cpcap_get_vendor(struct device *dev,
 
 	return 0;
 }
+
+int cpcap_sense_virq(struct regmap *regmap, int virq);
-- 
2.11.0

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

* [PATCHv2 2/2] input: cpcap-pwrbutton: new driver
  2017-03-02  0:22 ` [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Sebastian Reichel
@ 2017-03-02  0:22   ` Sebastian Reichel
  2017-03-02  1:20     ` Dmitry Torokhov
  2017-03-04 16:22     ` kbuild test robot
  2017-03-02 15:17   ` [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Tony Lindgren
  2017-03-02 16:09   ` Tony Lindgren
  2 siblings, 2 replies; 12+ messages in thread
From: Sebastian Reichel @ 2017-03-02  0:22 UTC (permalink / raw)
  To: Sebastian Reichel, Tony Lindgren, Dmitry Torokhov, Lee Jones
  Cc: Rob Herring, Mark Rutland, linux-input, devicetree, linux-kernel

Motorola CPCAP is a PMIC found in multiple smartphones.
This driver adds support for the power/on button and has
been tested in Droid 4.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
Changes since PATCHv1:
 - Fix device for devm_request_threaded_irq()
 - Add Acked-By from Rob Herring (for the DT binding)
 - Use newly introduced cpcap_sense_virq to sense the IRQ pin
---
 .../devicetree/bindings/input/cpcap-pwrbutton.txt  |  20 ++++
 drivers/input/misc/Kconfig                         |  10 ++
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/cpcap-pwrbutton.c               | 117 +++++++++++++++++++++
 4 files changed, 148 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
 create mode 100644 drivers/input/misc/cpcap-pwrbutton.c

diff --git a/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt b/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
new file mode 100644
index 000000000000..0dd0076daf71
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
@@ -0,0 +1,20 @@
+Motorola CPCAP on key
+
+This module is part of the CPCAP. For more details about the whole
+chip see Documentation/devicetree/bindings/mfd/motorola-cpcap.txt.
+
+This module provides a simple power button event via an Interrupt.
+
+Required properties:
+- compatible: should be one of the following
+   - "motorola,cpcap-pwrbutton"
+- interrupts: irq specifier for CPCAP's ON IRQ
+
+Example:
+
+&cpcap {
+	cpcap_pwrbutton: pwrbutton {
+		compatible = "motorola,cpcap-pwrbutton";
+		interrupts = <23 IRQ_TYPE_NONE>;
+	};
+};
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5b6c52210d20..9f7b72249eac 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -316,6 +316,16 @@ config INPUT_COBALT_BTNS
 	  To compile this driver as a module, choose M here: the
 	  module will be called cobalt_btns.
 
+config INPUT_CPCAP_PWRBUTTON
+	tristate "CPCAP OnKey"
+	depends on MFD_CPCAP
+	help
+	  Say Y here if you want to enable power key reporting via the
+	  Motorola CPCAP chip.
+
+	  To compile this driver as a module, choose M here. The module will
+	  be called cpcap-pwrbutton.
+
 config INPUT_WISTRON_BTNS
 	tristate "x86 Wistron laptop button interface"
 	depends on X86_32
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b10523f2878e..b923a9828c88 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_INPUT_CM109)		+= cm109.o
 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_CPCAP_PWRBUTTON)	+= cpcap-pwrbutton.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)	+= da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)	+= da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)	+= da9063_onkey.o
diff --git a/drivers/input/misc/cpcap-pwrbutton.c b/drivers/input/misc/cpcap-pwrbutton.c
new file mode 100644
index 000000000000..0abef63217e2
--- /dev/null
+++ b/drivers/input/misc/cpcap-pwrbutton.c
@@ -0,0 +1,117 @@
+/**
+ * CPCAP Power Button Input Driver
+ *
+ * Copyright (C) 2017 Sebastian Reichel <sre@kernel.org>
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/regmap.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/mfd/motorola-cpcap.h>
+
+#define CPCAP_IRQ_ON 23
+#define CPCAP_IRQ_ON_BITMASK (1 << (CPCAP_IRQ_ON % 16))
+
+struct cpcap_power_button {
+	struct regmap *regmap;
+	struct input_dev *idev;
+	struct device *dev;
+};
+
+static irqreturn_t powerbutton_irq(int irq, void *_button)
+{
+	struct cpcap_power_button *button = _button;
+	int val;
+
+	val = cpcap_sense_virq(button->regmap, irq);
+	if (val < 0) {
+		dev_err(button->dev, "irq read failed: %d", val);
+		return IRQ_HANDLED;
+	}
+
+	pm_wakeup_event(button->dev, 0);
+	input_report_key(button->idev, KEY_POWER, val);
+	input_sync(button->idev);
+
+	return IRQ_HANDLED;
+}
+
+static int cpcap_power_button_probe(struct platform_device *pdev)
+{
+	struct cpcap_power_button *button;
+	int irq = platform_get_irq(pdev, 0);
+	int err;
+
+	button = devm_kmalloc(&pdev->dev, sizeof(*button), GFP_KERNEL);
+	if (!button)
+		return -ENOMEM;
+
+	button->idev = devm_input_allocate_device(&pdev->dev);
+	if (!button->idev)
+		return -ENOMEM;
+
+	button->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+	if (!button->regmap)
+		return -ENODEV;
+
+	button->dev = &pdev->dev;
+
+	button->idev->name = "cpcap-pwrbutton";
+	button->idev->phys = "cpcap-pwrbutton/input0";
+	button->idev->dev.parent = button->dev;
+	input_set_capability(button->idev, EV_KEY, KEY_POWER);
+
+	err = devm_request_threaded_irq(&pdev->dev, irq, NULL,
+		powerbutton_irq, IRQF_ONESHOT, "cpcap_pwrbutton", button);
+	if (err < 0) {
+		dev_err(&pdev->dev, "IRQ request failed: %d\n", err);
+		return err;
+	}
+
+	err = input_register_device(button->idev);
+	if (err) {
+		dev_err(&pdev->dev, "Input register failed: %d\n", err);
+		return err;
+	}
+
+	device_init_wakeup(&pdev->dev, true);
+
+	return 0;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id cpcap_pwrbutton_dt_match_table[] = {
+	{ .compatible = "motorola,cpcap-pwrbutton" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, cpcap_pwrbutton_dt_match_table);
+#endif
+
+static struct platform_driver cpcap_power_button_driver = {
+	.probe		= cpcap_power_button_probe,
+	.driver		= {
+		.name	= "cpcap-pwrbutton",
+		.of_match_table = of_match_ptr(cpcap_pwrbutton_dt_match_table),
+	},
+};
+module_platform_driver(cpcap_power_button_driver);
+
+MODULE_ALIAS("platform:cpcap-pwrbutton");
+MODULE_DESCRIPTION("CPCAP Power Button");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sebastian Reichel <sre@kernel.org>");
-- 
2.11.0

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

* Re: [PATCHv2 2/2] input: cpcap-pwrbutton: new driver
  2017-03-02  0:22   ` [PATCHv2 2/2] input: cpcap-pwrbutton: new driver Sebastian Reichel
@ 2017-03-02  1:20     ` Dmitry Torokhov
  2017-03-02 18:01       ` Tony Lindgren
  2017-03-04 16:22     ` kbuild test robot
  1 sibling, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2017-03-02  1:20 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Tony Lindgren, Lee Jones, Rob Herring, Mark Rutland, linux-input,
	devicetree, linux-kernel

On Thu, Mar 02, 2017 at 01:22:42AM +0100, Sebastian Reichel wrote:
> Motorola CPCAP is a PMIC found in multiple smartphones.
> This driver adds support for the power/on button and has
> been tested in Droid 4.
> 
> Acked-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
> Changes since PATCHv1:
>  - Fix device for devm_request_threaded_irq()
>  - Add Acked-By from Rob Herring (for the DT binding)
>  - Use newly introduced cpcap_sense_virq to sense the IRQ pin

OK, so will this be merged through MFD? If so:

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

> ---
>  .../devicetree/bindings/input/cpcap-pwrbutton.txt  |  20 ++++
>  drivers/input/misc/Kconfig                         |  10 ++
>  drivers/input/misc/Makefile                        |   1 +
>  drivers/input/misc/cpcap-pwrbutton.c               | 117 +++++++++++++++++++++
>  4 files changed, 148 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
>  create mode 100644 drivers/input/misc/cpcap-pwrbutton.c
> 
> diff --git a/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt b/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
> new file mode 100644
> index 000000000000..0dd0076daf71
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
> @@ -0,0 +1,20 @@
> +Motorola CPCAP on key
> +
> +This module is part of the CPCAP. For more details about the whole
> +chip see Documentation/devicetree/bindings/mfd/motorola-cpcap.txt.
> +
> +This module provides a simple power button event via an Interrupt.
> +
> +Required properties:
> +- compatible: should be one of the following
> +   - "motorola,cpcap-pwrbutton"
> +- interrupts: irq specifier for CPCAP's ON IRQ
> +
> +Example:
> +
> +&cpcap {
> +	cpcap_pwrbutton: pwrbutton {
> +		compatible = "motorola,cpcap-pwrbutton";
> +		interrupts = <23 IRQ_TYPE_NONE>;
> +	};
> +};
> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> index 5b6c52210d20..9f7b72249eac 100644
> --- a/drivers/input/misc/Kconfig
> +++ b/drivers/input/misc/Kconfig
> @@ -316,6 +316,16 @@ config INPUT_COBALT_BTNS
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called cobalt_btns.
>  
> +config INPUT_CPCAP_PWRBUTTON
> +	tristate "CPCAP OnKey"
> +	depends on MFD_CPCAP
> +	help
> +	  Say Y here if you want to enable power key reporting via the
> +	  Motorola CPCAP chip.
> +
> +	  To compile this driver as a module, choose M here. The module will
> +	  be called cpcap-pwrbutton.
> +
>  config INPUT_WISTRON_BTNS
>  	tristate "x86 Wistron laptop button interface"
>  	depends on X86_32
> diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
> index b10523f2878e..b923a9828c88 100644
> --- a/drivers/input/misc/Makefile
> +++ b/drivers/input/misc/Makefile
> @@ -24,6 +24,7 @@ obj-$(CONFIG_INPUT_CM109)		+= cm109.o
>  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_CPCAP_PWRBUTTON)	+= cpcap-pwrbutton.o
>  obj-$(CONFIG_INPUT_DA9052_ONKEY)	+= da9052_onkey.o
>  obj-$(CONFIG_INPUT_DA9055_ONKEY)	+= da9055_onkey.o
>  obj-$(CONFIG_INPUT_DA9063_ONKEY)	+= da9063_onkey.o
> diff --git a/drivers/input/misc/cpcap-pwrbutton.c b/drivers/input/misc/cpcap-pwrbutton.c
> new file mode 100644
> index 000000000000..0abef63217e2
> --- /dev/null
> +++ b/drivers/input/misc/cpcap-pwrbutton.c
> @@ -0,0 +1,117 @@
> +/**
> + * CPCAP Power Button Input Driver
> + *
> + * Copyright (C) 2017 Sebastian Reichel <sre@kernel.org>
> + *
> + * 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.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/errno.h>
> +#include <linux/input.h>
> +#include <linux/interrupt.h>
> +#include <linux/regmap.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/mfd/motorola-cpcap.h>
> +
> +#define CPCAP_IRQ_ON 23
> +#define CPCAP_IRQ_ON_BITMASK (1 << (CPCAP_IRQ_ON % 16))
> +
> +struct cpcap_power_button {
> +	struct regmap *regmap;
> +	struct input_dev *idev;
> +	struct device *dev;
> +};
> +
> +static irqreturn_t powerbutton_irq(int irq, void *_button)
> +{
> +	struct cpcap_power_button *button = _button;
> +	int val;
> +
> +	val = cpcap_sense_virq(button->regmap, irq);
> +	if (val < 0) {
> +		dev_err(button->dev, "irq read failed: %d", val);
> +		return IRQ_HANDLED;
> +	}
> +
> +	pm_wakeup_event(button->dev, 0);
> +	input_report_key(button->idev, KEY_POWER, val);
> +	input_sync(button->idev);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static int cpcap_power_button_probe(struct platform_device *pdev)
> +{
> +	struct cpcap_power_button *button;
> +	int irq = platform_get_irq(pdev, 0);
> +	int err;
> +
> +	button = devm_kmalloc(&pdev->dev, sizeof(*button), GFP_KERNEL);
> +	if (!button)
> +		return -ENOMEM;
> +
> +	button->idev = devm_input_allocate_device(&pdev->dev);
> +	if (!button->idev)
> +		return -ENOMEM;
> +
> +	button->regmap = dev_get_regmap(pdev->dev.parent, NULL);
> +	if (!button->regmap)
> +		return -ENODEV;
> +
> +	button->dev = &pdev->dev;
> +
> +	button->idev->name = "cpcap-pwrbutton";
> +	button->idev->phys = "cpcap-pwrbutton/input0";
> +	button->idev->dev.parent = button->dev;
> +	input_set_capability(button->idev, EV_KEY, KEY_POWER);
> +
> +	err = devm_request_threaded_irq(&pdev->dev, irq, NULL,
> +		powerbutton_irq, IRQF_ONESHOT, "cpcap_pwrbutton", button);
> +	if (err < 0) {
> +		dev_err(&pdev->dev, "IRQ request failed: %d\n", err);
> +		return err;
> +	}
> +
> +	err = input_register_device(button->idev);
> +	if (err) {
> +		dev_err(&pdev->dev, "Input register failed: %d\n", err);
> +		return err;
> +	}
> +
> +	device_init_wakeup(&pdev->dev, true);
> +
> +	return 0;
> +}
> +
> +#ifdef CONFIG_OF
> +static const struct of_device_id cpcap_pwrbutton_dt_match_table[] = {
> +	{ .compatible = "motorola,cpcap-pwrbutton" },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, cpcap_pwrbutton_dt_match_table);
> +#endif
> +
> +static struct platform_driver cpcap_power_button_driver = {
> +	.probe		= cpcap_power_button_probe,
> +	.driver		= {
> +		.name	= "cpcap-pwrbutton",
> +		.of_match_table = of_match_ptr(cpcap_pwrbutton_dt_match_table),
> +	},
> +};
> +module_platform_driver(cpcap_power_button_driver);
> +
> +MODULE_ALIAS("platform:cpcap-pwrbutton");
> +MODULE_DESCRIPTION("CPCAP Power Button");
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Sebastian Reichel <sre@kernel.org>");
> -- 
> 2.11.0
> 

-- 
Dmitry

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

* Re: [PATCHv2 1/2] mfd: cpcap: implement irq sense helper
  2017-03-02  0:22 ` [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Sebastian Reichel
  2017-03-02  0:22   ` [PATCHv2 2/2] input: cpcap-pwrbutton: new driver Sebastian Reichel
@ 2017-03-02 15:17   ` Tony Lindgren
  2017-03-02 16:09   ` Tony Lindgren
  2 siblings, 0 replies; 12+ messages in thread
From: Tony Lindgren @ 2017-03-02 15:17 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Dmitry Torokhov, Lee Jones, Rob Herring, Mark Rutland,
	linux-input, devicetree, linux-kernel

* Sebastian Reichel <sre@kernel.org> [170301 16:24]:
> CPCAP can sense if IRQ is currently set or not. This
> functionality is required for a few subdevices, such
> as the power button and usb phy modules.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
> Changes since PATCHv1:
>  - Newly introduced patch

Works for me:

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCHv2 1/2] mfd: cpcap: implement irq sense helper
  2017-03-02  0:22 ` [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Sebastian Reichel
  2017-03-02  0:22   ` [PATCHv2 2/2] input: cpcap-pwrbutton: new driver Sebastian Reichel
  2017-03-02 15:17   ` [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Tony Lindgren
@ 2017-03-02 16:09   ` Tony Lindgren
  2 siblings, 0 replies; 12+ messages in thread
From: Tony Lindgren @ 2017-03-02 16:09 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Dmitry Torokhov, Lee Jones, Rob Herring, Mark Rutland,
	linux-input, devicetree, linux-kernel

* Sebastian Reichel <sre@kernel.org> [170301 16:24]:
> CPCAP can sense if IRQ is currently set or not. This
> functionality is required for a few subdevices, such
> as the power button and usb phy modules.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
> Changes since PATCHv1:
>  - Newly introduced patch
> ---
>  drivers/mfd/motorola-cpcap.c       | 25 +++++++++++++++++++++++++
>  include/linux/mfd/motorola-cpcap.h |  2 ++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
> index 6aeada7d7ce5..b2a53750d579 100644
> --- a/drivers/mfd/motorola-cpcap.c
> +++ b/drivers/mfd/motorola-cpcap.c
> @@ -32,6 +32,31 @@ struct cpcap_ddata {
>  	struct regmap *regmap;
>  };
>  
> +static int cpcap_sense_irq(struct regmap *regmap, int irq)
> +{
> +	int reg = CPCAP_REG_INTS1 + (irq / 16) * 4;
> +	int mask = 1 << (irq % 16);
> +	int err, val;
> +
> +	if (irq < 0 || irq > 64)
> +		return -EINVAL;
> +
> +	err = regmap_read(regmap, reg, &val);
> +	if (err)
> +		return err;
> +
> +	return !!(val & mask);
> +}
> +
> +int cpcap_sense_virq(struct regmap *regmap, int virq)
> +{
> +	struct regmap_irq_chip_data *d = irq_get_chip_data(virq);
> +	int base = regmap_irq_chip_get_base(d);
> +
> +	return cpcap_sense_irq(regmap, virq - base);
> +}
> +EXPORT_SYMBOL_GPL(cpcap_sense_irq);

You have a typo here, should be cpcap_sense_virq for the exported one :)

Other than that my ack is still valid.

Regards,

Tony

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

* Re: [PATCHv2 2/2] input: cpcap-pwrbutton: new driver
  2017-03-02  1:20     ` Dmitry Torokhov
@ 2017-03-02 18:01       ` Tony Lindgren
  0 siblings, 0 replies; 12+ messages in thread
From: Tony Lindgren @ 2017-03-02 18:01 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Sebastian Reichel, Lee Jones, Rob Herring, Mark Rutland,
	linux-input, devicetree, linux-kernel

* Dmitry Torokhov <dmitry.torokhov@gmail.com> [170301 17:21]:
> On Thu, Mar 02, 2017 at 01:22:42AM +0100, Sebastian Reichel wrote:
> > Motorola CPCAP is a PMIC found in multiple smartphones.
> > This driver adds support for the power/on button and has
> > been tested in Droid 4.
> > 
> > Acked-by: Rob Herring <robh@kernel.org>
> > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > ---
> > Changes since PATCHv1:
> >  - Fix device for devm_request_threaded_irq()
> >  - Add Acked-By from Rob Herring (for the DT binding)
> >  - Use newly introduced cpcap_sense_virq to sense the IRQ pin
> 
> OK, so will this be merged through MFD? If so:
> 
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Ideally we'd have an immutable branch against v4.11-rc1 when out
with just these two patches somewhere that can get merged in as
needed to MFD or input tree.

Anyways, this driver still works for me:

Tested-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCHv2 2/2] input: cpcap-pwrbutton: new driver
  2017-03-02  0:22   ` [PATCHv2 2/2] input: cpcap-pwrbutton: new driver Sebastian Reichel
  2017-03-02  1:20     ` Dmitry Torokhov
@ 2017-03-04 16:22     ` kbuild test robot
  1 sibling, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2017-03-04 16:22 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: kbuild-all, Sebastian Reichel, Tony Lindgren, Dmitry Torokhov,
	Lee Jones, Rob Herring, Mark Rutland, linux-input, devicetree,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 911 bytes --]

Hi Sebastian,

[auto build test ERROR on ljones-mfd/for-mfd-next]
[also build test ERROR on next-20170303]
[cannot apply to input/next v4.10]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Sebastian-Reichel/mfd-cpcap-implement-irq-sense-helper/20170304-192034
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

>> ERROR: "cpcap_sense_virq" [drivers/input/misc/cpcap-pwrbutton.ko] undefined!

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 58056 bytes --]

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

end of thread, other threads:[~2017-03-04 16:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-24  8:59 [PATCH] input: cpcap-pwrbutton: new driver Sebastian Reichel
2017-02-25 18:58 ` Dmitry Torokhov
2017-02-25 19:21   ` Tony Lindgren
2017-02-28  2:32     ` Tony Lindgren
2017-02-28  0:18 ` Rob Herring
2017-03-02  0:22 ` [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Sebastian Reichel
2017-03-02  0:22   ` [PATCHv2 2/2] input: cpcap-pwrbutton: new driver Sebastian Reichel
2017-03-02  1:20     ` Dmitry Torokhov
2017-03-02 18:01       ` Tony Lindgren
2017-03-04 16:22     ` kbuild test robot
2017-03-02 15:17   ` [PATCHv2 1/2] mfd: cpcap: implement irq sense helper Tony Lindgren
2017-03-02 16:09   ` Tony Lindgren

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).