diff options
Diffstat (limited to 'board/ryu/board.c')
-rw-r--r-- | board/ryu/board.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c index b34d50d3db..a5b5346e93 100644 --- a/board/ryu/board.c +++ b/board/ryu/board.c @@ -49,6 +49,12 @@ static int charge_current_limit; +/* + * Store the state of our USB data switches so that they can be restored + * after pericom reset. + */ +static int usb_switch_state; + static void vbus_log(void) { CPRINTS("VBUS %d", gpio_get_level(GPIO_CHGR_ACOK)); @@ -104,6 +110,13 @@ void usb_charger_task(void) /* Trigger chip reset to refresh detection registers */ pi3usb9281_reset(0); + /* + * Restore data switch settings - switches return to + * closed on reset until restored. + */ + if (usb_switch_state) + pi3usb9281_set_switches(0, 1); + /* Clear possible disconnect interrupt */ pi3usb9281_get_interrupts(0); /* Mask attach interrupt */ @@ -369,6 +382,16 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); +static void board_set_usb_switches(int port, int open) +{ + /* If switch is not changing, then return */ + if (open == usb_switch_state) + return; + + usb_switch_state = open; + pi3usb9281_set_switches(port, open); +} + void board_set_usb_mux(int port, enum typec_mux mux, enum usb_switch usb, int polarity) { @@ -377,6 +400,9 @@ void board_set_usb_mux(int port, enum typec_mux mux, gpio_set_level(GPIO_USBC_MUX_CONF1, 0); gpio_set_level(GPIO_USBC_MUX_CONF2, 0); + /* Set D+/D- switch to appropriate level */ + board_set_usb_switches(port, usb); + if (mux == TYPEC_MUX_NONE) /* everything is already disabled, we can return */ return; |