From: maxime.ripard@free-electrons.com (Maxime Ripard)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs
Date: Tue, 26 Sep 2017 15:12:56 +0200 [thread overview]
Message-ID: <20170926131256.bqfzgqs2k63liqjj@flea> (raw)
In-Reply-To: <b950efcbb2f4d399812591cdf5dce11d0d35b42b.1506428208.git-series.quentin.schulz@free-electrons.com>
On Tue, Sep 26, 2017 at 12:17:16PM +0000, Quentin Schulz wrote:
> 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>
> ---
> Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt | 13 ++-
> drivers/pinctrl/pinctrl-axp209.c | 30 ++++++-
> 2 files changed, 39 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt
> index a5bfe87..a1d5dec 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-pctl"
> - #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 functions
> -------------------------
>
> +axp209
> +------
> GPIO | Functions
> ------------------------
> GPIO0 | gpio_in, gpio_out, ldo, adc
> GPIO1 | gpio_in, gpio_out, ldo, adc
> GPIO2 | gpio_in, gpio_out
> +
> +axp813
> +------
> +GPIO | Functions
> +------------------------
> +GPIO0 | gpio_in, gpio_out, ldo, adc
> +GPIO1 | gpio_in, gpio_out, ldo
> diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
> index 11f871e..500862b 100644
> --- a/drivers/pinctrl/pinctrl-axp209.c
> +++ b/drivers/pinctrl/pinctrl-axp209.c
> @@ -108,11 +108,28 @@ static const struct axp20x_desc_pin axp209_pins[] = {
> AXP20X_FUNCTION(0x2, "gpio_in")),
> };
>
> +static const struct axp20x_desc_pin axp813_pins[] = {
> + AXP20X_PIN(AXP20X_PINCTRL_PIN(0, "GPIO0", (void *)AXP20X_GPIO0_CTRL),
> + AXP20X_FUNCTION(0x0, "gpio_out"),
> + AXP20X_FUNCTION(0x2, "gpio_in"),
> + AXP20X_FUNCTION(0x3, "ldo"),
> + AXP20X_FUNCTION(0x4, "adc")),
> + AXP20X_PIN(AXP20X_PINCTRL_PIN(1, "GPIO1", (void *)AXP20X_GPIO1_CTRL),
> + AXP20X_FUNCTION(0x0, "gpio_out"),
> + AXP20X_FUNCTION(0x2, "gpio_in"),
> + AXP20X_FUNCTION(0x3, "ldo")),
> +};
> +
> static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {
> .pins = axp209_pins,
> .npins = ARRAY_SIZE(axp209_pins),
> };
>
> +static const struct axp20x_pinctrl_desc axp813_pinctrl_data = {
> + .pins = axp813_pins,
> + .npins = ARRAY_SIZE(axp813_pins),
> +};
> +
> static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)
> {
> return pinctrl_gpio_direction_input(chip->base + offset);
> @@ -479,6 +496,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
> struct axp20x_pctl *pctl;
> struct pinctrl_desc *pctrl_desc;
> struct pinctrl_pin_desc *pins;
> + struct device_node *np = pdev->dev.of_node;
> int ret, i;
>
> if (!of_device_is_available(pdev->dev.of_node))
> @@ -505,13 +523,18 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
> pctl->chip.set = axp20x_gpio_set;
> pctl->chip.direction_input = axp20x_gpio_input;
> pctl->chip.direction_output = axp20x_gpio_output;
> - pctl->chip.ngpio = 3;
>
> pctl->regmap = axp20x->regmap;
>
> - pctl->desc = &axp20x_pinctrl_data;
> - pctl->gpio_status_offset = 4;
> + if (of_device_is_compatible(np, "x-powers,axp209-gpio")) {
> + pctl->desc = &axp20x_pinctrl_data;
> + pctl->gpio_status_offset = 4;
> + } else {
> + pctl->desc = &axp813_pinctrl_data;
> + pctl->gpio_status_offset = 0;
> + }
> pctl->dev = &pdev->dev;
> + pctl->chip.ngpio = pctl->desc->npins;
This should be part of a structure that would be attached to the
compatible.
Thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170926/0d2db9f0/attachment.sig>
next prev parent reply other threads:[~2017-09-26 13:12 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-26 12:17 [PATCH v2 00/10] add pinmuxing support for pins in AXP209 and AXP813 PMICs Quentin Schulz
2017-09-26 12:17 ` [PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl Quentin Schulz
2017-09-26 12:55 ` Maxime Ripard
2017-09-26 12:59 ` Quentin Schulz
2017-09-26 13:08 ` Chen-Yu Tsai
2017-10-05 20:50 ` Rob Herring
2017-09-26 12:17 ` [PATCH v2 02/10] pinctrl: axp209: add pinctrl features Quentin Schulz
2017-09-26 13:00 ` Maxime Ripard
2017-09-26 13:08 ` Quentin Schulz
2017-09-26 13:27 ` Maxime Ripard
2017-09-26 13:37 ` Quentin Schulz
2017-09-27 9:28 ` Maxime Ripard
2017-09-26 12:17 ` [PATCH v2 03/10] pinctrl: axp209: use drv_data of pinctrl_pin_desc to store pin reg Quentin Schulz
2017-09-26 13:01 ` Maxime Ripard
2017-09-26 13:17 ` Quentin Schulz
2017-09-26 13:45 ` Maxime Ripard
2017-09-29 17:27 ` kbuild test robot
2017-09-26 12:17 ` [PATCH v2 04/10] pinctrl: axp209: rename everything from gpio to pctl Quentin Schulz
2017-09-26 12:17 ` [PATCH v2 05/10] pinctrl: axp209: add programmable gpio_status_offset Quentin Schulz
2017-09-26 12:17 ` [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs Quentin Schulz
2017-09-26 13:12 ` Maxime Ripard [this message]
2017-09-26 12:17 ` [PATCH v2 07/10] mfd: axp20x: add pinctrl cell for AXP813 Quentin Schulz
2017-09-26 13:14 ` Maxime Ripard
2017-09-28 19:06 ` Lee Jones
2017-09-26 12:17 ` [PATCH v2 08/10] ARM: dts: add dtsi for AXP813 PMIC Quentin Schulz
2017-09-26 13:16 ` Maxime Ripard
2017-09-26 13:53 ` Chen-Yu Tsai
2017-09-26 12:17 ` [PATCH v2 09/10] ARM: dts: sun8i: a711: include axp813 dtsi Quentin Schulz
2017-09-26 12:17 ` [PATCH v2 10/10] ARM: dts: sun8i: bananapi-m3: " Quentin Schulz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170926131256.bqfzgqs2k63liqjj@flea \
--to=maxime.ripard@free-electrons.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox