diff options
author | Zick Wei <zick.wei@quanta.corp-partner.google.com> | 2021-01-21 10:01:31 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-26 08:05:57 +0000 |
commit | 0ba6f7f8c8a5699b9a20280fed63f057e387dbfc (patch) | |
tree | 862e36f99cd703d18c0d9ef431d43a4cb6b1f4de /baseboard/zork | |
parent | e10667e305702d6ce6ca4fdcd380458fbc3456a5 (diff) | |
download | chrome-ec-0ba6f7f8c8a5699b9a20280fed63f057e387dbfc.tar.gz |
zork: add support SSFC
This patch add support SSFC for zork,
add support base sensor as below:
SSFC_BASE_GYRO_BMI160 = 1,
SSFC_BASE_GYRO_LSM6DSM = 2,
SSFC_BASE_GYRO_ICM426XX = 3,
BUG=b:173753906
BRANCH=zork
TEST=make buildall
Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com>
Change-Id: I10749d819b852861ac5a32d69f2b872527633082
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2641706
Reviewed-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'baseboard/zork')
-rw-r--r-- | baseboard/zork/build.mk | 1 | ||||
-rw-r--r-- | baseboard/zork/cbi_ssfc.c | 31 | ||||
-rw-r--r-- | baseboard/zork/cbi_ssfc.h | 40 |
3 files changed, 72 insertions, 0 deletions
diff --git a/baseboard/zork/build.mk b/baseboard/zork/build.mk index 740252ac9a..e79d60cc91 100644 --- a/baseboard/zork/build.mk +++ b/baseboard/zork/build.mk @@ -8,6 +8,7 @@ baseboard-y=baseboard.o baseboard-y+=cbi_ec_fw_config.o +baseboard-y+=cbi_ssfc.o baseboard-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o baseboard-$(VARIANT_ZORK_TREMBYLE)+=variant_trembyle.o baseboard-$(VARIANT_ZORK_DALBOZ)+=variant_dalboz.o diff --git a/baseboard/zork/cbi_ssfc.c b/baseboard/zork/cbi_ssfc.c new file mode 100644 index 0000000000..cf1001e5c2 --- /dev/null +++ b/baseboard/zork/cbi_ssfc.c @@ -0,0 +1,31 @@ +/* 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 zork_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_gyro_sensor get_cbi_ssfc_base_sensor(void) +{ + return cached_ssfc.base_sensor; +} diff --git a/baseboard/zork/cbi_ssfc.h b/baseboard/zork/cbi_ssfc.h new file mode 100644 index 0000000000..de073847e7 --- /dev/null +++ b/baseboard/zork/cbi_ssfc.h @@ -0,0 +1,40 @@ +/* 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 _ZORK_CBI_SSFC__H_ +#define _ZORK_CBI_SSFC__H_ + +#include "stdint.h" + +/**************************************************************************** + * Zork CBI Second Source Factory Cache + */ + +/* + * Base Sensor (Bits 0-2) + */ +enum ec_ssfc_base_gyro_sensor { + SSFC_BASE_GYRO_NONE = 0, + SSFC_BASE_GYRO_BMI160 = 1, + SSFC_BASE_GYRO_LSM6DSM = 2, + SSFC_BASE_GYRO_ICM426XX = 3, +}; + +union zork_cbi_ssfc { + struct { + enum ec_ssfc_base_gyro_sensor base_sensor : 3; + uint32_t reserved : 29; + }; + uint32_t raw_value; +}; + +/** + * Get the Base sensor type from SSFC_CONFIG. + * + * @return the Base sensor board type. + */ +enum ec_ssfc_base_gyro_sensor get_cbi_ssfc_base_sensor(void); + +#endif /* _ZORK_CBI_SSFC__H_ */ |