]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: pinctrl: Add pinctrl_get_pin_name and pinctrl_get_pins_count
authorPatrice Chotard <patrice.chotard@st.com>
Wed, 24 Oct 2018 12:10:14 +0000 (14:10 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 16 Nov 2018 21:51:55 +0000 (16:51 -0500)
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>
drivers/pinctrl/pinctrl-uclass.c
include/dm/pinctrl.h

index 3833dd2324f6bff191452839da5c6c3eccd87798..6db0445067079dcb2bdc986d7a1b6cd49710da98 100644 (file)
@@ -249,6 +249,29 @@ int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index)
        return ops->get_gpio_mux(dev, banknum, index);
 }
 
+int pinctrl_get_pins_count(struct udevice *dev)
+{
+       struct pinctrl_ops *ops = pinctrl_get_ops(dev);
+
+       if (!ops->get_pins_count)
+               return -ENOSYS;
+
+       return ops->get_pins_count(dev);
+}
+
+int pinctrl_get_pin_name(struct udevice *dev, int selector, char *buf,
+                        int size)
+{
+       struct pinctrl_ops *ops = pinctrl_get_ops(dev);
+
+       if (!ops->get_pin_name)
+               return -ENOSYS;
+
+       snprintf(buf, size, ops->get_pin_name(dev, selector));
+
+       return 0;
+}
+
 int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf,
                           int size)
 {
index e88438d6a5dcee779fc6061e237175e31a1533e5..5a7c5f102e67e2ff166d506cc4cd04e3eb7d123e 100644 (file)
@@ -382,4 +382,26 @@ int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index);
 int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf,
                           int size);
 
+/**
+ * pinctrl_get_pins_count() - display pin-controller pins number
+ *
+ * This allows to know the number of pins owned by a given pin-controller
+ *
+ * @dev:       Pinctrl device to use
+ * @return pins number if OK, -ve on error
+ */
+int pinctrl_get_pins_count(struct udevice *dev);
+
+/**
+ * pinctrl_get_pin_name() - Returns the pin's name
+ *
+ * This allows to display the pin's name for debug purpose
+ *
+ * @dev:       Pinctrl device to use
+ * @selector   Pin index within pin-controller
+ * @buf                Pin's name
+ * @return 0 if OK, -ve on error
+ */
+int pinctrl_get_pin_name(struct udevice *dev, int selector, char *buf,
+                        int size);
 #endif /* __PINCTRL_H */