summaryrefslogtreecommitdiff
path: root/board/puff
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2020-06-11 14:16:50 +1000
committerCommit Bot <commit-bot@chromium.org>2020-06-11 11:31:42 +0000
commite6c9581b499e265fb6dcbe7aacd56e0270f51d8c (patch)
tree35194d2c105b80d269f904a8cc88deb42c3c4c39 /board/puff
parent6ba72e77e41ad4f5aa127ac9f21a0069ecc150ac (diff)
downloadchrome-ec-e6c9581b499e265fb6dcbe7aacd56e0270f51d8c.tar.gz
Puff: Expand BJ field in fw_config to 4 bits
To allow for up to 16 barreljack ratings, expand the fw_config barreljack field to 4 bits. This is backwards compatible with the existing fw_config allocation. BUG=b:158716456 TEST=Confirm correct power adapter parameters are selected. BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: If7470b88233c12be81ff1200ec4d1c1af550f3e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2237452 Tested-by: Andrew McRae <amcrae@chromium.org> Commit-Queue: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'board/puff')
-rw-r--r--board/puff/board.c41
-rw-r--r--board/puff/board.h10
2 files changed, 32 insertions, 19 deletions
diff --git a/board/puff/board.c b/board/puff/board.c
index 8a2a89ae62..303b2258d6 100644
--- a/board/puff/board.c
+++ b/board/puff/board.c
@@ -161,6 +161,24 @@ static void port_ocp_interrupt(enum gpio_signal signal)
* protection, so we're safe to turn one on then the other off- but we should
* only do that if the system is off since it might still brown out.
*/
+
+/*
+ * Barrel-jack power adapter ratings.
+ */
+static const struct {
+ int voltage;
+ int current;
+} bj_power[] = {
+ { /* 0 - 65W (also default) */
+ .voltage = 19000,
+ .current = 3420
+ },
+ { /* 1 - 90W */
+ .voltage = 19000,
+ .current = 4740
+ },
+};
+
#define ADP_DEBOUNCE_MS 1000 /* Debounce time for BJ plug/unplug */
/* Debounced connection state of the barrel jack */
static int8_t adp_connected = -1;
@@ -173,16 +191,10 @@ static void adp_connect_deferred(void)
if (connected == adp_connected)
return;
if (connected) {
- 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;
- }
+ unsigned int bj = ec_config_get_bj_power();
+
+ pi.voltage = bj_power[bj].voltage;
+ pi.current = bj_power[bj].current;
}
charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED,
DEDICATED_CHARGE_PORT, &pi);
@@ -611,7 +623,12 @@ 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)
+unsigned int ec_config_get_bj_power(void)
{
- return ((fw_config & EC_CFG_BJ_POWER_MASK) >> EC_CFG_BJ_POWER_L);
+ unsigned int bj =
+ (fw_config & EC_CFG_BJ_POWER_MASK) >> EC_CFG_BJ_POWER_L;
+ /* Out of range value defaults to 0 */
+ if (bj >= ARRAY_SIZE(bj_power))
+ bj = 0;
+ return bj;
}
diff --git a/board/puff/board.h b/board/puff/board.h
index e639efaa57..83cbd5dca6 100644
--- a/board/puff/board.h
+++ b/board/puff/board.h
@@ -233,17 +233,13 @@ void led_alert(int enable);
void show_critical_error(void);
/*
- * Barrel-jack power (1 bit)
+ * Barrel-jack power (4 bits).
*/
-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_H 3
#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);
+unsigned int ec_config_get_bj_power(void);
#endif /* !__ASSEMBLER__ */