aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass2016-01-21 19:43:56 -0700
committerSimon Glass2016-01-21 20:42:35 -0700
commit77eaa19e73f0c6b4c29982417676ab23cd72895a (patch)
treeb7ab16733baebc6138519269b323b122c04c5f80 /drivers
parent1f2b4b06ae327ea899d63b1dd0d12751b9ac850b (diff)
dm: pinctrl: Add a way for a GPIO driver to obtain a pin function
GPIO drivers want to be able to show if a pin is enabled for input, output, or is being used by another function. Some drivers can easily find this and the code is included in the driver. For some SoCs this is more complex. Conceptually this should be handled by pinctrl rather than GPIO. Most pinctrl drivers will have this feature anyway. Add a method by which a GPIO driver can obtain the pin mux value given a GPIO reference. This avoids repeating the code in two places. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pinctrl/pinctrl-uclass.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index 1acbfafa818..ccc5d309d6d 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -246,6 +246,16 @@ int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph)
return ops->get_periph_id(dev, periph);
}
+int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index)
+{
+ struct pinctrl_ops *ops = pinctrl_get_ops(dev);
+
+ if (!ops->get_gpio_mux)
+ return -ENOSYS;
+
+ return ops->get_gpio_mux(dev, banknum, index);
+}
+
/**
* pinconfig_post-bind() - post binding for PINCTRL uclass
* Recursively bind child nodes as pinconfig devices in case of full pinctrl.