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