Skip to contentSkip to conversation

Hi655x powerkey support for HiKey

RFC PATCH In review John Stultz 4 participants 16 messages Jun 1, 2016 – Jun 9, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Hi655x powerkey support for HiKey

This patchset enables the pmic powerkey to function on HiKey.

I wanted to submit it for some initial review. Feedback would be greatly appreciated!

thanks
-john

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

Guodong Xu (1):
arm64: dts: Add powerkey info to pmic for hi6220-hikey

John Stultz (3):
dts: bindings: Add binding documentation for hisilicon,hi6552-powerkey
hi655x-pmic: Make hi655x pmic logic probe child nodes in the dt
hi655x-pmic: Fixup issue with un-acked interrupts

Jorge Ramirez-Ortiz (1):
drivers: input: powerkey for HISI 65xx SoC

 .../bindings/input/hisilicon,hi6552-powerkey.txt   |  40 ++++
 arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts     |   7 +
 drivers/input/misc/Kconfig                         |   8 +
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/hisi_powerkey.c                 | 228 +++++++++++++++++++++
 drivers/mfd/hi655x-pmic.c                          |   9 +
 6 files changed, 293 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/hisilicon,hi6552-powerkey.txt
 create mode 100644 drivers/input/misc/hisi_powerkey.c
Signature · 1 line
1.9.1
#1 lore raw

RFC PATCH 1/5 dts: bindings: Add binding documentation for hisilicon,hi6552-powerkey

Adds binding documentation for hi6552 pmic powerkey button.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>
---
 .../bindings/input/hisilicon,hi6552-powerkey.txt   | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/hisilicon,hi6552-powerkey.txt
Documentation/devicetree/bindings/input/hisilicon,hi6552-powerkey.txt new file +40 -0
new file mode 100644
index 0000000..7f09124
@@ -0,0 +1,40 @@
+HiSilicon hi6552 PMIC Power Key
+
+PROPERTIES
+
+- compatible:
+	Usage: required
+	Value type: <string>
+	Definition: must be one of:
+		    "hisilicon,hi6552-powerkey"
+
+- interrupt-parent
+	Usage: (required if interrupt property is defined)
+	Value type: <phandle>
+	Definition: A single <phandle> value that points to the interrupt
+		    parent to which the child domain is being mapped.
+
+- interrupts:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: The first interrupt specifies the key release interrupt
+		    and the second interrupt specifies the key press interrupt,
+		    the third defines the timed key-hold interrupt.
+		    The format of the specifier is defined by the binding
+		    document describing the node's interrupt parent.
+
+- interrupt-names:
+	Usage: required
+	Value type: "down", "up", "hold 4s"
+	Definition: String names for the press, release and timed hold
+		    interrupts.
+
+
+EXAMPLE
+
+	powerkey:powerkey@b1{
+		compatible = "hisilicon,hi6552-powerkey";
+		interrupt-parent = <&pmic>;
+		interrupts = <6 0>, <5 0>, <4 0>;
+		interrupt-names = "down", "up", "hold 4s";
+	};
Signature · 1 line
1.9.1
#2 lore raw

RFC PATCH 2/5 hi655x-pmic: Make hi655x pmic logic probe child nodes in the dt

In reply to John Stultz

In trying to wire up the powerkey driver, I found I needed to add this to get the pmic logic to probe child nodes in the dt data.

With this patch, child nodes get properly probed.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>
---
 drivers/mfd/hi655x-pmic.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mfd/hi655x-pmic.c +8 -0
index 05ddc78..3511035 100644
@@ -39,6 +39,11 @@ static const struct regmap_irq hi655x_irqs[] = {
 	{ .reg_offset = 0, .mask = RESERVE_INT },
 };
 
+static const struct of_device_id of_hi655x_pmic_child_match_tbl[] = {
+	{ .compatible = "hisilicon,hi6552-powerkey", },
+	{ /* end */ }
+};
+
 static const struct regmap_irq_chip hi655x_irq_chip = {
 	.name = "hi655x-pmic",
 	.irqs = hi655x_irqs,
@@ -122,6 +127,9 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pmic);
 
+	/* populate sub nodes */
+	of_platform_populate(np, of_hi655x_pmic_child_match_tbl, NULL, dev);
+
 	ret = mfd_add_devices(dev, PLATFORM_DEVID_AUTO, hi655x_pmic_devs,
 			      ARRAY_SIZE(hi655x_pmic_devs), NULL, 0, NULL);
 	if (ret) {
Signature · 1 line
1.9.1
#14 lore raw

RFC PATCH 5/5 arm64: dts: Add powerkey info to pmic for hi6220-hikey

In reply to John Stultz

From: Guodong Xu <[email protected]>

Add powerkey entry to the HiKey dts.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>
---
 arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts +7 -0
index e92a30c..c8e49a6 100644
@@ -144,6 +144,13 @@
 		#interrupt-cells = <2>;
 		pmic-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
 
+		powerkey:powerkey@b1{
+			compatible = "hisilicon,hi6552-powerkey";
+			interrupt-parent = <&pmic>;
+			interrupts = <6 0>, <5 0>, <4 0>;
+			interrupt-names = "down", "up", "hold 4s";
+		};
+
 		regulators {
 			ldo2: LDO2 {
 				regulator-name = "LDO2_2V8";
Signature · 1 line
1.9.1
#8 lore raw

RFC PATCH 4/5 drivers: input: powerkey for HISI 65xx SoC

In reply to John Stultz

From: Jorge Ramirez-Ortiz <[email protected]>

This driver provides a input driver for the power button on the HiSi 65xx SoC for boards like HiKey.

This driver was originally by Zhiliang Xue <[email protected]> then basically rewritten by Jorge, but preserving the original module author credits.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, and made a few small fixes and cleanups of my own]

---
 drivers/input/misc/Kconfig         |   8 ++
 drivers/input/misc/Makefile        |   1 +
 drivers/input/misc/hisi_powerkey.c | 228 +++++++++++++++++++++++++++++++++++++
 3 files changed, 237 insertions(+)
 create mode 100644 drivers/input/misc/hisi_powerkey.c
drivers/input/misc/Kconfig +8 -0
index 1f2337a..2e57bbd 100644
@@ -796,4 +796,12 @@ config INPUT_DRV2667_HAPTICS
 	  To compile this driver as a module, choose M here: the
 	  module will be called drv2667-haptics.
 
+config HISI_POWERKEY
+	tristate "Hisilicon PMIC ONKEY support"
+	help
+	  Say Y to enable support for PMIC ONKEY.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called hisi_powerkey.
+
 endif
drivers/input/misc/Makefile +1 -0
index 0357a08..f264777 100644
@@ -75,3 +75,4 @@ obj-$(CONFIG_INPUT_WM831X_ON)		+= wm831x-on.o
 obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND)	+= xen-kbdfront.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
 obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR)	+= ideapad_slidebar.o
