From patchwork Wed Nov 11 17:25:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro Iwamatsu X-Patchwork-Id: 11896913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEDA2C388F9 for ; Wed, 11 Nov 2020 08:31:08 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08EA3207BB for ; Wed, 11 Nov 2020 08:31:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="i5amdL7Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08EA3207BB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=toshiba.co.jp Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yz6vG9DJbMJ4QOMnhOI7R0eLVf3zi44BdDA+Xx1tzr4=; b=i5amdL7Yw3qVDI2OpTSDB5lNM CQKVQg/owBtzurz4gjLBL24cnIJSfJ/4BD4QYRCOo0yk8W6C76e/MyAMStjBZtukEMV3PE8gYz0pX /Sra8aM8T9J0pINk4P0Y3DBn6XPEsfGABePhD19583rLpzKLXHK4GnDuhuncR6LrXWqW0MlN+A1DS fv1Eo5p6CsMlVclR1e4GEYrEEC35q8XkfBahSply5w5JMAeWm28Z1dxJlidrukzK6zYqu8POGU8zG fGWvKQu2FYOnqBKvBCmJkC+KWbv9BaHgNN0l1cT/YyVPNOzEysFj1fHev894oMeCGZU634L5rz8fZ rBOIQrNlQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kclW2-00050Y-Qt; Wed, 11 Nov 2020 08:30:09 +0000 Received: from mo-csw1514.securemx.jp ([210.130.202.153] helo=mo-csw.securemx.jp) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kclTG-000423-BC for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2020 08:27:18 +0000 Received: by mo-csw.securemx.jp (mx-mo-csw1514) id 0AB8R4d4028947; Wed, 11 Nov 2020 17:27:04 +0900 X-Iguazu-Qid: 34tru22Sm28wWYIhgO X-Iguazu-QSIG: v=2; s=0; t=1605083224; q=34tru22Sm28wWYIhgO; m=aeEbFW/VjOoxOWHY2UeFS7I+hvaA/8Ym7LB/V4U4feM= Received: from imx12.toshiba.co.jp (imx12.toshiba.co.jp [61.202.160.132]) by relay.securemx.jp (mx-mr1510) id 0AB8R3iU020951; Wed, 11 Nov 2020 17:27:03 +0900 Received: from enc02.toshiba.co.jp ([61.202.160.51]) by imx12.toshiba.co.jp with ESMTP id 0AB8R3Mr006953; Wed, 11 Nov 2020 17:27:03 +0900 (JST) Received: from hop101.toshiba.co.jp ([133.199.85.107]) by enc02.toshiba.co.jp with ESMTP id 0AB8R2wE032436; Wed, 11 Nov 2020 17:27:02 +0900 From: Nobuhiro Iwamatsu To: Rob Herring , Linus Walleij Subject: [PATCH 1/4] dt-bindings: gpio: Add bindings for Toshiba Visconti GPIO Controller Date: Thu, 12 Nov 2020 02:25:50 +0900 X-TSB-HOP: ON Message-Id: <20201111172553.1369282-2-nobuhiro1.iwamatsu@toshiba.co.jp> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201111172553.1369282-1-nobuhiro1.iwamatsu@toshiba.co.jp> References: <20201111172553.1369282-1-nobuhiro1.iwamatsu@toshiba.co.jp> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201111_032714_857402_FBD80665 X-CRM114-Status: GOOD ( 11.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, punit1.agrawal@toshiba.co.jp, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Nobuhiro Iwamatsu , yuji2.ishikawa@toshiba.co.jp, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add bindings for the Toshiba Visconti GPIO Controller. Signed-off-by: Nobuhiro Iwamatsu --- .../bindings/gpio/toshiba,gpio-visconti.yaml | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/toshiba,gpio-visconti.yaml diff --git a/Documentation/devicetree/bindings/gpio/toshiba,gpio-visconti.yaml b/Documentation/devicetree/bindings/gpio/toshiba,gpio-visconti.yaml new file mode 100644 index 000000000000..49356b9b6284 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/toshiba,gpio-visconti.yaml @@ -0,0 +1,85 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/toshiba,gpio-visconti.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba Visconti ARM SoCs GPIO controller + +maintainers: + - Nobuhiro Iwamatsu + +properties: + compatible: + items: + - const: toshiba,gpio-tmpv7708 + + reg: + maxItems: 1 + + "#gpio-cells": + const: 2 + + gpio-ranges: truei + + gpio-controller: true + + interrupt-controller: true + + "#interrupt-cells": + const: 2 + + interrupts: + description: + interrupt mapping one per GPIO. + minItems: 32 + maxItems: 32 + +required: + - compatible + - reg + - "#gpio-cells" + - gpio-ranges + - gpio-controller + - interrupt-controller + - "#interrupt-cells" + - interrupts + +additionalProperties: false + +examples: + - | + #include + #include + + soc { + #address-cells = <2>; + #size-cells = <2>; + + gpio: gpio@28020000 { + compatible = "toshiba,gpio-tmpv7708"; + reg = <0 0x28020000 0 0x1000>; + #gpio-cells = <0x2>; + gpio-ranges = <&pmux 0 0 32>; + gpio-controller; + interrupt-controller; + #interrupt-cells = <2>; + interrupts = , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + }; + }; +... From patchwork Wed Nov 11 17:25:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro Iwamatsu X-Patchwork-Id: 11896915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74015C4742C for ; Wed, 11 Nov 2020 08:31:30 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DFCE7205CA for ; Wed, 11 Nov 2020 08:31:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sKHlhTo4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFCE7205CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=toshiba.co.jp Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nkN0xgbNemuYK6FbKAlRO5TAf6ECyZMn2l3wNSbThEg=; b=sKHlhTo4PZtXwfSXsMqomPwrR 12h8oy4BK27LcuFn6kQoiNv1FzcehkyHoCT9lrTki021A0CCaG/ncpdZ5hL6WJtj8EEIWpq4Rrrq8 ovnb/qd38r9MuxNLb6r2djkTE3dlLhW5a7pNv3zLLCbX07Mgxs0h8OWeP9qOImunv7kZGp86XXzAn gEtbzYivaqczsCV22demYVKDMmg1eJ7Fuh9aq0RDjkdcDOKCDgPLTs8+mIhynkdnQVJrtbxRYDRQG U0ljezcV6fXWkW9Xrao7ckevWcNcvE6zmWfYFZ4/ZYd1MFomER3DuD50jKwxA2xPkei1d+kwe/RiJ ltlcobzdw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kclWN-00058a-0l; Wed, 11 Nov 2020 08:30:27 +0000 Received: from mo-csw1514.securemx.jp ([210.130.202.153] helo=mo-csw.securemx.jp) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kclTH-00043J-Aq for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2020 08:27:19 +0000 Received: by mo-csw.securemx.jp (mx-mo-csw1514) id 0AB8RAf8029352; Wed, 11 Nov 2020 17:27:10 +0900 X-Iguazu-Qid: 34ts1bXBCWNx5lGpLG X-Iguazu-QSIG: v=2; s=0; t=1605083230; q=34ts1bXBCWNx5lGpLG; m=sg7wuxs2jsQQBFDTvCm9P547QkMobmb9beTKpiAmDUg= Received: from imx12.toshiba.co.jp (imx12.toshiba.co.jp [61.202.160.132]) by relay.securemx.jp (mx-mr1513) id 0AB8R9Ii025832; Wed, 11 Nov 2020 17:27:09 +0900 Received: from enc02.toshiba.co.jp ([61.202.160.51]) by imx12.toshiba.co.jp with ESMTP id 0AB8R96o007010; Wed, 11 Nov 2020 17:27:09 +0900 (JST) Received: from hop101.toshiba.co.jp ([133.199.85.107]) by enc02.toshiba.co.jp with ESMTP id 0AB8R8sD032536; Wed, 11 Nov 2020 17:27:09 +0900 From: Nobuhiro Iwamatsu To: Rob Herring , Linus Walleij Subject: [PATCH 2/4] gpio: visoconti: Add Toshiba Visconti GPIO support Date: Thu, 12 Nov 2020 02:25:51 +0900 X-TSB-HOP: ON Message-Id: <20201111172553.1369282-3-nobuhiro1.iwamatsu@toshiba.co.jp> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201111172553.1369282-1-nobuhiro1.iwamatsu@toshiba.co.jp> References: <20201111172553.1369282-1-nobuhiro1.iwamatsu@toshiba.co.jp> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201111_032715_810846_C7C3D9B0 X-CRM114-Status: GOOD ( 24.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, punit1.agrawal@toshiba.co.jp, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Nobuhiro Iwamatsu , yuji2.ishikawa@toshiba.co.jp, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add the GPIO driver for Toshiba Visconti ARM SoCs. Signed-off-by: Nobuhiro Iwamatsu --- drivers/gpio/Kconfig | 8 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-visconti.c | 287 ++++++++++++++++++++++ drivers/pinctrl/visconti/pinctrl-common.c | 23 ++ 4 files changed, 319 insertions(+) create mode 100644 drivers/gpio/gpio-visconti.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 5d4de5cd6759..fd8bd229b0c6 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -631,6 +631,14 @@ config GPIO_VF610 help Say yes here to support Vybrid vf610 GPIOs. +config GPIO_VISCONTI + tristate "Toshiba Visconti GPIO support" + depends on ARCH_VISCONTI || COMPILE_TEST + depends on OF_GPIO + select GPIOLIB_IRQCHIP + help + Say yes here to support GPIO on Tohisba Visconti. + config GPIO_VR41XX tristate "NEC VR4100 series General-purpose I/O Uint support" depends on CPU_VR41XX diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 09dada80ac34..02c9d8d83a54 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -162,6 +162,7 @@ obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o obj-$(CONFIG_GPIO_UNIPHIER) += gpio-uniphier.o obj-$(CONFIG_GPIO_VF610) += gpio-vf610.o obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o +obj-$(CONFIG_GPIO_VISCONTI) += gpio-visconti.o obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o obj-$(CONFIG_GPIO_VX855) += gpio-vx855.o obj-$(CONFIG_GPIO_WCD934X) += gpio-wcd934x.o diff --git a/drivers/gpio/gpio-visconti.c b/drivers/gpio/gpio-visconti.c new file mode 100644 index 000000000000..e12f53ad1a0b --- /dev/null +++ b/drivers/gpio/gpio-visconti.c @@ -0,0 +1,287 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Toshiba Visconti GPIO Support + * + * (C) Copyright 2020 Toshiba Electronic Devices & Storage Corporation + * (C) Copyright 2020 Nobuhiro Iwamatsu + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* register offset */ +#define GPIO_DIR 0x00 +#define GPIO_IDATA 0x08 +#define GPIO_ODATA 0x10 +#define GPIO_OSET 0x18 +#define GPIO_OCLR 0x20 +#define GPIO_INTMODE 0x30 + +#define VISCONTI_GPIO_NR 32 + +struct visconti_gpio { + void __iomem *base; + int *irq; + spinlock_t lock; /* protect gpio register */ + struct device *dev; + struct gpio_chip gpio_chip; + struct irq_chip irq_chip; +}; + +static void visconti_gpio_irq_mask(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct visconti_gpio *priv = gpiochip_get_data(gc); + + disable_irq_nosync(priv->irq[irqd_to_hwirq(d)]); +} + +static void visconti_gpio_irq_unmask(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct visconti_gpio *priv = gpiochip_get_data(gc); + + enable_irq(priv->irq[irqd_to_hwirq(d)]); +} + +static int visconti_gpio_irq_set_type(struct irq_data *d, unsigned int type) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct visconti_gpio *priv = gpiochip_get_data(gc); + u32 offset = irqd_to_hwirq(d); + u32 bit = BIT(offset); + u32 intc_type = IRQ_TYPE_EDGE_RISING; + u32 intmode, odata; + int ret = 0; + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + + odata = readl(priv->base + GPIO_ODATA); + intmode = readl(priv->base + GPIO_INTMODE); + + switch (type) { + case IRQ_TYPE_EDGE_RISING: + odata &= ~bit; + intmode &= ~bit; + break; + case IRQ_TYPE_EDGE_FALLING: + odata |= bit; + intmode &= ~bit; + break; + case IRQ_TYPE_EDGE_BOTH: + intmode |= bit; + break; + case IRQ_TYPE_LEVEL_HIGH: + intc_type = IRQ_TYPE_LEVEL_HIGH; + odata &= ~bit; + intmode &= ~bit; + break; + case IRQ_TYPE_LEVEL_LOW: + intc_type = IRQ_TYPE_LEVEL_HIGH; + odata |= bit; + intmode &= ~bit; + break; + default: + ret = -EINVAL; + goto err; + } + + writel(odata, priv->base + GPIO_ODATA); + writel(intmode, priv->base + GPIO_INTMODE); + irq_set_irq_type(priv->irq[offset], intc_type); +err: + spin_unlock_irqrestore(&priv->lock, flags); + + return ret; +} + +static irqreturn_t visconti_gpio_irq_handler(int irq, void *dev_id) +{ + struct visconti_gpio *priv = dev_id; + u32 offset = irq - priv->irq[0]; + + generic_handle_irq(irq_find_mapping(priv->gpio_chip.irq.domain, offset)); + + return IRQ_HANDLED; +} + +static int visconti_gpio_get(struct gpio_chip *chip, unsigned int offset) +{ + struct visconti_gpio *priv = gpiochip_get_data(chip); + + return !!(readl(priv->base + GPIO_IDATA) & BIT(offset)); +} + +static void visconti_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) +{ + struct visconti_gpio *priv = gpiochip_get_data(chip); + u32 bit = BIT(offset); + + if (value) + writel(bit, priv->base + GPIO_OSET); + else + writel(bit, priv->base + GPIO_OCLR); +} + +static int visconti_gpio_get_dir(struct gpio_chip *chip, unsigned int offset) +{ + struct visconti_gpio *priv = gpiochip_get_data(chip); + + return !(readl(priv->base + GPIO_DIR) & BIT(offset)); +} + +static int visconti_gpio_dir_in(struct gpio_chip *chip, unsigned int offset) +{ + struct visconti_gpio *priv = gpiochip_get_data(chip); + unsigned long flags; + u32 val; + + spin_lock_irqsave(&priv->lock, flags); + val = readl(priv->base + GPIO_DIR); + val &= ~BIT(offset); + writel(val, priv->base + GPIO_DIR); + spin_unlock_irqrestore(&priv->lock, flags); + + return 0; +} + +static int visconti_gpio_dir_out(struct gpio_chip *chip, unsigned int offset, int value) +{ + struct visconti_gpio *priv = gpiochip_get_data(chip); + unsigned long flags; + u32 val; + + spin_lock_irqsave(&priv->lock, flags); + visconti_gpio_set(chip, offset, value); + val = readl(priv->base + GPIO_DIR); + val |= BIT(offset); + writel(val, priv->base + GPIO_DIR); + spin_unlock_irqrestore(&priv->lock, flags); + + return 0; +} + +static void visconti_init_irq_valid_mask(struct gpio_chip *chip, unsigned long *valid_mask, + unsigned int ngpios) +{ + int i; + + /* Exclude GPIO pins 16-31 from irq */ + for (i = 16; i < ngpios; i++) + clear_bit(i, valid_mask); +} + +static int visconti_gpio_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct visconti_gpio *priv; + struct gpio_chip *gpio_chip; + struct irq_chip *irq_chip; + struct irq_desc *desc; + const char *name = dev_name(dev); + int i, ret, num_irq; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->dev = dev; + spin_lock_init(&priv->lock); + + priv->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + + ret = platform_irq_count(pdev); + if (!ret) { + dev_err(dev, "Couldn't determine # GPIO banks\n"); + return -ENOENT; + } + num_irq = ret; + + priv->irq = devm_kcalloc(dev, num_irq, sizeof(priv->irq), GFP_KERNEL); + if (!priv->irq) + return -ENOMEM; + + for (i = 0; i < num_irq; i++) { + priv->irq[i] = platform_get_irq(pdev, i); + if (priv->irq[i] < 0) { + dev_err(dev, "invalid IRQ[%d]\n", i); + return priv->irq[i]; + } + } + + gpio_chip = &priv->gpio_chip; + gpio_chip->label = name; + gpio_chip->owner = THIS_MODULE; + gpio_chip->parent = dev; + gpio_chip->request = gpiochip_generic_request; + gpio_chip->free = gpiochip_generic_free; + gpio_chip->get = visconti_gpio_get; + gpio_chip->set = visconti_gpio_set; + gpio_chip->get_direction = visconti_gpio_get_dir; + gpio_chip->direction_input = visconti_gpio_dir_in; + gpio_chip->direction_output = visconti_gpio_dir_out; + gpio_chip->base = 0; + gpio_chip->ngpio = VISCONTI_GPIO_NR; + gpio_chip->irq.init_valid_mask = visconti_init_irq_valid_mask; + + irq_chip = &priv->irq_chip; + irq_chip->name = "gpio-visconti"; + irq_chip->irq_mask = visconti_gpio_irq_mask; + irq_chip->irq_unmask = visconti_gpio_irq_unmask; + irq_chip->irq_set_type = visconti_gpio_irq_set_type; + irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; + + ret = devm_gpiochip_add_data(dev, gpio_chip, priv); + if (ret) { + dev_err(dev, "failed to add GPIO chip\n"); + return ret; + } + + ret = gpiochip_irqchip_add(gpio_chip, irq_chip, 0, handle_level_irq, + IRQ_TYPE_NONE); + if (ret) { + dev_err(dev, "cannot add IRQ chip\n"); + return ret; + } + + for (i = 0; i < num_irq; i++) { + desc = irq_to_desc(priv->irq[i]); + desc->status_use_accessors |= IRQ_NOAUTOEN; + if (devm_request_irq(dev, priv->irq[i], + visconti_gpio_irq_handler, 0, name, priv)) { + dev_err(dev, "failed to request IRQ[%d]\n", i); + return -ENOENT; + } + } + + return ret; +} + +static const struct of_device_id visconti_gpio_of_match[] = { + { .compatible = "toshiba,gpio-tmpv7708", }, + { /* end of table */ } +}; +MODULE_DEVICE_TABLE(of, visconti_gpio_of_match); + +static struct platform_driver visconti_gpio_driver = { + .probe = visconti_gpio_probe, + .driver = { + .name = "visconti_gpio", + .of_match_table = of_match_ptr(visconti_gpio_of_match), + } +}; +module_platform_driver(visconti_gpio_driver); + +MODULE_AUTHOR("Toshiba Electronic Devices & Storage Corporation"); +MODULE_AUTHOR("Nobuhiro Iwamatsu "); +MODULE_DESCRIPTION("Toshiba Visconti GPIO Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/pinctrl/visconti/pinctrl-common.c b/drivers/pinctrl/visconti/pinctrl-common.c index 0cb10b7b4430..21c7e0d18fea 100644 --- a/drivers/pinctrl/visconti/pinctrl-common.c +++ b/drivers/pinctrl/visconti/pinctrl-common.c @@ -245,11 +245,34 @@ static int visconti_set_mux(struct pinctrl_dev *pctldev, return 0; } +static int visconti_gpio_request_enable(struct pinctrl_dev *pctldev, + struct pinctrl_gpio_range *range, + unsigned int pin) +{ + struct visconti_pinctrl *priv = pinctrl_dev_get_drvdata(pctldev); + const struct visconti_mux *gpio_mux = &priv->devdata->gpio_mux[pin]; + unsigned long flags; + unsigned int val; + + dev_dbg(priv->dev, "%s: pin = %d\n", __func__, pin); + + /* update mux */ + spin_lock_irqsave(&priv->lock, flags); + val = readl(priv->base + gpio_mux->offset); + val &= ~gpio_mux->mask; + val |= gpio_mux->val; + writel(val, priv->base + gpio_mux->offset); + spin_unlock_irqrestore(&priv->lock, flags); + + return 0; +} + static const struct pinmux_ops visconti_pinmux_ops = { .get_functions_count = visconti_get_functions_count, .get_function_name = visconti_get_function_name, .get_function_groups = visconti_get_function_groups, .set_mux = visconti_set_mux, + .gpio_request_enable = visconti_gpio_request_enable, .strict = true, }; From patchwork Wed Nov 11 17:25:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro Iwamatsu X-Patchwork-Id: 11896877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0004FC388F9 for ; Wed, 11 Nov 2020 08:29:50 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E8B5206F1 for ; Wed, 11 Nov 2020 08:29:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aF6F2gxU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E8B5206F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=toshiba.co.jp Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aQYplQNDeo/lb+zJmUmKVIYktIXSrRSxWyyV56Nsv5A=; b=aF6F2gxUQwDsinH7eIgzsiVLh ZtN9CDKYGjbjncZCoo/nF1hSuugqNEZUGcClQfTRCwV6Dv0kTBSf94eKKFWGPozR677eX538pUPUE PnmC9R6B+YgpbPb0dlVC/jEIot6eB+2l436sMUm642c1Nkez3JxRh5MUmuGyM7gLTEHvaJC5PxKpr s7IuyFNu2tL8ZUofXKheavJszsA3499Jl6ojTmRVah+LV6Fr+DpYIA7D3YQ22zPkwMHNCWWcBK0py kTXtgV5QD+r3Nw/MPIWt7/D5nbzg2/uDJWHmyv2IB6b+W5vNJziCaYXH9tBnj8Ejk1IrJJJGiyfVl zycR7Bniw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kclUr-0004Xk-V2; Wed, 11 Nov 2020 08:28:56 +0000 Received: from mo-csw1115.securemx.jp ([210.130.202.157] helo=mo-csw.securemx.jp) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kclTG-00041h-6a for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2020 08:27:16 +0000 Received: by mo-csw.securemx.jp (mx-mo-csw1115) id 0AB8R1O3031490; Wed, 11 Nov 2020 17:27:01 +0900 X-Iguazu-Qid: 2wHHmca9fjm8Ybd8ro X-Iguazu-QSIG: v=2; s=0; t=1605083221; q=2wHHmca9fjm8Ybd8ro; m=KJP6CDDJxGlPugnW+J1zzmfZpKOaWDTq6SkZ7oJbxDk= Received: from imx12.toshiba.co.jp (imx12.toshiba.co.jp [61.202.160.132]) by relay.securemx.jp (mx-mr1111) id 0AB8R0xm017970; Wed, 11 Nov 2020 17:27:00 +0900 Received: from enc02.toshiba.co.jp ([61.202.160.51]) by imx12.toshiba.co.jp with ESMTP id 0AB8R0DO006932; Wed, 11 Nov 2020 17:27:00 +0900 (JST) Received: from hop101.toshiba.co.jp ([133.199.85.107]) by enc02.toshiba.co.jp with ESMTP id 0AB8QxCe032365; Wed, 11 Nov 2020 17:27:00 +0900 From: Nobuhiro Iwamatsu To: Rob Herring , Linus Walleij Subject: [PATCH 3/4] MAINTAINERS: Add entries for Toshiba Visconti GPIO controller Date: Thu, 12 Nov 2020 02:25:52 +0900 X-TSB-HOP: ON Message-Id: <20201111172553.1369282-4-nobuhiro1.iwamatsu@toshiba.co.jp> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201111172553.1369282-1-nobuhiro1.iwamatsu@toshiba.co.jp> References: <20201111172553.1369282-1-nobuhiro1.iwamatsu@toshiba.co.jp> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201111_032714_711061_5E59CD28 X-CRM114-Status: UNSURE ( 8.94 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, punit1.agrawal@toshiba.co.jp, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Nobuhiro Iwamatsu , yuji2.ishikawa@toshiba.co.jp, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add entries for Toshiba Visconti GPIO Controller binding and driver. Signed-off-by: Nobuhiro Iwamatsu --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 94ac10a153c7..7af1f9257eec 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2635,8 +2635,10 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Supported T: git git://git.kernel.org/pub/scm/linux/kernel/git/iwamatsu/linux-visconti.git F: Documentation/devicetree/bindings/arm/toshiba.yaml +F: Documentation/devicetree/bindings/gpio/toshiba,gpio-visconti.yaml F: Documentation/devicetree/bindings/pinctrl/toshiba,tmpv7700-pinctrl.yaml F: arch/arm64/boot/dts/toshiba/ +F: drivers/gpio/gpio-visconti.c F: drivers/pinctrl/visconti/ N: visconti From patchwork Wed Nov 11 17:25:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro Iwamatsu X-Patchwork-Id: 11896953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97D0EC388F9 for ; Wed, 11 Nov 2020 08:33:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EEFE205CA for ; Wed, 11 Nov 2020 08:33:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tzh4Fr+f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0EEFE205CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=toshiba.co.jp Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OGBK67oaidDALMRWe5tSbHBMyMVwnH0QNmKfcS2PwW8=; b=tzh4Fr+fPu/sp0pd+cioETt/7 L+cbfC09V0p/orvzN9MqXIPfp9PYyaopnU9fZ3Ud/hNCudeXpR3PVXoESlQD5P8qf4hxBIiXRRKlJ p4DU6l7wZco3UAjSELQyz6al/9CVMerl05JJiNLpCVyFNbqn2kWgviHlAGFARmvWjeUa8NlIqAJ/u 6vkwkOvelEsZvv3SAdYmXOEajZ/PrjLzGIjEDPn7Khx/2ZLJ6E1q6rPaqUbY/q6d53jEfx6v38JTx kNekTyan36Xp3+GvLsowkknnVplmUMkcHYx1HWmg7al0/CyzLPMzF7XIwRuV7ItjX4sV1K2BT0Wpe jpdE+Jnag==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kclVj-0004tA-Li; Wed, 11 Nov 2020 08:29:47 +0000 Received: from mo-csw1114.securemx.jp ([210.130.202.156] helo=mo-csw.securemx.jp) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kclTG-00042z-BC for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2020 08:27:19 +0000 Received: by mo-csw.securemx.jp (mx-mo-csw1114) id 0AB8R6re025478; Wed, 11 Nov 2020 17:27:06 +0900 X-Iguazu-Qid: 2wHHmca9fjm8rMI7eI X-Iguazu-QSIG: v=2; s=0; t=1605083225; q=2wHHmca9fjm8rMI7eI; m=afy4oIk53vMZyofpYQPL4yJqLx3Qj3dM2D4YgsstBOc= Received: from imx12.toshiba.co.jp (imx12.toshiba.co.jp [61.202.160.132]) by relay.securemx.jp (mx-mr1113) id 0AB8R5pD003613; Wed, 11 Nov 2020 17:27:05 +0900 Received: from enc02.toshiba.co.jp ([61.202.160.51]) by imx12.toshiba.co.jp with ESMTP id 0AB8R4Zh006966; Wed, 11 Nov 2020 17:27:04 +0900 (JST) Received: from hop101.toshiba.co.jp ([133.199.85.107]) by enc02.toshiba.co.jp with ESMTP id 0AB8R4rR032457; Wed, 11 Nov 2020 17:27:04 +0900 From: Nobuhiro Iwamatsu To: Rob Herring , Linus Walleij Subject: [PATCH 4/4] arm: dts: visconti: Add DT support for Toshiba Visconti5 GPIO driver Date: Thu, 12 Nov 2020 02:25:53 +0900 X-TSB-HOP: ON Message-Id: <20201111172553.1369282-5-nobuhiro1.iwamatsu@toshiba.co.jp> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201111172553.1369282-1-nobuhiro1.iwamatsu@toshiba.co.jp> References: <20201111172553.1369282-1-nobuhiro1.iwamatsu@toshiba.co.jp> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201111_032714_988149_9A03F2A0 X-CRM114-Status: UNSURE ( 9.86 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, punit1.agrawal@toshiba.co.jp, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Nobuhiro Iwamatsu , yuji2.ishikawa@toshiba.co.jp, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add the GPIO node in Toshiba Visconti5 SoC-specific DT file. And enable the GPIO node in TMPV7708 RM main board's board-specific DT file. Signed-off-by: Nobuhiro Iwamatsu --- .../boot/dts/toshiba/tmpv7708-rm-mbrc.dts | 4 +++ arch/arm64/boot/dts/toshiba/tmpv7708.dtsi | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/arch/arm64/boot/dts/toshiba/tmpv7708-rm-mbrc.dts b/arch/arm64/boot/dts/toshiba/tmpv7708-rm-mbrc.dts index ed0bf7f13f54..950010a290f0 100644 --- a/arch/arm64/boot/dts/toshiba/tmpv7708-rm-mbrc.dts +++ b/arch/arm64/boot/dts/toshiba/tmpv7708-rm-mbrc.dts @@ -41,3 +41,7 @@ &uart1 { clocks = <&uart_clk>; clock-names = "apb_pclk"; }; + +&gpio { + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/toshiba/tmpv7708.dtsi b/arch/arm64/boot/dts/toshiba/tmpv7708.dtsi index 242f25f4e12a..e202ae52eca9 100644 --- a/arch/arm64/boot/dts/toshiba/tmpv7708.dtsi +++ b/arch/arm64/boot/dts/toshiba/tmpv7708.dtsi @@ -157,6 +157,33 @@ pmux: pmux@24190000 { reg = <0 0x24190000 0 0x10000>; }; + gpio: gpio@28020000 { + compatible = "toshiba,gpio-visconti"; + reg = <0 0x28020000 0 0x1000>; + #gpio-cells = <0x2>; + gpio-ranges = <&pmux 0 0 32>; + gpio-controller; + interrupt-controller; + #interrupt-cells = <2>; + interrupts = + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + }; + uart0: serial@28200000 { compatible = "arm,pl011", "arm,primecell"; reg = <0 0x28200000 0 0x1000>;