Skip to contentSkip to conversation

input: Add RAVE SP Powerbutton driver

PATCH Superseded Andrey Smirnov 3 participants 6 messages Mar 1, 2018 – Mar 7, 2018

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 input: Add RAVE SP Powerbutton driver

Add driver that properly handles input event emitted by RAVE SP devices.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Chris Healy <[email protected]>
Cc Lucas Stach <[email protected]>

---

Changes since [v1]:

- Removed redundant dev.parent assignment

- Various cosmetic changes

[v1] lkml.kernel.org/r/[email protected]

 drivers/input/misc/Kconfig             |  9 ++++
 drivers/input/misc/Makefile            |  1 +
 drivers/input/misc/rave-sp-pwrbutton.c | 94 ++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)
 create mode 100644 drivers/input/misc/rave-sp-pwrbutton.c
drivers/input/misc/Kconfig +9 -0
index 62a1312a7387..6a3c753b093b 100644
@@ -841,4 +841,13 @@ config INPUT_HISI_POWERKEY
 	  To compile this driver as a module, choose M here: the
 	  module will be called hisi_powerkey.
 
+config INPUT_RAVE_SP_PWRBUTTON
+	tristate "RAVE SP Power button Driver"
+	depends on RAVE_SP_CORE
+	help
+	  Say Y here if you want to enable power key reporting from RAVE SP
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called rave-sp-pwrbutton.
+
 endif
drivers/input/misc/Makefile +1 -0
index a8f61af865aa..8cc58f362bb8 100644
@@ -60,6 +60,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)	+= pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_POWERMATE)		+= powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER)		+= pwm-beeper.o
 obj-$(CONFIG_INPUT_PWM_VIBRA)		+= pwm-vibra.o
+obj-$(CONFIG_INPUT_RAVE_SP_PWRBUTTON)	+= rave-sp-pwrbutton.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)	+= rb532_button.o
 obj-$(CONFIG_INPUT_REGULATOR_HAPTIC)	+= regulator-haptic.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON)	+= retu-pwrbutton.o
drivers/input/misc/rave-sp-pwrbutton.c new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
2.14.3
#1 lore raw

PATCH v2 2/2 dt-bindings: input: Add binding for RAVE SP input driver

Add Device Tree bindings for RAVE SP input drvier - an MFD cell of parent RAVE SP driver (documented in Documentation/devicetree/bindings/mfd/zii,rave-sp.txt).

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Chris Healy <[email protected]>
Cc Lucas Stach <[email protected]>
---
 .../bindings/input/zii,rave-sp-pwrbutton.txt       | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt
Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt new file +24 -0
new file mode 100644
index 000000000000..e14e12d27772
@@ -0,0 +1,24 @@
+Zodiac Inflight Innovations RAVE Supervisory Processor Power Button Bindings
+
+RAVE SP input device is a "MFD cell" device corresponding to power
+button functionality of RAVE Supervisory Processor. It is expected
+that its Device Tree node is specified as a child of the node
+corresponding to the parent RAVE SP device (as documented in
+Documentation/devicetree/bindings/mfd/zii,rave-sp.txt)
+
+Required properties:
+
+- compatible: Should be "zii,rave-sp-pwrbutton"
+
+Example:
+
+	rave-sp {
+		compatible = "zii,rave-sp-rdu1";
+		current-speed = <38400>;
+
+		pwrbutton {
+			compatible = "zii,rave-sp-pwrbutton";
+			status = "okay";
+		};
+	}
+
Signature · 1 line
2.14.3
Acked-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] dt-bindings: input: Add binding for RAVE SP input driver

Am Donnerstag, den 01.03.2018, 08:55 -0800 schrieb Andrey Smirnov:

Quoted 7 lines

Add Device Tree bindings for RAVE SP input drvier - an MFD cell of parent RAVE SP driver (documented in Documentation/devicetree/bindings/mfd/zii,rave-sp.txt).

Quoted 1 line
Cc Dmitry Torokhov <[email protected]>
Quoted 7 lines
Quoted 2 lines
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Quoted 3 lines
Cc Guenter Roeck <[email protected]>
Cc Chris Healy <[email protected]>
Cc Lucas Stach <[email protected]>
Quoted 35 lines

