Message ID | 1537450626-27439-2-git-send-email-patrice.chotard@st.com |
---|---|
State | Changes Requested |
Delegated to: | Simon Glass |
Headers | show |
Series | Add pinmux command | expand |
Hi Patrice, On 20 September 2018 at 07:37, Patrice Chotard <patrice.chotard@st.com> wrote: > pinmux_show() allows to display the muxing of all pins > belonging to a pin-controller > > Signed-off-by: Patrice Chotard <patrice.chotard@st.com> > --- > > drivers/pinctrl/pinctrl-uclass.c | 10 ++++++++++ > include/dm/pinctrl.h | 29 +++++++++++++++++++++++++++++ > 2 files changed, 39 insertions(+) > If you look at this pinctrl method: const char *(*get_pin_name)(struct udevice *dev, unsigned selector); you can see that we can specify particular pins. Can we have the command discover what pins are available and iterate over them? Then we can have a function which returns the status of a particular pin as a string, and the command can output it. Perhaps like cpu_get_desc()? Regards, Simon
Hi Simon On 09/26/2018 07:42 AM, Simon Glass wrote: > Hi Patrice, > > On 20 September 2018 at 07:37, Patrice Chotard <patrice.chotard@st.com> wrote: >> pinmux_show() allows to display the muxing of all pins >> belonging to a pin-controller >> >> Signed-off-by: Patrice Chotard <patrice.chotard@st.com> >> --- >> >> drivers/pinctrl/pinctrl-uclass.c | 10 ++++++++++ >> include/dm/pinctrl.h | 29 +++++++++++++++++++++++++++++ >> 2 files changed, 39 insertions(+) >> > > If you look at this pinctrl method: > > const char *(*get_pin_name)(struct udevice *dev, unsigned selector); > > you can see that we can specify particular pins. Can we have the > command discover what pins are available and iterate over them? Then > we can have a function which returns the status of a particular pin as > a string, and the command can output it. Perhaps like cpu_get_desc()? Understand, i will rework this series following this way of doing. Thanks Patrice > > Regards, > Simon >
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 */
pinmux_show() allows to display the muxing of all pins belonging to a pin-controller Signed-off-by: Patrice Chotard <patrice.chotard@st.com> --- drivers/pinctrl/pinctrl-uclass.c | 10 ++++++++++ include/dm/pinctrl.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+)