summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2021-04-20 01:02:56 -0700
committerCommit Bot <commit-bot@chromium.org>2021-04-21 02:04:30 +0000
commit0f69cef4c4871d70f959eff2e54761acc0e0921b (patch)
tree34782820490c2196a8639a7b2c3b15566cd440be
parentd77890f15553f9448bd0da19c2bcff76d61980ee (diff)
downloadchrome-ec-0f69cef4c4871d70f959eff2e54761acc0e0921b.tar.gz
brya: Define fw_config at board level
This updates the brya FW config fields based on the brya/config.star definitions. FW config fields and values are now defined at the project level rather than the program level. In other words each board (variant) defines its own FW config and no longer relies on baseboard definitions. BRANCH=none BUG=b:180434685 TEST=USB C1 port still works on brya for PD charging and SS data Change-Id: I055b0e2b051b7d41bbe116455274fe8b4a785741 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2837417 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--baseboard/brya/baseboard.h6
-rw-r--r--baseboard/brya/build.mk1
-rw-r--r--baseboard/brya/cbi.c7
-rw-r--r--baseboard/brya/cbi_ec_fw_config.h66
-rw-r--r--board/brya/board.c10
-rw-r--r--board/brya/build.mk1
-rw-r--r--board/brya/fw_config.c (renamed from baseboard/brya/cbi_ec_fw_config.c)13
-rw-r--r--board/brya/fw_config.h54
-rw-r--r--board/brya/usbc_config.c2
9 files changed, 79 insertions, 81 deletions
diff --git a/baseboard/brya/baseboard.h b/baseboard/brya/baseboard.h
index 4dd67b2976..62553d2c88 100644
--- a/baseboard/brya/baseboard.h
+++ b/baseboard/brya/baseboard.h
@@ -217,6 +217,12 @@
*/
__override_proto void board_cbi_init(void);
+/**
+ * Initialize the FW_CONFIG from CBI data. If the CBI data is not valid, set the
+ * FW_CONFIG to the board specific defaults.
+ */
+__override_proto void board_init_fw_config(void);
+
/*
* Check battery disconnect state.
* This function will return if battery is initialized or not.
diff --git a/baseboard/brya/build.mk b/baseboard/brya/build.mk
index 2200897ee6..e03e0a919c 100644
--- a/baseboard/brya/build.mk
+++ b/baseboard/brya/build.mk
@@ -9,7 +9,6 @@
baseboard-y=
baseboard-y+=baseboard.o
baseboard-y+=battery_presence.o
-baseboard-y+=cbi_ec_fw_config.o
baseboard-y+=cbi.o
baseboard-y+=charger.o
baseboard-y+=usb_pd_policy.o
diff --git a/baseboard/brya/cbi.c b/baseboard/brya/cbi.c
index 295dea26a3..a0a7275a7c 100644
--- a/baseboard/brya/cbi.c
+++ b/baseboard/brya/cbi.c
@@ -3,7 +3,6 @@
* found in the LICENSE file.
*/
-#include "cbi_ec_fw_config.h"
#include "common.h"
#include "cros_board_info.h"
#include "hooks.h"
@@ -23,6 +22,10 @@ __overridable void board_cbi_init(void)
{
}
+__overridable void board_init_fw_config(void)
+{
+}
+
/*
* Read CBI from I2C EEPROM and initialize variables for board variants.
*/
@@ -39,7 +42,7 @@ static void cbi_init(void)
CPRINTS("Board ID: %d", board_id);
- init_fw_config();
+ board_init_fw_config();
/* Allow the board project to make runtime changes based on CBI data */
board_cbi_init();
diff --git a/baseboard/brya/cbi_ec_fw_config.h b/baseboard/brya/cbi_ec_fw_config.h
deleted file mode 100644
index fd56ced869..0000000000
--- a/baseboard/brya/cbi_ec_fw_config.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* 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 __BRYA_CBI_EC_FW_CONFIG_H_
-#define __BRYA_CBI_EC_FW_CONFIG_H_
-
-#include "stdint.h"
-
-/****************************************************************************
- * CBI FW_CONFIG layout shared by all Brya boards
- *
- * Source of truth is the program/brya/program.star configuration file.
- */
-
-/*
- * TODO(b/180434685): are these right?
- * also, remove DB_USB_ABSENT2 after all existing boards have been
- * set up correctly.
- */
-
-enum ec_cfg_usb_db_type {
- DB_USB_ABSENT = 0,
- DB_USB3_PS8815 = 1,
- DB_USB_ABSENT2 = 15
-};
-
-union brya_cbi_fw_config {
- struct {
- /*
- * TODO(b/180434685): 4 bits?
- */
- enum ec_cfg_usb_db_type usb_db : 4;
- uint32_t reserved_1 : 28;
- };
- uint32_t raw_value;
-};
-
-/*
- * Each Brya board must define the default FW_CONFIG options to use
- * if the CBI data has not been initialized.
- */
-extern const union brya_cbi_fw_config fw_config_defaults;
-
-/**
- * Initialize the FW_CONFIG from CBI data. If the CBI data is not valid, set the
- * FW_CONFIG to the board specific defaults.
- */
-void init_fw_config(void);
-
-/**
- * Read the cached FW_CONFIG. Guaranteed to have valid values.
- *
- * @return the FW_CONFIG for the board.
- */
-union brya_cbi_fw_config get_fw_config(void);
-
-/**
- * Get the USB daughter board type from FW_CONFIG.
- *
- * @return the USB daughter board type.
- */
-enum ec_cfg_usb_db_type ec_cfg_usb_db_type(void);
-
-#endif /* __BRYA_CBI_EC_FW_CONFIG_H_ */
diff --git a/board/brya/board.c b/board/brya/board.c
index ea5a6404b4..3d26292df3 100644
--- a/board/brya/board.c
+++ b/board/brya/board.c
@@ -6,13 +6,13 @@
#include "common.h"
#include "button.h"
-#include "cbi_ec_fw_config.h"
#include "charge_ramp.h"
#include "charger.h"
#include "console.h"
#include "driver/accel_lis2dw12.h"
#include "driver/accelgyro_lsm6dso.h"
#include "driver/als_tcs3400.h"
+#include "fw_config.h"
#include "hooks.h"
#include "lid_switch.h"
#include "power_button.h"
@@ -37,14 +37,6 @@ BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) == USB_PORT_COUNT);
/******************************************************************************/
-/*
- * FW_CONFIG defaults for brya if the CBI.FW_CONFIG data is not
- * initialized.
- */
-const union brya_cbi_fw_config fw_config_defaults = {
- .usb_db = DB_USB3_PS8815,
-};
-
__override void board_cbi_init(void)
{
config_usb_db_type();
diff --git a/board/brya/build.mk b/board/brya/build.mk
index 5950facc88..67cc3b39d0 100644
--- a/board/brya/build.mk
+++ b/board/brya/build.mk
@@ -15,6 +15,7 @@ board-y=
board-y+=battery.o
board-y+=board.o
board-y+=fans.o
+board-y+=fw_config.o
board-y+=i2c.o
board-y+=keyboard.o
board-y+=led.o
diff --git a/baseboard/brya/cbi_ec_fw_config.c b/board/brya/fw_config.c
index d81ef4b4e8..2d9ee6de25 100644
--- a/baseboard/brya/cbi_ec_fw_config.c
+++ b/board/brya/fw_config.c
@@ -5,18 +5,27 @@
#include "common.h"
#include "console.h"
-#include "cbi_ec_fw_config.h"
#include "cros_board_info.h"
+#include "fw_config.h"
#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
static union brya_cbi_fw_config fw_config;
BUILD_ASSERT(sizeof(fw_config) == sizeof(uint32_t));
+/*
+ * FW_CONFIG defaults for brya if the CBI.FW_CONFIG data is not
+ * initialized.
+ */
+static const union brya_cbi_fw_config fw_config_defaults = {
+ .usb_db = DB_USB3_PS8815,
+ .kb_bl = KEYBOARD_BACKLIGHT_ENABLED,
+};
+
/****************************************************************************
* Brya FW_CONFIG access
*/
-void init_fw_config(void)
+void board_init_fw_config(void)
{
if (cbi_get_fw_config(&fw_config.raw_value)) {
CPRINTS("CBI: Read FW_CONFIG failed, using board defaults");
diff --git a/board/brya/fw_config.h b/board/brya/fw_config.h
new file mode 100644
index 0000000000..31843e759e
--- /dev/null
+++ b/board/brya/fw_config.h
@@ -0,0 +1,54 @@
+/* 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 __BOARD_BRYA_FW_CONFIG_H_
+#define __BOARD_BRYA_FW_CONFIG_H_
+
+#include "stdint.h"
+
+/****************************************************************************
+ * CBI FW_CONFIG layout for Brya board.
+ *
+ * Source of truth is the project/brya/brya/config.star configuration file.
+ */
+
+enum ec_cfg_usb_db_type {
+ DB_USB_ABSENT = 0,
+ DB_USB3_PS8815 = 1,
+ DB_USB_ABSENT2 = 15
+};
+
+enum ec_cfg_keyboard_backlight_type {
+ KEYBOARD_BACKLIGHT_DISABLED = 0,
+ KEYBOARD_BACKLIGHT_ENABLED = 1
+};
+
+union brya_cbi_fw_config {
+ struct {
+ enum ec_cfg_usb_db_type usb_db : 4;
+ uint32_t sd_db : 2;
+ uint32_t lte_db : 1;
+ enum ec_cfg_keyboard_backlight_type kb_bl : 1;
+ uint32_t audio : 3;
+ uint32_t reserved_1 : 21;
+ };
+ uint32_t raw_value;
+};
+
+/**
+ * Read the cached FW_CONFIG. Guaranteed to have valid values.
+ *
+ * @return the FW_CONFIG for the board.
+ */
+union brya_cbi_fw_config get_fw_config(void);
+
+/**
+ * Get the USB daughter board type from FW_CONFIG.
+ *
+ * @return the USB daughter board type.
+ */
+enum ec_cfg_usb_db_type ec_cfg_usb_db_type(void);
+
+#endif /* __BOARD_BRYA_FW_CONFIG_H_ */
diff --git a/board/brya/usbc_config.c b/board/brya/usbc_config.c
index 3e7347bcc0..2b2e786c76 100644
--- a/board/brya/usbc_config.c
+++ b/board/brya/usbc_config.c
@@ -5,7 +5,6 @@
#include "common.h"
-#include "cbi_ec_fw_config.h"
#include "driver/bc12/pi3usb9201_public.h"
#include "driver/ppc/nx20p348x.h"
#include "driver/ppc/syv682x_public.h"
@@ -13,6 +12,7 @@
#include "driver/tcpm/nct38xx.h"
#include "driver/tcpm/ps8xxx_public.h"
#include "driver/tcpm/tcpci.h"
+#include "fw_config.h"
#include "hooks.h"
#include "ioexpander.h"
#include "system.h"