diff options
Diffstat (limited to 'zephyr/shim/src/gpio.c')
-rw-r--r-- | zephyr/shim/src/gpio.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c index 59d59d78f7..6eb9a142ad 100644 --- a/zephyr/shim/src/gpio.c +++ b/zephyr/shim/src/gpio.c @@ -286,8 +286,22 @@ static int init_gpios(const struct device *unused) flags &= ~(GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH); - flags |= current ? GPIO_OUTPUT_INIT_HIGH - : GPIO_OUTPUT_INIT_LOW; + + /* + * For an open drain output, its current value + * doesn't imply the previous output state. + * + * The current low state is either + * 1) the EC previously drove the pin low; + * 2) the EC previously high-Z'ed the pin. + * + * These 2 cases can't be differentiated, so + * skip overriding the output state. + */ + if ((flags & GPIO_OPEN_DRAIN) != GPIO_OPEN_DRAIN) { + flags |= current ? GPIO_OUTPUT_INIT_HIGH + : GPIO_OUTPUT_INIT_LOW; + } } rv = gpio_pin_configure_dt(&configs[i].spec, flags); |