From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969134AbdIZNNK (ORCPT ); Tue, 26 Sep 2017 09:13:10 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:54613 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969118AbdIZNNI (ORCPT ); Tue, 26 Sep 2017 09:13:08 -0400 Date: Tue, 26 Sep 2017 15:12:56 +0200 From: Maxime Ripard To: Quentin Schulz Cc: linus.walleij@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org, linux@armlinux.org.uk, lee.jones@linaro.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, thomas.petazzoni@free-electrons.com Subject: Re: [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs Message-ID: <20170926131256.bqfzgqs2k63liqjj@flea> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ghy5ao52fovi7777" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170914 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ghy5ao52fovi7777 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > Moreover, the status bit of the GPIOs when in input mode is not offset > by 4 unlike the AXP209. >=20 > Signed-off-by: Quentin Schulz > --- > Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt | 13 ++- > drivers/pinctrl/pinctrl-axp209.c | 30 ++++++- > 2 files changed, 39 insertions(+), 4 deletions(-) >=20 > 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 > =20 > 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 > ------------------------- > =20 > +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-a= xp209.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[] = =3D { > AXP20X_FUNCTION(0x2, "gpio_in")), > }; > =20 > +static const struct axp20x_desc_pin axp813_pins[] =3D { > + 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 =3D { > .pins =3D axp209_pins, > .npins =3D ARRAY_SIZE(axp209_pins), > }; > =20 > +static const struct axp20x_pinctrl_desc axp813_pinctrl_data =3D { > + .pins =3D axp813_pins, > + .npins =3D 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 =3D pdev->dev.of_node; > int ret, i; > =20 > 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 =3D axp20x_gpio_set; > pctl->chip.direction_input =3D axp20x_gpio_input; > pctl->chip.direction_output =3D axp20x_gpio_output; > - pctl->chip.ngpio =3D 3; > =20 > pctl->regmap =3D axp20x->regmap; > =20 > - pctl->desc =3D &axp20x_pinctrl_data; > - pctl->gpio_status_offset =3D 4; > + if (of_device_is_compatible(np, "x-powers,axp209-gpio")) { > + pctl->desc =3D &axp20x_pinctrl_data; > + pctl->gpio_status_offset =3D 4; > + } else { > + pctl->desc =3D &axp813_pinctrl_data; > + pctl->gpio_status_offset =3D 0; > + } > pctl->dev =3D &pdev->dev; > + pctl->chip.ngpio =3D pctl->desc->npins; This should be part of a structure that would be attached to the compatible. Thanks! Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --ghy5ao52fovi7777 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJZylJYAAoJEBx+YmzsjxAgHkgQAKdFph3RPY5UbfT0xiWciC2P t8xRAfuEweC3Bh+xueQBOrJI+oz8BFlcbUJmB+gg+qOM5TsuxjtEERpwMo0e0uT1 bqmif5uPCVgs4nokUixJCNz6kw4hiuLpK084qUvaVfDFvJmNLap6Tejnq3AtemNm Z3PVsjquuQmHrVpjMI9CXg6/U74fv/i+XDc36eGTu/RgGcA7w6plN1CkPW9jvfeh 0fUpBJwWmXVzmruwHD2Y8rPdqzk/qAoa/wJpdJwRnAl4a6V/CdRiavaEc4cx/jgU 8piFNWMGEkdRgQG6n6Q7uAvfGSHVd1+zuPOa7CRdxY6UO8g9ih5mU1abJV+GOB3B gm08vTei/58iCiOp2KSPOi54BmdzoOt8xNEMf5IsA3nXyZlLKFVZDrCQuEbFaXt2 QLdSM1qahe+v+B6nzz2WJ/Hp5atJIujIpsMgXlRpCipp0ZEYU706LNpYk04gvfIF XcaAooasAxK6uofe7yxH5q1MjBB5LtpvXbbcef1TZ+bdT8lX7bk8nFumL5hkRXEJ W3qPMmrl4OhyXOWF0kjkPK7UxGavvHeCjm5aGKWBHbyQIRqmXZpQvUZjFP362YZu 2f7mGoLcvkmZAA89YDskjOLZdq7GMf/vG7WvPCQpw+Ltz3FlOPuXiMer4RSaXAkD eGf0BMX+n8lbVcf6V5YB =62jW -----END PGP SIGNATURE----- --ghy5ao52fovi7777--