From patchwork Sun Feb 4 16:58:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13544744 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 B55AAC48286 for ; Sun, 4 Feb 2024 16:59:53 +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=/pHUNH+51rrat/1mcNyqNiwc4GycOdh7WjTA/qzBWTg=; b=Rr6Ww8z2SuyidY KjvGAcrKSrezTbHoXwTc9v1uzfb3yJF2zFDwqFr6b8KDjuz/iKAvMyTvVZMFEhbNW28t5BYqs9bSN 0znI+608DjIav2Y04IuWyr64PBUdVg9/CHHnj8ObE8mfreqDiD6+diMjdKRPomkDFe90orCA8Jv76 9A61qeCuN3ZjCwc3Ik3gIW9atHvX89+epdj1mSmgxi5kYgHyFvPD9Lj868UPZ5jqiBZlSZxfByXYH 4f+kVZIWHfDGZLDYt9WBHXsUuTc+bix7bN7aJ+KCL8nXrD1Ov9nDARd6fJRbLKSR1HVq34Wi6GYFc JgRdkXk2z780aZB2cthg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWfqI-00000001BTm-1AUv; Sun, 04 Feb 2024 16:59:42 +0000 Received: from mout.gmx.net ([212.227.17.22]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWfqF-00000001BSZ-0Kpo; Sun, 04 Feb 2024 16:59:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1707065974; x=1707670774; i=wahrenst@gmx.net; bh=vxjfUH6oE+5NHrasm9nsqIMIn8HoUbUx645/gxxS4D8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=F0vNrEV3621PdX8nyXwp1IkK7SmUZ1Ljhi5Y7Phtw5+hGRN3GBEdk6Csi/U8Rbu3 BNHzgl277eesTz7KfPMYkxTdFoiEjcxGLiYWjAaRydm2kgjNFLbw8pvuJUfpbs88g k/v/0fLoRYz0vc6f25smPmdg3Bve+IZDREVfNaba0B1RB11et08iHMqd5hitm91YB L4Vv7gNH+NnQaE/jAWYuaJ9IW//5dUvp2+lMFVH5aJeYdQrwY00cpuz9k5POAcIWR Wjddwc5x2MsWrG/OIP6w3re+aefYOzoU2U76PBlNizcn4YC0/w1RiAIXugDDo8REh lhbG7aA3e1hqUUK48Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mv2xU-1rErwM1Mcy-00qyRJ; Sun, 04 Feb 2024 17:59:34 +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 RFC 1/2] pinctrl: bcm2835: Implement bcm2835_pinconf_get Date: Sun, 4 Feb 2024 17:58:51 +0100 Message-Id: <20240204165852.166157-2-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204165852.166157-1-wahrenst@gmx.net> References: <20240204165852.166157-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:xzTypoUdgbS5hEMlJo09VZ5gTXUWydVhAsmF0okdeDTHZCrxMpn XA+5PPcqZkAPE5Dczh/b9H4BHcPgOMEzwljBKPlff2vxvOZIP3wRBTV7WMGkoLZ/yLZItMR 2SBbb1gFbxsc4k3Yx2vcNm7a+iO+YdKkJaXrUuZGRHwBXB6LoY4n37Nicm7Oo7WaFyBHITh NWa+8PSdSW3Cjt1u2gXkA== UI-OutboundReport: notjunk:1;M01:P0:00r6adlArjk=;aP6V6y9/vrmu7dA8xq6+YgdAjU7 p/VuGwX4LnuoDrIlo8UNwiBx21W/T8kHlrZsgrbywv6xUv+LGPPPKWP6j/Wi2Ou18W1ch1OwK CKtmgdrQiYkhhxGmuQp+Eeg3Uzei5M6stJ+oM7BmVtH4f0UILkdxzhxagjx++BBi5o0rdMsrE I/DZYQUAq2hxa25EwvYsXqHX5fof1xgPLxCVJHnbQpyEAevz0xFt/XAM4HOOJNbe/bsLdLtUk UDoqijl3UW4t1Hd1r7i6b3FZ1Lcfdbz8qasL83BF1hs478mtHd+FZ2FOpWJOav0IvrB7qAPV7 UrxmRaBSDUflcpo24ekDA1gAaDbVQhAQzRogksDWgiDyX2IBT1J2XZJZwu5z7XKLTh2xoFdA4 Ieg8mE8QW4hhQAXX7th69zKcOBQAjDjCLf0p4y7M0h1NSl6n5begZ1HBrSYD94mvvH32jp0p1 WK3tgUUY0RwvJ22d/2nUMB+hkBWsVAS/LDh59opek3Ir/dPKRrI9PLDhW/VqDcyCB+6p3EMMV HPzvZxulvxJrid8QXvYwXzgjYdSH8ns12r9GlvQR33FCmdhkWHBG/mQapJBMTLRFcZ0cobAth 2GJqomOFh8NGDPOMJ5iJaZU5q+0mfC0qMX8QoY1t+dp43laFfE2+6/usuVLXJwmg2fjJyngTt koekaNPRg/tST7jDLu5sCXxAtgI9db8xW1nVXTvgIw11YXh5kbOIICJfoO0svY0gF4wPEOTrT Z78cB6uoc219kW6ttw6+mWL6AFwoUPJMAMqU+EnGJpGf8QMyPG4Ap6EPRB17ZZgG1Otd7pIM0 akBcIol0UlzHGmnzo6hzR6IpwbWYY4Ko1MU981hazcLjI= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240204_085939_441405_BB19570C X-CRM114-Status: GOOD ( 13.37 ) 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. Signed-off-by: Stefan Wahren --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 35 ++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) -- 2.34.1 diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index 1489191a213f..b37c86ec6915 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -1003,7 +1003,40 @@ 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 */ + 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_INPUT_ENABLE: + if (fsel != BCM2835_FSEL_GPIO_IN) + return -EINVAL; + + *config = pinconf_to_config_packed(param, 1); + return 0; + + case PIN_CONFIG_OUTPUT_ENABLE: + if (fsel != BCM2835_FSEL_GPIO_OUT) + return -EINVAL; + + *config = pinconf_to_config_packed(param, 1); + return 0; + + 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); + return 0; + + default: + break; + } + return -ENOTSUPP; } From patchwork Sun Feb 4 16:58:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13544745 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 EEE8DC4828F for ; Sun, 4 Feb 2024 16:59:53 +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=S3Px9UmRkSeUF3kfRduTBdwUvzvLWY/6Urh/EhQcERo=; b=BH8yA0VFoJtQ3I PfYTj/JARcydf2fM3pBb4Revht2Uk4BHDr+Bn77ztXxyq5kdDP9YvoTJFqj7c0yUmxqu0PSLx/CYW ZhaCPyMgnGMJe4ICK3/TgTzzbN2+h4wiZFPlhEUxF4VfI9ECyt2edE595EzPdKQnIhy9Fc1Lmyz/K f/2qrigbeyTmaCzhgSC+e9vA0dmbR0gR+B59E4KMN5N54AWIp348q8S4ndc7FRAx8klWZgQ61KmbW 07Krc+yZjH5evVl93MzDUuuvnOMqyNDhtpwLSa0M4yNB+N68rDuJrTt7AwvilnKKhbID27El9196F orSna8+iOZU/+6qSIOPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWfqL-00000001BUu-0WRw; Sun, 04 Feb 2024 16:59:45 +0000 Received: from mout.gmx.net ([212.227.17.22]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWfqF-00000001BSY-0Kvq; Sun, 04 Feb 2024 16:59:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1707065974; x=1707670774; i=wahrenst@gmx.net; bh=DBZ/WE6D+Fi7O27zqwzbAxoENTNSsxezdjn0kX3t45Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=kyVUHIhfv/ZhTiPosZmhEjAFVRwOSSwMX9hHKmVlp4S7Lp0Pv9sGTgfu6DROfUVB 9aFfCHH04ECO0Pf7VtVg8GLni5G/mguo/Zk7Vf7gYU81E6h4R4DA0q6zGZ757ZAkF m2yxNdu9SEWAM1XDUOAdC46Adz6RqjHQ2IFm+2kBin+KhD35FaCYmJ8K7pwLMNZ6y aB3dxAefwuQlAMNBxNUDX0IzSVpq1bV1lK72YdQUPbUWILLfrOK0TKeDNMGSecUWR 7OQawQR3+BWfef+xFrU1MVNDZk2HE1hMdlhSIh6AeYs1QrH9V1v+3U7wLACHnSgpA bLra1Ke47e1VRzpduw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MkYXm-1qkjd231mY-00m43v; Sun, 04 Feb 2024 17:59:34 +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 RFC 2/2] pinctrl: bcm2835: Implement bcm2711_pinconf_get Date: Sun, 4 Feb 2024 17:58:52 +0100 Message-Id: <20240204165852.166157-3-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204165852.166157-1-wahrenst@gmx.net> References: <20240204165852.166157-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:vKoEQijiPr4U+aUr7LBczpsMZqtWF2eHsknplrEcfGWYxC7lQta HeSY8IKwU0ilC78q3ULHKYxD+CamHyvxbAvQ3Z85NPyut9ONN4ret5l5O1cU6tlWOpXIEOf JPSFt2AZCMmMPRE8yHNz0JfMG3fXGUAg2kkjtlEAY/Ehy3SsZ2m45Tmh/OGGN45+iNOH3Gs /ZsADbxEicMYr7/xr9y1A== UI-OutboundReport: notjunk:1;M01:P0:Lo0IAOSgyLY=;HnShHnaQic980/RWQLnD4OsvMKz fKZq1AZdvyQYw288NsQVQH9zehASlP0tvzX91yIoOV9agL3jvZ5CytbeSrYKJL36iz17NjXUq WOi7b/xyFzoq1HCA6obM1AApfz0uubEU1RwrZ+xJKZPCBf8jAL6D7UOCLiUpL9SVH6tEamKgU bxCf5Y/hyYlKBfzoqR0Dh+W5Sr4hSzSALFBvQFtzFG8jaTB8jr4bCPcftxFczfWMBI7tPmxBU vX+H7CHy+zoe05mV4CKeOZFdyvPvi9TDn5JPmMEdXBtwhas8oCVyxIJ2kg7ll7NvuqF8FijpY U0GakAmjiO1e5GtS4o63PXNe1IS8ybf9PE2FLqstLZkk1H7+H5oKPC+pYbF1SkWqabYvsnFjE LnmMdl7i1PLIqhl685+029Cc1z9KIayXWE3fuLIy1t5NZ4shQBxvBMxtd4JZwFO3QOVjpq5wW UrWN0MJ5ffV54OibueAEfy4zUhE3IZCgNa0dd/eP3Z5uCnccfiWF3gOAwxn+MSUlREZCtqSoD Jm9F0aHfHP5SoCNNeOCwWu7bAtE91S4cHflt94m5JRYL90AU/c3fYfiz2JEIb9gec6cu0EEVU 7aC4AbJoKxt2M2FFFI+8dVNqEqLb1fuXw/C0D5zVCZd14lbFq8mkloBen09F2qFW6YAxisUEc Q5ZFOmJQ80VeMcNSv3w/zHp1qYf5FdIKbtnCVSoW2po3u4rIUY69eqmuDZ6Y8+F/snf7+IzsD 41VCqPRsU9SBJIAPUa/6zFMsKJnXK0jRFDhAAWOO5p5JmpbbYR5edoIjZTwuxXpsohVGrNaFp lNyI+PzoD+uN1swZSJ/5r2p7mXevzZzeuUb365uMG9mWY= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240204_085939_443635_08788B71 X-CRM114-Status: GOOD ( 12.69 ) 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 CM4 datasheet. This implementation assumes that BCM7211 behaves the same way. Signed-off-by: Stefan Wahren --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 43 ++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) -- 2.34.1 diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index b37c86ec6915..fcb9ab6729c0 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -1112,6 +1112,47 @@ 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 0; + else + return -EINVAL; + + case PIN_CONFIG_BIAS_PULL_UP: + if (((val >> shift) & PUD_2711_MASK) == BCM2711_PULL_UP) { + *config = pinconf_to_config_packed(param, 47000); + return 0; + } else { + return -EINVAL; + } + + case PIN_CONFIG_BIAS_PULL_DOWN: + if (((val >> shift) & PUD_2711_MASK) == BCM2711_PULL_DOWN) { + *config = pinconf_to_config_packed(param, 47000); + return 0; + } else { + return -EINVAL; + } + + default: + break; + } + + return bcm2835_pinconf_get(pctldev, pin, config); +} + static void bcm2711_pull_config_set(struct bcm2835_pinctrl *pc, unsigned int pin, unsigned int arg) { @@ -1179,7 +1220,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, };