+obj-$(CONFIG_HISI_POWERKEY)		+= hisi_powerkey.o
drivers/input/misc/hisi_powerkey.c new file +228 -0

228 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

RFC PATCH 3/5 hi655x-pmic: Fixup issue with un-acked interrupts

In reply to John Stultz

While trying to get the powerkey to function, I found when pressing the key, I would get infinitely repeating interrupts.

After digging around a bit, it seems we didn't set the ack_base value for the regmap irqchip logic, so nothing was acking the interrupt.

This patch adds the ack_base, which seems to make things work.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>
---
 drivers/mfd/hi655x-pmic.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mfd/hi655x-pmic.c +1 -0
index 3511035..4a3fdbc 100644
@@ -50,6 +50,7 @@ static const struct regmap_irq_chip hi655x_irq_chip = {
 	.num_regs = 1,
 	.num_irqs = ARRAY_SIZE(hi655x_irqs),
 	.status_base = HI655X_IRQ_STAT_BASE,
+	.ack_base = HI655X_IRQ_STAT_BASE,
 	.mask_base = HI655X_IRQ_MASK_BASE,
 };
 
Signature · 1 line
1.9.1
#15 lore raw

Re: [RFC][PATCH 5/5] arm64: dts: Add powerkey info to pmic for hi6220-hikey

In reply to John Stultz
Quoted 25 lines · John Stultz

From: Guodong Xu <[email protected]>

Add powerkey entry to the HiKey dts.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>
---
 arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts +0 -0
index e92a30c..c8e49a6 100644

arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts line 147

Quoted 4 lines
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts +1 -0
@@ -144,6 +144,13 @@
                #interrupt-cells = <2>;
                pmic-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
 
+               powerkey:powerkey@b1{

nit: you probably don't need the label and unit-address is not needed, so just:

powerkey {

Quoted 12 lines
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts +6 -1
+                       compatible = "hisilicon,hi6552-powerkey";
+                       interrupt-parent = <&pmic>;
+                       interrupts = <6 0>, <5 0>, <4 0>;
+                       interrupt-names = "down", "up", "hold 4s";
+               };
+
                regulators {
                        ldo2: LDO2 {
                                regulator-name = "LDO2_2V8";
--

1.9.1

maintainer
#9 lore raw

Re: [RFC][PATCH 4/5] drivers: input: powerkey for HISI 65xx SoC

In reply to John Stultz

Hi John,

Quoted 35 lines · John Stultz

From: Jorge Ramirez-Ortiz <[email protected]>

This driver provides a input driver for the power button on the HiSi 65xx SoC for boards like HiKey.

This driver was originally by Zhiliang Xue <[email protected]> then basically rewritten by Jorge, but preserving the original module author credits.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, and made a few small fixes and cleanups of my own]

---
 drivers/input/misc/Kconfig         |   8 ++
 drivers/input/misc/Makefile        |   1 +
 drivers/input/misc/hisi_powerkey.c | 228 +++++++++++++++++++++++++++++++++++++
 3 files changed, 237 insertions(+)
 create mode 100644 drivers/input/misc/hisi_powerkey.c
drivers/input/misc/Kconfig +0 -0
index 1f2337a..2e57bbd 100644

drivers/input/misc/Kconfig config INPUT_DRV2667_HAPTICS · line 800

Quoted 5 lines
drivers/input/misc/Kconfig +2 -0
@@ -796,4 +796,12 @@ config INPUT_DRV2667_HAPTICS
 	  To compile this driver as a module, choose M here: the
 	  module will be called drv2667-haptics.
 
+config HISI_POWERKEY
+	tristate "Hisilicon PMIC ONKEY support"

Any depends on? Something MACH_XX || COMPILE_TEST?

Quoted 22 lines
drivers/input/misc/Kconfig +6 -0
+	help
+	  Say Y to enable support for PMIC ONKEY.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called hisi_powerkey.
+
 endif
drivers/input/misc/Makefile +1 -0
index 0357a08..f264777 100644
@@ -75,3 +75,4 @@ obj-$(CONFIG_INPUT_WM831X_ON)		+= wm831x-on.o
 obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND)	+= xen-kbdfront.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
 obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR)	+= ideapad_slidebar.o
+obj-$(CONFIG_HISI_POWERKEY)		+= hisi_powerkey.o
drivers/input/misc/hisi_powerkey.c new file +0 -0
new file mode 100644
index 0000000..3a35a75

drivers/input/misc/hisi_powerkey.c line 2

