static void bcmpmu_otg_xceiv_id_change_handler(struct work_struct *work) { struct bcmpmu_otg_xceiv_data *xceiv_data = container_of(work, struct bcmpmu_otg_xceiv_data, bcm_otg_id_status_change_work); bool id_gnd = false; bool id_rid_a = false; bool id_rid_c = false; dev_info(xceiv_data->dev, "ID change detected\n"); id_gnd = bcmpmu_otg_xceiv_check_id_gnd(xceiv_data); id_rid_a = bcmpmu_otg_xceiv_check_id_rid_a(xceiv_data); id_rid_c = bcmpmu_otg_xceiv_check_id_rid_c(xceiv_data); bcm_hsotgctrl_phy_set_id_stat(!(id_gnd || id_rid_a)); /* If ID is gnd, we need to turn on Vbus within 200ms * If ID is RID_A/B/C/FLOAT then we should not turn it on */ bcmpmu_otg_xceiv_set_vbus(&xceiv_data->otg_xceiver. xceiver, id_gnd ? true : false); if (!id_rid_c) msleep(HOST_TO_PERIPHERAL_DELAY_MS); if (id_gnd || id_rid_a || id_rid_c) { bcm_hsotgctrl_phy_deinit(); xceiv_data->otg_xceiver.xceiver.state = OTG_STATE_UNDEFINED; atomic_notifier_call_chain(&xceiv_data->otg_xceiver.xceiver. notifier, USB_EVENT_ID, NULL); } }
static void bcmpmu_otg_xceiv_id_change_handler(struct work_struct *work) { struct bcmpmu_otg_xceiv_data *xceiv_data = container_of(work, struct bcmpmu_otg_xceiv_data, bcm_otg_id_status_change_work); unsigned int new_id; bool id_gnd = false; bool id_rid_a = false; bool id_rid_c = false; dev_info(xceiv_data->dev, "ID change detected\n"); bcmpmu_usb_get(xceiv_data->bcmpmu, BCMPMU_USB_CTRL_GET_ID_VALUE, &new_id); if (xceiv_data->prev_otg_id != new_id) { id_gnd = bcmpmu_otg_xceiv_check_id_gnd(xceiv_data); id_rid_a = bcmpmu_otg_xceiv_check_id_rid_a(xceiv_data); id_rid_c = bcmpmu_otg_xceiv_check_id_rid_c(xceiv_data); bcm_hsotgctrl_phy_set_id_stat(!(id_gnd || id_rid_a)); if (id_gnd) { /* If ID is gnd, we need to turn on * Vbus within 200ms */ bcmpmu_otg_xceiv_set_vbus(&xceiv_data->otg_xceiver. xceiver, true); } if (!id_rid_c) msleep(HOST_TO_PERIPHERAL_DELAY_MS); if (id_gnd || id_rid_a || id_rid_c) { bcm_hsotgctrl_phy_deinit(); xceiv_data->otg_xceiver.xceiver.state = OTG_STATE_UNDEFINED; atomic_notifier_call_chain(&xceiv_data-> otg_xceiver.xceiver.notifier, USB_EVENT_ID, NULL); } } /* Update local ID copy */ xceiv_data->prev_otg_id = new_id; }