diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2021-01-09 17:36:37 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-20 10:37:11 +0000 |
commit | 90237d36dee1fcb7694d5f3c1cd9b6c4ba37424a (patch) | |
tree | ca8737213c220e0a8fc56eb579d8e63c8b9fbe2a /board | |
parent | 44af7902177dbff6aec71a98a4b7b06efba0ec87 (diff) | |
download | chrome-ec-90237d36dee1fcb7694d5f3c1cd9b6c4ba37424a.tar.gz |
servo_v4p1: improve board ID support
- cache the value
- declare constants for the known values
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BUG=b:168621142
BRANCH=servo
TEST=none
Change-Id: I03c02ef04a1d6c2344bda08ec4e225ec159473ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2621305
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Jan Dąbroś <jsd@semihalf.com>
Diffstat (limited to 'board')
-rw-r--r-- | board/servo_v4p1/board.h | 8 | ||||
-rw-r--r-- | board/servo_v4p1/ioexpanders.c | 15 |
2 files changed, 18 insertions, 5 deletions
diff --git a/board/servo_v4p1/board.h b/board/servo_v4p1/board.h index 496736d043..25a63c34bf 100644 --- a/board/servo_v4p1/board.h +++ b/board/servo_v4p1/board.h @@ -278,6 +278,14 @@ enum adc_channel { ADC_CH_COUNT }; +/* Servo V4.1 Board ID mappings */ +enum servo_board_id { + BOARD_ID_UNSET = -1, + BOARD_ID_REV0 = 0, /* Proto */ + BOARD_ID_REV1 = 1, /* EVT */ + BOARD_ID_REV2 = 2, /* DVT */ +}; + /** * Compare cc_voltage to disconnect threshold * diff --git a/board/servo_v4p1/ioexpanders.c b/board/servo_v4p1/ioexpanders.c index f411cbbc73..6d3bb6c728 100644 --- a/board/servo_v4p1/ioexpanders.c +++ b/board/servo_v4p1/ioexpanders.c @@ -16,6 +16,8 @@ static int dut_chg_en_state; static int bc12_charger; +static enum servo_board_id board_id_val = BOARD_ID_UNSET; + /* Enable all ioexpander outputs. */ int init_ioexpanders(void) { @@ -245,13 +247,16 @@ inline int usb3_a1_mux_sel(int en) inline int board_id_det(void) { int id; - - id = tca6416a_read_byte(1, TCA6416A_IN_PORT_1); - if (id < 0) - return id; + if (board_id_val == BOARD_ID_UNSET) { + /* Cache board ID at init */ + id = tca6416a_read_byte(1, TCA6416A_IN_PORT_1); + if (id < 0) + return id; + board_id_val = id; + } /* Board ID consists of bits 5, 4, and 3 */ - return (id >> 3) & 0x7; + return (board_id_val >> 3) & 0x7; } inline int dongle_det(void) |