[U-Boot] [PATCH v1 1/5] dm: pinctrl: Add pinmux_show() ops

Patrice Chotard patrice.chotard at st.com
Thu Sep 20 13:37:02 UTC 2018


pinmux_show() allows to display the muxing of all pins
belonging to a pin-controller

Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
---

 drivers/pinctrl/pinctrl-uclass.c | 10 ++++++++++
 include/dm/pinctrl.h             | 29 +++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index c38bb212ed74..24de7cc09d63 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -249,6 +249,16 @@ int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index)
 	return ops->get_gpio_mux(dev, banknum, index);
 }
 
+int pinctrl_pinmux_show(struct udevice *dev)
+{
+	struct pinctrl_ops *ops = pinctrl_get_ops(dev);
+
+	if (!ops->pinmux_show)
+		return -ENOSYS;
+
+	return ops->pinmux_show(dev);
+}
+
 /**
  * pinconfig_post_bind() - post binding for PINCTRL uclass
  * Recursively bind child nodes as pinconfig devices in case of full pinctrl.
diff --git a/include/dm/pinctrl.h b/include/dm/pinctrl.h
index 80de3f3fed2b..cbae7e1a640b 100644
--- a/include/dm/pinctrl.h
+++ b/include/dm/pinctrl.h
@@ -66,6 +66,7 @@ struct pinconf_param {
  *	pointing a config node. (necessary for pinctrl_full)
  * @set_state_simple: do needed pinctrl operations for a peripherl @periph.
  *	(necessary for pinctrl_simple)
+ * @pinmux_show: display pin-controller's pin muxing.
  */
 struct pinctrl_ops {
 	int (*get_pins_count)(struct udevice *dev);
@@ -129,6 +130,20 @@ struct pinctrl_ops {
 	* @return mux value (SoC-specific, e.g. 0 for input, 1 for output)
 	 */
 	int (*get_gpio_mux)(struct udevice *dev, int banknum, int index);
+
+	/**
+	 * pinmux_show() - show pin-controller's pins muxing
+	 *
+	 * This allows to display all pin muxing configuration of a
+	 * pin-controller. It's useful for debug purpose to know if a pin is
+	 * configured as GPIO or as an alternate function and which one.
+	 * Typically it is used by a PINCTRL driver with knowledge of the SoC
+	 * pinctrl setup.
+	 *
+	 * @dev:	Pinctrl device to use
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*pinmux_show)(struct udevice *dev);
 };
 
 #define pinctrl_get_ops(dev)	((struct pinctrl_ops *)(dev)->driver->ops)
@@ -348,4 +363,18 @@ int pinctrl_decode_pin_config(const void *blob, int node);
 */
 int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index);
 
+/**
+ * pinctrl_pinmux_show() - display pin-controller pins muxing
+ *
+ * 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
+ * @return 0 if OK, -ve on error
+ */
+int pinctrl_pinmux_show(struct udevice *dev);
+
 #endif /* __PINCTRL_H */
-- 
1.9.1



More information about the U-Boot mailing list