diff options
Diffstat (limited to 'op-pwrctl/power_control_obj.c')
-rw-r--r-- | op-pwrctl/power_control_obj.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/op-pwrctl/power_control_obj.c b/op-pwrctl/power_control_obj.c index cd13c68..679493c 100644 --- a/op-pwrctl/power_control_obj.c +++ b/op-pwrctl/power_control_obj.c @@ -208,6 +208,12 @@ set_up_gpio(GDBusConnection *connection, uint8_t pgood_state; // get gpio device paths + if(power_gpio->latch_out.name != NULL) { /* latch is optional */ + rc = gpio_init(connection, &power_gpio->latch_out); + if(rc != GPIO_OK) { + error = rc; + } + } rc = gpio_init(connection, &power_gpio->power_good_in); if(rc != GPIO_OK) { error = rc; @@ -225,6 +231,26 @@ set_up_gpio(GDBusConnection *connection, } } + /* If there's a latch, it only needs to be set once. */ + if(power_gpio->latch_out.name != NULL) { + do { + rc = gpio_open(&power_gpio->latch_out); + if(rc != GPIO_OK) { + /* Failures are non-fatal. */ + break; + } + rc = gpio_write(&power_gpio->latch_out, 1); + gpio_close(&power_gpio->latch_out); + } while(0); + if (rc != GPIO_OK) { + error = rc; + g_print("PowerControl ERROR failed to assert latch %s rc=%d\n", + power_gpio->latch_out.name, rc); + } else { + g_print("PowerControl asserted latch %s\n", power_gpio->latch_out.name); + } + } + rc = gpio_open(&power_gpio->power_good_in); if(rc != GPIO_OK) { return rc; |