static int bsp_usb_pmu_detect_init(void) { int ret = 0; /* reg usb insert/remove detect callback */ if (bsp_pmu_irq_callback_register(PMU_INT_USB_IN, bsp_usb_pmu_insert_detect, &g_usb_notifier)) { g_usb_notifier.stat_reg_pmu_cb_fail++; } if (bsp_pmu_irq_callback_register(PMU_INT_USB_OUT, bsp_usb_pmu_remove_detect, &g_usb_notifier)) { g_usb_notifier.stat_reg_pmu_cb_fail++; } /* check whether the usb is connected in boot time */ if (bsp_pmu_usb_state_get()) { printk("usb is connect in boot\n"); usb_vendor_wake_lock(); ret = 1; } else { printk("usb is not connect in boot\n"); ret = 0; } if (!bsp_usb_is_support_pmu_detect()) { printk("usb is always init in boot\n"); ret = 1; } return ret; }
static void bsp_usb_pmu_remove_detect(void* ctx) { /* need to check whether usb is connected, as the PMU could * report the false event during rapid inserting & pluging */ if (bsp_pmu_usb_state_get()) { printk(KERN_WARNING "false remove event from PMU detected"); return; } printk(KERN_DEBUG "DWC3 USB: pmu remove event received\n"); if (bsp_usb_is_support_pmu_detect()) { /* usb gadget driver will catch the remove event if USB_PMU_DETECT not defined */ bsp_usb_status_change(USB_BALONG_DEVICE_REMOVE); } }
/***************************************************************************** 函 数 名 : is_power_off_charge_in 功能描述 : 关机时充电器是否插入 输入参数 : 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : *****************************************************************************/ LOCAL_1 bool is_power_off_charge_in( void ) { return bsp_pmu_usb_state_get(); }