From patchwork Thu Apr 28 09:05:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 8967091 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 1C66E9F1C1 for ; Thu, 28 Apr 2016 09:08:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 690C4202E5 for ; Thu, 28 Apr 2016 09:08:50 +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 68C08202BE for ; Thu, 28 Apr 2016 09:08:49 +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 1avhv0-0007pR-1C; Thu, 28 Apr 2016 09:07:30 +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-0006TL-Lt 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 e201so20931768wme.2 for ; Thu, 28 Apr 2016 02:05:39 -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=Q9SPgoV4u2fdTiogeuAd6ktEDLDunzPWCczoLOQ/2NU=; b=l4wnExV+iS+6kI5ndg3ReIgRmEECVtKXNQh+lmKeu6tq5QKhlqTqGByetc466rCcpb Ao2yiXBxnnB5V4ZsjYSXRvhtOFkyFPtZ5URePHfZKmZmFpPDmL6YuSq1BhJ6iY4L1cug riAa5+ei53tTZheJqyJydFjgvGIU0cPGpe8TrNhA7OoeWDFRR4tFuvjla39T/uahqQGa lvQmNBK6T+cusz1iKzd+8pXo7Ih24B2kZiI0zTgP+a+6XhAcU3ylF6NqxGRLuumRjDFK Aquw2VC+QCJ/N0p9tAUH0vvi8/pW1DjyLNfGuVcRJ6opltG/IdgchM8qPjzkM5I3m0eh k/kg== 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=Q9SPgoV4u2fdTiogeuAd6ktEDLDunzPWCczoLOQ/2NU=; b=isk8VQhXlTTUOnjrKfRLaRJi3ZGids3uOuegoDzBkj+P3Mt4aRF8INec7vLsXLRKXa dBKf0M39OQ3P89ZZxqSVeKYJvdfqJ/KsenzUeP/BdiqmkQzmKA8q1AK2vPTYNnNMUnnD nsRPGaI4LONnmXTXoepIB7DikAm50dVX4TWqdORp2kgUxVNELBakl81trJsEQs9GkVZV e9XAVloqdjPn3RxT+RVhDJ047wJLSLYmDCi/gCscgFmo5oGm3XiZloDSkNFLDNWNkdtf wV9L0GXWCs4IXJO94XltecVEmyJZQimKRuovVwGIYuKOPeOYLtL1Tl8/xdMY5+83n/zU g2Ww== X-Gm-Message-State: AOPr4FXWPHE/Nau2Qgk3uMzqxFuoCQVuc2W3u1WTSQXlHs/tPGLbQs89j4beruj/8mJOJQ== X-Received: by 10.194.78.235 with SMTP id e11mr13804776wjx.54.1461834338035; Thu, 28 Apr 2016 02:05:38 -0700 (PDT) Received: from debian64.daheim (p5B2E6CB2.dip0.t-ipconnect.de. [91.46.108.178]) by smtp.googlemail.com with ESMTPSA id hk7sm8546075wjb.5.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 1avht5-0001wP-5t; 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 7/8] gpio: ts4800: integrate TS4800 into gpio-mmio Date: Thu, 28 Apr 2016 11:05:17 +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_107380_E860383E X-CRM114-Status: GOOD ( 18.40 ) 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 TS4800 FPGA GPIO driver into the gpio-mmio framework. Signed-off-by: Christian Lamparter --- drivers/gpio/Kconfig | 17 ++++----- drivers/gpio/Makefile | 2 +- drivers/gpio/gpio-mmio-compat.h | 11 ++++++ drivers/gpio/gpio-mmio.c | 1 + drivers/gpio/gpio-ts4800.c | 76 ++++++++++++++--------------------------- 5 files changed, 47 insertions(+), 60 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 487297f..7d88527 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -220,6 +220,15 @@ config GPIO_MOXART help Select this option to enable GPIO driver for MOXA ART SoC devices. + +config GPIO_TS4800 + bool "TS-4800 DIO blocks and compatibles" + depends on OF_GPIO + depends on SOC_IMX51 || COMPILE_TEST + select GPIO_GENERIC + help + This driver support TS-4800 FPGA GPIO controllers. + endif config GPIO_GRGPIO @@ -407,14 +416,6 @@ config GPIO_TEGRA default y depends on ARCH_TEGRA || COMPILE_TEST -config GPIO_TS4800 - tristate "TS-4800 DIO blocks and compatibles" - depends on OF_GPIO - depends on SOC_IMX51 || COMPILE_TEST - select GPIO_GENERIC - help - This driver support TS-4800 FPGA GPIO controllers. - config GPIO_TZ1090 bool "Toumaz Xenif TZ1090 GPIO support" depends on SOC_TZ1090 diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 32ad5fe..f9e5036 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -17,6 +17,7 @@ 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 +gpio-generic-$(CONFIG_GPIO_TS4800) += gpio-ts4800.o obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o @@ -107,7 +108,6 @@ obj-$(CONFIG_GPIO_TPS65218) += gpio-tps65218.o obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o -obj-$(CONFIG_GPIO_TS4800) += gpio-ts4800.o obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o diff --git a/drivers/gpio/gpio-mmio-compat.h b/drivers/gpio/gpio-mmio-compat.h index 702a384..a85835b 100644 --- a/drivers/gpio/gpio-mmio-compat.h +++ b/drivers/gpio/gpio-mmio-compat.h @@ -42,6 +42,17 @@ int moxart_parse_dt(struct platform_device *pdev, #define GPIO_MOXART_COMPATIBLE #endif /* CONFIG_GPIO_MOXART */ +#if IS_ENABLED(CONFIG_GPIO_TS4800) +int technologic_ts4800_parse_dt(struct platform_device *pdev, + struct bgpio_pdata *pdata, + unsigned long *flags); + +#define GPIO_TS4800_COMPATIBLE \ + ADD("technologic,ts4800-gpio", technologic_ts4800_parse_dt), +#else +#define GPIO_TS4800_COMPATIBLE +#endif /* CONFIG_GPIO_TS4800 */ + #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 fdaf701..9f2cb2c 100644 --- a/drivers/gpio/gpio-mmio.c +++ b/drivers/gpio/gpio-mmio.c @@ -611,6 +611,7 @@ static const struct of_device_id bgpio_of_match[] = { GPIO_CLPS711X_COMPATIBLE GPIO_GE_FPGA_COMPATIBLE GPIO_MOXART_COMPATIBLE + GPIO_TS4800_COMPATIBLE { } }; diff --git a/drivers/gpio/gpio-ts4800.c b/drivers/gpio/gpio-ts4800.c index 0c144a7..5003655 100644 --- a/drivers/gpio/gpio-ts4800.c +++ b/drivers/gpio/gpio-ts4800.c @@ -8,74 +8,48 @@ * warranty of any kind, whether express or implied. */ +#include +#include +#include +#include #include -#include -#include #include +#include "gpio-mmio-compat.h" #define DEFAULT_PIN_NUMBER 16 #define INPUT_REG_OFFSET 0x00 #define OUTPUT_REG_OFFSET 0x02 #define DIRECTION_REG_OFFSET 0x04 -static int ts4800_gpio_probe(struct platform_device *pdev) +int technologic_ts4800_parse_dt(struct platform_device *pdev, + struct bgpio_pdata *pdata, + unsigned long *flags) { - struct device_node *node; - struct gpio_chip *chip; + int err; struct resource *res; - void __iomem *base_addr; - int retval; - u32 ngpios; - - chip = devm_kzalloc(&pdev->dev, sizeof(struct gpio_chip), GFP_KERNEL); - if (!chip) - 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_addr = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(base_addr)) - return PTR_ERR(base_addr); - - node = pdev->dev.of_node; - if (!node) + if (!res || resource_size(res) != 6) return -EINVAL; - retval = of_property_read_u32(node, "ngpios", &ngpios); - if (retval == -EINVAL) - ngpios = DEFAULT_PIN_NUMBER; - else if (retval) - return retval; - - retval = bgpio_init(chip, &pdev->dev, 2, base_addr + INPUT_REG_OFFSET, - base_addr + OUTPUT_REG_OFFSET, NULL, - base_addr + DIRECTION_REG_OFFSET, NULL, 0); - if (retval) { - dev_err(&pdev->dev, "bgpio_init failed\n"); - return retval; - } - - chip->ngpio = ngpios; + set_resource_address(&nres[0], res->start + INPUT_REG_OFFSET, 0x2); + set_resource_address(&nres[1], res->start + OUTPUT_REG_OFFSET, 0x2); + set_resource_address(&nres[2], res->start + DIRECTION_REG_OFFSET, 0x2); - platform_set_drvdata(pdev, chip); + err = of_property_read_u32(pdev->dev.of_node, "ngpios", &pdata->ngpio); + if (err == -EINVAL) + pdata->ngpio = DEFAULT_PIN_NUMBER; + else if (err) + return err; - return devm_gpiochip_add_data(&pdev->dev, chip, NULL); + return platform_device_add_resources(pdev, nres, ARRAY_SIZE(nres)); } -static const struct of_device_id ts4800_gpio_of_match[] = { - { .compatible = "technologic,ts4800-gpio", }, - {}, -}; - -static struct platform_driver ts4800_gpio_driver = { - .driver = { - .name = "ts4800-gpio", - .of_match_table = ts4800_gpio_of_match, - }, - .probe = ts4800_gpio_probe, -}; - -module_platform_driver_probe(ts4800_gpio_driver, ts4800_gpio_probe); - MODULE_AUTHOR("Julien Grossholtz "); MODULE_DESCRIPTION("TS4800 FPGA GPIO driver"); -MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("gpio-ts4800");