[coreboot-gerrit] Change in coreboot[master]: google/gru: Fix GPIO_WP pull and polarity for Scarlet

Julius Werner (Code Review) gerrit at coreboot.org
Thu Feb 15 03:03:34 CET 2018


Hello Lin Huang, David Schneider, Philip Chen,

I'd like you to do a code review. Please visit

    https://review.coreboot.org/23767

to review the following change.


Change subject: google/gru: Fix GPIO_WP pull and polarity for Scarlet
......................................................................

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 <jwerner at chromium.org>
---
M src/mainboard/google/gru/chromeos.c
1 file changed, 10 insertions(+), 3 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/67/23767/1

diff --git a/src/mainboard/google/gru/chromeos.c b/src/mainboard/google/gru/chromeos.c
index ff5368a..55da879 100644
--- a/src/mainboard/google/gru/chromeos.c
+++ b/src/mainboard/google/gru/chromeos.c
@@ -21,15 +21,19 @@
 
 #include "board.h"
 
+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 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);
 }

-- 
To view, visit https://review.coreboot.org/23767
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd348ecdf9da8fff7201b83e869ba097b8570f32
Gerrit-Change-Number: 23767
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner at chromium.org>
Gerrit-Reviewer: David Schneider <dnschneid at chromium.org>
Gerrit-Reviewer: Lin Huang <hl at rock-chips.com>
Gerrit-Reviewer: Philip Chen <philipchen at chromium.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180215/135fcf3e/attachment-0001.html>


More information about the coreboot-gerrit mailing list