Quoted 2 lines
drivers/input/misc/hisi_powerkey.c new file +2 -0
@@ -0,0 +1,228 @@
+/*
+ * hisi_powerkey.c - Hisilicon MIC powerkey driver

Please drop filename - it may change in tree but I bet nobody will remember to update it here.

Quoted 26 lines
drivers/input/misc/hisi_powerkey.c new file +26 -0
+ *
+ * Copyright (C) 2013 Hisilicon Ltd.
+ * Copyright (C) 2015, 2016 Linaro Ltd.
+ *
+ * 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/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/reboot.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_irq.h>
+#include <linux/input.h>
+#include <linux/slab.h>
+
+/* the above held interrupt will trigger after 4 seconds */
+#define MAX_HELD_TIME	(4 * MSEC_PER_SEC)
+

drivers/input/misc/hisi_powerkey.c line 38

Quoted 10 lines
drivers/input/misc/hisi_powerkey.c new file +10 -0
+
+typedef irqreturn_t (*hi65xx_irq_handler) (int irq, void *data);
+enum { id_pressed, id_released, id_held, id_last };
+static irqreturn_t hi65xx_pkey_irq_handler(int irq, void *q);
+
+/*
+ * power key irq information
+ */
+static struct hi65xx_pkey_irq_info {
+	hi65xx_irq_handler handler;

They all seem to be using the same handler, drop?

Quoted 34 lines
drivers/input/misc/hisi_powerkey.c new file +34 -0
+	const char *const name;
+	int irq;
+} irq_info[id_last] = {
+	[id_pressed] = {
+		.handler = hi65xx_pkey_irq_handler,
+		.name = "down",
+		.irq = -1,
+	},
+	[id_released] = {
+		.handler = hi65xx_pkey_irq_handler,
+		.name = "up",
+		.irq = -1,
+	},
+	[id_held] = {
+		.handler = hi65xx_pkey_irq_handler,
+		.name = "hold 4s",
+		.irq = -1,
+	},
+};
+
+/*
+ * power key events
+ */
+static struct key_report_pairs {
+	int code;
+	int value;
+} pkey_report[id_last] = {
+	[id_released] = {
+		.code = KEY_POWER,
+		.value = 0
+	},
+	[id_pressed] = {
+		.code = KEY_POWER,
+		.value = 1

drivers/input/misc/hisi_powerkey.c line 82

Quoted 10 lines
drivers/input/misc/hisi_powerkey.c new file +10 -0
+	},
+	[id_held] = {
+		.code = KEY_RESTART,
+		.value = 0
+	},
+};
+
+struct hi65xx_priv {
+	struct input_dev *input;
+	struct wakeup_source wlock;

Why do you need custom wakeup source?

drivers/input/misc/hisi_powerkey.c line 85

Quoted 3 lines
drivers/input/misc/hisi_powerkey.c new file +3 -0
+};
+
+static inline void report_key(struct input_dev *dev, int id_action)

No "inline" in C files - let compiler decide.

Pass id_action as enum instead of int.

drivers/input/misc/hisi_powerkey.c line 88

Quoted 3 lines
drivers/input/misc/hisi_powerkey.c new file +3 -0
+{
+	/*
+	 * track the state of the key held event since only ON/OFF values are

Start sentence with a capital letter.

drivers/input/misc/hisi_powerkey.c line 90

Quoted 2 lines
drivers/input/misc/hisi_powerkey.c new file +2 -0
+	 * allowed on EV_KEY types: KEY_RESTART will always toggle its value to
+	 * guarantee that the event is passed to handlers (dispossition update).

s/dissposition/disposition.

drivers/input/misc/hisi_powerkey.c line 93

Quoted 3 lines
drivers/input/misc/hisi_powerkey.c new file +3 -0
+	 */
+	if (id_action == id_held)
+		pkey_report[id_held].value ^= 1;

You can fetch the state from input device, no need to modify module-global. In fact, I do not quite like that we modify both pkey_report and irq_info. I'd like to have them const static and move mutable data into hi65xx_priv.

drivers/input/misc/hisi_powerkey.c line 106

Quoted 13 lines
drivers/input/misc/hisi_powerkey.c new file +13 -0
+
+	dev_dbg(dev->dev.parent, "received - code %d, value %d\n",
+		pkey_report[id_action].code,
+		pkey_report[id_action].value);
+
+	input_report_key(dev, pkey_report[id_action].code,
+		pkey_report[id_action].value);
+}
+
+static irqreturn_t hi65xx_pkey_irq_handler(int irq, void *q)
+{
+	struct hi65xx_priv *p = q;
+	int i, action = -1;

Make action an enum, initialize to "last".

drivers/input/misc/hisi_powerkey.c line 112

Quoted 6 lines
drivers/input/misc/hisi_powerkey.c new file +6 -0
+
+	for (i = 0; i < id_last; i++)
+		if (irq == irq_info[i].irq)
+			action = i;
+
+	if (action == -1)

Compare against "last" here.

drivers/input/misc/hisi_powerkey.c line 115

Quoted 3 lines
drivers/input/misc/hisi_powerkey.c new file +3 -0
+		return IRQ_NONE;
+
+	__pm_wakeup_event(&p->wlock, MAX_HELD_TIME);

Why not pm_wakeup_event?

Quoted 7 lines
drivers/input/misc/hisi_powerkey.c new file +7 -0
+
+	report_key(p->input, action);
+	input_sync(p->input);
+
+	return IRQ_HANDLED;
+}
+

drivers/input/misc/hisi_powerkey.c line 132

Quoted 10 lines
drivers/input/misc/hisi_powerkey.c new file +10 -0
+static int hi65xx_powerkey_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct hi65xx_priv *priv;
+	int irq, i, ret;
+
+	if (pdev == NULL) {
+		dev_err(dev, "parameter error\n");
+		return -EINVAL;
+	}

Can't happen.

drivers/input/misc/hisi_powerkey.c line 138

