summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Wahren <wahrenst@gmx.net>2024-03-07 08:01:13 +0100
committerLinus Walleij <linus.walleij@linaro.org>2024-03-28 09:52:25 +0100
commitd54e4cda297241406bed37af3f836d242184ec84 (patch)
tree915a21f842245959ce9eada72b01e69f2ae8d0ca
parent85b02bc0785b5e6326814af7e1b7528ce3a488ea (diff)
downloadlinux-d54e4cda297241406bed37af3f836d242184ec84.tar.gz
linux-d54e4cda297241406bed37af3f836d242184ec84.tar.bz2
linux-d54e4cda297241406bed37af3f836d242184ec84.zip
pinctrl: bcm2835: Implement bcm2711_pinconf_get
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 <wahrenst@gmx.net> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Message-ID: <20240307070113.4888-3-wahrenst@gmx.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/pinctrl/bcm/pinctrl-bcm2835.c41
1 files changed, 40 insertions, 1 deletions
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,
};