• [PATCH v3 00/12] add pinmuxing support for pins in AXP209 and AXP813 PM

    From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:01 2017
    The AXP209 and AXP813 PMICs have several pins (respectively 3 and 2) that can be used either as GPIOs or for other purposes (ADC or LDO here).

    We already have a GPIO driver for the GPIO use of those pins on the AXP209. Let's "upgrade" this driver to support all the functions these pins can have.

    Then we add support to this driver for the AXP813 which is slighlty different (basically a different offset in a register and one less pin).

    I suggest patches 1 to 6 go through Linus's tree and 7 to 12 via Maxime or Chen-Yu's tree.

    This version of the patchset is based on Chen-Yu's patchset for AXP813/818 regulators[1].

    v3:
    - add defines for GPIO funcs,
    - use again get_regs function instead of drv_data (which was implemented in
    v2),
    - use of_device_id data for device specific data (gpio_status_offset and pins
    description),
    - change compatible from axp813-pctl to axp813-gpio,
    - use axp81x DT label instead of axp813 since AXP813 and AXP818 are similar,
    - add dtsi include for all boards embedding axp813/axp818,
    - drastically simplify structures,
    - rebase on Chen-Yu's patch series for regulators,
    - add GPIOs pinmuxing for LDO regulators,

    v2:
    - add support for AXP813 pins,
    - split into more patches so it is easier to follow the modifications,
    - reorder of some patches,
    - register all pins within the same range instead of a range per pin,

    [1] https://www.spinics.net/lists/arm-kernel/msg608384.html

    Thanks,
    Quentin

    Quentin Schulz (12):
    pinctrl: move gpio-axp209 to pinctrl
    pinctrl: axp209: add pinctrl features
    pinctrl: axp209: rename everything from gpio to pctl
    pinctrl: axp209: add programmable gpio_status_offset
    pinctrl: axp209: add support for AXP813 GPIOs
    mfd: axp20x: add pinctrl cell for AXP813
    ARM: dts: sun8i: a711: include axp81x dtsi
    ARM: dts: sun8i: bananapi-m3: include axp81x dtsi
    ARM: dts: sun8i: h8homlet-v2: include axp81x dtsi
    ARM: dts: sun8i: cubietruck-plus: include axp81x dtsi
    ARM: dtsi: axp81x: add GPIO DT node
    ARM: dtsi: axp81x: set pinmux for GPIO0/1 when used as LDOs

    .../devicetree/bindings/gpio/gpio-axp209.txt | 30 --
    .../devicetree/bindings/pinctrl/pinctrl-axp209.txt | 67 +++
    arch/arm/boot/dts/axp81x.dtsi | 20 +
    .../boot/dts/sun8i-a83t-allwinner-h8homlet-v2.dts | 2 +
    arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 2 +
    arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts | 2 +
    arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts | 4 +-
    drivers/gpio/Kconfig | 6 -
    drivers/gpio/Makefile | 1 -
    drivers/gpio/gpio-axp209.c | 188 ---------
    drivers/mfd/axp20x.c | 3 +
    drivers/pinctrl/Kconfig | 6 +
    drivers/pinctrl/Makefile | 1 +
    drivers/pinctrl/pinctrl-axp209.c | 459 +++++++++++++++++++++
    14 files changed, 565 insertions(+), 226 deletions(-)
    delete mode 100644 Documentation/devicetree/bindings/gpio/gpio-axp209.txt
    create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
    delete mode 100644 drivers/gpio/gpio-axp209.c
    create mode 100644 drivers/pinctrl/pinctrl-axp209.c

    --
    2.11.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:01 2017
    The X-Powers AXP209 has 3 GPIOs. GPIO0/1 can each act either as a GPIO,
    an ADC or a LDO regulator. GPIO2 can only act as a GPIO.

    This adds the pinctrl features to the driver so GPIO0/1 can be used as
    ADC or LDO regulator.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    .../devicetree/bindings/pinctrl/pinctrl-axp209.txt | 28 +-
    drivers/pinctrl/pinctrl-axp209.c | 293 +++++++++++++++++++--
    2 files changed, 300 insertions(+), 21 deletions(-)

    diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
    index a6611304dd3c..388c04492afd 100644
    --- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
    +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
    @@ -1,4 +1,4 @@
    -AXP209 GPIO controller
    +AXP209 GPIO & pinctrl controller

    This driver follows the usual GPIO bindings found in
    Documentation/devicetree/bindings/gpio/gpio.txt
    @@ -28,3 +28,29 @@ axp209: pmic@34 {
    #gpio-cells = <2>;
    };
    };
    +
    +The GPIOs can be muxed to other functions and therefore, must be a subnode of +axp_gpio.
    +
    +Example:
    +
    +&axp_gpio {
    + gpio0_adc: gpio0_adc {
    + pins = "GPIO0";
    + function = "adc";
    + };
    +};
    +
    +&example_node {
    + pinctrl-names = "defa
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:01 2017
    This board has an AXP818 PMIC so let's include its dtsi.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts b/arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts
    index 716a205c6dbb..5bef16d949f6 100644
    --- a/arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts
    +++ b/arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts
    @@ -179,6 +179,8 @@
    };
    };

    +#include "axp81x.dtsi"
    +
    &reg_usb1_vbus {
    gpio = <&pio 3 29 GPIO_ACTIVE_HIGH>; /* PD29 */
    status = "okay";
    --
    2.11.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:01 2017
    This board has an AXP818 PMIC so let's include its dtsi.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    arch/arm/boot/dts/sun8i-a83t-allwinner-h8homlet-v2.dts | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/arch/arm/boot/dts/sun8i-a83t-allwinner-h8homlet-v2.dts b/arch/arm/boot/dts/sun8i-a83t-allwinner-h8homlet-v2.dts
    index 1f0d60afb25b..222a983c3c6d 100644
    --- a/arch/arm/boot/dts/sun8i-a83t-allwinner-h8homlet-v2.dts
    +++ b/arch/arm/boot/dts/sun8i-a83t-allwinner-h8homlet-v2.dts
    @@ -131,6 +131,8 @@
    };
    };

    +#include "axp81x.dtsi"
    +
    &uart0 {
    pinctrl-names = "default";
    pinctrl-0 = <&uart0_pb_pins>;
    --
    2.11.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:01 2017
    This driver used to do only GPIO features of the GPIOs in X-Powers
    AXP20X. Now that we have migrated everything to the pinctrl subsystem
    and added pinctrl features, rename everything related to pinctrl from
    gpio to pctl to ease the understanding of differences between GPIO
    and pinctrl features.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    drivers/pinctrl/pinctrl-axp209.c | 178 +++++++++++++++++++--------------------
    1 file changed, 89 insertions(+), 89 deletions(-)

    diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
    index 96ef0cc28762..3ddeba45feed 100644
    --- a/drivers/pinctrl/pinctrl-axp209.c
    +++ b/drivers/pinctrl/pinctrl-axp209.c
    @@ -54,7 +54,7 @@ struct axp20x_pinctrl_function {
    unsigned int ngroups;
    };

    -struct axp20x_gpio {
    +struct axp20x_pctl {
    struct gpio_chip chip;
    struct regmap *regmap;
    struct pinctrl_dev *pctl_dev;
    @@ -97,11 +97,11 @@ static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)

    static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
    {
    - struct axp20x_gpio *gpio = gpiochip_get_data(chip);
    + struct axp20x_pctl *pctl = gpiochip_get_data(chip);
    unsigned int val;
    int ret;

    - ret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);
    + ret = regmap_read(pctl->regmap, AXP20X_GPIO20_SS, &val);
    if (ret)
    return ret;

    @
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:02 2017
    This board has an AXP813 PMIC so let's include its dtsi.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
    index 2bafd7e99ef7..bf8f3b9a65dd 100644
    --- a/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
    +++ b/arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts
    @@ -123,6 +123,8 @@
    };
    };

    +#include "axp81x.dtsi"
    +
    &reg_usb1_vbus {
    gpio = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* PD24 */
    status = "okay";
    --
    2.11.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:02 2017
    This board has an AXP813 PMIC so let's include its dtsi.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts | 4 +++-
    1 file changed, 3 insertions(+), 1 deletion(-)

    diff --git a/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts b/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
    index 723641f56a74..4f4db07ca19f 100644
    --- a/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
    +++ b/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
    @@ -146,7 +146,7 @@
    &r_rsb {
    status = "okay";

    - axp813: pmic@3a3 {
    + axp81x: pmic@3a3 {
    compatible = "x-powers,axp813";
    reg = <0x3a3>;
    interrupt-parent = <&r_intc>;
    @@ -179,6 +179,8 @@

    };

    +#include "axp81x.dtsi"
    +
    &uart0 {
    pinctrl-names = "default";
    pinctrl-0 = <&uart0_pb_pins>;
    --
    2.11.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:02 2017
    To prepare the driver for the upcoming pinctrl features, move the GPIO
    driver AXP209 from GPIO to pinctrl subsystem.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    .../bindings/{gpio/gpio-axp209.txt => pinctrl/pinctrl-axp209.txt} | 0
    drivers/gpio/Kconfig | 6 ------
    drivers/gpio/Makefile | 1 -
    drivers/pinctrl/Kconfig | 6 ++++++
    drivers/pinctrl/Makefile | 1 +
    drivers/{gpio/gpio-axp209.c => pinctrl/pinctrl-axp209.c} | 0
    6 files changed, 7 insertions(+), 7 deletions(-)
    rename Documentation/devicetree/bindings/{gpio/gpio-axp209.txt => pinctrl/pinctrl-axp209.txt} (100%)
    rename drivers/{gpio/gpio-axp209.c => pinctrl/pinctrl-axp209.c} (100%)

    diff --git a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
    similarity index 100%
    rename from Documentation/devicetree/bindings/gpio/gpio-axp209.txt
    rename to Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
    diff --git a/drivers/gpio/Kconfig
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:02 2017
    To prepare for patches that will add support for a new PMIC that has a different GPIO input status register, add a gpio_status_offset within axp20x_pctl structure and use it.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    drivers/pinctrl/pinctrl-axp209.c | 4 +++-
    1 file changed, 3 insertions(+), 1 deletion(-)

    diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
    index 3ddeba45feed..17146496b22a 100644
    --- a/drivers/pinctrl/pinctrl-axp209.c
    +++ b/drivers/pinctrl/pinctrl-axp209.c
    @@ -45,6 +45,7 @@ struct axp20x_pctrl_desc {
    unsigned int ldo_mask;
    /* Stores the pins supporting ADC function. Bit offset is pin number. */
    unsigned int adc_mask;
    + unsigned int gpio_status_offset;
    };

    struct axp20x_pinctrl_function {
    @@ -74,6 +75,7 @@ static const struct axp20x_pctrl_desc axp20x_data = {
    .npins = ARRAY_SIZE(axp209_pins),
    .ldo_mask = BIT(0) | BIT(1),
    .adc_mask = BIT(0) | BIT(1),
    + .gpio_status_offset = 4,
    };

    static int axp20x_gpio_get_reg(unsigned offset)
    @@ -105,7 +107,7 @@ static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)
    if (ret)
    return ret;

    - return !!(val & BIT(offset + 4));
    + return !!(val & BIT(offset + pctl->desc->gpio_
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:03 2017
    As GPIO/pinctrl driver now supports AXP813, add a cell for it.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    drivers/mfd/axp20x.c | 3 +++
    1 file changed, 3 insertions(+)

    diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
    index 2468b431bb22..d8c92fbbd170 100644
    --- a/drivers/mfd/axp20x.c
    +++ b/drivers/mfd/axp20x.c
    @@ -878,6 +878,9 @@ static struct mfd_cell axp813_cells[] = {
    .resources = axp803_pek_resources,
    }, {
    .name = "axp20x-regulator",
    + }, {
    + .name = "axp20x-gpio",
    + .of_compatible = "x-powers,axp813-gpio",
    }
    };

    --
    2.11.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:03 2017
    This adds DT node for the GPIO/pinctrl part present in AXP813/AXP818.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    arch/arm/boot/dts/axp81x.dtsi | 6 ++++++
    1 file changed, 6 insertions(+)

    diff --git a/arch/arm/boot/dts/axp81x.dtsi b/arch/arm/boot/dts/axp81x.dtsi index 73b761f850c5..f90f257130d5 100644
    --- a/arch/arm/boot/dts/axp81x.dtsi
    +++ b/arch/arm/boot/dts/axp81x.dtsi
    @@ -48,6 +48,12 @@
    interrupt-controller;
    #interrupt-cells = <1>;

    + axp_gpio: axp_gpio {
    + compatible = "x-powers,axp813-gpio";
    + gpio-controller;
    + #gpio-cells = <2>;
    + };
    +
    regulators {
    /* Default work frequency for buck regulators */
    x-powers,dcdc-freq = <3000>;
    --
    2.11.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:03 2017
    On AXP813/818, GPIO0 and GPIO1 can be used as LDO as (respectively)
    ldo_io0 and ldo_io1.

    Let's add the pinctrl properties to the said regulators.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    arch/arm/boot/dts/axp81x.dtsi | 14 ++++++++++++++
    1 file changed, 14 insertions(+)

    diff --git a/arch/arm/boot/dts/axp81x.dtsi b/arch/arm/boot/dts/axp81x.dtsi index f90f257130d5..099b0ddc1bbb 100644
    --- a/arch/arm/boot/dts/axp81x.dtsi
    +++ b/arch/arm/boot/dts/axp81x.dtsi
    @@ -52,6 +52,16 @@
    compatible = "x-powers,axp813-gpio";
    gpio-controller;
    #gpio-cells = <2>;
    +
    + gpio0_ldo: gpio0_ldo {
    + pins = "GPIO0";
    + function = "ldo";
    + };
    +
    + gpio1_ldo: gpio1_ldo {
    + pins = "GPIO1";
    + function = "ldo";
    + };
    };

    regulators {
    @@ -119,11 +129,15 @@
    };

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

    reg_ldo_io1: ldo-io1 {
    + pinctrl-names = "default";
    + pinctrl-0 = <&gpio1_ldo>;
    /* Disable by default to avoid conflicts with GPIO */
    status = "disabled";
    };
    --
    2.11.0

    --- SoupGate-Win32 v1.05
    * Origin:
  • From Quentin Schulz@21:1/5 to All on Mon Oct 2 14:20:02 2017
    The AXP813 has only two GPIOs. GPIO0 can either be used as a GPIO, an
    LDO regulator or an ADC. GPIO1 can be used either as a GPIO or an LDO regulator.

    Moreover, the status bit of the GPIOs when in input mode is not offset
    by 4 unlike the AXP209.

    Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
    ---
    .../devicetree/bindings/pinctrl/pinctrl-axp209.txt | 13 ++++++++-
    drivers/pinctrl/pinctrl-axp209.c | 32 ++++++++++++++++------
    2 files changed, 36 insertions(+), 9 deletions(-)

    diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
    index 388c04492afd..a4e4dbef65d6 100644
    --- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
    +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
    @@ -4,7 +4,9 @@ This driver follows the usual GPIO bindings found in
    Documentation/devicetree/bindings/gpio/gpio.txt

    Required properties:
    -- compatible: Should be "x-powers,axp209-gpio"
    +- compatible: Should be one of:
    + - "x-powers,axp209-gpio"
    + - "x-powers,axp813-gpio"
    - #gpio-cells: Should be two. The first cell is the pin number and the
    second is the GPIO flags.
    - gpio-controller: Marks the device node as a GPIO controller.
    @@ -49,8 +51,17 @@ Example:
    GPIOs and their fun