summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wahren <wahrenst@gmx.net>2024-03-07 10:01:12 +0300
committerLinus Walleij <linus.walleij@linaro.org>2024-03-28 11:52:25 +0300
commit85b02bc0785b5e6326814af7e1b7528ce3a488ea (patch)
tree1195261ba6181dc683242b012b8b780d45a27c99
parent76c22f094153478dc89735c9bd259ad99f933913 (diff)
downloadlinux-85b02bc0785b5e6326814af7e1b7528ce3a488ea.tar.xz
pinctrl: bcm2835: Implement bcm2835_pinconf_get
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. Keep ENOTSUPP here, because it's only used internally. Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Message-ID: <20240307070113.4888-2-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/pinctrl/bcm/pinctrl-bcm2835.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
index 1489191a213f..5d2b188a1ef4 100644
--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
@@ -1003,8 +1003,27 @@ 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 */
- return -ENOTSUPP;
+ 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_OUTPUT:
+ if (fsel != BCM2835_FSEL_GPIO_OUT)
+ return -EINVAL;
+
+ val = bcm2835_gpio_get_bit(pc, GPLEV0, pin);
+ *config = pinconf_to_config_packed(param, val);
+ break;
+
+ default:
+ return -ENOTSUPP;
+ }
+
+ return 0;
}
static void bcm2835_pull_config_set(struct bcm2835_pinctrl *pc,