Commit f55a0c0a20cad56440ebe9a9b2999f21ae00f61a

Authored by Patrice Chotard
Committed by Tom Rini
1 parent f9c87adc47

dm: pinctrl: Add get_pin_muxing() ops

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

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 45 additions and 0 deletions Side-by-side Diff

drivers/pinctrl/pinctrl-uclass.c
... ... @@ -249,6 +249,17 @@
249 249 return ops->get_gpio_mux(dev, banknum, index);
250 250 }
251 251  
  252 +int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf,
  253 + int size)
  254 +{
  255 + struct pinctrl_ops *ops = pinctrl_get_ops(dev);
  256 +
  257 + if (!ops->get_pin_muxing)
  258 + return -ENOSYS;
  259 +
  260 + return ops->get_pin_muxing(dev, selector, buf, size);
  261 +}
  262 +
252 263 /**
253 264 * pinconfig_post_bind() - post binding for PINCTRL uclass
254 265 * Recursively bind child nodes as pinconfig devices in case of full pinctrl.
include/dm/pinctrl.h
... ... @@ -66,6 +66,7 @@
66 66 * pointing a config node. (necessary for pinctrl_full)
67 67 * @set_state_simple: do needed pinctrl operations for a peripherl @periph.
68 68 * (necessary for pinctrl_simple)
  69 + * @get_pin_muxing: display the muxing of a given pin.
69 70 */
70 71 struct pinctrl_ops {
71 72 int (*get_pins_count)(struct udevice *dev);
... ... @@ -129,6 +130,24 @@
129 130 * @return mux value (SoC-specific, e.g. 0 for input, 1 for output)
130 131 */
131 132 int (*get_gpio_mux)(struct udevice *dev, int banknum, int index);
  133 +
  134 + /**
  135 + * get_pin_muxing() - show pin muxing
  136 + *
  137 + * This allows to display the muxing of a given pin. It's useful for
  138 + * debug purpose to know if a pin is configured as GPIO or as an
  139 + * alternate function and which one.
  140 + * Typically it is used by a PINCTRL driver with knowledge of the SoC
  141 + * pinctrl setup.
  142 + *
  143 + * @dev: Pinctrl device to use
  144 + * @selector: Pin selector
  145 + * @buf Pin's muxing description
  146 + * @size Pin's muxing description length
  147 + * return 0 if OK, -ve on error
  148 + */
  149 + int (*get_pin_muxing)(struct udevice *dev, unsigned int selector,
  150 + char *buf, int size);
132 151 };
133 152  
134 153 #define pinctrl_get_ops(dev) ((struct pinctrl_ops *)(dev)->driver->ops)
... ... @@ -347,6 +366,21 @@
347 366 * @return mux value (SoC-specific, e.g. 0 for input, 1 for output)
348 367 */
349 368 int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index);
  369 +
  370 +/**
  371 + * pinctrl_get_pin_muxing() - Returns the muxing description
  372 + *
  373 + * This allows to display the muxing description of the given pin for
  374 + * debug purpose
  375 + *
  376 + * @dev: Pinctrl device to use
  377 + * @selector Pin index within pin-controller
  378 + * @buf Pin's muxing description
  379 + * @size Pin's muxing description length
  380 + * @return 0 if OK, -ve on error
  381 + */
  382 +int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf,
  383 + int size);
350 384  
351 385 #endif /* __PINCTRL_H */