Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/881/?format=api
{ "id": 881, "url": "http://patchwork.ozlabs.org/api/patches/881/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1222095582-19918-1-git-send-email-jacmet@sunsite.dk/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api", "name": "Linux PPC development", "link_name": "linuxppc-dev", "list_id": "linuxppc-dev.lists.ozlabs.org", "list_email": "linuxppc-dev@lists.ozlabs.org", "web_url": "https://github.com/linuxppc/wiki/wiki", "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git", "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/", "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/", "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}" }, "msgid": "<1222095582-19918-1-git-send-email-jacmet@sunsite.dk>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/1222095582-19918-1-git-send-email-jacmet@sunsite.dk/", "date": "2008-09-22T14:59:42", "name": "[v4] powerpc: gpio driver for mpc8349/8572/8610 and compatible", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "560b89bb50b0f065873b9fc07a01ca7002493c4f", "submitter": { "id": 103, "url": "http://patchwork.ozlabs.org/api/people/103/?format=api", "name": "Peter Korsgaard", "email": "jacmet@sunsite.dk" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1222095582-19918-1-git-send-email-jacmet@sunsite.dk/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/881/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/881/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org>", "X-Original-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@ozlabs.org" ], "Delivered-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@ozlabs.org" ], "Received": [ "from ozlabs.org (localhost [127.0.0.1])\n\tby ozlabs.org (Postfix) with ESMTP id CEB8BDE372\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 23 Sep 2008 01:00:18 +1000 (EST)", "from gv-out-0910.google.com (gv-out-0910.google.com\n\t[216.239.58.185]) by ozlabs.org (Postfix) with ESMTP id 32C0ADDE1C\n\tfor <linuxppc-dev@ozlabs.org>; Tue, 23 Sep 2008 01:00:04 +1000 (EST)", "by gv-out-0910.google.com with SMTP id y18so51886gvf.14\n\tfor <linuxppc-dev@ozlabs.org>; Mon, 22 Sep 2008 08:00:02 -0700 (PDT)", "by 10.103.229.19 with SMTP id g19mr2750906mur.19.1222095601512;\n\tMon, 22 Sep 2008 08:00:01 -0700 (PDT)", "from macbook.be.48ers.dk ( [194.78.207.191])\n\tby mx.google.com with ESMTPS id\n\tj10sm10176295mue.17.2008.09.22.07.59.52\n\t(version=TLSv1/SSLv3 cipher=RC4-MD5);\n\tMon, 22 Sep 2008 08:00:00 -0700 (PDT)", "by macbook.be.48ers.dk (Postfix, from userid 1000)\n\tid 9971F98C531; Mon, 22 Sep 2008 16:59:42 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; \n\th=domainkey-signature:received:received:received:from:to:cc:subject\n\t:date:message-id:x-mailer:sender;\n\tbh=5Jnjf+YnVSWvPvEykT61BAjQ8F2nniHbud/Ba9ZH+f8=;\n\tb=bQOLZCvbNiiAHNAsa1g/SLDQtlb3Hctnik0/PCBLXe1nB1HpMHogz/uVZANvJCYhvP\n\tRTXEm9PEXeopjQmByc6zput+5ztERRzD8h+9Rot6tS3Ad1rJUJv/ZQgqSHe3WpmrNNKf\n\trKsUdGWt9qnGytyawTTe0nuu6HgV6w1zGq5qo=", "DomainKey-Signature": "a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\n\th=from:to:cc:subject:date:message-id:x-mailer:sender;\n\tb=QrSDYxpsdR1fBKMngDa4s4+20PUQ3ket0rRC915GJeiG12MLzDVTZ+jUbu1icco0/R\n\t02NhkD/UajKpa5QDEpO4pP68pB76va/mZy+ON4aNBxzSYajIhDvUyRzx54ZWFAZXQzvm\n\tD8oYFoyHDcrQfHFgOhYdHwc7UlAwKs0X+0//0=", "From": "Peter Korsgaard <jacmet@sunsite.dk>", "To": "galak@kernel.crashing.org, avorontsov@ru.mvista.com,\n\tlinuxppc-dev@ozlabs.org", "Subject": "[PATCH v4] powerpc: gpio driver for mpc8349/8572/8610 and compatible", "Date": "Mon, 22 Sep 2008 16:59:42 +0200", "Message-Id": "<1222095582-19918-1-git-send-email-jacmet@sunsite.dk>", "X-Mailer": "git-send-email 1.5.6.3", "X-BeenThere": "linuxppc-dev@ozlabs.org", "X-Mailman-Version": "2.1.11", "Precedence": "list", "List-Id": "Linux on PowerPC Developers Mail List <linuxppc-dev.ozlabs.org>", "List-Unsubscribe": "<https://ozlabs.org/mailman/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@ozlabs.org?subject=unsubscribe>", "List-Archive": "<http://ozlabs.org/pipermail/linuxppc-dev>", "List-Post": "<mailto:linuxppc-dev@ozlabs.org>", "List-Help": "<mailto:linuxppc-dev-request@ozlabs.org?subject=help>", "List-Subscribe": "<https://ozlabs.org/mailman/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@ozlabs.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org", "Errors-To": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org" }, "content": "Structured similar to the existing QE GPIO support.\n\nSigned-off-by: Peter Korsgaard <jacmet@sunsite.dk>\n---\n Changes since v3:\n - Incorporated feedback from Anton\n\n Changes since v2:\n - Clarified documentation as requested by Kumar.\n \n Changes since v1:\n Incorporated feedback from Anton and Kumar:\n - Core is also used on 8572/8610 so s/83xx/8xxx/\n - Use fsl,mpc8572-gpio / fsl,mpc8610-gpio for 85xx/86xx as compatible\n - Use shadowed data register to handle open drain outputs\n - Expandend dts binding doc, use 8347 as example instead of 8349\n - Misc small cleanups\n\n .../powerpc/dts-bindings/fsl/8xxx_gpio.txt | 40 +++++\n arch/powerpc/sysdev/Kconfig | 9 +\n arch/powerpc/sysdev/Makefile | 1 +\n arch/powerpc/sysdev/mpc8xxx_gpio.c | 171 ++++++++++++++++++++\n 4 files changed, 221 insertions(+), 0 deletions(-)\n create mode 100644 Documentation/powerpc/dts-bindings/fsl/8xxx_gpio.txt\n create mode 100644 arch/powerpc/sysdev/mpc8xxx_gpio.c", "diff": "diff --git a/Documentation/powerpc/dts-bindings/fsl/8xxx_gpio.txt b/Documentation/powerpc/dts-bindings/fsl/8xxx_gpio.txt\nnew file mode 100644\nindex 0000000..d015dce\n--- /dev/null\n+++ b/Documentation/powerpc/dts-bindings/fsl/8xxx_gpio.txt\n@@ -0,0 +1,40 @@\n+GPIO controllers on MPC8xxx SoCs\n+\n+This is for the non-QE/CPM/GUTs GPIO controllers as found on\n+8349, 8572, 8610 and compatible.\n+\n+Every GPIO controller node must have #gpio-cells property defined,\n+this information will be used to translate gpio-specifiers.\n+\n+Required properties:\n+- compatible : \"fsl,<CHIP>-gpio\" followed by \"fsl,mpc8349-gpio\" for\n+ 83xx, \"fsl,mpc8572-gpio\" for 85xx and \"fsl,mpc8610-gpio\" for 86xx.\n+- #gpio-cells : Should be two. The first cell is the pin number and the\n+ second cell is used to specify optional parameters (currently unused).\n+ - interrupts : Interrupt mapping for GPIO IRQ (currently unused).\n+ - interrupt-parent : Phandle for the interrupt controller that\n+ services interrupts for this device.\n+- gpio-controller : Marks the port as GPIO controller.\n+\n+Example of gpio-controller nodes for a MPC8347 SoC:\n+\n+\tgpio1: gpio-controller@c00 {\n+\t\t#gpio-cells = <2>;\n+\t\tcompatible = \"fsl,mpc8347-gpio\", \"fsl,mpc8349-gpio\";\n+\t\treg = <0xc00 0x100>;\n+\t\tinterrupts = <74 0x8>;\n+\t\tinterrupt-parent = <&ipic>;\n+\t\tgpio-controller;\n+\t};\n+\n+\tgpio2: gpio-controller@d00 {\n+\t\t#gpio-cells = <2>;\n+\t\tcompatible = \"fsl,mpc8347-gpio\", \"fsl,mpc8349-gpio\";\n+\t\treg = <0xd00 0x100>;\n+\t\tinterrupts = <75 0x8>;\n+\t\tinterrupt-parent = <&ipic>;\n+\t\tgpio-controller;\n+\t};\n+\n+See booting-without-of.txt for details of how to specify GPIO\n+information for devices.\ndiff --git a/arch/powerpc/sysdev/Kconfig b/arch/powerpc/sysdev/Kconfig\nindex 72fb35b..a11cc8f 100644\n--- a/arch/powerpc/sysdev/Kconfig\n+++ b/arch/powerpc/sysdev/Kconfig\n@@ -6,3 +6,12 @@ config PPC4xx_PCI_EXPRESS\n \tbool\n \tdepends on PCI && 4xx\n \tdefault n\n+\n+config MPC8xxx_GPIO\n+\tbool \"MPC8xxx GPIO support\"\n+\tdepends on PPC_MPC831x || PPC_MPC834x || PPC_MPC837x || PPC_85xx || PPC_86xx\n+\tselect GENERIC_GPIO\n+\tselect ARCH_REQUIRE_GPIOLIB\n+\thelp\n+\t Say Y here if you're going to use hardware that connects to the\n+\t MPC831x/834x/837x/8572/8610 GPIOs.\ndiff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile\nindex a90054b..e410764 100644\n--- a/arch/powerpc/sysdev/Makefile\n+++ b/arch/powerpc/sysdev/Makefile\n@@ -15,6 +15,7 @@ obj-$(CONFIG_FSL_SOC)\t\t+= fsl_soc.o\n obj-$(CONFIG_FSL_PCI)\t\t+= fsl_pci.o $(fsl-msi-obj-y)\n obj-$(CONFIG_FSL_LBC)\t\t+= fsl_lbc.o\n obj-$(CONFIG_FSL_GTM)\t\t+= fsl_gtm.o\n+obj-$(CONFIG_MPC8xxx_GPIO)\t+= mpc8xxx_gpio.o\n obj-$(CONFIG_RAPIDIO)\t\t+= fsl_rio.o\n obj-$(CONFIG_TSI108_BRIDGE)\t+= tsi108_pci.o tsi108_dev.o\n obj-$(CONFIG_QUICC_ENGINE)\t+= qe_lib/\ndiff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c\nnew file mode 100644\nindex 0000000..103eace\n--- /dev/null\n+++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c\n@@ -0,0 +1,171 @@\n+/*\n+ * GPIOs on MPC8349/8572/8610 and compatible\n+ *\n+ * Copyright (C) 2008 Peter Korsgaard <jacmet@sunsite.dk>\n+ *\n+ * This file is licensed under the terms of the GNU General Public License\n+ * version 2. This program is licensed \"as is\" without any warranty of any\n+ * kind, whether express or implied.\n+ */\n+\n+#include <linux/kernel.h>\n+#include <linux/init.h>\n+#include <linux/spinlock.h>\n+#include <linux/io.h>\n+#include <linux/of.h>\n+#include <linux/of_gpio.h>\n+#include <linux/gpio.h>\n+\n+#define MPC8XXX_GPIO_PINS\t32\n+\n+#define GPIO_DIR\t\t0x00\n+#define GPIO_ODR\t\t0x04\n+#define GPIO_DAT\t\t0x08\n+#define GPIO_IER\t\t0x0c\n+#define GPIO_IMR\t\t0x10\n+#define GPIO_ICR\t\t0x14\n+\n+struct mpc8xxx_gpio_chip {\n+\tstruct of_mm_gpio_chip mm_gc;\n+\tspinlock_t lock;\n+\n+\t/*\n+\t * shadowed data register to be able to clear/set output pins in\n+\t * open drain mode safely\n+\t */\n+\tu32 data;\n+};\n+\n+static inline u32 mpc8xxx_gpio2mask(unsigned int gpio)\n+{\n+\treturn 1u << (MPC8XXX_GPIO_PINS - 1 - gpio);\n+}\n+\n+static inline struct mpc8xxx_gpio_chip *\n+to_mpc8xxx_gpio_chip(struct of_mm_gpio_chip *mm)\n+{\n+\treturn container_of(mm, struct mpc8xxx_gpio_chip, mm_gc);\n+}\n+\n+static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm)\n+{\n+\tstruct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);\n+\n+\tmpc8xxx_gc->data = in_be32(mm->regs + GPIO_DAT);\n+}\n+\n+static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio)\n+{\n+\tstruct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);\n+\n+\treturn in_be32(mm->regs + GPIO_DAT) & mpc8xxx_gpio2mask(gpio);\n+}\n+\n+static void mpc8xxx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)\n+{\n+\tstruct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);\n+\tstruct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);\n+\tunsigned long flags;\n+\n+\tspin_lock_irqsave(&mpc8xxx_gc->lock, flags);\n+\n+\tif (val)\n+\t\tmpc8xxx_gc->data |= mpc8xxx_gpio2mask(gpio);\n+\telse\n+\t\tmpc8xxx_gc->data &= ~mpc8xxx_gpio2mask(gpio);\n+\n+\tout_be32(mm->regs + GPIO_DAT, mpc8xxx_gc->data);\n+\n+\tspin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);\n+}\n+\n+static int mpc8xxx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)\n+{\n+\tstruct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);\n+\tstruct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);\n+\tunsigned long flags;\n+\n+\tspin_lock_irqsave(&mpc8xxx_gc->lock, flags);\n+\n+\tclrbits32(mm->regs + GPIO_DIR, mpc8xxx_gpio2mask(gpio));\n+\n+\tspin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);\n+\n+\treturn 0;\n+}\n+\n+static int mpc8xxx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)\n+{\n+\tstruct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);\n+\tstruct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);\n+\tunsigned long flags;\n+\n+\tmpc8xxx_gpio_set(gc, gpio, val);\n+\n+\tspin_lock_irqsave(&mpc8xxx_gc->lock, flags);\n+\n+\tsetbits32(mm->regs + GPIO_DIR, mpc8xxx_gpio2mask(gpio));\n+\n+\tspin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);\n+\n+\treturn 0;\n+}\n+\n+static void __init mpc8xxx_add_controller(struct device_node *np)\n+{\n+\tstruct mpc8xxx_gpio_chip *mpc8xxx_gc;\n+\tstruct of_mm_gpio_chip *mm_gc;\n+\tstruct of_gpio_chip *of_gc;\n+\tstruct gpio_chip *gc;\n+\tint ret;\n+\n+\tmpc8xxx_gc = kzalloc(sizeof(*mpc8xxx_gc), GFP_KERNEL);\n+\tif (!mpc8xxx_gc) {\n+\t\tret = -ENOMEM;\n+\t\tgoto err;\n+\t}\n+\n+\tspin_lock_init(&mpc8xxx_gc->lock);\n+\n+\tmm_gc = &mpc8xxx_gc->mm_gc;\n+\tof_gc = &mm_gc->of_gc;\n+\tgc = &of_gc->gc;\n+\n+\tmm_gc->save_regs = mpc8xxx_gpio_save_regs;\n+\tof_gc->gpio_cells = 2;\n+\tgc->ngpio = MPC8XXX_GPIO_PINS;\n+\tgc->direction_input = mpc8xxx_gpio_dir_in;\n+\tgc->direction_output = mpc8xxx_gpio_dir_out;\n+\tgc->get = mpc8xxx_gpio_get;\n+\tgc->set = mpc8xxx_gpio_set;\n+\n+\tret = of_mm_gpiochip_add(np, mm_gc);\n+\tif (ret)\n+\t\tgoto err;\n+\n+\treturn;\n+\n+err:\n+\tpr_err(\"%s: registration failed with status %d\\n\",\n+\t np->full_name, ret);\n+\tkfree(mpc8xxx_gc);\n+\n+\treturn;\n+}\n+\n+static int __init mpc8xxx_add_gpiochips(void)\n+{\n+\tstruct device_node *np;\n+\n+\tfor_each_compatible_node(np, NULL, \"fsl,mpc8349-gpio\")\n+\t\tmpc8xxx_add_controller(np);\n+\n+\tfor_each_compatible_node(np, NULL, \"fsl,mpc8572-gpio\")\n+\t\tmpc8xxx_add_controller(np);\n+\n+\tfor_each_compatible_node(np, NULL, \"fsl,mpc8610-gpio\")\n+\t\tmpc8xxx_add_controller(np);\n+\n+\treturn 0;\n+}\n+arch_initcall(mpc8xxx_add_gpiochips);\n", "prefixes": [ "v4" ] }