diff options
Diffstat (limited to 'board/samus_pd')
-rw-r--r-- | board/samus_pd/board.c | 92 |
1 files changed, 5 insertions, 87 deletions
diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c index eb2273121b..e59646058c 100644 --- a/board/samus_pd/board.c +++ b/board/samus_pd/board.c @@ -102,67 +102,24 @@ DECLARE_DEFERRED(pericom_port1_reenable_interrupts); void vbus0_evt(enum gpio_signal signal) { - struct charge_port_info charge; - int vbus_level = gpio_get_level(signal); - - /* - * If VBUS is low, or VBUS is high and we are not outputting VBUS - * ourselves, then update the VBUS supplier. - */ - if (!vbus_level || !gpio_get_level(GPIO_USB_C0_5V_EN)) { - charge.voltage = USB_CHARGER_VOLTAGE_MV; - charge.current = vbus_level ? USB_CHARGER_MIN_CURR_MA : 0; - charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 0, &charge); - } - - /* - * Re-enable interrupts on pericom charger detector since the - * chip may periodically reset itself, and come back up with - * registers in default state. TODO(crosbug.com/p/33823): Fix - * these unwanted resets. - */ - hook_call_deferred(pericom_port0_reenable_interrupts, 0); + usb_charger_vbus_change(0, gpio_get_level(signal)); task_wake(TASK_ID_PD_C0); } void vbus1_evt(enum gpio_signal signal) { - struct charge_port_info charge; - int vbus_level = gpio_get_level(signal); - - /* - * If VBUS is low, or VBUS is high and we are not outputting VBUS - * ourselves, then update the VBUS supplier. - */ - if (!vbus_level || !gpio_get_level(GPIO_USB_C1_5V_EN)) { - charge.voltage = USB_CHARGER_VOLTAGE_MV; - charge.current = vbus_level ? USB_CHARGER_MIN_CURR_MA : 0; - charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 1, &charge); - } - - /* - * Re-enable interrupts on pericom charger detector since the - * chip may periodically reset itself, and come back up with - * registers in default state. TODO(crosbug.com/p/33823): Fix - * these unwanted resets. - */ - hook_call_deferred(pericom_port1_reenable_interrupts, 0); + usb_charger_vbus_change(1, gpio_get_level(signal)); task_wake(TASK_ID_PD_C1); } -static void wake_usb_charger_task(int port) -{ - task_wake(port ? TASK_ID_USB_CHG_P1 : TASK_ID_USB_CHG_P0); -} - void usb0_evt(enum gpio_signal signal) { - wake_usb_charger_task(0); + task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12, 0); } void usb1_evt(enum gpio_signal signal) { - wake_usb_charger_task(1); + task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12, 0); } static void chipset_s5_to_s3(void) @@ -252,10 +209,9 @@ void board_config_pre_init(void) /* Initialize board. */ static void board_init(void) { - int pd_enable, i; + int pd_enable; int slp_s5 = gpio_get_level(GPIO_PCH_SLP_S5_L); int slp_s3 = gpio_get_level(GPIO_PCH_SLP_S3_L); - struct charge_port_info charge_none, charge_vbus; /* * Enable CC lines after all GPIO have been initialized. Note, it is @@ -268,44 +224,6 @@ static void board_init(void) gpio_enable_interrupt(GPIO_USB_C0_VBUS_WAKE); gpio_enable_interrupt(GPIO_USB_C1_VBUS_WAKE); - /* Initialize all pericom charge suppliers to 0 */ - charge_none.voltage = USB_CHARGER_VOLTAGE_MV; - charge_none.current = 0; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { - charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY, - i, - &charge_none); - charge_manager_update_charge(CHARGE_SUPPLIER_BC12_CDP, - i, - &charge_none); - charge_manager_update_charge(CHARGE_SUPPLIER_BC12_DCP, - i, - &charge_none); - charge_manager_update_charge(CHARGE_SUPPLIER_BC12_SDP, - i, - &charge_none); - charge_manager_update_charge(CHARGE_SUPPLIER_OTHER, - i, - &charge_none); - } - - /* Initialize VBUS supplier based on whether or not VBUS is present */ - charge_vbus.voltage = USB_CHARGER_VOLTAGE_MV; - charge_vbus.current = USB_CHARGER_MIN_CURR_MA; - if (gpio_get_level(GPIO_USB_C0_VBUS_WAKE)) - charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 0, - &charge_vbus); - else - charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 0, - &charge_none); - - if (gpio_get_level(GPIO_USB_C1_VBUS_WAKE)) - charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 1, - &charge_vbus); - else - charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 1, - &charge_none); - /* Enable pericom BC1.2 interrupts. */ gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_L); gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_L); |