diff options
-rw-r--r-- | board/flapjack/board.c | 12 | ||||
-rw-r--r-- | driver/charger/rt946x.c | 11 | ||||
-rw-r--r-- | driver/charger/rt946x.h | 7 |
3 files changed, 29 insertions, 1 deletions
diff --git a/board/flapjack/board.c b/board/flapjack/board.c index 4efb2f2887..d8ede41890 100644 --- a/board/flapjack/board.c +++ b/board/flapjack/board.c @@ -22,6 +22,7 @@ #include "driver/sync.h" #include "driver/tcpm/mt6370.h" #include "driver/temp_sensor/tmp432.h" +#include "driver/wpc/p9221.h" #include "ec_commands.h" #include "extpower.h" #include "gpio.h" @@ -47,7 +48,6 @@ #include "usb_mux.h" #include "usb_pd_tcpm.h" #include "util.h" -#include "driver/wpc/p9221.h" #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) @@ -417,6 +417,16 @@ static void board_init(void) } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); +#ifdef SECTION_IS_RW +static void usb_pd_connect(void) +{ + /* VBUS from p9221 is already zero as it's disabled by NCP3902 */ + p9221_notify_vbus_change(0); + rt946x_toggle_bc12_detection(); +} +DECLARE_HOOK(HOOK_USB_PD_CONNECT, usb_pd_connect, HOOK_PRIO_DEFAULT); +#endif + void board_config_pre_init(void) { STM32_RCC_AHBENR |= STM32_RCC_HB_DMA1; diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c index d3d9309129..4573943197 100644 --- a/driver/charger/rt946x.c +++ b/driver/charger/rt946x.c @@ -927,6 +927,17 @@ void rt946x_interrupt(enum gpio_signal signal) task_wake(TASK_ID_USB_CHG); } +int rt946x_toggle_bc12_detection(void) +{ + int rv; + rv = rt946x_enable_bc12_detection(0); + if (rv) + return rv; + /* mt6370 requires 40us delay to toggle RT946X_MASK_USBCHGEN */ + udelay(40); + return rt946x_enable_bc12_detection(1); +} + void usb_charger_task(void *u) { struct charge_port_info chg; diff --git a/driver/charger/rt946x.h b/driver/charger/rt946x.h index 2b8c50ce19..ee35fae901 100644 --- a/driver/charger/rt946x.h +++ b/driver/charger/rt946x.h @@ -615,6 +615,13 @@ int rt946x_cutoff_battery(void); /* Enable/Disable charge temination */ int rt946x_enable_charge_termination(int en); +/** + * Toggle BC12 detection + * + * @return EC_SUCCESS or EC_ERROR_* + */ +int rt946x_toggle_bc12_detection(void); + struct rt946x_init_setting { uint16_t eoc_current; uint16_t mivr; |