From patchwork Fri Nov 27 03:53:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 410860423@qq.com X-Patchwork-Id: 11935013 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BF69A6A for ; Fri, 27 Nov 2020 03:54:57 +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 2A1B0208CA for ; Fri, 27 Nov 2020 03:54:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rlBh68Jk"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=qq.com header.i=@qq.com header.b="s/Za6tb9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A1B0208CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=qq.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.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:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Date:Subject:To:From:Message-ID:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=+kkx+HcI00cJwMq7jjWhj8VL0lrJ6skCB8AXdOC1V7Y=; b=rlBh68JkonKwn6aOqzTkCn22uP is6IshZrVXPWTgko1g5MPsifgpozlDuPACnsNZ+VofWhem7bLaxAQGlBeYR2UP5AeM6Qv/2Dkl8Xh L2cbGroBMQ2e9K2zZ1ZLww0rVlfudWtUJLSvng/lJT6mS6FNry4rIflUDvNlUwQ6z7ko6Tie6L7Tb im/LUszEVmhCIRopPTZt2H0vRnmlZbSZ5ZJwm9K+luChk5+Gj4dRBUiNZ4HjS3xjm1yrwgalAvx7d R+FzbNCxFV4N9V1o0qY7E7F1MXAwbSZc5ddpS0dBdkBVPro0N4UzsJrwQTZbRrX06JOnyPkzTTZeO f5nOODpA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiUqF-0000lR-Se; Fri, 27 Nov 2020 03:54:40 +0000 Received: from out203-205-221-209.mail.qq.com ([203.205.221.209] helo=qq.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiUpy-0000gB-FR; Fri, 27 Nov 2020 03:54:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1606449244; bh=cmUIRKiRCpniorIV6kOGuePdPfrh9Fgr6eJkwXgC6ko=; h=From:To:Cc:Subject:Date; b=s/Za6tb9US0j53ukITydjn2yfSLovX+KJ8IJV+H+IUGD/ePfKUDif0CJ2wga88n/w JGTzVC5WBHTnc3uppBieuwXxFK9xRSFBrz/Afd7T1RoyjV6GqXmyjA8lKEZXiVfS1v cbxM21gYVhALgL8X2oKqNi2CSduVzokDBZokZXJc= Received: from localhost.localdomain ([115.238.52.186]) by newxmesmtplogicsvrsza5.qq.com (NewEsmtp) with SMTP id D81356EC; Fri, 27 Nov 2020 11:54:01 +0800 X-QQ-mid: xmsmtpt1606449241tcjkkzfx6 Message-ID: X-QQ-XMAILINFO: NvLWmUiDNnOAYYp+HAKicFIjUUdEdXNnTbfVmml1THFfXzxVVcxY76QkIZQlJF BMYoQeYDIss1uxtqeOue5raPt3rvdg6nKDcPQiTJJq1mSDWEDpdJduPogNTl2GEpKyP6T3Hya0sE 2Xl88yefzbqaazYKwg9tLtCATOmagyRfZGjO6O6WMhWuAqI1RQ449Qry0jRhw+NKwLbNNH9rZBzy 8KZZ+JpP8RLbbAYrYel1/t4V38I+YLrH8huq3riV1GqzGYIOaRjfb22pulKHJiML/OH7hh0cplCU QnX3Gz4dIMsXjbQ42WXPUuwYJJoV9La65SYDwbC4iTW1Axs+fGRARJsl2isGoJF8TZLjtsLQHB5v LAWeJqu62FbNWAjYDFHGZfa8sm4+qWsrxMOzAe2n0GvdRcGjo3Un3lpHXF3wnj5sflOtCRNZzdRD /Rkgmk0vYB6F1PQAiedDm/O4OZ7/70P4J6/eVb4eBc3tJkmNC8sUMG/z/BUq1kT1ru0FgaZGEuQH XPlKkMhf3ZMVD3/49sLKUmoL1KRNZvBA+nzNV/s6KgAGmeNUu22Ces6ik80BMheMZ4AMZ+IlFOk7 fg1dAJU2I0CixPufZGVrE4aguPIiJUc5/gKdREEoBMkzR/ZYrj10QrLRFCxv2LJoLT+lrx5LmfEw Vh5cRoQVvmOaDGiCNX10UIbgww5sMq6vnDWMaE8r0Df0q0V/a3fhldhefHaS06U6TuuN4KwKeu/Q 7i0taA/ejWP6zi0/kagS40wNGBZkNtXx5L5cuY6ytzn811emQMBYHMFZ3YZJdTKrWZ7vbJG18nLf bVM9GTVF7wJg== From: 410860423@qq.com To: linus.walleij@linaro.org, khilman@baylibre.com, narmstrong@baylibre.co, jbrunet@baylibre.com, martin.blumenstingl@googlemail.com, linshenghuan@hangtu-china.com Subject: [PATCH] add amlogic gpio to irq Date: Fri, 27 Nov 2020 11:53:59 +0800 X-OQ-MSGID: <1606449239-27057-1-git-send-email-410860423@qq.com> X-Mailer: git-send-email 2.7.4 Signed-off-by: Lin shenghuan X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201126_225423_260029_D5C2B5A1 X-CRM114-Status: GOOD ( 14.23 ) X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [203.205.221.209 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [203.205.221.209 listed in wl.mailspike.net] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [410860423[at]qq.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [410860423[at]qq.com] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, Lin shenghuan <410860423@qq.com>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org From: Lin shenghuan <410860423@qq.com> --- drivers/pinctrl/meson/pinctrl-meson.c | 36 +++++++++++++++++++++++++++++++++++ drivers/pinctrl/meson/pinctrl-meson.h | 1 + 2 files changed, 37 insertions(+) diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 20683cd..b91ff2c 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "../core.h" #include "../pinctrl-utils.h" @@ -598,6 +599,34 @@ static int meson_gpio_get(struct gpio_chip *chip, unsigned gpio) return !!(val & BIT(bit)); } +static int meson_gpio_to_irq(struct gpio_chip *chip, unsigned int gpio) +{ + struct meson_pinctrl *pc = gpiochip_get_data(chip); + struct meson_bank *bank; + struct irq_fwspec fwspec; + int hwirq; + + if (meson_get_bank(pc, gpio, &bank)) + return -EINVAL; + + if (bank->irq_first < 0) { + dev_warn(pc->dev, "no support irq for pin[%d]\n", gpio); + return -EINVAL; + } + if (!pc->of_irq) { + dev_err(pc->dev, "invalid device node of gpio INTC\n"); + return -EINVAL; + } + + hwirq = gpio - bank->first + bank->irq_first; + fwspec.fwnode = of_node_to_fwnode(pc->of_irq); + fwspec.param_count = 2; + fwspec.param[0] = hwirq; + fwspec.param[1] = IRQ_TYPE_NONE; + + return irq_create_fwspec_mapping(&fwspec); +} + static int meson_gpiolib_register(struct meson_pinctrl *pc) { int ret; @@ -612,6 +641,7 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc) pc->chip.direction_output = meson_gpio_direction_output; pc->chip.get = meson_gpio_get; pc->chip.set = meson_gpio_set; + pc->chip.to_irq = meson_gpio_to_irq; pc->chip.base = -1; pc->chip.ngpio = pc->data->num_pins; pc->chip.can_sleep = false; @@ -682,6 +712,12 @@ static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc, pc->of_node = gpio_np; + pc->of_irq = of_find_compatible_node(NULL, + NULL, "amlogic,meson-gpio-intc"); + if (!pc->of_irq) + pc->of_irq = of_find_compatible_node(NULL, + NULL, "amlogic,meson-gpio-intc-ext"); + pc->reg_mux = meson_map_resource(pc, gpio_np, "mux"); if (IS_ERR_OR_NULL(pc->reg_mux)) { dev_err(pc->dev, "mux registers not found\n"); diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h index f8b0ff9..0f808bb 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.h +++ b/drivers/pinctrl/meson/pinctrl-meson.h @@ -131,6 +131,7 @@ struct meson_pinctrl { struct regmap *reg_ds; struct gpio_chip chip; struct device_node *of_node; + struct device_node *of_irq; }; #define FUNCTION(fn) \