diff options
author | Ben Chen <ben.chen2@quanta.corp-partner.google.com> | 2020-12-21 15:50:40 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-30 02:30:51 +0000 |
commit | d2036f8eb8fa3f85da9e0b9e26a1c38bf4d55c03 (patch) | |
tree | 5a75e620a79ef2bff027720627c14f12d075bc7d | |
parent | e0aa74f0fe7447736d57b85e05ad6f443a608864 (diff) | |
download | chrome-ec-d2036f8eb8fa3f85da9e0b9e26a1c38bf4d55c03.tar.gz |
Volteer: Initiate the first version of parsing SSFC of CBI
Initiate the helper functions to parse the SSFC of CBI. The first
component define lid / base sensors in this version.
BUG=b:176039213, b:175843510
BRANCH=main
TEST=Make buildall PASS.
Change-Id: I63254e94d4953c5046868b15f3684f7a8a40f1ab
Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2599638
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | baseboard/volteer/build.mk | 1 | ||||
-rw-r--r-- | baseboard/volteer/cbi_ssfc.c | 36 | ||||
-rw-r--r-- | baseboard/volteer/cbi_ssfc.h | 58 |
3 files changed, 95 insertions, 0 deletions
diff --git a/baseboard/volteer/build.mk b/baseboard/volteer/build.mk index 662f3abdee..4ab5739836 100644 --- a/baseboard/volteer/build.mk +++ b/baseboard/volteer/build.mk @@ -10,3 +10,4 @@ baseboard-y=baseboard.o baseboard-y+=battery_presence.o baseboard-y+=usb_pd_policy.o baseboard-y+=cbi_ec_fw_config.o +baseboard-y+=cbi_ssfc.o diff --git a/baseboard/volteer/cbi_ssfc.c b/baseboard/volteer/cbi_ssfc.c new file mode 100644 index 0000000000..ac8e1591f2 --- /dev/null +++ b/baseboard/volteer/cbi_ssfc.c @@ -0,0 +1,36 @@ +/* Copyright 2020 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 volteer_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 cached_ssfc.base_sensor; +} + +enum ec_ssfc_lid_sensor get_cbi_ssfc_lid_sensor(void) +{ + return cached_ssfc.lid_sensor; +} diff --git a/baseboard/volteer/cbi_ssfc.h b/baseboard/volteer/cbi_ssfc.h new file mode 100644 index 0000000000..838bd35f78 --- /dev/null +++ b/baseboard/volteer/cbi_ssfc.h @@ -0,0 +1,58 @@ +/* Copyright 2020 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 _VOLTEER_CBI_SSFC__H_ +#define _VOLTEER_CBI_SSFC__H_ + +#include "stdint.h" + +/**************************************************************************** + * Volteer CBI Second Source Factory Cache + */ + +/* + * Base Sensor (Bits 0-2) + */ +enum ec_ssfc_base_sensor { + SSFC_SENSOR_BASE_DEFAULT = 0, + SSFC_SENSOR_BMI160 = 1, + SSFC_SENSOR_ICM426XX = 2 +}; + +/* + * Lid Sensor (Bits 3-5) + */ +enum ec_ssfc_lid_sensor { + SSFC_SENSOR_LID_DEFAULT = 0, + SSFC_SENSOR_BMA255 = 1, + SSFC_SENSOR_KX022 = 2 +}; + +union volteer_cbi_ssfc { + struct { + enum ec_ssfc_base_sensor base_sensor : 3; + enum ec_ssfc_lid_sensor 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 /* _Volteer_CBI_SSFC__H_ */ |