Skip to contentSkip to conversation

Hi655x powerkey support for HiKey (v4)

PATCH Applied John Stultz 3 participants 15 messages Jun 14, 2016 – Jun 23, 2016

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

cover Hi655x powerkey support for HiKey (v4)

This patchset enables the pmic powerkey to function on HiKey, that I'd like to submit for consideration to be merged.

New in v4:
* Integrated a few cleanup suggestions from Lee Jones.
* Removed MODULE_DEVICE_TABLE(of, hi65xx_powerkey_of_match); line I missed when removing the dts initialization logic.

Review and feedback are always appreciated!

thanks
-john

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

John Stultz (3):
mfd: hi655x-pmic: Fixup issue with un-acked interrupts
mfd: hi655x-pmic: Rename some interrupt macro names
mfd: hi655x-pmic: Add powerkey device to hi655x PMIC driver

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

 drivers/input/misc/Kconfig         |   9 +++
 drivers/input/misc/Makefile        |   1 +
 drivers/input/misc/hisi_powerkey.c | 147 +++++++++++++++++++++++++++++++++++++
 drivers/mfd/hi655x-pmic.c          |  52 +++++++++----
 include/linux/mfd/hi655x-pmic.h    |  25 +++++--
 5 files changed, 213 insertions(+), 21 deletions(-)
 create mode 100644 drivers/input/misc/hisi_powerkey.c
Signature · 1 line
1.9.1
#1 lore raw

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

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 Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, implemented some larger cleanups suggested by DmitryT]

---
v2: Major rework integrating feedback from Dmitry.
v3: Dropped of_match compatible line since no longer using DT
for this.
v4: Removed MODULE_DEVICE_TABLE(of, hi65xx_powerkey_of_match) line
I missed in the last revision, which casued build issues w/ modules.

 drivers/input/misc/Kconfig         |   9 +++
 drivers/input/misc/Makefile        |   1 +
 drivers/input/misc/hisi_powerkey.c | 147 +++++++++++++++++++++++++++++++++++++
 3 files changed, 157 insertions(+)
 create mode 100644 drivers/input/misc/hisi_powerkey.c
drivers/input/misc/Kconfig +9 -0
index 1f2337a..07aacfc 100644
@@ -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
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 +147 -0

147 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

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

Quoted 19 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 Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, implemented some larger cleanups suggested by DmitryT]

Quoted 8 lines

---
v2: Major rework integrating feedback from Dmitry.
v3: Dropped of_match compatible line since no longer using DT
for this.
v4: Removed MODULE_DEVICE_TABLE(of, hi65xx_powerkey_of_match) line
I missed in the last revision, which casued build issues w/ modules.

Hey Dmitry,
Just wanted to ping you to see if there was anything else you were
wanting changed with this patch. Lee has queued the mfd patches in -next, so I wanted to be sure to address any concerns you had that was keeping this from heading upstream in 4.8 (hopefully :).

thanks
-john

maintainer
#3 lore raw

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

Quoted 29 lines · John Stultz
Quoted 19 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 Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, implemented some larger cleanups suggested by DmitryT]

Quoted 8 lines

---
v2: Major rework integrating feedback from Dmitry.
v3: Dropped of_match compatible line since no longer using DT
for this.
v4: Removed MODULE_DEVICE_TABLE(of, hi65xx_powerkey_of_match) line
I missed in the last revision, which casued build issues w/ modules.

Quoted 5 lines

Hey Dmitry,
Just wanted to ping you to see if there was anything else you were
wanting changed with this patch. Lee has queued the mfd patches in -next, so I wanted to be sure to address any concerns you had that was keeping this from heading upstream in 4.8 (hopefully :).

Right, sorry, does the following look OK to you?

Thanks.

Signature · 9 lines
Dmitry


Input: hisi_powerkey - misc changes

Signed-off-by: Dmitry Torokhov <[email protected]>
---
 drivers/input/misc/hisi_powerkey.c |  101 +++++++++++++++++-------------------
 1 file changed, 48 insertions(+), 53 deletions(-)
