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: 769980 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0CD523758 for ; Sun, 4 Feb 2024 16:59:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707065985; cv=none; b=FDMzgY1D33Jc1FosThYFkOEeg9NZs/9Ok18bIFL+6PoeMtNxxqxEwfRgL8yrGbs77cRk+toW8PdrQjbiDIniwb3WXtWzAAnH7jL9qqd7oRXPNw7gBRZO/57EElYevOkeldQRxMlL8mkXfPgfXsSVzK/W3wRF8tQg3mNIcF63Zqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707065985; c=relaxed/simple; bh=vxjfUH6oE+5NHrasm9nsqIMIn8HoUbUx645/gxxS4D8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gj2GykHMQOPIBvZOIDi8EgbOLhb4U/RpbmvYog+Tw/xgprtb/a3jdSFsaAhffBUD0P6vSS4N+L6XtID59hVPwTNUpYxAjoODt+JzMytyYkpatSPsaPJUrM5WFYt8Jr9ng6KE9BCPdypv9NAxpKwgDV/I55sQ9IjRcILxHs8ruy4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net; spf=pass smtp.mailfrom=gmx.net; dkim=pass (2048-bit key) header.d=gmx.net header.i=wahrenst@gmx.net header.b=F0vNrEV3; arc=none smtp.client-ip=212.227.17.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.net header.i=wahrenst@gmx.net header.b="F0vNrEV3" 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:xzTypoUdgbS5hEMlJo09VZ5gTXUWydVhAsmF0okdeDTHZCrxMpn XA+5PPcqZkAPE5Dczh/b9H4BHcPgOMEzwljBKPlff2vxvOZIP3wRBTV7WMGkoLZ/yLZItMR 2SBbb1gFbxsc4k3Yx2vcNm7a+iO+YdKkJaXrUuZGRHwBXB6LoY4n37Nicm7Oo7WaFyBHITh NWa+8PSdSW3Cjt1u2gXkA== X-Spam-Flag: NO 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= 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: 770182 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0661823754 for ; Sun, 4 Feb 2024 16:59:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707065986; cv=none; b=GzSd/fIwmaBtdQ7WQxjstGUf4CGCvYDKoF8GqlFIdc6t4aMZtVsC7ynmcjuIiY20K8oyuNh9uiUpcm9XOw1XrlXPg6AyyxZ3dZXrf396lq1/8DO69bW4LwY6SRzsuufnvaxVm6LZue0DwF4nkYptE9TCpoQ6nPJK3IO9joh8jyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707065986; c=relaxed/simple; bh=DBZ/WE6D+Fi7O27zqwzbAxoENTNSsxezdjn0kX3t45Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hnBG/yLQTkq0IttQp4TIO9pdZq/LGD/COJC4reQIcsHghf91tmb8u8cu2hhM43tYlSTmYMjSfG38Gk0xzADdiqJr8TxQ2Ehf9k0dXi+clBDZYWshG5wzlL/P8wlLE6mq5Zwwi4q0ToCwiC9UlgqU9Gdx/kOg8tbCZPHDqX8NFz0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net; spf=pass smtp.mailfrom=gmx.net; dkim=pass (2048-bit key) header.d=gmx.net header.i=wahrenst@gmx.net header.b=kyVUHIhf; arc=none smtp.client-ip=212.227.17.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.net header.i=wahrenst@gmx.net header.b="kyVUHIhf" 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:vKoEQijiPr4U+aUr7LBczpsMZqtWF2eHsknplrEcfGWYxC7lQta HeSY8IKwU0ilC78q3ULHKYxD+CamHyvxbAvQ3Z85NPyut9ONN4ret5l5O1cU6tlWOpXIEOf JPSFt2AZCMmMPRE8yHNz0JfMG3fXGUAg2kkjtlEAY/Ehy3SsZ2m45Tmh/OGGN45+iNOH3Gs /ZsADbxEicMYr7/xr9y1A== X-Spam-Flag: NO 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= 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, };