diff options
-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_ */ |