Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/818614/?format=api
{ "id": 818614, "url": "http://patchwork.ozlabs.org/api/patches/818614/?format=api", "web_url": "http://patchwork.ozlabs.org/project/devicetree-bindings/patch/e193f8efe9092171ebeffb77ab77422179fd3cab.1506428208.git-series.quentin.schulz@free-electrons.com/", "project": { "id": 37, "url": "http://patchwork.ozlabs.org/api/projects/37/?format=api", "name": "Devicetree Bindings", "link_name": "devicetree-bindings", "list_id": "devicetree.vger.kernel.org", "list_email": "devicetree@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<e193f8efe9092171ebeffb77ab77422179fd3cab.1506428208.git-series.quentin.schulz@free-electrons.com>", "list_archive_url": null, "date": "2017-09-26T12:17:11", "name": "[v2,01/10] pinctrl: move gpio-axp209 to pinctrl", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "abcb33553272398f14c64b65e16a53032a293d95", "submitter": { "id": 69366, "url": "http://patchwork.ozlabs.org/api/people/69366/?format=api", "name": "Quentin Schulz", "email": "quentin.schulz@free-electrons.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/devicetree-bindings/patch/e193f8efe9092171ebeffb77ab77422179fd3cab.1506428208.git-series.quentin.schulz@free-electrons.com/mbox/", "series": [ { "id": 5121, "url": "http://patchwork.ozlabs.org/api/series/5121/?format=api", "web_url": "http://patchwork.ozlabs.org/project/devicetree-bindings/list/?series=5121", "date": "2017-09-26T12:17:10", "name": "add pinmuxing support for pins in AXP209 and AXP813 PMICs", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/5121/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/818614/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/818614/checks/", "tags": {}, "related": [], "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 3y1g4l6vBYz9tXK\n\tfor <incoming-dt@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 22:19:51 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S968564AbdIZMSJ (ORCPT <rfc822; incoming-dt@patchwork.ozlabs.org>);\n\tTue, 26 Sep 2017 08:18:09 -0400", "from mail.free-electrons.com ([62.4.15.54]:52091 \"EHLO\n\tmail.free-electrons.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S965758AbdIZMSH (ORCPT\n\t<rfc822; devicetree@vger.kernel.org>); Tue, 26 Sep 2017 08:18:07 -0400", "by mail.free-electrons.com (Postfix, from userid 110)\n\tid 9D0DD20911; Tue, 26 Sep 2017 14:18:04 +0200 (CEST)", "from localhost.localdomain\n\t(LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87])\n\tby mail.free-electrons.com (Postfix) with ESMTPSA id 34B012083C;\n\tTue, 26 Sep 2017 14:17:54 +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\tURIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0", "From": "Quentin Schulz <quentin.schulz@free-electrons.com>", "To": "linus.walleij@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com,\n\twens@csie.org, linux@armlinux.org.uk,\n\tmaxime.ripard@free-electrons.com, lee.jones@linaro.org", "Cc": "linux-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,\n\tQuentin Schulz <quentin.schulz@free-electrons.com>", "Subject": "[PATCH v2 01/10] pinctrl: move gpio-axp209 to pinctrl", "Date": "Tue, 26 Sep 2017 14:17:11 +0200", "Message-Id": "<e193f8efe9092171ebeffb77ab77422179fd3cab.1506428208.git-series.quentin.schulz@free-electrons.com>", "X-Mailer": "git-send-email 2.11.0", "In-Reply-To": [ "<cover.1c314f4154a6d27354625f03d0a5269eee55a9c5.1506428208.git-series.quentin.schulz@free-electrons.com>", "<cover.1c314f4154a6d27354625f03d0a5269eee55a9c5.1506428208.git-series.quentin.schulz@free-electrons.com>" ], "References": [ "<cover.1c314f4154a6d27354625f03d0a5269eee55a9c5.1506428208.git-series.quentin.schulz@free-electrons.com>", "<cover.1c314f4154a6d27354625f03d0a5269eee55a9c5.1506428208.git-series.quentin.schulz@free-electrons.com>" ], "Sender": "devicetree-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<devicetree.vger.kernel.org>", "X-Mailing-List": "devicetree@vger.kernel.org" }, "content": "To prepare the driver for the upcoming pinctrl features, move the GPIO\ndriver AXP209 from GPIO to pinctrl subsystem.\n\nSigned-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>\n---\n Documentation/devicetree/bindings/gpio/gpio-axp209.txt | 30 +-\n Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt | 30 +-\n drivers/gpio/Kconfig | 6 +-\n drivers/gpio/Makefile | 1 +-\n drivers/gpio/gpio-axp209.c | 188 +-------\n drivers/pinctrl/Kconfig | 6 +-\n drivers/pinctrl/Makefile | 1 +-\n drivers/pinctrl/pinctrl-axp209.c | 188 +++++++-\n 8 files changed, 225 insertions(+), 225 deletions(-)\n delete mode 100644 Documentation/devicetree/bindings/gpio/gpio-axp209.txt\n create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt\n delete mode 100644 drivers/gpio/gpio-axp209.c\n create mode 100644 drivers/pinctrl/pinctrl-axp209.c", "diff": "diff --git a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt b/Documentation/devicetree/bindings/gpio/gpio-axp209.txt\ndeleted file mode 100644\nindex a661130..0000000\n--- a/Documentation/devicetree/bindings/gpio/gpio-axp209.txt\n+++ /dev/null\n@@ -1,30 +0,0 @@\n-AXP209 GPIO controller\n-\n-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-- #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-\n-This node must be a subnode of the axp20x PMIC, documented in\n-Documentation/devicetree/bindings/mfd/axp20x.txt\n-\n-Example:\n-\n-axp209: pmic@34 {\n-\tcompatible = \"x-powers,axp209\";\n-\treg = <0x34>;\n-\tinterrupt-parent = <&nmi_intc>;\n-\tinterrupts = <0 IRQ_TYPE_LEVEL_LOW>;\n-\tinterrupt-controller;\n-\t#interrupt-cells = <1>;\n-\n-\taxp_gpio: gpio {\n-\t\tcompatible = \"x-powers,axp209-gpio\";\n-\t\tgpio-controller;\n-\t\t#gpio-cells = <2>;\n-\t};\n-};\ndiff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt\nnew file mode 100644\nindex 0000000..a661130\n--- /dev/null\n+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-axp209.txt\n@@ -0,0 +1,30 @@\n+AXP209 GPIO controller\n+\n+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+- #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+\n+This node must be a subnode of the axp20x PMIC, documented in\n+Documentation/devicetree/bindings/mfd/axp20x.txt\n+\n+Example:\n+\n+axp209: pmic@34 {\n+\tcompatible = \"x-powers,axp209\";\n+\treg = <0x34>;\n+\tinterrupt-parent = <&nmi_intc>;\n+\tinterrupts = <0 IRQ_TYPE_LEVEL_LOW>;\n+\tinterrupt-controller;\n+\t#interrupt-cells = <1>;\n+\n+\taxp_gpio: gpio {\n+\t\tcompatible = \"x-powers,axp209-gpio\";\n+\t\tgpio-controller;\n+\t\t#gpio-cells = <2>;\n+\t};\n+};\ndiff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig\nindex 3f80f16..ad88178 100644\n--- a/drivers/gpio/Kconfig\n+++ b/drivers/gpio/Kconfig\n@@ -122,12 +122,6 @@ config GPIO_ATH79\n \t Select this option to enable GPIO driver for\n \t Atheros AR71XX/AR724X/AR913X SoC devices.\n \n-config GPIO_AXP209\n-\ttristate \"X-Powers AXP209 PMIC GPIO Support\"\n-\tdepends on MFD_AXP20X\n-\thelp\n-\t Say yes to enable GPIO support for the AXP209 PMIC\n-\n config GPIO_BCM_KONA\n \tbool \"Broadcom Kona GPIO\"\n \tdepends on OF_GPIO && (ARCH_BCM_MOBILE || COMPILE_TEST)\ndiff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile\nindex aeb70e9..f63631a 100644\n--- a/drivers/gpio/Makefile\n+++ b/drivers/gpio/Makefile\n@@ -31,7 +31,6 @@ obj-$(CONFIG_GPIO_AMDPT)\t+= gpio-amdpt.o\n obj-$(CONFIG_GPIO_ARIZONA)\t+= gpio-arizona.o\n obj-$(CONFIG_GPIO_ATH79)\t+= gpio-ath79.o\n obj-$(CONFIG_GPIO_ASPEED)\t+= gpio-aspeed.o\n-obj-$(CONFIG_GPIO_AXP209)\t+= gpio-axp209.o\n obj-$(CONFIG_GPIO_BCM_KONA)\t+= gpio-bcm-kona.o\n obj-$(CONFIG_GPIO_BD9571MWV)\t+= gpio-bd9571mwv.o\n obj-$(CONFIG_GPIO_BRCMSTB)\t+= gpio-brcmstb.o\ndiff --git a/drivers/gpio/gpio-axp209.c b/drivers/gpio/gpio-axp209.c\ndeleted file mode 100644\nindex 4a346b7..0000000\n--- a/drivers/gpio/gpio-axp209.c\n+++ /dev/null\n@@ -1,188 +0,0 @@\n-/*\n- * AXP20x GPIO driver\n- *\n- * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com>\n- *\n- * This program is free software; you can redistribute it and/or modify it\n- * under the terms of the GNU General Public License as published by the\n- * Free Software Foundation; either version 2 of the License, or (at your\n- * option) any later version.\n- */\n-\n-#include <linux/bitops.h>\n-#include <linux/device.h>\n-#include <linux/gpio/driver.h>\n-#include <linux/init.h>\n-#include <linux/interrupt.h>\n-#include <linux/kernel.h>\n-#include <linux/mfd/axp20x.h>\n-#include <linux/module.h>\n-#include <linux/of.h>\n-#include <linux/platform_device.h>\n-#include <linux/regmap.h>\n-#include <linux/slab.h>\n-\n-#define AXP20X_GPIO_FUNCTIONS\t\t0x7\n-#define AXP20X_GPIO_FUNCTION_OUT_LOW\t0\n-#define AXP20X_GPIO_FUNCTION_OUT_HIGH\t1\n-#define AXP20X_GPIO_FUNCTION_INPUT\t2\n-\n-struct axp20x_gpio {\n-\tstruct gpio_chip\tchip;\n-\tstruct regmap\t\t*regmap;\n-};\n-\n-static int axp20x_gpio_get_reg(unsigned offset)\n-{\n-\tswitch (offset) {\n-\tcase 0:\n-\t\treturn AXP20X_GPIO0_CTRL;\n-\tcase 1:\n-\t\treturn AXP20X_GPIO1_CTRL;\n-\tcase 2:\n-\t\treturn AXP20X_GPIO2_CTRL;\n-\t}\n-\n-\treturn -EINVAL;\n-}\n-\n-static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)\n-{\n-\tstruct axp20x_gpio *gpio = gpiochip_get_data(chip);\n-\tint reg;\n-\n-\treg = axp20x_gpio_get_reg(offset);\n-\tif (reg < 0)\n-\t\treturn reg;\n-\n-\treturn regmap_update_bits(gpio->regmap, reg,\n-\t\t\t\t AXP20X_GPIO_FUNCTIONS,\n-\t\t\t\t AXP20X_GPIO_FUNCTION_INPUT);\n-}\n-\n-static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)\n-{\n-\tstruct axp20x_gpio *gpio = gpiochip_get_data(chip);\n-\tunsigned int val;\n-\tint ret;\n-\n-\tret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);\n-\tif (ret)\n-\t\treturn ret;\n-\n-\treturn !!(val & BIT(offset + 4));\n-}\n-\n-static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)\n-{\n-\tstruct axp20x_gpio *gpio = gpiochip_get_data(chip);\n-\tunsigned int val;\n-\tint reg, ret;\n-\n-\treg = axp20x_gpio_get_reg(offset);\n-\tif (reg < 0)\n-\t\treturn reg;\n-\n-\tret = regmap_read(gpio->regmap, reg, &val);\n-\tif (ret)\n-\t\treturn ret;\n-\n-\t/*\n-\t * This shouldn't really happen if the pin is in use already,\n-\t * or if it's not in use yet, it doesn't matter since we're\n-\t * going to change the value soon anyway. Default to output.\n-\t */\n-\tif ((val & AXP20X_GPIO_FUNCTIONS) > 2)\n-\t\treturn 0;\n-\n-\t/*\n-\t * The GPIO directions are the three lowest values.\n-\t * 2 is input, 0 and 1 are output\n-\t */\n-\treturn val & 2;\n-}\n-\n-static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,\n-\t\t\t int value)\n-{\n-\tstruct axp20x_gpio *gpio = gpiochip_get_data(chip);\n-\tint reg;\n-\n-\treg = axp20x_gpio_get_reg(offset);\n-\tif (reg < 0)\n-\t\treturn reg;\n-\n-\treturn regmap_update_bits(gpio->regmap, reg,\n-\t\t\t\t AXP20X_GPIO_FUNCTIONS,\n-\t\t\t\t value ? AXP20X_GPIO_FUNCTION_OUT_HIGH\n-\t\t\t\t : AXP20X_GPIO_FUNCTION_OUT_LOW);\n-}\n-\n-static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,\n-\t\t\t int value)\n-{\n-\taxp20x_gpio_output(chip, offset, value);\n-}\n-\n-static int axp20x_gpio_probe(struct platform_device *pdev)\n-{\n-\tstruct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);\n-\tstruct axp20x_gpio *gpio;\n-\tint ret;\n-\n-\tif (!of_device_is_available(pdev->dev.of_node))\n-\t\treturn -ENODEV;\n-\n-\tif (!axp20x) {\n-\t\tdev_err(&pdev->dev, \"Parent drvdata not set\\n\");\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tgpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);\n-\tif (!gpio)\n-\t\treturn -ENOMEM;\n-\n-\tgpio->chip.base\t\t\t= -1;\n-\tgpio->chip.can_sleep\t\t= true;\n-\tgpio->chip.parent\t\t= &pdev->dev;\n-\tgpio->chip.label\t\t= dev_name(&pdev->dev);\n-\tgpio->chip.owner\t\t= THIS_MODULE;\n-\tgpio->chip.get\t\t\t= axp20x_gpio_get;\n-\tgpio->chip.get_direction\t= axp20x_gpio_get_direction;\n-\tgpio->chip.set\t\t\t= axp20x_gpio_set;\n-\tgpio->chip.direction_input\t= axp20x_gpio_input;\n-\tgpio->chip.direction_output\t= axp20x_gpio_output;\n-\tgpio->chip.ngpio\t\t= 3;\n-\n-\tgpio->regmap = axp20x->regmap;\n-\n-\tret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);\n-\tif (ret) {\n-\t\tdev_err(&pdev->dev, \"Failed to register GPIO chip\\n\");\n-\t\treturn ret;\n-\t}\n-\n-\tdev_info(&pdev->dev, \"AXP209 GPIO driver loaded\\n\");\n-\n-\treturn 0;\n-}\n-\n-static const struct of_device_id axp20x_gpio_match[] = {\n-\t{ .compatible = \"x-powers,axp209-gpio\" },\n-\t{ }\n-};\n-MODULE_DEVICE_TABLE(of, axp20x_gpio_match);\n-\n-static struct platform_driver axp20x_gpio_driver = {\n-\t.probe\t\t= axp20x_gpio_probe,\n-\t.driver = {\n-\t\t.name\t\t= \"axp20x-gpio\",\n-\t\t.of_match_table\t= axp20x_gpio_match,\n-\t},\n-};\n-\n-module_platform_driver(axp20x_gpio_driver);\n-\n-MODULE_AUTHOR(\"Maxime Ripard <maxime.ripard@free-electrons.com>\");\n-MODULE_DESCRIPTION(\"AXP20x PMIC GPIO driver\");\n-MODULE_LICENSE(\"GPL\");\ndiff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig\nindex 1778cf4..b125a21 100644\n--- a/drivers/pinctrl/Kconfig\n+++ b/drivers/pinctrl/Kconfig\n@@ -63,6 +63,12 @@ config PINCTRL_AS3722\n \t open drain configuration for the GPIO pins of AS3722 devices. It also\n \t supports the GPIO functionality through gpiolib.\n \n+config PINCTRL_AXP209\n+\ttristate \"X-Powers AXP209 PMIC pinctrl and GPIO Support\"\n+\tdepends on MFD_AXP20X\n+\thelp\n+\t Say yes to enable pinctrl and GPIO support for the AXP209 PMIC\n+\n config PINCTRL_BF54x\n \tdef_bool y if BF54x\n \tselect PINCTRL_ADI2\ndiff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile\nindex c16e279..9f621e5 100644\n--- a/drivers/pinctrl/Makefile\n+++ b/drivers/pinctrl/Makefile\n@@ -10,6 +10,7 @@ obj-$(CONFIG_GENERIC_PINCONF)\t+= pinconf-generic.o\n obj-$(CONFIG_PINCTRL_ADI2)\t+= pinctrl-adi2.o\n obj-$(CONFIG_PINCTRL_ARTPEC6)\t+= pinctrl-artpec6.o\n obj-$(CONFIG_PINCTRL_AS3722)\t+= pinctrl-as3722.o\n+obj-$(CONFIG_PINCTRL_AXP209)\t+= pinctrl-axp209.o\n obj-$(CONFIG_PINCTRL_BF54x)\t+= pinctrl-adi2-bf54x.o\n obj-$(CONFIG_PINCTRL_BF60x)\t+= pinctrl-adi2-bf60x.o\n obj-$(CONFIG_PINCTRL_AT91)\t+= pinctrl-at91.o\ndiff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c\nnew file mode 100644\nindex 0000000..4a346b7\n--- /dev/null\n+++ b/drivers/pinctrl/pinctrl-axp209.c\n@@ -0,0 +1,188 @@\n+/*\n+ * AXP20x GPIO driver\n+ *\n+ * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com>\n+ *\n+ * This program is free software; you can redistribute it and/or modify it\n+ * under the terms of the GNU General Public License as published by the\n+ * Free Software Foundation; either version 2 of the License, or (at your\n+ * option) any later version.\n+ */\n+\n+#include <linux/bitops.h>\n+#include <linux/device.h>\n+#include <linux/gpio/driver.h>\n+#include <linux/init.h>\n+#include <linux/interrupt.h>\n+#include <linux/kernel.h>\n+#include <linux/mfd/axp20x.h>\n+#include <linux/module.h>\n+#include <linux/of.h>\n+#include <linux/platform_device.h>\n+#include <linux/regmap.h>\n+#include <linux/slab.h>\n+\n+#define AXP20X_GPIO_FUNCTIONS\t\t0x7\n+#define AXP20X_GPIO_FUNCTION_OUT_LOW\t0\n+#define AXP20X_GPIO_FUNCTION_OUT_HIGH\t1\n+#define AXP20X_GPIO_FUNCTION_INPUT\t2\n+\n+struct axp20x_gpio {\n+\tstruct gpio_chip\tchip;\n+\tstruct regmap\t\t*regmap;\n+};\n+\n+static int axp20x_gpio_get_reg(unsigned offset)\n+{\n+\tswitch (offset) {\n+\tcase 0:\n+\t\treturn AXP20X_GPIO0_CTRL;\n+\tcase 1:\n+\t\treturn AXP20X_GPIO1_CTRL;\n+\tcase 2:\n+\t\treturn AXP20X_GPIO2_CTRL;\n+\t}\n+\n+\treturn -EINVAL;\n+}\n+\n+static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset)\n+{\n+\tstruct axp20x_gpio *gpio = gpiochip_get_data(chip);\n+\tint reg;\n+\n+\treg = axp20x_gpio_get_reg(offset);\n+\tif (reg < 0)\n+\t\treturn reg;\n+\n+\treturn regmap_update_bits(gpio->regmap, reg,\n+\t\t\t\t AXP20X_GPIO_FUNCTIONS,\n+\t\t\t\t AXP20X_GPIO_FUNCTION_INPUT);\n+}\n+\n+static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset)\n+{\n+\tstruct axp20x_gpio *gpio = gpiochip_get_data(chip);\n+\tunsigned int val;\n+\tint ret;\n+\n+\tret = regmap_read(gpio->regmap, AXP20X_GPIO20_SS, &val);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn !!(val & BIT(offset + 4));\n+}\n+\n+static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)\n+{\n+\tstruct axp20x_gpio *gpio = gpiochip_get_data(chip);\n+\tunsigned int val;\n+\tint reg, ret;\n+\n+\treg = axp20x_gpio_get_reg(offset);\n+\tif (reg < 0)\n+\t\treturn reg;\n+\n+\tret = regmap_read(gpio->regmap, reg, &val);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/*\n+\t * This shouldn't really happen if the pin is in use already,\n+\t * or if it's not in use yet, it doesn't matter since we're\n+\t * going to change the value soon anyway. Default to output.\n+\t */\n+\tif ((val & AXP20X_GPIO_FUNCTIONS) > 2)\n+\t\treturn 0;\n+\n+\t/*\n+\t * The GPIO directions are the three lowest values.\n+\t * 2 is input, 0 and 1 are output\n+\t */\n+\treturn val & 2;\n+}\n+\n+static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset,\n+\t\t\t int value)\n+{\n+\tstruct axp20x_gpio *gpio = gpiochip_get_data(chip);\n+\tint reg;\n+\n+\treg = axp20x_gpio_get_reg(offset);\n+\tif (reg < 0)\n+\t\treturn reg;\n+\n+\treturn regmap_update_bits(gpio->regmap, reg,\n+\t\t\t\t AXP20X_GPIO_FUNCTIONS,\n+\t\t\t\t value ? AXP20X_GPIO_FUNCTION_OUT_HIGH\n+\t\t\t\t : AXP20X_GPIO_FUNCTION_OUT_LOW);\n+}\n+\n+static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset,\n+\t\t\t int value)\n+{\n+\taxp20x_gpio_output(chip, offset, value);\n+}\n+\n+static int axp20x_gpio_probe(struct platform_device *pdev)\n+{\n+\tstruct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);\n+\tstruct axp20x_gpio *gpio;\n+\tint ret;\n+\n+\tif (!of_device_is_available(pdev->dev.of_node))\n+\t\treturn -ENODEV;\n+\n+\tif (!axp20x) {\n+\t\tdev_err(&pdev->dev, \"Parent drvdata not set\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tgpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);\n+\tif (!gpio)\n+\t\treturn -ENOMEM;\n+\n+\tgpio->chip.base\t\t\t= -1;\n+\tgpio->chip.can_sleep\t\t= true;\n+\tgpio->chip.parent\t\t= &pdev->dev;\n+\tgpio->chip.label\t\t= dev_name(&pdev->dev);\n+\tgpio->chip.owner\t\t= THIS_MODULE;\n+\tgpio->chip.get\t\t\t= axp20x_gpio_get;\n+\tgpio->chip.get_direction\t= axp20x_gpio_get_direction;\n+\tgpio->chip.set\t\t\t= axp20x_gpio_set;\n+\tgpio->chip.direction_input\t= axp20x_gpio_input;\n+\tgpio->chip.direction_output\t= axp20x_gpio_output;\n+\tgpio->chip.ngpio\t\t= 3;\n+\n+\tgpio->regmap = axp20x->regmap;\n+\n+\tret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio);\n+\tif (ret) {\n+\t\tdev_err(&pdev->dev, \"Failed to register GPIO chip\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tdev_info(&pdev->dev, \"AXP209 GPIO driver loaded\\n\");\n+\n+\treturn 0;\n+}\n+\n+static const struct of_device_id axp20x_gpio_match[] = {\n+\t{ .compatible = \"x-powers,axp209-gpio\" },\n+\t{ }\n+};\n+MODULE_DEVICE_TABLE(of, axp20x_gpio_match);\n+\n+static struct platform_driver axp20x_gpio_driver = {\n+\t.probe\t\t= axp20x_gpio_probe,\n+\t.driver = {\n+\t\t.name\t\t= \"axp20x-gpio\",\n+\t\t.of_match_table\t= axp20x_gpio_match,\n+\t},\n+};\n+\n+module_platform_driver(axp20x_gpio_driver);\n+\n+MODULE_AUTHOR(\"Maxime Ripard <maxime.ripard@free-electrons.com>\");\n+MODULE_DESCRIPTION(\"AXP20x PMIC GPIO driver\");\n+MODULE_LICENSE(\"GPL\");\n", "prefixes": [ "v2", "01/10" ] }