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