Quoted 6 lines
drivers/input/misc/hisi_powerkey.c new file +6 -0
+
+	priv = devm_kzalloc(dev, sizeof(struct hi65xx_priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->input = input_allocate_device();

devm_input_allocate_devivce(&pdev->dev);

drivers/input/misc/hisi_powerkey.c line 141

Quoted 3 lines
drivers/input/misc/hisi_powerkey.c new file +3 -0
+	if (!priv->input) {
+		dev_err(&pdev->dev, "failed to allocate input device\n");
+		return -ENOENT;

-ENOMEM

drivers/input/misc/hisi_powerkey.c line 144

Quoted 3 lines
drivers/input/misc/hisi_powerkey.c new file +3 -0
+	}
+
+	priv->input->evbit[0] = BIT_MASK(EV_KEY);

Not needed - input_set_capability() will do this for us.

drivers/input/misc/hisi_powerkey.c line 145

Quoted 1 line
drivers/input/misc/hisi_powerkey.c new file +1 -0
+	priv->input->dev.parent = &pdev->dev;

Drop if switching to devm.

Quoted 8 lines
drivers/input/misc/hisi_powerkey.c new file +8 -0
+	priv->input->phys = "hisi_on/input0";
+	priv->input->name = "HISI 65xx PowerOn Key";
+
+	for (i = 0; i < ARRAY_SIZE(pkey_report); i++)
+		input_set_capability(priv->input, EV_KEY, pkey_report[i].code);
+
+	for (i = 0; i < ARRAY_SIZE(irq_info); i++) {
+

drivers/input/misc/hisi_powerkey.c line 163

Quoted 10 lines
drivers/input/misc/hisi_powerkey.c new file +10 -0
+		irq = platform_get_irq_byname(pdev, irq_info[i].name);
+		if (irq < 0) {
+			dev_err(dev, "couldn't get irq %s\n", irq_info[i].name);
+			ret = irq;
+			goto err_irq;
+		}
+
+		ret = devm_request_threaded_irq(dev, irq, NULL,
+					irq_info[i].handler, IRQF_ONESHOT,
+					irq_info[i].name, priv);

Why threaded irq? Seems wasteful to have 3 threads for this.

drivers/input/misc/hisi_powerkey.c line 172

Quoted 9 lines
drivers/input/misc/hisi_powerkey.c new file +9 -0
+		if (ret < 0) {
+			dev_err(dev, "couldn't get irq %s\n", irq_info[i].name);
+			goto err_irq;
+		}
+
+		irq_info[i].irq = irq;
+	}
+
+	wakeup_source_init(&priv->wlock, "hisi-powerkey");

Why not the standard device_init_wakeup()?

drivers/input/misc/hisi_powerkey.c line 178

Quoted 6 lines
drivers/input/misc/hisi_powerkey.c new file +6 -0
+
+	ret = input_register_device(priv->input);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to register input device: %d\n",
+			ret);
+		ret = -ENOENT;

Why do you discard perfectly good error code from
input_register_device()?

drivers/input/misc/hisi_powerkey.c line 189

Quoted 11 lines
drivers/input/misc/hisi_powerkey.c new file +11 -0
+		goto err_register;
+	}
+
+	platform_set_drvdata(pdev, priv);
+
+	return 0;
+
+err_register:
+	wakeup_source_trash(&priv->wlock);
+err_irq:
+	input_free_device(priv->input);

Drop if switching to devm.

drivers/input/misc/hisi_powerkey.c line 199

Quoted 10 lines
drivers/input/misc/hisi_powerkey.c new file +10 -0
+
+	return ret;
+}
+
+static int hi65xx_powerkey_remove(struct platform_device *pdev)
+{
+	struct hi65xx_priv *priv = platform_get_drvdata(pdev);
+
+	wakeup_source_trash(&priv->wlock);
+	input_unregister_device(priv->input);

Drop if moving to devm.

Quoted 4 lines
drivers/input/misc/hisi_powerkey.c new file +4 -0
+
+	return 0;
+}
+

drivers/input/misc/hisi_powerkey.c line 213

Quoted 10 lines
drivers/input/misc/hisi_powerkey.c new file +10 -0
+static const struct of_device_id hi65xx_powerkey_of_match[] = {
+	{ .compatible = "hisilicon,hi6552-powerkey", },
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, hi65xx_powerkey_of_match);
+
+static struct platform_driver hi65xx_powerkey_driver = {
+	.driver = {
+		.owner = THIS_MODULE,

No need to set owner.

drivers/input/misc/hisi_powerkey.c line 215

Quoted 2 lines
drivers/input/misc/hisi_powerkey.c new file +2 -0
+		.name = "hi65xx-powerkey",
+		.of_match_table = hi65xx_powerkey_of_match,

of_match_ptr()?

drivers/input/misc/hisi_powerkey.c line 226

Quoted 11 lines
drivers/input/misc/hisi_powerkey.c new file +11 -0
+	},
+	.probe = hi65xx_powerkey_probe,
+	.remove  = hi65xx_powerkey_remove,
+};
+
+module_platform_driver(hi65xx_powerkey_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Zhiliang Xue <[email protected]");
+MODULE_DESCRIPTION("Hisi PMIC Power key driver");
+MODULE_LICENSE("GPL v2");

2 module licences? I guess GPL v2 is the right one, drop the first one please.

drivers/input/misc/hisi_powerkey.c line 228

Quoted 2 lines
drivers/input/misc/hisi_powerkey.c new file +2 -0
+
+

Drop 2 ending empty lines.

Quoted 3 lines
Signature · 1 line
1.9.1

Thanks.

Signature · 1 line
Dmitry
#10 lore raw

Re: [RFC][PATCH 4/5] drivers: input: powerkey for HISI 65xx SoC

Quoted 41 lines · Dmitry Torokhov

Hi John,

Quoted 38 lines · John Stultz

From: Jorge Ramirez-Ortiz <[email protected]>

This driver provides a input driver for the power button on the HiSi 65xx SoC for boards like HiKey.

This driver was originally by Zhiliang Xue <[email protected]> then basically rewritten by Jorge, but preserving the original module author credits.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, and made a few small fixes and cleanups of my own]

