summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/atlas/board.h3
-rw-r--r--board/chell/board.h2
-rw-r--r--board/coral/board.h3
-rw-r--r--board/elm/board.h2
-rw-r--r--board/eve/board.h3
-rw-r--r--board/fizz/board.h4
-rw-r--r--board/glados/board.h2
-rw-r--r--board/glkrvp/board.h3
-rw-r--r--board/glkrvp_ite/board.h3
-rw-r--r--board/grunt/board.h2
-rw-r--r--board/it83xx_evb/board.h2
-rw-r--r--board/kahlee/board.h3
-rw-r--r--board/kevin/board.h3
-rw-r--r--board/mchpevb1/board.h2
-rw-r--r--board/nami/board.h4
-rw-r--r--board/nautilus/board.h3
-rw-r--r--board/npcx7_evb/board.h2
-rw-r--r--board/npcx_evb/board.h2
-rw-r--r--board/npcx_evb_arm/board.h2
-rw-r--r--board/oak/board.h2
-rw-r--r--board/poppy/board.h3
-rw-r--r--board/rainier/board.h3
-rw-r--r--board/reef/board.h3
-rw-r--r--board/reef_it8320/board.h3
-rw-r--r--board/samus/board.h2
-rw-r--r--board/scarlet/board.h3
-rw-r--r--board/servo_v4/board.h3
-rw-r--r--board/strago/board.h2
-rw-r--r--board/wheatley/board.h2
-rw-r--r--board/yorp/board.h3
-rw-r--r--board/zoombini/board.h8
-rw-r--r--common/cbi.c12
-rw-r--r--common/system.c55
-rw-r--r--include/config.h30
34 files changed, 102 insertions, 82 deletions
diff --git a/board/atlas/board.h b/board/atlas/board.h
index 1ef45910c8..b381333a9e 100644
--- a/board/atlas/board.h
+++ b/board/atlas/board.h
@@ -25,8 +25,7 @@
/* EC */
#define CONFIG_ADC
#define CONFIG_BACKLIGHT_LID
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_BOARD_FORCE_RESET_PIN
#define CONFIG_DPTF
#define CONFIG_FPU
diff --git a/board/chell/board.h b/board/chell/board.h
index ada855b016..ae5c4dc17f 100644
--- a/board/chell/board.h
+++ b/board/chell/board.h
@@ -20,7 +20,7 @@
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L
#define CONFIG_BATTERY_SMART
#define CONFIG_BOARD_HAS_RTC_RESET
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGE_RAMP_HW
diff --git a/board/coral/board.h b/board/coral/board.h
index 208bacdfb8..d063e6131f 100644
--- a/board/coral/board.h
+++ b/board/coral/board.h
@@ -114,8 +114,7 @@
/* EC */
#define CONFIG_ADC
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_EXTPOWER_GPIO
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
diff --git a/board/elm/board.h b/board/elm/board.h
index f066dfc67c..d07094b1d9 100644
--- a/board/elm/board.h
+++ b/board/elm/board.h
@@ -74,7 +74,7 @@
#define CONFIG_VBOOT_HASH
#undef CONFIG_WATCHDOG_HELP
#define CONFIG_SWITCH
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#undef CONFIG_UART_CONSOLE
#define CONFIG_UART_CONSOLE 1
#define CONFIG_TEMP_SENSOR
diff --git a/board/eve/board.h b/board/eve/board.h
index e8fa791505..727986e7c1 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -25,8 +25,7 @@
/* EC */
#define CONFIG_ADC
#define CONFIG_BACKLIGHT_LID
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_BOARD_FORCE_RESET_PIN
#define CONFIG_DEVICE_EVENT
#define CONFIG_DPTF
diff --git a/board/fizz/board.h b/board/fizz/board.h
index 464b517db8..b4ed5a19ae 100644
--- a/board/fizz/board.h
+++ b/board/fizz/board.h
@@ -17,8 +17,7 @@
/* EC */
#define CONFIG_ADC
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CBI
#define CONFIG_CRC8
#define CONFIG_CROS_BOARD_INFO
#define CONFIG_DEDICATED_RECOVERY_BUTTON
@@ -239,7 +238,6 @@ enum mft_channel {
#define PD_MAX_VOLTAGE_MV 20000
/* Board specific handlers */
-int board_get_version(void);
void board_reset_pd_mcu(void);
void board_set_tcpc_power_mode(int port, int mode);
int board_get_battery_soc(void);
diff --git a/board/glados/board.h b/board/glados/board.h
index cec7d50abd..605551fea6 100644
--- a/board/glados/board.h
+++ b/board/glados/board.h
@@ -22,7 +22,7 @@
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L
#define CONFIG_BATTERY_SMART
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGE_RAMP_HW
diff --git a/board/glkrvp/board.h b/board/glkrvp/board.h
index 2236285087..91ac5c2c45 100644
--- a/board/glkrvp/board.h
+++ b/board/glkrvp/board.h
@@ -86,8 +86,7 @@
#define CONFIG_POWER_TRACK_HOST_SLEEP_STATE
/* EC */
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_VOLUME_BUTTONS
#define GPIO_VOLUME_UP_L GPIO_EC_VOLUP_BTN_ODL
#define GPIO_VOLUME_DOWN_L GPIO_EC_VOLDN_BTN_ODL
diff --git a/board/glkrvp_ite/board.h b/board/glkrvp_ite/board.h
index d21b6c4cdb..802b9beefe 100644
--- a/board/glkrvp_ite/board.h
+++ b/board/glkrvp_ite/board.h
@@ -86,8 +86,7 @@
#define CONFIG_POWER_TRACK_HOST_SLEEP_STATE
/* EC */
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_VOLUME_BUTTONS
#define CONFIG_LID_SWITCH
#define CONFIG_WP_ALWAYS
diff --git a/board/grunt/board.h b/board/grunt/board.h
index 98fcc9823b..10ad79bbfd 100644
--- a/board/grunt/board.h
+++ b/board/grunt/board.h
@@ -33,7 +33,7 @@
#define CONFIG_ADC
#define CONFIG_BACKLIGHT_LID
#define CONFIG_BACKLIGHT_LID_ACTIVE_LOW
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#define CONFIG_HOSTCMD_SKUID
#define CONFIG_I2C
#define CONFIG_I2C_MASTER
diff --git a/board/it83xx_evb/board.h b/board/it83xx_evb/board.h
index 234d9fd5bc..8da6cf79d0 100644
--- a/board/it83xx_evb/board.h
+++ b/board/it83xx_evb/board.h
@@ -13,7 +13,7 @@
/* Optional features */
#define CONFIG_BATTERY_SMART
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#define CONFIG_FANS 1
#define CONFIG_I2C
#define CONFIG_I2C_MASTER
diff --git a/board/kahlee/board.h b/board/kahlee/board.h
index 224299768b..d77b89bb29 100644
--- a/board/kahlee/board.h
+++ b/board/kahlee/board.h
@@ -93,8 +93,7 @@
/* EC */
#define CONFIG_ADC
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_EXTPOWER_GPIO
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
diff --git a/board/kevin/board.h b/board/kevin/board.h
index 39c4c24f28..221a5de29b 100644
--- a/board/kevin/board.h
+++ b/board/kevin/board.h
@@ -48,8 +48,7 @@
#define CONFIG_RAM_SIZE (CONFIG_DATA_RAM_SIZE - 0x800)
/* Optional features */
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_FLASH_SIZE 0x00080000 /* 512KB spi flash */
#define CONFIG_HOST_COMMAND_STATUS
#define CONFIG_HOSTCMD_SECTION_SORTED /* Host commands are sorted. */
diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h
index 529bc5e35a..679bd3b44f 100644
--- a/board/mchpevb1/board.h
+++ b/board/mchpevb1/board.h
@@ -143,7 +143,7 @@
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L
#define CONFIG_BATTERY_SMART
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#define CONFIG_BUTTON_COUNT 2
/* #define CONFIG_CHARGE_MANAGER */
/* #define CONFIG_CHARGE_RAMP_SW */
diff --git a/board/nami/board.h b/board/nami/board.h
index 63481f315a..f086fbd109 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -18,8 +18,7 @@
#define CONFIG_ADC
#define CONFIG_BACKLIGHT_LID
#define CONFIG_BACKLIGHT_LID_ACTIVE_LOW
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CBI
#define CONFIG_BOARD_FORCE_RESET_PIN
#define CONFIG_CRC8
#define CONFIG_CROS_BOARD_INFO
@@ -282,7 +281,6 @@ enum oem_id {
#define PD_MAX_VOLTAGE_MV 20000
/* Board specific handlers */
-int board_get_version(void);
void board_reset_pd_mcu(void);
void board_set_tcpc_power_mode(int port, int mode);
diff --git a/board/nautilus/board.h b/board/nautilus/board.h
index d516cde646..2b8f7e71e8 100644
--- a/board/nautilus/board.h
+++ b/board/nautilus/board.h
@@ -17,8 +17,7 @@
/* EC */
#define CONFIG_ADC
#define CONFIG_BACKLIGHT_LID
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_BOARD_FORCE_RESET_PIN
#define CONFIG_CASE_CLOSED_DEBUG_EXTERNAL
#define CONFIG_DPTF
diff --git a/board/npcx7_evb/board.h b/board/npcx7_evb/board.h
index 4370cf5fbb..2449b07636 100644
--- a/board/npcx7_evb/board.h
+++ b/board/npcx7_evb/board.h
@@ -26,7 +26,7 @@
#define CONFIG_ESPI_VW_SIGNALS /* Use VW signals instead of GPIOs */
/* Optional features */
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_I2C_MASTER
#define CONFIG_KEYBOARD_BOARD_CONFIG
diff --git a/board/npcx_evb/board.h b/board/npcx_evb/board.h
index 8c26e48e4c..b5dab2a370 100644
--- a/board/npcx_evb/board.h
+++ b/board/npcx_evb/board.h
@@ -29,7 +29,7 @@
#define CONFIG_POWER_BUTTON
#define CONFIG_VBOOT_HASH
#define CONFIG_PWM_KBLIGHT
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
/* Optional features for test commands */
#define CONFIG_CMD_TASKREADY
diff --git a/board/npcx_evb_arm/board.h b/board/npcx_evb_arm/board.h
index ee6a691e1c..c6c09b1c58 100644
--- a/board/npcx_evb_arm/board.h
+++ b/board/npcx_evb_arm/board.h
@@ -25,7 +25,7 @@
#define CONFIG_POWER_BUTTON
#define CONFIG_VBOOT_HASH
#define CONFIG_PWM_KBLIGHT
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
/* Optional features for test commands */
#define CONFIG_CMD_TASKREADY
diff --git a/board/oak/board.h b/board/oak/board.h
index f7324effe1..3bba4a1f44 100644
--- a/board/oak/board.h
+++ b/board/oak/board.h
@@ -105,7 +105,7 @@
#define CONFIG_VBOOT_HASH
#undef CONFIG_WATCHDOG_HELP
#define CONFIG_SWITCH
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#undef CONFIG_UART_CONSOLE
#define CONFIG_UART_CONSOLE 1
#define CONFIG_TEMP_SENSOR
diff --git a/board/poppy/board.h b/board/poppy/board.h
index fbdf6e86e3..033e6388e4 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -17,8 +17,7 @@
/* EC */
#define CONFIG_ADC
#define CONFIG_BACKLIGHT_LID
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_BOARD_FORCE_RESET_PIN
#define CONFIG_BUTTON_TRIGGERED_RECOVERY
#define CONFIG_DPTF
diff --git a/board/rainier/board.h b/board/rainier/board.h
index 833352482d..ff2a5b26d6 100644
--- a/board/rainier/board.h
+++ b/board/rainier/board.h
@@ -41,8 +41,7 @@
/* Optional features */
#define CONFIG_BOARD_PRE_INIT
-#define CONFIG_BOARD_SPECIFIC_VERSION
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_BUTTON_TRIGGERED_RECOVERY
#define CONFIG_CHARGER_ILIM_PIN_DISABLED
#define CONFIG_FORCE_CONSOLE_RESUME
diff --git a/board/reef/board.h b/board/reef/board.h
index d9dfb78e92..a3060be05f 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -112,8 +112,7 @@
/* EC */
#define CONFIG_ADC
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_EXTPOWER_GPIO
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
diff --git a/board/reef_it8320/board.h b/board/reef_it8320/board.h
index 879130f4c3..262a831b16 100644
--- a/board/reef_it8320/board.h
+++ b/board/reef_it8320/board.h
@@ -97,8 +97,7 @@
/* EC */
#define CONFIG_ADC
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_EXTPOWER_GPIO
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
diff --git a/board/samus/board.h b/board/samus/board.h
index f21f8a874f..1e0b73179e 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -19,7 +19,7 @@
#define CONFIG_ACCEL_KXCJ9
#define CONFIG_ACCEL_STD_REF_FRAME_OLD
#define CONFIG_ALS_ISL29035
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO
#undef CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT
diff --git a/board/scarlet/board.h b/board/scarlet/board.h
index d7fe301b60..653b6513fc 100644
--- a/board/scarlet/board.h
+++ b/board/scarlet/board.h
@@ -46,8 +46,7 @@
/* Optional features */
#define CONFIG_BOARD_PRE_INIT
-#define CONFIG_BOARD_SPECIFIC_VERSION
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
#define CONFIG_BUTTON_TRIGGERED_RECOVERY
#define CONFIG_CHARGER_ILIM_PIN_DISABLED
#define CONFIG_FORCE_CONSOLE_RESUME
diff --git a/board/servo_v4/board.h b/board/servo_v4/board.h
index f28c2f8902..65206dd772 100644
--- a/board/servo_v4/board.h
+++ b/board/servo_v4/board.h
@@ -15,8 +15,7 @@
* id from previous versions.
*/
#define BOARD_VERSION_BLACK 3
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
/* 48 MHz SYSCLK clock frequency */
#define CPU_CLOCK 48000000
diff --git a/board/strago/board.h b/board/strago/board.h
index b7faf53a12..64721ca95f 100644
--- a/board/strago/board.h
+++ b/board/strago/board.h
@@ -15,7 +15,7 @@
#define CONFIG_CHIPSET_BRASWELL
#define CONFIG_SCI_GPIO GPIO_PCH_SCI_L
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#define CONFIG_KEYBOARD_COL2_INVERTED
#define CONFIG_KEYBOARD_IRQ_GPIO GPIO_KBD_IRQ_L
diff --git a/board/wheatley/board.h b/board/wheatley/board.h
index 1dbe7a2376..ce4dfbdef1 100644
--- a/board/wheatley/board.h
+++ b/board/wheatley/board.h
@@ -16,7 +16,7 @@
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L
#define CONFIG_BATTERY_SMART
-#define CONFIG_BOARD_VERSION
+#define CONFIG_BOARD_VERSION_GPIO
#define CONFIG_CHARGE_MANAGER
#define CONFIG_BOARD_FORCE_RESET_PIN
diff --git a/board/yorp/board.h b/board/yorp/board.h
index be23cb116e..91605a6dfb 100644
--- a/board/yorp/board.h
+++ b/board/yorp/board.h
@@ -30,8 +30,7 @@
#define CONFIG_VBOOT_HASH
#define CONFIG_VSTORE
#define CONFIG_VSTORE_SLOT_COUNT 1
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CBI
#define CONFIG_CRC8
#define CONFIG_CROS_BOARD_INFO
/* Keyboard */
diff --git a/board/zoombini/board.h b/board/zoombini/board.h
index 4ed61302d6..aae8270f7d 100644
--- a/board/zoombini/board.h
+++ b/board/zoombini/board.h
@@ -75,9 +75,13 @@
#define CONFIG_BATTERY_REVIVE_DISCONNECT
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L
-#define CONFIG_BOARD_VERSION
#ifdef BOARD_MEOWTH
-#define CONFIG_BOARD_SPECIFIC_VERSION
+#define CONFIG_BOARD_VERSION_CUSTOM
+#else
+#define CONFIG_BOARD_VERSION_GPIO
+#endif
+
+#ifdef BOARD_MEOWTH
#define CONFIG_BUTTON_TRIGGERED_RECOVERY
#endif /* defined(BOARD_MEOWTH) */
diff --git a/common/cbi.c b/common/cbi.c
index c1063c6476..584a6e8415 100644
--- a/common/cbi.c
+++ b/common/cbi.c
@@ -241,18 +241,6 @@ int cbi_get_oem_id(uint32_t *id)
return cbi_get_board_info(CBI_TAG_OEM_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 int hc_cbi_get(struct host_cmd_handler_args *args)
{
const struct __ec_align4 ec_params_get_cbi *p = args->params;
diff --git a/common/system.c b/common/system.c
index 1699b5b3fa..65c1d16681 100644
--- a/common/system.c
+++ b/common/system.c
@@ -10,6 +10,7 @@
#include "common.h"
#include "console.h"
#include "cpu.h"
+#include "cros_board_info.h"
#include "dma.h"
#include "flash.h"
#include "gpio.h"
@@ -756,24 +757,32 @@ 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)
{
- int v = 0;
-
-#ifdef CONFIG_BOARD_VERSION
-#ifdef CONFIG_BOARD_SPECIFIC_VERSION
- v = board_get_version();
+#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;
#else
- 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
+ return 0;
#endif
-
- return v;
}
__attribute__((weak)) /* Weird chips may need their own implementations */
@@ -1063,9 +1072,17 @@ 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());
- ccprintf("Board: %d\n", system_get_board_version());
+
+ board_version = system_get_board_version();
+ if (board_version < 0)
+ ccprintf("Board: Error %d\n", -board_version);
+ else
+ ccprintf("Board: %d\n", board_version);
+
#ifdef CHIP_HAS_RO_B
{
enum system_image_copy_t active;
@@ -1375,9 +1392,15 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_CHIP_INFO,
int host_command_get_board_version(struct host_cmd_handler_args *args)
{
struct ec_response_board_version *r = args->response;
+ int board_version;
- r->board_version = (uint16_t) system_get_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 = board_version;
args->response_size = sizeof(*r);
return EC_RES_SUCCESS;
diff --git a/include/config.h b/include/config.h
index fd24547884..c32c68faf3 100644
--- a/include/config.h
+++ b/include/config.h
@@ -412,10 +412,21 @@
*/
#undef CONFIG_BOARD_PRE_INIT
-/* EC has GPIOs attached to board version stuffing resistors */
+/*
+ * 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.
+ */
#undef CONFIG_BOARD_VERSION
-/* The decoding of the GPIOs defining board version is defined in board code */
-#undef CONFIG_BOARD_SPECIFIC_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
/* EC responses to a board defined I2C slave address */
#undef CONFIG_BOARD_I2C_SLAVE_ADDR
@@ -3324,6 +3335,19 @@
#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
+
/******************************************************************************/
/*
* Throttle AP must have temperature sensor enabled to get the readings for