[U-Boot] [PATCH v2 1/9] dm: pinctrl: Add get_pin_muxing() ops

Patrice Chotard patrice.chotard at st.com
Mon Oct 1 11:59:29 UTC 2018


Add get_pin_muxing() allows to display the muxing of
a given pin belonging to a pin-controller

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

Changes in v2:
 - Replace pinmux_show ops which displayed the complete pin-controller
   muxing by get_pin_muxing ops which displays the muxing of one pin

 drivers/pinctrl/pinctrl-uclass.c | 13 +++++++++++++
 include/dm/pinctrl.h             | 17 +++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index c38bb212ed74..7671f1b551cb 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -249,6 +249,19 @@ int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index)
 	return ops->get_gpio_mux(dev, banknum, index);
 }
 
+int pinctrl_get_pin_muxing(struct udevice *dev, int selector, const char **buf)
+
+{
+	struct pinctrl_ops *ops = pinctrl_get_ops(dev);
+
+	if (!ops->get_pin_muxing)
+		return -ENOSYS;
+
+	*buf = ops->get_pin_muxing(dev, selector);
+
+	return 0;
+}
+
 /**
  * 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..34afdbb02238 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)
+ * @get_pin_muxing: display the muxing of a given pin.
  */
 struct pinctrl_ops {
 	int (*get_pins_count)(struct udevice *dev);
@@ -129,6 +130,22 @@ 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);
+
+	/**
+	 * get_pin_muxing() - show pin muxing
+	 *
+	 * This allows to display the muxing of a given pin. 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
+	 * @selector	Pin selector
+	 * @return a string wich contains the muxing description
+	 */
+	const char *(*get_pin_muxing)(struct udevice *dev,
+				      unsigned int selector);
 };
 
 #define pinctrl_get_ops(dev)	((struct pinctrl_ops *)(dev)->driver->ops)
-- 
1.9.1



More information about the U-Boot mailing list