---
 drivers/input/misc/Kconfig         |   8 ++
 drivers/input/misc/Makefile        |   1 +
 drivers/input/misc/hisi_powerkey.c | 228 +++++++++++++++++++++++++++++++++++++
 3 files changed, 237 insertions(+)
 create mode 100644 drivers/input/misc/hisi_powerkey.c
drivers/input/misc/Kconfig +0 -0
index 1f2337a..2e57bbd 100644
@@ -796,4 +796,12 @@ config INPUT_DRV2667_HAPTICS
        To compile this driver as a module, choose M here: the
        module will be called drv2667-haptics.
 
Quoted 4 lines

drivers/input/misc/Kconfig config INPUT_DRV2667_HAPTICS · line 800

Quoted 2 lines
drivers/input/misc/Kconfig +2 -0
+config HISI_POWERKEY
+     tristate "Hisilicon PMIC ONKEY support"

Any depends on? Something MACH_XX || COMPILE_TEST?

Hey Dmitry!

Thanks so much for the review! I've got almost all your suggestions integrated (and it greatly simplifies things) and will resend tomorrow.

One comment on your question below...

Quoted 5 lines

drivers/input/misc/Kconfig config INPUT_DRV2667_HAPTICS · line 803

Quoted 3 lines
drivers/input/misc/Kconfig +3 -0
+             ret = devm_request_threaded_irq(dev, irq, NULL,
+                                     irq_info[i].handler, IRQF_ONESHOT,
+                                     irq_info[i].name, priv);

Why threaded irq? Seems wasteful to have 3 threads for this.

As this is a nested interrupt, devm_request_irq was failing unless it was threaded.
Any ideas for something better?

thanks
-john

maintainer
#11 lore raw

Re: [RFC][PATCH 4/5] drivers: input: powerkey for HISI 65xx SoC

Quoted 48 lines · John Stultz
Quoted 41 lines · Dmitry Torokhov

Hi John,

Quoted 38 lines · John Stultz

From: Jorge Ramirez-Ortiz <[email protected]>

This driver provides a input driver for the power button on the HiSi 65xx SoC for boards like HiKey.

This driver was originally by Zhiliang Xue <[email protected]> then basically rewritten by Jorge, but preserving the original module author credits.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, and made a few small fixes and cleanups of my own]

---
 drivers/input/misc/Kconfig         |   8 ++
 drivers/input/misc/Makefile        |   1 +
 drivers/input/misc/hisi_powerkey.c | 228 +++++++++++++++++++++++++++++++++++++
 3 files changed, 237 insertions(+)
 create mode 100644 drivers/input/misc/hisi_powerkey.c
drivers/input/misc/Kconfig +0 -0
index 1f2337a..2e57bbd 100644
@@ -796,4 +796,12 @@ config INPUT_DRV2667_HAPTICS
        To compile this driver as a module, choose M here: the
        module will be called drv2667-haptics.
 
Quoted 4 lines

drivers/input/misc/Kconfig config INPUT_DRV2667_HAPTICS · line 800

Quoted 2 lines
drivers/input/misc/Kconfig +2 -0
+config HISI_POWERKEY
+     tristate "Hisilicon PMIC ONKEY support"

Any depends on? Something MACH_XX || COMPILE_TEST?

Quoted 5 lines

Hey Dmitry!

Thanks so much for the review! I've got almost all your suggestions integrated (and it greatly simplifies things) and will resend tomorrow.

Actually, I was thinking about it some more and I wonder if it would not be even simpler if we had 3 separate interrupt handlers, one for key press, one fore key release, and another for toggling. Then you woudl not need to iterate through IRQ numbers to figure out the action and interrupt handlers would be really tiny:

static irqreturn_t hi65xx_power_press_isr(int irq, void *q)

{
	struct hi65xx_priv *p = q;

	pm_wakeup_event(&p->dev, MAX_HELD_TIME);
	input_report_key(p->input, KEY_POWER, 1);
	input_sync(p->input);
}

static irqreturn_t hi65xx_power_release_isr(int irq, void *q)

{
	struct hi65xx_priv *p = q;

	pm_wakeup_event(&p->dev, MAX_HELD_TIME); // Needed ?
	input_report_key(p->input, KEY_POWER, 0);
	input_sync(p->input);
}

static irqreturn_t hi65xx_restart_toggle_isr(int irq, void *q)

{
	struct hi65xx_priv *p = q;
	int value = test_bit(KEY_RESTART, p->input->keys);

	pm_wakeup_event(&p->dev, MAX_HELD_TIME);
	input_report_key(p->input, KEY_RESTART, !value);
	input_sync(p->input);
}
static struct hi65xx_isr_info {
	const char *name;
	irqreturn_t (*handler)(int irq, void *q);
} hi65xx_isr_info[] = {
	{ .name = "down", .handler = hi65xx_power_press_isr },
	{ .name = "up", .handler = hi65xx_power_release_isr },
	{ .name = "hold 4s", .handler = hi65xx_restart_toggle_isr },
};
Quoted 7 lines

One comment on your question below...

Quoted 4 lines
Quoted 3 lines
drivers/input/misc/Kconfig +3 -0
+             ret = devm_request_threaded_irq(dev, irq, NULL,
+                                     irq_info[i].handler, IRQF_ONESHOT,
+                                     irq_info[i].name, priv);
Quoted 5 lines
Quoted 1 line

Why threaded irq? Seems wasteful to have 3 threads for this.

As this is a nested interrupt, devm_request_irq was failing unless it was threaded.
Any ideas for something better?

Ahh, that is unfortunate, but I guess we'll have to live with it. Please use devm_request_any_context_irq() then to show that the driver itself does not need threaded interrupt but platform may provide it.

Thanks.

Signature · 1 line
Dmitry
#12 lore raw

Re: [RFC][PATCH 4/5] drivers: input: powerkey for HISI 65xx SoC

Quoted 89 lines · Dmitry Torokhov
Quoted 48 lines · John Stultz
Quoted 41 lines · Dmitry Torokhov

Hi John,

Quoted 38 lines · John Stultz

From: Jorge Ramirez-Ortiz <[email protected]>

This driver provides a input driver for the power button on the HiSi 65xx SoC for boards like HiKey.

This driver was originally by Zhiliang Xue <[email protected]> then basically rewritten by Jorge, but preserving the original module author credits.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, and made a few small fixes and cleanups of my own]

---
 drivers/input/misc/Kconfig         |   8 ++
 drivers/input/misc/Makefile        |   1 +
 drivers/input/misc/hisi_powerkey.c | 228 +++++++++++++++++++++++++++++++++++++
 3 files changed, 237 insertions(+)
 create mode 100644 drivers/input/misc/hisi_powerkey.c
drivers/input/misc/Kconfig +0 -0
index 1f2337a..2e57bbd 100644
@@ -796,4 +796,12 @@ config INPUT_DRV2667_HAPTICS
        To compile this driver as a module, choose M here: the
        module will be called drv2667-haptics.
 
Quoted 4 lines

drivers/input/misc/Kconfig config INPUT_DRV2667_HAPTICS · line 800

Quoted 2 lines
drivers/input/misc/Kconfig +2 -0
+config HISI_POWERKEY
+     tristate "Hisilicon PMIC ONKEY support"

Any depends on? Something MACH_XX || COMPILE_TEST?

Quoted 5 lines

Hey Dmitry!

Thanks so much for the review! I've got almost all your suggestions integrated (and it greatly simplifies things) and will resend tomorrow.

Actually, I was thinking about it some more and I wonder if it would not be even simpler if we had 3 separate interrupt handlers, one for key press, one fore key release, and another for toggling. Then you woudl not need to iterate through IRQ numbers to figure out the action and interrupt handlers would be really tiny:

static irqreturn_t hi65xx_power_press_isr(int irq, void *q)

{
        struct hi65xx_priv *p = q;

        pm_wakeup_event(&p->dev, MAX_HELD_TIME);
        input_report_key(p->input, KEY_POWER, 1);
        input_sync(p->input);
}

static irqreturn_t hi65xx_power_release_isr(int irq, void *q)

{
        struct hi65xx_priv *p = q;

        pm_wakeup_event(&p->dev, MAX_HELD_TIME); // Needed ?
        input_report_key(p->input, KEY_POWER, 0);
        input_sync(p->input);
}

static irqreturn_t hi65xx_restart_toggle_isr(int irq, void *q)

{
        struct hi65xx_priv *p = q;
        int value = test_bit(KEY_RESTART, p->input->keys);

        pm_wakeup_event(&p->dev, MAX_HELD_TIME);
        input_report_key(p->input, KEY_RESTART, !value);
        input_sync(p->input);
}
Quoted 8 lines
static struct hi65xx_isr_info {
        const char *name;
        irqreturn_t (*handler)(int irq, void *q);
} hi65xx_isr_info[] = {
        { .name = "down", .handler = hi65xx_power_press_isr },
        { .name = "up", .handler = hi65xx_power_release_isr },
        { .name = "hold 4s", .handler = hi65xx_restart_toggle_isr },
};

Hrm.. Ok. I can rework it this way. If you were curious, here's what the code currently looks like:
https://git.linaro.org/people/john.stultz/android-dev.git/commitdiff/2b0de7d8ba22d188e961a4ffef6d95030ef31c15

But I'll rework it and submit it tomorrow.

Quoted 8 lines
Quoted 8 lines

One comment on your question below...

Quoted 5 lines

drivers/input/misc/Kconfig config INPUT_DRV2667_HAPTICS · line 803

Quoted 3 lines
drivers/input/misc/Kconfig +3 -0
+             ret = devm_request_threaded_irq(dev, irq, NULL,
+                                     irq_info[i].handler, IRQF_ONESHOT,
+                                     irq_info[i].name, priv);

Why threaded irq? Seems wasteful to have 3 threads for this.

Quoted 7 lines
Quoted 3 lines

As this is a nested interrupt, devm_request_irq was failing unless it was threaded.
Any ideas for something better?

Ahh, that is unfortunate, but I guess we'll have to live with it. Please use devm_request_any_context_irq() then to show that the driver itself does not need threaded interrupt but platform may provide it.

Sounds good. Will do.

thanks
-john

maintainer
#13 lore raw

Re: [RFC][PATCH 4/5] drivers: input: powerkey for HISI 65xx SoC

Quoted 100 lines · John Stultz
Quoted 89 lines · Dmitry Torokhov
Quoted 48 lines · John Stultz
Quoted 41 lines · Dmitry Torokhov

Hi John,

Quoted 38 lines · John Stultz

From: Jorge Ramirez-Ortiz <[email protected]>

This driver provides a input driver for the power button on the HiSi 65xx SoC for boards like HiKey.

This driver was originally by Zhiliang Xue <[email protected]> then basically rewritten by Jorge, but preserving the original module author credits.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, and made a few small fixes and cleanups of my own]

---
 drivers/input/misc/Kconfig         |   8 ++
 drivers/input/misc/Makefile        |   1 +
 drivers/input/misc/hisi_powerkey.c | 228 +++++++++++++++++++++++++++++++++++++
 3 files changed, 237 insertions(+)
 create mode 100644 drivers/input/misc/hisi_powerkey.c
drivers/input/misc/Kconfig +0 -0
index 1f2337a..2e57bbd 100644
@@ -796,4 +796,12 @@ config INPUT_DRV2667_HAPTICS
        To compile this driver as a module, choose M here: the
        module will be called drv2667-haptics.
 
