diff options
-rw-r--r-- | baseboard/dedede/build.mk | 2 | ||||
-rw-r--r-- | baseboard/dedede/cbi_fw_config.c | 34 | ||||
-rw-r--r-- | baseboard/dedede/cbi_fw_config.h | 28 |
3 files changed, 63 insertions, 1 deletions
diff --git a/baseboard/dedede/build.mk b/baseboard/dedede/build.mk index f30c6d04f2..e86d1976ed 100644 --- a/baseboard/dedede/build.mk +++ b/baseboard/dedede/build.mk @@ -6,6 +6,6 @@ # Baseboard specific files build # -baseboard-y=baseboard.o +baseboard-y=baseboard.o cbi_fw_config.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_fw_config.c b/baseboard/dedede/cbi_fw_config.c new file mode 100644 index 0000000000..c483e5dbb7 --- /dev/null +++ b/baseboard/dedede/cbi_fw_config.c @@ -0,0 +1,34 @@ +/* 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_fw_config.h" +#include "common.h" +#include "console.h" +#include "cros_board_info.h" +#include "hooks.h" + +/**************************************************************************** + * Dedede CBI FW Configuration + */ + +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) + +/* Cache FW_CONFIG on init since we don't expect it to change in runtime */ +static uint32_t cached_fw_config; + +static void cbi_fw_config_init(void) +{ + if (cbi_get_fw_config(&cached_fw_config) != EC_SUCCESS) + /* Default to 0 when CBI isn't populated */ + cached_fw_config = 0; + + CPRINTS("FW_CONFIG: 0x%04X", cached_fw_config); +} +DECLARE_HOOK(HOOK_INIT, cbi_fw_config_init, HOOK_PRIO_INIT_I2C + 1); + +enum fw_config_db get_cbi_fw_config_db(void) +{ + return ((cached_fw_config & FW_CONFIG_DB_MASK) >> FW_CONFIG_DB_OFFSET); +} diff --git a/baseboard/dedede/cbi_fw_config.h b/baseboard/dedede/cbi_fw_config.h new file mode 100644 index 0000000000..cca9af68b4 --- /dev/null +++ b/baseboard/dedede/cbi_fw_config.h @@ -0,0 +1,28 @@ +/* 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 _DEDEDE_CBI_FW_CONFIG__H_ +#define _DEDEDE_CBI_FW_CONFIG__H_ + +/**************************************************************************** + * Dedede CBI FW Configuration + */ + +/* + * Daughter Board (Bits 0-3) + */ +enum fw_config_db { + DB_NONE, + DB_2C, + DB_1C_LTE, + DB_1A_HDMI, + DB_1C, +}; +#define FW_CONFIG_DB_OFFSET 0 +#define FW_CONFIG_DB_MASK GENMASK(3, 0) + +enum fw_config_db get_cbi_fw_config_db(void); + +#endif /* _DEDEDE_CBI_FW_CONFIG__H_ */ |