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: 777588 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (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 21BA213FF1 for ; Sat, 2 Mar 2024 09:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709373303; cv=none; b=rbzfdBlwyjGqhiL0gObUqxWNwB75hlD4wM/lef1JT6GpVULuyLcGNqph+yjnk5vAFXEY85uz57iC9lGJskjAi7Q3SXQaNavUPNdrdGQ6qClowN7YCCp5/yZBDb1Kue6/H6w+M2zXY7GWpcm6olzuZIdxHfuEwb3Tn/JrngvpXzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709373303; c=relaxed/simple; bh=vxjfUH6oE+5NHrasm9nsqIMIn8HoUbUx645/gxxS4D8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gL+YOettAg5U9LTdAHSgiEqqcMYm27zLfmuR5gq1FFws8n9Xdm1ZwhuxDF6Mjcgo/PcrejleBeiuUL27dA9jq+Kaonn1Q6XdnKr1sTG7vxf5yn42aXHgerY4lAyF2CbtxZ7LHtwkgHZRA1qj6RjctQp1C0JHSfSO+bO95Eg7MTM= 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=YuuGuCwX; arc=none smtp.client-ip=212.227.15.15 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="YuuGuCwX" 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> 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:c15vxFlTnCc3Lz7gwS+zvXayDt6flnwermTsw0Q33JwhKKbEJn6 esuilFN9XKlmjBBujcj74DWH4/v6lBiBfbMC7AKsx/i+s8tBTh3VH2McfxPlWdk6+6ObP+e 2eoRiyV7UUTfEedkHTCOcwOxs2UjO88FFYDkwtIOxit5RQ4IPwlRVnWNV7O2xwZhqtfhVTL pIMy9WqBbd75wSW1HUc2A== X-Spam-Flag: NO 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= 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 Sat Mar 2 09:54:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 777659 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (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 9E73B79C8 for ; Sat, 2 Mar 2024 09:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709373303; cv=none; b=VuHxWpt96cPuLAFrqAvEnxbeLsrnygbh2o9RTfMFEtrETLf5u++aoeIl5UiKpS8mwpkvAZCt4R4HcUSmIP8VxiPBUmVZyLFKqpSp73O3sLDv2qMFNnmIKbBq5NcES6FM2e8F4cRLX5YlfkAwPCCGUPZJsGwrzgXcmYSRJ1Nqjm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709373303; c=relaxed/simple; bh=pxvTbFrEhKnP34X+hqvpNu02JI9TDimz+eas9scR3aU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FslnoBRcFt+9rOlMuylQHZIJcnwyyn8wottwIf0SlGUYgl9QfgL7jv1S5cOdbTXZq2UK/Ig3o5/Dm3BbhpQMDtYKePCNJDjQvgm7Z0x6HegQWW8nOiRgvx/hGR4HcpQrt52xMfoXitejtrh0iYV02xJkH/3vfO8VPuO19ANUbls= 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=mBDip5kD; arc=none smtp.client-ip=212.227.15.19 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="mBDip5kD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1709373292; x=1709978092; i=wahrenst@gmx.net; bh=pxvTbFrEhKnP34X+hqvpNu02JI9TDimz+eas9scR3aU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=mBDip5kDBI/j2foJXg/xgHdm/efhWcpXEZ2kr3zoJxm4YezrPEknQ2h9T7mcv2Jt RPWMc9L8EpZyovdOcQPr5Qbtc1nIYZHnERLCcYVpYvvm+Hm78Mgk//C4mkHfQcxvh iY7Ps7X1fOM+q7eDtz0Ae3UvnB+YU6kywHkzxhexA44aVK6phSkJt58N3XBMWkIp9 OenGC8G3csoRAtBdGbZ1u8gFeOOhfuWaKh5LDuKmr4Acd0xvydBNFoDrgWSOEKSBa dgcFS0pDILeKP6CuwNoLdqZOSl7Ep+5M3tA5LwCIN+5GK8/RI2+P54t3NtkxC72Jv EKgY9sdcheSojGJ2iA== 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 1MybKp-1qxJTN0zzZ-00yxq4; 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 2/2] pinctrl: bcm2835: Implement bcm2711_pinconf_get Date: Sat, 2 Mar 2024 10:54:30 +0100 Message-Id: <20240302095430.4871-3-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> 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:G3xIv53yPqofak8lVAYgqEtlc/bPM6Ubbnh330WxX92F8L4rkJR aW4QYQIsexT0YvdXG3nHjRQFOVGvguePsDWYw/QM1Cefxjk61x/8sRl757JuO4/w6EkzdLN Ip7J9K3eIJIMIfpVMc5n2hCfEgO+vyqmc4RHAgSEBloG762ImyxREWam8itdZI2d9QUP265 SZ4IxJrVHYp0Q6qT3/sOQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:pn8wpvsTGE0=;jnMDqSrCSfR2yFDaPTrCTi5GGEC EGSBPcTAoGO10YoI8jkWR9M0a8vNZfUSfVQCsSrvNDtayNU6JZUfZtsYwGqG6xcCFMN67CFZy h9NcW81BZ9O1pn8h8q95bhVZtKkcaSM1wyrN8DxfTKWVqjQW65yV+NCaSPrF+45o0OKtUoEKa yF+y6UM8+xQB1e4eCGsxTjN3cMc6Qe2BvTjPJiFJnZ5k84g0wgV6Af0d4agRwj902O+PCGHvB htgrs9vhafjOkVtGf18t9W2KZngiiigQRMWJT5ONrq8JGmto6Y33b/DiWVQENzQrHM8ZBnyz9 ras/kyocUj/HuxDl74dD7LxQpXz1b8PG8TzCx6CZYuWDGg5fjvTEGNkYOVc/EdGHjgcn8r6kw /a+KyeK+wXQjgbuzabhsx9VtpH652VF+YmPSQuW4YZeLD0bmwEQ1lISlV/1Yf7jxxDEJPLUhp 30SYVKPYhV6xKaOS8YgncUtjk6r37tC5jSuVMGjPOk7f8qBL1O0IwnRYbVQD1FR00El8J/l6X PNj09yyxv8MxiFZL4vgDYhVO1Q2hFcly4hcm6YqWaS1fN8NVdNE4FurPcVlfdlL19AWlYZXOd nDW5FwaCtTKvtXB2nTTXlmsdWGLjNfsWFc3WlJVhvT8zKocLqIRNCMPo3jbLOsce7odJbSr1y wwNOLyWD2pxAjcfZWZBUXfhVuuh9a+Ly6gcyUyEAP7eijJywz303dQIYjBmG88r1wWDO3hkme oGibWaTPLat2JAZakvLD6TToMEQpNOptJu/SKBlvVHRSU1W0ollxJ0aAxSC06kxjCrIsV6kZx WeXtGwElymQOJS9rdoYpgPZDsRQuVquNHJMU18rAGHDq4= 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 --- 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, 50000); + 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, 50000); + 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, };