Zephyr GPIO write works but readback fails

My device tree overlay GPIO section looks like this:


Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/delete-node/ &led2; // GPIO 19 repurposed to be vout enable
/{
lm5176_control {
compatible = "gpio-leds";
enable1: enable_1 {
gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>;
label = "VOUT Enable Low";
};
};
aliases {
cmvoutenable = &enable1;
/delete-property/ led1; // This was GPIO 19
};
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Note that I repurposing a GPIO that was used for an LED in the board's device tree file. Also note that node numbers start from 1 and property numbers start from 0, so the delete-node and delete-property are both deleting the items for GPIO 19.

My runtime code looks like this:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define VOUT_ENABLE DT_ALIAS(cmvoutenable)
static const struct gpio_dt_spec vout_enable = GPIO_DT_SPEC_GET(VOUT_ENABLE, gpios);
#define PGOOD DT_ALIAS(cmpgood)
static const struct gpio_dt_spec pgood = GPIO_DT_SPEC_GET(PGOOD, gpios);
message_error_t lm5176_init( void ) {
message_error_t ret = MESSAGE_OK;
printk("Initializing LM5176 boost/buck\n");
if (!device_is_ready(vout_enable.port)) {
printk("VOUT GPIO enable not ready\n");
return GPIO_ERROR;
} else {
if( gpio_pin_configure_dt(&vout_enable, GPIO_OUTPUT_ACTIVE) < 0 ) {
printk("VOUT GPIO enable cannot be activated\n");
return GPIO_ERROR;
}
}
if (!device_is_ready(pgood.port)) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The gpio_pin_set_dt call is working perfectly - I can see the GPIO pin go high or low as expected.

But the gpio_pin_get_dt call always returns false, regardless of the state of the GPIO output.

I suspect this problem is because I'm configuring the GPIO as an output and then trying to read its state. In other words, I'd like to access the output register of the GPIO instead of creating a different variable to hold the last state I set. Is this possible?