summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam McNally <sammc@chromium.org>2020-05-13 18:38:47 +1000
committerCommit Bot <commit-bot@chromium.org>2020-05-14 06:53:03 +0000
commitb70e2768c856641e91205fdb50b20a4147b2a7e2 (patch)
tree47fe50bc7881ba1bd512b0bdc941af145f8fe003
parent6b9db38c8fa8a0c9813825ee31234f7d904f4e07 (diff)
downloadchrome-ec-b70e2768c856641e91205fdb50b20a4147b2a7e2.tar.gz
puff: Determine BJ power based on fw config.
BUG=b:154657629 TEST=make buildall -j; chgsup reports current according to fw config BRANCH=none Change-Id: Ieea86484ee49e056c368a6e764a217958bae3835 Signed-off-by: Sam McNally <sammc@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2198816 Reviewed-by: Andrew McRae <amcrae@chromium.org>
-rw-r--r--board/puff/board.c34
-rw-r--r--board/puff/board.h13
2 files changed, 34 insertions, 13 deletions
diff --git a/board/puff/board.c b/board/puff/board.c
index b3215f7855..f28d64615f 100644
--- a/board/puff/board.c
+++ b/board/puff/board.c
@@ -172,17 +172,16 @@ static void adp_connect_deferred(void)
if (connected == adp_connected)
return;
if (connected) {
- pi.voltage = 19000;
- /*
- * TODO(b:143975429) set current according to SKU.
- * Different SKUs will ship with different power bricks
- * that have varying power, though setting this to the
- * maximum current available on any SKU may be okay
- * (assume the included brick is sufficient to run the
- * system at max power and over-reporting available
- * power will have no effect).
- */
- pi.current = 4740;
+ switch (ec_config_get_bj_power()) {
+ case BJ_POWER_65W:
+ pi.voltage = 19000;
+ pi.current = 3420;
+ break;
+ case BJ_POWER_90W:
+ pi.voltage = 19000;
+ pi.current = 4740;
+ break;
+ }
}
charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED,
DEDICATED_CHARGE_PORT, &pi);
@@ -570,8 +569,10 @@ int extpower_is_present(void)
}
static uint16_t board_version;
+static uint32_t fw_config;
+
-static void load_board_info(void)
+static void cbi_init(void)
{
/*
* Load board info from CBI to control per-device configuration.
@@ -584,8 +585,11 @@ static void load_board_info(void)
if (cbi_get_board_version(&val) == EC_SUCCESS && val <= UINT16_MAX)
board_version = val;
CPRINTS("Board Version: 0x%04x", board_version);
+ if (cbi_get_fw_config(&val) == EC_SUCCESS)
+ fw_config = val;
+ CPRINTS("Firmware config: 0x%08x", fw_config);
}
-DECLARE_HOOK(HOOK_INIT, load_board_info, HOOK_PRIO_INIT_I2C + 1);
+DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1);
int board_is_c10_gate_enabled(void)
{
@@ -603,3 +607,7 @@ void board_enable_s0_rails(int enable)
gpio_set_level(GPIO_EN_PP5000_HDMI, enable);
}
+enum ec_cfg_bj_power_type ec_config_get_bj_power(void)
+{
+ return ((fw_config & EC_CFG_BJ_POWER_MASK) >> EC_CFG_BJ_POWER_L);
+}
diff --git a/board/puff/board.h b/board/puff/board.h
index 63664666b6..95ed4df8cf 100644
--- a/board/puff/board.h
+++ b/board/puff/board.h
@@ -228,6 +228,19 @@ void board_set_tcpc_power_mode(int port, int mode);
void led_alert(int enable);
void show_critical_error(void);
+/*
+ * Barrel-jack power (1 bit)
+ */
+enum ec_cfg_bj_power_type {
+ BJ_POWER_65W = 0,
+ BJ_POWER_90W = 1,
+};
+#define EC_CFG_BJ_POWER_L 0
+#define EC_CFG_BJ_POWER_H 0
+#define EC_CFG_BJ_POWER_MASK GENMASK(EC_CFG_BJ_POWER_H, EC_CFG_BJ_POWER_L)
+
+enum ec_cfg_bj_power_type ec_config_get_bj_power(void);
+
#endif /* !__ASSEMBLER__ */
/* Pin renaming */