From patchwork Fri Oct 25 11:49:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 838863 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 890051E47DB; Fri, 25 Oct 2024 11:49:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856970; cv=none; b=bTuRm6Hrda58y/XewuNRg0pdKqvCxvfpgXvqc7Tov9NrpgHiKxJCNNoBZvKbriPy7XG92+TTyMxL0+P4L26k/UukPkf5RwzntVty7i3qSNsfXdTHX1vf5unGUJaY0RaBsLYv397zXQ+rcsHzgKwuXoiV+im3dawK/+OU2QzNMa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856970; c=relaxed/simple; bh=nHyQRDtRRtPvE4YCxirrCGGKgYQCnSWllFmKKTrWnuE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CL77uF+XVHMxfVkm+nxU21BMdZBlWfTRCNq/4kJ+LAjLqQfFb9Q2Ow0m/epEL2siUyPCCj0wV51dKA2Np1yGgwcvNS0Ip22mwmdsvkQLRLTg1y8gDuDCqa+WIwphpHON94lEQe/63vPztGImv90LvvXrX6k3nvrmgAeEnN1gfFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=H0aTSEgh; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H0aTSEgh" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-43168d9c6c9so19951055e9.3; Fri, 25 Oct 2024 04:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729856967; x=1730461767; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1vztMECmolaOLkAvwQUeZqW1KpwJlvFjGfFWGaanGDs=; b=H0aTSEghboggTe8/Xe09EBOHveykEAZZYNXQuR0zrNnabWpEUReqFcK3vVNILalyl8 iJFzT6cYqsAC1QNameLhmdLOFiFH5xWwtzp4DVoe6qLBwyz5kW3GqP3m/HRox+n8ojx9 NlSkMWOgPd9OiQreGHEd5i52p87eiF01omd67K9gSO//UMgWQX+DImEQjztfW2aGeYMi aA5nNKQ+7ZAYPLrqiHhAKMhk9ZVFU0vsM4v2bq5xkR1LxRAExvyhXiRzApEAPHkeXa3F j62Nzof738W9ydS2sYJ7yUNGUiGnm2axi8t6EkGOM/PBGoyLuZwtG5AcDX2/Z9EkzHhv DBNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729856967; x=1730461767; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1vztMECmolaOLkAvwQUeZqW1KpwJlvFjGfFWGaanGDs=; b=NfnUwqPJszcJNwo1p4Y1+boxVN7h2ZPltJwSJNgN7zNxiAxaXHHLlasVq4kmN9Jb01 T6B4hP8XNejxDbYY7CPmShlorl+yqAL36x8NIYkjPB66cfieOHQhDOV0Jk4e0cEXF367 XMf6jAiQrm0wNfC4YYRc+16ecCPDVr1UwFyHXaYaBdd3vRpt3HiG3V75OoeXE2rqYJZQ iD2rGcF9qfMV9sB/nnSCDcIkMbQXUhQDbRTTi1XyqPC/GTOmyMSeLPsY77jtwwloSzXg Wf7wMJHVdrvAjesCCRdzFUwAumhh2mr4/gqhUL1R+QvKshuPJXKVhj6BM/JRTi+bBWjt vvIA== X-Forwarded-Encrypted: i=1; AJvYcCUZQFvqR7AwrJmxiAQebuPY2UNjqNve5swn8Zx7o4jFylL5YjFrmQR0HuVb+4A6tl/8+lI2l89g9/oUgqII@vger.kernel.org, AJvYcCXbqTyHMIC47ra+STnqE8jChimYVmSDJ8i+u59r/oc1xf5DxFGqipQMj++FJ9/l+EuxdNVxFBbLT/VNiw==@vger.kernel.org, AJvYcCXtL9iuRzbTO0QVT1VHwV9Vdvy0oExkcvAIVbDqrJZMW1OLx8xMcNaKHur1j4ZPeVbHiw5PcodhHqy3@vger.kernel.org X-Gm-Message-State: AOJu0Yyuy85RKKJMMkA+nr0qzWna/1ETfvvTjwW4bK+FaUUqtMZpsQ73 EPNk3YzIm8gt5IGEcdT/Z5mwJkhtVqN6FwH9nIeI/1pi02zzx7QP X-Google-Smtp-Source: AGHT+IGJJ+V0/6N0J6CA2A1LlSs8FNlvBxtBsVl/pwbEuelQcHS9H+vSmCG7EcyYauDoG8g/L2VwzQ== X-Received: by 2002:a05:600c:502b:b0:431:4880:3120 with SMTP id 5b1f17b1804b1-4318c6f16ccmr40005825e9.11.1729856966564; Fri, 25 Oct 2024 04:49:26 -0700 (PDT) Received: from prasmi.Home ([2a06:5906:61b:2d00:1044:9cc9:b89d:54cd]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b56741fsm45109785e9.22.2024.10.25.04.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 04:49:26 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Magnus Damm , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij Cc: linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 1/6] arm64: dts: renesas: rzg3s-smarc: Drop hogging of GPIO pins Date: Fri, 25 Oct 2024 12:49:09 +0100 Message-ID: <20241025114914.714597-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Hogging of gpio pins used as interrupts is not required, as the rzg2l pinctrl driver sets the direction as input when the pin is requested as GPIO interrupt. Signed-off-by: Lad Prabhakar --- v1->v2 - No change --- .../boot/dts/renesas/rzg3s-smarc-som.dtsi | 18 ---------------- arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi | 21 ------------------- 2 files changed, 39 deletions(-) diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi index 71424e69939e..6e95933cd7ef 100644 --- a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi +++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi @@ -196,15 +196,6 @@ &sdhi2 { #endif &pinctrl { -#if SW_CONFIG3 == SW_ON - eth0-phy-irq-hog { - gpio-hog; - gpios = ; - input; - line-name = "eth0-phy-irq"; - }; -#endif - eth0_pins: eth0 { txc { pinmux = ; /* ET0_TXC */ @@ -239,15 +230,6 @@ mux { }; }; -#if SW_CONFIG3 == SW_ON - eth1-phy-irq-hog { - gpio-hog; - gpios = ; - input; - line-name = "eth1-phy-irq"; - }; -#endif - eth1_pins: eth1 { txc { pinmux = ; /* ET1_TXC */ diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi b/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi index 4509151344c4..baeca5ff5d61 100644 --- a/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi +++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi @@ -71,27 +71,6 @@ &i2c0 { }; &pinctrl { - key-1-gpio-hog { - gpio-hog; - gpios = ; - input; - line-name = "key-1-gpio-irq"; - }; - - key-2-gpio-hog { - gpio-hog; - gpios = ; - input; - line-name = "key-2-gpio-irq"; - }; - - key-3-gpio-hog { - gpio-hog; - gpios = ; - input; - line-name = "key-3-gpio-irq"; - }; - scif0_pins: scif0 { pinmux = , /* RXD */ ; /* TXD */ From patchwork Fri Oct 25 11:49:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 838862 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0391A1B6D1E; Fri, 25 Oct 2024 11:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856972; cv=none; b=CzybyxPCHyfRf6IbkbA1TafGhj6kTiH4HY8tUTBcrJwnp77AYboyuYApKSkyqdY1cP5CpsqxxXf8UZBxZWwW20cdHcia1vEpUZVnpUws9g5ZVec//fCajF1xjol0C4XlVbk3on1/H64Y+AMoNJTKwWfu1TDhxKShf/DAT4E30/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856972; c=relaxed/simple; bh=IFSN6+NQRn4+PSD8DPcmwIxzRIX23QVqKcE5ou+fGs4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LUXR1C4d7eMqzM+vvLBv6gUN4ECjxxDQ/yAxZ9TIWWvHPPCmTY9rsvQjuPaGMwrR9vzLUXoATYLsw7/na4qgWUXGl9H6f0Mh/k0QyouJfNcRcayTP3XDTok5Zg++wxpU9APUQqb/WvWboMbtWd2dybKoOmFmL1KEUkIy5VnXH4c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=i74DvA2B; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i74DvA2B" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2fb5be4381dso21455701fa.2; Fri, 25 Oct 2024 04:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729856968; x=1730461768; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VoaXpDJ6rPqnyL6hF8gNhqswIJFFWm8mj5yKDECTdeg=; b=i74DvA2BwM6BX1ahGQhniEZlQlgGHrgLlvWx1QFvIQjesrfb5sckwCLAjYxr3A/14e QGH2LmwMTn3AbnqOIhUjS4or06/6YXmPBAhMcqMf+AXNPWTq4g0lhRXMG02Z7I86DpgZ B4A1k6ivxzfIOGa1AufXTqjcyMCxEI+y7+CjTDXH9DVdAbMsS5hsPdWwPRdH1UIEedpT tZpS9CT3g2ZbONklc14ooCoy4Hz7WPOY7BgIE9yfVaN8LbDDFGGxIuOu02OW2L5Y2iUM OglXcLhvOlhyOGgIPQwGb4KtkuqvW8NyKgEvLhrYzOQzi78uAXU2PAgbILhnfpEbGUAc 3zdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729856968; x=1730461768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VoaXpDJ6rPqnyL6hF8gNhqswIJFFWm8mj5yKDECTdeg=; b=jvROhYRjwYxw7UHNWwCO/MMb4QhULgX+TNZWBFS/T9zfBhd8X7znDPEM60lONRWPiv WURbvVICAtdPONu6MywzR8zxd/den4uegAV20+k85A+Yq0qYP/OBQOvSMvwUiOtAIC7w HPswWEPi/vqd5eYuRl0YJmLzmRqLKFabce/ad/wRJLCajRzWbu8/OYYvF5apzQLbs1i7 9/390CDv89K/6Epq0lnyOqTg0H4ynj4Sv1qoZT0NlWh3wmarrFhnmQR9eG0iB8PmHoZr jK5vp+meTaVhIdUke5O14TiZim1gMtDACPs6UCY0zHpXDsIhh3OtjcGW/Yw1/P/Icsce HgZA== X-Forwarded-Encrypted: i=1; AJvYcCWinq7vQt+By87MAzOXBIB22mzt9ADHSIvWjPG3MPTYHeB9NoWY6NrfutJcaaLR7Mrgdn81YDqJXvBv@vger.kernel.org, AJvYcCWzSUyC8sfnF6WG3XqdeMo4L7rjXpexC7fc+qx8RI1VGNcyJrC4xDpUCYZ6QQiukJvC1/t4jhgwJrmYxhfS@vger.kernel.org, AJvYcCX0h1o1VTtyy6/6za7WDfs1TzWwvJ52G0PRQpAXNNXaTyKAV2+R0bQBsdmqoAtAtv0I6Yys06ZM8wSXLg==@vger.kernel.org X-Gm-Message-State: AOJu0YylenuYHCZfl3YfRcU9Ama20Lz/4YDlD6BdZEU6LzRNCFlt4pip E12UeVjNhgipum7QY0S8JMwOOMRwGB6A5ecEZEFBCZ4bQmr4n07z X-Google-Smtp-Source: AGHT+IGESHwlJsvcSXD1bLP1IU57Xc9KbIJiPx3bBZPlSWTwuUrwyBvfZrtGqcRbDk/MbXVPN5SB5g== X-Received: by 2002:a2e:4a11:0:b0:2fa:cc50:41b with SMTP id 38308e7fff4ca-2fca81c3d61mr27258271fa.5.1729856967601; Fri, 25 Oct 2024 04:49:27 -0700 (PDT) Received: from prasmi.Home ([2a06:5906:61b:2d00:1044:9cc9:b89d:54cd]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b56741fsm45109785e9.22.2024.10.25.04.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 04:49:27 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Magnus Damm , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij Cc: linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 2/6] pinctrl: renesas: rzg2l: Release all the virq's in free callback Date: Fri, 25 Oct 2024 12:49:10 +0100 Message-ID: <20241025114914.714597-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar The `free` callback in `struct irq_domain_ops` expects to free nr_irqs interrupts starting from virq. Signed-off-by: Lad Prabhakar --- v1->v2 - No change --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 39 ++++++++++++++----------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index 8ffb9430a134..1a09ccbfebad 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -2477,25 +2477,30 @@ static void rzg2l_gpio_irq_restore(struct rzg2l_pinctrl *pctrl) static void rzg2l_gpio_irq_domain_free(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs) { + struct rzg2l_pinctrl *pctrl; + irq_hw_number_t hwirq; + struct gpio_chip *gc; + unsigned long flags; struct irq_data *d; + unsigned int i, j; - d = irq_domain_get_irq_data(domain, virq); - if (d) { - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct rzg2l_pinctrl *pctrl = container_of(gc, struct rzg2l_pinctrl, gpio_chip); - irq_hw_number_t hwirq = irqd_to_hwirq(d); - unsigned long flags; - unsigned int i; - - for (i = 0; i < RZG2L_TINT_MAX_INTERRUPT; i++) { - if (pctrl->hwirq[i] == hwirq) { - rzg2l_gpio_irq_endisable(pctrl, hwirq, false); - rzg2l_gpio_free(gc, hwirq); - spin_lock_irqsave(&pctrl->bitmap_lock, flags); - bitmap_release_region(pctrl->tint_slot, i, get_order(1)); - spin_unlock_irqrestore(&pctrl->bitmap_lock, flags); - pctrl->hwirq[i] = 0; - break; + for (j = 0; j < nr_irqs; j++) { + d = irq_domain_get_irq_data(domain, virq + j); + if (d) { + gc = irq_data_get_irq_chip_data(d); + pctrl = container_of(gc, struct rzg2l_pinctrl, gpio_chip); + hwirq = irqd_to_hwirq(d); + + for (i = 0; i < RZG2L_TINT_MAX_INTERRUPT; i++) { + if (pctrl->hwirq[i] == hwirq) { + rzg2l_gpio_irq_endisable(pctrl, hwirq, false); + rzg2l_gpio_free(gc, hwirq); + spin_lock_irqsave(&pctrl->bitmap_lock, flags); + bitmap_release_region(pctrl->tint_slot, i, get_order(1)); + spin_unlock_irqrestore(&pctrl->bitmap_lock, flags); + pctrl->hwirq[i] = 0; + break; + } } } } From patchwork Fri Oct 25 11:49:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 838518 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE4501D8E1A; Fri, 25 Oct 2024 11:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856972; cv=none; b=sM6TtsMW4v3Hqpa/1X0aoiB6Gu8pw1B5PgabEImsM4jGMmK6ZjgpJMONWTuQykMTvBZbPK2ca31YbKsV7JYJ+0pOAsDpDeaCVEuEAmuaHGfkCURZvzGOZajS2z5hgrHBZhM1TOUCl8PjxuDqVVjSjyjpF8MK1IByn2v718AfNFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856972; c=relaxed/simple; bh=+6OiIHZUXuK/rxdkmicJ+jQ7BZRkUgg5/YkiZrEKIBk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fbkhSNJ4K0Wbbs1aF5qS3UPz03rSLlX4BDIuG84D2npbi8MgMaKviTD3UoFgGXD/wfxYV8PbFGBVQZXNX+36s2gxavt8xJUFxvy13RgQdBljQVGVAB+nrYyMEUN7PPBOvVARgySqwYx89Wl5c2mL9bFbisf374dBBFgfcdYwIa4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gPYAPnWv; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gPYAPnWv" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4314c4cb752so19474655e9.2; Fri, 25 Oct 2024 04:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729856969; x=1730461769; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J0/wAHRYUulJtThCskv96/D77J9Pl3F9tDm+0Mz3HHA=; b=gPYAPnWvcGTNbK0F0q+VUG6XyWTCc2vD2YFrjf8PJyw4f8jrkfbXfuvNPqYn4S+NE7 lxCnHtYXCf3+YB3qqwqu9yUGtTR51UMMXXseqAyA8Kv0geOkucciCmNbAc2oFMtQopqC i+DN0ip1ca2ESNpLoAoIDY1pUNHN9r1469zhw3b5Ic66HdWNCZzi/cVSrIVG+g+emALa aJ96xJVgHNvFTiCmMkfYhLLTQ3ssT39KU9KONh8CwfLt4rsc8QOHvG5VxKSZpnRqOZJB XGpX4k/px3XM2TueLx3LvxX+IOyRRJ2c+zDXCp42lMmZmH1SqeCO7RLEoJkYoHWb4two /HEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729856969; x=1730461769; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J0/wAHRYUulJtThCskv96/D77J9Pl3F9tDm+0Mz3HHA=; b=pau+1w4eLpwB8tpwecJq7DWo2TxLMJpph5Y/4++9eArrSjCKwxRHgJtz7W5AlMddHJ Sz0vCtl9/ymq8g1TT2F/ioqa9XPNR4AHpy9CKQ4anE3ekOn+PkzxyNcmEBTaL+Jb/EcI Rw6ZTXvHjLJc/xen/dH7XQqsodPD9lXGHbhNaluBYsxBykMVll2igNNW35m6CnsG5jie /sIc6No0ppRtDi1qW2JD4gmdzKW34Zs2fVYprHo8JtCDb6+BK21Yor0RODe4kVl1FOKv wNhE7Wlhoh91KmPno/AzFVjzLq87cj4fRXBzZSuo3FRG81WfG2Ym3sGMNqWjWTS2x7aG wGHQ== X-Forwarded-Encrypted: i=1; AJvYcCUpdwZzw2fmE8AWji25ljVsHt8/NjeQYf6JIQVxtxiqrgQ+8pcB4WGHPWlGFzqQZ2zM66CB+nd6SaLvfA==@vger.kernel.org, AJvYcCV3HkkHpo2Gmouds8zkkWOxk5gpbUDQKlpCIgmj7SuccBEFmHr7VRutEZO0ElBzIckLUkKLc6peza4e@vger.kernel.org, AJvYcCX8IO8NPidna08+T0KrpHy+Bp8de6QRxtvEAPOvBHakvTtqwhNCfP8tkSYPU1aCkNOlrJejF55yxkHT45k4@vger.kernel.org X-Gm-Message-State: AOJu0YygYQP8S3eYtmdJauLaMVSQJoIPmwgJzmVuSGiX70wKzQx4fNox 0h4ohS6nzRrUZFiJMDKJ04OfXU1AnWFex6Yb0wYhkopAP2A7qx0M X-Google-Smtp-Source: AGHT+IFxNYNJYs0fHmZKVjoueOHBXiaK6/iUx1aK7IFXiShNcvj0onhgBcD5Sis1/NN7I7tf81nXWA== X-Received: by 2002:a05:600c:190b:b0:431:5632:448b with SMTP id 5b1f17b1804b1-4318419a81bmr78264015e9.25.1729856968615; Fri, 25 Oct 2024 04:49:28 -0700 (PDT) Received: from prasmi.Home ([2a06:5906:61b:2d00:1044:9cc9:b89d:54cd]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b56741fsm45109785e9.22.2024.10.25.04.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 04:49:28 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Magnus Damm , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij Cc: linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 3/6] pinctrl: renesas: rzg2l: Reorder function call in rzg2l_gpio_free() Date: Fri, 25 Oct 2024 12:49:11 +0100 Message-ID: <20241025114914.714597-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar The order of function calls in the gpio free operation should be the reverse of that in the gpio request operation. Thus move pinctrl_gpio_free() call at the very end in rzg2l_gpio_free() Signed-off-by: Lad Prabhakar --- v1->v2 - No change --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index 1a09ccbfebad..d8b942fbf537 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -1774,8 +1774,6 @@ static void rzg2l_gpio_free(struct gpio_chip *chip, unsigned int offset) { unsigned int virq; - pinctrl_gpio_free(chip, offset); - virq = irq_find_mapping(chip->irq.domain, offset); if (virq) irq_dispose_mapping(virq); @@ -1785,6 +1783,8 @@ static void rzg2l_gpio_free(struct gpio_chip *chip, unsigned int offset) * drive the GPIO pin as an output. */ rzg2l_gpio_direction_input(chip, offset); + + pinctrl_gpio_free(chip, offset); } static const char * const rzg2l_gpio_names[] = { From patchwork Fri Oct 25 11:49:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 838861 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA498202656; Fri, 25 Oct 2024 11:49:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856974; cv=none; b=bwr2YsFKlUql7yPGNIqfNNtoaNL7uVXnszH/NenVjpOKylVPjDCda6av0i0Lo4ohSH4EDQ9wKYnVylmtf6tBSnQRoZQNjGAc3yFsI3guVKw3Tfl8igV3nMcxZewxC7jVix4LgZVmzftCZ1JhER0LPqcNE7D3biGFdDxZbWhMr1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856974; c=relaxed/simple; bh=aspKmrgS7DI6+o3FPUtlY+vECrso8UKZIs+nvvoHLyI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NH0hSCrjb1guFXqiTbHmCSrmlHP8sbGXDJU40tdDfVoz1sVf3Kkjq85xYXXoP18FSZ6zBUpgfn0/wZXGzYn+gJgOD2I6EJXH2E4QTyJod0h2ZNCmqxg0aJJ7KEBvQ10xddycc8fNNGWtjv53iwI+H0+wBpzx4j5OE48HX90jSUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FjBRUCno; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FjBRUCno" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2fb599aac99so19641331fa.1; Fri, 25 Oct 2024 04:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729856970; x=1730461770; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NQCNfwaBzrVCghcxLAoBZ2ERMZxjDuEt6bNvg8b+FBg=; b=FjBRUCnoKWD1PRSFsscyoJXn1+ycq3m9lcIiXt+SluyDeRwCW2/ytGgTicJBkHZBVo ORb3XcAozzrx2abEN3sZc7zdmPttOKfZEIuVzZ3hN9/K0U0oYsr2xjzB7IhYi9Eq45Ht uDDO/8lRAMo0V+RMJlI9Jzt36J4EGgg6jg68PDAwPA8MW74Cm2qKKUTga3IraCa4kgRR nlFTUcWVDk34UEnoUb5+NyDhK/Zz8zdCdW2kzFKzEq4RO8TUVI8U/T+LE3CuTg7ur/WD IxkJSP6DrJle6zHr3OizsJm3UARd+ff9Kks1jxVEdHeJa3ljyryvZNRUgTLm9mODDCYX aLJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729856970; x=1730461770; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NQCNfwaBzrVCghcxLAoBZ2ERMZxjDuEt6bNvg8b+FBg=; b=D7WpmvHUD4RA/b5BUEk0r7z4qV/2Bg8dLYMArAXvrLiJ3XgWvWZH4y8kThGWKqsRC4 TrMNomH1aSrxdYwNvvp5Ru2zLqNO96O4QPmLj9/mm6J5wTWgveWEqKlZgocGmjhKSdvY jrJDKY2UfYDV+J91fAbAe42ivP/aklqwxjaUN7QS/6+y2y80uGLgsFuvl2ZT/60sRhwd HPbuEJuBIBYZVcCGiLvHvBaoGxAWlaj9CtOo/zvMQo79MJDcW65/ESwQSPzHk6lNg1k8 OpWutPLshMN8vMHmRBfc0Y3FD/zgq/YmErNYLBtjnJcklL8jXkFtb0Uu+d9WonyVwM1w 8Uqg== X-Forwarded-Encrypted: i=1; AJvYcCVn5SEBUARzHrtHvJVEjzQbrwr4kOPWAM6VyA6e1oQ0mSuf7wRo2N9cVbUQM+WvHwRDg7IWxXszifTltlAA@vger.kernel.org, AJvYcCW0X50gGugbkZuGnCmW7nUkiNgnNFnFeDZNjKSUlGvtIFBZuibzGzPbej2P1AmaPWeWiGgmdJtn/cI2@vger.kernel.org, AJvYcCX1MFqF0nZ48/N9Wh4O9g2lTHGQRB/cdz35GxN1EevelqiZV02uyRmtcTH2pPcRHpuvjB15b2aTyBtSbA==@vger.kernel.org X-Gm-Message-State: AOJu0YxOyJpqpSLX+m9LLRkFYf4S1+0cbIoj4oYDD8sTc26Wd8rQDUYx PsP+aUVb+fmojEXX5FbXN9IIqB7d1wXDMb/EHUv+iUjNJT4ZB2uH X-Google-Smtp-Source: AGHT+IHSlgkWSxFVF7akBafw+6JwTnPk7YZvSdZYN+3jqEsaPy48+WOM8E8zQhqNVbpyg7q0awInng== X-Received: by 2002:a05:651c:1256:b0:2fb:5da7:47a7 with SMTP id 38308e7fff4ca-2fc9d375d15mr42867061fa.25.1729856969531; Fri, 25 Oct 2024 04:49:29 -0700 (PDT) Received: from prasmi.Home ([2a06:5906:61b:2d00:1044:9cc9:b89d:54cd]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b56741fsm45109785e9.22.2024.10.25.04.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 04:49:29 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Magnus Damm , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij Cc: linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 4/6] pinctrl: renesas: rzg2l: Drop calling rzg2l_gpio_request() Date: Fri, 25 Oct 2024 12:49:12 +0100 Message-ID: <20241025114914.714597-5-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Drop calling rzg2l_gpio_request() in rzg2l_gpio_interrupt_input_mode() this was added to handle special case of bootloader setting the same gpio pin as function. When GPIO pin is requested as interrupt through `gpios` DT property the gpio_request() is called through the code path and when releasing GPIO pin it goes through the gpio_free() path, so drop calling gpio_request() in rzg2l_gpio_child_to_parent_hwirq() path and also drop rzg2l_gpio_free() in rzg2l_gpio_irq_domain_free(). This fixes case where rzg2l_gpio_free() was being called twice after the GPIO interrupt pin is freed (after unbinding the module). When GPIO pin is requested as interrupt through `interrupt` DT property this doesn't go through gpio_request()/gpio_free() code path. Signed-off-by: Lad Prabhakar --- v1->v2 - No change --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 33 +++---------------------- 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index d8b942fbf537..b9a8bf43a92a 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -2372,26 +2372,6 @@ static const struct irq_chip rzg2l_gpio_irqchip = { GPIOCHIP_IRQ_RESOURCE_HELPERS, }; -static int rzg2l_gpio_interrupt_input_mode(struct gpio_chip *chip, unsigned int offset) -{ - struct rzg2l_pinctrl *pctrl = gpiochip_get_data(chip); - const struct pinctrl_pin_desc *pin_desc = &pctrl->desc.pins[offset]; - u64 *pin_data = pin_desc->drv_data; - u32 off = RZG2L_PIN_CFG_TO_PORT_OFFSET(*pin_data); - u8 bit = RZG2L_PIN_ID_TO_PIN(offset); - u8 reg8; - int ret; - - reg8 = readb(pctrl->base + PMC(off)); - if (reg8 & BIT(bit)) { - ret = rzg2l_gpio_request(chip, offset); - if (ret) - return ret; - } - - return rzg2l_gpio_direction_input(chip, offset); -} - static int rzg2l_gpio_child_to_parent_hwirq(struct gpio_chip *gc, unsigned int child, unsigned int child_type, @@ -2407,17 +2387,15 @@ static int rzg2l_gpio_child_to_parent_hwirq(struct gpio_chip *gc, if (gpioint < 0) return gpioint; - ret = rzg2l_gpio_interrupt_input_mode(gc, child); + ret = rzg2l_gpio_direction_input(gc, child); if (ret) return ret; spin_lock_irqsave(&pctrl->bitmap_lock, flags); irq = bitmap_find_free_region(pctrl->tint_slot, RZG2L_TINT_MAX_INTERRUPT, get_order(1)); spin_unlock_irqrestore(&pctrl->bitmap_lock, flags); - if (irq < 0) { - ret = -ENOSPC; - goto err; - } + if (irq < 0) + return -ENOSPC; rzg2l_gpio_irq_endisable(pctrl, child, true); pctrl->hwirq[irq] = child; @@ -2427,10 +2405,6 @@ static int rzg2l_gpio_child_to_parent_hwirq(struct gpio_chip *gc, *parent_type = IRQ_TYPE_LEVEL_HIGH; *parent = RZG2L_PACK_HWIRQ(gpioint, irq); return 0; - -err: - rzg2l_gpio_free(gc, child); - return ret; } static void rzg2l_gpio_irq_restore(struct rzg2l_pinctrl *pctrl) @@ -2494,7 +2468,6 @@ static void rzg2l_gpio_irq_domain_free(struct irq_domain *domain, unsigned int v for (i = 0; i < RZG2L_TINT_MAX_INTERRUPT; i++) { if (pctrl->hwirq[i] == hwirq) { rzg2l_gpio_irq_endisable(pctrl, hwirq, false); - rzg2l_gpio_free(gc, hwirq); spin_lock_irqsave(&pctrl->bitmap_lock, flags); bitmap_release_region(pctrl->tint_slot, i, get_order(1)); spin_unlock_irqrestore(&pctrl->bitmap_lock, flags); From patchwork Fri Oct 25 11:49:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 838517 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F4622038A5; Fri, 25 Oct 2024 11:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856975; cv=none; b=r8Pnohkb90ZP5VrIVkhG3DLYQu3ED/kGzf74hXD72cM31RCh1bw+qk90REwSCAQ/oBUo2G3rdf24l/CR7igqA/I/VF+JuPrsc7IcvKpJOixmD4aY2cnrh8IoqQddsOTwvtyzPtv8Gv9qBeGJXdbhwdU/6ODDWM0UW+cSYoeMiSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856975; c=relaxed/simple; bh=3g7b5GOmv692vGg7/3yVQcA9gvqk1+NqU0y8jh1A/KI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FFM6ZMcAw0egV/OEGZnrq+KLWDEbiH1aG3hnvR0emXHJ1ddiBW6nKq30af5ufOrwBGr35GgVqJkN+ttN6V2/0zKTtAVp01Zl50ZTEgr59IZBL+eHIqpmslwq3RSXQE6ROub37Frn56RZN9lKRPWq1qmFQkWsnmRZAx65yUnzfpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VMgoRo6i; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VMgoRo6i" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2fb4fa17044so21195671fa.3; Fri, 25 Oct 2024 04:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729856971; x=1730461771; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pw6x7l5AuN4o5c97yCezR04TZd3IFBzsNnyyt25aGPo=; b=VMgoRo6iQ7GPeAtOU/CNP3RYNIkrkvUtj/X0euGejCo9pFvSFdNgLvtJEFmqHlKkV/ Sel02UjGyUJnNkey/Tw7cBsXaifnFRAqN40kC00JRjP9fWOQoiT5NL4VLd8I79+CekYE Md2W2RodccR2ABaNMRQXiuV6awrgcEBkj/FEjcgaVRB8BH3tpwxwF3eDYV1yJnmty2mL BNMdqv96k8JR4N4sfUYTrfw/jNBSYGqwHyVUvBjGz7CUs14yoSR15XcOPVno7O0mX/V0 7Fh0aHtwZdmkkDelkf4hc+L/+BWrogLBKdftxKS8COEVFnCkR/GiOXpMo37SrZtP05fp ihig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729856971; x=1730461771; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pw6x7l5AuN4o5c97yCezR04TZd3IFBzsNnyyt25aGPo=; b=USwh6TtPZgPEkE1QV5L4QbMYuVy9mxwxDc4gFaAOjnf33gWZXrNyzFd16T3qptaWIE TLlv68kF7P1vBSUUTA1YSGQcpGNKonX51zrZq49x8WA4+3h0KVOS5Em4iKNzAv0yVmRT bOBmEFqEYrJWoMmH5ojcZKiSbenv88OfDCbksJzoY+ARDjBvo6dVaf2YG80U8ONNp4x0 sp7DhPXZYwkKx1Dr1GmZ6GK5hNuybt79o/0iqYm4zOCKpavi7TLYbB8d2wAXHaUCTLyP ZoqFgTQ74pE1QKlfzuW4BvTM6hchizW3EJ2lCM+uQjfDgs9ACuTkYC4bo5Xth36VeYVw Yeew== X-Forwarded-Encrypted: i=1; AJvYcCUfsDNOUPv9jDpkS3MbRfxMqIbcjcvC0kms38UomPenWCcskJ3nvqSsH23XHhOIpAYgYAG9otZbl5aM8T5i@vger.kernel.org, AJvYcCW++o/+zcu/iZhYZ7Eqvp44Qql8tAzfv7EDGfZObv8BZkHJWvjNdQcOg89Fh0AN/GMw0RVZ+lfHvpZx@vger.kernel.org, AJvYcCXVj0ec3CUP2+6wyfwDyxEhwHZDxDW2OxRnJJMJkpebt6wbPtF8B0+4LurHROytmgo5Jrhqew4lJqLkpA==@vger.kernel.org X-Gm-Message-State: AOJu0YwKyG7ORdy6jM7sbCT2aE4jjJ36hkOUL87zRZkh/EttezohizCi ATSkP92r54CM2ZiGAaBhefGU/sGnZGs1TPvoH93WKnwfwIbpejaF X-Google-Smtp-Source: AGHT+IFnU5j1cE09Hk/oUtLcXUwzGhA3hZaRMS9pqo2liLR4Nwl1OGWojpryufo0e+rIKC/CLSJZTQ== X-Received: by 2002:a05:651c:210e:b0:2fb:565a:d918 with SMTP id 38308e7fff4ca-2fc9d2f5eabmr50101371fa.12.1729856971121; Fri, 25 Oct 2024 04:49:31 -0700 (PDT) Received: from prasmi.Home ([2a06:5906:61b:2d00:1044:9cc9:b89d:54cd]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b56741fsm45109785e9.22.2024.10.25.04.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 04:49:30 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Magnus Damm , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij Cc: linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 5/6] pinctrl: pinmux: Introduce API to check if a pin is requested Date: Fri, 25 Oct 2024 12:49:13 +0100 Message-ID: <20241025114914.714597-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Introduce `pin_requested` API to check if a pin is currently requested. This API allows pinctrl drivers to verify whether a pin is requested or not by checking if the pin is owned by either `gpio_owner` or `mux_owner`. GPIO pins used as interrupts through the `interrupts` DT property do not follow the usual `gpio_request`/`pin_request` path, unlike GPIO pins used as interrupts via the `gpios` property. As a result, such pins were reported as `UNCLAIMED` in the `pinmux-pins` sysfs file, even though they were in use as interrupts. With the newly introduced API, pinctrl drivers can check if a pin is already requested by the pinctrl core and ensure that pin is requested during when using as irq. This helps to ensure that the `pinmux-pins` sysfs file reflects the correct status of the pin. Signed-off-by: Lad Prabhakar Reviewed-by: Linus Walleij --- v1->v2 - Fixed build warning - Collected RB tag --- drivers/pinctrl/pinmux.c | 14 ++++++++++++++ drivers/pinctrl/pinmux.h | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 02033ea1c643..6c3d18b162ad 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -99,6 +99,20 @@ bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned int pin) return !(ops->strict && !!desc->gpio_owner); } +bool pin_requested(struct pinctrl_dev *pctldev, int pin) +{ + struct pin_desc *desc; + + desc = pin_desc_get(pctldev, pin); + if (!desc) + return false; + + if (!desc->gpio_owner && !desc->mux_owner) + return false; + + return true; +} + /** * pin_request() - request a single pin to be muxed in, typically for GPIO * @pctldev: the associated pin controller device diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h index 2965ec20b77f..df44dc4c8b84 100644 --- a/drivers/pinctrl/pinmux.h +++ b/drivers/pinctrl/pinmux.h @@ -42,6 +42,7 @@ int pinmux_map_to_setting(const struct pinctrl_map *map, void pinmux_free_setting(const struct pinctrl_setting *setting); int pinmux_enable_setting(const struct pinctrl_setting *setting); void pinmux_disable_setting(const struct pinctrl_setting *setting); +bool pin_requested(struct pinctrl_dev *pctldev, int pin); #else @@ -100,6 +101,11 @@ static inline void pinmux_disable_setting(const struct pinctrl_setting *setting) { } +static inline bool __maybe_unused pin_requested(struct pinctrl_dev *pctldev, int pin) +{ + return false; +} + #endif #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS) From patchwork Fri Oct 25 11:49:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 838860 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38C65204095; Fri, 25 Oct 2024 11:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856976; cv=none; b=LYQ9Y6wI0sfKR39jMN+P7o6HnWn//0V+pin3FHQVuxcil6UoGSB5xBIr2GxdBc8DZjwyi2vm+p0IGJpFvyDtMcvMZHC3dwoCM8ObWVQjDoWLLkjBODxwrxaLZ3zc8tumk1NvayHjgz+Uh4EBktwnklnICfvO1yS26JmqxweGGWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729856976; c=relaxed/simple; bh=2zpW30oJJ0gzFLA0Df0Xi9Xx6SwsPHwfQ29ZKgha3VA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rxx87dwy8//p2HTy+Nei+LRrgI8TKsCazP5yZI9O1rIBV0lkI2w+3bn+4MAMLHZvkYfaiP6zNw3RpHVgFfOl5ySv+SiJfl/MMTMcDXnvGdGvyzIol6rLAmLMvrVJTBKwkwbrzcbn5tBP6BqmaBLfo/GK/ueDuw70Hu2GVuuwLHg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZUTYcpVL; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZUTYcpVL" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-43163667f0eso19344135e9.0; Fri, 25 Oct 2024 04:49:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729856972; x=1730461772; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CElfZLNsSgILS/BsLAAu+iVhhIWO8y3BRkrHAx+d6KM=; b=ZUTYcpVLE1+XQQy/h2kZn5lBpAo47yKPwLuokZhTvrIOACcpTic8hOnx+VBnXHzo1c 0BRp03NcAaFhMJ3YHCzgFQqEI1BwoLEWzb1qyXr3uxtWowHyDyiYpa7eA3ibpWFtQndb RsmA47GGEAU+vUF5/Xx9RgCMWi0SBuqBb0lyXka70eQdbhwXvxvGwKPn2bFZkcYphbtZ jZCior2GgP1NSuJQZRNsWGnitTbu8/fY5iEp72sqKgIw8P64IZS5tpcCFNuBUFEO4Fe0 3n1sUnHsfGcnXYFAMDiVRvwOfNWD/A5A9fkHs/h1mjyJn7AycZHOwkq1yCdqiirwiVGI LDww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729856972; x=1730461772; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CElfZLNsSgILS/BsLAAu+iVhhIWO8y3BRkrHAx+d6KM=; b=Ej9NeWD+euylyz0/MmRzQpOWVhw5XpBxkEs7QmRQekc73ZQe/3MSMObO5eD1ucV6GL MqCROo0KYQUg+V1FVnwJRdcmRA2GFF1o79bBKbHeIKPZ1BoP15Sv7l2bwRGdn6DqAq7I T44XY3rc/oonluJUpDpV8xyze89PNUrP+W+xYM9Pf+hjH224KlkoEWIHteJe9cYszPUk plpyzpTz7NnLESB57cADVpM9GQRw3qoRU+otkuPJ28MUsZWdQrk7cN8e9Y2uEayZ+AYU v9NcAPKVP6VCxhRNtxJjlEcPPvVlHfWdHQZEIXtFhzv1o+FJ/l5VYtPLu2ZO/a6/h/Xl bW/g== X-Forwarded-Encrypted: i=1; AJvYcCUOgm5+zQNi2dAaAM+PzSk3OEokVzksbiwMb2arl8Qha9XlIRKh/u8gomFjlNc1I5hfmaCV06l6gs3blkkx@vger.kernel.org, AJvYcCXDL3lnYM8XHhbT21SCHDBehyBuZKzHMf33XjtOYMsI91I0oGzvY099twNYJ9qCSZe7UQwGoFdnsAC0TA==@vger.kernel.org, AJvYcCXxiLYDms/rP1XIAp8lUg3RPXzWwF2wyTirHSygkje0lcDGuujJWSty2lotKGA5k0N9gV/fD7fqXWTC@vger.kernel.org X-Gm-Message-State: AOJu0YxY022OgUc1cQ5w9+kKNDUTIMRq9EeYxEjqFmK3awgK79zHz2oi nZBG3C9qpE8rXbpHlrYPFNL8mpdCvT7HB230YEsKMyGSwKPNofvXu4xlEQ== X-Google-Smtp-Source: AGHT+IHvR8cjRlQraeVOLsO2IR4h8i4KWB13AVDra+R2EV+LjSCTCS/+FbWsmbtTC7LwJHE31x5Llg== X-Received: by 2002:a05:600c:1e29:b0:431:51c0:c90f with SMTP id 5b1f17b1804b1-4318420a152mr82683295e9.21.1729856972511; Fri, 25 Oct 2024 04:49:32 -0700 (PDT) Received: from prasmi.Home ([2a06:5906:61b:2d00:1044:9cc9:b89d:54cd]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b56741fsm45109785e9.22.2024.10.25.04.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 04:49:31 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Magnus Damm , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij Cc: linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 6/6] pinctrl: renesas: pinctrl-rzg2l: Override irq_request/release_resources Date: Fri, 25 Oct 2024 12:49:14 +0100 Message-ID: <20241025114914.714597-7-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241025114914.714597-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Override the default `irq_request_resources` and `irq_release_resources` functions with `rzg2l_gpio_irq_request_resources` and `rzg2l_gpio_irq_release_resources` in the RZ/G2L pinctrl driver. The `rzg2l_gpio_irq_request_resources()` function now ensures that the pin is requested by the pinctrl core before locking the GPIO as an IRQ. This ensures that the `pinmux-pins` file in sysfs correctly reports the pin as claimed. Additionally, the `rzg2l_gpio_direction_input()` call is moved into the `rzg2l_gpio_irq_request_resources()` callback, as it makes sense to configure the GPIO pin as an input after it has been requested. The `rzg2l_gpio_irq_release_resources()` function unlocks the GPIO as an IRQ and then frees the GPIO, ensuring proper cleanup when the IRQ is no longer needed. This guarantees that the `pinmux-pins` file in sysfs correctly reports the pin as unclaimed. Also add a `pin_requested()` check in `rzg2l_gpio_free()` to return early if the pin is already released. Signed-off-by: Lad Prabhakar --- v1->v2 - No change --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 41 +++++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index b9a8bf43a92a..47b3e296d094 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -1772,8 +1772,12 @@ static int rzg2l_gpio_get(struct gpio_chip *chip, unsigned int offset) static void rzg2l_gpio_free(struct gpio_chip *chip, unsigned int offset) { + struct rzg2l_pinctrl *pctrl = gpiochip_get_data(chip); unsigned int virq; + if (!pin_requested(pctrl->pctl, offset)) + return; + virq = irq_find_mapping(chip->irq.domain, offset); if (virq) irq_dispose_mapping(virq); @@ -2357,6 +2361,35 @@ static int rzg2l_gpio_irq_set_wake(struct irq_data *data, unsigned int on) return 0; } +static int rzg2l_gpio_irq_request_resources(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct rzg2l_pinctrl *pctrl = container_of(gc, struct rzg2l_pinctrl, gpio_chip); + unsigned int child = irqd_to_hwirq(d); + int ret; + + if (!pin_requested(pctrl->pctl, child)) { + ret = rzg2l_gpio_request(gc, child); + if (ret) + return ret; + } + + ret = rzg2l_gpio_direction_input(gc, child); + if (ret) + return ret; + + return gpiochip_irq_reqres(d); +} + +static void rzg2l_gpio_irq_release_resources(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + unsigned int child = irqd_to_hwirq(d); + + gpiochip_irq_relres(d); + rzg2l_gpio_free(gc, child); +} + static const struct irq_chip rzg2l_gpio_irqchip = { .name = "rzg2l-gpio", .irq_disable = rzg2l_gpio_irq_disable, @@ -2368,8 +2401,9 @@ static const struct irq_chip rzg2l_gpio_irqchip = { .irq_print_chip = rzg2l_gpio_irq_print_chip, .irq_set_affinity = irq_chip_set_affinity_parent, .irq_set_wake = rzg2l_gpio_irq_set_wake, + .irq_request_resources = rzg2l_gpio_irq_request_resources, + .irq_release_resources = rzg2l_gpio_irq_release_resources, .flags = IRQCHIP_IMMUTABLE, - GPIOCHIP_IRQ_RESOURCE_HELPERS, }; static int rzg2l_gpio_child_to_parent_hwirq(struct gpio_chip *gc, @@ -2381,16 +2415,11 @@ static int rzg2l_gpio_child_to_parent_hwirq(struct gpio_chip *gc, struct rzg2l_pinctrl *pctrl = gpiochip_get_data(gc); unsigned long flags; int gpioint, irq; - int ret; gpioint = rzg2l_gpio_get_gpioint(child, pctrl); if (gpioint < 0) return gpioint; - ret = rzg2l_gpio_direction_input(gc, child); - if (ret) - return ret; - spin_lock_irqsave(&pctrl->bitmap_lock, flags); irq = bitmap_find_free_region(pctrl->tint_slot, RZG2L_TINT_MAX_INTERRUPT, get_order(1)); spin_unlock_irqrestore(&pctrl->bitmap_lock, flags);