summaryrefslogtreecommitdiff
path: root/baseboard/brya/cbi.c
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2021-02-19 02:31:24 -0800
committerCommit Bot <commit-bot@chromium.org>2021-02-27 04:04:56 +0000
commit16a6024a7a38acf9d3eac7e304f30db23b169ff6 (patch)
treeb0efca130645a49e9433596c5074133a3cb1981f /baseboard/brya/cbi.c
parent924d0cad36a6a6a1d87df5926a0af8c77ddb244b (diff)
downloadchrome-ec-stabilize-13821.B-main.tar.gz
brya: Add CBI and FW_CONFIG supportstabilize-13821.B-main
This adds support for CBI and the first USB DB type field in FW_CONFIG. BUG=b:173575131,b:180434685 BRANCH=none TEST=buildall succeeds Signed-off-by: Caveh Jalali <caveh@chromium.org> Change-Id: If1d27fc100db9b814f90a9378d8dd19530a92bf4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2706964 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Sooraj Govindan <sooraj.govindan@intel.com>
Diffstat (limited to 'baseboard/brya/cbi.c')
-rw-r--r--baseboard/brya/cbi.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/baseboard/brya/cbi.c b/baseboard/brya/cbi.c
new file mode 100644
index 0000000000..295dea26a3
--- /dev/null
+++ b/baseboard/brya/cbi.c
@@ -0,0 +1,47 @@
+/* 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_ec_fw_config.h"
+#include "common.h"
+#include "cros_board_info.h"
+#include "hooks.h"
+#include "system.h"
+
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
+
+static uint8_t board_id;
+
+uint8_t get_board_id(void)
+{
+ return board_id;
+}
+
+__overridable void board_cbi_init(void)
+{
+}
+
+/*
+ * Read CBI from I2C EEPROM and initialize variables for board variants.
+ */
+static void cbi_init(void)
+{
+ uint32_t cbi_val;
+
+ /* Board ID */
+ if (cbi_get_board_version(&cbi_val) != EC_SUCCESS ||
+ cbi_val > UINT8_MAX)
+ CPRINTS("CBI: Read Board ID failed");
+ else
+ board_id = cbi_val;
+
+ CPRINTS("Board ID: %d", board_id);
+
+ init_fw_config();
+
+ /* Allow the board project to make runtime changes based on CBI data */
+ board_cbi_init();
+}
+DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_FIRST);