From 19eb488e290f1e76bfd7faa46e5222ab3d655bf8 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Wed, 16 Feb 2022 18:35:36 +0100 Subject: [PATCH] gpio: fix init for BH edition PinePhone BH PinePhone don't have the modem's `STATUS` pin connected to the SoC, and as such require using `libusb` for checking the modem power state. We didn't handle this case previously due to lack of on-device testing, causing BH phones to fail with newer versions. This patch ignores the `status` GPIO for devices relying on `libusb`, which are only pre-CE PinePhones. --- src/gpio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gpio.c b/src/gpio.c index 49bee0d..ad74f34 100644 --- a/src/gpio.c +++ b/src/gpio.c @@ -144,7 +144,7 @@ int gpio_init(struct EG25Manager *manager, toml_table_t *config[]) if (!gpio_config[EG25_CONFIG_SYS]) g_error("Default config file lacks the 'gpio' section!"); - /* + /* * The system config could have the `chips` key, but the user one * could still use the old format! In order to avoid problems, we * should use the new format only if: @@ -196,8 +196,13 @@ int gpio_init(struct EG25Manager *manager, toml_table_t *config[]) for (i = 0; i < GPIO_IN_COUNT; i++) { toml_table_t *table; toml_datum_t chip, line; - if (!config_get_table(gpio_config, gpio_in_names[i], &table)) + + if (!config_get_table(gpio_config, gpio_in_names[i], &table)) { + // BH edition don't have the STATUS line connected, ignore it + if (manager->use_libusb && g_strcmp0(gpio_in_names[i], "status") == 0) + continue; g_error("Unable to get config for input GPIO '%s'", gpio_in_names[i]); + } chip = toml_int_in(table, "chip"); if (!chip.ok || chip.u.i < 0 || chip.u.i > 2)