Description
Describe the bug
The current implementation of the regulator-fixed
read the current state of the GPIO before writing and only changes the state of that GPIO, when it is different from the expected state. This leads to the problem, that a requested new state is not applied when a wrong value is being returned by gpio_pin_get_dt()
and the voltage change is not effective.
zephyr/drivers/regulator/regulator_gpio.c
Lines 41 to 48 in e22ca6b
I tried to use this driver with a nRF9151 and noticed, that it somehow did lock up in one specific state. The nRF9151 does actually disconnect the input buffer when configured as output. This can also be seen on the diagram of how the pins on a nRF9151 work.

The nRF9151 allows to enable the input driver while being configured as output. The driver expects in this case that gpio_pin_configure()
the GPIO_OUTPUT
and GPIO_INPUT
flags are being set.
zephyr/drivers/gpio/gpio_nrfx.c
Lines 187 to 192 in e22ca6b
To allow the regulator-gpio
driver to work with nordic micro controllers, i see two possible improvements, which would solve this:
- Don't check the current state of the GPIO before setting it, or allow to disable this behavior
- Set
GPIO_OUTPUT
andGPIO_INPUT
flags when configuring the control GPIOs
Regression
- This is a regression.
Steps to reproduce
- Connect a GPIO controlled voltage regulator to a nordic micro controller(or any micro controller not allowing read back from outputs by default)
- Configure the voltage regulator as
regulator-gpio
in the device tree - Change the requested voltage e.g. via the regulator-shell and observe, that certain voltages won't change even when requested
Relevant log output
Impact
Functional Limitation – Some features not working as expected, but system usable.
Environment
- MCU: nRF9151
- SDK: nRF Connect SDK 3.0.1
Additional Context
No response