[{"id":1775475,"web_url":"http://patchwork.ozlabs.org/comment/1775475/","msgid":"<20170926131256.bqfzgqs2k63liqjj@flea>","list_archive_url":null,"date":"2017-09-26T13:12:56","subject":"Re: [PATCH v2 06/10] pinctrl: axp209: add support for AXP813 GPIOs","submitter":{"id":12916,"url":"http://patchwork.ozlabs.org/api/people/12916/","name":"Maxime Ripard","email":"maxime.ripard@free-electrons.com"},"content":"On Tue, Sep 26, 2017 at 12:17:16PM +0000, Quentin Schulz wrote:\n> The AXP813 has only two GPIOs. GPIO0 can either be used as a GPIO, an\n> LDO regulator or an ADC. GPIO1 can be used either as a GPIO or an LDO\n> regulator.\n> \n> Moreover, the status bit of the GPIOs when in input mode is not offset\n> by 4 unlike the AXP209.\n> \n> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>\n> ---\n>  Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt | 13 ++-\n>  drivers/pinctrl/pinctrl-axp209.c                             | 30 ++++++-\n>  2 files changed, 39 insertions(+), 4 deletions(-)\n> \n> diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt\n> index a5bfe87..a1d5dec 100644\n> --- a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt\n> +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt\n> @@ -4,7 +4,9 @@ This driver follows the usual GPIO bindings found in\n>  Documentation/devicetree/bindings/gpio/gpio.txt\n>  \n>  Required properties:\n> -- compatible: Should be \"x-powers,axp209-gpio\"\n> +- compatible: Should be one of:\n> +\t- \"x-powers,axp209-gpio\"\n> +\t- \"x-powers,axp813-pctl\"\n>  - #gpio-cells: Should be two. The first cell is the pin number and the\n>    second is the GPIO flags.\n>  - gpio-controller: Marks the device node as a GPIO controller.\n> @@ -49,8 +51,17 @@ Example:\n>  GPIOs and their functions\n>  -------------------------\n>  \n> +axp209\n> +------\n>  GPIO\t|\tFunctions\n>  ------------------------\n>  GPIO0\t|\tgpio_in, gpio_out, ldo, adc\n>  GPIO1\t|\tgpio_in, gpio_out, ldo, adc\n>  GPIO2\t|\tgpio_in, gpio_out\n> +\n> +axp813\n> +------\n> +GPIO\t|\tFunctions\n> +------------------------\n> +GPIO0\t|\tgpio_in, gpio_out, ldo, adc\n> +GPIO1\t|\tgpio_in, gpio_out, ldo\n> diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c\n> index 11f871e..500862b 100644\n> --- a/drivers/pinctrl/pinctrl-axp209.c\n> +++ b/drivers/pinctrl/pinctrl-axp209.c\n> @@ -108,11 +108,28 @@ static const struct axp20x_desc_pin axp209_pins[] = {\n>  \t\t   AXP20X_FUNCTION(0x2, \"gpio_in\")),\n>  };\n>  \n> +static const struct axp20x_desc_pin axp813_pins[] = {\n> +\tAXP20X_PIN(AXP20X_PINCTRL_PIN(0, \"GPIO0\", (void *)AXP20X_GPIO0_CTRL),\n> +\t\t   AXP20X_FUNCTION(0x0, \"gpio_out\"),\n> +\t\t   AXP20X_FUNCTION(0x2, \"gpio_in\"),\n> +\t\t   AXP20X_FUNCTION(0x3, \"ldo\"),\n> +\t\t   AXP20X_FUNCTION(0x4, \"adc\")),\n> +\tAXP20X_PIN(AXP20X_PINCTRL_PIN(1, \"GPIO1\", (void *)AXP20X_GPIO1_CTRL),\n> +\t\t   AXP20X_FUNCTION(0x0, \"gpio_out\"),\n> +\t\t   AXP20X_FUNCTION(0x2, \"gpio_in\"),\n> +\t\t   AXP20X_FUNCTION(0x3, \"ldo\")),\n> +};\n> +\n>  static const struct axp20x_pinctrl_desc axp20x_pinctrl_data = {\n>  \t.pins\t= axp209_pins,\n>  \t.npins\t= ARRAY_SIZE(axp209_pins),\n>  };\n>  \n> +static const struct axp20x_pinctrl_desc axp813_pinctrl_data = {\n> +\t.pins\t= axp813_pins,\n> +\t.npins\t= ARRAY_SIZE(axp813_pins),\n> +};\n> +\n>  static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)\n>  {\n>  \treturn pinctrl_gpio_direction_input(chip->base + offset);\n> @@ -479,6 +496,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)\n>  \tstruct axp20x_pctl *pctl;\n>  \tstruct pinctrl_desc *pctrl_desc;\n>  \tstruct pinctrl_pin_desc *pins;\n> +\tstruct device_node *np = pdev->dev.of_node;\n>  \tint ret, i;\n>  \n>  \tif (!of_device_is_available(pdev->dev.of_node))\n> @@ -505,13 +523,18 @@ static int axp20x_pctl_probe(struct platform_device *pdev)\n>  \tpctl->chip.set\t\t\t= axp20x_gpio_set;\n>  \tpctl->chip.direction_input\t= axp20x_gpio_input;\n>  \tpctl->chip.direction_output\t= axp20x_gpio_output;\n> -\tpctl->chip.ngpio\t\t= 3;\n>  \n>  \tpctl->regmap = axp20x->regmap;\n>  \n> -\tpctl->desc = &axp20x_pinctrl_data;\n> -\tpctl->gpio_status_offset = 4;\n> +\tif (of_device_is_compatible(np, \"x-powers,axp209-gpio\")) {\n> +\t\tpctl->desc = &axp20x_pinctrl_data;\n> +\t\tpctl->gpio_status_offset = 4;\n> +\t} else {\n> +\t\tpctl->desc = &axp813_pinctrl_data;\n> +\t\tpctl->gpio_status_offset = 0;\n> +\t}\n>  \tpctl->dev = &pdev->dev;\n> +\tpctl->chip.ngpio = pctl->desc->npins;\n\nThis should be part of a structure that would be attached to the\ncompatible.\n\nThanks!\nMaxime","headers":{"Return-Path":"<devicetree-owner@vger.kernel.org>","X-Original-To":"incoming-dt@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-dt@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=devicetree-owner@vger.kernel.org; receiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y1hGG621yz9tXn\n\tfor <incoming-dt@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 23:13:10 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S969119AbdIZNNJ (ORCPT <rfc822; incoming-dt@patchwork.ozlabs.org>);\n\tTue, 26 Sep 2017 09:13:09 -0400","from mail.free-electrons.com ([62.4.15.54]:54613 \"EHLO\n\tmail.free-electrons.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S969118AbdIZNNI (ORCPT\n\t<rfc822; devicetree@vger.kernel.org>); Tue, 26 Sep 2017 09:13:08 -0400","by mail.free-electrons.com (Postfix, from userid 110)\n\tid 1FE7E20858; Tue, 26 Sep 2017 15:13:06 +0200 (CEST)","from localhost (unknown [195.81.232.10])\n\tby mail.free-electrons.com (Postfix) with ESMTPSA id E94A1207E1;\n\tTue, 26 Sep 2017 15:12:55 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on\n\tmail.free-electrons.com","X-Spam-Level":"","X-Spam-Status":"No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT\n\tshortcircuit=ham autolearn=disabled version=3.4.0","Date":"Tue, 26 Sep 2017 15:12:56 +0200","From":"Maxime Ripard <maxime.ripard@free-electrons.com>","To":"Quentin Schulz <quentin.schulz@free-electrons.com>","Cc":"linus.walleij@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com,\n\twens@csie.org, linux@armlinux.org.uk, lee.jones@linaro.org,\n\tlinux-gpio@vger.kernel.org, devicetree@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org,\n\tlinux-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":"<cover.1c314f4154a6d27354625f03d0a5269eee55a9c5.1506428208.git-series.quentin.schulz@free-electrons.com>\n\t<b950efcbb2f4d399812591cdf5dce11d0d35b42b.1506428208.git-series.quentin.schulz@free-electrons.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"ghy5ao52fovi7777\"","Content-Disposition":"inline","In-Reply-To":"<b950efcbb2f4d399812591cdf5dce11d0d35b42b.1506428208.git-series.quentin.schulz@free-electrons.com>","User-Agent":"NeoMutt/20170914 (1.9.0)","Sender":"devicetree-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<devicetree.vger.kernel.org>","X-Mailing-List":"devicetree@vger.kernel.org"}}]