Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1413531 > unrolled thread
| Started by | John Stultz <john.stultz@linaro.org> |
|---|---|
| First post | 2016-06-04 00:20 +0200 |
| Last post | 2016-06-08 17:40 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/5] Hi655x powerkey support for HiKey (v2) John Stultz <john.stultz@linaro.org> - 2016-06-04 00:20 +0200
[PATCH 4/5] drivers: input: powerkey for HISI 65xx SoC John Stultz <john.stultz@linaro.org> - 2016-06-04 00:20 +0200
[PATCH 1/5] dts: bindings: Add binding documentation for hisilicon,hi6552-powerkey John Stultz <john.stultz@linaro.org> - 2016-06-04 00:20 +0200
[PATCH 2/5] hi655x-pmic: Make hi655x pmic logic probe child nodes in the dt John Stultz <john.stultz@linaro.org> - 2016-06-04 00:20 +0200
Re: [PATCH 0/5] Hi655x powerkey support for HiKey (v2) Lee Jones <lee.jones@linaro.org> - 2016-06-08 17:40 +0200
| From | John Stultz <john.stultz@linaro.org> |
|---|---|
| Date | 2016-06-04 00:20 +0200 |
| Subject | [PATCH 0/5] Hi655x powerkey support for HiKey (v2) |
| Message-ID | <rG5BE-xM-5@gated-at.bofh.it> |
This patchset enables the pmic powerkey to function on HiKey. I wanted to submit it for some initial review. Feedback would be greatly appreciated! New in v2: * Larger rework to the powerkey driver, integrating feedback from Dmitry * Minor dts cleanup suggested by Rob thanks -john Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Rob Herring <robh+dt@kernel.org> Cc: Pawel Moll <pawel.moll@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Ian Campbell <ijc+devicetree@hellion.org.uk> Cc: Kumar Gala <galak@codeaurora.org> Cc: Lee Jones <lee.jones@linaro.org> Cc: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org> Cc: Wei Xu <xuwei5@hisilicon.com> Cc: Guodong Xu <guodong.xu@linaro.org> 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 | 9 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/hisi_powerkey.c | 155 +++++++++++++++++++++ drivers/mfd/hi655x-pmic.c | 9 ++ 6 files changed, 221 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/hisilicon,hi6552-powerkey.txt create mode 100644 drivers/input/misc/hisi_powerkey.c -- 1.9.1
[toc] | [next] | [standalone]
| From | John Stultz <john.stultz@linaro.org> |
|---|---|
| Date | 2016-06-04 00:20 +0200 |
| Subject | [PATCH 4/5] drivers: input: powerkey for HISI 65xx SoC |
| Message-ID | <rG5BE-xM-25@gated-at.bofh.it> |
| In reply to | #1413531 |
From: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
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 <xuezhiliang@huawei.com>
then basically rewritten by Jorge, but preserving the original
module author credits.
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
Cc: Kumar Gala <galak@codeaurora.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
[jstultz: Reworked commit message, folded in other fixes/cleanups
from Jorge, implemented some larger cleanups suggested by DmitryT]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
drivers/input/misc/Kconfig | 9 +++
drivers/input/misc/Makefile | 1 +
drivers/input/misc/hisi_powerkey.c | 155 +++++++++++++++++++++++++++++++++++++
3 files changed, 165 insertions(+)
create mode 100644 drivers/input/misc/hisi_powerkey.c
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 1f2337a..07aacfc 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -796,4 +796,13 @@ 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"
+ depends on ARCH_HISI || COMPILE_TEST
+ 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
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 0357a08..f264777 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -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
diff --git a/drivers/input/misc/hisi_powerkey.c b/drivers/input/misc/hisi_powerkey.c
new file mode 100644
index 0000000..270b881
--- /dev/null
+++ b/drivers/input/misc/hisi_powerkey.c
@@ -0,0 +1,155 @@
+/*
+ * Hisilicon PMIC powerkey driver
+ *
+ * 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 held interrupt will trigger after 4 seconds */
+#define MAX_HELD_TIME (4 * MSEC_PER_SEC)
+
+
+enum id_action { ID_PRESSED, ID_RELEASED, ID_HELD, ID_LAST };
+const char *const irq_names[ID_LAST] = {"down", "up", "hold 4s"};
+
+struct hi65xx_priv {
+ struct input_dev *input;
+};
+
+static irqreturn_t hi65xx_power_press_isr(int irq, void *q)
+{
+ struct hi65xx_priv *p = q;
+
+ pm_wakeup_event(p->input->dev.parent, MAX_HELD_TIME);
+ input_report_key(p->input, KEY_POWER, 1);
+ input_sync(p->input);
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t hi65xx_power_release_isr(int irq, void *q)
+{
+ struct hi65xx_priv *p = q;
+
+ pm_wakeup_event(p->input->dev.parent, MAX_HELD_TIME);
+ input_report_key(p->input, KEY_POWER, 0);
+ input_sync(p->input);
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t hi65xx_restart_toggle_isr(int irq, void *q)
+{
+ struct hi65xx_priv *p = q;
+ int value = test_bit(KEY_RESTART, p->input->key);
+
+ pm_wakeup_event(p->input->dev.parent, MAX_HELD_TIME);
+ input_report_key(p->input, KEY_RESTART, !value);
+ input_sync(p->input);
+
+ return IRQ_HANDLED;
+}
+
+irqreturn_t (*irq_handlers[ID_LAST])(int irq, void *q) = {
+ hi65xx_power_press_isr,
+ hi65xx_power_release_isr,
+ hi65xx_restart_toggle_isr,
+};
+
+static int hi65xx_powerkey_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct hi65xx_priv *priv;
+ int irq, i, ret;
+
+ priv = devm_kzalloc(dev, sizeof(struct hi65xx_priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->input = devm_input_allocate_device(&pdev->dev);
+ if (!priv->input) {
+ dev_err(&pdev->dev, "failed to allocate input device\n");
+ return -ENOMEM;
+ }
+
+ priv->input->phys = "hisi_on/input0";
+ priv->input->name = "HISI 65xx PowerOn Key";
+
+ input_set_capability(priv->input, EV_KEY, KEY_POWER);
+ input_set_capability(priv->input, EV_KEY, KEY_RESTART);
+
+ for (i = 0; i < ID_LAST; i++) {
+
+ irq = platform_get_irq_byname(pdev, irq_names[i]);
+ if (irq < 0) {
+ dev_err(dev, "couldn't get irq %s\n", irq_names[i]);
+ return irq;
+ }
+
+ ret = devm_request_any_context_irq(dev, irq,
+ irq_handlers[i], IRQF_ONESHOT,
+ irq_names[i], priv);
+ if (ret < 0) {
+ dev_err(dev, "couldn't get irq %s\n", irq_names[i]);
+ return ret;
+ }
+ }
+
+ ret = input_register_device(priv->input);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register input device: %d\n",
+ ret);
+ return ret;
+ }
+
+ platform_set_drvdata(pdev, priv);
+ device_init_wakeup(&pdev->dev, 1);
+
+ return 0;
+}
+
+static int hi65xx_powerkey_remove(struct platform_device *pdev)
+{
+ device_init_wakeup(&pdev->dev, 0);
+ return 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 = {
+ .name = "hi65xx-powerkey",
+ .of_match_table = of_match_ptr(hi65xx_powerkey_of_match),
+ },
+ .probe = hi65xx_powerkey_probe,
+ .remove = hi65xx_powerkey_remove,
+};
+
+module_platform_driver(hi65xx_powerkey_driver);
+
+MODULE_AUTHOR("Zhiliang Xue <xuezhiliang@huawei.com");
+MODULE_DESCRIPTION("Hisi PMIC Power key driver");
+MODULE_LICENSE("GPL v2");
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | John Stultz <john.stultz@linaro.org> |
|---|---|
| Date | 2016-06-04 00:20 +0200 |
| Subject | [PATCH 1/5] dts: bindings: Add binding documentation for hisilicon,hi6552-powerkey |
| Message-ID | <rG5BF-xM-29@gated-at.bofh.it> |
| In reply to | #1413531 |
Adds binding documentation for hi6552 pmic powerkey button.
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
Cc: Kumar Gala <galak@codeaurora.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
.../bindings/input/hisilicon,hi6552-powerkey.txt | 40 ++++++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/hisilicon,hi6552-powerkey.txt
diff --git a/Documentation/devicetree/bindings/input/hisilicon,hi6552-powerkey.txt b/Documentation/devicetree/bindings/input/hisilicon,hi6552-powerkey.txt
new file mode 100644
index 0000000..7f09124
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/hisilicon,hi6552-powerkey.txt
@@ -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";
+ };
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | John Stultz <john.stultz@linaro.org> |
|---|---|
| Date | 2016-06-04 00:20 +0200 |
| Subject | [PATCH 2/5] hi655x-pmic: Make hi655x pmic logic probe child nodes in the dt |
| Message-ID | <rG5BF-xM-35@gated-at.bofh.it> |
| In reply to | #1413531 |
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 <dmitry.torokhov@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
Cc: Kumar Gala <galak@codeaurora.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
drivers/mfd/hi655x-pmic.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/mfd/hi655x-pmic.c b/drivers/mfd/hi655x-pmic.c
index 05ddc78..3511035 100644
--- a/drivers/mfd/hi655x-pmic.c
+++ b/drivers/mfd/hi655x-pmic.c
@@ -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) {
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2016-06-08 17:40 +0200 |
| Message-ID | <rHNKi-1Yh-19@gated-at.bofh.it> |
| In reply to | #1413531 |
On Fri, 03 Jun 2016, John Stultz wrote: > This patchset enables the pmic powerkey to function on HiKey. > > I wanted to submit it for some initial review. Feedback would > be greatly appreciated! > > New in v2: > * Larger rework to the powerkey driver, integrating feedback > from Dmitry > * Minor dts cleanup suggested by Rob Looks like I reviewed your RFC instead. The points are still valid here though. > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> > Cc: Rob Herring <robh+dt@kernel.org> > Cc: Pawel Moll <pawel.moll@arm.com> > Cc: Mark Rutland <mark.rutland@arm.com> > Cc: Ian Campbell <ijc+devicetree@hellion.org.uk> > Cc: Kumar Gala <galak@codeaurora.org> > Cc: Lee Jones <lee.jones@linaro.org> > Cc: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org> > Cc: Wei Xu <xuwei5@hisilicon.com> > Cc: Guodong Xu <guodong.xu@linaro.org> > > > 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 | 9 ++ > drivers/input/misc/Makefile | 1 + > drivers/input/misc/hisi_powerkey.c | 155 +++++++++++++++++++++ > drivers/mfd/hi655x-pmic.c | 9 ++ > 6 files changed, 221 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/hisilicon,hi6552-powerkey.txt > create mode 100644 drivers/input/misc/hisi_powerkey.c > -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web