From patchwork Thu Mar 7 07:01:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13585137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20A5EC48BF6 for ; Thu, 7 Mar 2024 07:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dKZHTu57Q0yRcyWQ6JLGDXg1jT4L7VZz+Xaw8J3OCDw=; b=ehMvV1QuTbGz5o 0CThcv+jjGiDADplVDKB3p+4uUVlZ7tVHAWNUuAmLYhta3axLhcWQHBCYiv6eE1kwPHd69d1OuYR7 d7ZNT87R87zm4dgFY4RYgfZEqnNvDem82qqBri1rGeZGyL9/wxiGtLO2bXlE8pZ3Bnp7hCnksnCp/ 10WjD2RHtbAJI0DR/7fmD3L21sYRTnG3WHEGvycAwmd004zEJWXS9VNzjhV8SsQtGduXNwxXbf8jQ oGYXgegWEhDHriiV2R4b5knBs0WI5v2pcUOvVnew76svVvW6WP07FeFiRgUtZ8YywvkciEzxIE371 FusSp70pctlNRR+ST63w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri7lA-00000003LuU-03oq; Thu, 07 Mar 2024 07:01:44 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri7l6-00000003Lqx-0GWA; Thu, 07 Mar 2024 07:01:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1709794895; x=1710399695; i=wahrenst@gmx.net; bh=WZMlvwhKwo0STQynbUFCeOquxvFPPnzMmc2OHbcnTSE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=bSGtJOtQCwGmRxFWbMCqCHaIEgtZYi72ssTsB0TtzgKm6fpKwDh/YoEZxEE+i6RS urpgrR0oayH2n48dgj0xbpLKOCQUP95amvHkw32pt+kj2uMcdTaArvKtixEDycwsN 7C5LaIzuSn2BTXmFEdcBgrKpDWFKZhu/sV0tye865iRRfx9UiaZ1LihPZRn/373Xj ANUk8JywdsIc7qTuomE2gwY9BFK7L1we+RWLfTvVTr9kXM1kM4UGBDt41v5S5m83g QF/5enQoJdjkyk6tLR039aOpNhx05NUHkgnzWtlGUUjdtikJHgWWdGLdC0hawHxM/ hdnqTWOcmtZWA/WtyA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MsHns-1qpkkX1Fda-00thyx; Thu, 07 Mar 2024 08:01:35 +0100 From: Stefan Wahren To: Linus Walleij , Florian Fainelli , Ray Jui , Scott Branden Cc: bcm-kernel-feedback-list@broadcom.com, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH V4 1/2] pinctrl: bcm2835: Implement bcm2835_pinconf_get Date: Thu, 7 Mar 2024 08:01:12 +0100 Message-Id: <20240307070113.4888-2-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307070113.4888-1-wahrenst@gmx.net> References: <20240307070113.4888-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:S0BhBl0JbCOyPPu2k+xrDPamKFGD//J2ncjVL7zhBiDxFRw2s/f hlSD6Q8wZJ04J/oTovXTGPlNQ6UXQdIDmFcP2hIjoPs/cR7usMhnId0Xqb8Dq/zQd4v2Jq/ KbB084TcACkSeAPyTVMGzUYcX1EwY3K6G/RFnT8zCowe+UJujKMH12lXBJNODhUUNl4aHBK 3tyBoIwPMr1XmurKOaFrQ== UI-OutboundReport: notjunk:1;M01:P0:pgIKXaKr3hw=;Z6QWGg3qUCMEVtWDFZwkCRtEkKa Sn/0CRpYhar8ibZkcTnO1fSr2AoojCHo/RDnGqV8TaZFHn3/W2PbnVKGKE2uN24CzER8DbR1Z wfAFf0keDgFD4qnQyNLlpndeg0v7es9z80illnROIhNKSF3APm4erhFNUMH4geO3s74HjfVGI K3JdUxv4+QTo/PCRcdyLV73Ft3hpkwVAAU5/+m3KzYFdwH0FdIQlx8AWGWBDipvjpppyBpPvA jDJ/w0IhPH5bjcnBIzeTlVoygADOKLAP6sVFE70RipBIgXojoZeXgeDR+LUgvST+O3P6W090b RoYX8625tDpQe1I1yJFVDicEMMUk03tHWes48HMJG9kpef/AYimEOuLENuK/4NtIAE5G5qN5Y GerhlRoETPqLbNp+QeL+P4LB6cw26Ow9wDSdgfaq8IWdoYL0LGSWGk2PhSQgqLyxRFfmQh6sb B6oiCy3oohjIbSX78l4G++DUkShf7U5NtloCdeELnqp5MvI6573pwUINL/LzeFg+w33FoCfSM Lt3cYyjoZVxt2ibd6kjL+o264Ycr0ZMBLOyqABNt8cu5kvcrxTf5AVYKo7Shaqpl/2vfR4HUe mCJnYwYLY0rSIi548b/QJOYouff2o6rIN9GGIKGaID1Alf4bpNZZQ4rnp18vc6rP7lMoKaiN7 zD2pgut4ggv0MKK+Xb9dm5+nqBCLleIOEurULwhJKsC0baOW7lfM7cnaV6+4a6BJSki4eT5zP 2PcbaSDGPklPOYxgOKb2CdeUVxW32Zqnzwj0e8fea5t/IzFDJmHaxpqUPXquigN3QNWGEMDgQ juEBhcPhDWqdhTL9QdUAbgrJ+EIvypFCWgviAvLMfhDF8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240306_230140_435907_8DA92256 X-CRM114-Status: GOOD ( 13.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Even the driver already has implemented pin_dbg_show, it could be helpful to implement pin_conf_get for a more generic behavior. Contrary to the BCM2711, the BCM2835 SOC doesn't allow to read the bias config, so the implementation is limited to the basics. Keep ENOTSUPP here, because it's only used internally. Signed-off-by: Stefan Wahren Reviewed-by: Chen-Yu Tsai --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index 1489191a213f..5d2b188a1ef4 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -1003,8 +1003,27 @@ static const struct pinmux_ops bcm2835_pmx_ops = { static int bcm2835_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin, unsigned long *config) { - /* No way to read back config in HW */ - return -ENOTSUPP; + enum pin_config_param param = pinconf_to_config_param(*config); + struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev); + enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, pin); + u32 val; + + /* No way to read back bias config in HW */ + + switch (param) { + case PIN_CONFIG_OUTPUT: + if (fsel != BCM2835_FSEL_GPIO_OUT) + return -EINVAL; + + val = bcm2835_gpio_get_bit(pc, GPLEV0, pin); + *config = pinconf_to_config_packed(param, val); + break; + + default: + return -ENOTSUPP; + } + + return 0; } static void bcm2835_pull_config_set(struct bcm2835_pinctrl *pc, From patchwork Thu Mar 7 07:01:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13585135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3DB5C48BF6 for ; Thu, 7 Mar 2024 07:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Hr5hxHl/cvsZnmsnRbgRVjBKpFqXAi2SLt0bUfPoDXc=; b=uIpL+aaoe+8U+J QSG4z2+2QTuXjAHYrONR4edDdxy4YlkbK15aymEqNMwUM7tKXxe4HH7rDz8mcztiHgALMpOSaHhmv Ot+b99ULLOLOIqE4cPtKnlYfMPAn/s0GGVlVsEyd11kutHsnXnaP0iPKK7e6IbreDf5fTOpPtgfrb wJ9sON+c06BG8SWXdCWiFWWng1hm80jtNp8j9f7P9XO8Q1+ma5hCuc76R1TIUy5fnwysjTFfy2AcA BHfUa5KAgYH3PUoJv9+ZtaGtIuH+SqrrGJkbZmDek5DFOerAh7jtU4lxlpDoWmSm+H8jBLli5fXc6 c5fBci/PB061O2XcE37w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri7lA-00000003Lue-2QXn; Thu, 07 Mar 2024 07:01:44 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri7l6-00000003LrB-0H0i; Thu, 07 Mar 2024 07:01:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1709794895; x=1710399695; i=wahrenst@gmx.net; bh=ifYiOgp3knTsR6lC0MHYh79PwcVHlan23djwx4rl6OU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=eqUErcwQMb/NC0eL+Qu273xANDwup/kw4KBWDclbx8da76rWxjGTjN/l575VmS5Z /8icEyxV9/Mbqi1pifCl5U0/HbLGfmjFpW4/iQ13SpuYcySDl1OlrERYeABZBC+Un UChKOMILkV4QrvHGn4sKqZQXxgbZUB9oDYUgoms+PDzRMhMhG6oCULxinu9E/XP1L vpGfdjMIqif4xe2XaWNNtCxrQ1THNRBs0DXllwzXRrgin7ivko081IR1Kb+nYYCEv HQ/tzTH3V0MUs0cAnn7jKSoRCnSduHUGMq1S/MRqcLxuZfU29w/6u1fZVIR2TWWS9 O3I3gO6a7kRcvcihHA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1My36T-1quzY02y47-00zSba; Thu, 07 Mar 2024 08:01:35 +0100 From: Stefan Wahren To: Linus Walleij , Florian Fainelli , Ray Jui , Scott Branden Cc: bcm-kernel-feedback-list@broadcom.com, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH V4 2/2] pinctrl: bcm2835: Implement bcm2711_pinconf_get Date: Thu, 7 Mar 2024 08:01:13 +0100 Message-Id: <20240307070113.4888-3-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307070113.4888-1-wahrenst@gmx.net> References: <20240307070113.4888-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:DCccPuS8QyVdPnMEcwog/EF0++clZNFV5FmydDrTVqEaJx5LsSa I4KEmckJZowefSlMYv9rYno83+Bg8210wiTRtSIIp33KgcpT/l1N9UhDH+p0RcvQVbMp3dq luGMo9m6WJa6uAm+7R8v/xKp8sCHGa94b7rFk/BixUPMq2DBagRGAVcUnhzaad0p6Gsmiw7 Bkr4G2Xsk+JkiUMimv34g== UI-OutboundReport: notjunk:1;M01:P0:11mm5wwasfY=;sWUeDeS0YKe2o8YXTrSL4SrjuaB iFhcu7nmkhM1FuTfPfRNqEA5OnkbaQLe3QtQHhGSVC9s+6qP2uRr2raJCgzcKLvLVUMdX1wKl 7FiAP2EkYsCZRr9ln7U0zR6DMnPiGb/h9oSzU4u5AgtrsqzSvkfPjR57rm6WWwKj2rzvhZv6D MWmmRmr6hmfLucMVjpnxoH0hIuTkK0cxQIfNvV2/Oav1c+yJMGExXtsXLkmTLbBdMC+ZhoErO GXE78Y2T72PoULNPJ0s2mee05z2K6rxDONvTmWtn9VW6E3rSY4X9oL42/mrTUiqZNK7/yfXYb gw8xrcxrrCTWcwdRYTLUAO05iLTYYzjKJXei9UAGMTg89rgqdziPic6hnbexYLJkY32EHkLs2 CjKRgXiBGwgganx7WYV/ep5sa+jrX9YB+0WXCvOZi7DXowZ2XhJHBJH1RXhKmVHXxtIdfBdvM YFdnFD5v9951S+Em4aze3zR8djFNVIjXlCogs1CIKwjfjTqzzVvPdCd+SBHHSB1hMB1YLWE9P t1toud1viYuSor/vOe4kdBulICzQ9UuTor1oY4uiyHy+BJtMlpCDEeqpW6zywsO4RsZL6SHKq SI9d59bDwYBrihyzBqFPNHvhyAVPiZyDFbglRgIV/GHiTJaQFeOE8wXatDnQtqAcJBfz5V1DZ hPzs/c9VijnEtsenGYvnBExvapuP9MEEOZoR8SoNhlNahBi29deVhrSlGxEUaHQXm7ekkoUuN k/XSBWj4pv4f7YggKVtzZaCqIOs20pSjqkM+xtr5QC5DutPPo4CRY14nolAL50hS5fvfeY+IH VCM63FxNBSxRawI7wmO9WRHmu7bgCSkFIvTsQQ/X8xgCA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240306_230140_433809_4A35DDB6 X-CRM114-Status: GOOD ( 12.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The BCM2711 allows to read the bias config. So implement pin_conf_get accordingly. The pull resistor values has been taken from the BCM2711/7211 datasheet. This implementation assumes that BCM7211 behaves the same way. Signed-off-by: Stefan Wahren Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 41 ++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) -- 2.34.1 diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index 5d2b188a1ef4..f5a9372d43bd 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -1098,6 +1098,45 @@ static const struct pinconf_ops bcm2835_pinconf_ops = { .pin_config_set = bcm2835_pinconf_set, }; +static int bcm2711_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin, + unsigned long *config) +{ + struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev); + enum pin_config_param param = pinconf_to_config_param(*config); + u32 offset, shift, val; + + offset = PUD_2711_REG_OFFSET(pin); + shift = PUD_2711_REG_SHIFT(pin); + val = bcm2835_gpio_rd(pc, GP_GPIO_PUP_PDN_CNTRL_REG0 + (offset * 4)); + + switch (param) { + case PIN_CONFIG_BIAS_DISABLE: + if (((val >> shift) & PUD_2711_MASK) != BCM2711_PULL_NONE) + return -EINVAL; + + break; + + case PIN_CONFIG_BIAS_PULL_UP: + if (((val >> shift) & PUD_2711_MASK) != BCM2711_PULL_UP) + return -EINVAL; + + *config = pinconf_to_config_packed(param, 50000); + break; + + case PIN_CONFIG_BIAS_PULL_DOWN: + if (((val >> shift) & PUD_2711_MASK) != BCM2711_PULL_DOWN) + return -EINVAL; + + *config = pinconf_to_config_packed(param, 50000); + break; + + default: + return bcm2835_pinconf_get(pctldev, pin, config); + } + + return 0; +} + static void bcm2711_pull_config_set(struct bcm2835_pinctrl *pc, unsigned int pin, unsigned int arg) { @@ -1165,7 +1204,7 @@ static int bcm2711_pinconf_set(struct pinctrl_dev *pctldev, static const struct pinconf_ops bcm2711_pinconf_ops = { .is_generic = true, - .pin_config_get = bcm2835_pinconf_get, + .pin_config_get = bcm2711_pinconf_get, .pin_config_set = bcm2711_pinconf_set, };