diff options
author | Ben Chen <ben.chen2@quanta.corp-partner.google.com> | 2020-12-25 18:14:26 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-09 05:14:27 +0000 |
commit | 251a1ee0ae893929f41c7afcd32741ea0f3805a2 (patch) | |
tree | 6cfa8c512ff7d2ef5093185637430d7e0f9d85e1 /baseboard/dedede | |
parent | 5b7e3cc504e833054e07c70bbaa85ad11fa94a59 (diff) | |
download | chrome-ec-251a1ee0ae893929f41c7afcd32741ea0f3805a2.tar.gz |
Dedede: 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:176314158, b:176314157
BRANCH=main
TEST=Make buildall PASS.
Change-Id: I1dbf06b7f2c8037a98e4d4c5c3d7beee556270ce
Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2603092
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'baseboard/dedede')
-rw-r--r-- | baseboard/dedede/build.mk | 4 | ||||
-rw-r--r-- | baseboard/dedede/cbi_ssfc.c | 37 | ||||
-rw-r--r-- | baseboard/dedede/cbi_ssfc.h | 56 |
3 files changed, 95 insertions, 2 deletions
diff --git a/baseboard/dedede/build.mk b/baseboard/dedede/build.mk index e86d1976ed..c92c855b3a 100644 --- a/baseboard/dedede/build.mk +++ b/baseboard/dedede/build.mk @@ -1,11 +1,11 @@ # -*- makefile -*- -# Copyright 2020 The Chromium OS Authors. All rights reserved. +# 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. # # Baseboard specific files build # -baseboard-y=baseboard.o cbi_fw_config.o +baseboard-y=baseboard.o cbi_fw_config.o cbi_ssfc.o baseboard-$(VARIANT_DEDEDE_EC_NPCX796FC)+=variant_ec_npcx796fc.o baseboard-$(VARIANT_DEDEDE_EC_IT8320)+=variant_ec_it8320.o diff --git a/baseboard/dedede/cbi_ssfc.c b/baseboard/dedede/cbi_ssfc.c new file mode 100644 index 0000000000..d49e1b0843 --- /dev/null +++ b/baseboard/dedede/cbi_ssfc.c @@ -0,0 +1,37 @@ +/* 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 "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 dedede_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/dedede/cbi_ssfc.h b/baseboard/dedede/cbi_ssfc.h new file mode 100644 index 0000000000..6b46a39839 --- /dev/null +++ b/baseboard/dedede/cbi_ssfc.h @@ -0,0 +1,56 @@ +/* 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. + */ + +#ifndef _DEDEDE_CBI_SSFC__H_ +#define _DEDEDE_CBI_SSFC__H_ + +#include "stdint.h" + +/**************************************************************************** + * Dedede 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 dedede_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 /* _DEDEDE_CBI_SSFC__H_ */ |