summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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__ */