diff options
author | Patrick Delaunay <patrick.delaunay@st.com> | 2020-01-13 11:35:11 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-04-16 23:06:54 -0400 |
commit | 77ed5692c95abcb1cdda5b87570f661bbcf1b4b3 (patch) | |
tree | 7c279d700ff07b1956e66fff03890c4038355da1 /drivers/pinctrl | |
parent | 6a0388c5b12b911e4e2a65b60731c1c245821181 (diff) | |
download | u-boot-77ed5692c95abcb1cdda5b87570f661bbcf1b4b3.tar.gz |
pinctrl: sandbox: Add mux information in get_pin_muxing
Add param information in pin information output.
This update prepare unitary test for pin configuration
in pinctrl node.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/pinctrl-sandbox.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-sandbox.c b/drivers/pinctrl/pinctrl-sandbox.c index 0786afe747..d1a21f0f19 100644 --- a/drivers/pinctrl/pinctrl-sandbox.c +++ b/drivers/pinctrl/pinctrl-sandbox.c @@ -54,6 +54,10 @@ static const struct pinconf_param sandbox_conf_params[] = { { "input-disable", PIN_CONFIG_INPUT_ENABLE, 0 }, }; +/* bitfield used to save param and value of each pin/selector */ +static unsigned int sandbox_pins_param[ARRAY_SIZE(sandbox_pins)]; +static unsigned int sandbox_pins_value[ARRAY_SIZE(sandbox_pins)]; + static int sandbox_get_pins_count(struct udevice *dev) { return ARRAY_SIZE(sandbox_pins); @@ -68,8 +72,25 @@ static int sandbox_get_pin_muxing(struct udevice *dev, unsigned int selector, char *buf, int size) { + const struct pinconf_param *p; + int i; + snprintf(buf, size, "%s", sandbox_pins_muxing[selector]); + if (sandbox_pins_param[selector]) { + for (i = 0, p = sandbox_conf_params; + i < ARRAY_SIZE(sandbox_conf_params); + i++, p++) { + if ((sandbox_pins_param[selector] & BIT(p->param)) && + (!!(sandbox_pins_value[selector] & BIT(p->param)) == + p->default_value)) { + strncat(buf, " ", size); + strncat(buf, p->property, size); + } + } + } + strncat(buf, ".", size); + return 0; } @@ -102,6 +123,9 @@ static int sandbox_pinmux_set(struct udevice *dev, unsigned pin_selector, pin_selector, sandbox_get_pin_name(dev, pin_selector), func_selector, sandbox_get_function_name(dev, func_selector)); + sandbox_pins_param[pin_selector] = 0; + sandbox_pins_value[pin_selector] = 0; + return 0; } @@ -123,6 +147,12 @@ static int sandbox_pinconf_set(struct udevice *dev, unsigned pin_selector, pin_selector, sandbox_get_pin_name(dev, pin_selector), param, argument); + sandbox_pins_param[pin_selector] |= BIT(param); + if (argument) + sandbox_pins_value[pin_selector] |= BIT(param); + else + sandbox_pins_value[pin_selector] &= ~BIT(param); + return 0; } |