2022-06-21 03:44:12

by Samuel Holland

[permalink] [raw]
Subject: [PATCH v2 0/4] AXP221/AXP223/AXP809 GPIO support

This series hooks up the GPIO controller found in some older X-Powers
PMICs. The main motivation is converting the U-Boot driver over to use
devicetree, but Linux might as well gain support for the hardware too.

Changes in v2:
- Combine multiple "const"s in the binding into an "enum"

Samuel Holland (4):
dt-bindings: gpio: Add AXP221/AXP223/AXP809 compatibles
mfd: axp20x: Add AXP221/AXP223/AXP809 GPIO cells
pinctrl: axp209: Support the AXP221/AXP223/AXP809 variant
ARM: dts: axp22x/axp809: Add GPIO controller nodes

.../bindings/gpio/x-powers,axp209-gpio.yaml | 6 ++++++
arch/arm/boot/dts/axp22x.dtsi | 18 ++++++++++++++++++
arch/arm/boot/dts/axp809.dtsi | 19 +++++++++++++++++++
drivers/mfd/axp20x.c | 9 +++++++++
drivers/pinctrl/pinctrl-axp209.c | 14 +++++++++++---
5 files changed, 63 insertions(+), 3 deletions(-)

--
2.35.1


2022-06-21 03:44:17

by Samuel Holland

[permalink] [raw]
Subject: [PATCH v2 1/4] dt-bindings: gpio: Add AXP221/AXP223/AXP809 compatibles

These PMICs each have 2 GPIOs with the same register layout as AXP813,
but without an ADC function.

Signed-off-by: Samuel Holland <[email protected]>
---

Changes in v2:
- Combine multiple "const"s in the binding into an "enum"

.../devicetree/bindings/gpio/x-powers,axp209-gpio.yaml | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/gpio/x-powers,axp209-gpio.yaml b/Documentation/devicetree/bindings/gpio/x-powers,axp209-gpio.yaml
index 0f628b088cec..14486aee97b4 100644
--- a/Documentation/devicetree/bindings/gpio/x-powers,axp209-gpio.yaml
+++ b/Documentation/devicetree/bindings/gpio/x-powers,axp209-gpio.yaml
@@ -19,7 +19,13 @@ properties:
oneOf:
- enum:
- x-powers,axp209-gpio
+ - x-powers,axp221-gpio
- x-powers,axp813-gpio
+ - items:
+ - enum:
+ - x-powers,axp223-gpio
+ - x-powers,axp809-gpio
+ - const: x-powers,axp221-gpio
- items:
- const: x-powers,axp803-gpio
- const: x-powers,axp813-gpio
--
2.35.1

2022-06-21 03:44:42

by Samuel Holland

[permalink] [raw]
Subject: [PATCH v2 2/4] mfd: axp20x: Add AXP221/AXP223/AXP809 GPIO cells

These PMICs all contain a compatible GPIO controller.

Signed-off-by: Samuel Holland <[email protected]>
---

(no changes since v1)

