diff options
author | Mary Ruthven <mruthven@chromium.org> | 2021-11-09 17:05:05 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-18 04:51:06 +0000 |
commit | 5402eb74eaec24a351e66ee6e2898db17c489923 (patch) | |
tree | 325edd1dd82c94f1db0a9f238f3065dd44313696 | |
parent | 431b1b6b8fe1162a889237b5b511400d5932e1ff (diff) | |
download | chrome-ec-5402eb74eaec24a351e66ee6e2898db17c489923.tar.gz |
Revert "system: update board version to return an error if encountered"
This reverts commit ff9248fbaabef72761728140c2e65d0aa02dc17c.
BUG=b:200823466
TEST=make buildall -j
Change-Id: I22ffe8ff8bc88e88c21c285ed0cc3bed432d6463
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3273428
Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
-rw-r--r-- | common/cbi.c | 12 | ||||
-rw-r--r-- | common/system.c | 55 | ||||
-rw-r--r-- | include/config.h | 30 |
3 files changed, 31 insertions, 66 deletions
diff --git a/common/cbi.c b/common/cbi.c index f29ae2040c..ddeb41fd22 100644 --- a/common/cbi.c +++ b/common/cbi.c @@ -282,6 +282,18 @@ int cbi_get_model_id(uint32_t *id) uint8_t size = sizeof(*id); return cbi_get_board_info(CBI_TAG_MODEL_ID, (uint8_t *)id, &size); } +/* + * For backward compatibility. New code should use cbi_get_board_version. + */ +int board_get_version(void) +{ + uint32_t ver; + uint8_t size = sizeof(ver); + + if (cbi_get_board_info(CBI_TAG_BOARD_VERSION, (uint8_t *)&ver, &size)) + return -1; + return ver; +} static enum ec_status hc_cbi_get(struct host_cmd_handler_args *args) { diff --git a/common/system.c b/common/system.c index 00d2c0af23..b26d35e1d2 100644 --- a/common/system.c +++ b/common/system.c @@ -8,7 +8,6 @@ #include "common.h" #include "console.h" #include "cpu.h" -#include "cros_board_info.h" #include "dma.h" #include "flash.h" #include "gpio.h" @@ -728,32 +727,24 @@ int system_get_image_used(enum system_image_copy_t copy) return data ? MAX((int)data->size, 0) : 0; } -/* - * Returns positive board version if successfully retrieved. Otherwise the - * value is a negative version of an EC return code. Without this optimization - * multiple boards run out of flash size. - */ int system_get_board_version(void) { -#if defined(CONFIG_BOARD_VERSION_CUSTOM) - return board_get_version(); -#elif defined(CONFIG_BOARD_VERSION_GPIO) - return - (!!gpio_get_level(GPIO_BOARD_VERSION1) << 0) | - (!!gpio_get_level(GPIO_BOARD_VERSION2) << 1) | - (!!gpio_get_level(GPIO_BOARD_VERSION3) << 2); -#elif defined(CONFIG_BOARD_VERSION_CBI) - int error; - int32_t version; - - error = cbi_get_board_version(&version); - if (error) - return -error; - else - return version; + int v = 0; + +#ifdef CONFIG_BOARD_VERSION +#ifdef CONFIG_BOARD_SPECIFIC_VERSION + v = board_get_version(); #else - return 0; + if (gpio_get_level(GPIO_BOARD_VERSION1)) + v |= 0x01; + if (gpio_get_level(GPIO_BOARD_VERSION2)) + v |= 0x02; + if (gpio_get_level(GPIO_BOARD_VERSION3)) + v |= 0x04; +#endif #endif + + return v; } __attribute__((weak)) /* Weird chips may need their own implementations */ @@ -1060,17 +1051,9 @@ static void print_build_string(void) static int command_version(int argc, char **argv) { - int board_version; - ccprintf("Chip: %s %s %s\n", system_get_chip_vendor(), system_get_chip_name(), system_get_chip_revision()); - - board_version = system_get_board_version(); - if (board_version < 0) - ccprintf("Board: Error %d\n", -board_version); - else - ccprintf("Board: %d\n", board_version); - + ccprintf("Board: %d\n", system_get_board_version()); #ifdef CHIP_HAS_RO_B { enum system_image_copy_t active; @@ -1387,15 +1370,9 @@ enum ec_status host_command_get_board_version(struct host_cmd_handler_args *args) { struct ec_response_board_version *r = args->response; - int board_version; - board_version = system_get_board_version(); - if (board_version < 0) { - CPRINTS("Failed (%d) getting board version", -board_version); - return EC_RES_ERROR; - } + r->board_version = (uint16_t) system_get_board_version(); - r->board_version = board_version; args->response_size = sizeof(*r); return EC_RES_SUCCESS; diff --git a/include/config.h b/include/config.h index db6186d47b..651b643ede 100644 --- a/include/config.h +++ b/include/config.h @@ -575,21 +575,10 @@ */ #undef CONFIG_BOARD_PRE_INIT -/* - * EC has the notion of board version either through resistors or EEPROM. - * The common CONFIG_BOARD_VERSION is defined automatically when one of the - * specific options is used. - */ +/* EC has GPIOs attached to board version stuffing resistors */ #undef CONFIG_BOARD_VERSION -/* The board version comes from Cros Board Info within EEPROM. */ -#undef CONFIG_BOARD_VERSION_CBI -/* The board version function is defined in board code. */ -#undef CONFIG_BOARD_VERSION_CUSTOM -/* - * The board version is encoded with 3 GPIO signals where GPIO_BOARD_VERSION1 - * is the LSB. - */ -#undef CONFIG_BOARD_VERSION_GPIO +/* The decoding of the GPIOs defining board version is defined in board code */ +#undef CONFIG_BOARD_SPECIFIC_VERSION /* * The board is unable to distinguish EC reset from power-on so it should treat @@ -4324,19 +4313,6 @@ #define CONFIG_CRC8 #endif /* defined(CONFIG_EXPERIMENTAL_CONSOLE) */ - -/******************************************************************************/ -/* - * Automatically define common CONFIG_BOARD_VERSION if any specific option is - * used. - */ - -#if defined(CONFIG_BOARD_VERSION_CBI) || \ - defined(CONFIG_BOARD_VERSION_CUSTOM) || \ - defined(CONFIG_BOARD_VERSION_GPIO) -#define CONFIG_BOARD_VERSION -#endif - /******************************************************************************/ /* * Thermal throttling AP must have temperature sensor enabled to get |