diff options
author | Zhuohao Lee <zhuohao@chromium.org> | 2022-03-09 19:32:13 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-03-10 09:17:28 +0000 |
commit | 4a6781cb21c5c3b6831fddf037a0887bf2a62c72 (patch) | |
tree | 229b7ed9dd810561d6d391cc3374a91933b94987 /baseboard/brask | |
parent | d0b2c5412ae04793c5b37141bd9c0cfca2cd4699 (diff) | |
download | chrome-ec-4a6781cb21c5c3b6831fddf037a0887bf2a62c72.tar.gz |
baseboard/brask: Add the common cbi interface
Add the common cbi control interface for all of the
brask variants.
BUG=b:205646582
TEST=build pass
Change-Id: I5597a4f9023bbed86d077256527d98c4ed2d3a46
Signed-off-by: Zhuohao Lee <zhuohao@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3513272
Reviewed-by: caveh jalali <caveh@chromium.org>
Commit-Queue: caveh jalali <caveh@chromium.org>
Diffstat (limited to 'baseboard/brask')
-rw-r--r-- | baseboard/brask/build.mk | 1 | ||||
-rw-r--r-- | baseboard/brask/cbi.c | 58 | ||||
-rw-r--r-- | baseboard/brask/cbi.h | 38 |
3 files changed, 97 insertions, 0 deletions
diff --git a/baseboard/brask/build.mk b/baseboard/brask/build.mk index 5ba6b135f9..e29bcaf4ac 100644 --- a/baseboard/brask/build.mk +++ b/baseboard/brask/build.mk @@ -8,4 +8,5 @@ baseboard-y= baseboard-y+=baseboard.o +baseboard-y+=cbi.o baseboard-y+=usb_pd_policy.o diff --git a/baseboard/brask/cbi.c b/baseboard/brask/cbi.c new file mode 100644 index 0000000000..038a491f05 --- /dev/null +++ b/baseboard/brask/cbi.c @@ -0,0 +1,58 @@ +/* Copyright 2022 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 <stdint.h> + +#include "console.h" +#include "common.h" +#include "cros_board_info.h" +#include "hooks.h" + +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args) + +static uint8_t board_id; + +uint8_t get_board_id(void) +{ + return board_id; +} + +__overridable void board_cbi_init(void) +{ +} + +__overridable void board_init_fw_config(void) +{ +} + +__overridable void board_init_ssfc(void) +{ +} + +/* + * Read CBI from I2C EEPROM and initialize variables for board variants. + */ +static void cbi_init(void) +{ + uint32_t cbi_val; + + /* Board ID */ + if (cbi_get_board_version(&cbi_val) != EC_SUCCESS || + cbi_val > UINT8_MAX) + CPRINTS("CBI: Read Board ID failed"); + else + board_id = cbi_val; + + CPRINTS("Board ID: %d", board_id); + + board_init_fw_config(); + + board_init_ssfc(); + + /* Allow the board project to make runtime changes based on CBI data */ + board_cbi_init(); +} +DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_FIRST); diff --git a/baseboard/brask/cbi.h b/baseboard/brask/cbi.h new file mode 100644 index 0000000000..5fa41feadd --- /dev/null +++ b/baseboard/brask/cbi.h @@ -0,0 +1,38 @@ +/* Copyright 2022 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. + */ + +/* brask family-specific CBI functions, shared with Zephyr */ + +#ifndef __CROS_EC_BASEBOARD_CBI_H +#define __CROS_EC_BASEBOARD_CBI_H + +#include "common.h" + +/* + * Return the board revision number. + */ +uint8_t get_board_id(void); + +/** + * Configure run-time data structures and operation based on CBI data. This + * typically includes customization for changes in the BOARD_VERSION and + * FW_CONFIG fields in CBI. This routine is called from the baseboard after + * the CBI data has been initialized. + */ +__override_proto void board_cbi_init(void); + +/** + * Initialize the FW_CONFIG from CBI data. If the CBI data is not valid, set the + * FW_CONFIG to the board specific defaults. + */ +__override_proto void board_init_fw_config(void); + +/** + * Initialize the SSFC from CBI data. If the CBI data is not valid, set the + * SSFC to the board specific defaults. + */ +__override_proto void board_init_ssfc(void); + +#endif /* __CROS_EC_BASEBOARD_CBI_H */ |