summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/meson/pinctrl-meson.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pinctrl/meson/pinctrl-meson.c')
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index babf1bccc96..7dbaf966f93 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -117,8 +117,26 @@ int meson_gpio_get(struct udevice *dev, unsigned int offset)
struct meson_pinctrl *priv = dev_get_priv(dev->parent);
unsigned int reg, bit;
int ret;
+ enum gpio_func_t direction;
+ enum meson_reg_type reg_type;
- ret = meson_gpio_calc_reg_and_bit(dev->parent, offset, REG_IN, &reg,
+ direction = meson_gpio_get_direction(dev, offset);
+
+ switch (direction) {
+ case GPIOF_INPUT:
+ reg_type = REG_IN;
+ break;
+
+ case GPIOF_OUTPUT:
+ reg_type = REG_OUT;
+ break;
+
+ default:
+ dev_warn(dev, "Failed to get current direction of Pin %u\n", offset);
+ return -EINVAL;
+ }
+
+ ret = meson_gpio_calc_reg_and_bit(dev->parent, offset, reg_type, &reg,
&bit);
if (ret)
return ret;