From patchwork Sat Mar 2 09:54:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13579499 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 BD730C54E4A for ; Sat, 2 Mar 2024 09:55:10 +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=xjljr7+PPwuNFT /MsfMXS/7tg533K8QU2BAkfROTlKTdnljih8C0PBZCbLwx+lwrgiUInCZIbeVwoWwHyw6asuy2cS2 eqF8avRAM2KLk+w+9/4kreIctO0wSe8KHT/FQ7aNL6kNLt/p3G9bEf3XiokwpZD+nwhxCZjNX8gQ9 B9bqd7/30wXkH2XaiA9TB5yE3S8+uKLiqiNFxr/MdN5stD1Bw2eTGvzqKdGGg1onWsDIWRdWRwrhJ PY6lJ82mdI9fbUcEEew17xbE4tYOyr+VqW6CLgDHqqlnIaKdqOU+WML9Fkdew2WbXh35Yaa7TTBzW 0+bb1L3WxRZIbCX42zaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgM57-00000003GcH-0OPo; Sat, 02 Mar 2024 09:55:01 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgM53-00000003Ga7-0mLf; Sat, 02 Mar 2024 09:54:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1709373292; x=1709978092; i=wahrenst@gmx.net; bh=vxjfUH6oE+5NHrasm9nsqIMIn8HoUbUx645/gxxS4D8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=YuuGuCwXxQImDr5Hs9a/lqXPG4BrsZz9PjgU2C8ZdKrbWI/zWAkVmOIUdjxW4wGX FXLGuijkkWy09qQM3LfryluRg31o8nDi1qFATLtihXfKVHTGuXJEzCR4uuRLnNLPM wkiXER2UJx/aOe7QfPAzcCaNg7rsMtiTJ2xRZL1EbcYJnZqEIUm8Sbp9DvHoO74H1 RN6/iXaWzZdIXElIUdidQ3LM0dStbmznZErnITGWnDJlK6awk/nNQLN0lY/dAnKzb WIjwSJjfLGALoa6x2sCwXmQ+DACp4alXJH20pB1zuTCiZpkwEeMl3mW5Zq03qiIt+ v5pZS22lftarXD1Nkw== 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 1MUowV-1rG7wo3lJZ-00QgHU; Sat, 02 Mar 2024 10:54:52 +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 V2 1/2] pinctrl: bcm2835: Implement bcm2835_pinconf_get Date: Sat, 2 Mar 2024 10:54:29 +0100 Message-Id: <20240302095430.4871-2-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240302095430.4871-1-wahrenst@gmx.net> References: <20240302095430.4871-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:c15vxFlTnCc3Lz7gwS+zvXayDt6flnwermTsw0Q33JwhKKbEJn6 esuilFN9XKlmjBBujcj74DWH4/v6lBiBfbMC7AKsx/i+s8tBTh3VH2McfxPlWdk6+6ObP+e 2eoRiyV7UUTfEedkHTCOcwOxs2UjO88FFYDkwtIOxit5RQ4IPwlRVnWNV7O2xwZhqtfhVTL pIMy9WqBbd75wSW1HUc2A== UI-OutboundReport: notjunk:1;M01:P0:+kw/xRZqaEA=;8KNR/eJfixXGPAdEholcLjyz6Ec F2vQVi7yuCG4QqSL/2F/BEgm3Y9W6bh07KovZQym+ewClnjfJMGUSOdisXQg7OO5MDL9g1nVV G8FCboc6RRBC8xriamArXwQTH4c8vfSV19zvO6FyDggNtSOarqyD5azMF3ZhvgiFXaEaM9vjz w1m9JrbmEoCIe7zVDHHZBhmgtKjk17n2fKe9jLcc1W07sIb8usdHht2XP0zYLE0/QZdpcMzYQ +B5E60UbKyilY74Y9XFMVgznO4jeKpf3kNIKr7bzD0hBWsCeoPuYNfgNuk/HqmpY8Xgya2ltW EiAK19k+Qht3X2I93DT63GBd2d2errni3qZQb3dOADZqKXRzQt005T/tQ38m7FXue1dihXUns LFtHdj3xl8S05fs1A1aaxOY5Lxenxq16Xqgct/JJtqJg7AueQNHd38QddQIR4EHDulE08y6bk eJookqAfmHVxj/4w1xilq1hXNH+5I/h447eteJEPwmRNc0V0HTAvv0uM0V8tTlxHjkGcTKYzg 3pzxljA5jFyzE8pbT8568PnMGCFl2cp7gVqV4Vj4bkDiaD+fhzB9KdGkixmwGiBSOl6JDL3QM Y5r09a703fjqB77HlPejcUMmxKSZ32ceNK1BABqx4EucdL6hhTgWkvFMlLhssx+9fG5vqy3zl B9Wz9yXEgwyn7o0HBc/djGKa1YEOAPR7hl5FV73RZiV65hnzci3mwAL39t1zUHJ00pkcio6+2 bp5VKv33eBDPbNKlqTGmN29gld0oL4I6Z7Pgcn9hoKzzZQasUlIB/B+Zoz2wx4dTuAcCeHLbm osB0Hv7155Is4+73sAiWGDHopjvpp1vLdvBN4w3/Iur7s= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240302_015457_531085_EEC2395E X-CRM114-Status: GOOD ( 12.80 ) 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; }