mirror of
https://gitlab.com/mobian1/eg25-manager.git
synced 2025-08-30 15:52:11 +02:00
improve poweroff sequence
When powering off the modem, we must assert the RESET line only when the modem has shut down (otherwise it'll cause a hard reset and won't allow the modem to shut down properly). This commit also polls the STATUS pin during poweroff and quits immediately once this pin goes high.
This commit is contained in:
18
src/gpio.c
18
src/gpio.c
@@ -64,11 +64,8 @@ int gpio_sequence_poweron(struct EG25Manager *manager)
|
||||
|
||||
int gpio_sequence_shutdown(struct EG25Manager *manager)
|
||||
{
|
||||
gpiod_line_set_value(manager->gpio_out[GPIO_OUT_RESET], 1);
|
||||
gpiod_line_set_value(manager->gpio_out[GPIO_OUT_DISABLE], 1);
|
||||
gpiod_line_set_value(manager->gpio_out[GPIO_OUT_PWRKEY], 1);
|
||||
sleep(1);
|
||||
gpiod_line_set_value(manager->gpio_out[GPIO_OUT_PWRKEY], 0);
|
||||
gpio_sequence_poweron(manager);
|
||||
|
||||
g_message("Executed power-off sequence");
|
||||
|
||||
@@ -175,6 +172,19 @@ int gpio_init(struct EG25Manager *manager)
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean gpio_check_poweroff(struct EG25Manager *manager)
|
||||
{
|
||||
if (manager->gpio_in[GPIO_IN_STATUS] &&
|
||||
gpiod_line_get_value(manager->gpio_in[GPIO_IN_STATUS]) == 1) {
|
||||
|
||||
// Asserting RESET line to prevent modem from rebooting
|
||||
gpiod_line_set_value(manager->gpio_out[GPIO_OUT_RESET], 1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void gpio_destroy(struct EG25Manager *manager)
|
||||
{
|
||||
int i;
|
||||
|
Reference in New Issue
Block a user