Skip to contentSkip to conversation

Support TPS65217 PMIC interrupt in DT

PATCH In review Milo Kim 3 participants 13 messages Oct 28, 2016 – Nov 21, 2016

Subsystems (2)
lore
Share & tools
lore

Milo Kim

author
#0 lore raw

v2 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.

v2:
Add missing a dt-binding header
Use #defines instead of enum type for interrupt numbers

Milo Kim (8):
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
dt-bindings: mfd: Provide human readable defines for TPS65217
interrupts
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/dt-bindings/mfd/tps65217.h        | 26 ++++++++++++++++++++++++++
 include/linux/mfd/tps65217.h              | 11 +++++------
 4 files changed, 60 insertions(+), 6 deletions(-)
 create mode 100644 include/dt-bindings/mfd/tps65217.h
Signature · 1 line
2.9.3
author
#1 lore raw

PATCH v2 1/8 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 v2 2/8 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 v2 3/8 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 v2 4/8 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 v2 5/8 dt-bindings: mfd: Provide human readable defines for TPS65217 interrupts

In reply to Milo Kim

TPS65217 supports three interrupt sources. This patch enables assigning each IRQ number in the charger and power button node. Then corresponding IRQ will be requested by each driver.

---
 include/dt-bindings/mfd/tps65217.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 include/dt-bindings/mfd/tps65217.h
include/dt-bindings/mfd/tps65217.h new file +26 -0
new file mode 100644
index 0000000..cafb9e6
@@ -0,0 +1,26 @@
+/*
+ * This header provides macros for TI TPS65217 DT bindings.
+ *
+ * Copyright (C) 2016 Texas Instruments
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#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
+
+#endif
Signature · 1 line
2.9.3
#6 lore raw

Re: [PATCH v2 5/8] dt-bindings: mfd: Provide human readable defines for TPS65217 interrupts

Quoted 30 lines · Milo Kim

TPS65217 supports three interrupt sources. This patch enables assigning each IRQ number in the charger and power button node. Then corresponding IRQ will be requested by each driver.

---
 include/dt-bindings/mfd/tps65217.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 include/dt-bindings/mfd/tps65217.h
include/dt-bindings/mfd/tps65217.h new file +14 -0
new file mode 100644
index 0000000..cafb9e6
@@ -0,0 +1,26 @@
+/*
+ * This header provides macros for TI TPS65217 DT bindings.
+ *
+ * Copyright (C) 2016 Texas Instruments
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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/dt-bindings/mfd/tps65217.h line 24

Quoted 10 lines
include/dt-bindings/mfd/tps65217.h new file +10 -0
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#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

What are "AC" and "PB". Seeing as these are meant to be "human readable", let's make them more human friendly.

Quoted 1 line
include/dt-bindings/mfd/tps65217.h new file +1 -0
+#endif
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#7 lore raw

Re: [PATCH v2 5/8] dt-bindings: mfd: Provide human readable defines for TPS65217 interrupts

Quoted 37 lines · Lee Jones
Quoted 35 lines · Milo Kim

TPS65217 supports three interrupt sources. This patch enables assigning each IRQ number in the charger and power button node. Then corresponding IRQ will be requested by each driver.

---
 include/dt-bindings/mfd/tps65217.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 include/dt-bindings/mfd/tps65217.h
include/dt-bindings/mfd/tps65217.h new file +19 -0
new file mode 100644
index 0000000..cafb9e6
@@ -0,0 +1,26 @@
+/*
+ * This header provides macros for TI TPS65217 DT bindings.
+ *
+ * Copyright (C) 2016 Texas Instruments
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __DT_BINDINGS_TPS65217_H__
Quoted 8 lines

include/dt-bindings/mfd/tps65217.h line 24

Quoted 5 lines
include/dt-bindings/mfd/tps65217.h new file +5 -0
+#define __DT_BINDINGS_TPS65217_H__
+
+#define TPS65217_IRQ_USB	0
+#define TPS65217_IRQ_AC		1
+#define TPS65217_IRQ_PB		2

What are "AC" and "PB". Seeing as these are meant to be "human readable", let's make them more human friendly.

Good idea. Milo, please do an incremental single follow-up patch as I already have applied this and the dts changes using it.

Regards,

Tony

author
#8 lore raw

Re: [PATCH v2 5/8] dt-bindings: mfd: Provide human readable defines for TPS65217 interrupts

Quoted 8 lines · Tony Lindgren
Quoted 6 lines
Quoted 6 lines

+#define TPS65217_IRQ_USB 0

Quoted 2 lines

include/dt-bindings/mfd/tps65217.h line 24

Quoted 2 lines
include/dt-bindings/mfd/tps65217.h new file +2 -0
+#define TPS65217_IRQ_AC		1
+#define TPS65217_IRQ_PB		2

What are "AC" and "PB". Seeing as these are meant to be "human readable", let's make them more human friendly.

Good idea. Milo, please do an incremental single follow-up patch as I already have applied this and the dts changes using it.

Thanks for catching this. Let me send a patch soon.

Best regards,
Milo

author
#9 lore raw

PATCH v2 6/8 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
author
#10 lore raw

PATCH v2 7/8 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
#11 lore raw

PATCH v2 8/8 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 defines synchronized IRQ value.

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

---
 include/linux/mfd/tps65217.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
include/linux/mfd/tps65217.h +5 -6
index 4ccda89..3cbec4b 100644
@@ -234,12 +234,11 @@ struct tps65217_bl_pdata {
 	int dft_brightness;
 };
 
-enum tps65217_irq_type {
-	TPS65217_IRQ_PB,
-	TPS65217_IRQ_AC,
-	TPS65217_IRQ_USB,
-	TPS65217_NUM_IRQ
-};
+/* Interrupt numbers */
+#define TPS65217_IRQ_USB		0
+#define TPS65217_IRQ_AC			1
+#define TPS65217_IRQ_PB			2
+#define TPS65217_NUM_IRQ		3
 
 /**
  * struct tps65217_board - packages regulator init data
Signature · 1 line
2.9.3
#12 lore raw
In reply to Milo Kim
Quoted 5 lines · Milo Kim

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.

Applying into omap-for-v4.10/dt except the last patch I'll apply into omap-for-v4.10/fixes-not-urgent.

Regards,

Tony