From ef213ce62df85749d159547d0282b9519a4e111a Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Thu, 20 Jul 2017 09:51:11 -0700 Subject: [PATCH] cr50: introduce means of detecting chip running in factory mode When installed in the factory test rig, the DIOB4 pin is set to high by the moment the RW section starts. Software behavior needs to change to comply with the factory test rig requirements. Define the GPIO and add a function to report the factory mode state. BRANCH=cr50 BUG=b:63686091 TEST=tested along with the rest of the stack of patches. Change-Id: I8c4158fc75138d717fc009496365c8e61b42a890 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/579584 Reviewed-by: Nick Sanders --- board/cr50/board.c | 14 ++++++++++++++ board/cr50/board.h | 3 +++ board/cr50/gpio.inc | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/board/cr50/board.c b/board/cr50/board.c index 43597dcb5d..24e0023cea 100644 --- a/board/cr50/board.c +++ b/board/cr50/board.c @@ -1641,3 +1641,17 @@ static int command_board_properties(int argc, char **argv) } DECLARE_SAFE_CONSOLE_COMMAND(brdprop, command_board_properties, NULL, "Display board properties"); + +int chip_factory_mode(void) +{ + static uint8_t mode_set; + + /* + * Bit 0x2 used to indicate that mode has been set, bit 0x1 is the + * actual indicator of the chip factory mode. + */ + if (!mode_set) + mode_set = 2 | !!gpio_get_level(GPIO_DIOB4); + + return mode_set & 1; +} diff --git a/board/cr50/board.h b/board/cr50/board.h index c6bc33987c..5b1b541653 100644 --- a/board/cr50/board.h +++ b/board/cr50/board.h @@ -222,6 +222,9 @@ void board_reboot_ap(void); int board_wipe_tpm(void); int board_is_first_factory_boot(void); +/* Returns True if chip is brought up in a factory test harness. */ +int chip_factory_mode(void); + #endif /* !__ASSEMBLER__ */ /* USB interface indexes (use define rather than enum to expand them) */ diff --git a/board/cr50/gpio.inc b/board/cr50/gpio.inc index fc86447de5..e47f06fabb 100644 --- a/board/cr50/gpio.inc +++ b/board/cr50/gpio.inc @@ -91,6 +91,9 @@ GPIO(SPI_MOSI, PIN(0, 7), GPIO_INPUT) GPIO(SPI_CLK, PIN(0, 8), GPIO_INPUT) GPIO(SPI_CS_L, PIN(0, 9), GPIO_INPUT) +/* Used during *chip* factory process. */ +GPIO(DIOB4, PIN(0, 10), GPIO_INPUT | GPIO_PULL_DOWN) + /* GPIOs used for Cr50 strapping options */ GPIO(STRAP_A0, PIN(1, 12), GPIO_INPUT) GPIO(STRAP_A1, PIN(1, 13), GPIO_INPUT) @@ -190,4 +193,8 @@ PINMUX(GPIO(DETECT_SERVO), B5, DIO_INPUT) PINMUX(GPIO(SPI_MOSI), A4, DIO_OUTPUT) PINMUX(GPIO(SPI_CLK), A8, DIO_OUTPUT) PINMUX(GPIO(SPI_CS_L), A14, DIO_OUTPUT) + +PINMUX(GPIO(DIOB4), B4, DIO_INPUT) + + #undef PINMUX