---
 .../bindings/input/zii,rave-sp-pwrbutton.txt       | 24 ++++++++++++++++++++++

 1 file changed, 24 insertions(+)

 create mode 100644 Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt

Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt new file +14 -0
new file mode 100644
index 000000000000..e14e12d27772
@@ -0,0 +1,24 @@
+Zodiac Inflight Innovations RAVE Supervisory Processor Power Button Bindings
+
+RAVE SP input device is a "MFD cell" device corresponding to power
+button functionality of RAVE Supervisory Processor. It is expected
+that its Device Tree node is specified as a child of the node
+corresponding to the parent RAVE SP device (as documented in
+Documentation/devicetree/bindings/mfd/zii,rave-sp.txt)
+
+Required properties:
+
+- compatible: Should be "zii,rave-sp-pwrbutton"
+
+Example:
+

Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt line 17

Quoted 3 lines
Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt new file +3 -0
+	rave-sp {
+		compatible = "zii,rave-sp-rdu1";
+		current-speed = <38400>;

+

Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt line 23

Quoted 5 lines
Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt new file +5 -0
+		pwrbutton {
+			compatible = "zii,rave-sp-pwrbutton";
+			status = "okay";
+		};
+	}

+

#3 lore raw

Re: [PATCH v2 2/2] dt-bindings: input: Add binding for RAVE SP input driver

In reply to Andrey Smirnov

Hi Andrey,

On Thu, Mar 1, 2018 at 1:55 PM, Andrey Smirnov <[email protected]> wrote:
l

Quoted 13 lines

+++ b/Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt

Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt new file +11 -0
@@ -0,0 +1,24 @@
+Zodiac Inflight Innovations RAVE Supervisory Processor Power Button Bindings
+
+RAVE SP input device is a "MFD cell" device corresponding to power
+button functionality of RAVE Supervisory Processor. It is expected
+that its Device Tree node is specified as a child of the node
+corresponding to the parent RAVE SP device (as documented in
+Documentation/devicetree/bindings/mfd/zii,rave-sp.txt)
+
+Required properties:
+
+- compatible: Should be "zii,rave-sp-pwrbutton"

Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt line 21

