diff options
-rw-r--r-- | board/primus/build.mk | 1 | ||||
-rw-r--r-- | board/primus/cbi_ssfc.c | 30 | ||||
-rw-r--r-- | board/primus/cbi_ssfc.h | 31 |
3 files changed, 62 insertions, 0 deletions
diff --git a/board/primus/build.mk b/board/primus/build.mk index 217f95da10..ddf50b46e2 100644 --- a/board/primus/build.mk +++ b/board/primus/build.mk @@ -14,6 +14,7 @@ BASEBOARD:=brya board-y= board-y+=battery.o board-y+=board.o +board-y+=cbi_ssfc.o board-y+=charger.o board-y+=fans.o board-y+=fw_config.o diff --git a/board/primus/cbi_ssfc.c b/board/primus/cbi_ssfc.c new file mode 100644 index 0000000000..dd59bb2c9f --- /dev/null +++ b/board/primus/cbi_ssfc.c @@ -0,0 +1,30 @@ +/* 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 "compile_time_macros.h" +#include "console.h" +#include "cros_board_info.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 primus_cbi_ssfc cached_ssfc; +BUILD_ASSERT(sizeof(cached_ssfc) == sizeof(uint32_t)); + +void board_init_ssfc(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); +} + +enum ec_ssfc_trackpoint get_cbi_ssfc_trackpoint(void) +{ + return cached_ssfc.trackpoint; +} diff --git a/board/primus/cbi_ssfc.h b/board/primus/cbi_ssfc.h new file mode 100644 index 0000000000..d1ad8c991f --- /dev/null +++ b/board/primus/cbi_ssfc.h @@ -0,0 +1,31 @@ +/* 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 _PRIMUS_CBI_SSFC_H_ +#define _PRIMUS_CBI_SSFC_H_ +#include "stdint.h" +/**************************************************************************** + * Primus CBI Second Source Factory Cache + */ +/* + * Trackpoint (Bit 0) + */ +enum ec_ssfc_trackpoint { + SSFC_SENSOR_TRACKPOINT_ELAN = 0, + SSFC_SENSOR_TRACKPOINT_SYNAPTICS = 1, +}; +union primus_cbi_ssfc { + struct { + enum ec_ssfc_trackpoint trackpoint : 2; + uint32_t reserved_1 : 30; + }; + uint32_t raw_value; +}; +/** + * Get the trackpoint type from SSFC_CONFIG. + * + * @return the Trackpoint board type. + */ +enum ec_ssfc_trackpoint get_cbi_ssfc_trackpoint(void); +#endif /* _PRIMUS_CBI_SSFC_H_ */ |