Quoted 4 lines

drivers/input/misc/Kconfig config INPUT_DRV2667_HAPTICS · line 800

Quoted 2 lines
drivers/input/misc/Kconfig +2 -0
+config HISI_POWERKEY
+     tristate "Hisilicon PMIC ONKEY support"

Any depends on? Something MACH_XX || COMPILE_TEST?

Quoted 5 lines

Hey Dmitry!

Thanks so much for the review! I've got almost all your suggestions integrated (and it greatly simplifies things) and will resend tomorrow.

Actually, I was thinking about it some more and I wonder if it would not be even simpler if we had 3 separate interrupt handlers, one for key press, one fore key release, and another for toggling. Then you woudl not need to iterate through IRQ numbers to figure out the action and interrupt handlers would be really tiny:

static irqreturn_t hi65xx_power_press_isr(int irq, void *q)

{
        struct hi65xx_priv *p = q;

        pm_wakeup_event(&p->dev, MAX_HELD_TIME);
        input_report_key(p->input, KEY_POWER, 1);
        input_sync(p->input);
}

static irqreturn_t hi65xx_power_release_isr(int irq, void *q)

{
        struct hi65xx_priv *p = q;

        pm_wakeup_event(&p->dev, MAX_HELD_TIME); // Needed ?
        input_report_key(p->input, KEY_POWER, 0);
        input_sync(p->input);
}

static irqreturn_t hi65xx_restart_toggle_isr(int irq, void *q)

{
        struct hi65xx_priv *p = q;
        int value = test_bit(KEY_RESTART, p->input->keys);

        pm_wakeup_event(&p->dev, MAX_HELD_TIME);
        input_report_key(p->input, KEY_RESTART, !value);
        input_sync(p->input);
}
Quoted 8 lines
static struct hi65xx_isr_info {
        const char *name;
        irqreturn_t (*handler)(int irq, void *q);
} hi65xx_isr_info[] = {
        { .name = "down", .handler = hi65xx_power_press_isr },
        { .name = "up", .handler = hi65xx_power_release_isr },
        { .name = "hold 4s", .handler = hi65xx_restart_toggle_isr },
};
Quoted 5 lines

Hrm.. Ok. I can rework it this way. If you were curious, here's what the code currently looks like:
https://git.linaro.org/people/john.stultz/android-dev.git/commitdiff/2b0de7d8ba22d188e961a4ffef6d95030ef31c15

But I'll rework it and submit it tomorrow.

Actually, it is up to you, I'm fine with the above as well. You can probably drop of_irq.h form there though.

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

One comment on your question below...

Quoted 5 lines

drivers/input/misc/Kconfig config INPUT_DRV2667_HAPTICS · line 803

Quoted 3 lines
drivers/input/misc/Kconfig +3 -0
+             ret = devm_request_threaded_irq(dev, irq, NULL,
+                                     irq_info[i].handler, IRQF_ONESHOT,
+                                     irq_info[i].name, priv);

Why threaded irq? Seems wasteful to have 3 threads for this.

As this is a nested interrupt, devm_request_irq was failing unless it was threaded.
Any ideas for something better?

Quoted 5 lines
Quoted 3 lines

Ahh, that is unfortunate, but I guess we'll have to live with it. Please use devm_request_any_context_irq() then to show that the driver itself does not need threaded interrupt but platform may provide it.

Sounds good. Will do.

Thanks.

Signature · 1 line
Dmitry
#3 lore raw

Re: [RFC][PATCH 2/5] hi655x-pmic: Make hi655x pmic logic probe child nodes in the dt

In reply to John Stultz

Subject should indicate "mfd".

git log --oneline -- drivers/mfd

Quoted 2 lines

In trying to wire up the powerkey driver, I found I needed to add this to get the pmic logic to probe

PMIC

Quoted 1 line

child nodes in the dt data.

DT.

Please use full buffer width. Wrapping at 50 chars is not necessary.

Quoted 34 lines

With this patch, child nodes get properly probed.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>
---
 drivers/mfd/hi655x-pmic.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mfd/hi655x-pmic.c +5 -0
index 05ddc78..3511035 100644
@@ -39,6 +39,11 @@ static const struct regmap_irq hi655x_irqs[] = {
 	{ .reg_offset = 0, .mask = RESERVE_INT },
 };
 
+static const struct of_device_id of_hi655x_pmic_child_match_tbl[] = {
+	{ .compatible = "hisilicon,hi6552-powerkey", },
+	{ /* end */ }
+};
+
 static const struct regmap_irq_chip hi655x_irq_chip = {
 	.name = "hi655x-pmic",
 	.irqs = hi655x_irqs,

drivers/mfd/hi655x-pmic.c static int hi655x_pmic_probe(struct platform_device *pdev) · line 132

Quoted 6 lines
drivers/mfd/hi655x-pmic.c +3 -0
@@ -122,6 +127,9 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pmic);
 
+	/* populate sub nodes */
+	of_platform_populate(np, of_hi655x_pmic_child_match_tbl, NULL, dev);
+

Oh, holey poop, no!

Please don't mix DT and MFD registration like this.

Drivers should contain either of_platform_populate() or mfd_add_devices(), but never both.

