From patchwork Fri Nov 27 03:52:05 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: 11935011 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 F2955A6A for ; Fri, 27 Nov 2020 03:53:28 +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 A8AFC208CA for ; Fri, 27 Nov 2020 03:53:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Kd+H44B7"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=qq.com header.i=@qq.com header.b="uq5KGMPX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8AFC208CA 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=Kd+H44B7YUiXJHi3zjzOFhBqc6 PC/Sa2LLz2iAtD+Xl+gpe+HEvfPtgJzaz3ktrzh5kXaHezNF6XGF2f+78Z2N0JkVr+4DIYCXBS/zw Q20Zq/QZ17mJLjRF34L0sROPp9LD/l539EJMTbF2oy6tHfXIgzJPfbrtKgVxC6LzlhIOevK9UqfBt vKbBCPRc+MNueV1kADtiSOp/ZaPNLM43Ujib68dYOPFNk9sDlbpBjteiUiQ5IchtrMxO15SrGJRWu Woh+ejwQRHBb5Y9UyBvPlv7d36C28soeI35oY36zERPEYwFnVZprsA4CwKfo+h4UCsCA8n08PgrZX 9n+x9clw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiUok-0000PV-6o; Fri, 27 Nov 2020 03:53:06 +0000 Received: from out203-205-221-242.mail.qq.com ([203.205.221.242] helo=qq.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiUoW-0000FK-3S; Fri, 27 Nov 2020 03:52:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1606449129; bh=cmUIRKiRCpniorIV6kOGuePdPfrh9Fgr6eJkwXgC6ko=; h=From:To:Cc:Subject:Date; b=uq5KGMPXWQd/k8ci5FP+SwVEWHjWH94c1+uUSezFhERNHyUfTXKY+FX0x+DfDBm81 10F55QPRm2KrVqiI0PhghTEg8U/Se/LkqUPmBeTCx6WX2p18Pn5NKlB6NuJaKOf/0c DqbandAevelYk3r0bI0pzA61kgX7hytDuBGWzlPw= Received: from localhost.localdomain ([115.238.52.186]) by newxmesmtplogicsvrsza8.qq.com (NewEsmtp) with SMTP id D0780CEE; Fri, 27 Nov 2020 11:52:07 +0800 X-QQ-mid: xmsmtpt1606449127td1mb3804 Message-ID: X-QQ-XMAILINFO: OamAntdBv86i9y6BogR++tZeFtQ1sJF2L3ra99pqujESyblIeFzBTLWPuKcMpJ bEPdFueJG58Rtrq26ukqxrQh2nYcBL3fGCGeVf9oiSpa2Fjhc9bf+fRCfj4I084oeqSoRVU5S5QH bAf6hm3YAdSA7WspWeUBTGHuH2vCdakOg9SGjY16mCGQtv3AzjBR0dZaPNNAW09ztArgoMkf5G7g jz/NH7NJpXdPQ2j2j/gbzRy86/aWkrsNVfDIBW/3vH52XJPuVpsuY6Xw26G1t2gCl1eSTYdRszzQ t0HSexHuaIuZnkRn7JKLHHP/d9syPxmC6PW96paBu6n1ADAfwsRUDcDZtHquuY9orxktNaZoeDLa 2ycnPZIM0d6TFG/kufPpUXU5pb2EtYWFpfvYASGm5PDSQ8ZBn19+On7vsATBvTwCbzAHMmCgT/6N dKshIjytJVrtDDdkbAEVuv4EeHw7PY22luhOctHgvNnXKGP80/nMwKseSi4F1tnqmvPzQ2zV+rQ2 PCfvvqY5rjTUkzERWiUqF+NhMZSU9uFHsEbg2rkC1oInPDoEnHSFx0UCrLqfFkoP2lFxE/EoROAy aq+xr1TCmHvkHPi7ogeHN/WxMwaLaYvwEzG8dntg94+5xKGb/TLSTkvTyotk/WgcqrmQQPXlpxHJ PpipaLxKNZKpEODvuvW9eyAX6gPeTtvpKKHFS/j6cxgvxffZwWv0iFnNABx/6ZxRh21+glFdoOjd LCiG+41FX/WJd7OZn6Q55BO2f3cONiC4E3bsVCcIY9v14= From: 410860423@qq.com To: linus.walleij@linaro.org, khilman@baylibre.com, narmstrong@baylibre.co, jbrunet@baylibre.com, martin.blumenstingl@googlemail.com Subject: [PATCH] add amlogic gpio to irq Date: Fri, 27 Nov 2020 11:52:05 +0800 X-OQ-MSGID: <1606449125-26630-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_225252_926549_89F1E86C 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.242 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [203.205.221.242 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) \