diff options
author | Ting Shen <phoenixshen@google.com> | 2021-04-13 15:08:35 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-27 03:49:02 +0000 |
commit | 72814ca3a57b556b28eb9e573f9d421a8ce599d9 (patch) | |
tree | e0fadd67434f89bbe723f5fd1c7e4c6a13e3a5ca /baseboard/cherry | |
parent | 9b660a8b90ad7f9f133a2ea56bc1593765286ce9 (diff) | |
download | chrome-ec-72814ca3a57b556b28eb9e573f9d421a8ce599d9.tar.gz |
cherry: enable CBI
BUG=b:185196921
TEST=`ectool cbi set 0 56 1 10`
verify board version changed to "56" in ec console
BRANCH=main
Signed-off-by: Ting Shen <phoenixshen@google.com>
Change-Id: I17045fd24bfaf50da9ada1ef09e25c60a758a8f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2823641
Tested-by: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Eric Yilun Lin <yllin@google.com>
Commit-Queue: Eric Yilun Lin <yllin@google.com>
Diffstat (limited to 'baseboard/cherry')
-rw-r--r-- | baseboard/cherry/baseboard.h | 17 | ||||
-rw-r--r-- | baseboard/cherry/board_id.c | 107 | ||||
-rw-r--r-- | baseboard/cherry/build.mk | 2 |
3 files changed, 8 insertions, 118 deletions
diff --git a/baseboard/cherry/baseboard.h b/baseboard/cherry/baseboard.h index f9ce133922..c610f13db9 100644 --- a/baseboard/cherry/baseboard.h +++ b/baseboard/cherry/baseboard.h @@ -22,7 +22,6 @@ * allow the second reset to be treated as a power-on. */ #define CONFIG_BOARD_RESET_AFTER_POWER_ON -#define CONFIG_BOARD_VERSION_CUSTOM #define CONFIG_CHIPSET_MT8192 #define CONFIG_EXTPOWER_GPIO #define CONFIG_HIBERNATE_WAKE_PINS_DYNAMIC @@ -53,6 +52,13 @@ #undef CONFIG_BC12_SINGLE_DRIVER #define CONFIG_USB_CHARGER +/* CBI */ +#define CONFIG_BOARD_VERSION_CBI +#define CONFIG_CROS_BOARD_INFO +#define CONFIG_CMD_CBI +#define I2C_PORT_EEPROM IT83XX_I2C_CH_A +#define I2C_ADDR_EEPROM_FLAGS 0x50 + /* Charger */ #define ADC_AMON_BMON ADC_CHARGER_AMON_R /* ADC name remap */ #define ADC_PSYS ADC_CHARGER_PMON /* ADC name remap */ @@ -208,15 +214,6 @@ enum power_signal { POWER_SIGNAL_COUNT, }; -enum board_sub_board { - SUB_BOARD_NONE = -1, - SUB_BOARD_TYPEC, - SUB_BOARD_HDMI, - - SUB_BOARD_COUNT, -}; - -int board_get_version(void); void board_reset_pd_mcu(void); #endif /* !__ASSEMBLER__ */ diff --git a/baseboard/cherry/board_id.c b/baseboard/cherry/board_id.c deleted file mode 100644 index e90da11f57..0000000000 --- a/baseboard/cherry/board_id.c +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "adc.h" -#include "common.h" -#include "console.h" -#include "gpio.h" -#include "hooks.h" -#include "timer.h" -#include "util.h" - -/** - * Conversion based on following table: - * - * ID | Rp | Rd | Voltage - * | kOhm | kOhm | mV - * ---+------+------+-------- - * 0 | 51.1 | 2.2 | 136.2 - * 1 | 51.1 | 6.81 | 388.1 - * 2 | 51.1 | 11 | 584.5 - * 3 | 57.6 | 18 | 785.7 - * 4 | 51.1 | 22 | 993.2 - * 5 | 51.1 | 30 | 1220.7 - * 6 | 51.1 | 39.2 | 1432.6 - * 7 | 56 | 56 | 1650.0 - * 8 | 47 | 61.9 | 1875.8 - * 9 | 47 | 80.6 | 2084.5 - * 10 | 56 | 124 | 2273.3 - * 11 | 51.1 | 150 | 2461.5 - * 12 | 47 | 200 | 2672.1 - * 13 | 47 | 330 | 2888.6 - * 14 | 47 | 680 | 3086.7 - */ -const static int voltage_map[] = { - 136, - 388, - 584, - 785, - 993, - 1220, - 1432, - 1650, - 1875, - 2084, - 2273, - 2461, - 2672, - 2888, - 3086, -}; - -const int threshold_mv = 100; - -/** - * Convert ADC value to board id using the voltage table above. - * - * @param ch ADC channel to read, usually ADC_BOARD_ID_0 or ADC_BOARD_ID_1. - * - * @return a non-negative board id, or negative value if error. - */ -static int adc_value_to_numeric_id(enum adc_channel ch) -{ - int mv; - - gpio_set_level(GPIO_EN_EC_ID_ODL, 0); - /* Wait to allow cap charge */ - msleep(10); - - mv = adc_read_channel(ch); - if (mv == ADC_READ_ERROR) - mv = adc_read_channel(ch); - - gpio_set_level(GPIO_EN_EC_ID_ODL, 1); - - if (mv == ADC_READ_ERROR) - return -EC_ERROR_UNKNOWN; - - for (int i = 0; i < ARRAY_SIZE(voltage_map); i++) { - if (IN_RANGE(mv, voltage_map[i] - threshold_mv, - voltage_map[i] + threshold_mv)) - return i; - } - - return -EC_ERROR_UNKNOWN; -} - -static int version = -1; - -/* b/163963220: Cache ADC value before board_hibernate_late() reads it */ -static void board_version_init(void) -{ - version = adc_value_to_numeric_id(ADC_BOARD_ID); - if (version < 0) { - ccprints("WARN:BOARD_ID_0"); - ccprints("Assuming board id = 0"); - - version = 0; - } -} -DECLARE_HOOK(HOOK_INIT, board_version_init, HOOK_PRIO_INIT_ADC + 1); - -int board_get_version(void) -{ - return version; -} diff --git a/baseboard/cherry/build.mk b/baseboard/cherry/build.mk index 58e9934bc0..ae82c1ca68 100644 --- a/baseboard/cherry/build.mk +++ b/baseboard/cherry/build.mk @@ -6,5 +6,5 @@ # Baseboard specific files build # -baseboard-y=baseboard.o board_id.o +baseboard-y=baseboard.o baseboard-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o |