Quoted 10 lines
Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt new file +10 -0
+
+Example:
+
+       rave-sp {
+               compatible = "zii,rave-sp-rdu1";
+               current-speed = <38400>;
+
+               pwrbutton {
+                       compatible = "zii,rave-sp-pwrbutton";
+                       status = "okay";

In the dts patch review Shawn said:

"The okay status is to flip the state of devices that are initially disabled. I think it's unnecessary for the case here."

so please remove the status line.

#4 lore raw

Re: [PATCH v2 2/2] dt-bindings: input: Add binding for RAVE SP input driver

Quoted 30 lines · Fabio Estevam

Hi Andrey,

On Thu, Mar 1, 2018 at 1:55 PM, Andrey Smirnov <[email protected]> wrote:
l

Quoted 13 lines

+++ b/Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt

Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt new file +11 -0
@@ -0,0 +1,24 @@
+Zodiac Inflight Innovations RAVE Supervisory Processor Power Button Bindings
+
+RAVE SP input device is a "MFD cell" device corresponding to power
+button functionality of RAVE Supervisory Processor. It is expected
+that its Device Tree node is specified as a child of the node
+corresponding to the parent RAVE SP device (as documented in
+Documentation/devicetree/bindings/mfd/zii,rave-sp.txt)
+
+Required properties:
+
+- compatible: Should be "zii,rave-sp-pwrbutton"

Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt line 21

Quoted 10 lines
Documentation/devicetree/bindings/input/zii,rave-sp-pwrbutton.txt new file +10 -0
+
+Example:
+
+       rave-sp {
+               compatible = "zii,rave-sp-rdu1";
+               current-speed = <38400>;
+
+               pwrbutton {
+                       compatible = "zii,rave-sp-pwrbutton";
+                       status = "okay";

In the dts patch review Shawn said:

Quoted 4 lines

"The okay status is to flip the state of devices that are initially disabled. I think it's unnecessary for the case here."

so please remove the status line.

Sure, will do in v3.

Thanks,
Andrey Smirnov

Reviewed-by on v2 1/2
#5 lore raw
In reply to Andrey Smirnov

Am Donnerstag, den 01.03.2018, 08:55 -0800 schrieb Andrey Smirnov:

Quoted 6 lines

Add driver that properly handles input event emitted by RAVE SP devices.

Quoted 1 line
Cc Dmitry Torokhov <[email protected]>
Quoted 7 lines
Quoted 2 lines
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Quoted 3 lines
Cc Guenter Roeck <[email protected]>
Cc Chris Healy <[email protected]>
Cc Lucas Stach <[email protected]>
Quoted 146 lines

---

Changes since [v1]:

- Removed redundant dev.parent assignment

- Various cosmetic changes

[v1] lkml.kernel.org/r/[email protected]

 drivers/input/misc/Kconfig             |  9 ++++ drivers/input/misc/Makefile            |  1 + drivers/input/misc/rave-sp-pwrbutton.c | 94 ++++++++++++++++++++++++++++++++++

 3 files changed, 104 insertions(+)

 create mode 100644 drivers/input/misc/rave-sp-pwrbutton.c

drivers/input/misc/Kconfig +0 -0
index 62a1312a7387..6a3c753b093b 100644
@@ -841,4 +841,13 @@ config INPUT_HISI_POWERKEY
Quoted 2 lines

    To compile this driver as a module, choose M here: the module will be called hisi_powerkey.


+config INPUT_RAVE_SP_PWRBUTTON

drivers/input/misc/Kconfig config INPUT_HISI_POWERKEY · line 848

Quoted 4 lines
drivers/input/misc/Kconfig +4 -0
+	tristate "RAVE SP Power button Driver"
+	depends on RAVE_SP_CORE
+	help
+	  Say Y here if you want to enable power key reporting from RAVE SP

+

drivers/input/misc/Kconfig config INPUT_HISI_POWERKEY · line 851

Quoted 2 lines
drivers/input/misc/Kconfig +2 -0
+	  To compile this driver as a module, choose M here: the
+	  module will be called rave-sp-pwrbutton.

+
 endif

drivers/input/misc/Makefile +0 -0
index a8f61af865aa..8cc58f362bb8 100644
Quoted 8 lines
(quoted diff) +0 -0
@@ -60,6 +60,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)	+= pmic8xxx-pwrkey.o

 obj-$(CONFIG_INPUT_POWERMATE) += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
 obj-$(CONFIG_INPUT_PWM_VIBRA) += pwm-vibra.o
+obj-$(CONFIG_INPUT_RAVE_SP_PWRBUTTON) += rave-sp-pwrbutton.o
 obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o
 obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o

drivers/input/misc/rave-sp-pwrbutton.c new file +14 -0
new file mode 100644
index 000000000000..bcab3cdb7ebd
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Power Button driver for RAVE SP
+//
+// Copyright (C) 2017 Zodiac Inflight Innovations
+//
+//
+
+#include <linux/input.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mfd/rave-sp.h>
+#include <linux/platform_device.h>
+
Quoted 1 line

+#define RAVE_SP_EVNT_BUTTON_PRESS (RAVE_SP_EVNT_BASE + 0x00)

drivers/input/misc/rave-sp-pwrbutton.c new file +2 -0
+
+struct rave_sp_power_button {
Quoted 2 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +2 -0
+	struct input_dev *idev;
+	struct notifier_block nb;
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+};
+
+static int rave_sp_power_button_event(struct notifier_block *nb,

drivers/input/misc/rave-sp-pwrbutton.c line 23

Quoted 1 line
drivers/input/misc/rave-sp-pwrbutton.c new file +1 -0
+				      unsigned long action, void *data)

+{

drivers/input/misc/rave-sp-pwrbutton.c line 29

Quoted 5 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +5 -0
+	struct rave_sp_power_button *pb =
+		container_of(nb, struct rave_sp_power_button, nb);
+	const u8 event = rave_sp_action_unpack_event(action);
+	const u8 value = rave_sp_action_unpack_value(action);
+	struct input_dev *idev = pb->idev;

+

drivers/input/misc/rave-sp-pwrbutton.c line 33

Quoted 3 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+	if (event == RAVE_SP_EVNT_BUTTON_PRESS) {
+		input_report_key(idev, KEY_POWER, value);
+		input_sync(idev);

+

Review

Quoted 2 lines
(quoted diff) +2 -0
+		return NOTIFY_STOP;
+	}

+

Quoted 1 line
drivers/input/misc/rave-sp-pwrbutton.c new file +1 -0
+	return NOTIFY_DONE;
drivers/input/misc/rave-sp-pwrbutton.c new file +4 -0
+}
+
+static int rave_sp_pwrbutton_probe(struct platform_device *pdev)
+{

drivers/input/misc/rave-sp-pwrbutton.c line 46

Quoted 4 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +4 -0
+	struct device *dev = &pdev->dev;
+	struct rave_sp_power_button *pb;
+	struct input_dev *idev;
+	int error;

+

drivers/input/misc/rave-sp-pwrbutton.c line 50

Quoted 3 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+	pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL);
+	if (!pb)
+		return -ENOMEM;

+

drivers/input/misc/rave-sp-pwrbutton.c line 54

Quoted 3 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+	idev = devm_input_allocate_device(dev);
+	if (!idev)
+		return -ENOMEM;

+

drivers/input/misc/rave-sp-pwrbutton.c line 56

Quoted 1 line
drivers/input/misc/rave-sp-pwrbutton.c new file +1 -0
+	idev->name = pdev->name;

+

drivers/input/misc/rave-sp-pwrbutton.c line 58

Quoted 1 line
drivers/input/misc/rave-sp-pwrbutton.c new file +1 -0
+	input_set_capability(idev, EV_KEY, KEY_POWER);

+

drivers/input/misc/rave-sp-pwrbutton.c line 62

Quoted 3 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+	error = input_register_device(idev);
+	if (error)
+		return error;

+

drivers/input/misc/rave-sp-pwrbutton.c line 66

Quoted 3 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+	pb->idev = idev;
+	pb->nb.notifier_call = rave_sp_power_button_event;
+	pb->nb.priority = 128;

+

drivers/input/misc/rave-sp-pwrbutton.c line 70

Quoted 3 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+	error = devm_rave_sp_register_event_notifier(dev, &pb->nb);
+	if (error)
+		return error;

+

Quoted 1 line
drivers/input/misc/rave-sp-pwrbutton.c new file +1 -0
+	return 0;
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+}
+
+static const struct of_device_id rave_sp_pwrbutton_of_match[] = {
Quoted 2 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +2 -0
+	{ .compatible = "zii,rave-sp-pwrbutton" },
+	{}
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+};
+
+static struct platform_driver rave_sp_pwrbutton_driver = {
Quoted 5 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +1 -0
+	.probe = rave_sp_pwrbutton_probe,
Quoted 1 line
drivers/input/misc/rave-sp-pwrbutton.c new file +1 -0
+	.driver	= {
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+		.name = KBUILD_MODNAME,
+		.of_match_table = rave_sp_pwrbutton_of_match,
+	},
drivers/input/misc/rave-sp-pwrbutton.c new file +5 -0
+};
+module_platform_driver(rave_sp_pwrbutton_driver);
+
+MODULE_DEVICE_TABLE(of, rave_sp_pwrbutton_of_match);
+MODULE_LICENSE("GPL");

drivers/input/misc/rave-sp-pwrbutton.c line 93

Quoted 3 lines
drivers/input/misc/rave-sp-pwrbutton.c new file +3 -0
+MODULE_AUTHOR("Andrey Vostrikov <[email protected]>");
+MODULE_AUTHOR("Nikita Yushchenko <[email protected]>");
+MODULE_AUTHOR("Andrey Smirnov <[email protected]>");

+MODULE_DESCRIPTION("RAVE SP Power Button driver");