diff options
author | Tommy Chung <tommy.chung@quanta.corp-partner.google.com> | 2022-07-04 19:55:59 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-06 07:07:57 +0000 |
commit | e80b2d6c4ea18990c5dab11ece2dd77b37b31b12 (patch) | |
tree | 64285fcbbe15e9950879e7ec63a7bb42aeebbfa6 | |
parent | d03f6309c11400554b53659d792017f920114951 (diff) | |
download | chrome-ec-e80b2d6c4ea18990c5dab11ece2dd77b37b31b12.tar.gz |
dojo: Set up board SSFC parsing
Set up basic file to use for parsing SSFC. Currently, SSFC is set to
recognize 2nd source of base sensor and lid sensor.
BUG=b:237963220
BRANCH=cherry
TEST=make BOARD=dojo
Signed-off-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com>
Change-Id: I50af96214b2e263e704580b06ecf93d4f9c95295
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3742857
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Devin Lu <devin.lu@quantatw.com>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3746056
Reviewed-by: Chen-Tsung Hsieh <chentsung@chromium.org>
Commit-Queue: Chen-Tsung Hsieh <chentsung@chromium.org>
-rw-r--r-- | board/dojo/build.mk | 2 | ||||
-rw-r--r-- | board/dojo/cbi_ssfc.c | 36 | ||||
-rw-r--r-- | board/dojo/cbi_ssfc.h | 57 |
3 files changed, 94 insertions, 1 deletions
diff --git a/board/dojo/build.mk b/board/dojo/build.mk index 25af05d562..e32df81d01 100644 --- a/board/dojo/build.mk +++ b/board/dojo/build.mk @@ -11,4 +11,4 @@ CHIP_FAMILY:=it8xxx2 CHIP_VARIANT:=it81202bx_1024 BASEBOARD:=cherry -board-y+=led.o battery.o board.o cbi_fw_config.o +board-y+=led.o battery.o board.o cbi_fw_config.o cbi_ssfc.o diff --git a/board/dojo/cbi_ssfc.c b/board/dojo/cbi_ssfc.c new file mode 100644 index 0000000000..6ece151e12 --- /dev/null +++ b/board/dojo/cbi_ssfc.c @@ -0,0 +1,36 @@ +/* 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 "cbi_ssfc.h" +#include "common.h" +#include "console.h" +#include "cros_board_info.h" +#include "hooks.h" + +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) + +/* Cache SSFC on init since we don't expect it to change in runtime */ +static union dojo_cbi_ssfc cached_ssfc; +BUILD_ASSERT(sizeof(cached_ssfc) == sizeof(uint32_t)); + +static void cbi_ssfc_init(void) +{ + if (cbi_get_ssfc(&cached_ssfc.raw_value) != EC_SUCCESS) + /* Default to 0 when CBI isn't populated */ + cached_ssfc.raw_value = 0; + + CPRINTS("Read CBI SSFC : 0x%04X", cached_ssfc.raw_value); +} +DECLARE_HOOK(HOOK_INIT, cbi_ssfc_init, HOOK_PRIO_FIRST); + +enum ec_ssfc_base_sensor get_cbi_ssfc_base_sensor(void) +{ + return (enum ec_ssfc_base_sensor)cached_ssfc.base_sensor; +} + +enum ec_ssfc_lid_sensor get_cbi_ssfc_lid_sensor(void) +{ + return (enum ec_ssfc_lid_sensor)cached_ssfc.lid_sensor; +} diff --git a/board/dojo/cbi_ssfc.h b/board/dojo/cbi_ssfc.h new file mode 100644 index 0000000000..53caad7ac8 --- /dev/null +++ b/board/dojo/cbi_ssfc.h @@ -0,0 +1,57 @@ +/* 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. + */ + +#ifndef _DOJO_CBI_SSFC__H_ +#define _DOJO_CBI_SSFC__H_ + +#include "stdint.h" + +/**************************************************************************** + * Dojo CBI Second Source Factory Cache + */ + +/* + * Base Sensor (Bits 0-2) + */ +enum ec_ssfc_base_sensor { + SSFC_SENSOR_BASE_DEFAULT = 0, + SSFC_SENSOR_ICM42607 = 1, + SSFC_SENSOR_ICM426XX = 2, + SSFC_SENSOR_BMI260 = 3, +}; + +/* + * Lid Sensor (Bits 3-5) + */ +enum ec_ssfc_lid_sensor { + SSFC_SENSOR_LID_DEFAULT = 0, + SSFC_SENSOR_BMA422 = 1, + SSFC_SENSOR_KX022 = 2, +}; + +union dojo_cbi_ssfc { + struct { + uint32_t base_sensor : 3; + uint32_t lid_sensor : 3; + uint32_t reserved_2 : 26; + }; + uint32_t raw_value; +}; + +/** + * Get the Base sensor type from SSFC_CONFIG. + * + * @return the Base sensor board type. + */ +enum ec_ssfc_base_sensor get_cbi_ssfc_base_sensor(void); + +/** + * Get the Lid sensor type from SSFC_CONFIG. + * + * @return the Lid sensor board type. + */ +enum ec_ssfc_lid_sensor get_cbi_ssfc_lid_sensor(void); + +#endif /* _DOJO_CBI_SSFC__H_ */ |