From patchwork Thu Apr 28 09:05:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 8967101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C74339FB96 for ; Thu, 28 Apr 2016 09:09:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96FC5202FF for ; Thu, 28 Apr 2016 09:09:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B35B6202E5 for ; Thu, 28 Apr 2016 09:09:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1avhub-0007Lr-Bt; Thu, 28 Apr 2016 09:07:05 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1avhtV-0006TA-TH for linux-arm-kernel@lists.infradead.org; Thu, 28 Apr 2016 09:06:01 +0000 Received: by mail-wm0-x243.google.com with SMTP id n129so11657816wmn.1 for ; Thu, 28 Apr 2016 02:05:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=w/DpGy9xh5t12CuXcOSE3idl2pooQSK+MC+M6hrjqlw=; b=f4QS9veUv5lKxhg5rE4CNvsuNAYxLj7CDVxs6gpFNbnNmL50CDusKL1OA6TGW08d99 7T+1YSmT8fhH6175GemwHRBUqeGFjyWKxS2a4Q82IfbTVDqUnIfVA8zS6Qloj9R05DXS G5D2A6tPaSvWepU1o49939y4WqZm8GMV4HtEb0oMdCu1F1maSnPFnAf3XvXXBJXUya2G f5XTnoHPhdSKlXFApkCqSllax1sA9ax1cFujmDlFfk4d7I4TCQPKT0MytZwidH+7PVMV aVNiQkoOtbLeGqqhVjuV/85V01D2lEMDFeKT4lkPJNcju4EooYUs8OCq6ghKyLU0sJAK kYww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=w/DpGy9xh5t12CuXcOSE3idl2pooQSK+MC+M6hrjqlw=; b=PRZJvTDiCLA4yMXv1tgDTu1/yvJRjzYsFxe3y6ed2C/mRp48l9BQ/sO79lweBFxPvX aM8s9n7JrZ/Kn1C4/RCMSw1uVJdUBETeGOSw2xkaWEQMVAENAs+zx/EmwFu8iulUsDTk zk4kYv60XrhMa5m2MkaaHlDflS/f5sZLYy04NJjA36T472+T6s74Dln3EV74m4769CJi vTv6T7DOgcBU2gSVOoryC6yjly3kjdgXAh1ZXrnzXM0FszxbInw+BHX1WvNfqQx64+xd D01mooWYLXbZuS977slIzL4rYTJuV0NVf7F164WsMqWPBiFeml/GuaP40UIahDOA/n6Y P1RA== X-Gm-Message-State: AOPr4FX5X0pa7NnAlnksj1LaMCTIP+Wl7VwsrPRPDWhX4oKWzRkyLu/u7uVc4Bud/mg9fQ== X-Received: by 10.194.11.36 with SMTP id n4mr14968318wjb.10.1461834336110; Thu, 28 Apr 2016 02:05:36 -0700 (PDT) Received: from debian64.daheim (p5B2E6CB2.dip0.t-ipconnect.de. [91.46.108.178]) by smtp.googlemail.com with ESMTPSA id r123sm12926280wmg.20.2016.04.28.02.05.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Apr 2016 02:05:31 -0700 (PDT) Received: from chuck by debian64.daheim with local (Exim 4.87) (envelope-from ) id 1avht4-0001wF-Nu; Thu, 28 Apr 2016 11:05:30 +0200 From: Christian Lamparter To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v4 5/8] gpio: ge: integrate GE's FPGA GPIO into gpio-mmio Date: Thu, 28 Apr 2016 11:05:15 +0200 Message-Id: X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160428_020558_390150_32C15E06 X-CRM114-Status: GOOD ( 19.69 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Alexandre Courbot , =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= , Pawel Moll , Alexander Shiyan , Ian Campbell , Linus Walleij , Rob Herring , Kumar Gala , Christian Lamparter MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch integrates the gpio-ge driver into the gpio-mmio framework. Signed-off-by: Christian Lamparter --- drivers/gpio/Kconfig | 24 +++++----- drivers/gpio/Makefile | 2 +- drivers/gpio/gpio-ge.c | 101 ++++++++++++---------------------------- drivers/gpio/gpio-mmio-compat.h | 14 ++++++ drivers/gpio/gpio-mmio.c | 1 + 5 files changed, 57 insertions(+), 85 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index ff9ac65..a0e140d 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -187,18 +187,6 @@ config GPIO_ETRAXFS help Say yes here to support the GPIO controller on Axis ETRAX FS SoCs. -config GPIO_GE_FPGA - bool "GE FPGA based GPIO" - depends on GE_FPGA - select GPIO_GENERIC - help - Support for common GPIO functionality provided on some GE Single Board - Computers. - - This driver provides basic support (configure as input or output, read - and write pin state) for GPIO implemented in a number of GE single - board computers. - config GPIO_GENERIC_PLATFORM tristate "Generic memory-mapped GPIO controller support (MMIO platform device)" select GPIO_GENERIC @@ -213,6 +201,18 @@ config GPIO_CLPS711X help Say yes here to support GPIO on CLPS711X SoCs. +config GPIO_GE_FPGA + bool "GE FPGA based GPIO" + depends on GE_FPGA || COMPILE_TEST + select GPIO_GENERIC + help + Support for common GPIO functionality provided on some GE Single Board + Computers. + + This driver provides basic support (configure as input or output, read + and write pin state) for GPIO implemented in a number of GE single + board computers. + endif config GPIO_GRGPIO diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index a1ae48f..a76b13d 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o # directly supported by gpio-generic gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o gpio-generic-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o +gpio-generic-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o @@ -43,7 +44,6 @@ obj-$(CONFIG_GPIO_EM) += gpio-em.o obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o obj-$(CONFIG_GPIO_ETRAXFS) += gpio-etraxfs.o obj-$(CONFIG_GPIO_F7188X) += gpio-f7188x.o -obj-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o obj-$(CONFIG_GPIO_ICH) += gpio-ich.o obj-$(CONFIG_GPIO_IOP) += gpio-iop.o diff --git a/drivers/gpio/gpio-ge.c b/drivers/gpio/gpio-ge.c index 8650b29..63cea89 100644 --- a/drivers/gpio/gpio-ge.c +++ b/drivers/gpio/gpio-ge.c @@ -18,13 +18,12 @@ */ #include -#include -#include -#include -#include -#include #include +#include +#include #include +#include +#include "gpio-mmio-compat.h" #define GEF_GPIO_DIRECT 0x00 #define GEF_GPIO_IN 0x04 @@ -36,79 +35,37 @@ #define GEF_GPIO_OVERRUN 0x1C #define GEF_GPIO_MODE 0x20 -static const struct of_device_id gef_gpio_ids[] = { - { - .compatible = "gef,sbc610-gpio", - .data = (void *)19, - }, { - .compatible = "gef,sbc310-gpio", - .data = (void *)6, - }, { - .compatible = "ge,imp3a-gpio", - .data = (void *)16, - }, - { } -}; -MODULE_DEVICE_TABLE(of, gef_gpio_ids); - -static int __init gef_gpio_probe(struct platform_device *pdev) +int ge_parse_dt(struct platform_device *pdev, + struct bgpio_pdata *pdata, + unsigned long *flags) { - const struct of_device_id *of_id = - of_match_device(gef_gpio_ids, &pdev->dev); - struct gpio_chip *gc; - void __iomem *regs; - int ret; - - gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL); - if (!gc) - return -ENOMEM; - - regs = of_iomap(pdev->dev.of_node, 0); - if (!regs) - return -ENOMEM; - - ret = bgpio_init(gc, &pdev->dev, 4, regs + GEF_GPIO_IN, - regs + GEF_GPIO_OUT, NULL, NULL, - regs + GEF_GPIO_DIRECT, BGPIOF_BIG_ENDIAN_BYTE_ORDER); - if (ret) { - dev_err(&pdev->dev, "bgpio_init failed\n"); - goto err0; - } + struct device_node *np = pdev->dev.of_node; - /* Setup pointers to chip functions */ - gc->label = devm_kstrdup(&pdev->dev, pdev->dev.of_node->full_name, - GFP_KERNEL); - if (!gc->label) { - ret = -ENOMEM; - goto err0; - } + struct resource *res; + struct resource nres[] = { + DEFINE_RES_MEM_NAMED(0, 1, "dat"), + DEFINE_RES_MEM_NAMED(0, 1, "set"), + DEFINE_RES_MEM_NAMED(0, 1, "dirin"), + }; - gc->base = -1; - gc->ngpio = (u16)(uintptr_t)of_id->data; - gc->of_gpio_n_cells = 2; - gc->of_node = pdev->dev.of_node; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res || resource_size(res) != 0x24) + return -EINVAL; - /* This function adds a memory mapped GPIO chip */ - ret = devm_gpiochip_add_data(&pdev->dev, gc, NULL); - if (ret) - goto err0; + set_resource_address(&nres[0], res->start + GEF_GPIO_IN, 0x4); + set_resource_address(&nres[1], res->start + GEF_GPIO_OUT, 0x4); + set_resource_address(&nres[2], res->start + GEF_GPIO_DIRECT, 0x4); + *flags |= BGPIOF_BIG_ENDIAN_BYTE_ORDER; - return 0; -err0: - iounmap(regs); - pr_err("%s: GPIO chip registration failed\n", - pdev->dev.of_node->full_name); - return ret; -}; + if (of_device_is_compatible(np, "ge,imp3a-gpio")) + pdata->ngpio = 16; + else if (of_device_is_compatible(np, "gef,sbc310-gpio")) + pdata->ngpio = 6; + else if (of_device_is_compatible(np, "gef,sbc610-gpio")) + pdata->ngpio = 19; -static struct platform_driver gef_gpio_driver = { - .driver = { - .name = "gef-gpio", - .of_match_table = gef_gpio_ids, - }, -}; -module_platform_driver_probe(gef_gpio_driver, gef_gpio_probe); + return platform_device_add_resources(pdev, nres, ARRAY_SIZE(nres)); +} MODULE_DESCRIPTION("GE I/O FPGA GPIO driver"); MODULE_AUTHOR("Martyn Welch