pinctrl: support selecting states from command line
Subsystems (3)
PATCH 1/1 pinctrl: support selecting states from command line
This can be useful for debugging to exercise pinctrl for nodes that have no driver yet. Example:
setenv adc-joystick.of.pinctrl_state=default
Signed-off-by Ahmad Fatoum <[email protected]>
--- drivers/base/driver.c | 4 ++ drivers/pinctrl/Kconfig | 4 ++ drivers/pinctrl/pinctrl.c | 92 +++++++++++++++++++++++++++++++++++++++ include/param.h | 2 + include/pinctrl.h | 10 +++++ lib/parameter.c | 6 ++- 6 files changed, 116 insertions(+), 2 deletions(-)
drivers/base/driver.c +4 -0
@@ -268,6 +268,8 @@ int register_device(struct device *new_device)bobject_init (&new_device->bobject); +of_pinctrl_register_consumer (new_device, new_device->device_node); +if (new_device->bus) {if (!new_device->parent) new_device->parent = &new_device->bus->dev;
@@ -298,6 +300,8 @@ int unregister_device(struct device *old_dev)bobject_del (&old_dev->bobject); +of_pinctrl_unregister_consumer (old_dev); +if (old_dev->driver)device_remove (old_dev);
drivers/pinctrl/Kconfig +4 -0
@@ -10,6 +10,10 @@ config PINCTRL from the devicetree. Legacy drivers here may not need this core support but instead provide their own SoC specific APIs +config PINCTRL_STATE_PARAM + bool "pinctrl state control via device parameters" + depends on PARAMETER && PINCTRL + # The following drivers are needed even without PINCTRL because # the either have a legacy iomux interface or also register a gpio # chip.
drivers/pinctrl/pinctrl.c +92 -0
123 lines not on this page · raw message
include/param.h +2 -0
@@ -42,6 +42,8 @@ struct param_d {enum param_type type; }; +#define PARAM_ENUM_UNKNOWN (-1000000) +enum param_tristate {PARAM_TRISTATE_UNKNOWN ,PARAM_TRISTATE_TRUE ,PARAM_TRISTATE_FALSE };#ifdef CONFIG_PARAMETER
include/pinctrl.h +10 -0
@@ -25,4 +25,14 @@ struct pinctrl_device {int pinctrl_register (struct pinctrl_device *pdev);void pinctrl_unregister (struct pinctrl_device *pdev); +#ifdef CONFIG_PINCTRL_STATE_PARAM +void of_pinctrl_register_consumer (struct device *dev,struct device_node *np); +void of_pinctrl_unregister_consumer (struct device *dev); +#else +static inline void of_pinctrl_register_consumer (struct device *dev,struct device_node *np) +{ +} +static inline void of_pinctrl_unregister_consumer (struct device *dev) {} +#endif +#endif /* PINCTRL_H */
lib/parameter.c +4 -2
@@ -612,7 +612,9 @@ static const char *param_enum_get(struct bobject *bobj, struct param_d *p)free (p->value); -if (*pe->value >= pe->num_names) +if (*pe->value ==PARAM_ENUM_UNKNOWN ) + p->value =strdup ("unknown" ); +else if (*pe->value >= pe->num_names) p->value =basprintf ("invalid:%d" , *pe->value);else p->value =strdup (pe->names[*pe->value]);
@@ -625,7 +627,7 @@ static void param_enum_info(struct param_d *p)struct param_enum *pe =to_param_enum (p);int i; -if (pe->num_names <=1 ) +if (pe->num_names <=1 && *pe->value !=PARAM_ENUM_UNKNOWN )return ;printf (" (values: " );
Signature · 1 line
2.47.3
Sascha Hauer
AppliedQuoted 6 lines · Ahmad Fatoum
This can be useful for debugging to exercise pinctrl for nodes that have no driver yet. Example:
setenv adc-joystick.of.pinctrl_state=default
Applied, thanks!
[1/1] pinctrl: support selecting states from command line
https://git.pengutronix.de/cgit/barebox/commit/?id=27ae60915e43 (link may not be stable)
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>