From 9ec6928b8c7bfdd3bed4eb233672e74f6914ebb6 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Wed, 14 Feb 2018 18:01:27 -0800 Subject: google/gru: Fix GPIO_WP pull and polarity for Scarlet Turns out the write-protect GPIO polarity for Scarlet is different than for Kevin/Gru, and nobody ever told us. Also, it must not be configured with an internal pull-up or we'll not read the correct value. This patch fixes both issues. BRANCH=scarlet BUG=b:73356326 TEST=Booted Scarlet, confirmed that crossystem wpsw_boot returns the right value in all cases. Change-Id: Idd348ecdf9da8fff7201b83e869ba097b8570f32 Signed-off-by: Julius Werner Reviewed-on: https://review.coreboot.org/23767 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Paul Menzel --- src/mainboard/google/gru/chromeos.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/mainboard/google/gru') diff --git a/src/mainboard/google/gru/chromeos.c b/src/mainboard/google/gru/chromeos.c index ff5368a65c..7fb47d0da8 100644 --- a/src/mainboard/google/gru/chromeos.c +++ b/src/mainboard/google/gru/chromeos.c @@ -21,15 +21,19 @@ #include "board.h" +static const uint32_t wp_polarity = IS_ENABLED(CONFIG_GRU_BASEBOARD_SCARLET) ? + ACTIVE_LOW : ACTIVE_HIGH; + int get_write_protect_state(void) { - return gpio_get(GPIO_WP); + int raw = gpio_get(GPIO_WP); + return wp_polarity == ACTIVE_HIGH ? raw : !raw; } void fill_lb_gpios(struct lb_gpios *gpios) { struct lb_gpio chromeos_gpios[] = { - {GPIO_WP.raw, ACTIVE_HIGH, get_write_protect_state(), + {GPIO_WP.raw, wp_polarity, gpio_get(GPIO_WP), "write protect"}, {-1, ACTIVE_HIGH, get_recovery_mode_switch(), "recovery"}, #if IS_ENABLED(CONFIG_GRU_BASEBOARD_SCARLET) @@ -49,7 +53,10 @@ void fill_lb_gpios(struct lb_gpios *gpios) void setup_chromeos_gpios(void) { - gpio_input_pullup(GPIO_WP); + if (IS_ENABLED(CONFIG_GRU_BASEBOARD_SCARLET)) + gpio_input(GPIO_WP); + else + gpio_input_pullup(GPIO_WP); gpio_input_pullup(GPIO_EC_IN_RW); gpio_input_pullup(GPIO_EC_IRQ); } -- cgit v1.2.3