summaryrefslogtreecommitdiff
path: root/board/pompom/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/pompom/board.c')
-rw-r--r--board/pompom/board.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/board/pompom/board.c b/board/pompom/board.c
index ccaff4f55f..394f06be8e 100644
--- a/board/pompom/board.c
+++ b/board/pompom/board.c
@@ -269,6 +269,8 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
void board_hibernate(void)
{
+ int i;
+
/*
* Sensors are unpowered in hibernate. Apply PD to the
* interrupt lines such that they don't float.
@@ -288,7 +290,8 @@ void board_hibernate(void)
* otherwise, ACOK won't go High and can't wake EC up. Check the
* bug b/170324206 for details.
*/
- ppc_vbus_sink_enable(USB_PD_PORT_C0, 1);
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
+ ppc_vbus_sink_enable(i, 1);
}
__override uint16_t board_get_ps8xxx_product_id(int port)
@@ -320,9 +323,9 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- usb_mux_hpd_update(USB_PD_PORT_C0,
- USB_PD_MUX_HPD_LVL_DEASSERTED |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
@@ -402,20 +405,24 @@ void board_overcurrent_event(int port, int is_overcurrented)
int board_set_active_charge_port(int port)
{
- int is_real_port = (port == USB_PD_PORT_C0);
+ int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int i;
if (!is_real_port && port != CHARGE_PORT_NONE)
return EC_ERROR_INVAL;
if (port == CHARGE_PORT_NONE) {
CPRINTS("Disabling all charging port");
- /*
- * Do not return early if one fails otherwise we can
- * get into a boot loop assertion failure.
- */
- if (board_vbus_sink_enable(USB_PD_PORT_C0, 0))
- CPRINTS("Disabling p%d sink path failed.",
- USB_PD_PORT_C0);
+
+ /* Disable all ports. */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ /*
+ * Do not return early if one fails otherwise we can
+ * get into a boot loop assertion failure.
+ */
+ if (board_vbus_sink_enable(i, 0))
+ CPRINTS("Disabling p%d sink path failed.", i);
+ }
return EC_SUCCESS;
}
@@ -428,6 +435,18 @@ int board_set_active_charge_port(int port)
CPRINTS("New charge port: p%d", port);
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ if (i == port)
+ continue;
+
+ if (board_vbus_sink_enable(i, 0))
+ CPRINTS("p%d: sink path disable failed.", i);
+ }
+
/* Enable requested charge port. */
if (board_vbus_sink_enable(port, 1)) {
CPRINTS("p%d: sink path enable failed.", port);
@@ -437,8 +456,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-__override void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
+ int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -450,7 +469,9 @@ __override void board_set_charge_limit(int port, int supplier, int charge_ma,
charge_ma = max_ma;
}
- charge_set_input_current_limit(charge_ma, charge_mv);
+ charge_ma = charge_ma * 95 / 100;
+ charge_set_input_current_limit(
+ MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
uint16_t tcpc_get_alert_status(void)