summaryrefslogtreecommitdiff
path: root/baseboard/volteer
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-08 11:22:19 -0700
committerCommit Bot <commit-bot@chromium.org>2021-01-12 21:03:51 +0000
commit9cdf0dbd2fe9c6d7ca2f3a2eae4e7c1de2a799c3 (patch)
tree8d1a9597c78254daf4a35b6e77844d863bf2c06a /baseboard/volteer
parent83b1aef29fee7f353b274a388eeb5a670855e666 (diff)
downloadchrome-ec-9cdf0dbd2fe9c6d7ca2f3a2eae4e7c1de2a799c3.tar.gz
volteer: Split out baseboard CBI code into its own file
Move this out of baseboard.c so we can use it on Zephyr. BUG=b:175434113 BRANCH=none TEST=make BOARD=volteer -j30 With a zephyr-chrome CL, build volteer on zephyr Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I3783211d2e566f09b476043b045b5fed734164b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2617367
Diffstat (limited to 'baseboard/volteer')
-rw-r--r--baseboard/volteer/baseboard.c39
-rw-r--r--baseboard/volteer/baseboard.h11
-rw-r--r--baseboard/volteer/build.mk1
-rw-r--r--baseboard/volteer/cbi.c53
-rw-r--r--baseboard/volteer/cbi.h21
5 files changed, 76 insertions, 49 deletions
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c
index 5552809c84..3118cb9204 100644
--- a/baseboard/volteer/baseboard.c
+++ b/baseboard/volteer/baseboard.c
@@ -142,42 +142,3 @@ static void baseboard_init(void)
gpio_enable_interrupt(GPIO_EC_PROCHOT_IN_L);
}
DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_DEFAULT);
-
-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
- *
- * Example for configuring for a USB3 DB:
- * ectool cbi set 6 2 4 10
- */
-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);
-
- /* FW config */
- 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);
-
diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h
index 327c58b0a3..4ceb63a95a 100644
--- a/baseboard/volteer/baseboard.h
+++ b/baseboard/volteer/baseboard.h
@@ -235,6 +235,7 @@
#include "gpio_signal.h"
#include "common.h"
#include "baseboard_usbc_config.h"
+#include "cbi.h"
enum adc_channel {
ADC_TEMP_SENSOR_1_CHARGER,
@@ -264,16 +265,6 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
-unsigned char get_board_id(void);
-
-/**
- * Configure run-time data structures and operation based on CBI data. This
- * typically includes customization for changes in the BOARD_VERSION and
- * FW_CONFIG fields in CBI. This routine is called from the baseboard after
- * the CBI data has been initialized.
- */
-__override_proto void board_cbi_init(void);
-
/*
* Check battery disconnect state.
* This function will return if battery is initialized or not.
diff --git a/baseboard/volteer/build.mk b/baseboard/volteer/build.mk
index ae17954a69..96c017df37 100644
--- a/baseboard/volteer/build.mk
+++ b/baseboard/volteer/build.mk
@@ -10,6 +10,7 @@ baseboard-y=baseboard.o
baseboard-y+=battery_presence.o
baseboard-y+=charger.o
baseboard-y+=usb_pd_policy.o
+baseboard-y+=cbi.o
baseboard-y+=cbi_ec_fw_config.o
baseboard-y+=cbi_ssfc.o
baseboard-y+=usbc_config.o
diff --git a/baseboard/volteer/cbi.c b/baseboard/volteer/cbi.c
new file mode 100644
index 0000000000..ea446acc4e
--- /dev/null
+++ b/baseboard/volteer/cbi.c
@@ -0,0 +1,53 @@
+/* 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.
+ */
+
+/* Volteer family-specific functions, shared with Zephyr */
+
+#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
+ *
+ * Example for configuring for a USB3 DB:
+ * ectool cbi set 6 2 4 10
+ */
+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);
+
+ /* FW config */
+ 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);
diff --git a/baseboard/volteer/cbi.h b/baseboard/volteer/cbi.h
new file mode 100644
index 0000000000..049c0f65e2
--- /dev/null
+++ b/baseboard/volteer/cbi.h
@@ -0,0 +1,21 @@
+/* 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.
+ */
+
+/* Volteer family-specific CBI functions, shared with Zephyr */
+
+#ifndef __CROS_EC_BASEBOARD_CBI_H
+#define __CROS_EC_BASEBOARD_CBI_H
+
+unsigned char get_board_id(void);
+
+/**
+ * Configure run-time data structures and operation based on CBI data. This
+ * typically includes customization for changes in the BOARD_VERSION and
+ * FW_CONFIG fields in CBI. This routine is called from the baseboard after
+ * the CBI data has been initialized.
+ */
+__override_proto void board_cbi_init(void);
+
+#endif /* __CROS_EC_BASEBOARD_CBI_H */