Quoted 3 lines
drivers/mfd/hi655x-pmic.c +0 -0
 	ret = mfd_add_devices(dev, PLATFORM_DEVID_AUTO, hi655x_pmic_devs,
 			      ARRAY_SIZE(hi655x_pmic_devs), NULL, 0, NULL);
 	if (ret) {
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Acked-by on v1 3/5
#7 lore raw

Re: [RFC][PATCH 3/5] hi655x-pmic: Fixup issue with un-acked interrupts

In reply to John Stultz
Quoted 22 lines · John Stultz

While trying to get the powerkey to function, I found when pressing the key, I would get infinitely repeating interrupts.

After digging around a bit, it seems we didn't set the ack_base value for the regmap irqchip logic, so nothing was acking the interrupt.

This patch adds the ack_base, which seems to make things work.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>
Quoted 3 lines
---
 drivers/mfd/hi655x-pmic.c | 1 +
 1 file changed, 1 insertion(+)

Seems reasonable.

Quoted 12 lines
drivers/mfd/hi655x-pmic.c +1 -0
index 3511035..4a3fdbc 100644
@@ -50,6 +50,7 @@ static const struct regmap_irq_chip hi655x_irq_chip = {
 	.num_regs = 1,
 	.num_irqs = ARRAY_SIZE(hi655x_irqs),
 	.status_base = HI655X_IRQ_STAT_BASE,
+	.ack_base = HI655X_IRQ_STAT_BASE,
 	.mask_base = HI655X_IRQ_MASK_BASE,
 };
 
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw

Re: [RFC][PATCH 2/5] hi655x-pmic: Make hi655x pmic logic probe child nodes in the dt

In reply to Lee Jones
Quoted 2 lines · Lee Jones

Please use full buffer width. Wrapping at 50 chars is not necessary.

But then how would you be able to review patches on your phone?! :)

Quoted 24 lines
Quoted 15 lines
drivers/mfd/hi655x-pmic.c +5 -0
@@ -39,6 +39,11 @@ static const struct regmap_irq hi655x_irqs[] = {
      { .reg_offset = 0, .mask = RESERVE_INT },
 };
 
+static const struct of_device_id of_hi655x_pmic_child_match_tbl[] = {
+     { .compatible = "hisilicon,hi6552-powerkey", },
+     { /* end */ }
+};
+
 static const struct regmap_irq_chip hi655x_irq_chip = {
      .name = "hi655x-pmic",
      .irqs = hi655x_irqs,

drivers/mfd/hi655x-pmic.c static int hi655x_pmic_probe(struct platform_device *pdev) · line 132

Quoted 6 lines
drivers/mfd/hi655x-pmic.c +3 -0
@@ -122,6 +127,9 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
 
      platform_set_drvdata(pdev, pmic);
 
+     /* populate sub nodes */
+     of_platform_populate(np, of_hi655x_pmic_child_match_tbl, NULL, dev);
+

Oh, holey poop, no!

Quoted 8 lines

Please don't mix DT and MFD registration like this.

Drivers should contain either of_platform_populate() or mfd_add_devices(), but never both.

Quoted 3 lines
drivers/mfd/hi655x-pmic.c +0 -0
      ret = mfd_add_devices(dev, PLATFORM_DEVID_AUTO, hi655x_pmic_devs,
                            ARRAY_SIZE(hi655x_pmic_devs), NULL, 0, NULL);
      if (ret) {

So apologies for my ignorance here. I'm not quite sure I see what the right thing to do. I tried adding a "hi65xx-powerkey" entry in the hi655x_pmic_devs, but then mfd_add_devices doesn't seem to provide any of the irq info from the DT.

The only way I can think to make it work w/o calling to populate sub-nodes is to pull the powerkey subnode out of the pmic node. It seems to work, but I'm not sure if it properly describes the hardware then. Sorry again for being a bit clueless here.

Thanks for the review!
-john

#5 lore raw

Re: [RFC][PATCH 2/5] hi655x-pmic: Make hi655x pmic logic probe child nodes in the dt

Quoted 5 lines · John Stultz
Quoted 2 lines · Lee Jones

Please use full buffer width. Wrapping at 50 chars is not necessary.

But then how would you be able to review patches on your phone?! :)

Sideways! ;)

Quoted 39 lines
Quoted 24 lines
Quoted 15 lines
drivers/mfd/hi655x-pmic.c +5 -0
@@ -39,6 +39,11 @@ static const struct regmap_irq hi655x_irqs[] = {
      { .reg_offset = 0, .mask = RESERVE_INT },
 };
 
+static const struct of_device_id of_hi655x_pmic_child_match_tbl[] = {
+     { .compatible = "hisilicon,hi6552-powerkey", },
+     { /* end */ }
+};
+
 static const struct regmap_irq_chip hi655x_irq_chip = {
      .name = "hi655x-pmic",
      .irqs = hi655x_irqs,

drivers/mfd/hi655x-pmic.c static int hi655x_pmic_probe(struct platform_device *pdev) · line 132

Quoted 6 lines
drivers/mfd/hi655x-pmic.c +3 -0
@@ -122,6 +127,9 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
 
      platform_set_drvdata(pdev, pmic);
 
+     /* populate sub nodes */
+     of_platform_populate(np, of_hi655x_pmic_child_match_tbl, NULL, dev);
+

Oh, holey poop, no!

Quoted 8 lines

Please don't mix DT and MFD registration like this.

Drivers should contain either of_platform_populate() or mfd_add_devices(), but never both.

Quoted 3 lines
drivers/mfd/hi655x-pmic.c +0 -0
      ret = mfd_add_devices(dev, PLATFORM_DEVID_AUTO, hi655x_pmic_devs,
                            ARRAY_SIZE(hi655x_pmic_devs), NULL, 0, NULL);
      if (ret) {

So apologies for my ignorance here. I'm not quite sure I see what the right thing to do. I tried adding a "hi65xx-powerkey" entry in the hi655x_pmic_devs, but then mfd_add_devices doesn't seem to provide any of the irq info from the DT.

Quoted 4 lines

The only way I can think to make it work w/o calling to populate sub-nodes is to pull the powerkey subnode out of the pmic node. It seems to work, but I'm not sure if it properly describes the hardware then. Sorry again for being a bit clueless here.

Since we use mfd_add_devices() already, you need to create a cell in this file for the power-key driver and omit it from DT altogether. If your priority is to have each sub-device represented in DT, then you need to stop using mfd_add_devices() and have of_platform_populate() do your bidding.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog