2016-10-21 14:02:05

by Milo Kim

[permalink] [raw]
Subject: [PATCH 0/7] 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(-)

--
2.9.3


2016-10-21 14:02:09

by Milo Kim

[permalink] [raw]
Subject: [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

Signed-off-by: Milo Kim <[email protected]>
---
arch/arm/boot/dts/tps65217.dtsi | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/tps65217.dtsi b/arch/arm/boot/dts/tps65217.dtsi
index a632724..27935f8 100644
--- a/arch/arm/boot/dts/tps65217.dtsi
+++ b/arch/arm/boot/dts/tps65217.dtsi
@@ -13,6 +13,8 @@

&tps {
compatible = "ti,tps65217";
+ interrupt-controller;
+ #interrupt-cells = <1>;

regulators {
#address-cells = <1>;
--
2.9.3

2016-10-21 14:02:19

by Milo Kim

[permalink] [raw]
Subject: [PATCH 4/7] ARM: dts: am335x: Support the PMIC interrupt

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.

Signed-off-by: Milo Kim <[email protected]>
---
arch/arm/boot/dts/am335x-bone-common.dtsi | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
index 007b5e5..25303d9 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -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 {
--
2.9.3

2016-10-21 14:02:13

by Milo Kim

[permalink] [raw]
Subject: [PATCH 2/7] ARM: dts: tps65217: Add the charger device

Support the charger driver and disable it by default.

Signed-off-by: Milo Kim <[email protected]>
---
arch/arm/boot/dts/tps65217.dtsi | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/tps65217.dtsi b/arch/arm/boot/dts/tps65217.dtsi
index 27935f8..8f77d0d 100644
--- a/arch/arm/boot/dts/tps65217.dtsi
+++ b/arch/arm/boot/dts/tps65217.dtsi
@@ -16,6 +16,11 @@
interrupt-controller;
#interrupt-cells = <1>;

+ charger {
+ compatible = "ti,tps65217-charger";
+ status = "disabled";
+ };
+
regulators {
#address-cells = <1>;
#size-cells = <0>;
--
2.9.3

2016-10-21 14:02:30

by Milo Kim

[permalink] [raw]
Subject: [PATCH 7/7] mfd: tps65217: Fix mismatched interrupt number

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

Signed-off-by: Milo Kim <[email protected]>
---
include/linux/mfd/tps65217.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h
index 4ccda89..75a3a5f 100644
--- a/include/linux/mfd/tps65217.h
+++ b/include/linux/mfd/tps65217.h
@@ -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
};

--
2.9.3

2016-10-21 14:02:27

by Milo Kim

[permalink] [raw]
Subject: [PATCH 6/7] ARM: dts: am335x: Add the power button interrupt

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

Signed-off-by: Milo Kim <[email protected]>
---
arch/arm/boot/dts/am335x-bone-common.dtsi | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
index cec9d91..0c0a90c 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -324,6 +324,11 @@
status = "okay";
};

+ pwrbutton {
+ interrupts = <TPS65217_IRQ_PB>;
+ status = "okay";
+ };
+
regulators {
dcdc1_reg: regulator@0 {
regulator-name = "vdds_dpr";
--
2.9.3

2016-10-21 14:03:13

by Milo Kim

[permalink] [raw]
Subject: [PATCH 5/7] ARM: dts: am335x: Add the charger interrupt

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

Signed-off-by: Milo Kim <[email protected]>
---
arch/arm/boot/dts/am335x-bone-common.dtsi | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
index 25303d9..cec9d91 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -6,6 +6,8 @@
* published by the Free Software Foundation.
*/

+#include <dt-bindings/mfd/tps65217.h>
+
/ {
cpus {
cpu@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@0 {
regulator-name = "vdds_dpr";
--
2.9.3

2016-10-21 14:03:29

by Milo Kim

[permalink] [raw]
Subject: [PATCH 3/7] ARM: dts: tps65217: Add the power button device

Support the power button driver and disable it by default.

Signed-off-by: Milo Kim <[email protected]>
---
arch/arm/boot/dts/tps65217.dtsi | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/tps65217.dtsi b/arch/arm/boot/dts/tps65217.dtsi
index 8f77d0d..02de56b 100644
--- a/arch/arm/boot/dts/tps65217.dtsi
+++ b/arch/arm/boot/dts/tps65217.dtsi
@@ -21,6 +21,11 @@
status = "disabled";
};

+ pwrbutton {
+ compatible = "ti,tps65217-pwrbutton";
+ status = "disabled";
+ };
+
regulators {
#address-cells = <1>;
#size-cells = <0>;
--
2.9.3

2016-10-21 20:48:36

by Robert Nelson

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

On Fri, Oct 21, 2016 at 9:01 AM, Milo Kim <[email protected]> wrote:
> This enables the charger driver gets corresponding IRQ number by using
> platform_get_irq_byname() helper.
>
> Signed-off-by: Milo Kim <[email protected]>
> ---
> arch/arm/boot/dts/am335x-bone-common.dtsi | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
> index 25303d9..cec9d91 100644
> --- a/arch/arm/boot/dts/am335x-bone-common.dtsi
> +++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
> @@ -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.. ;)

> +
> / {
> cpus {
> cpu@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@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 [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html



--
Robert Nelson
https://rcn-ee.com/

2016-10-21 21:01:43

by Robert Nelson

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

On Fri, Oct 21, 2016 at 3:47 PM, Robert Nelson <[email protected]> wrote:
> On Fri, Oct 21, 2016 at 9:01 AM, Milo Kim <[email protected]> wrote:
>> This enables the charger driver gets corresponding IRQ number by using
>> platform_get_irq_byname() helper.
>>
>> Signed-off-by: Milo Kim <[email protected]>
>> ---
>> arch/arm/boot/dts/am335x-bone-common.dtsi | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
>> index 25303d9..cec9d91 100644
>> --- a/arch/arm/boot/dts/am335x-bone-common.dtsi
>> +++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
>> @@ -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.. ;)

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

https://www.mail-archive.com/[email protected]/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...

diff --git a/drivers/input/misc/tps65218-pwrbutton.c
b/drivers/input/misc/tps65218-pwrbutton.c
index cc74a41..f7e5492 100644
--- a/drivers/input/misc/tps65218-pwrbutton.c
+++ b/drivers/input/misc/tps65218-pwrbutton.c
@@ -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 = {
diff --git a/include/dt-bindings/mfd/tps65217.h
b/include/dt-bindings/mfd/tps65217.h
new file mode 100644
index 0000000..26b2ba8
--- /dev/null
+++ b/include/dt-bindings/mfd/tps65217.h
@@ -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,

--
Robert Nelson
https://rcn-ee.com/

2016-10-26 13:54:10

by Lee Jones

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

On Fri, 21 Oct 2016, Milo Kim wrote:

> 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
>
> Signed-off-by: Milo Kim <[email protected]>
> ---
> include/linux/mfd/tps65217.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h
> index 4ccda89..75a3a5f 100644
> --- a/include/linux/mfd/tps65217.h
> +++ b/include/linux/mfd/tps65217.h
> @@ -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.

--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2016-10-28 04:02:43

by Milo Kim

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

On 10/22/2016 05:47 AM, Robert Nelson wrote:
>> +#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

2016-10-28 04:04:43

by Milo Kim

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

On 10/26/2016 10:56 PM, Lee Jones wrote:
>> diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h
>> > index 4ccda89..75a3a5f 100644
>> > --- a/include/linux/mfd/tps65217.h
>> > +++ b/include/linux/mfd/tps65217.h
>> > @@ -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.

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

Best regards,
Milo