summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/bc12/pi3usb9281.c12
-rw-r--r--include/usb_charge.h1
2 files changed, 6 insertions, 7 deletions
diff --git a/driver/bc12/pi3usb9281.c b/driver/bc12/pi3usb9281.c
index eb4e6a8b6d..0c43bb199b 100644
--- a/driver/bc12/pi3usb9281.c
+++ b/driver/bc12/pi3usb9281.c
@@ -37,7 +37,6 @@
/* Store the state of our USB data switches so that they can be restored. */
static int usb_switch_state[CONFIG_USB_PD_PORT_COUNT];
-static struct mutex usb_switch_lock[CONFIG_USB_PD_PORT_COUNT];
static int pi3usb9281_reset(int port);
static int pi3usb9281_get_interrupts(int port);
@@ -278,14 +277,10 @@ void usb_charger_set_switches(int port, enum usb_switch setting)
/* If switch is not changing then return */
if (setting == usb_switch_state[port])
return;
-
- mutex_lock(&usb_switch_lock[port]);
if (setting != USB_SWITCH_RESTORE)
usb_switch_state[port] = setting;
-
- pi3usb9281_set_switches(port, usb_switch_state[port]);
-
- mutex_unlock(&usb_switch_lock[port]);
+ CPRINTS("USB MUX %d", usb_switch_state[port]);
+ task_set_event(TASK_ID_USB_CHG_P0 + port, USB_CHG_EVENT_MUX, 0);
}
static int pc3usb9281_read_interrupt(int port)
@@ -438,6 +433,9 @@ void usb_charger_task(void *u)
evt = bc12_detect(port);
}
+ if (evt & USB_CHG_EVENT_MUX)
+ pi3usb9281_set_switches(port, usb_switch_state[port]);
+
/*
* Re-enable interrupts on pericom charger detector since the
* chip may periodically reset itself, and come back up with
diff --git a/include/usb_charge.h b/include/usb_charge.h
index 46ba725b95..6b83a1c52f 100644
--- a/include/usb_charge.h
+++ b/include/usb_charge.h
@@ -55,6 +55,7 @@ int usb_charge_set_mode(int usb_port_id, enum usb_charge_mode mode,
#define USB_CHG_EVENT_DR_UFP TASK_EVENT_CUSTOM_BIT(3)
#define USB_CHG_EVENT_DR_DFP TASK_EVENT_CUSTOM_BIT(4)
#define USB_CHG_EVENT_CC_OPEN TASK_EVENT_CUSTOM_BIT(5)
+#define USB_CHG_EVENT_MUX TASK_EVENT_CUSTOM_BIT(6)
#endif
/*