drivers/input/misc/hisi_powerkey.c +48 -53
index e5ab5d8..675539c 100644
@@ -26,101 +26,96 @@
 /* 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;
+	struct input_dev *input = q;
 
-	pm_wakeup_event(p->input->dev.parent, MAX_HELD_TIME);
-	input_report_key(p->input, KEY_POWER, 1);
-	input_sync(p->input);
+	pm_wakeup_event(input->dev.parent, MAX_HELD_TIME);
+	input_report_key(input, KEY_POWER, 1);
+	input_sync(input);
 
 	return IRQ_HANDLED;
 }
 
 static irqreturn_t hi65xx_power_release_isr(int irq, void *q)
 {
-	struct hi65xx_priv *p = q;
+	struct input_dev *input = q;
 
-	pm_wakeup_event(p->input->dev.parent, MAX_HELD_TIME);
-	input_report_key(p->input, KEY_POWER, 0);
-	input_sync(p->input);
+	pm_wakeup_event(input->dev.parent, MAX_HELD_TIME);
+	input_report_key(input, KEY_POWER, 0);
+	input_sync(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);
+	struct input_dev *input = q;
+	int value = test_bit(KEY_RESTART, input->key);
 
-	pm_wakeup_event(p->input->dev.parent, MAX_HELD_TIME);
-	input_report_key(p->input, KEY_RESTART, !value);
-	input_sync(p->input);
+	pm_wakeup_event(input->dev.parent, MAX_HELD_TIME);
+	input_report_key(input, KEY_RESTART, !value);
+	input_sync(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 const struct {
+	const char *name;
+	irqreturn_t (*handler)(int irq, void *q);
+} hi65xx_irq_info[] = {
+	{ "down", hi65xx_power_press_isr },
+	{ "up", hi65xx_power_release_isr },
+	{ "hold 4s", 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;
+	struct input_dev *input;
+	int irq, i, error;
 
-	priv->input = devm_input_allocate_device(&pdev->dev);
-	if (!priv->input) {
+	input = devm_input_allocate_device(&pdev->dev);
+	if (!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->phys = "hisi_on/input0";
+	input->name = "HISI 65xx PowerOn Key";
 
-	input_set_capability(priv->input, EV_KEY, KEY_POWER);
-	input_set_capability(priv->input, EV_KEY, KEY_RESTART);
+	input_set_capability(input, EV_KEY, KEY_POWER);
+	input_set_capability(input, EV_KEY, KEY_RESTART);
 
-	for (i = 0; i < ID_LAST; i++) {
+	for (i = 0; i < ARRAY_SIZE(hi65xx_irq_info); i++) {
 
-		irq = platform_get_irq_byname(pdev, irq_names[i]);
+		irq = platform_get_irq_byname(pdev, hi65xx_irq_info[i].name);
 		if (irq < 0) {
-			dev_err(dev, "couldn't get irq %s\n", irq_names[i]);
-			return irq;
+			error = irq;
+			dev_err(dev, "couldn't get irq %s: %d\n",
+				hi65xx_irq_info[i].name, error);
+			return error;
 		}
 
-		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;
+		error = devm_request_any_context_irq(dev, irq,
+						     hi65xx_irq_info[i].handler,
+						     IRQF_ONESHOT,
+						     hi65xx_irq_info[i].name,
+						     input);
+		if (error < 0) {
+			dev_err(dev, "couldn't request irq %s: %d\n",
+				hi65xx_irq_info[i].name, error);
+			return error;
 		}
 	}
 
-	ret = input_register_device(priv->input);
-	if (ret) {
+	error = input_register_device(input);
+	if (error) {
 		dev_err(&pdev->dev, "failed to register input device: %d\n",
-			ret);
-		return ret;
+			error);
+		return error;
 	}
 
-	platform_set_drvdata(pdev, priv);
 	device_init_wakeup(&pdev->dev, 1);
 
 	return 0;
@@ -129,6 +124,7 @@ static int hi65xx_powerkey_probe(struct platform_device *pdev)
 static int hi65xx_powerkey_remove(struct platform_device *pdev)
 {
 	device_init_wakeup(&pdev->dev, 0);
+
 	return 0;
 }
 
@@ -139,7 +135,6 @@ static struct platform_driver hi65xx_powerkey_driver = {
 	.probe = hi65xx_powerkey_probe,
 	.remove  = hi65xx_powerkey_remove,
 };
-
 module_platform_driver(hi65xx_powerkey_driver);
 
 MODULE_AUTHOR("Zhiliang Xue <[email protected]");
#4 lore raw

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

Quoted 30 lines · Dmitry Torokhov
Quoted 29 lines · John Stultz
Quoted 27 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 Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, implemented some larger cleanups suggested by DmitryT]

---
v2: Major rework integrating feedback from Dmitry.
v3: Dropped of_match compatible line since no longer using DT
for this.
v4: Removed MODULE_DEVICE_TABLE(of, hi65xx_powerkey_of_match) line
I missed in the last revision, which casued build issues w/ modules.

Quoted 8 lines
Quoted 5 lines

Hey Dmitry,
Just wanted to ping you to see if there was anything else you were
wanting changed with this patch. Lee has queued the mfd patches in -next, so I wanted to be sure to address any concerns you had that was keeping this from heading upstream in 4.8 (hopefully :).

Right, sorry, does the following look OK to you?

Yes! It looks great (and I tested it works too)!

Do you want to fold that in, or do you need me to re-submit with those changes?

thanks
-john

maintainer
#5 lore raw

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

Quoted 38 lines · John Stultz
Quoted 36 lines · Dmitry Torokhov
Quoted 34 lines · John Stultz
Quoted 19 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 Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, implemented some larger cleanups suggested by DmitryT]

Quoted 8 lines

---
v2: Major rework integrating feedback from Dmitry.
v3: Dropped of_match compatible line since no longer using DT
for this.
v4: Removed MODULE_DEVICE_TABLE(of, hi65xx_powerkey_of_match) line
I missed in the last revision, which casued build issues w/ modules.

Hey Dmitry,
Just wanted to ping you to see if there was anything else you were
wanting changed with this patch. Lee has queued the mfd patches in -next, so I wanted to be sure to address any concerns you had that was keeping this from heading upstream in 4.8 (hopefully :).

Quoted 6 lines
Quoted 2 lines

Right, sorry, does the following look OK to you?

Yes! It looks great (and I tested it works too)!

Do you want to fold that in, or do you need me to re-submit with those changes?

I'll fold it in on my side. Thank you for testing it!

Signature · 1 line
Dmitry
maintainer
#6 lore raw

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

Quoted 39 lines · Dmitry Torokhov
Quoted 38 lines · John Stultz
Quoted 36 lines · Dmitry Torokhov
Quoted 34 lines · John Stultz
Quoted 19 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 Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Reworked commit message, folded in other fixes/cleanups from Jorge, implemented some larger cleanups suggested by DmitryT]

Quoted 8 lines

---
v2: Major rework integrating feedback from Dmitry.
v3: Dropped of_match compatible line since no longer using DT
for this.
v4: Removed MODULE_DEVICE_TABLE(of, hi65xx_powerkey_of_match) line
I missed in the last revision, which casued build issues w/ modules.

Hey Dmitry,
Just wanted to ping you to see if there was anything else you were
wanting changed with this patch. Lee has queued the mfd patches in -next, so I wanted to be sure to address any concerns you had that was keeping this from heading upstream in 4.8 (hopefully :).

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Right, sorry, does the following look OK to you?

Yes! It looks great (and I tested it works too)!

Do you want to fold that in, or do you need me to re-submit with those changes?

I'll fold it in on my side. Thank you for testing it!

Changed the config symbol to INPUT_HISI_POWERKEY to match other symbols in drivers/input/misc and queued for the next merge window.

Thanks.

Signature · 1 line
Dmitry
#7 lore raw

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

Quoted 8 lines · Dmitry Torokhov
Quoted 7 lines · Dmitry Torokhov
Quoted 6 lines · John Stultz
Quoted 3 lines · Dmitry Torokhov

Right, sorry, does the following look OK to you?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Yes! It looks great (and I tested it works too)!

Do you want to fold that in, or do you need me to re-submit with those changes?

I'll fold it in on my side. Thank you for testing it!

Changed the config symbol to INPUT_HISI_POWERKEY to match other symbols in drivers/input/misc and queued for the next merge window.

Thanks, I really appreciate it, and apologies for missing so many things you had to fix up!
-john

maintainer
#8 lore raw

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

Quoted 14 lines · John Stultz
Quoted 12 lines · Dmitry Torokhov
Quoted 11 lines · Dmitry Torokhov
Quoted 9 lines · John Stultz
Quoted 3 lines · Dmitry Torokhov

Right, sorry, does the following look OK to you?

Yes! It looks great (and I tested it works too)!

Do you want to fold that in, or do you need me to re-submit with those changes?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I'll fold it in on my side. Thank you for testing it!

Changed the config symbol to INPUT_HISI_POWERKEY to match other symbols in drivers/input/misc and queued for the next merge window.

Thanks, I really appreciate it, and apologies for missing so many things you had to fix up!

It wasn't a big deal, it's mostly my OCD at play here ;)

Signature · 1 line
Dmitry
#9 lore raw

PATCH 2/4 mfd: 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 Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[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 05ddc78..68ab370 100644
@@ -45,6 +45,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
Applied
#10 lore raw

Re: [PATCH 2/4] mfd: hi655x-pmic: Fixup issue with un-acked interrupts

Quoted 18 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 Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[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(+)

Applied, thanks.

Quoted 12 lines
drivers/mfd/hi655x-pmic.c +1 -0
index 05ddc78..68ab370 100644
@@ -45,6 +45,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
#11 lore raw

PATCH 3/4 mfd: hi655x-pmic: Rename some interrupt macro names

In reply to John Stultz

Currently the hi655x-pmic driver has names for interrupt mask values, but not for the interrupt numbers themselves.

So to allow for interrupt numbers to have sane names, rename the mask values with the _MASK postfix and use the existing names as the interrupt name

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>
---
 drivers/mfd/hi655x-pmic.c       | 16 ++++++++--------
 include/linux/mfd/hi655x-pmic.h | 25 +++++++++++++++++--------
 2 files changed, 25 insertions(+), 16 deletions(-)
drivers/mfd/hi655x-pmic.c +8 -8
index 68ab370..072e6fe 100644
@@ -29,14 +29,14 @@ static const struct mfd_cell hi655x_pmic_devs[] = {
 };
 
 static const struct regmap_irq hi655x_irqs[] = {
-	{ .reg_offset = 0, .mask = OTMP_D1R_INT },
-	{ .reg_offset = 0, .mask = VSYS_2P5_R_INT },
-	{ .reg_offset = 0, .mask = VSYS_UV_D3R_INT },
-	{ .reg_offset = 0, .mask = VSYS_6P0_D200UR_INT },
-	{ .reg_offset = 0, .mask = PWRON_D4SR_INT },
-	{ .reg_offset = 0, .mask = PWRON_D20F_INT },
-	{ .reg_offset = 0, .mask = PWRON_D20R_INT },
-	{ .reg_offset = 0, .mask = RESERVE_INT },
+	{ .reg_offset = 0, .mask = OTMP_D1R_INT_MASK },
+	{ .reg_offset = 0, .mask = VSYS_2P5_R_INT_MASK },
+	{ .reg_offset = 0, .mask = VSYS_UV_D3R_INT_MASK },
+	{ .reg_offset = 0, .mask = VSYS_6P0_D200UR_INT_MASK },
+	{ .reg_offset = 0, .mask = PWRON_D4SR_INT_MASK },
+	{ .reg_offset = 0, .mask = PWRON_D20F_INT_MASK },
+	{ .reg_offset = 0, .mask = PWRON_D20R_INT_MASK },
+	{ .reg_offset = 0, .mask = RESERVE_INT_MASK },
 };
 
 static const struct regmap_irq_chip hi655x_irq_chip = {
include/linux/mfd/hi655x-pmic.h +17 -8
index dbbe9a6..62f03c2 100644
@@ -34,14 +34,23 @@
 #define PMU_VER_START                   0x10
 #define PMU_VER_END                     0x38
 
-#define RESERVE_INT                     BIT(7)
-#define PWRON_D20R_INT                  BIT(6)
-#define PWRON_D20F_INT                  BIT(5)
-#define PWRON_D4SR_INT                  BIT(4)
-#define VSYS_6P0_D200UR_INT             BIT(3)
-#define VSYS_UV_D3R_INT                 BIT(2)
-#define VSYS_2P5_R_INT                  BIT(1)
-#define OTMP_D1R_INT                    BIT(0)
+#define RESERVE_INT                     7
+#define PWRON_D20R_INT                  6
+#define PWRON_D20F_INT                  5
+#define PWRON_D4SR_INT                  4
+#define VSYS_6P0_D200UR_INT             3
+#define VSYS_UV_D3R_INT                 2
+#define VSYS_2P5_R_INT                  1
+#define OTMP_D1R_INT                    0
+
+#define RESERVE_INT_MASK                BIT(RESERVE_INT)
+#define PWRON_D20R_INT_MASK             BIT(PWRON_D20R_INT)
+#define PWRON_D20F_INT_MASK             BIT(PWRON_D20F_INT)
+#define PWRON_D4SR_INT_MASK             BIT(PWRON_D4SR_INT)
+#define VSYS_6P0_D200UR_INT_MASK        BIT(VSYS_6P0_D200UR_INT)
+#define VSYS_UV_D3R_INT_MASK            BIT(VSYS_UV_D3R_INT)
+#define VSYS_2P5_R_INT_MASK             BIT(VSYS_2P5_R_INT)
+#define OTMP_D1R_INT_MASK               BIT(OTMP_D1R_INT)
 
 struct hi655x_pmic {
 	struct resource *res;
Signature · 1 line
1.9.1
Applied
#12 lore raw

Re: [PATCH 3/4] mfd: hi655x-pmic: Rename some interrupt macro names

Quoted 15 lines · John Stultz

Currently the hi655x-pmic driver has names for interrupt mask values, but not for the interrupt numbers themselves.

So to allow for interrupt numbers to have sane names, rename the mask values with the _MASK postfix and use the existing names as the interrupt name

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>
Quoted 4 lines
---
 drivers/mfd/hi655x-pmic.c       | 16 ++++++++--------
 include/linux/mfd/hi655x-pmic.h | 25 +++++++++++++++++--------
 2 files changed, 25 insertions(+), 16 deletions(-)

Applied, thanks.

Quoted 63 lines
drivers/mfd/hi655x-pmic.c +8 -8
index 68ab370..072e6fe 100644
@@ -29,14 +29,14 @@ static const struct mfd_cell hi655x_pmic_devs[] = {
 };
 
 static const struct regmap_irq hi655x_irqs[] = {
-	{ .reg_offset = 0, .mask = OTMP_D1R_INT },
-	{ .reg_offset = 0, .mask = VSYS_2P5_R_INT },
-	{ .reg_offset = 0, .mask = VSYS_UV_D3R_INT },
-	{ .reg_offset = 0, .mask = VSYS_6P0_D200UR_INT },
-	{ .reg_offset = 0, .mask = PWRON_D4SR_INT },
-	{ .reg_offset = 0, .mask = PWRON_D20F_INT },
-	{ .reg_offset = 0, .mask = PWRON_D20R_INT },
-	{ .reg_offset = 0, .mask = RESERVE_INT },
+	{ .reg_offset = 0, .mask = OTMP_D1R_INT_MASK },
+	{ .reg_offset = 0, .mask = VSYS_2P5_R_INT_MASK },
+	{ .reg_offset = 0, .mask = VSYS_UV_D3R_INT_MASK },
+	{ .reg_offset = 0, .mask = VSYS_6P0_D200UR_INT_MASK },
+	{ .reg_offset = 0, .mask = PWRON_D4SR_INT_MASK },
+	{ .reg_offset = 0, .mask = PWRON_D20F_INT_MASK },
+	{ .reg_offset = 0, .mask = PWRON_D20R_INT_MASK },
+	{ .reg_offset = 0, .mask = RESERVE_INT_MASK },
 };
 
 static const struct regmap_irq_chip hi655x_irq_chip = {
include/linux/mfd/hi655x-pmic.h +17 -8
index dbbe9a6..62f03c2 100644
@@ -34,14 +34,23 @@
 #define PMU_VER_START                   0x10
 #define PMU_VER_END                     0x38
 
-#define RESERVE_INT                     BIT(7)
-#define PWRON_D20R_INT                  BIT(6)
-#define PWRON_D20F_INT                  BIT(5)
-#define PWRON_D4SR_INT                  BIT(4)
-#define VSYS_6P0_D200UR_INT             BIT(3)
-#define VSYS_UV_D3R_INT                 BIT(2)
-#define VSYS_2P5_R_INT                  BIT(1)
-#define OTMP_D1R_INT                    BIT(0)
+#define RESERVE_INT                     7
+#define PWRON_D20R_INT                  6
+#define PWRON_D20F_INT                  5
+#define PWRON_D4SR_INT                  4
+#define VSYS_6P0_D200UR_INT             3
+#define VSYS_UV_D3R_INT                 2
+#define VSYS_2P5_R_INT                  1
+#define OTMP_D1R_INT                    0
+
+#define RESERVE_INT_MASK                BIT(RESERVE_INT)
+#define PWRON_D20R_INT_MASK             BIT(PWRON_D20R_INT)
+#define PWRON_D20F_INT_MASK             BIT(PWRON_D20F_INT)
+#define PWRON_D4SR_INT_MASK             BIT(PWRON_D4SR_INT)
+#define VSYS_6P0_D200UR_INT_MASK        BIT(VSYS_6P0_D200UR_INT)
+#define VSYS_UV_D3R_INT_MASK            BIT(VSYS_UV_D3R_INT)
+#define VSYS_2P5_R_INT_MASK             BIT(VSYS_2P5_R_INT)
+#define OTMP_D1R_INT_MASK               BIT(OTMP_D1R_INT)
 
 struct hi655x_pmic {
 	struct resource *res;
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#13 lore raw

PATCH 4/4 mfd: hi655x-pmic: Add powerkey device to hi655x PMIC driver

In reply to John Stultz

Wire up the powerkey driver functionality for the hi655x PMIC.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>

---
v4: Cleaned up magic values and realigned regulator entry to be
a onliner

 drivers/mfd/hi655x-pmic.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)
drivers/mfd/hi655x-pmic.c +30 -5
index 072e6fe..e955a0c 100644
@@ -24,10 +24,6 @@
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 
-static const struct mfd_cell hi655x_pmic_devs[] = {
-	{ .name = "hi655x-regulator", },
-};
-
 static const struct regmap_irq hi655x_irqs[] = {
 	{ .reg_offset = 0, .mask = OTMP_D1R_INT_MASK },
 	{ .reg_offset = 0, .mask = VSYS_2P5_R_INT_MASK },
@@ -56,6 +52,34 @@ static struct regmap_config hi655x_regmap_config = {
 	.max_register = HI655X_BUS_ADDR(0xFFF),
 };
 
+static struct resource pwrkey_resources[] = {
+	{
+		.name	= "down",
+		.start	= PWRON_D20R_INT,
+		.end	= PWRON_D20R_INT,
+		.flags	= IORESOURCE_IRQ,
+	}, {
+		.name	= "up",
+		.start	= PWRON_D20F_INT,
+		.end	= PWRON_D20F_INT,
+		.flags	= IORESOURCE_IRQ,
+	}, {
+		.name	= "hold 4s",
+		.start	= PWRON_D4SR_INT,
+		.end	= PWRON_D4SR_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static const struct mfd_cell hi655x_pmic_devs[] = {
+	{
+		.name		= "hi65xx-powerkey",
+		.num_resources	= ARRAY_SIZE(pwrkey_resources),
+		.resources	= &pwrkey_resources[0],
+	},
+	{	.name		= "hi655x-regulator", },
+};
+
 static void hi655x_local_irq_clear(struct regmap *map)
 {
 	int i;
@@ -124,7 +148,8 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, pmic);
 
 	ret = mfd_add_devices(dev, PLATFORM_DEVID_AUTO, hi655x_pmic_devs,
-			      ARRAY_SIZE(hi655x_pmic_devs), NULL, 0, NULL);
+			      ARRAY_SIZE(hi655x_pmic_devs), NULL, 0,
+			      regmap_irq_get_domain(pmic->irq_data));
 	if (ret) {
 		dev_err(dev, "Failed to register device %d\n", ret);
 		regmap_del_irq_chip(gpio_to_irq(pmic->gpio), pmic->irq_data);
Signature · 1 line
1.9.1
Applied
#14 lore raw

Re: [PATCH 4/4] mfd: hi655x-pmic: Add powerkey device to hi655x PMIC driver

Quoted 10 lines · John Stultz

Wire up the powerkey driver functionality for the hi655x PMIC.

Cc Dmitry Torokhov <[email protected]>
Cc Rob Herring <[email protected]>
Cc Lee Jones <[email protected]>
Cc Jorge Ramirez-Ortiz <[email protected]>
Cc Feng Chen <[email protected]>
Cc Wei Xu <[email protected]>
Cc Guodong Xu <[email protected]>
Quoted 6 lines

---
v4: Cleaned up magic values and realigned regulator entry to be
a onliner

 drivers/mfd/hi655x-pmic.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

Applied, thanks.

Quoted 60 lines
drivers/mfd/hi655x-pmic.c +30 -5
index 072e6fe..e955a0c 100644
@@ -24,10 +24,6 @@
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 
-static const struct mfd_cell hi655x_pmic_devs[] = {
-	{ .name = "hi655x-regulator", },
-};
-
 static const struct regmap_irq hi655x_irqs[] = {
 	{ .reg_offset = 0, .mask = OTMP_D1R_INT_MASK },
 	{ .reg_offset = 0, .mask = VSYS_2P5_R_INT_MASK },
@@ -56,6 +52,34 @@ static struct regmap_config hi655x_regmap_config = {
 	.max_register = HI655X_BUS_ADDR(0xFFF),
 };
 
+static struct resource pwrkey_resources[] = {
+	{
+		.name	= "down",
+		.start	= PWRON_D20R_INT,
+		.end	= PWRON_D20R_INT,
+		.flags	= IORESOURCE_IRQ,
+	}, {
+		.name	= "up",
+		.start	= PWRON_D20F_INT,
+		.end	= PWRON_D20F_INT,
+		.flags	= IORESOURCE_IRQ,
+	}, {
+		.name	= "hold 4s",
+		.start	= PWRON_D4SR_INT,
+		.end	= PWRON_D4SR_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static const struct mfd_cell hi655x_pmic_devs[] = {
+	{
+		.name		= "hi65xx-powerkey",
+		.num_resources	= ARRAY_SIZE(pwrkey_resources),
+		.resources	= &pwrkey_resources[0],
+	},
+	{	.name		= "hi655x-regulator", },
+};
+
 static void hi655x_local_irq_clear(struct regmap *map)
 {
 	int i;
@@ -124,7 +148,8 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, pmic);
 
 	ret = mfd_add_devices(dev, PLATFORM_DEVID_AUTO, hi655x_pmic_devs,
-			      ARRAY_SIZE(hi655x_pmic_devs), NULL, 0, NULL);
+			      ARRAY_SIZE(hi655x_pmic_devs), NULL, 0,
+			      regmap_irq_get_domain(pmic->irq_data));
 	if (ret) {
 		dev_err(dev, "Failed to register device %d\n", ret);
 		regmap_del_irq_chip(gpio_to_irq(pmic->gpio), pmic->irq_data);
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog