From d02cc2c9611dbd27a67fbcad7bf6cb2880f49575 Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Tue, 31 Jul 2012 17:30:19 +0800 Subject: Snow has write protect pin (PB4) wired to EC. Intend to keep fake_wp functions for test. BUG=chrome-os-partner:9986 TEST=build only (success on link/snow/daisy/bds). Have no hardware to test. Change-Id: I1e2ae923790d65b6c95819f5274dbe8c7f254429 Signed-off-by: Louis Yung-Chieh Lo Reviewed-on: https://gerrit.chromium.org/gerrit/28793 Commit-Ready: Yung-Chieh Lo Tested-by: Yung-Chieh Lo Reviewed-by: Randall Spangler --- board/snow/board.c | 2 +- board/snow/board.h | 8 +------- chip/stm32/flash-stm32f100.c | 4 ++-- chip/stm32/system.c | 2 ++ common/system_common.c | 6 +++--- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/board/snow/board.c b/board/snow/board.c index b3fa050ecf..d32150329a 100644 --- a/board/snow/board.c +++ b/board/snow/board.c @@ -43,6 +43,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = { {"CHARGER_INT", GPIO_C, (1<<4), GPIO_INT_RISING, NULL}, {"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_RISING, gaia_lid_event}, {"SUSPEND_L", GPIO_A, (1<<7), GPIO_INT_BOTH, gaia_suspend_event}, + {"WP_L", GPIO_B, (1<<4), GPIO_INPUT, NULL}, {"KB_IN00", GPIO_C, (1<<8), GPIO_KB_INPUT, matrix_interrupt}, {"KB_IN01", GPIO_C, (1<<9), GPIO_KB_INPUT, matrix_interrupt}, {"KB_IN02", GPIO_C, (1<<10), GPIO_KB_INPUT, matrix_interrupt}, @@ -260,4 +261,3 @@ void board_pmu_init(void) } } #endif /* CONFIG_BOARD_PMU_INIT */ - diff --git a/board/snow/board.h b/board/snow/board.h index 983a20738e..5622fe0383 100644 --- a/board/snow/board.h +++ b/board/snow/board.h @@ -26,13 +26,6 @@ #define CONFIG_TASK_PROFILING #define CONFIG_WATCHDOG_HELP -/* Allow dangerous commands all the time, since we don't have a write protect - * switch. */ -/* TODO: (crosbug.com/p/9986) This is a serious security hole and should be - * removed in mass production. We add this to allow manual firmware update. - * Once we complete the vboot and autoupdate, we should remove this. */ -#define CONFIG_SYSTEM_UNLOCKED - #ifndef __ASSEMBLER__ /* By default, enable all console messages except keyboard */ @@ -64,6 +57,7 @@ enum gpio_signal { GPIO_CHARGER_INT, GPIO_LID_OPEN, /* LID switch detection */ GPIO_SUSPEND_L, /* AP suspend/resume state */ + GPIO_WRITE_PROTECTn, /* Write protection pin (low active) */ /* Keyboard inputs */ GPIO_KB_IN00, GPIO_KB_IN01, diff --git a/chip/stm32/flash-stm32f100.c b/chip/stm32/flash-stm32f100.c index 2b2ee4ca46..68f2268198 100644 --- a/chip/stm32/flash-stm32f100.c +++ b/chip/stm32/flash-stm32f100.c @@ -551,8 +551,7 @@ uint32_t flash_get_protect(void) int i; int not_protected[2] = {0}; - /* TODO (vpalatin) : write protect scheme for stm32 */ - if (system_get_fake_wp()) + if (system_get_fake_wp() || !gpio_get_level(GPIO_WRITE_PROTECTn)) flags |= EC_FLASH_PROTECT_GPIO_ASSERTED; /* Read the current persist state from flash */ @@ -613,6 +612,7 @@ int flash_set_protect(uint32_t mask, uint32_t flags) return retval; } +/* TODO: crosbug.com/p/12036 */ static int command_set_fake_wp(int argc, char **argv) { int val; diff --git a/chip/stm32/system.c b/chip/stm32/system.c index f8b00371f0..4bfecf0812 100644 --- a/chip/stm32/system.c +++ b/chip/stm32/system.c @@ -287,12 +287,14 @@ const char *system_get_chip_revision(void) } +/* TODO: crosbug.com/p/12036 */ int system_set_fake_wp(int val) { return bkpdata_write(BKPDATA_INDEX_FAKE_WP, (uint16_t)val); } +/* TODO: crosbug.com/p/12036 */ int system_get_fake_wp(void) { return bkpdata_read(BKPDATA_INDEX_FAKE_WP); diff --git a/common/system_common.c b/common/system_common.c index c9c6384975..4fe4c0c48e 100644 --- a/common/system_common.c +++ b/common/system_common.c @@ -90,10 +90,10 @@ int system_is_locked(void) /* System is explicitly unlocked */ return 0; -#elif defined(BOARD_link) && defined(CONFIG_FLASH) +#elif defined(CONFIG_FLASH) /* - * On link, unlocked if write protect pin deasserted or read-only - * firmware is not protected. + * Unlocked if write protect pin deasserted or read-only firmware + * is not protected. */ if ((EC_FLASH_PROTECT_GPIO_ASSERTED | EC_FLASH_PROTECT_RO_NOW) & ~flash_get_protect()) -- cgit v1.2.1