drivers/mfd/axp20x.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 8161a5dc68e8..88a212a8168c 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -619,6 +619,9 @@ static const struct mfd_cell axp20x_cells[] = {

static const struct mfd_cell axp221_cells[] = {
{
+ .name = "axp20x-gpio",
+ .of_compatible = "x-powers,axp221-gpio",
+ }, {
.name = "axp221-pek",
.num_resources = ARRAY_SIZE(axp22x_pek_resources),
.resources = axp22x_pek_resources,
@@ -645,6 +648,9 @@ static const struct mfd_cell axp221_cells[] = {

static const struct mfd_cell axp223_cells[] = {
{
+ .name = "axp20x-gpio",
+ .of_compatible = "x-powers,axp221-gpio",
+ }, {
.name = "axp221-pek",
.num_resources = ARRAY_SIZE(axp22x_pek_resources),
.resources = axp22x_pek_resources,
@@ -785,6 +791,9 @@ static const struct mfd_cell axp806_cells[] = {

static const struct mfd_cell axp809_cells[] = {
{
+ .name = "axp20x-gpio",
+ .of_compatible = "x-powers,axp221-gpio",
+ }, {
.name = "axp221-pek",
.num_resources = ARRAY_SIZE(axp809_pek_resources),
.resources = axp809_pek_resources,
--
2.35.1

2022-06-21 03:44:49

by Samuel Holland

[permalink] [raw]
Subject: [PATCH v2 3/4] pinctrl: axp209: Support the AXP221/AXP223/AXP809 variant

These PMICs each have 2 GPIOs with the same register layout as AXP813,
but without an ADC function. They all fall back to the AXP221 compatible
string, so only that one needs to be listed in the driver.

Signed-off-by: Samuel Holland <[email protected]>
---

(no changes since v1)

drivers/pinctrl/pinctrl-axp209.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 207cbae3a7bf..7ab20ac15391 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -73,7 +73,7 @@ static const struct pinctrl_pin_desc axp209_pins[] = {
PINCTRL_PIN(2, "GPIO2"),
};

-static const struct pinctrl_pin_desc axp813_pins[] = {
+static const struct pinctrl_pin_desc axp22x_pins[] = {
PINCTRL_PIN(0, "GPIO0"),
PINCTRL_PIN(1, "GPIO1"),
};
@@ -87,9 +87,16 @@ static const struct axp20x_pctrl_desc axp20x_data = {
.adc_mux = AXP20X_MUX_ADC,
};

+static const struct axp20x_pctrl_desc axp22x_data = {
+ .pins = axp22x_pins,
+ .npins = ARRAY_SIZE(axp22x_pins),
+ .ldo_mask = BIT(0) | BIT(1),
+ .gpio_status_offset = 0,
+};
+
static const struct axp20x_pctrl_desc axp813_data = {
- .pins = axp813_pins,
- .npins = ARRAY_SIZE(axp813_pins),
+ .pins = axp22x_pins,
+ .npins = ARRAY_SIZE(axp22x_pins),
.ldo_mask = BIT(0) | BIT(1),
.adc_mask = BIT(0),
.gpio_status_offset = 0,
@@ -388,6 +395,7 @@ static int axp20x_build_funcs_groups(struct platform_device *pdev)

static const struct of_device_id axp20x_pctl_match[] = {
{ .compatible = "x-powers,axp209-gpio", .data = &axp20x_data, },
+ { .compatible = "x-powers,axp221-gpio", .data = &axp22x_data, },
{ .compatible = "x-powers,axp813-gpio", .data = &axp813_data, },
{ }
};
--
2.35.1

2022-06-21 03:45:06

by Samuel Holland

[permalink] [raw]
Subject: [PATCH v2 4/4] ARM: dts: axp22x/axp809: Add GPIO controller nodes

These PMICs all contain a GPIO controller. Now that the binding is
documented, wire up the controller in the device tree.

Signed-off-by: Samuel Holland <[email protected]>
---

(no changes since v1)

arch/arm/boot/dts/axp22x.dtsi | 18 ++++++++++++++++++
arch/arm/boot/dts/axp809.dtsi | 19 +++++++++++++++++++
2 files changed, 37 insertions(+)

diff --git a/arch/arm/boot/dts/axp22x.dtsi b/arch/arm/boot/dts/axp22x.dtsi
index a020c12b2884..5c233c84be92 100644
--- a/arch/arm/boot/dts/axp22x.dtsi
+++ b/arch/arm/boot/dts/axp22x.dtsi
@@ -67,6 +67,24 @@ battery_power_supply: battery-power {
status = "disabled";
};

+ axp_gpio: gpio {
+ compatible = "x-powers,axp221-gpio";
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ /omit-if-no-ref/
+ gpio0_ldo: gpio0-ldo-pin {
+ pins = "GPIO0";
+ function = "ldo";
+ };
+
+ /omit-if-no-ref/
+ gpio1_ldo: gpio1-ldo-pin {
+ pins = "GPIO1";
+ function = "ldo";
+ };
+ };
+
regulators {
/* Default work frequency for buck regulators */
x-powers,dcdc-freq = <3000>;
diff --git a/arch/arm/boot/dts/axp809.dtsi b/arch/arm/boot/dts/axp809.dtsi
index ab8e5f2d9246..da92b105f3b0 100644
--- a/arch/arm/boot/dts/axp809.dtsi
+++ b/arch/arm/boot/dts/axp809.dtsi
@@ -50,4 +50,23 @@ &axp809 {
compatible = "x-powers,axp809";
interrupt-controller;
#interrupt-cells = <1>;
+
+ axp_gpio: gpio {
+ compatible = "x-powers,axp809-gpio",
+ "x-powers,axp221-gpio";
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ /omit-if-no-ref/
+ gpio0_ldo: gpio0-ldo-pin {
+ pins = "GPIO0";
+ function = "ldo";
+ };
+
+ /omit-if-no-ref/
+ gpio1_ldo: gpio1-ldo-pin {
+ pins = "GPIO1";
+ function = "ldo";
+ };
+ };
};
--
2.35.1

2022-06-24 16:03:04

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] dt-bindings: gpio: Add AXP221/AXP223/AXP809 compatibles

On 21/06/2022 05:42, Samuel Holland wrote:
> These PMICs each have 2 GPIOs with the same register layout as AXP813,
> but without an ADC function.
>
> Signed-off-by: Samuel Holland <[email protected]>
> ---
>
> Changes in v2:
> - Combine multiple "const"s in the binding into an "enum"
>
> .../devicetree/bindings/gpio/x-powers,axp209-gpio.yaml | 6 ++++++
> 1 file changed, 6 insertions(+)


Acked-by: Krzysztof Kozlowski <[email protected]>


Best regards,
Krzysztof

2022-06-26 13:10:51

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] pinctrl: axp209: Support the AXP221/AXP223/AXP809 variant

On Tue, Jun 21, 2022 at 11:42 AM Samuel Holland <[email protected]> wrote:
>
> These PMICs each have 2 GPIOs with the same register layout as AXP813,
> but without an ADC function. They all fall back to the AXP221 compatible
> string, so only that one needs to be listed in the driver.
>
> Signed-off-by: Samuel Holland <[email protected]>

Reviewed-by: Chen-Yu Tsai <[email protected]>

2022-06-26 13:24:28

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] dt-bindings: gpio: Add AXP221/AXP223/AXP809 compatibles

On Tue, Jun 21, 2022 at 11:42 AM Samuel Holland <[email protected]> wrote:
>
> These PMICs each have 2 GPIOs with the same register layout as AXP813,
> but without an ADC function.
>
> Signed-off-by: Samuel Holland <[email protected]>

Reviewed-by: Chen-Yu Tsai <[email protected]>

2022-06-26 13:25:30

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v2 4/4] ARM: dts: axp22x/axp809: Add GPIO controller nodes

On Tue, Jun 21, 2022 at 11:42 AM Samuel Holland <[email protected]> wrote:
>
> These PMICs all contain a GPIO controller. Now that the binding is
> documented, wire up the controller in the device tree.
>
> Signed-off-by: Samuel Holland <[email protected]>
> ---
>
> (no changes since v1)
>
> arch/arm/boot/dts/axp22x.dtsi | 18 ++++++++++++++++++
> arch/arm/boot/dts/axp809.dtsi | 19 +++++++++++++++++++
> 2 files changed, 37 insertions(+)
>
> diff --git a/arch/arm/boot/dts/axp22x.dtsi b/arch/arm/boot/dts/axp22x.dtsi
> index a020c12b2884..5c233c84be92 100644
> --- a/arch/arm/boot/dts/axp22x.dtsi
> +++ b/arch/arm/boot/dts/axp22x.dtsi
> @@ -67,6 +67,24 @@ battery_power_supply: battery-power {
> status = "disabled";
> };
>
> + axp_gpio: gpio {
> + compatible = "x-powers,axp221-gpio";
> + gpio-controller;
> + #gpio-cells = <2>;
> +
> + /omit-if-no-ref/
> + gpio0_ldo: gpio0-ldo-pin {
> + pins = "GPIO0";
> + function = "ldo";
> + };
> +
> + /omit-if-no-ref/
> + gpio1_ldo: gpio1-ldo-pin {
> + pins = "GPIO1";
> + function = "ldo";
> + };
> + };
> +

We have

reg_ldo_io0: ldo-io0 {
pinctrl-names = "default";
pinctrl-0 = <&gpio0_ldo>;
/* Disable by default to avoid conflicts with GPIO */
...
}

in axp81x.dtsi . Should we add it here and for axp803.dtsi as well?

Otherwise,

Reviewed-by: Chen-Yu Tsai <[email protected]>

2022-06-26 13:27:10

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH v2 2/4] mfd: axp20x: Add AXP221/AXP223/AXP809 GPIO cells

On Tue, Jun 21, 2022 at 11:42 AM Samuel Holland <[email protected]> wrote:
>
> These PMICs all contain a compatible GPIO controller.
>
> Signed-off-by: Samuel Holland <[email protected]>

Reviewed-by: Chen-Yu Tsai <[email protected]>

2022-06-28 14:34:07

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v2 2/4] mfd: axp20x: Add AXP221/AXP223/AXP809 GPIO cells

On Tue, Jun 21, 2022 at 5:42 AM Samuel Holland <[email protected]> wrote:

> These PMICs all contain a compatible GPIO controller.
>
> Signed-off-by: Samuel Holland <[email protected]>

If I can get Lee's ACK on this patch I suppose I can apply patches
1-3 to the pin control tree?

Yours,
Linus Walleij

2022-06-29 02:31:37

by Samuel Holland

[permalink] [raw]
Subject: Re: [PATCH v2 2/4] mfd: axp20x: Add AXP221/AXP223/AXP809 GPIO cells

On 6/28/22 9:03 AM, Linus Walleij wrote:
> On Tue, Jun 21, 2022 at 5:42 AM Samuel Holland <[email protected]> wrote:
>
>> These PMICs all contain a compatible GPIO controller.
>>
>> Signed-off-by: Samuel Holland <[email protected]>
>
> If I can get Lee's ACK on this patch I suppose I can apply patches
> 1-3 to the pin control tree?

Looks like he already applied v1 of this patch (which was identical):

https://lore.kernel.org/lkml/[email protected]/

Regards,
Samuel

2022-06-29 10:10:20

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v2 2/4] mfd: axp20x: Add AXP221/AXP223/AXP809 GPIO cells

On Tue, 28 Jun 2022, Samuel Holland wrote:

> On 6/28/22 9:03 AM, Linus Walleij wrote:
> > On Tue, Jun 21, 2022 at 5:42 AM Samuel Holland <[email protected]> wrote:
> >
> >> These PMICs all contain a compatible GPIO controller.
> >>
> >> Signed-off-by: Samuel Holland <[email protected]>
> >
> > If I can get Lee's ACK on this patch I suppose I can apply patches
> > 1-3 to the pin control tree?
>
> Looks like he already applied v1 of this patch (which was identical):
>
> https://lore.kernel.org/lkml/[email protected]/

Right, you don't need this one Linus.

Please take the others.

--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

2022-06-30 12:15:21

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v2 2/4] mfd: axp20x: Add AXP221/AXP223/AXP809 GPIO cells

On Wed, Jun 29, 2022 at 11:19 AM Lee Jones <[email protected]> wrote:
> On Tue, 28 Jun 2022, Samuel Holland wrote:
>
> > On 6/28/22 9:03 AM, Linus Walleij wrote:
> > > On Tue, Jun 21, 2022 at 5:42 AM Samuel Holland <[email protected]> wrote:
> > >
> > >> These PMICs all contain a compatible GPIO controller.
> > >>
> > >> Signed-off-by: Samuel Holland <[email protected]>
> > >
> > > If I can get Lee's ACK on this patch I suppose I can apply patches
> > > 1-3 to the pin control tree?
> >
> > Looks like he already applied v1 of this patch (which was identical):
> >
> > https://lore.kernel.org/lkml/[email protected]/
>
> Right, you don't need this one Linus.
>
> Please take the others.

True! No compile-time dependence.

I'll queue the others.

Yours,
Linus Walleij

2022-06-30 12:15:39

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] pinctrl: axp209: Support the AXP221/AXP223/AXP809 variant

On Tue, Jun 21, 2022 at 5:42 AM Samuel Holland <[email protected]> wrote:

> These PMICs each have 2 GPIOs with the same register layout as AXP813,
> but without an ADC function. They all fall back to the AXP221 compatible
> string, so only that one needs to be listed in the driver.
>
> Signed-off-by: Samuel Holland <[email protected]>

Patch applied to the pinctrl tree!

Yours,
Linus Walleij

2022-06-30 12:40:38

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] dt-bindings: gpio: Add AXP221/AXP223/AXP809 compatibles

On Tue, Jun 21, 2022 at 5:42 AM Samuel Holland <[email protected]> wrote:

> These PMICs each have 2 GPIOs with the same register layout as AXP813,
> but without an ADC function.
>
> Signed-off-by: Samuel Holland <[email protected]>

Patch applied to the pinctrl tree.

OK the binding is in *gpio* but the driver is in pinctrl so has to go
with the other patch in my tree.

Yours,
Linus Walleij

2022-09-16 04:29:28

by Samuel Holland

[permalink] [raw]
Subject: Re: [PATCH v2 4/4] ARM: dts: axp22x/axp809: Add GPIO controller nodes

On 6/26/22 08:03, Chen-Yu Tsai wrote:
> On Tue, Jun 21, 2022 at 11:42 AM Samuel Holland <[email protected]> wrote:
>>
>> These PMICs all contain a GPIO controller. Now that the binding is
>> documented, wire up the controller in the device tree.
>>
>> Signed-off-by: Samuel Holland <[email protected]>
>> ---
>>
>> (no changes since v1)
>>
>> arch/arm/boot/dts/axp22x.dtsi | 18 ++++++++++++++++++
>> arch/arm/boot/dts/axp809.dtsi | 19 +++++++++++++++++++
>> 2 files changed, 37 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/axp22x.dtsi b/arch/arm/boot/dts/axp22x.dtsi
>> index a020c12b2884..5c233c84be92 100644
>> --- a/arch/arm/boot/dts/axp22x.dtsi
>> +++ b/arch/arm/boot/dts/axp22x.dtsi
>> @@ -67,6 +67,24 @@ battery_power_supply: battery-power {
>> status = "disabled";
>> };
>>
>> + axp_gpio: gpio {
>> + compatible = "x-powers,axp221-gpio";
>> + gpio-controller;
>> + #gpio-cells = <2>;
>> +
>> + /omit-if-no-ref/
>> + gpio0_ldo: gpio0-ldo-pin {
>> + pins = "GPIO0";
>> + function = "ldo";
>> + };
>> +
>> + /omit-if-no-ref/
>> + gpio1_ldo: gpio1-ldo-pin {
>> + pins = "GPIO1";
>> + function = "ldo";
>> + };
>> + };
>> +
>
> We have
>
> reg_ldo_io0: ldo-io0 {
> pinctrl-names = "default";
> pinctrl-0 = <&gpio0_ldo>;
> /* Disable by default to avoid conflicts with GPIO */
> ...
> }
>
> in axp81x.dtsi . Should we add it here and for axp803.dtsi as well?

Actually, I don't think these pinctrl nodes should exist at all. The
regulator already sets the pinmux, because that is the only way to turn
the regulator on/off. So I think we should leave it alone here.

Regards,
Samuel

> Otherwise,
>
> Reviewed-by: Chen-Yu Tsai <[email protected]>