From patchwork Sun Mar 3 14:01:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13579777 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 0B3D0C48BF6 for ; Sun, 3 Mar 2024 14:02:37 +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=rHJugbcljdlBX5TTBY/bZUctjDCFl1f7QUYsjz26/Zo=; b=P6X9N1vZ3ohJ9p DhOZRIDSw9TlUq9Levf4mhA9t9S+wcJW9OGu7CQ0WD8H+eq2ouKILSicBojURwt+t8ZgFLYBlCBYN 7GjNDYQkEnwebfWlc3FLlmzVlr5kdH++Sq29eGBVjMYW945/734UPp2Baocp86XXyNLidS9yv/fau sqC1/dbhJ3t2oI52uMzCmxhxnqTOvsotsK+M1c/b19fqct7dEn/iaK0OFXl9AAwX4Gy4nAOzkUD9v m8gxJdjX98YWTk1y/ecZvlVROPbeAXqZ1BEyw96O08Av7huYnBjSlre23BjuGf8KOqYLISDU4feBI nxaG+CM6w1NzO4fPVimA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgmQ4-000000061t1-0SRI; Sun, 03 Mar 2024 14:02:24 +0000 Received: from mout.gmx.net ([212.227.17.20]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgmPw-000000061ky-1uME; Sun, 03 Mar 2024 14:02:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1709474524; x=1710079324; i=wahrenst@gmx.net; bh=lECRiuSJWaP4QyRGREeVhkDPQQYnJwFCWuROb1bA+tc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=AJeokGLZI2lz0dpuM3pF25DydrqIzrZZ/+5ojyMSEZqZfzdxiAjcyo+aFZCsVElY eMTSQFcLRBOn3R/BPVmOaZRdF9/ccSlzMFr48HNQlBJ3S+CXjAcN4/E66Vo5q890X a6nPeGMkUsO7t+TTggBFyKSF3AghxHsQheZu5r0AjMlV58OcdgCFWgucZeTm89bL5 ac4C2pBaYnoyOzH3MYaVwZhpqU+oa9I48GBoIrLejfZuyP+pxl/c8e3Vptc0RiIJl I7GMwqgWDmM2AMH37MruAbm4SLm7w2WTQ3wcjLvQ8XXRlTMZP9bPzMD/QpLeQlL+a sTk92/IptgpXLZZVVA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N79yG-1qmg7c37GO-017XgT; Sun, 03 Mar 2024 15:02:04 +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 V3 2/2] pinctrl: bcm2835: Implement bcm2711_pinconf_get Date: Sun, 3 Mar 2024 15:01:37 +0100 Message-Id: <20240303140137.157522-3-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240303140137.157522-1-wahrenst@gmx.net> References: <20240303140137.157522-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:bXCSHkyGiT5pFZpix0e5CvssCVAhBmhUQL5AHfxukT/TaeGfXW6 hdjDEt6yvjLIFJpoXoitiR3qS3/OlQSs5ODWbMJpMGUHnCekmqtL/JTgiXkkHUGs/VuoXSB QTzIPirzIUuhkaavTB2SNkLQsOlC3eTzu5BrG4caWz/aFkS+86eLBq4H1YFxxBl83WBpU5g yPcsbQi/5n0HbYulC+EgQ== UI-OutboundReport: notjunk:1;M01:P0:SP4B2YZj6Kg=;c8TgZYmBwovrbUH6iK/Q0h81KaI zZusHPy+ypC+f0122YbEX+iaqAbv9QryJzfKu0PCc6cjeMvAp7hifz+GYeUe6DrQFHfJuywSo QxguXzDONDwvMaCpBBRKODLI5tGOk3Hj5labo5w6OgZmTydq8yKeWcU9V65iqZJgfxhqzGURw WWqrVR/ME7Xp2E/nsCfzeZNfqo8jrtcs6elht98CIt+iEKOjVC1eITHx29MvdmiVy+d/kGmyQ G9sbqfHKiwjvKm49g6ZLzG6uCPwdn+pATNZt4T3u2HkCubR8YhwEPgY0kazGZyY40oDhLsJfr Ncb0xuZbABuc+HqdTZwEjN4JvcCHLJQuSA2qsvPqF6OPqMBtP81jTwjQNP/FtupdquDtoKH7Y 9qbSyH+gGvWisgzJ/pVeK/E+A5LCjIqmVCGCSYctygPu/a21uF1J1pgU1hEtDJ/iVKEPHQGaX 2IkUBT4L2AppR7n+wN1NS5Cun6SPjr0FEo5x65AJSCmv9Ybe9lk56SEGzq56GI2exat+MhQHL LdA6YIL4G+VO5z/JRPp35bbYG7hzcRtDhKvcOqTh9DoU12kNaacUTn3cK8b3w5D+e94UxVIGm zpnVVE17Zi9K/5XHZYIknRK91YJmvpzjK/52Gl2YRn4hrcavrw2XTwyZZHzDc+HM2MHiM3eqy fYa4z+WDUmgPQUGrPnNsNhFNRhf4x3+zPZki4ts4gDp8+2lrTbe5Ob4il1crvMp7SRF4ulrlH 8OtEFlqYpOAvLt8WxbRoq3vOqR6rWrnggb659jrASQwAAdYW4Qddb91N3cGPT16c6jttl1mWW Jsi5Suh1kYLpwXuSTu95AHZfZz6lfWuZ7A514y4er14Rk= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240303_060216_838651_AC652BE0 X-CRM114-Status: GOOD ( 11.51 ) 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 ed768cefe5d0..7c88626af736 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -1112,6 +1112,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) { @@ -1179,7 +1218,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, };