From patchwork Thu Apr 28 09:05:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 8967111 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0085EBF29F for ; Thu, 28 Apr 2016 09:09:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2990F20221 for ; Thu, 28 Apr 2016 09:09:06 +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 03282202F2 for ; Thu, 28 Apr 2016 09:09:05 +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 1avhuR-0007CZ-1S; Thu, 28 Apr 2016 09:06:55 +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-0006TF-TI for linux-arm-kernel@lists.infradead.org; Thu, 28 Apr 2016 09:06:00 +0000 Received: by mail-wm0-x243.google.com with SMTP id e201so20931638wme.2 for ; Thu, 28 Apr 2016 02:05:38 -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=UkLjP/+7E+Er1AjTbkCCECYZYHtgleHUGEdA0TPNI/g=; b=eeji0cTrrzshwEkrMcSYq9vz4ZJh4lEVYXYRzEo+/p6G5sCDKP4fC/dOSH3gWz4AOU H/VjizkqvMq2V4Ud5VemvUhELjMJkdfJJ4pMxbLQlbbIq+WJehU99VuPFVzL4bQ7PV9P 4qP2j4o1L0k4Wf8k68RlWUuaIuwI+i2IT85M3XtxiROHJOxq35Q37CIlMQpR7ZiUVlPz bnmsl2/XLuGCi/a4TmQNm61fY7Bnml2ym8JvQd4tnDtypFnQ8uYqrg82z57Lysz/Xo63 nS7I9BIOSGfOBw4oT/X/Dvro6GUEDdXjFaYsapRlTqODGpfbd1Fj7ZBQKLLqeH9+H5sS DRCg== 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=UkLjP/+7E+Er1AjTbkCCECYZYHtgleHUGEdA0TPNI/g=; b=Y14cXoyp1kNJmJdoK2nvphTc9HLcUDM08NoGipSSjJ9x/SG1H7VLZDxEOPbpyhUa8M Wc1rvrmvcCZ6evqd7oeewWruH8XQFsKXD5F54/loFz6MQUmo3oz6DTDu6sQ7cYVs1K+0 78/49H7fyF50u698g5B5qQqZB10QJ0vXc0F9FX6vrp50NoZclSMxeb1Q7mSYRg9a7E9S LGA5ZiJh4fwfDBkHWQCPV/FedtSVDVNa5pQclEV96RZTYB3tJytGh+SMVWr8O1T7onO0 bQ+RCOvLOcIjsvQ2zIymi0B45IQR3cYtOkf6O5Aieozr34202dQ6S/p3oOhVoHEBu3Ps GWkA== X-Gm-Message-State: AOPr4FULi0E51t7iNg7+uW8f4w6BGmHJrusA554cORCe8ckj2vAp2WK7xGy75KIb/NtTbQ== X-Received: by 10.194.62.110 with SMTP id x14mr15841934wjr.68.1461834337134; Thu, 28 Apr 2016 02:05:37 -0700 (PDT) Received: from debian64.daheim (p5B2E6CB2.dip0.t-ipconnect.de. [91.46.108.178]) by smtp.googlemail.com with ESMTPSA id m6sm8537492wje.21.2016.04.28.02.05.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Apr 2016 02:05:36 -0700 (PDT) Received: from chuck by debian64.daheim with local (Exim 4.87) (envelope-from ) id 1avht4-0001wK-VT; Thu, 28 Apr 2016 11:05:31 +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 6/8] gpio: moxart: integrate MOXA ART GPIO driver into gpio-mmio Date: Thu, 28 Apr 2016 11:05:16 +0200 Message-Id: <47faa5ebc21fc12688a2b2a009967150f5ecf2ce.1461806071.git.chunkeey@googlemail.com> 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_335590_55E7E8D8 X-CRM114-Status: GOOD ( 18.73 ) 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 driver for the MOXA ART SoC into the gpio-mmio framework. Signed-off-by: Christian Lamparter --- drivers/gpio/Kconfig | 15 ++++---- drivers/gpio/Makefile | 2 +- drivers/gpio/gpio-mmio-compat.h | 12 ++++++ drivers/gpio/gpio-mmio.c | 1 + drivers/gpio/gpio-moxart.c | 81 +++++++++++------------------------------ 5 files changed, 42 insertions(+), 69 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index a0e140d..487297f 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -213,6 +213,13 @@ config GPIO_GE_FPGA and write pin state) for GPIO implemented in a number of GE single board computers. +config GPIO_MOXART + bool "MOXART GPIO support" + depends on ARCH_MOXART || COMPILE_TEST + select GPIO_GENERIC + help + Select this option to enable GPIO driver for + MOXA ART SoC devices. endif config GPIO_GRGPIO @@ -289,14 +296,6 @@ config GPIO_MM_LANTIQ (EBU) found on Lantiq SoCs. The gpios are output only as they are created by attaching a 16bit latch to the bus. -config GPIO_MOXART - bool "MOXART GPIO support" - depends on ARCH_MOXART || COMPILE_TEST - select GPIO_GENERIC - help - Select this option to enable GPIO driver for - MOXA ART SoC devices. - config GPIO_MPC5200 def_bool y depends on PPC_MPC52xx diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index a76b13d..32ad5fe 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o 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 +gpio-generic-$(CONFIG_GPIO_MOXART) += gpio-moxart.o obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o @@ -68,7 +69,6 @@ obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o obj-$(CONFIG_GPIO_MCP23S08) += gpio-mcp23s08.o obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o -obj-$(CONFIG_GPIO_MOXART) += gpio-moxart.o obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o obj-$(CONFIG_GPIO_MSIC) += gpio-msic.o diff --git a/drivers/gpio/gpio-mmio-compat.h b/drivers/gpio/gpio-mmio-compat.h index 63863da..702a384 100644 --- a/drivers/gpio/gpio-mmio-compat.h +++ b/drivers/gpio/gpio-mmio-compat.h @@ -30,6 +30,18 @@ int ge_parse_dt(struct platform_device *pdev, #define GPIO_GE_FPGA_COMPATIBLE #endif /* CONFIG_CONFIG_GPIO_GE_FPGA */ +#if IS_ENABLED(CONFIG_GPIO_MOXART) +int moxart_parse_dt(struct platform_device *pdev, + struct bgpio_pdata *pdata, + unsigned long *flags); + +#define GPIO_MOXART_COMPATIBLE \ + ADD("moxa,moxart-gpio", moxart_parse_dt), + +#else +#define GPIO_MOXART_COMPATIBLE +#endif /* CONFIG_GPIO_MOXART */ + #undef ADD static inline void set_resource_address(struct resource *res, diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c index 81af498..fdaf701 100644 --- a/drivers/gpio/gpio-mmio.c +++ b/drivers/gpio/gpio-mmio.c @@ -610,6 +610,7 @@ static const struct of_device_id bgpio_of_match[] = { ADD("linux,gpio-mmio", bgpio_basic_mmio_parse_dt), GPIO_CLPS711X_COMPATIBLE GPIO_GE_FPGA_COMPATIBLE + GPIO_MOXART_COMPATIBLE { } }; diff --git a/drivers/gpio/gpio-moxart.c b/drivers/gpio/gpio-moxart.c index d58d389..812b86a 100644 --- a/drivers/gpio/gpio-moxart.c +++ b/drivers/gpio/gpio-moxart.c @@ -10,75 +10,36 @@ * warranty of any kind, whether express or implied. */ +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include "gpio-mmio-compat.h" #define GPIO_DATA_OUT 0x00 #define GPIO_DATA_IN 0x04 #define GPIO_PIN_DIRECTION 0x08 -static int moxart_gpio_probe(struct platform_device *pdev) +int moxart_parse_dt(struct platform_device *pdev, + struct bgpio_pdata *pdata, + unsigned long *flags) { - struct device *dev = &pdev->dev; struct resource *res; - struct gpio_chip *gc; - void __iomem *base; - int ret; - - gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL); - if (!gc) - return -ENOMEM; + struct resource nres[] = { + DEFINE_RES_MEM_NAMED(0, 1, "dat"), + DEFINE_RES_MEM_NAMED(0, 1, "set"), + DEFINE_RES_MEM_NAMED(0, 1, "dirout"), + }; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); - - ret = bgpio_init(gc, dev, 4, base + GPIO_DATA_IN, - base + GPIO_DATA_OUT, NULL, - base + GPIO_PIN_DIRECTION, NULL, - BGPIOF_READ_OUTPUT_REG_SET); - if (ret) { - dev_err(&pdev->dev, "bgpio_init failed\n"); - return ret; - } - - gc->label = "moxart-gpio"; - gc->request = gpiochip_generic_request; - gc->free = gpiochip_generic_free; - gc->base = 0; - gc->owner = THIS_MODULE; - - ret = devm_gpiochip_add_data(dev, gc, NULL); - if (ret) { - dev_err(dev, "%s: gpiochip_add failed\n", - dev->of_node->full_name); - return ret; - } - - return ret; + if (!res || resource_size(res) != 12) + return -EINVAL; + + *flags |= BGPIOF_READ_OUTPUT_REG_SET; + set_resource_address(&nres[0], res->start + GPIO_DATA_IN, 0x4); + set_resource_address(&nres[1], res->start + GPIO_DATA_OUT, 0x4); + set_resource_address(&nres[2], res->start + GPIO_PIN_DIRECTION, 0x4); + return platform_device_add_resources(pdev, nres, ARRAY_SIZE(nres)); } - -static const struct of_device_id moxart_gpio_match[] = { - { .compatible = "moxa,moxart-gpio" }, - { } -}; - -static struct platform_driver moxart_gpio_driver = { - .driver = { - .name = "moxart-gpio", - .of_match_table = moxart_gpio_match, - }, - .probe = moxart_gpio_probe, -}; -builtin_platform_driver(moxart_gpio_driver);