Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59004 )
Change subject: google/deltaur,drallion,sarien: Refactor ChromeOS GPIOs ......................................................................
google/deltaur,drallion,sarien: Refactor ChromeOS GPIOs
Low-level GPIOs should not depend of late cros_gpios that should be guarded with CHROMEOS and implemented for the purpose of ACPI \OIPG package generation.
Change-Id: Ibe708330504bc819e312eddaf5dfe4016cda21a1 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/mainboard/google/deltaur/chromeos.c M src/mainboard/google/drallion/chromeos.c M src/mainboard/google/sarien/chromeos.c 3 files changed, 21 insertions(+), 66 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/04/59004/1
diff --git a/src/mainboard/google/deltaur/chromeos.c b/src/mainboard/google/deltaur/chromeos.c index 9fdbe77..7ed2dbc 100644 --- a/src/mainboard/google/deltaur/chromeos.c +++ b/src/mainboard/google/deltaur/chromeos.c @@ -33,24 +33,14 @@ lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); }
-static int cros_get_gpio_value(int type) +int get_write_protect_state(void) { - const struct cros_gpio *cros_gpios; - size_t i, num_gpios = 0; + return gpio_get(GPIO_PCH_WP); +}
- cros_gpios = variant_cros_gpios(&num_gpios); - - for (i = 0; i < num_gpios; i++) { - const struct cros_gpio *gpio = &cros_gpios[i]; - if (gpio->type == type) { - int state = gpio_get(gpio->gpio_num); - if (gpio->polarity == CROS_GPIO_ACTIVE_LOW) - return !state; - else - return state; - } - } - return 0; +static bool raw_get_recovery_mode_switch(void) +{ + return !gpio_get(GPIO_REC_MODE); }
void mainboard_chromeos_acpi_generate(void) @@ -63,11 +53,6 @@ chromeos_acpi_gpio_generate(cros_gpios, num_gpios); }
-int get_write_protect_state(void) -{ - return cros_get_gpio_value(CROS_GPIO_WP); -} - int get_recovery_mode_switch(void) { static enum rec_mode_state saved_rec_mode = REC_MODE_UNINITIALIZED; @@ -93,7 +78,7 @@ state = REC_MODE_REQUESTED;
/* Read state from the GPIO controlled by servo. */ - if (cros_get_gpio_value(CROS_GPIO_REC)) + if (raw_get_recovery_mode_switch()) state = REC_MODE_REQUESTED;
/* Store the state in case this is called again in verstage. */ diff --git a/src/mainboard/google/drallion/chromeos.c b/src/mainboard/google/drallion/chromeos.c index c1db7e5..2ab1d6f 100644 --- a/src/mainboard/google/drallion/chromeos.c +++ b/src/mainboard/google/drallion/chromeos.c @@ -31,24 +31,14 @@ lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); }
-static int cros_get_gpio_value(int type) +int get_write_protect_state(void) { - const struct cros_gpio *cros_gpios; - size_t i, num_gpios = 0; + return gpio_get(GPP_E15); +}
- cros_gpios = variant_cros_gpios(&num_gpios); - - for (i = 0; i < num_gpios; i++) { - const struct cros_gpio *gpio = &cros_gpios[i]; - if (gpio->type == type) { - int state = gpio_get(gpio->gpio_num); - if (gpio->polarity == CROS_GPIO_ACTIVE_LOW) - return !state; - else - return state; - } - } - return 0; +static bool raw_get_recovery_mode_switch(void) +{ + return !gpio_get(GPP_E8); }
void mainboard_chromeos_acpi_generate(void) @@ -61,11 +51,6 @@ chromeos_acpi_gpio_generate(cros_gpios, num_gpios); }
-int get_write_protect_state(void) -{ - return cros_get_gpio_value(CROS_GPIO_WP); -} - int get_recovery_mode_switch(void) { static enum rec_mode_state saved_rec_mode = REC_MODE_UNINITIALIZED; @@ -91,7 +76,7 @@ state = REC_MODE_REQUESTED;
/* Read state from the GPIO controlled by servo. */ - if (cros_get_gpio_value(CROS_GPIO_REC)) + if (raw_get_recovery_mode_switch()) state = REC_MODE_REQUESTED;
/* Store the state in case this is called again in verstage. */ diff --git a/src/mainboard/google/sarien/chromeos.c b/src/mainboard/google/sarien/chromeos.c index e1b9635..2acfbd0 100644 --- a/src/mainboard/google/sarien/chromeos.c +++ b/src/mainboard/google/sarien/chromeos.c @@ -29,24 +29,14 @@ lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); }
-static int cros_get_gpio_value(int type) +int get_write_protect_state(void) { - const struct cros_gpio *cros_gpios; - size_t i, num_gpios = 0; + return gpio_get(GPP_E15); +}
- cros_gpios = variant_cros_gpios(&num_gpios); - - for (i = 0; i < num_gpios; i++) { - const struct cros_gpio *gpio = &cros_gpios[i]; - if (gpio->type == type) { - int state = gpio_get(gpio->gpio_num); - if (gpio->polarity == CROS_GPIO_ACTIVE_LOW) - return !state; - else - return state; - } - } - return 0; +static bool raw_get_recovery_mode_switch(void) +{ + return !gpio_get(GPP_E8); }
void mainboard_chromeos_acpi_generate(void) @@ -59,11 +49,6 @@ chromeos_acpi_gpio_generate(cros_gpios, num_gpios); }
-int get_write_protect_state(void) -{ - return cros_get_gpio_value(CROS_GPIO_WP); -} - int get_recovery_mode_switch(void) { static enum rec_mode_state saved_rec_mode = REC_MODE_UNINITIALIZED; @@ -89,7 +74,7 @@ state = REC_MODE_REQUESTED;
/* Read state from the GPIO controlled by servo. */ - if (cros_get_gpio_value(CROS_GPIO_REC)) + if (raw_get_recovery_mode_switch()) state = REC_MODE_REQUESTED;
/* Store the state in case this is called again in verstage. */