From patchwork Thu Apr 28 09:05:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 8967081 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 7797F9F1C1 for ; Thu, 28 Apr 2016 09:08:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4341A202D1 for ; Thu, 28 Apr 2016 09:08:45 +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 431BE202BE for ; Thu, 28 Apr 2016 09:08:44 +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 1avhuH-00074P-KG; Thu, 28 Apr 2016 09:06:45 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1avhtV-0006T8-Lw for linux-arm-kernel@lists.infradead.org; Thu, 28 Apr 2016 09:05:59 +0000 Received: by mail-wm0-x244.google.com with SMTP id e201so20931324wme.2 for ; Thu, 28 Apr 2016 02:05:36 -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=uScdYCh0sglS1AqOyoWRwPg3jGHNF5vFoMsDbDByyQA=; b=AQlkiiz33bbzggQadXKxdVA6mPz+owedLO+PE0/88UrhULLsTOvI/1n1vp3h1IifNW /U2DkTHc1O3ew6QyEzgt9WavKdAQGtJFNdhz+DCYFPxehmqFJgi3MmOgICsPu9DORskK tacVckXH5SJcmqxAjW07Kw/M+XhZF52gceBFs6kd2eGcOoln4nTskRX1IxoB2c/u6xty PcLTLezvY+YgBcbVNLyquhFWUr4phxb4t12UQVtlnT9ygaqkjsnj1Xb4juhCsVdfJUCP V4qG1V0Esnx6A4+Etq3qAdnVp8S3DU3GEQg9TWnhXsv24Xqchf9p81QvFVSUKygbXLWk TJOA== 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=uScdYCh0sglS1AqOyoWRwPg3jGHNF5vFoMsDbDByyQA=; b=beHedP5y++A2nm51DdVjAolm/qKLfV/fKKGbbQHPXvIuFRsjgNLR/0mqDdTz3QV+tP DB9lvdwR3jtHGxNHfgQQPXd2OQHEBHHTgM6TKs1WuCLvtvdnOP9pgAB15MFoGsv6cd3a UL7BnY0S1joXOJ2Uw5PeQwpFUoBsTsjjQT5Nnvw8e2TRSQNwAMbHdQF7/+880xcNKUAh oe4kPF2WTtqJEEP3rSLwksLJAsBWIg5u9QKczexYarhoGHhDxjc3OaNziv8M0SxOmbyt 5d63sINuFCfdlfpu/+75aNX2NS1GbZRSgch0bUHTOWn/mP4PW57oxonpHiia7J4jYLwl Rejw== X-Gm-Message-State: AOPr4FUKHqbkrPAEoYvH59Z0kMGqgk2CwZFX55F7Z62WSqcLBM6bjozcFGO9zzDc8qzf8A== X-Received: by 10.194.93.2 with SMTP id cq2mr14993820wjb.151.1461834335116; Thu, 28 Apr 2016 02:05:35 -0700 (PDT) Received: from debian64.daheim (p5B2E6CB2.dip0.t-ipconnect.de. [91.46.108.178]) by smtp.googlemail.com with ESMTPSA id gk4sm8512258wjd.7.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-0001wA-HT; 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 4/8] gpio: clps711x: integrate cirrus clps711x into gpio-mmio Date: Thu, 28 Apr 2016 11:05:14 +0200 Message-Id: <79a6a3bb50a02320cc90690df9ad2b1e91c5c5c3.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_119167_F848B409 X-CRM114-Status: GOOD ( 19.89 ) 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 Cirrus' clps711x driver into the gpio-mmio framework. Signed-off-by: Christian Lamparter --- drivers/gpio/Kconfig | 14 +++---- drivers/gpio/Makefile | 2 +- drivers/gpio/gpio-clps711x.c | 84 ++++++++++++++--------------------------- drivers/gpio/gpio-mmio-compat.h | 11 ++++++ drivers/gpio/gpio-mmio.c | 1 + 5 files changed, 48 insertions(+), 64 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index d1f124e..ff9ac65 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -152,13 +152,6 @@ config GPIO_BRCMSTB help Say yes here to enable GPIO support for Broadcom STB (BCM7XXX) SoCs. -config GPIO_CLPS711X - tristate "CLPS711X GPIO support" - depends on ARCH_CLPS711X || COMPILE_TEST - select GPIO_GENERIC - help - Say yes here to support GPIO on CLPS711X SoCs. - config GPIO_DAVINCI bool "TI Davinci/Keystone GPIO support" default y if ARCH_DAVINCI @@ -213,6 +206,13 @@ config GPIO_GENERIC_PLATFORM Say yes here to support basic platform_device memory-mapped GPIO controllers. if GPIO_GENERIC_PLATFORM +config GPIO_CLPS711X + bool "CLPS711X GPIO support" + depends on ARCH_CLPS711X || COMPILE_TEST + select GPIO_GENERIC + help + Say yes here to support GPIO on CLPS711X SoCs. + endif config GPIO_GRGPIO diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 991598e..a1ae48f 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -14,6 +14,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 obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o @@ -31,7 +32,6 @@ obj-$(CONFIG_GPIO_ATH79) += gpio-ath79.o obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o -obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o diff --git a/drivers/gpio/gpio-clps711x.c b/drivers/gpio/gpio-clps711x.c index 5a69025..2072d0f 100644 --- a/drivers/gpio/gpio-clps711x.c +++ b/drivers/gpio/gpio-clps711x.c @@ -9,83 +9,55 @@ * (at your option) any later version. */ -#include +#include #include +#include +#include #include #include +#include "gpio-mmio-compat.h" -static int clps711x_gpio_probe(struct platform_device *pdev) +int cirrus_clps711x_parse_dt(struct platform_device *pdev, + struct bgpio_pdata *pdata, + unsigned long *flags) { struct device_node *np = pdev->dev.of_node; - void __iomem *dat, *dir; - struct gpio_chip *gc; + int id = np ? of_alias_get_id(np, "gpio") : pdev->id; struct resource *res; - int err, id = np ? of_alias_get_id(np, "gpio") : pdev->id; + struct resource nres[] = { + DEFINE_RES_MEM_NAMED(0, 1, "dat"), + DEFINE_RES_MEM_NAMED(0, 1, "dirout"), + }; if ((id < 0) || (id > 4)) return -ENODEV; - gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL); - if (!gc) - return -ENOMEM; + if (id == 4) { + /* PORTE is 3 lines only */ + pdata->ngpio = 3; + } + + pdata->base = id * 8; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - dat = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(dat)) - return PTR_ERR(dat); + if (!res || resource_size(res) != 0x1) + return -EINVAL; + set_resource_address(&nres[0], res->start, 0x1); res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - dir = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(dir)) - return PTR_ERR(dir); + if (!res || resource_size(res) != 0x1) + return -EINVAL; + set_resource_address(&nres[1], res->start, 0x1); - switch (id) { - case 3: + if (id == 3) { /* PORTD is inverted logic for direction register */ - err = bgpio_init(gc, &pdev->dev, 1, dat, NULL, NULL, - NULL, dir, 0); - break; - default: - err = bgpio_init(gc, &pdev->dev, 1, dat, NULL, NULL, - dir, NULL, 0); - break; - } - - if (err) - return err; - - switch (id) { - case 4: - /* PORTE is 3 lines only */ - gc->ngpio = 3; - break; - default: - break; + nres[1].name = "dirin"; } - gc->base = id * 8; - gc->owner = THIS_MODULE; - platform_set_drvdata(pdev, gc); - - return devm_gpiochip_add_data(&pdev->dev, gc, NULL); + return platform_device_add_resources(pdev, nres, ARRAY_SIZE(nres)); } -static const struct of_device_id __maybe_unused clps711x_gpio_ids[] = { - { .compatible = "cirrus,clps711x-gpio" }, - { } -}; -MODULE_DEVICE_TABLE(of, clps711x_gpio_ids); - -static struct platform_driver clps711x_gpio_driver = { - .driver = { - .name = "clps711x-gpio", - .of_match_table = of_match_ptr(clps711x_gpio_ids), - }, - .probe = clps711x_gpio_probe, -}; -module_platform_driver(clps711x_gpio_driver); - -MODULE_LICENSE("GPL"); MODULE_AUTHOR("Alexander Shiyan "); MODULE_DESCRIPTION("CLPS711X GPIO driver"); MODULE_ALIAS("platform:clps711x-gpio"); +MODULE_ALIAS("clps711x-gpio"); diff --git a/drivers/gpio/gpio-mmio-compat.h b/drivers/gpio/gpio-mmio-compat.h index 73c48bc..32b5510 100644 --- a/drivers/gpio/gpio-mmio-compat.h +++ b/drivers/gpio/gpio-mmio-compat.h @@ -5,6 +5,17 @@ #define ADD(_name, _func) { .compatible = _name, .data = _func } +#if IS_ENABLED(CONFIG_GPIO_CLPS711X) +int cirrus_clps711x_parse_dt(struct platform_device *pdev, + struct bgpio_pdata *pdata, + unsigned long *flags); + +#define GPIO_CLPS711X_COMPATIBLE \ + ADD("cirrus,clps711x-gpio", cirrus_clps711x_parse_dt), +#else +#define GPIO_CLPS711X_COMPATIBLE +#endif /* CONFIG_GPIO_CLPS711X */ + #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 4de9846..1be8cb7 100644 --- a/drivers/gpio/gpio-mmio.c +++ b/drivers/gpio/gpio-mmio.c @@ -608,6 +608,7 @@ static int bgpio_basic_mmio_parse_dt(struct platform_device *pdev, static const struct of_device_id bgpio_of_match[] = { ADD("linux,gpio-mmio", bgpio_basic_mmio_parse_dt), + GPIO_CLPS711X_COMPATIBLE { } };