Skip to content
Snippets Groups Projects
Commit e87e86f3 authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

gpio: sandbox: Make sandbox_gpio_set_flags() set all flags


Allow this function to see all flags, including the internal sandbox ones.
This allows the tests to fully control the behaviour of the driver.

To make this work, move the setting of GPIOD_EXT_HIGH -to where the flags
are updated via driver model, rather than the sandbox 'back door'.

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>

Reviewed-by: default avatarPatrick Delaunay <patrick.delaunay@foss.st.com>
parent 0242aecb
No related branches found
No related tags found
No related merge requests found
...@@ -114,13 +114,7 @@ int sandbox_gpio_set_flags(struct udevice *dev, uint offset, ulong flags) ...@@ -114,13 +114,7 @@ int sandbox_gpio_set_flags(struct udevice *dev, uint offset, ulong flags)
{ {
struct gpio_state *state = get_gpio_state(dev, offset); struct gpio_state *state = get_gpio_state(dev, offset);
/* state->flags = flags;
* We don't need to clear GPIOD_EXT_HIGH here to make the tests pass,
* but this is handled in a future patch.
*/
if (flags & GPIOD_IS_OUT_ACTIVE)
flags |= GPIOD_EXT_HIGH;
state->flags = (state->flags & GPIOD_SANDBOX_MASK) | flags;
return 0; return 0;
} }
...@@ -221,14 +215,23 @@ static int sb_gpio_set_flags(struct udevice *dev, unsigned int offset, ...@@ -221,14 +215,23 @@ static int sb_gpio_set_flags(struct udevice *dev, unsigned int offset,
ulong flags) ulong flags)
{ {
debug("%s: offset:%u, flags = %lx\n", __func__, offset, flags); debug("%s: offset:%u, flags = %lx\n", __func__, offset, flags);
struct gpio_state *state = get_gpio_state(dev, offset);
return sandbox_gpio_set_flags(dev, offset, flags); if (flags & GPIOD_IS_OUT) {
if (flags & GPIOD_IS_OUT_ACTIVE)
flags |= GPIOD_EXT_HIGH;
else
flags &= ~GPIOD_EXT_HIGH;
}
state->flags = flags;
return 0;
} }
static int sb_gpio_get_flags(struct udevice *dev, uint offset, ulong *flagsp) static int sb_gpio_get_flags(struct udevice *dev, uint offset, ulong *flagsp)
{ {
debug("%s: offset:%u\n", __func__, offset); debug("%s: offset:%u\n", __func__, offset);
*flagsp = *get_gpio_flags(dev, offset); *flagsp = *get_gpio_flags(dev, offset) & ~GPIOD_SANDBOX_MASK;
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment