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, };