Skip to contentSkip to conversation

Support TPS65217 PMIC interrupt in DT

PATCH Superseded Milo Kim 3 participants 13 messages Oct 21, 2016 – Oct 28, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Milo Kim

author
#0 lore raw

cover Support TPS65217 PMIC interrupt in DT

TPS65217 interrupt events include push button pressed/released, USB and AC voltage status change. AM335x bone based boards (like BB, BBB, BBG) have common PMIC interrupt pin (named NMI) of AM335x core.

This patchset support interrupts in device tree file.

Milo Kim (7):
ARM: dts: tps65217: Specify the interrupt controller
ARM: dts: tps65217: Add the charger device
ARM: dts: tps65217: Add the power button device
ARM: dts: am335x: Support the PMIC interrupt
ARM: dts: am335x: Add the charger interrupt
ARM: dts: am335x: Add the power button interrupt
mfd: tps65217: Fix mismatched interrupt number

 arch/arm/boot/dts/am335x-bone-common.dtsi | 17 +++++++++++++++++
 arch/arm/boot/dts/tps65217.dtsi           | 12 ++++++++++++
 include/linux/mfd/tps65217.h              |  4 ++--
 3 files changed, 31 insertions(+), 2 deletions(-)
Signature · 1 line
2.9.3
author
#1 lore raw

PATCH 1/7 ARM: dts: tps65217: Specify the interrupt controller

TPS65217 MFD driver supports the IRQ domain to handle the charger input interrupts and push button status event. The interrupt controller enables corresponding IRQ handling in the charger[*] and power button driver[**].

[*] drivers/power/supply/tps65217_charger.c
[**] drivers/input/misc/tps65218-pwrbutton.c

---
 arch/arm/boot/dts/tps65217.dtsi | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/boot/dts/tps65217.dtsi +2 -0
index a632724..27935f8 100644
@@ -13,6 +13,8 @@
 
 &tps {
 	compatible = "ti,tps65217";
+	interrupt-controller;
+	#interrupt-cells = <1>;
 
 	regulators {
 		#address-cells = <1>;
Signature · 1 line
2.9.3
author
#2 lore raw

PATCH 2/7 ARM: dts: tps65217: Add the charger device

In reply to Milo Kim

Support the charger driver and disable it by default.

---
 arch/arm/boot/dts/tps65217.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/tps65217.dtsi +5 -0
index 27935f8..8f77d0d 100644
@@ -16,6 +16,11 @@
 	interrupt-controller;
 	#interrupt-cells = <1>;
 
+	charger {
+		compatible = "ti,tps65217-charger";
+		status = "disabled";
+	};
+
 	regulators {
 		#address-cells = <1>;
 		#size-cells = <0>;
Signature · 1 line
2.9.3
author
#3 lore raw

PATCH 3/7 ARM: dts: tps65217: Add the power button device

In reply to Milo Kim

Support the power button driver and disable it by default.

---
 arch/arm/boot/dts/tps65217.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/tps65217.dtsi +5 -0
index 8f77d0d..02de56b 100644
@@ -21,6 +21,11 @@
 		status = "disabled";
 	};
 
+	pwrbutton {
+		compatible = "ti,tps65217-pwrbutton";
+		status = "disabled";
+	};
+
 	regulators {
 		#address-cells = <1>;
 		#size-cells = <0>;
Signature · 1 line
2.9.3
author
#4 lore raw

PATCH 4/7 ARM: dts: am335x: Support the PMIC interrupt

In reply to Milo Kim

AM335x bone based boards have the PMIC interrupt named NMI which is connected to TPS65217 device. AM335x main interrupt controller provides it and the number is 7.

---
 arch/arm/boot/dts/am335x-bone-common.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/am335x-bone-common.dtsi +4 -0
index 007b5e5..25303d9 100644
@@ -310,6 +310,10 @@
 	 * by the hardware problems. (Tip: double-check by performing a current
 	 * measurement after shutdown: it should be less than 1 mA.)
 	 */
+
+	interrupts = <7>; /* NMI */
+	interrupt-parent = <&intc>;
+
 	ti,pmic-shutdown-controller;
 
 	regulators {
Signature · 1 line
2.9.3
author
#5 lore raw

PATCH 5/7 ARM: dts: am335x: Add the charger interrupt

In reply to Milo Kim

This enables the charger driver gets corresponding IRQ number by using platform_get_irq_byname() helper.

---
 arch/arm/boot/dts/am335x-bone-common.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/am335x-bone-common.dtsi +8 -0
index 25303d9..cec9d91 100644
@@ -6,6 +6,8 @@
  * published by the Free Software Foundation.
  */
 
+#include <dt-bindings/mfd/tps65217.h>
+
 / {
 	cpus {
 		cpu at 0 {
@@ -316,6 +318,12 @@
 
 	ti,pmic-shutdown-controller;
 
+	charger {
+		interrupts = <TPS65217_IRQ_AC>, <TPS65217_IRQ_USB>;
+		interrupts-names = "AC", "USB";
+		status = "okay";
+	};
+
 	regulators {
 		dcdc1_reg: regulator at 0 {
 			regulator-name = "vdds_dpr";
Signature · 1 line
2.9.3
#6 lore raw

Re: [PATCH 5/7] ARM: dts: am335x: Add the charger interrupt

Quoted 13 lines · Milo Kim

This enables the charger driver gets corresponding IRQ number by using platform_get_irq_byname() helper.

---
 arch/arm/boot/dts/am335x-bone-common.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/am335x-bone-common.dtsi +0 -0
index 25303d9..cec9d91 100644

arch/arm/boot/dts/am335x-bone-common.dtsi line 9

Quoted 4 lines
arch/arm/boot/dts/am335x-bone-common.dtsi +1 -0
@@ -6,6 +6,8 @@
  * published by the Free Software Foundation.
  */
 
+#include <dt-bindings/mfd/tps65217.h>

^ this hasn't been posted nor pushed to mainline yet.. ;)

Quoted 24 lines
arch/arm/boot/dts/am335x-bone-common.dtsi +7 -1
+
 / {
        cpus {
                cpu at 0 {
@@ -316,6 +318,12 @@
 
        ti,pmic-shutdown-controller;
 
+       charger {
+               interrupts = <TPS65217_IRQ_AC>, <TPS65217_IRQ_USB>;
+               interrupts-names = "AC", "USB";
+               status = "okay";
+       };
+
        regulators {
                dcdc1_reg: regulator at 0 {
                        regulator-name = "vdds_dpr";
--

2.9.3

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Robert Nelson
https://rcn-ee.com/
#7 lore raw

Re: [PATCH 5/7] ARM: dts: am335x: Add the charger interrupt

Quoted 17 lines · Robert Nelson
Quoted 16 lines · Milo Kim

This enables the charger driver gets corresponding IRQ number by using platform_get_irq_byname() helper.

---
 arch/arm/boot/dts/am335x-bone-common.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/am335x-bone-common.dtsi +0 -0
index 25303d9..cec9d91 100644
@@ -6,6 +6,8 @@
  * published by the Free Software Foundation.
  */
 
Quoted 3 lines

arch/arm/boot/dts/am335x-bone-common.dtsi line 9

Quoted 1 line
arch/arm/boot/dts/am335x-bone-common.dtsi +1 -0
+#include <dt-bindings/mfd/tps65217.h>

^ this hasn't been posted nor pushed to mainline yet.. ;)

So, with this patchset + Keerthy's [RESEND PATCH v8 0/5] mfd:
tps65218: Clean ups:

https://www.mail-archive.com/linux-kernel at vger.kernel.org/msg1250918.html

and this patch, as systemd is looking for "tps65217_pwr_but"..

https://github.com/systemd/systemd/blob/master/src/login/70-power-switch.rules#L13

Shutdown is working on my BBB/BBG/BBGW/BBBW's...

(quoted diff) +0 -0

b/drivers/input/misc/tps65218-pwrbutton.c
index cc74a41..f7e5492 100644

drivers/input/misc/tps65218-pwrbutton.c +1 -1
@@ -36,7 +36,7 @@ struct tps6521x_data {
 static const struct tps6521x_data tps65217_data = {
  .reg_status = TPS65217_REG_STATUS,
  .pb_mask = TPS65217_STATUS_PB,
- .name = "tps65217_pwrbutton",
+ .name = "tps65217_pwr_but",
 };
 
 static const struct tps6521x_data tps65218_data = {
(quoted diff) +0 -0

b/include/dt-bindings/mfd/tps65217.h
new file mode 100644
index 0000000..26b2ba8

include/dt-bindings/mfd/tps65217.h new file +9 -0
@@ -0,0 +1,9 @@
+#ifndef __DT_BINDINGS_TPS65217_H
+#define __DT_BINDINGS_TPS65217_H
+
+#define TPS65217_IRQ_USB 0
+#define TPS65217_IRQ_AC 1
+#define TPS65217_IRQ_PB 2
+#define TPS65217_NUM_IRQ 3
+
+#endif /* __DT_BINDINGS_TPS65217_H */

Regards,

Signature · 2 lines
Robert Nelson
https://rcn-ee.com/
author
#8 lore raw

Re: [PATCH 5/7] ARM: dts: am335x: Add the charger interrupt

In reply to Robert Nelson
Quoted 3 lines · Robert Nelson
Quoted 1 line

+#include <dt-bindings/mfd/tps65217.h>

^ this hasn't been posted nor pushed to mainline yet.. ;)

Oops! I've created this file but not captured not only in my git tree but also in my head! Thanks for your review.

Best regards,
Milo

author
#9 lore raw

PATCH 6/7 ARM: dts: am335x: Add the power button interrupt

In reply to Milo Kim

This enables the power button driver gets corresponding IRQ number by using platform_get_irq().

---
 arch/arm/boot/dts/am335x-bone-common.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/am335x-bone-common.dtsi +5 -0
index cec9d91..0c0a90c 100644
@@ -324,6 +324,11 @@
 		status = "okay";
 	};
 
+	pwrbutton {
+		interrupts = <TPS65217_IRQ_PB>;
+		status = "okay";
+	};
+
 	regulators {
 		dcdc1_reg: regulator at 0 {
 			regulator-name = "vdds_dpr";
Signature · 1 line
2.9.3
author
#10 lore raw

PATCH 7/7 mfd: tps65217: Fix mismatched interrupt number

In reply to Milo Kim

Enum value of 'tps65217_irq_type' is not matched with DT parsed hwirq number[*].

The MFD driver gets the IRQ data by referencing hwirq, but the value is different. So, irq_to_tps65217_irq() returns mismatched IRQ data. Eventually, the power button driver enables not PB but USB interrupt when it is probed.

According to the TPS65217 register map[**], USB interrupt is the LSB. This patch synchronizes TPS65217 IRQ index.

[*] include/dt-bindings/mfd/tps65217.h [**] http://www.ti.com/lit/ds/symlink/tps65217.pdf

---
 include/linux/mfd/tps65217.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mfd/tps65217.h +2 -2
index 4ccda89..75a3a5f 100644
@@ -235,9 +235,9 @@ struct tps65217_bl_pdata {
 };
 
 enum tps65217_irq_type {
-	TPS65217_IRQ_PB,
-	TPS65217_IRQ_AC,
 	TPS65217_IRQ_USB,
+	TPS65217_IRQ_AC,
+	TPS65217_IRQ_PB,
 	TPS65217_NUM_IRQ
 };
 
Signature · 1 line
2.9.3
#11 lore raw

Re: [PATCH 7/7] mfd: tps65217: Fix mismatched interrupt number

Quoted 24 lines · Milo Kim

Enum value of 'tps65217_irq_type' is not matched with DT parsed hwirq number[*].

The MFD driver gets the IRQ data by referencing hwirq, but the value is different. So, irq_to_tps65217_irq() returns mismatched IRQ data. Eventually, the power button driver enables not PB but USB interrupt when it is probed.

According to the TPS65217 register map[**], USB interrupt is the LSB. This patch synchronizes TPS65217 IRQ index.

[*] include/dt-bindings/mfd/tps65217.h [**] http://www.ti.com/lit/ds/symlink/tps65217.pdf

---
 include/linux/mfd/tps65217.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mfd/tps65217.h +0 -0
index 4ccda89..75a3a5f 100644

include/linux/mfd/tps65217.h struct tps65217_bl_pdata { · line 242

Quoted 10 lines
include/linux/mfd/tps65217.h +2 -2
@@ -235,9 +235,9 @@ struct tps65217_bl_pdata {
 };
 
 enum tps65217_irq_type {
-	TPS65217_IRQ_PB,
-	TPS65217_IRQ_AC,
 	TPS65217_IRQ_USB,
+	TPS65217_IRQ_AC,
+	TPS65217_IRQ_PB,
 	TPS65217_NUM_IRQ
 };

This is why using enum for these types of assignments is sometimes dangerous. It's probably best to be explicit.

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

Re: [PATCH 7/7] mfd: tps65217: Fix mismatched interrupt number

Quoted 7 lines · Lee Jones
Quoted 7 lines
include/linux/mfd/tps65217.h +0 -0
Quoted 6 lines

index 4ccda89..75a3a5f 100644

include/linux/mfd/tps65217.h +0 -0
@@ -235,9 +235,9 @@ struct tps65217_bl_pdata {
 };
 
Quoted 10 lines
Quoted 8 lines

include/linux/mfd/tps65217.h struct tps65217_bl_pdata { · line 242

Quoted 8 lines
include/linux/mfd/tps65217.h +2 -2
 enum tps65217_irq_type {
-	TPS65217_IRQ_PB,
-	TPS65217_IRQ_AC,
 	TPS65217_IRQ_USB,
+	TPS65217_IRQ_AC,
+	TPS65217_IRQ_PB,
 	TPS65217_NUM_IRQ
 };

This is why using enum for these types of assignments is sometimes dangerous. It's probably best to be explicit.

I agree with you. Let me fix in v2 - use #define instead of enum type.

Best regards,
Milo