Skip to content

regulator-gpio: new voltage does not get applied when reading current GPIO state is not possible #93012

Open
@rvoell-7lab

Description

@rvoell-7lab

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.

ret = gpio_pin_get_dt(&cfg->gpios[gpio_idx]);
if (ret < 0) {
LOG_ERR("%s: can't get pin state", dev->name);
return ret;
}
if (ret != new_state_of_gpio) {
ret = gpio_pin_set_dt(&cfg->gpios[gpio_idx], new_state_of_gpio);

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.

Image

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.

if (flags & GPIO_OUTPUT) {
nrfx_gpiote_output_config_t output_config = {
.drive = drive,
.input_connect = (flags & GPIO_INPUT)
? NRF_GPIO_PIN_INPUT_CONNECT
: NRF_GPIO_PIN_INPUT_DISCONNECT,

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 and GPIO_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

Metadata

Metadata

Labels

area: RegulatorsbugThe issue is a bug, or the PR is fixing a bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions