Commit 8bbb5b20852aa81024eb7b2dcc3eb58275e83bb0

Authored by Patrice Chotard
Committed by Tom Rini
1 parent f55a0c0a20

dm: pinctrl: Add pinctrl_get_pin_name and pinctrl_get_pins_count

Add pinctrl_get_pin_name() and pinctrl_get_pins_count() methods
to obtain pin's name and pin's muxing given a pin reference.

This will be used by the new pinmux command.

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,29 @@
249 249 return ops->get_gpio_mux(dev, banknum, index);
250 250 }
251 251  
  252 +int pinctrl_get_pins_count(struct udevice *dev)
  253 +{
  254 + struct pinctrl_ops *ops = pinctrl_get_ops(dev);
  255 +
  256 + if (!ops->get_pins_count)
  257 + return -ENOSYS;
  258 +
  259 + return ops->get_pins_count(dev);
  260 +}
  261 +
  262 +int pinctrl_get_pin_name(struct udevice *dev, int selector, char *buf,
  263 + int size)
  264 +{
  265 + struct pinctrl_ops *ops = pinctrl_get_ops(dev);
  266 +
  267 + if (!ops->get_pin_name)
  268 + return -ENOSYS;
  269 +
  270 + snprintf(buf, size, ops->get_pin_name(dev, selector));
  271 +
  272 + return 0;
  273 +}
  274 +
252 275 int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf,
253 276 int size)
254 277 {
include/dm/pinctrl.h
... ... @@ -382,5 +382,27 @@
382 382 int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf,
383 383 int size);
384 384  
  385 +/**
  386 + * pinctrl_get_pins_count() - display pin-controller pins number
  387 + *
  388 + * This allows to know the number of pins owned by a given pin-controller
  389 + *
  390 + * @dev: Pinctrl device to use
  391 + * @return pins number if OK, -ve on error
  392 + */
  393 +int pinctrl_get_pins_count(struct udevice *dev);
  394 +
  395 +/**
  396 + * pinctrl_get_pin_name() - Returns the pin's name
  397 + *
  398 + * This allows to display the pin's name for debug purpose
  399 + *
  400 + * @dev: Pinctrl device to use
  401 + * @selector Pin index within pin-controller
  402 + * @buf Pin's name
  403 + * @return 0 if OK, -ve on error
  404 + */
  405 +int pinctrl_get_pin_name(struct udevice *dev, int selector, char *buf,
  406 + int size);
385 407 #endif /* __PINCTRL_H */