Lines Matching refs:hsotg
56 static const char *dwc2_op_state_str(struct dwc2_hsotg *hsotg) in dwc2_op_state_str() argument
58 switch (hsotg->op_state) { in dwc2_op_state_str()
81 static void dwc2_handle_usb_port_intr(struct dwc2_hsotg *hsotg) in dwc2_handle_usb_port_intr() argument
83 u32 hprt0 = dwc2_readl(hsotg->regs + HPRT0); in dwc2_handle_usb_port_intr()
87 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_handle_usb_port_intr()
91 dwc2_writel(GINTSTS_PRTINT, hsotg->regs + GINTSTS); in dwc2_handle_usb_port_intr()
99 static void dwc2_handle_mode_mismatch_intr(struct dwc2_hsotg *hsotg) in dwc2_handle_mode_mismatch_intr() argument
101 dev_warn(hsotg->dev, "Mode Mismatch Interrupt: currently in %s mode\n", in dwc2_handle_mode_mismatch_intr()
102 dwc2_is_host_mode(hsotg) ? "Host" : "Device"); in dwc2_handle_mode_mismatch_intr()
105 dwc2_writel(GINTSTS_MODEMIS, hsotg->regs + GINTSTS); in dwc2_handle_mode_mismatch_intr()
114 static void dwc2_handle_otg_intr(struct dwc2_hsotg *hsotg) in dwc2_handle_otg_intr() argument
120 gotgint = dwc2_readl(hsotg->regs + GOTGINT); in dwc2_handle_otg_intr()
121 gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); in dwc2_handle_otg_intr()
122 dev_dbg(hsotg->dev, "++OTG Interrupt gotgint=%0x [%s]\n", gotgint, in dwc2_handle_otg_intr()
123 dwc2_op_state_str(hsotg)); in dwc2_handle_otg_intr()
126 dev_dbg(hsotg->dev, in dwc2_handle_otg_intr()
128 dwc2_op_state_str(hsotg)); in dwc2_handle_otg_intr()
129 gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); in dwc2_handle_otg_intr()
131 if (dwc2_is_device_mode(hsotg)) in dwc2_handle_otg_intr()
132 dwc2_hsotg_disconnect(hsotg); in dwc2_handle_otg_intr()
134 if (hsotg->op_state == OTG_STATE_B_HOST) { in dwc2_handle_otg_intr()
135 hsotg->op_state = OTG_STATE_B_PERIPHERAL; in dwc2_handle_otg_intr()
142 dev_dbg(hsotg->dev, "Session End Detected\n"); in dwc2_handle_otg_intr()
143 dev_err(hsotg->dev, in dwc2_handle_otg_intr()
152 hsotg->lx_state = DWC2_L0; in dwc2_handle_otg_intr()
155 gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); in dwc2_handle_otg_intr()
157 dwc2_writel(gotgctl, hsotg->regs + GOTGCTL); in dwc2_handle_otg_intr()
161 dev_dbg(hsotg->dev, in dwc2_handle_otg_intr()
163 gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); in dwc2_handle_otg_intr()
165 if (hsotg->core_params->phy_type == in dwc2_handle_otg_intr()
167 && hsotg->core_params->i2c_enable > 0) { in dwc2_handle_otg_intr()
168 hsotg->srp_success = 1; in dwc2_handle_otg_intr()
171 gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); in dwc2_handle_otg_intr()
173 dwc2_writel(gotgctl, hsotg->regs + GOTGCTL); in dwc2_handle_otg_intr()
183 gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); in dwc2_handle_otg_intr()
188 if (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a) in dwc2_handle_otg_intr()
191 if (dwc2_is_host_mode(hsotg)) { in dwc2_handle_otg_intr()
192 hsotg->op_state = OTG_STATE_B_HOST; in dwc2_handle_otg_intr()
203 gintmsk = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_handle_otg_intr()
205 dwc2_writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_handle_otg_intr()
211 spin_unlock(&hsotg->lock); in dwc2_handle_otg_intr()
214 dwc2_hcd_start(hsotg); in dwc2_handle_otg_intr()
215 spin_lock(&hsotg->lock); in dwc2_handle_otg_intr()
216 hsotg->op_state = OTG_STATE_B_HOST; in dwc2_handle_otg_intr()
219 gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); in dwc2_handle_otg_intr()
221 dwc2_writel(gotgctl, hsotg->regs + GOTGCTL); in dwc2_handle_otg_intr()
222 dev_dbg(hsotg->dev, "HNP Failed\n"); in dwc2_handle_otg_intr()
223 dev_err(hsotg->dev, in dwc2_handle_otg_intr()
235 dev_dbg(hsotg->dev, in dwc2_handle_otg_intr()
237 (dwc2_is_host_mode(hsotg) ? "Host" : "Device")); in dwc2_handle_otg_intr()
238 if (dwc2_is_device_mode(hsotg)) { in dwc2_handle_otg_intr()
239 dev_dbg(hsotg->dev, "a_suspend->a_peripheral (%d)\n", in dwc2_handle_otg_intr()
240 hsotg->op_state); in dwc2_handle_otg_intr()
241 spin_unlock(&hsotg->lock); in dwc2_handle_otg_intr()
242 dwc2_hcd_disconnect(hsotg); in dwc2_handle_otg_intr()
243 spin_lock(&hsotg->lock); in dwc2_handle_otg_intr()
244 hsotg->op_state = OTG_STATE_A_PERIPHERAL; in dwc2_handle_otg_intr()
247 gintmsk = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_handle_otg_intr()
249 dwc2_writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_handle_otg_intr()
250 spin_unlock(&hsotg->lock); in dwc2_handle_otg_intr()
251 dwc2_hcd_start(hsotg); in dwc2_handle_otg_intr()
252 spin_lock(&hsotg->lock); in dwc2_handle_otg_intr()
253 hsotg->op_state = OTG_STATE_A_HOST; in dwc2_handle_otg_intr()
258 dev_dbg(hsotg->dev, in dwc2_handle_otg_intr()
261 dev_dbg(hsotg->dev, " ++OTG Interrupt: Debounce Done++\n"); in dwc2_handle_otg_intr()
264 dwc2_writel(gotgint, hsotg->regs + GOTGINT); in dwc2_handle_otg_intr()
277 static void dwc2_handle_conn_id_status_change_intr(struct dwc2_hsotg *hsotg) in dwc2_handle_conn_id_status_change_intr() argument
279 u32 gintmsk = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_handle_conn_id_status_change_intr()
283 dwc2_writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_handle_conn_id_status_change_intr()
285 dev_dbg(hsotg->dev, " ++Connector ID Status Change Interrupt++ (%s)\n", in dwc2_handle_conn_id_status_change_intr()
286 dwc2_is_host_mode(hsotg) ? "Host" : "Device"); in dwc2_handle_conn_id_status_change_intr()
293 if (hsotg->wq_otg) { in dwc2_handle_conn_id_status_change_intr()
294 spin_unlock(&hsotg->lock); in dwc2_handle_conn_id_status_change_intr()
295 queue_work(hsotg->wq_otg, &hsotg->wf_otg); in dwc2_handle_conn_id_status_change_intr()
296 spin_lock(&hsotg->lock); in dwc2_handle_conn_id_status_change_intr()
300 dwc2_writel(GINTSTS_CONIDSTSCHNG, hsotg->regs + GINTSTS); in dwc2_handle_conn_id_status_change_intr()
314 static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg) in dwc2_handle_session_req_intr() argument
318 dev_dbg(hsotg->dev, "Session request interrupt - lx_state=%d\n", in dwc2_handle_session_req_intr()
319 hsotg->lx_state); in dwc2_handle_session_req_intr()
322 dwc2_writel(GINTSTS_SESSREQINT, hsotg->regs + GINTSTS); in dwc2_handle_session_req_intr()
324 if (dwc2_is_device_mode(hsotg)) { in dwc2_handle_session_req_intr()
325 if (hsotg->lx_state == DWC2_L2) { in dwc2_handle_session_req_intr()
326 ret = dwc2_exit_hibernation(hsotg, true); in dwc2_handle_session_req_intr()
328 dev_err(hsotg->dev, in dwc2_handle_session_req_intr()
336 dwc2_hsotg_disconnect(hsotg); in dwc2_handle_session_req_intr()
347 static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg) in dwc2_handle_wakeup_detected_intr() argument
350 dev_dbg(hsotg->dev, "++Resume or Remote Wakeup Detected Interrupt++\n"); in dwc2_handle_wakeup_detected_intr()
351 dev_dbg(hsotg->dev, "%s lxstate = %d\n", __func__, hsotg->lx_state); in dwc2_handle_wakeup_detected_intr()
353 if (dwc2_is_device_mode(hsotg)) { in dwc2_handle_wakeup_detected_intr()
354 dev_dbg(hsotg->dev, "DSTS=0x%0x\n", in dwc2_handle_wakeup_detected_intr()
355 dwc2_readl(hsotg->regs + DSTS)); in dwc2_handle_wakeup_detected_intr()
356 if (hsotg->lx_state == DWC2_L2) { in dwc2_handle_wakeup_detected_intr()
357 u32 dctl = dwc2_readl(hsotg->regs + DCTL); in dwc2_handle_wakeup_detected_intr()
361 dwc2_writel(dctl, hsotg->regs + DCTL); in dwc2_handle_wakeup_detected_intr()
362 ret = dwc2_exit_hibernation(hsotg, true); in dwc2_handle_wakeup_detected_intr()
364 dev_err(hsotg->dev, "exit hibernation failed\n"); in dwc2_handle_wakeup_detected_intr()
366 call_gadget(hsotg, resume); in dwc2_handle_wakeup_detected_intr()
369 hsotg->lx_state = DWC2_L0; in dwc2_handle_wakeup_detected_intr()
371 if (hsotg->core_params->hibernation) { in dwc2_handle_wakeup_detected_intr()
372 dwc2_writel(GINTSTS_WKUPINT, hsotg->regs + GINTSTS); in dwc2_handle_wakeup_detected_intr()
375 if (hsotg->lx_state != DWC2_L1) { in dwc2_handle_wakeup_detected_intr()
376 u32 pcgcctl = dwc2_readl(hsotg->regs + PCGCTL); in dwc2_handle_wakeup_detected_intr()
380 dwc2_writel(pcgcctl, hsotg->regs + PCGCTL); in dwc2_handle_wakeup_detected_intr()
381 mod_timer(&hsotg->wkp_timer, in dwc2_handle_wakeup_detected_intr()
385 hsotg->lx_state = DWC2_L0; in dwc2_handle_wakeup_detected_intr()
390 dwc2_writel(GINTSTS_WKUPINT, hsotg->regs + GINTSTS); in dwc2_handle_wakeup_detected_intr()
397 static void dwc2_handle_disconnect_intr(struct dwc2_hsotg *hsotg) in dwc2_handle_disconnect_intr() argument
399 dev_dbg(hsotg->dev, "++Disconnect Detected Interrupt++ (%s) %s\n", in dwc2_handle_disconnect_intr()
400 dwc2_is_host_mode(hsotg) ? "Host" : "Device", in dwc2_handle_disconnect_intr()
401 dwc2_op_state_str(hsotg)); in dwc2_handle_disconnect_intr()
403 if (hsotg->op_state == OTG_STATE_A_HOST) in dwc2_handle_disconnect_intr()
404 dwc2_hcd_disconnect(hsotg); in dwc2_handle_disconnect_intr()
406 dwc2_writel(GINTSTS_DISCONNINT, hsotg->regs + GINTSTS); in dwc2_handle_disconnect_intr()
417 static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg *hsotg) in dwc2_handle_usb_suspend_intr() argument
422 dev_dbg(hsotg->dev, "USB SUSPEND\n"); in dwc2_handle_usb_suspend_intr()
424 if (dwc2_is_device_mode(hsotg)) { in dwc2_handle_usb_suspend_intr()
429 dsts = dwc2_readl(hsotg->regs + DSTS); in dwc2_handle_usb_suspend_intr()
430 dev_dbg(hsotg->dev, "DSTS=0x%0x\n", dsts); in dwc2_handle_usb_suspend_intr()
431 dev_dbg(hsotg->dev, in dwc2_handle_usb_suspend_intr()
434 hsotg->hw_params.power_optimized); in dwc2_handle_usb_suspend_intr()
435 if ((dsts & DSTS_SUSPSTS) && hsotg->hw_params.power_optimized) { in dwc2_handle_usb_suspend_intr()
437 if (!dwc2_is_device_connected(hsotg)) { in dwc2_handle_usb_suspend_intr()
438 dev_dbg(hsotg->dev, in dwc2_handle_usb_suspend_intr()
443 ret = dwc2_enter_hibernation(hsotg); in dwc2_handle_usb_suspend_intr()
446 dev_err(hsotg->dev, in dwc2_handle_usb_suspend_intr()
454 if (!IS_ERR_OR_NULL(hsotg->uphy)) in dwc2_handle_usb_suspend_intr()
455 usb_phy_set_suspend(hsotg->uphy, true); in dwc2_handle_usb_suspend_intr()
461 hsotg->lx_state = DWC2_L2; in dwc2_handle_usb_suspend_intr()
464 call_gadget(hsotg, suspend); in dwc2_handle_usb_suspend_intr()
467 if (hsotg->op_state == OTG_STATE_A_PERIPHERAL) { in dwc2_handle_usb_suspend_intr()
468 dev_dbg(hsotg->dev, "a_peripheral->a_host\n"); in dwc2_handle_usb_suspend_intr()
471 hsotg->lx_state = DWC2_L2; in dwc2_handle_usb_suspend_intr()
473 spin_unlock(&hsotg->lock); in dwc2_handle_usb_suspend_intr()
474 dwc2_hcd_start(hsotg); in dwc2_handle_usb_suspend_intr()
475 spin_lock(&hsotg->lock); in dwc2_handle_usb_suspend_intr()
476 hsotg->op_state = OTG_STATE_A_HOST; in dwc2_handle_usb_suspend_intr()
482 dwc2_writel(GINTSTS_USBSUSP, hsotg->regs + GINTSTS); in dwc2_handle_usb_suspend_intr()
493 static u32 dwc2_read_common_intr(struct dwc2_hsotg *hsotg) in dwc2_read_common_intr() argument
500 gintsts = dwc2_readl(hsotg->regs + GINTSTS); in dwc2_read_common_intr()
501 gintmsk = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_read_common_intr()
502 gahbcfg = dwc2_readl(hsotg->regs + GAHBCFG); in dwc2_read_common_intr()
506 dev_dbg(hsotg->dev, "gintsts=%08x gintmsk=%08x\n", in dwc2_read_common_intr()
530 struct dwc2_hsotg *hsotg = dev; in dwc2_handle_common_intr() local
534 spin_lock(&hsotg->lock); in dwc2_handle_common_intr()
536 if (!dwc2_is_controller_alive(hsotg)) { in dwc2_handle_common_intr()
537 dev_warn(hsotg->dev, "Controller is dead\n"); in dwc2_handle_common_intr()
541 gintsts = dwc2_read_common_intr(hsotg); in dwc2_handle_common_intr()
546 dwc2_handle_mode_mismatch_intr(hsotg); in dwc2_handle_common_intr()
548 dwc2_handle_otg_intr(hsotg); in dwc2_handle_common_intr()
550 dwc2_handle_conn_id_status_change_intr(hsotg); in dwc2_handle_common_intr()
552 dwc2_handle_disconnect_intr(hsotg); in dwc2_handle_common_intr()
554 dwc2_handle_session_req_intr(hsotg); in dwc2_handle_common_intr()
556 dwc2_handle_wakeup_detected_intr(hsotg); in dwc2_handle_common_intr()
558 dwc2_handle_usb_suspend_intr(hsotg); in dwc2_handle_common_intr()
565 if (dwc2_is_device_mode(hsotg)) { in dwc2_handle_common_intr()
566 dev_dbg(hsotg->dev, in dwc2_handle_common_intr()
568 dwc2_handle_usb_port_intr(hsotg); in dwc2_handle_common_intr()
574 spin_unlock(&hsotg->lock); in dwc2_handle_common_intr()