summaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-01-21 19:43:56 -0700
committerSimon Glass <sjg@chromium.org>2016-01-21 20:42:35 -0700
commit77eaa19e73f0c6b4c29982417676ab23cd72895a (patch)
treeb7ab16733baebc6138519269b323b122c04c5f80 /include/dm
parent1f2b4b06ae327ea899d63b1dd0d12751b9ac850b (diff)
downloadu-boot-imx-77eaa19e73f0c6b4c29982417676ab23cd72895a.zip
u-boot-imx-77eaa19e73f0c6b4c29982417676ab23cd72895a.tar.gz
u-boot-imx-77eaa19e73f0c6b4c29982417676ab23cd72895a.tar.bz2
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 'include/dm')
-rw-r--r--include/dm/pinctrl.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/dm/pinctrl.h b/include/dm/pinctrl.h
index 5cd4503..0eb4b92 100644
--- a/include/dm/pinctrl.h
+++ b/include/dm/pinctrl.h
@@ -114,6 +114,22 @@ struct pinctrl_ops {
* @return peripheral ID of @periph, or -ENOENT on error
*/
int (*get_periph_id)(struct udevice *dev, struct udevice *periph);
+
+ /**
+ * get_gpio_mux() - get the mux value for a particular GPIO
+ *
+ * This allows the raw mux value for a GPIO to be obtained. It is
+ * useful for displaying the function being used by that GPIO, such
+ * as with the 'gpio' command. This function is internal to the GPIO
+ * subsystem and should not be used by generic code. Typically it is
+ * used by a GPIO driver with knowledge of the SoC pinctrl setup.
+ *
+ * @dev: Pinctrl device to use
+ * @banknum: GPIO bank number
+ * @index: GPIO index within the bank
+ * @return mux value (SoC-specific, e.g. 0 for input, 1 for output)
+ */
+ int (*get_gpio_mux)(struct udevice *dev, int banknum, int index);
};
#define pinctrl_get_ops(dev) ((struct pinctrl_ops *)(dev)->driver->ops)
@@ -297,4 +313,20 @@ int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph);
*/
int pinctrl_decode_pin_config(const void *blob, int node);
+/**
+ * pinctrl_get_gpio_mux() - get the mux value for a particular GPIO
+ *
+ * This allows the raw mux value for a GPIO to be obtained. It is
+ * useful for displaying the function being used by that GPIO, such
+ * as with the 'gpio' command. This function is internal to the GPIO
+ * subsystem and should not be used by generic code. Typically it is
+ * used by a GPIO driver with knowledge of the SoC pinctrl setup.
+ *
+ * @dev: Pinctrl device to use
+ * @banknum: GPIO bank number
+ * @index: GPIO index within the bank
+ * @return mux value (SoC-specific, e.g. 0 for input, 1 for output)
+*/
+int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index);
+
#endif /* __PINCTRL_H */