Lines Matching refs:hsotg

51 static inline void dwc2_set_bit(struct dwc2_hsotg *hsotg, u32 offset, u32 val)  in dwc2_set_bit()  argument
53 dwc2_writel(hsotg, dwc2_readl(hsotg, offset) | val, offset); in dwc2_set_bit()
56 static inline void dwc2_clear_bit(struct dwc2_hsotg *hsotg, u32 offset, u32 val) in dwc2_clear_bit() argument
58 dwc2_writel(hsotg, dwc2_readl(hsotg, offset) & ~val, offset); in dwc2_clear_bit()
61 static inline struct dwc2_hsotg_ep *index_to_ep(struct dwc2_hsotg *hsotg, in index_to_ep() argument
65 return hsotg->eps_in[ep_index]; in index_to_ep()
67 return hsotg->eps_out[ep_index]; in index_to_ep()
71 static void dwc2_hsotg_dump(struct dwc2_hsotg *hsotg);
92 static inline bool using_dma(struct dwc2_hsotg *hsotg) in using_dma() argument
94 return hsotg->params.g_dma; in using_dma()
103 static inline bool using_desc_dma(struct dwc2_hsotg *hsotg) in using_desc_dma() argument
105 return hsotg->params.g_dma_desc; in using_desc_dma()
117 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_incr_frame_num() local
120 if (hsotg->gadget.speed != USB_SPEED_HIGH) in dwc2_gadget_incr_frame_num()
144 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_dec_frame_num_by_one() local
147 if (hsotg->gadget.speed != USB_SPEED_HIGH) in dwc2_gadget_dec_frame_num_by_one()
161 static void dwc2_hsotg_en_gsint(struct dwc2_hsotg *hsotg, u32 ints) in dwc2_hsotg_en_gsint() argument
163 u32 gsintmsk = dwc2_readl(hsotg, GINTMSK); in dwc2_hsotg_en_gsint()
169 dev_dbg(hsotg->dev, "gsintmsk now 0x%08x\n", new_gsintmsk); in dwc2_hsotg_en_gsint()
170 dwc2_writel(hsotg, new_gsintmsk, GINTMSK); in dwc2_hsotg_en_gsint()
179 static void dwc2_hsotg_disable_gsint(struct dwc2_hsotg *hsotg, u32 ints) in dwc2_hsotg_disable_gsint() argument
181 u32 gsintmsk = dwc2_readl(hsotg, GINTMSK); in dwc2_hsotg_disable_gsint()
187 dwc2_writel(hsotg, new_gsintmsk, GINTMSK); in dwc2_hsotg_disable_gsint()
200 static void dwc2_hsotg_ctrl_epint(struct dwc2_hsotg *hsotg, in dwc2_hsotg_ctrl_epint() argument
212 daint = dwc2_readl(hsotg, DAINTMSK); in dwc2_hsotg_ctrl_epint()
217 dwc2_writel(hsotg, daint, DAINTMSK); in dwc2_hsotg_ctrl_epint()
226 int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg) in dwc2_hsotg_tx_fifo_count() argument
228 if (hsotg->hw_params.en_multiple_tx_fifo) in dwc2_hsotg_tx_fifo_count()
230 return hsotg->hw_params.num_dev_in_eps; in dwc2_hsotg_tx_fifo_count()
233 return hsotg->hw_params.num_dev_perio_in_ep; in dwc2_hsotg_tx_fifo_count()
242 int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) in dwc2_hsotg_tx_fifo_total_depth() argument
248 np_tx_fifo_size = min_t(u32, hsotg->hw_params.dev_nperio_tx_fifo_size, in dwc2_hsotg_tx_fifo_total_depth()
249 hsotg->params.g_np_tx_fifo_size); in dwc2_hsotg_tx_fifo_total_depth()
252 tx_addr_max = hsotg->hw_params.total_fifo_size; in dwc2_hsotg_tx_fifo_total_depth()
254 addr = hsotg->params.g_rx_fifo_size + np_tx_fifo_size; in dwc2_hsotg_tx_fifo_total_depth()
267 static void dwc2_gadget_wkup_alert_handler(struct dwc2_hsotg *hsotg) in dwc2_gadget_wkup_alert_handler() argument
272 gintsts2 = dwc2_readl(hsotg, GINTSTS2); in dwc2_gadget_wkup_alert_handler()
273 gintmsk2 = dwc2_readl(hsotg, GINTMSK2); in dwc2_gadget_wkup_alert_handler()
277 dev_dbg(hsotg->dev, "%s: Wkup_Alert_Int\n", __func__); in dwc2_gadget_wkup_alert_handler()
278 dwc2_set_bit(hsotg, GINTSTS2, GINTSTS2_WKUP_ALERT_INT); in dwc2_gadget_wkup_alert_handler()
279 dwc2_set_bit(hsotg, DCTL, DCTL_RMTWKUPSIG); in dwc2_gadget_wkup_alert_handler()
289 int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg) in dwc2_hsotg_tx_fifo_average_depth() argument
294 tx_fifo_depth = dwc2_hsotg_tx_fifo_total_depth(hsotg); in dwc2_hsotg_tx_fifo_average_depth()
296 tx_fifo_count = dwc2_hsotg_tx_fifo_count(hsotg); in dwc2_hsotg_tx_fifo_average_depth()
308 static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg) in dwc2_hsotg_init_fifo() argument
315 u32 *txfsz = hsotg->params.g_tx_fifo_size; in dwc2_hsotg_init_fifo()
318 WARN_ON(hsotg->fifo_map); in dwc2_hsotg_init_fifo()
319 hsotg->fifo_map = 0; in dwc2_hsotg_init_fifo()
322 dwc2_writel(hsotg, hsotg->params.g_rx_fifo_size, GRXFSIZ); in dwc2_hsotg_init_fifo()
323 dwc2_writel(hsotg, (hsotg->params.g_rx_fifo_size << in dwc2_hsotg_init_fifo()
325 (hsotg->params.g_np_tx_fifo_size << FIFOSIZE_DEPTH_SHIFT), in dwc2_hsotg_init_fifo()
336 addr = hsotg->params.g_rx_fifo_size + hsotg->params.g_np_tx_fifo_size; in dwc2_hsotg_init_fifo()
348 WARN_ONCE(addr + txfsz[ep] > hsotg->fifo_mem, in dwc2_hsotg_init_fifo()
352 dwc2_writel(hsotg, val, DPTXFSIZN(ep)); in dwc2_hsotg_init_fifo()
353 val = dwc2_readl(hsotg, DPTXFSIZN(ep)); in dwc2_hsotg_init_fifo()
356 dwc2_writel(hsotg, hsotg->hw_params.total_fifo_size | in dwc2_hsotg_init_fifo()
364 dwc2_writel(hsotg, GRSTCTL_TXFNUM(0x10) | GRSTCTL_TXFFLSH | in dwc2_hsotg_init_fifo()
370 val = dwc2_readl(hsotg, GRSTCTL); in dwc2_hsotg_init_fifo()
376 dev_err(hsotg->dev, in dwc2_hsotg_init_fifo()
385 dev_dbg(hsotg->dev, "FIFOs reset, timeout at %d\n", timeout); in dwc2_hsotg_init_fifo()
430 static void dwc2_hsotg_unmap_dma(struct dwc2_hsotg *hsotg, in dwc2_hsotg_unmap_dma() argument
436 usb_gadget_unmap_request(&hsotg->gadget, req, hs_ep->map_dir); in dwc2_hsotg_unmap_dma()
447 static int dwc2_gadget_alloc_ctrl_desc_chains(struct dwc2_hsotg *hsotg) in dwc2_gadget_alloc_ctrl_desc_chains() argument
449 hsotg->setup_desc[0] = in dwc2_gadget_alloc_ctrl_desc_chains()
450 dmam_alloc_coherent(hsotg->dev, in dwc2_gadget_alloc_ctrl_desc_chains()
452 &hsotg->setup_desc_dma[0], in dwc2_gadget_alloc_ctrl_desc_chains()
454 if (!hsotg->setup_desc[0]) in dwc2_gadget_alloc_ctrl_desc_chains()
457 hsotg->setup_desc[1] = in dwc2_gadget_alloc_ctrl_desc_chains()
458 dmam_alloc_coherent(hsotg->dev, in dwc2_gadget_alloc_ctrl_desc_chains()
460 &hsotg->setup_desc_dma[1], in dwc2_gadget_alloc_ctrl_desc_chains()
462 if (!hsotg->setup_desc[1]) in dwc2_gadget_alloc_ctrl_desc_chains()
465 hsotg->ctrl_in_desc = in dwc2_gadget_alloc_ctrl_desc_chains()
466 dmam_alloc_coherent(hsotg->dev, in dwc2_gadget_alloc_ctrl_desc_chains()
468 &hsotg->ctrl_in_desc_dma, in dwc2_gadget_alloc_ctrl_desc_chains()
470 if (!hsotg->ctrl_in_desc) in dwc2_gadget_alloc_ctrl_desc_chains()
473 hsotg->ctrl_out_desc = in dwc2_gadget_alloc_ctrl_desc_chains()
474 dmam_alloc_coherent(hsotg->dev, in dwc2_gadget_alloc_ctrl_desc_chains()
476 &hsotg->ctrl_out_desc_dma, in dwc2_gadget_alloc_ctrl_desc_chains()
478 if (!hsotg->ctrl_out_desc) in dwc2_gadget_alloc_ctrl_desc_chains()
503 static int dwc2_hsotg_write_fifo(struct dwc2_hsotg *hsotg, in dwc2_hsotg_write_fifo() argument
508 u32 gnptxsts = dwc2_readl(hsotg, GNPTXSTS); in dwc2_hsotg_write_fifo()
522 if (periodic && !hsotg->dedicated_fifos) { in dwc2_hsotg_write_fifo()
523 u32 epsize = dwc2_readl(hsotg, DIEPTSIZ(hs_ep->index)); in dwc2_hsotg_write_fifo()
539 dwc2_hsotg_en_gsint(hsotg, GINTSTS_PTXFEMP); in dwc2_hsotg_write_fifo()
543 dev_dbg(hsotg->dev, "%s: left=%d, load=%d, fifo=%d, size %d\n", in dwc2_hsotg_write_fifo()
552 dev_dbg(hsotg->dev, "%s: => can_write1=%d\n", in dwc2_hsotg_write_fifo()
556 dev_dbg(hsotg->dev, "%s: => can_write2=%d\n", in dwc2_hsotg_write_fifo()
560 dwc2_hsotg_en_gsint(hsotg, GINTSTS_PTXFEMP); in dwc2_hsotg_write_fifo()
563 } else if (hsotg->dedicated_fifos && hs_ep->index != 0) { in dwc2_hsotg_write_fifo()
564 can_write = dwc2_readl(hsotg, in dwc2_hsotg_write_fifo()
571 dev_dbg(hsotg->dev, in dwc2_hsotg_write_fifo()
575 dwc2_hsotg_en_gsint(hsotg, GINTSTS_NPTXFEMP); in dwc2_hsotg_write_fifo()
585 dev_dbg(hsotg->dev, "%s: GNPTXSTS=%08x, can=%d, to=%d, max_transfer %d\n", in dwc2_hsotg_write_fifo()
605 if (!hsotg->dedicated_fifos) in dwc2_hsotg_write_fifo()
606 dwc2_hsotg_en_gsint(hsotg, in dwc2_hsotg_write_fifo()
634 if (!hsotg->dedicated_fifos) in dwc2_hsotg_write_fifo()
635 dwc2_hsotg_en_gsint(hsotg, in dwc2_hsotg_write_fifo()
640 dev_dbg(hsotg->dev, "write %d/%d, can_write %d, done %d\n", in dwc2_hsotg_write_fifo()
655 dwc2_writel_rep(hsotg, EPFIFO(hs_ep->index), data, to_write); in dwc2_hsotg_write_fifo()
705 static u32 dwc2_hsotg_read_frameno(struct dwc2_hsotg *hsotg) in dwc2_hsotg_read_frameno() argument
709 dsts = dwc2_readl(hsotg, DSTS); in dwc2_hsotg_read_frameno()
913 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_fill_isoc_desc() local
926 dev_dbg(hsotg->dev, "%s: desc chain full\n", __func__); in dwc2_gadget_fill_isoc_desc()
934 dev_dbg(hsotg->dev, "%s: Filling ep %d, dir %s isoc desc # %d\n", in dwc2_gadget_fill_isoc_desc()
982 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_start_isoc_ddma() local
994 dev_dbg(hsotg->dev, "%s: No requests in queue\n", __func__); in dwc2_gadget_start_isoc_ddma()
1025 dwc2_writel(hsotg, hs_ep->desc_list_dma, dma_reg); in dwc2_gadget_start_isoc_ddma()
1027 ctrl = dwc2_readl(hsotg, depctl); in dwc2_gadget_start_isoc_ddma()
1029 dwc2_writel(hsotg, ctrl, depctl); in dwc2_gadget_start_isoc_ddma()
1033 static void dwc2_hsotg_complete_request(struct dwc2_hsotg *hsotg,
1048 static void dwc2_hsotg_start_req(struct dwc2_hsotg *hsotg, in dwc2_hsotg_start_req() argument
1067 dev_err(hsotg->dev, "%s: active request\n", __func__); in dwc2_hsotg_start_req()
1071 dev_err(hsotg->dev, in dwc2_hsotg_start_req()
1082 dev_dbg(hsotg->dev, "%s: DxEPCTL=0x%08x, ep %d, dir %s\n", in dwc2_hsotg_start_req()
1083 __func__, dwc2_readl(hsotg, epctrl_reg), index, in dwc2_hsotg_start_req()
1087 ctrl = dwc2_readl(hsotg, epctrl_reg); in dwc2_hsotg_start_req()
1090 dev_warn(hsotg->dev, "%s: ep%d is stalled\n", __func__, index); in dwc2_hsotg_start_req()
1095 dev_dbg(hsotg->dev, "ureq->length:%d ureq->actual:%d\n", in dwc2_hsotg_start_req()
1098 if (!using_desc_dma(hsotg)) in dwc2_hsotg_start_req()
1106 dev_dbg(hsotg->dev, "%s: length %d, max-req %d, r %d\n", in dwc2_hsotg_start_req()
1143 dev_dbg(hsotg->dev, "%s: %d@%d/%d, 0x%08x => 0x%08x\n", in dwc2_hsotg_start_req()
1149 if (using_desc_dma(hsotg)) { in dwc2_hsotg_start_req()
1169 dwc2_writel(hsotg, hs_ep->desc_list_dma, dma_reg); in dwc2_hsotg_start_req()
1171 dev_dbg(hsotg->dev, "%s: %08x pad => 0x%08x\n", in dwc2_hsotg_start_req()
1175 dwc2_writel(hsotg, epsize, epsize_reg); in dwc2_hsotg_start_req()
1177 if (using_dma(hsotg) && !continuing && (length != 0)) { in dwc2_hsotg_start_req()
1183 dwc2_writel(hsotg, ureq->dma, dma_reg); in dwc2_hsotg_start_req()
1185 dev_dbg(hsotg->dev, "%s: %pad => 0x%08x\n", in dwc2_hsotg_start_req()
1202 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, -ENODATA); in dwc2_hsotg_start_req()
1209 dev_dbg(hsotg->dev, "ep0 state:%d\n", hsotg->ep0_state); in dwc2_hsotg_start_req()
1212 if (!(index == 0 && hsotg->ep0_state == DWC2_EP0_SETUP)) in dwc2_hsotg_start_req()
1215 dev_dbg(hsotg->dev, "%s: DxEPCTL=0x%08x\n", __func__, ctrl); in dwc2_hsotg_start_req()
1216 dwc2_writel(hsotg, ctrl, epctrl_reg); in dwc2_hsotg_start_req()
1226 if (dir_in && !using_dma(hsotg)) { in dwc2_hsotg_start_req()
1230 dwc2_hsotg_write_fifo(hsotg, hs_ep, hs_req); in dwc2_hsotg_start_req()
1239 if (!(dwc2_readl(hsotg, epctrl_reg) & DXEPCTL_EPENA)) in dwc2_hsotg_start_req()
1240 dev_dbg(hsotg->dev, in dwc2_hsotg_start_req()
1242 index, dwc2_readl(hsotg, epctrl_reg)); in dwc2_hsotg_start_req()
1244 dev_dbg(hsotg->dev, "%s: DXEPCTL=0x%08x\n", in dwc2_hsotg_start_req()
1245 __func__, dwc2_readl(hsotg, epctrl_reg)); in dwc2_hsotg_start_req()
1248 dwc2_hsotg_ctrl_epint(hsotg, hs_ep->index, hs_ep->dir_in, 1); in dwc2_hsotg_start_req()
1263 static int dwc2_hsotg_map_dma(struct dwc2_hsotg *hsotg, in dwc2_hsotg_map_dma() argument
1270 ret = usb_gadget_map_request(&hsotg->gadget, req, hs_ep->dir_in); in dwc2_hsotg_map_dma()
1277 dev_err(hsotg->dev, "%s: failed to map buffer %p, %d bytes\n", in dwc2_hsotg_map_dma()
1283 static int dwc2_hsotg_handle_unaligned_buf_start(struct dwc2_hsotg *hsotg, in dwc2_hsotg_handle_unaligned_buf_start() argument
1290 if (!using_dma(hsotg) || !((long)req_buf & 3)) in dwc2_hsotg_handle_unaligned_buf_start()
1295 dev_dbg(hsotg->dev, "%s: %s: buf=%p length=%d\n", __func__, in dwc2_hsotg_handle_unaligned_buf_start()
1301 dev_err(hsotg->dev, in dwc2_hsotg_handle_unaligned_buf_start()
1316 dwc2_hsotg_handle_unaligned_buf_complete(struct dwc2_hsotg *hsotg, in dwc2_hsotg_handle_unaligned_buf_complete() argument
1321 if (!using_dma(hsotg) || !hs_req->saved_req_buf) in dwc2_hsotg_handle_unaligned_buf_complete()
1324 dev_dbg(hsotg->dev, "%s: %s: status=%d actual-length=%d\n", __func__, in dwc2_hsotg_handle_unaligned_buf_complete()
1348 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_target_frame_elapsed() local
1350 u32 current_frame = hsotg->frame_number; in dwc2_gadget_target_frame_elapsed()
1354 if (hsotg->gadget.speed != USB_SPEED_HIGH) in dwc2_gadget_target_frame_elapsed()
1375 static int dwc2_gadget_set_ep0_desc_chain(struct dwc2_hsotg *hsotg, in dwc2_gadget_set_ep0_desc_chain() argument
1378 switch (hsotg->ep0_state) { in dwc2_gadget_set_ep0_desc_chain()
1381 hs_ep->desc_list = hsotg->setup_desc[0]; in dwc2_gadget_set_ep0_desc_chain()
1382 hs_ep->desc_list_dma = hsotg->setup_desc_dma[0]; in dwc2_gadget_set_ep0_desc_chain()
1386 hs_ep->desc_list = hsotg->ctrl_in_desc; in dwc2_gadget_set_ep0_desc_chain()
1387 hs_ep->desc_list_dma = hsotg->ctrl_in_desc_dma; in dwc2_gadget_set_ep0_desc_chain()
1390 hs_ep->desc_list = hsotg->ctrl_out_desc; in dwc2_gadget_set_ep0_desc_chain()
1391 hs_ep->desc_list_dma = hsotg->ctrl_out_desc_dma; in dwc2_gadget_set_ep0_desc_chain()
1394 dev_err(hsotg->dev, "invalid EP 0 state in queue %d\n", in dwc2_gadget_set_ep0_desc_chain()
1395 hsotg->ep0_state); in dwc2_gadget_set_ep0_desc_chain()
1561 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_hsotg_complete_oursetup() local
1563 dev_dbg(hsotg->dev, "%s: ep %p, req %p\n", __func__, ep, req); in dwc2_hsotg_complete_oursetup()
1576 static struct dwc2_hsotg_ep *ep_from_windex(struct dwc2_hsotg *hsotg, in ep_from_windex() argument
1585 if (idx > hsotg->num_of_eps) in ep_from_windex()
1588 return index_to_ep(hsotg, idx, dir); in ep_from_windex()
1597 int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode) in dwc2_hsotg_set_test_mode() argument
1599 int dctl = dwc2_readl(hsotg, DCTL); in dwc2_hsotg_set_test_mode()
1613 dwc2_writel(hsotg, dctl, DCTL); in dwc2_hsotg_set_test_mode()
1627 static int dwc2_hsotg_send_reply(struct dwc2_hsotg *hsotg, in dwc2_hsotg_send_reply() argument
1635 dev_dbg(hsotg->dev, "%s: buff %p, len %d\n", __func__, buff, length); in dwc2_hsotg_send_reply()
1638 hsotg->ep0_reply = req; in dwc2_hsotg_send_reply()
1640 dev_warn(hsotg->dev, "%s: cannot alloc req\n", __func__); in dwc2_hsotg_send_reply()
1644 req->buf = hsotg->ep0_buff; in dwc2_hsotg_send_reply()
1658 dev_warn(hsotg->dev, "%s: cannot queue req\n", __func__); in dwc2_hsotg_send_reply()
1670 static int dwc2_hsotg_process_req_status(struct dwc2_hsotg *hsotg, in dwc2_hsotg_process_req_status() argument
1673 struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0]; in dwc2_hsotg_process_req_status()
1679 dev_dbg(hsotg->dev, "%s: USB_REQ_GET_STATUS\n", __func__); in dwc2_hsotg_process_req_status()
1682 dev_warn(hsotg->dev, "%s: direction out?\n", __func__); in dwc2_hsotg_process_req_status()
1688 status = hsotg->gadget.is_selfpowered << in dwc2_hsotg_process_req_status()
1690 status |= hsotg->remote_wakeup_allowed << in dwc2_hsotg_process_req_status()
1701 ep = ep_from_windex(hsotg, le16_to_cpu(ctrl->wIndex)); in dwc2_hsotg_process_req_status()
1715 ret = dwc2_hsotg_send_reply(hsotg, ep0, &reply, 2); in dwc2_hsotg_process_req_status()
1717 dev_err(hsotg->dev, "%s: failed to send reply\n", __func__); in dwc2_hsotg_process_req_status()
1748 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_start_next_request() local
1754 dwc2_hsotg_start_req(hsotg, hs_ep, hs_req, false); in dwc2_gadget_start_next_request()
1761 dev_dbg(hsotg->dev, "%s: No more ISOC-IN requests\n", in dwc2_gadget_start_next_request()
1764 dev_dbg(hsotg->dev, "%s: No more ISOC-OUT requests\n", in dwc2_gadget_start_next_request()
1774 static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg, in dwc2_hsotg_process_req_feature() argument
1777 struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0]; in dwc2_hsotg_process_req_feature()
1787 dev_dbg(hsotg->dev, "%s: %s_FEATURE\n", in dwc2_hsotg_process_req_feature()
1799 hsotg->remote_wakeup_allowed = 1; in dwc2_hsotg_process_req_feature()
1801 hsotg->remote_wakeup_allowed = 0; in dwc2_hsotg_process_req_feature()
1810 hsotg->test_mode = wIndex >> 8; in dwc2_hsotg_process_req_feature()
1816 ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0); in dwc2_hsotg_process_req_feature()
1818 dev_err(hsotg->dev, in dwc2_hsotg_process_req_feature()
1825 ep = ep_from_windex(hsotg, wIndex); in dwc2_hsotg_process_req_feature()
1827 dev_dbg(hsotg->dev, "%s: no endpoint for 0x%04x\n", in dwc2_hsotg_process_req_feature()
1839 ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0); in dwc2_hsotg_process_req_feature()
1841 dev_err(hsotg->dev, in dwc2_hsotg_process_req_feature()
1861 spin_unlock(&hsotg->lock); in dwc2_hsotg_process_req_feature()
1864 spin_lock(&hsotg->lock); in dwc2_hsotg_process_req_feature()
1885 static void dwc2_hsotg_enqueue_setup(struct dwc2_hsotg *hsotg);
1893 static void dwc2_hsotg_stall_ep0(struct dwc2_hsotg *hsotg) in dwc2_hsotg_stall_ep0() argument
1895 struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0]; in dwc2_hsotg_stall_ep0()
1899 dev_dbg(hsotg->dev, "ep0 stall (dir=%d)\n", ep0->dir_in); in dwc2_hsotg_stall_ep0()
1907 ctrl = dwc2_readl(hsotg, reg); in dwc2_hsotg_stall_ep0()
1910 dwc2_writel(hsotg, ctrl, reg); in dwc2_hsotg_stall_ep0()
1912 dev_dbg(hsotg->dev, in dwc2_hsotg_stall_ep0()
1914 ctrl, reg, dwc2_readl(hsotg, reg)); in dwc2_hsotg_stall_ep0()
1920 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_stall_ep0()
1932 static void dwc2_hsotg_process_control(struct dwc2_hsotg *hsotg, in dwc2_hsotg_process_control() argument
1935 struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0]; in dwc2_hsotg_process_control()
1939 dev_dbg(hsotg->dev, in dwc2_hsotg_process_control()
1946 hsotg->ep0_state = DWC2_EP0_STATUS_IN; in dwc2_hsotg_process_control()
1949 hsotg->ep0_state = DWC2_EP0_DATA_IN; in dwc2_hsotg_process_control()
1952 hsotg->ep0_state = DWC2_EP0_DATA_OUT; in dwc2_hsotg_process_control()
1958 hsotg->connected = 1; in dwc2_hsotg_process_control()
1959 dcfg = dwc2_readl(hsotg, DCFG); in dwc2_hsotg_process_control()
1963 dwc2_writel(hsotg, dcfg, DCFG); in dwc2_hsotg_process_control()
1965 dev_info(hsotg->dev, "new address %d\n", ctrl->wValue); in dwc2_hsotg_process_control()
1967 ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0); in dwc2_hsotg_process_control()
1971 ret = dwc2_hsotg_process_req_status(hsotg, ctrl); in dwc2_hsotg_process_control()
1976 ret = dwc2_hsotg_process_req_feature(hsotg, ctrl); in dwc2_hsotg_process_control()
1983 if (ret == 0 && hsotg->driver) { in dwc2_hsotg_process_control()
1984 spin_unlock(&hsotg->lock); in dwc2_hsotg_process_control()
1985 ret = hsotg->driver->setup(&hsotg->gadget, ctrl); in dwc2_hsotg_process_control()
1986 spin_lock(&hsotg->lock); in dwc2_hsotg_process_control()
1988 dev_dbg(hsotg->dev, "driver->setup() ret %d\n", ret); in dwc2_hsotg_process_control()
1991 hsotg->delayed_status = false; in dwc2_hsotg_process_control()
1993 hsotg->delayed_status = true; in dwc2_hsotg_process_control()
2001 dwc2_hsotg_stall_ep0(hsotg); in dwc2_hsotg_process_control()
2016 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_hsotg_complete_setup() local
2019 dev_dbg(hsotg->dev, "%s: failed %d\n", __func__, req->status); in dwc2_hsotg_complete_setup()
2023 spin_lock(&hsotg->lock); in dwc2_hsotg_complete_setup()
2025 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_complete_setup()
2027 dwc2_hsotg_process_control(hsotg, req->buf); in dwc2_hsotg_complete_setup()
2028 spin_unlock(&hsotg->lock); in dwc2_hsotg_complete_setup()
2038 static void dwc2_hsotg_enqueue_setup(struct dwc2_hsotg *hsotg) in dwc2_hsotg_enqueue_setup() argument
2040 struct usb_request *req = hsotg->ctrl_req; in dwc2_hsotg_enqueue_setup()
2044 dev_dbg(hsotg->dev, "%s: queueing setup request\n", __func__); in dwc2_hsotg_enqueue_setup()
2048 req->buf = hsotg->ctrl_buff; in dwc2_hsotg_enqueue_setup()
2052 dev_dbg(hsotg->dev, "%s already queued???\n", __func__); in dwc2_hsotg_enqueue_setup()
2056 hsotg->eps_out[0]->dir_in = 0; in dwc2_hsotg_enqueue_setup()
2057 hsotg->eps_out[0]->send_zlp = 0; in dwc2_hsotg_enqueue_setup()
2058 hsotg->ep0_state = DWC2_EP0_SETUP; in dwc2_hsotg_enqueue_setup()
2060 ret = dwc2_hsotg_ep_queue(&hsotg->eps_out[0]->ep, req, GFP_ATOMIC); in dwc2_hsotg_enqueue_setup()
2062 dev_err(hsotg->dev, "%s: failed queue (%d)\n", __func__, ret); in dwc2_hsotg_enqueue_setup()
2070 static void dwc2_hsotg_program_zlp(struct dwc2_hsotg *hsotg, in dwc2_hsotg_program_zlp() argument
2079 dev_dbg(hsotg->dev, "Sending zero-length packet on ep%d\n", in dwc2_hsotg_program_zlp()
2082 dev_dbg(hsotg->dev, "Receiving zero-length packet on ep%d\n", in dwc2_hsotg_program_zlp()
2084 if (using_desc_dma(hsotg)) { in dwc2_hsotg_program_zlp()
2089 dwc2_gadget_set_ep0_desc_chain(hsotg, hs_ep); in dwc2_hsotg_program_zlp()
2093 dwc2_writel(hsotg, DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) | in dwc2_hsotg_program_zlp()
2098 ctrl = dwc2_readl(hsotg, epctl_reg); in dwc2_hsotg_program_zlp()
2102 dwc2_writel(hsotg, ctrl, epctl_reg); in dwc2_hsotg_program_zlp()
2118 static void dwc2_hsotg_complete_request(struct dwc2_hsotg *hsotg, in dwc2_hsotg_complete_request() argument
2124 dev_dbg(hsotg->dev, "%s: nothing to complete?\n", __func__); in dwc2_hsotg_complete_request()
2128 dev_dbg(hsotg->dev, "complete: ep %p %s, req %p, %d => %p\n", in dwc2_hsotg_complete_request()
2139 if (using_dma(hsotg)) in dwc2_hsotg_complete_request()
2140 dwc2_hsotg_unmap_dma(hsotg, hs_ep, hs_req); in dwc2_hsotg_complete_request()
2142 dwc2_hsotg_handle_unaligned_buf_complete(hsotg, hs_ep, hs_req); in dwc2_hsotg_complete_request()
2153 spin_unlock(&hsotg->lock); in dwc2_hsotg_complete_request()
2155 spin_lock(&hsotg->lock); in dwc2_hsotg_complete_request()
2159 if (using_desc_dma(hsotg) && hs_ep->isochronous) in dwc2_hsotg_complete_request()
2183 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_complete_isoc_request_ddma() local
2197 dev_warn(hsotg->dev, "%s: ISOC EP queue empty\n", __func__); in dwc2_gadget_complete_isoc_request_ddma()
2222 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0); in dwc2_gadget_complete_isoc_request_ddma()
2242 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_handle_isoc_bna() local
2245 dwc2_flush_rx_fifo(hsotg); in dwc2_gadget_handle_isoc_bna()
2246 dwc2_hsotg_complete_request(hsotg, hs_ep, get_ep_head(hs_ep), 0); in dwc2_gadget_handle_isoc_bna()
2263 static void dwc2_hsotg_rx_data(struct dwc2_hsotg *hsotg, int ep_idx, int size) in dwc2_hsotg_rx_data() argument
2265 struct dwc2_hsotg_ep *hs_ep = hsotg->eps_out[ep_idx]; in dwc2_hsotg_rx_data()
2272 u32 epctl = dwc2_readl(hsotg, DOEPCTL(ep_idx)); in dwc2_hsotg_rx_data()
2275 dev_dbg(hsotg->dev, in dwc2_hsotg_rx_data()
2281 (void)dwc2_readl(hsotg, EPFIFO(ep_idx)); in dwc2_hsotg_rx_data()
2290 dev_dbg(hsotg->dev, "%s: read %d/%d, done %d/%d\n", in dwc2_hsotg_rx_data()
2311 dwc2_readl_rep(hsotg, EPFIFO(ep_idx), in dwc2_hsotg_rx_data()
2327 static void dwc2_hsotg_ep0_zlp(struct dwc2_hsotg *hsotg, bool dir_in) in dwc2_hsotg_ep0_zlp() argument
2330 hsotg->eps_out[0]->dir_in = dir_in; in dwc2_hsotg_ep0_zlp()
2331 hsotg->ep0_state = dir_in ? DWC2_EP0_STATUS_IN : DWC2_EP0_STATUS_OUT; in dwc2_hsotg_ep0_zlp()
2333 dwc2_hsotg_program_zlp(hsotg, hsotg->eps_out[0]); in dwc2_hsotg_ep0_zlp()
2346 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_get_xfersize_ddma() local
2369 dev_err(hsotg->dev, "descriptor %d closed with %x\n", in dwc2_gadget_get_xfersize_ddma()
2390 static void dwc2_hsotg_handle_outdone(struct dwc2_hsotg *hsotg, int epnum) in dwc2_hsotg_handle_outdone() argument
2392 u32 epsize = dwc2_readl(hsotg, DOEPTSIZ(epnum)); in dwc2_hsotg_handle_outdone()
2393 struct dwc2_hsotg_ep *hs_ep = hsotg->eps_out[epnum]; in dwc2_hsotg_handle_outdone()
2400 dev_dbg(hsotg->dev, "%s: no request active\n", __func__); in dwc2_hsotg_handle_outdone()
2404 if (epnum == 0 && hsotg->ep0_state == DWC2_EP0_STATUS_OUT) { in dwc2_hsotg_handle_outdone()
2405 dev_dbg(hsotg->dev, "zlp packet received\n"); in dwc2_hsotg_handle_outdone()
2406 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0); in dwc2_hsotg_handle_outdone()
2407 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_handle_outdone()
2411 if (using_desc_dma(hsotg)) in dwc2_hsotg_handle_outdone()
2414 if (using_dma(hsotg)) { in dwc2_hsotg_handle_outdone()
2434 dwc2_hsotg_start_req(hsotg, hs_ep, hs_req, true); in dwc2_hsotg_handle_outdone()
2439 dev_dbg(hsotg->dev, "%s: got %d/%d (short not ok) => error\n", in dwc2_hsotg_handle_outdone()
2449 if (!using_desc_dma(hsotg) && epnum == 0 && in dwc2_hsotg_handle_outdone()
2450 hsotg->ep0_state == DWC2_EP0_DATA_OUT) { in dwc2_hsotg_handle_outdone()
2452 if (!hsotg->delayed_status) in dwc2_hsotg_handle_outdone()
2453 dwc2_hsotg_ep0_zlp(hsotg, true); in dwc2_hsotg_handle_outdone()
2457 if (!using_desc_dma(hsotg) && hs_ep->isochronous) { in dwc2_hsotg_handle_outdone()
2462 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, result); in dwc2_hsotg_handle_outdone()
2481 static void dwc2_hsotg_handle_rx(struct dwc2_hsotg *hsotg) in dwc2_hsotg_handle_rx() argument
2483 u32 grxstsr = dwc2_readl(hsotg, GRXSTSP); in dwc2_hsotg_handle_rx()
2486 WARN_ON(using_dma(hsotg)); in dwc2_hsotg_handle_rx()
2494 dev_dbg(hsotg->dev, "%s: GRXSTSP=0x%08x (%d@%d)\n", in dwc2_hsotg_handle_rx()
2499 dev_dbg(hsotg->dev, "GLOBALOUTNAK\n"); in dwc2_hsotg_handle_rx()
2503 dev_dbg(hsotg->dev, "OutDone (Frame=0x%08x)\n", in dwc2_hsotg_handle_rx()
2504 dwc2_hsotg_read_frameno(hsotg)); in dwc2_hsotg_handle_rx()
2506 if (!using_dma(hsotg)) in dwc2_hsotg_handle_rx()
2507 dwc2_hsotg_handle_outdone(hsotg, epnum); in dwc2_hsotg_handle_rx()
2511 dev_dbg(hsotg->dev, in dwc2_hsotg_handle_rx()
2513 dwc2_hsotg_read_frameno(hsotg), in dwc2_hsotg_handle_rx()
2514 dwc2_readl(hsotg, DOEPCTL(0))); in dwc2_hsotg_handle_rx()
2520 if (hsotg->ep0_state == DWC2_EP0_SETUP) in dwc2_hsotg_handle_rx()
2521 dwc2_hsotg_handle_outdone(hsotg, epnum); in dwc2_hsotg_handle_rx()
2525 dwc2_hsotg_rx_data(hsotg, epnum, size); in dwc2_hsotg_handle_rx()
2529 dev_dbg(hsotg->dev, in dwc2_hsotg_handle_rx()
2531 dwc2_hsotg_read_frameno(hsotg), in dwc2_hsotg_handle_rx()
2532 dwc2_readl(hsotg, DOEPCTL(0))); in dwc2_hsotg_handle_rx()
2534 WARN_ON(hsotg->ep0_state != DWC2_EP0_SETUP); in dwc2_hsotg_handle_rx()
2536 dwc2_hsotg_rx_data(hsotg, epnum, size); in dwc2_hsotg_handle_rx()
2540 dev_warn(hsotg->dev, "%s: unknown status %08x\n", in dwc2_hsotg_handle_rx()
2543 dwc2_hsotg_dump(hsotg); in dwc2_hsotg_handle_rx()
2581 static void dwc2_hsotg_set_ep_maxpacket(struct dwc2_hsotg *hsotg, in dwc2_hsotg_set_ep_maxpacket() argument
2588 hs_ep = index_to_ep(hsotg, ep, dir_in); in dwc2_hsotg_set_ep_maxpacket()
2611 reg = dwc2_readl(hsotg, DIEPCTL(ep)); in dwc2_hsotg_set_ep_maxpacket()
2614 dwc2_writel(hsotg, reg, DIEPCTL(ep)); in dwc2_hsotg_set_ep_maxpacket()
2616 reg = dwc2_readl(hsotg, DOEPCTL(ep)); in dwc2_hsotg_set_ep_maxpacket()
2619 dwc2_writel(hsotg, reg, DOEPCTL(ep)); in dwc2_hsotg_set_ep_maxpacket()
2625 dev_err(hsotg->dev, "ep%d: bad mps of %d\n", ep, mps); in dwc2_hsotg_set_ep_maxpacket()
2633 static void dwc2_hsotg_txfifo_flush(struct dwc2_hsotg *hsotg, unsigned int idx) in dwc2_hsotg_txfifo_flush() argument
2635 dwc2_writel(hsotg, GRSTCTL_TXFNUM(idx) | GRSTCTL_TXFFLSH, in dwc2_hsotg_txfifo_flush()
2639 if (dwc2_hsotg_wait_bit_clear(hsotg, GRSTCTL, GRSTCTL_TXFFLSH, 100)) in dwc2_hsotg_txfifo_flush()
2640 dev_warn(hsotg->dev, "%s: timeout flushing fifo GRSTCTL_TXFFLSH\n", in dwc2_hsotg_txfifo_flush()
2652 static int dwc2_hsotg_trytx(struct dwc2_hsotg *hsotg, in dwc2_hsotg_trytx() argument
2663 dwc2_hsotg_ctrl_epint(hsotg, hs_ep->index, in dwc2_hsotg_trytx()
2669 dev_dbg(hsotg->dev, "trying to write more for ep%d\n", in dwc2_hsotg_trytx()
2671 return dwc2_hsotg_write_fifo(hsotg, hs_ep, hs_req); in dwc2_hsotg_trytx()
2685 static void dwc2_hsotg_complete_in(struct dwc2_hsotg *hsotg, in dwc2_hsotg_complete_in() argument
2689 u32 epsize = dwc2_readl(hsotg, DIEPTSIZ(hs_ep->index)); in dwc2_hsotg_complete_in()
2693 dev_dbg(hsotg->dev, "XferCompl but no req\n"); in dwc2_hsotg_complete_in()
2698 if (hs_ep->index == 0 && hsotg->ep0_state == DWC2_EP0_STATUS_IN) { in dwc2_hsotg_complete_in()
2699 dev_dbg(hsotg->dev, "zlp packet sent\n"); in dwc2_hsotg_complete_in()
2707 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0); in dwc2_hsotg_complete_in()
2708 if (hsotg->test_mode) { in dwc2_hsotg_complete_in()
2711 ret = dwc2_hsotg_set_test_mode(hsotg, hsotg->test_mode); in dwc2_hsotg_complete_in()
2713 dev_dbg(hsotg->dev, "Invalid Test #%d\n", in dwc2_hsotg_complete_in()
2714 hsotg->test_mode); in dwc2_hsotg_complete_in()
2715 dwc2_hsotg_stall_ep0(hsotg); in dwc2_hsotg_complete_in()
2719 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_complete_in()
2732 if (using_desc_dma(hsotg)) { in dwc2_hsotg_complete_in()
2735 dev_err(hsotg->dev, "error parsing DDMA results %d\n", in dwc2_hsotg_complete_in()
2745 dev_dbg(hsotg->dev, "%s: adjusting size done %d => %d\n", in dwc2_hsotg_complete_in()
2749 dev_dbg(hsotg->dev, "req->length:%d req->actual:%d req->zero:%d\n", in dwc2_hsotg_complete_in()
2753 dev_dbg(hsotg->dev, "%s trying more for req...\n", __func__); in dwc2_hsotg_complete_in()
2754 dwc2_hsotg_start_req(hsotg, hs_ep, hs_req, true); in dwc2_hsotg_complete_in()
2761 if (!using_desc_dma(hsotg)) { in dwc2_hsotg_complete_in()
2762 dwc2_hsotg_program_zlp(hsotg, hs_ep); in dwc2_hsotg_complete_in()
2768 if (hs_ep->index == 0 && hsotg->ep0_state == DWC2_EP0_DATA_IN) { in dwc2_hsotg_complete_in()
2770 dwc2_hsotg_ep0_zlp(hsotg, false); in dwc2_hsotg_complete_in()
2775 if (!using_desc_dma(hsotg) && hs_ep->isochronous) { in dwc2_hsotg_complete_in()
2780 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0); in dwc2_hsotg_complete_in()
2792 static u32 dwc2_gadget_read_ep_interrupts(struct dwc2_hsotg *hsotg, in dwc2_gadget_read_ep_interrupts() argument
2801 mask = dwc2_readl(hsotg, epmsk_reg); in dwc2_gadget_read_ep_interrupts()
2802 diepempmsk = dwc2_readl(hsotg, DIEPEMPMSK); in dwc2_gadget_read_ep_interrupts()
2806 ints = dwc2_readl(hsotg, epint_reg); in dwc2_gadget_read_ep_interrupts()
2826 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_handle_ep_disabled() local
2831 int dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_handle_ep_disabled()
2833 dev_dbg(hsotg->dev, "%s: EPDisbld\n", __func__); in dwc2_gadget_handle_ep_disabled()
2836 int epctl = dwc2_readl(hsotg, epctl_reg); in dwc2_gadget_handle_ep_disabled()
2838 dwc2_hsotg_txfifo_flush(hsotg, hs_ep->fifo_index); in dwc2_gadget_handle_ep_disabled()
2841 int dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_handle_ep_disabled()
2844 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_handle_ep_disabled()
2850 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_handle_ep_disabled()
2858 dev_dbg(hsotg->dev, "%s: complete_ep 0x%p, ep->queue empty!\n", in dwc2_gadget_handle_ep_disabled()
2868 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, in dwc2_gadget_handle_ep_disabled()
2873 hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg); in dwc2_gadget_handle_ep_disabled()
2890 struct dwc2_hsotg *hsotg = ep->parent; in dwc2_gadget_handle_out_token_ep_disabled() local
2897 if (using_desc_dma(hsotg)) { in dwc2_gadget_handle_out_token_ep_disabled()
2900 ep->target_frame = hsotg->frame_number; in dwc2_gadget_handle_out_token_ep_disabled()
2909 ep->target_frame = hsotg->frame_number; in dwc2_gadget_handle_out_token_ep_disabled()
2911 ctrl = dwc2_readl(hsotg, DOEPCTL(ep->index)); in dwc2_gadget_handle_out_token_ep_disabled()
2917 dwc2_writel(hsotg, ctrl, DOEPCTL(ep->index)); in dwc2_gadget_handle_out_token_ep_disabled()
2926 dwc2_hsotg_complete_request(hsotg, ep, hs_req, -ENODATA); in dwc2_gadget_handle_out_token_ep_disabled()
2931 hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg); in dwc2_gadget_handle_out_token_ep_disabled()
2939 static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg,
2958 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_handle_nak() local
2968 if (using_desc_dma(hsotg)) { in dwc2_gadget_handle_nak()
2969 hs_ep->target_frame = hsotg->frame_number; in dwc2_gadget_handle_nak()
2975 if (hsotg->params.service_interval) { in dwc2_gadget_handle_nak()
2992 hs_ep->target_frame = hsotg->frame_number; in dwc2_gadget_handle_nak()
2994 u32 ctrl = dwc2_readl(hsotg, in dwc2_gadget_handle_nak()
3001 dwc2_writel(hsotg, ctrl, DIEPCTL(hs_ep->index)); in dwc2_gadget_handle_nak()
3005 if (using_desc_dma(hsotg)) in dwc2_gadget_handle_nak()
3008 ctrl = dwc2_readl(hsotg, DIEPCTL(hs_ep->index)); in dwc2_gadget_handle_nak()
3010 dwc2_hsotg_ep_stop_xfr(hsotg, hs_ep); in dwc2_gadget_handle_nak()
3012 dwc2_hsotg_txfifo_flush(hsotg, hs_ep->fifo_index); in dwc2_gadget_handle_nak()
3019 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, -ENODATA); in dwc2_gadget_handle_nak()
3024 hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg); in dwc2_gadget_handle_nak()
3039 static void dwc2_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, in dwc2_hsotg_epint() argument
3042 struct dwc2_hsotg_ep *hs_ep = index_to_ep(hsotg, idx, dir_in); in dwc2_hsotg_epint()
3048 ints = dwc2_gadget_read_ep_interrupts(hsotg, idx, dir_in); in dwc2_hsotg_epint()
3051 dwc2_writel(hsotg, ints, epint_reg); in dwc2_hsotg_epint()
3054 dev_err(hsotg->dev, "%s:Interrupt for unconfigured ep%d(%s)\n", in dwc2_hsotg_epint()
3059 dev_dbg(hsotg->dev, "%s: ep%d(%s) DxEPINT=0x%08x\n", in dwc2_hsotg_epint()
3072 if (using_desc_dma(hsotg) && idx == 0 && !hs_ep->dir_in && in dwc2_hsotg_epint()
3073 hsotg->ep0_state == DWC2_EP0_SETUP && !(ints & DXEPINT_SETUP)) in dwc2_hsotg_epint()
3077 dev_dbg(hsotg->dev, in dwc2_hsotg_epint()
3079 __func__, dwc2_readl(hsotg, epctl_reg), in dwc2_hsotg_epint()
3080 dwc2_readl(hsotg, epsiz_reg)); in dwc2_hsotg_epint()
3083 if (using_desc_dma(hsotg) && hs_ep->isochronous) { in dwc2_hsotg_epint()
3092 dwc2_hsotg_complete_in(hsotg, hs_ep); in dwc2_hsotg_epint()
3095 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_epint()
3096 } else if (using_dma(hsotg)) { in dwc2_hsotg_epint()
3102 dwc2_hsotg_handle_outdone(hsotg, idx); in dwc2_hsotg_epint()
3116 dev_dbg(hsotg->dev, "%s: AHBErr\n", __func__); in dwc2_hsotg_epint()
3119 dev_dbg(hsotg->dev, "%s: Setup/Timeout\n", __func__); in dwc2_hsotg_epint()
3121 if (using_dma(hsotg) && idx == 0) { in dwc2_hsotg_epint()
3132 dwc2_hsotg_handle_outdone(hsotg, 0); in dwc2_hsotg_epint()
3137 dev_dbg(hsotg->dev, "%s: StsPhseRcvd\n", __func__); in dwc2_hsotg_epint()
3140 if (hsotg->ep0_state == DWC2_EP0_DATA_OUT) { in dwc2_hsotg_epint()
3142 if (using_desc_dma(hsotg)) { in dwc2_hsotg_epint()
3143 if (!hsotg->delayed_status) in dwc2_hsotg_epint()
3144 dwc2_hsotg_ep0_zlp(hsotg, true); in dwc2_hsotg_epint()
3153 dwc2_set_bit(hsotg, DIEPCTL(0), in dwc2_hsotg_epint()
3161 dev_dbg(hsotg->dev, "%s: B2BSetup/INEPNakEff\n", __func__); in dwc2_hsotg_epint()
3164 dev_dbg(hsotg->dev, "%s: BNA interrupt\n", __func__); in dwc2_hsotg_epint()
3172 dev_dbg(hsotg->dev, "%s: ep%d: INTknTXFEmpMsk\n", in dwc2_hsotg_epint()
3178 dev_warn(hsotg->dev, "%s: ep%d: INTknEP\n", in dwc2_hsotg_epint()
3183 if (hsotg->dedicated_fifos && in dwc2_hsotg_epint()
3185 dev_dbg(hsotg->dev, "%s: ep%d: TxFIFOEmpty\n", in dwc2_hsotg_epint()
3187 if (!using_dma(hsotg)) in dwc2_hsotg_epint()
3188 dwc2_hsotg_trytx(hsotg, hs_ep); in dwc2_hsotg_epint()
3200 static void dwc2_hsotg_irq_enumdone(struct dwc2_hsotg *hsotg) in dwc2_hsotg_irq_enumdone() argument
3202 u32 dsts = dwc2_readl(hsotg, DSTS); in dwc2_hsotg_irq_enumdone()
3211 dev_dbg(hsotg->dev, "EnumDone (DSTS=0x%08x)\n", dsts); in dwc2_hsotg_irq_enumdone()
3223 hsotg->gadget.speed = USB_SPEED_FULL; in dwc2_hsotg_irq_enumdone()
3229 hsotg->gadget.speed = USB_SPEED_HIGH; in dwc2_hsotg_irq_enumdone()
3235 hsotg->gadget.speed = USB_SPEED_LOW; in dwc2_hsotg_irq_enumdone()
3245 dev_info(hsotg->dev, "new device is %s\n", in dwc2_hsotg_irq_enumdone()
3246 usb_speed_string(hsotg->gadget.speed)); in dwc2_hsotg_irq_enumdone()
3256 dwc2_hsotg_set_ep_maxpacket(hsotg, 0, ep0_mps, 0, 1); in dwc2_hsotg_irq_enumdone()
3257 dwc2_hsotg_set_ep_maxpacket(hsotg, 0, ep0_mps, 0, 0); in dwc2_hsotg_irq_enumdone()
3258 for (i = 1; i < hsotg->num_of_eps; i++) { in dwc2_hsotg_irq_enumdone()
3259 if (hsotg->eps_in[i]) in dwc2_hsotg_irq_enumdone()
3260 dwc2_hsotg_set_ep_maxpacket(hsotg, i, ep_mps, in dwc2_hsotg_irq_enumdone()
3262 if (hsotg->eps_out[i]) in dwc2_hsotg_irq_enumdone()
3263 dwc2_hsotg_set_ep_maxpacket(hsotg, i, ep_mps, in dwc2_hsotg_irq_enumdone()
3270 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_irq_enumdone()
3272 dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", in dwc2_hsotg_irq_enumdone()
3273 dwc2_readl(hsotg, DIEPCTL0), in dwc2_hsotg_irq_enumdone()
3274 dwc2_readl(hsotg, DOEPCTL0)); in dwc2_hsotg_irq_enumdone()
3286 static void kill_all_requests(struct dwc2_hsotg *hsotg, in kill_all_requests() argument
3297 dwc2_hsotg_complete_request(hsotg, ep, req, result); in kill_all_requests()
3300 if (!hsotg->dedicated_fifos) in kill_all_requests()
3302 size = (dwc2_readl(hsotg, DTXFSTS(ep->fifo_index)) & 0xffff) * 4; in kill_all_requests()
3304 dwc2_hsotg_txfifo_flush(hsotg, ep->fifo_index); in kill_all_requests()
3315 void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg) in dwc2_hsotg_disconnect() argument
3319 if (!hsotg->connected) in dwc2_hsotg_disconnect()
3322 hsotg->connected = 0; in dwc2_hsotg_disconnect()
3323 hsotg->test_mode = 0; in dwc2_hsotg_disconnect()
3326 for (ep = 0; ep < hsotg->num_of_eps; ep++) { in dwc2_hsotg_disconnect()
3327 if (hsotg->eps_in[ep]) in dwc2_hsotg_disconnect()
3328 kill_all_requests(hsotg, hsotg->eps_in[ep], in dwc2_hsotg_disconnect()
3330 if (hsotg->eps_out[ep]) in dwc2_hsotg_disconnect()
3331 kill_all_requests(hsotg, hsotg->eps_out[ep], in dwc2_hsotg_disconnect()
3335 call_gadget(hsotg, disconnect); in dwc2_hsotg_disconnect()
3336 hsotg->lx_state = DWC2_L3; in dwc2_hsotg_disconnect()
3338 usb_gadget_set_state(&hsotg->gadget, USB_STATE_NOTATTACHED); in dwc2_hsotg_disconnect()
3346 static void dwc2_hsotg_irq_fifoempty(struct dwc2_hsotg *hsotg, bool periodic) in dwc2_hsotg_irq_fifoempty() argument
3352 for (epno = 0; epno < hsotg->num_of_eps; epno++) { in dwc2_hsotg_irq_fifoempty()
3353 ep = index_to_ep(hsotg, epno, 1); in dwc2_hsotg_irq_fifoempty()
3365 ret = dwc2_hsotg_trytx(hsotg, ep); in dwc2_hsotg_irq_fifoempty()
3384 void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, in dwc2_hsotg_core_init_disconnected() argument
3394 kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET); in dwc2_hsotg_core_init_disconnected()
3397 if (dwc2_core_reset(hsotg, true)) in dwc2_hsotg_core_init_disconnected()
3401 for (ep = 1; ep < hsotg->num_of_eps; ep++) { in dwc2_hsotg_core_init_disconnected()
3402 if (hsotg->eps_in[ep]) in dwc2_hsotg_core_init_disconnected()
3403 dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep); in dwc2_hsotg_core_init_disconnected()
3404 if (hsotg->eps_out[ep]) in dwc2_hsotg_core_init_disconnected()
3405 dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep); in dwc2_hsotg_core_init_disconnected()
3415 usbcfg = dwc2_readl(hsotg, GUSBCFG); in dwc2_hsotg_core_init_disconnected()
3421 dwc2_writel(hsotg, usbcfg, GUSBCFG); in dwc2_hsotg_core_init_disconnected()
3423 dwc2_phy_init(hsotg, true); in dwc2_hsotg_core_init_disconnected()
3425 dwc2_hsotg_init_fifo(hsotg); in dwc2_hsotg_core_init_disconnected()
3428 dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON); in dwc2_hsotg_core_init_disconnected()
3432 switch (hsotg->params.speed) { in dwc2_hsotg_core_init_disconnected()
3437 if (hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM_FS) in dwc2_hsotg_core_init_disconnected()
3446 if (hsotg->params.ipg_isoc_en) in dwc2_hsotg_core_init_disconnected()
3449 dwc2_writel(hsotg, dcfg, DCFG); in dwc2_hsotg_core_init_disconnected()
3452 dwc2_writel(hsotg, 0xffffffff, GOTGINT); in dwc2_hsotg_core_init_disconnected()
3455 dwc2_writel(hsotg, 0xffffffff, GINTSTS); in dwc2_hsotg_core_init_disconnected()
3463 if (!using_desc_dma(hsotg)) in dwc2_hsotg_core_init_disconnected()
3466 if (!hsotg->params.external_id_pin_ctl) in dwc2_hsotg_core_init_disconnected()
3469 dwc2_writel(hsotg, intmsk, GINTMSK); in dwc2_hsotg_core_init_disconnected()
3471 if (using_dma(hsotg)) { in dwc2_hsotg_core_init_disconnected()
3472 dwc2_writel(hsotg, GAHBCFG_GLBL_INTR_EN | GAHBCFG_DMA_EN | in dwc2_hsotg_core_init_disconnected()
3473 hsotg->params.ahbcfg, in dwc2_hsotg_core_init_disconnected()
3477 if (using_desc_dma(hsotg)) in dwc2_hsotg_core_init_disconnected()
3478 dwc2_set_bit(hsotg, DCFG, DCFG_DESCDMA_EN); in dwc2_hsotg_core_init_disconnected()
3481 dwc2_writel(hsotg, ((hsotg->dedicated_fifos) ? in dwc2_hsotg_core_init_disconnected()
3493 dwc2_writel(hsotg, ((hsotg->dedicated_fifos && !using_dma(hsotg)) ? in dwc2_hsotg_core_init_disconnected()
3503 dwc2_writel(hsotg, (using_dma(hsotg) ? (DIEPMSK_XFERCOMPLMSK | in dwc2_hsotg_core_init_disconnected()
3510 if (using_desc_dma(hsotg)) { in dwc2_hsotg_core_init_disconnected()
3511 dwc2_set_bit(hsotg, DOEPMSK, DOEPMSK_BNAMSK); in dwc2_hsotg_core_init_disconnected()
3512 dwc2_set_bit(hsotg, DIEPMSK, DIEPMSK_BNAININTRMSK); in dwc2_hsotg_core_init_disconnected()
3516 if (using_desc_dma(hsotg) && hsotg->params.service_interval) in dwc2_hsotg_core_init_disconnected()
3517 dwc2_set_bit(hsotg, DCTL, DCTL_SERVICE_INTERVAL_SUPPORTED); in dwc2_hsotg_core_init_disconnected()
3519 dwc2_writel(hsotg, 0, DAINTMSK); in dwc2_hsotg_core_init_disconnected()
3521 dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", in dwc2_hsotg_core_init_disconnected()
3522 dwc2_readl(hsotg, DIEPCTL0), in dwc2_hsotg_core_init_disconnected()
3523 dwc2_readl(hsotg, DOEPCTL0)); in dwc2_hsotg_core_init_disconnected()
3526 dwc2_hsotg_en_gsint(hsotg, GINTSTS_OEPINT | GINTSTS_IEPINT); in dwc2_hsotg_core_init_disconnected()
3533 if (!using_dma(hsotg)) in dwc2_hsotg_core_init_disconnected()
3534 dwc2_hsotg_en_gsint(hsotg, GINTSTS_RXFLVL); in dwc2_hsotg_core_init_disconnected()
3537 dwc2_hsotg_ctrl_epint(hsotg, 0, 0, 1); in dwc2_hsotg_core_init_disconnected()
3538 dwc2_hsotg_ctrl_epint(hsotg, 0, 1, 1); in dwc2_hsotg_core_init_disconnected()
3541 dwc2_set_bit(hsotg, DCTL, DCTL_PWRONPRGDONE); in dwc2_hsotg_core_init_disconnected()
3543 dwc2_clear_bit(hsotg, DCTL, DCTL_PWRONPRGDONE); in dwc2_hsotg_core_init_disconnected()
3546 dev_dbg(hsotg->dev, "DCTL=0x%08x\n", dwc2_readl(hsotg, DCTL)); in dwc2_hsotg_core_init_disconnected()
3554 dwc2_writel(hsotg, DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) | in dwc2_hsotg_core_init_disconnected()
3557 dwc2_writel(hsotg, dwc2_hsotg_ep0_mps(hsotg->eps_out[0]->ep.maxpacket) | in dwc2_hsotg_core_init_disconnected()
3563 dwc2_writel(hsotg, dwc2_hsotg_ep0_mps(hsotg->eps_out[0]->ep.maxpacket) | in dwc2_hsotg_core_init_disconnected()
3570 dwc2_set_bit(hsotg, DCTL, val); in dwc2_hsotg_core_init_disconnected()
3573 dwc2_gadget_init_lpm(hsotg); in dwc2_hsotg_core_init_disconnected()
3576 if (using_desc_dma(hsotg) && hsotg->params.service_interval) in dwc2_hsotg_core_init_disconnected()
3577 dwc2_gadget_program_ref_clk(hsotg); in dwc2_hsotg_core_init_disconnected()
3582 hsotg->lx_state = DWC2_L0; in dwc2_hsotg_core_init_disconnected()
3584 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_core_init_disconnected()
3586 dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", in dwc2_hsotg_core_init_disconnected()
3587 dwc2_readl(hsotg, DIEPCTL0), in dwc2_hsotg_core_init_disconnected()
3588 dwc2_readl(hsotg, DOEPCTL0)); in dwc2_hsotg_core_init_disconnected()
3591 void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) in dwc2_hsotg_core_disconnect() argument
3594 dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON); in dwc2_hsotg_core_disconnect()
3597 void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg) in dwc2_hsotg_core_connect() argument
3600 if (!hsotg->role_sw || (dwc2_readl(hsotg, GOTGCTL) & GOTGCTL_BSESVLD)) in dwc2_hsotg_core_connect()
3601 dwc2_clear_bit(hsotg, DCTL, DCTL_SFTDISCON); in dwc2_hsotg_core_connect()
3617 static void dwc2_gadget_handle_incomplete_isoc_in(struct dwc2_hsotg *hsotg) in dwc2_gadget_handle_incomplete_isoc_in() argument
3624 dev_dbg(hsotg->dev, "Incomplete isoc in interrupt received:\n"); in dwc2_gadget_handle_incomplete_isoc_in()
3626 daintmsk = dwc2_readl(hsotg, DAINTMSK); in dwc2_gadget_handle_incomplete_isoc_in()
3628 for (idx = 1; idx < hsotg->num_of_eps; idx++) { in dwc2_gadget_handle_incomplete_isoc_in()
3629 hs_ep = hsotg->eps_in[idx]; in dwc2_gadget_handle_incomplete_isoc_in()
3634 epctrl = dwc2_readl(hsotg, DIEPCTL(idx)); in dwc2_gadget_handle_incomplete_isoc_in()
3639 dwc2_writel(hsotg, epctrl, DIEPCTL(idx)); in dwc2_gadget_handle_incomplete_isoc_in()
3644 dwc2_writel(hsotg, GINTSTS_INCOMPL_SOIN, GINTSTS); in dwc2_gadget_handle_incomplete_isoc_in()
3660 static void dwc2_gadget_handle_incomplete_isoc_out(struct dwc2_hsotg *hsotg) in dwc2_gadget_handle_incomplete_isoc_out() argument
3669 dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOOUT\n", __func__); in dwc2_gadget_handle_incomplete_isoc_out()
3671 daintmsk = dwc2_readl(hsotg, DAINTMSK); in dwc2_gadget_handle_incomplete_isoc_out()
3674 for (idx = 1; idx < hsotg->num_of_eps; idx++) { in dwc2_gadget_handle_incomplete_isoc_out()
3675 hs_ep = hsotg->eps_out[idx]; in dwc2_gadget_handle_incomplete_isoc_out()
3680 epctrl = dwc2_readl(hsotg, DOEPCTL(idx)); in dwc2_gadget_handle_incomplete_isoc_out()
3684 gintmsk = dwc2_readl(hsotg, GINTMSK); in dwc2_gadget_handle_incomplete_isoc_out()
3686 dwc2_writel(hsotg, gintmsk, GINTMSK); in dwc2_gadget_handle_incomplete_isoc_out()
3688 gintsts = dwc2_readl(hsotg, GINTSTS); in dwc2_gadget_handle_incomplete_isoc_out()
3690 dwc2_set_bit(hsotg, DCTL, DCTL_SGOUTNAK); in dwc2_gadget_handle_incomplete_isoc_out()
3697 dwc2_writel(hsotg, GINTSTS_INCOMPL_SOOUT, GINTSTS); in dwc2_gadget_handle_incomplete_isoc_out()
3707 struct dwc2_hsotg *hsotg = pw; in dwc2_hsotg_irq() local
3712 if (!dwc2_is_device_mode(hsotg)) in dwc2_hsotg_irq()
3715 spin_lock(&hsotg->lock); in dwc2_hsotg_irq()
3717 gintsts = dwc2_readl(hsotg, GINTSTS); in dwc2_hsotg_irq()
3718 gintmsk = dwc2_readl(hsotg, GINTMSK); in dwc2_hsotg_irq()
3720 dev_dbg(hsotg->dev, "%s: %08x %08x (%08x) retry %d\n", in dwc2_hsotg_irq()
3726 dev_dbg(hsotg->dev, "%s: USBRstDet\n", __func__); in dwc2_hsotg_irq()
3728 dwc2_writel(hsotg, GINTSTS_RESETDET, GINTSTS); in dwc2_hsotg_irq()
3731 if (hsotg->in_ppd && hsotg->lx_state == DWC2_L2) in dwc2_hsotg_irq()
3732 dwc2_exit_partial_power_down(hsotg, 0, true); in dwc2_hsotg_irq()
3735 if (hsotg->params.power_down == in dwc2_hsotg_irq()
3736 DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && in dwc2_hsotg_irq()
3737 !hsotg->params.no_clock_gating) in dwc2_hsotg_irq()
3738 dwc2_gadget_exit_clock_gating(hsotg, 0); in dwc2_hsotg_irq()
3740 hsotg->lx_state = DWC2_L0; in dwc2_hsotg_irq()
3744 u32 usb_status = dwc2_readl(hsotg, GOTGCTL); in dwc2_hsotg_irq()
3745 u32 connected = hsotg->connected; in dwc2_hsotg_irq()
3747 dev_dbg(hsotg->dev, "%s: USBRst\n", __func__); in dwc2_hsotg_irq()
3748 dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n", in dwc2_hsotg_irq()
3749 dwc2_readl(hsotg, GNPTXSTS)); in dwc2_hsotg_irq()
3751 dwc2_writel(hsotg, GINTSTS_USBRST, GINTSTS); in dwc2_hsotg_irq()
3754 dwc2_hsotg_disconnect(hsotg); in dwc2_hsotg_irq()
3757 dwc2_clear_bit(hsotg, DCFG, DCFG_DEVADDR_MASK); in dwc2_hsotg_irq()
3760 dwc2_hsotg_core_init_disconnected(hsotg, true); in dwc2_hsotg_irq()
3764 dwc2_writel(hsotg, GINTSTS_ENUMDONE, GINTSTS); in dwc2_hsotg_irq()
3766 dwc2_hsotg_irq_enumdone(hsotg); in dwc2_hsotg_irq()
3770 u32 daint = dwc2_readl(hsotg, DAINT); in dwc2_hsotg_irq()
3771 u32 daintmsk = dwc2_readl(hsotg, DAINTMSK); in dwc2_hsotg_irq()
3779 dev_dbg(hsotg->dev, "%s: daint=%08x\n", __func__, daint); in dwc2_hsotg_irq()
3781 for (ep = 0; ep < hsotg->num_of_eps && daint_out; in dwc2_hsotg_irq()
3784 dwc2_hsotg_epint(hsotg, ep, 0); in dwc2_hsotg_irq()
3787 for (ep = 0; ep < hsotg->num_of_eps && daint_in; in dwc2_hsotg_irq()
3790 dwc2_hsotg_epint(hsotg, ep, 1); in dwc2_hsotg_irq()
3797 dev_dbg(hsotg->dev, "NPTxFEmp\n"); in dwc2_hsotg_irq()
3805 dwc2_hsotg_disable_gsint(hsotg, GINTSTS_NPTXFEMP); in dwc2_hsotg_irq()
3806 dwc2_hsotg_irq_fifoempty(hsotg, false); in dwc2_hsotg_irq()
3810 dev_dbg(hsotg->dev, "PTxFEmp\n"); in dwc2_hsotg_irq()
3814 dwc2_hsotg_disable_gsint(hsotg, GINTSTS_PTXFEMP); in dwc2_hsotg_irq()
3815 dwc2_hsotg_irq_fifoempty(hsotg, true); in dwc2_hsotg_irq()
3825 dwc2_hsotg_handle_rx(hsotg); in dwc2_hsotg_irq()
3829 dev_dbg(hsotg->dev, "GINTSTS_ErlySusp\n"); in dwc2_hsotg_irq()
3830 dwc2_writel(hsotg, GINTSTS_ERLYSUSP, GINTSTS); in dwc2_hsotg_irq()
3846 daintmsk = dwc2_readl(hsotg, DAINTMSK); in dwc2_hsotg_irq()
3849 gintmsk = dwc2_readl(hsotg, GINTMSK); in dwc2_hsotg_irq()
3851 dwc2_writel(hsotg, gintmsk, GINTMSK); in dwc2_hsotg_irq()
3853 dev_dbg(hsotg->dev, "GOUTNakEff triggered\n"); in dwc2_hsotg_irq()
3854 for (idx = 1; idx < hsotg->num_of_eps; idx++) { in dwc2_hsotg_irq()
3855 hs_ep = hsotg->eps_out[idx]; in dwc2_hsotg_irq()
3860 epctrl = dwc2_readl(hsotg, DOEPCTL(idx)); in dwc2_hsotg_irq()
3866 dwc2_writel(hsotg, epctrl, DOEPCTL(idx)); in dwc2_hsotg_irq()
3876 dwc2_writel(hsotg, epctrl, DOEPCTL(idx)); in dwc2_hsotg_irq()
3884 dev_info(hsotg->dev, "GINNakEff triggered\n"); in dwc2_hsotg_irq()
3886 dwc2_set_bit(hsotg, DCTL, DCTL_CGNPINNAK); in dwc2_hsotg_irq()
3888 dwc2_hsotg_dump(hsotg); in dwc2_hsotg_irq()
3892 dwc2_gadget_handle_incomplete_isoc_in(hsotg); in dwc2_hsotg_irq()
3895 dwc2_gadget_handle_incomplete_isoc_out(hsotg); in dwc2_hsotg_irq()
3906 if (hsotg->params.service_interval) in dwc2_hsotg_irq()
3907 dwc2_gadget_wkup_alert_handler(hsotg); in dwc2_hsotg_irq()
3909 spin_unlock(&hsotg->lock); in dwc2_hsotg_irq()
3914 static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg, in dwc2_hsotg_ep_stop_xfr() argument
3925 dev_dbg(hsotg->dev, "%s: stopping transfer on %s\n", __func__, in dwc2_hsotg_ep_stop_xfr()
3929 if (hsotg->dedicated_fifos || hs_ep->periodic) { in dwc2_hsotg_ep_stop_xfr()
3930 dwc2_set_bit(hsotg, epctrl_reg, DXEPCTL_SNAK); in dwc2_hsotg_ep_stop_xfr()
3932 if (dwc2_hsotg_wait_bit_set(hsotg, epint_reg, in dwc2_hsotg_ep_stop_xfr()
3934 dev_warn(hsotg->dev, in dwc2_hsotg_ep_stop_xfr()
3938 dwc2_set_bit(hsotg, DCTL, DCTL_SGNPINNAK); in dwc2_hsotg_ep_stop_xfr()
3940 if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS, in dwc2_hsotg_ep_stop_xfr()
3942 dev_warn(hsotg->dev, in dwc2_hsotg_ep_stop_xfr()
3948 dwc2_hsotg_disable_gsint(hsotg, GINTSTS_GOUTNAKEFF); in dwc2_hsotg_ep_stop_xfr()
3950 if (!(dwc2_readl(hsotg, GINTSTS) & GINTSTS_GOUTNAKEFF)) in dwc2_hsotg_ep_stop_xfr()
3951 dwc2_set_bit(hsotg, DCTL, DCTL_SGOUTNAK); in dwc2_hsotg_ep_stop_xfr()
3953 if (!using_dma(hsotg)) { in dwc2_hsotg_ep_stop_xfr()
3955 if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS, in dwc2_hsotg_ep_stop_xfr()
3957 dev_warn(hsotg->dev, "%s: timeout GINTSTS.RXFLVL\n", in dwc2_hsotg_ep_stop_xfr()
3964 dwc2_readl(hsotg, GRXSTSP); in dwc2_hsotg_ep_stop_xfr()
3969 if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS, in dwc2_hsotg_ep_stop_xfr()
3971 dev_warn(hsotg->dev, "%s: timeout GINTSTS.GOUTNAKEFF\n", in dwc2_hsotg_ep_stop_xfr()
3976 dwc2_set_bit(hsotg, epctrl_reg, DXEPCTL_EPDIS | DXEPCTL_SNAK); in dwc2_hsotg_ep_stop_xfr()
3979 if (dwc2_hsotg_wait_bit_set(hsotg, epint_reg, DXEPINT_EPDISBLD, 100)) in dwc2_hsotg_ep_stop_xfr()
3980 dev_warn(hsotg->dev, in dwc2_hsotg_ep_stop_xfr()
3984 dwc2_set_bit(hsotg, epint_reg, DXEPINT_EPDISBLD); in dwc2_hsotg_ep_stop_xfr()
3989 if (hsotg->dedicated_fifos || hs_ep->periodic) in dwc2_hsotg_ep_stop_xfr()
3995 dwc2_flush_tx_fifo(hsotg, fifo_index); in dwc2_hsotg_ep_stop_xfr()
3998 if (!hsotg->dedicated_fifos && !hs_ep->periodic) in dwc2_hsotg_ep_stop_xfr()
3999 dwc2_set_bit(hsotg, DCTL, DCTL_CGNPINNAK); in dwc2_hsotg_ep_stop_xfr()
4003 dwc2_set_bit(hsotg, DCTL, DCTL_CGOUTNAK); in dwc2_hsotg_ep_stop_xfr()
4018 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_hsotg_ep_enable() local
4032 dev_dbg(hsotg->dev, in dwc2_hsotg_ep_enable()
4039 dev_err(hsotg->dev, "%s: called for EP 0\n", __func__); in dwc2_hsotg_ep_enable()
4045 dev_err(hsotg->dev, "%s: direction mismatch!\n", __func__); in dwc2_hsotg_ep_enable()
4054 if (using_desc_dma(hsotg) && ep_type == USB_ENDPOINT_XFER_ISOC && in dwc2_hsotg_ep_enable()
4056 dev_err(hsotg->dev, in dwc2_hsotg_ep_enable()
4062 if (using_desc_dma(hsotg) && ep_type == USB_ENDPOINT_XFER_ISOC && in dwc2_hsotg_ep_enable()
4064 dev_err(hsotg->dev, in dwc2_hsotg_ep_enable()
4072 epctrl = dwc2_readl(hsotg, epctrl_reg); in dwc2_hsotg_ep_enable()
4074 dev_dbg(hsotg->dev, "%s: read DxEPCTL=0x%08x from 0x%08x\n", in dwc2_hsotg_ep_enable()
4077 if (using_desc_dma(hsotg) && ep_type == USB_ENDPOINT_XFER_ISOC) in dwc2_hsotg_ep_enable()
4083 if (using_desc_dma(hsotg) && !hs_ep->desc_list) { in dwc2_hsotg_ep_enable()
4084 hs_ep->desc_list = dmam_alloc_coherent(hsotg->dev, in dwc2_hsotg_ep_enable()
4093 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_ep_enable()
4105 dwc2_hsotg_set_ep_maxpacket(hsotg, hs_ep->index, mps, mc, dir_in); in dwc2_hsotg_ep_enable()
4125 mask = dwc2_readl(hsotg, DIEPMSK); in dwc2_hsotg_ep_enable()
4127 dwc2_writel(hsotg, mask, DIEPMSK); in dwc2_hsotg_ep_enable()
4130 mask = dwc2_readl(hsotg, DOEPMSK); in dwc2_hsotg_ep_enable()
4132 dwc2_writel(hsotg, mask, DOEPMSK); in dwc2_hsotg_ep_enable()
4144 if (hsotg->gadget.speed == USB_SPEED_HIGH) in dwc2_hsotg_ep_enable()
4159 if (dir_in && hsotg->dedicated_fifos) { in dwc2_hsotg_ep_enable()
4160 unsigned fifo_count = dwc2_hsotg_tx_fifo_count(hsotg); in dwc2_hsotg_ep_enable()
4166 if (hsotg->fifo_map & (1 << i)) in dwc2_hsotg_ep_enable()
4168 val = dwc2_readl(hsotg, DPTXFSIZN(i)); in dwc2_hsotg_ep_enable()
4179 dev_err(hsotg->dev, in dwc2_hsotg_ep_enable()
4185 hsotg->fifo_map |= 1 << fifo_index; in dwc2_hsotg_ep_enable()
4201 if (hsotg->gadget.speed == USB_SPEED_FULL && in dwc2_hsotg_ep_enable()
4207 u32 gsnpsid = dwc2_readl(hsotg, GSNPSID); in dwc2_hsotg_ep_enable()
4216 dev_dbg(hsotg->dev, "%s: write DxEPCTL=0x%08x\n", in dwc2_hsotg_ep_enable()
4219 dwc2_writel(hsotg, epctrl, epctrl_reg); in dwc2_hsotg_ep_enable()
4220 dev_dbg(hsotg->dev, "%s: read DxEPCTL=0x%08x\n", in dwc2_hsotg_ep_enable()
4221 __func__, dwc2_readl(hsotg, epctrl_reg)); in dwc2_hsotg_ep_enable()
4224 dwc2_hsotg_ctrl_epint(hsotg, index, dir_in, 1); in dwc2_hsotg_ep_enable()
4227 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_ep_enable()
4230 if (ret && using_desc_dma(hsotg) && hs_ep->desc_list) { in dwc2_hsotg_ep_enable()
4231 dmam_free_coherent(hsotg->dev, desc_num * in dwc2_hsotg_ep_enable()
4247 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_hsotg_ep_disable() local
4253 dev_dbg(hsotg->dev, "%s(ep %p)\n", __func__, ep); in dwc2_hsotg_ep_disable()
4255 if (ep == &hsotg->eps_out[0]->ep) { in dwc2_hsotg_ep_disable()
4256 dev_err(hsotg->dev, "%s: called for ep0\n", __func__); in dwc2_hsotg_ep_disable()
4260 if (hsotg->op_state != OTG_STATE_B_PERIPHERAL) { in dwc2_hsotg_ep_disable()
4261 dev_err(hsotg->dev, "%s: called in host mode?\n", __func__); in dwc2_hsotg_ep_disable()
4267 ctrl = dwc2_readl(hsotg, epctrl_reg); in dwc2_hsotg_ep_disable()
4270 dwc2_hsotg_ep_stop_xfr(hsotg, hs_ep); in dwc2_hsotg_ep_disable()
4276 dev_dbg(hsotg->dev, "%s: DxEPCTL=0x%08x\n", __func__, ctrl); in dwc2_hsotg_ep_disable()
4277 dwc2_writel(hsotg, ctrl, epctrl_reg); in dwc2_hsotg_ep_disable()
4280 dwc2_hsotg_ctrl_epint(hsotg, hs_ep->index, hs_ep->dir_in, 0); in dwc2_hsotg_ep_disable()
4283 kill_all_requests(hsotg, hs_ep, -ESHUTDOWN); in dwc2_hsotg_ep_disable()
4285 hsotg->fifo_map &= ~(1 << hs_ep->fifo_index); in dwc2_hsotg_ep_disable()
4295 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_hsotg_ep_disable_lock() local
4299 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_ep_disable_lock()
4301 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_ep_disable_lock()
4493 static void dwc2_hsotg_init(struct dwc2_hsotg *hsotg) in dwc2_hsotg_init() argument
4497 dwc2_writel(hsotg, DIEPMSK_TIMEOUTMSK | DIEPMSK_AHBERRMSK | in dwc2_hsotg_init()
4501 dwc2_writel(hsotg, DOEPMSK_SETUPMSK | DOEPMSK_AHBERRMSK | in dwc2_hsotg_init()
4505 dwc2_writel(hsotg, 0, DAINTMSK); in dwc2_hsotg_init()
4508 dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON); in dwc2_hsotg_init()
4512 dev_dbg(hsotg->dev, "GRXFSIZ=0x%08x, GNPTXFSIZ=0x%08x\n", in dwc2_hsotg_init()
4513 dwc2_readl(hsotg, GRXFSIZ), in dwc2_hsotg_init()
4514 dwc2_readl(hsotg, GNPTXFSIZ)); in dwc2_hsotg_init()
4516 dwc2_hsotg_init_fifo(hsotg); in dwc2_hsotg_init()
4518 if (using_dma(hsotg)) in dwc2_hsotg_init()
4519 dwc2_set_bit(hsotg, GAHBCFG, GAHBCFG_DMA_EN); in dwc2_hsotg_init()
4533 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_udc_start() local
4537 if (!hsotg) { in dwc2_hsotg_udc_start()
4543 dev_err(hsotg->dev, "%s: no driver\n", __func__); in dwc2_hsotg_udc_start()
4548 dev_err(hsotg->dev, "%s: bad speed\n", __func__); in dwc2_hsotg_udc_start()
4551 dev_err(hsotg->dev, "%s: missing entry points\n", __func__); in dwc2_hsotg_udc_start()
4555 WARN_ON(hsotg->driver); in dwc2_hsotg_udc_start()
4557 hsotg->driver = driver; in dwc2_hsotg_udc_start()
4558 hsotg->gadget.dev.of_node = hsotg->dev->of_node; in dwc2_hsotg_udc_start()
4559 hsotg->gadget.speed = USB_SPEED_UNKNOWN; in dwc2_hsotg_udc_start()
4561 if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) { in dwc2_hsotg_udc_start()
4562 ret = dwc2_lowlevel_hw_enable(hsotg); in dwc2_hsotg_udc_start()
4567 if (!IS_ERR_OR_NULL(hsotg->uphy)) in dwc2_hsotg_udc_start()
4568 otg_set_peripheral(hsotg->uphy->otg, &hsotg->gadget); in dwc2_hsotg_udc_start()
4570 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_udc_start()
4571 if (dwc2_hw_is_device(hsotg)) { in dwc2_hsotg_udc_start()
4572 dwc2_hsotg_init(hsotg); in dwc2_hsotg_udc_start()
4573 dwc2_hsotg_core_init_disconnected(hsotg, false); in dwc2_hsotg_udc_start()
4576 hsotg->enabled = 0; in dwc2_hsotg_udc_start()
4577 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_udc_start()
4579 gadget->sg_supported = using_desc_dma(hsotg); in dwc2_hsotg_udc_start()
4580 dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name); in dwc2_hsotg_udc_start()
4585 hsotg->driver = NULL; in dwc2_hsotg_udc_start()
4597 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_udc_stop() local
4601 if (!hsotg) in dwc2_hsotg_udc_stop()
4605 for (ep = 1; ep < hsotg->num_of_eps; ep++) { in dwc2_hsotg_udc_stop()
4606 if (hsotg->eps_in[ep]) in dwc2_hsotg_udc_stop()
4607 dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep); in dwc2_hsotg_udc_stop()
4608 if (hsotg->eps_out[ep]) in dwc2_hsotg_udc_stop()
4609 dwc2_hsotg_ep_disable_lock(&hsotg->eps_out[ep]->ep); in dwc2_hsotg_udc_stop()
4612 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_udc_stop()
4614 hsotg->driver = NULL; in dwc2_hsotg_udc_stop()
4615 hsotg->gadget.speed = USB_SPEED_UNKNOWN; in dwc2_hsotg_udc_stop()
4616 hsotg->enabled = 0; in dwc2_hsotg_udc_stop()
4618 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_udc_stop()
4620 if (!IS_ERR_OR_NULL(hsotg->uphy)) in dwc2_hsotg_udc_stop()
4621 otg_set_peripheral(hsotg->uphy->otg, NULL); in dwc2_hsotg_udc_stop()
4623 if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) in dwc2_hsotg_udc_stop()
4624 dwc2_lowlevel_hw_disable(hsotg); in dwc2_hsotg_udc_stop()
4650 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_set_selfpowered() local
4653 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_set_selfpowered()
4655 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_set_selfpowered()
4669 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_pullup() local
4672 dev_dbg(hsotg->dev, "%s: is_on: %d op_state: %d\n", __func__, is_on, in dwc2_hsotg_pullup()
4673 hsotg->op_state); in dwc2_hsotg_pullup()
4676 if (hsotg->op_state != OTG_STATE_B_PERIPHERAL) { in dwc2_hsotg_pullup()
4677 hsotg->enabled = is_on; in dwc2_hsotg_pullup()
4681 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_pullup()
4683 hsotg->enabled = 1; in dwc2_hsotg_pullup()
4684 dwc2_hsotg_core_init_disconnected(hsotg, false); in dwc2_hsotg_pullup()
4686 dwc2_enable_acg(hsotg); in dwc2_hsotg_pullup()
4687 dwc2_hsotg_core_connect(hsotg); in dwc2_hsotg_pullup()
4689 dwc2_hsotg_core_disconnect(hsotg); in dwc2_hsotg_pullup()
4690 dwc2_hsotg_disconnect(hsotg); in dwc2_hsotg_pullup()
4691 hsotg->enabled = 0; in dwc2_hsotg_pullup()
4694 hsotg->gadget.speed = USB_SPEED_UNKNOWN; in dwc2_hsotg_pullup()
4695 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_pullup()
4702 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_vbus_session() local
4705 dev_dbg(hsotg->dev, "%s: is_active: %d\n", __func__, is_active); in dwc2_hsotg_vbus_session()
4706 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_vbus_session()
4712 if (hsotg->lx_state == DWC2_L2 && hsotg->in_ppd) in dwc2_hsotg_vbus_session()
4717 dwc2_exit_partial_power_down(hsotg, 0, false); in dwc2_hsotg_vbus_session()
4720 hsotg->op_state = OTG_STATE_B_PERIPHERAL; in dwc2_hsotg_vbus_session()
4722 dwc2_hsotg_core_init_disconnected(hsotg, false); in dwc2_hsotg_vbus_session()
4723 if (hsotg->enabled) { in dwc2_hsotg_vbus_session()
4725 dwc2_enable_acg(hsotg); in dwc2_hsotg_vbus_session()
4726 dwc2_hsotg_core_connect(hsotg); in dwc2_hsotg_vbus_session()
4729 dwc2_hsotg_core_disconnect(hsotg); in dwc2_hsotg_vbus_session()
4730 dwc2_hsotg_disconnect(hsotg); in dwc2_hsotg_vbus_session()
4733 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_vbus_session()
4746 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_vbus_draw() local
4748 if (IS_ERR_OR_NULL(hsotg->uphy)) in dwc2_hsotg_vbus_draw()
4750 return usb_phy_set_power(hsotg->uphy, mA); in dwc2_hsotg_vbus_draw()
4755 struct dwc2_hsotg *hsotg = to_hsotg(g); in dwc2_gadget_set_speed() local
4758 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_gadget_set_speed()
4761 hsotg->params.speed = DWC2_SPEED_PARAM_HIGH; in dwc2_gadget_set_speed()
4764 hsotg->params.speed = DWC2_SPEED_PARAM_FULL; in dwc2_gadget_set_speed()
4767 hsotg->params.speed = DWC2_SPEED_PARAM_LOW; in dwc2_gadget_set_speed()
4770 dev_err(hsotg->dev, "invalid speed (%d)\n", speed); in dwc2_gadget_set_speed()
4772 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_gadget_set_speed()
4797 static void dwc2_hsotg_initep(struct dwc2_hsotg *hsotg, in dwc2_hsotg_initep() argument
4821 list_add_tail(&hs_ep->ep.ep_list, &hsotg->gadget.ep_list); in dwc2_hsotg_initep()
4823 hs_ep->parent = hsotg; in dwc2_hsotg_initep()
4826 if (hsotg->params.speed == DWC2_SPEED_PARAM_LOW) in dwc2_hsotg_initep()
4836 if (hsotg->params.speed != DWC2_SPEED_PARAM_LOW) { in dwc2_hsotg_initep()
4853 if (using_dma(hsotg)) { in dwc2_hsotg_initep()
4857 dwc2_writel(hsotg, next, DIEPCTL(epnum)); in dwc2_hsotg_initep()
4859 dwc2_writel(hsotg, next, DOEPCTL(epnum)); in dwc2_hsotg_initep()
4869 static int dwc2_hsotg_hw_cfg(struct dwc2_hsotg *hsotg) in dwc2_hsotg_hw_cfg() argument
4877 hsotg->num_of_eps = hsotg->hw_params.num_dev_ep; in dwc2_hsotg_hw_cfg()
4880 hsotg->num_of_eps++; in dwc2_hsotg_hw_cfg()
4882 hsotg->eps_in[0] = devm_kzalloc(hsotg->dev, in dwc2_hsotg_hw_cfg()
4885 if (!hsotg->eps_in[0]) in dwc2_hsotg_hw_cfg()
4888 hsotg->eps_out[0] = hsotg->eps_in[0]; in dwc2_hsotg_hw_cfg()
4890 cfg = hsotg->hw_params.dev_ep_dirs; in dwc2_hsotg_hw_cfg()
4891 for (i = 1, cfg >>= 2; i < hsotg->num_of_eps; i++, cfg >>= 2) { in dwc2_hsotg_hw_cfg()
4895 hsotg->eps_in[i] = devm_kzalloc(hsotg->dev, in dwc2_hsotg_hw_cfg()
4897 if (!hsotg->eps_in[i]) in dwc2_hsotg_hw_cfg()
4902 hsotg->eps_out[i] = devm_kzalloc(hsotg->dev, in dwc2_hsotg_hw_cfg()
4904 if (!hsotg->eps_out[i]) in dwc2_hsotg_hw_cfg()
4909 hsotg->fifo_mem = hsotg->hw_params.total_fifo_size; in dwc2_hsotg_hw_cfg()
4910 hsotg->dedicated_fifos = hsotg->hw_params.en_multiple_tx_fifo; in dwc2_hsotg_hw_cfg()
4912 dev_info(hsotg->dev, "EPs: %d, %s fifos, %d entries in SPRAM\n", in dwc2_hsotg_hw_cfg()
4913 hsotg->num_of_eps, in dwc2_hsotg_hw_cfg()
4914 hsotg->dedicated_fifos ? "dedicated" : "shared", in dwc2_hsotg_hw_cfg()
4915 hsotg->fifo_mem); in dwc2_hsotg_hw_cfg()
4924 static void dwc2_hsotg_dump(struct dwc2_hsotg *hsotg) in dwc2_hsotg_dump() argument
4927 struct device *dev = hsotg->dev; in dwc2_hsotg_dump()
4932 dwc2_readl(hsotg, DCFG), dwc2_readl(hsotg, DCTL), in dwc2_hsotg_dump()
4933 dwc2_readl(hsotg, DIEPMSK)); in dwc2_hsotg_dump()
4936 dwc2_readl(hsotg, GAHBCFG), dwc2_readl(hsotg, GHWCFG1)); in dwc2_hsotg_dump()
4939 dwc2_readl(hsotg, GRXFSIZ), dwc2_readl(hsotg, GNPTXFSIZ)); in dwc2_hsotg_dump()
4943 for (idx = 1; idx < hsotg->num_of_eps; idx++) { in dwc2_hsotg_dump()
4944 val = dwc2_readl(hsotg, DPTXFSIZN(idx)); in dwc2_hsotg_dump()
4950 for (idx = 0; idx < hsotg->num_of_eps; idx++) { in dwc2_hsotg_dump()
4953 dwc2_readl(hsotg, DIEPCTL(idx)), in dwc2_hsotg_dump()
4954 dwc2_readl(hsotg, DIEPTSIZ(idx)), in dwc2_hsotg_dump()
4955 dwc2_readl(hsotg, DIEPDMA(idx))); in dwc2_hsotg_dump()
4957 val = dwc2_readl(hsotg, DOEPCTL(idx)); in dwc2_hsotg_dump()
4960 idx, dwc2_readl(hsotg, DOEPCTL(idx)), in dwc2_hsotg_dump()
4961 dwc2_readl(hsotg, DOEPTSIZ(idx)), in dwc2_hsotg_dump()
4962 dwc2_readl(hsotg, DOEPDMA(idx))); in dwc2_hsotg_dump()
4966 dwc2_readl(hsotg, DVBUSDIS), dwc2_readl(hsotg, DVBUSPULSE)); in dwc2_hsotg_dump()
4975 int dwc2_gadget_init(struct dwc2_hsotg *hsotg) in dwc2_gadget_init() argument
4977 struct device *dev = hsotg->dev; in dwc2_gadget_init()
4983 hsotg->params.g_np_tx_fifo_size); in dwc2_gadget_init()
4984 dev_dbg(dev, "RXFIFO size: %d\n", hsotg->params.g_rx_fifo_size); in dwc2_gadget_init()
4986 switch (hsotg->params.speed) { in dwc2_gadget_init()
4988 hsotg->gadget.max_speed = USB_SPEED_LOW; in dwc2_gadget_init()
4991 hsotg->gadget.max_speed = USB_SPEED_FULL; in dwc2_gadget_init()
4994 hsotg->gadget.max_speed = USB_SPEED_HIGH; in dwc2_gadget_init()
4998 hsotg->gadget.ops = &dwc2_hsotg_gadget_ops; in dwc2_gadget_init()
4999 hsotg->gadget.name = dev_name(dev); in dwc2_gadget_init()
5000 hsotg->gadget.otg_caps = &hsotg->params.otg_caps; in dwc2_gadget_init()
5001 hsotg->remote_wakeup_allowed = 0; in dwc2_gadget_init()
5003 if (hsotg->params.lpm) in dwc2_gadget_init()
5004 hsotg->gadget.lpm_capable = true; in dwc2_gadget_init()
5006 if (hsotg->dr_mode == USB_DR_MODE_OTG) in dwc2_gadget_init()
5007 hsotg->gadget.is_otg = 1; in dwc2_gadget_init()
5008 else if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) in dwc2_gadget_init()
5009 hsotg->op_state = OTG_STATE_B_PERIPHERAL; in dwc2_gadget_init()
5011 ret = dwc2_hsotg_hw_cfg(hsotg); in dwc2_gadget_init()
5013 dev_err(hsotg->dev, "Hardware configuration failed: %d\n", ret); in dwc2_gadget_init()
5017 hsotg->ctrl_buff = devm_kzalloc(hsotg->dev, in dwc2_gadget_init()
5019 if (!hsotg->ctrl_buff) in dwc2_gadget_init()
5022 hsotg->ep0_buff = devm_kzalloc(hsotg->dev, in dwc2_gadget_init()
5024 if (!hsotg->ep0_buff) in dwc2_gadget_init()
5027 if (using_desc_dma(hsotg)) { in dwc2_gadget_init()
5028 ret = dwc2_gadget_alloc_ctrl_desc_chains(hsotg); in dwc2_gadget_init()
5033 ret = devm_request_irq(hsotg->dev, hsotg->irq, dwc2_hsotg_irq, in dwc2_gadget_init()
5034 IRQF_SHARED, dev_name(hsotg->dev), hsotg); in dwc2_gadget_init()
5042 if (hsotg->num_of_eps == 0) { in dwc2_gadget_init()
5049 INIT_LIST_HEAD(&hsotg->gadget.ep_list); in dwc2_gadget_init()
5050 hsotg->gadget.ep0 = &hsotg->eps_out[0]->ep; in dwc2_gadget_init()
5054 hsotg->ctrl_req = dwc2_hsotg_ep_alloc_request(&hsotg->eps_out[0]->ep, in dwc2_gadget_init()
5056 if (!hsotg->ctrl_req) { in dwc2_gadget_init()
5062 for (epnum = 0; epnum < hsotg->num_of_eps; epnum++) { in dwc2_gadget_init()
5063 if (hsotg->eps_in[epnum]) in dwc2_gadget_init()
5064 dwc2_hsotg_initep(hsotg, hsotg->eps_in[epnum], in dwc2_gadget_init()
5066 if (hsotg->eps_out[epnum]) in dwc2_gadget_init()
5067 dwc2_hsotg_initep(hsotg, hsotg->eps_out[epnum], in dwc2_gadget_init()
5071 dwc2_hsotg_dump(hsotg); in dwc2_gadget_init()
5081 int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg) in dwc2_hsotg_remove() argument
5083 usb_del_gadget_udc(&hsotg->gadget); in dwc2_hsotg_remove()
5084 dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, hsotg->ctrl_req); in dwc2_hsotg_remove()
5089 int dwc2_hsotg_suspend(struct dwc2_hsotg *hsotg) in dwc2_hsotg_suspend() argument
5093 if (hsotg->lx_state != DWC2_L0) in dwc2_hsotg_suspend()
5096 if (hsotg->driver) { in dwc2_hsotg_suspend()
5099 dev_info(hsotg->dev, "suspending usb gadget %s\n", in dwc2_hsotg_suspend()
5100 hsotg->driver->driver.name); in dwc2_hsotg_suspend()
5102 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_suspend()
5103 if (hsotg->enabled) in dwc2_hsotg_suspend()
5104 dwc2_hsotg_core_disconnect(hsotg); in dwc2_hsotg_suspend()
5105 dwc2_hsotg_disconnect(hsotg); in dwc2_hsotg_suspend()
5106 hsotg->gadget.speed = USB_SPEED_UNKNOWN; in dwc2_hsotg_suspend()
5107 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_suspend()
5109 for (ep = 1; ep < hsotg->num_of_eps; ep++) { in dwc2_hsotg_suspend()
5110 if (hsotg->eps_in[ep]) in dwc2_hsotg_suspend()
5111 dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep); in dwc2_hsotg_suspend()
5112 if (hsotg->eps_out[ep]) in dwc2_hsotg_suspend()
5113 dwc2_hsotg_ep_disable_lock(&hsotg->eps_out[ep]->ep); in dwc2_hsotg_suspend()
5120 int dwc2_hsotg_resume(struct dwc2_hsotg *hsotg) in dwc2_hsotg_resume() argument
5124 if (hsotg->lx_state == DWC2_L2) in dwc2_hsotg_resume()
5127 if (hsotg->driver) { in dwc2_hsotg_resume()
5128 dev_info(hsotg->dev, "resuming usb gadget %s\n", in dwc2_hsotg_resume()
5129 hsotg->driver->driver.name); in dwc2_hsotg_resume()
5131 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_resume()
5132 dwc2_hsotg_core_init_disconnected(hsotg, false); in dwc2_hsotg_resume()
5133 if (hsotg->enabled) { in dwc2_hsotg_resume()
5135 dwc2_enable_acg(hsotg); in dwc2_hsotg_resume()
5136 dwc2_hsotg_core_connect(hsotg); in dwc2_hsotg_resume()
5138 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_resume()
5151 int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg) in dwc2_backup_device_registers() argument
5156 dev_dbg(hsotg->dev, "%s\n", __func__); in dwc2_backup_device_registers()
5159 dr = &hsotg->dr_backup; in dwc2_backup_device_registers()
5161 dr->dcfg = dwc2_readl(hsotg, DCFG); in dwc2_backup_device_registers()
5162 dr->dctl = dwc2_readl(hsotg, DCTL); in dwc2_backup_device_registers()
5163 dr->daintmsk = dwc2_readl(hsotg, DAINTMSK); in dwc2_backup_device_registers()
5164 dr->diepmsk = dwc2_readl(hsotg, DIEPMSK); in dwc2_backup_device_registers()
5165 dr->doepmsk = dwc2_readl(hsotg, DOEPMSK); in dwc2_backup_device_registers()
5167 for (i = 0; i < hsotg->num_of_eps; i++) { in dwc2_backup_device_registers()
5169 dr->diepctl[i] = dwc2_readl(hsotg, DIEPCTL(i)); in dwc2_backup_device_registers()
5177 dr->dieptsiz[i] = dwc2_readl(hsotg, DIEPTSIZ(i)); in dwc2_backup_device_registers()
5178 dr->diepdma[i] = dwc2_readl(hsotg, DIEPDMA(i)); in dwc2_backup_device_registers()
5181 dr->doepctl[i] = dwc2_readl(hsotg, DOEPCTL(i)); in dwc2_backup_device_registers()
5189 dr->doeptsiz[i] = dwc2_readl(hsotg, DOEPTSIZ(i)); in dwc2_backup_device_registers()
5190 dr->doepdma[i] = dwc2_readl(hsotg, DOEPDMA(i)); in dwc2_backup_device_registers()
5191 dr->dtxfsiz[i] = dwc2_readl(hsotg, DPTXFSIZN(i)); in dwc2_backup_device_registers()
5207 int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup) in dwc2_restore_device_registers() argument
5212 dev_dbg(hsotg->dev, "%s\n", __func__); in dwc2_restore_device_registers()
5215 dr = &hsotg->dr_backup; in dwc2_restore_device_registers()
5217 dev_err(hsotg->dev, "%s: no device registers to restore\n", in dwc2_restore_device_registers()
5224 dwc2_writel(hsotg, dr->dctl, DCTL); in dwc2_restore_device_registers()
5226 dwc2_writel(hsotg, dr->daintmsk, DAINTMSK); in dwc2_restore_device_registers()
5227 dwc2_writel(hsotg, dr->diepmsk, DIEPMSK); in dwc2_restore_device_registers()
5228 dwc2_writel(hsotg, dr->doepmsk, DOEPMSK); in dwc2_restore_device_registers()
5230 for (i = 0; i < hsotg->num_of_eps; i++) { in dwc2_restore_device_registers()
5232 dwc2_writel(hsotg, dr->dieptsiz[i], DIEPTSIZ(i)); in dwc2_restore_device_registers()
5233 dwc2_writel(hsotg, dr->diepdma[i], DIEPDMA(i)); in dwc2_restore_device_registers()
5234 dwc2_writel(hsotg, dr->doeptsiz[i], DOEPTSIZ(i)); in dwc2_restore_device_registers()
5240 if (using_desc_dma(hsotg) && in dwc2_restore_device_registers()
5242 dr->diepdma[i] = hsotg->eps_in[i]->desc_list_dma; in dwc2_restore_device_registers()
5243 dwc2_writel(hsotg, dr->dtxfsiz[i], DPTXFSIZN(i)); in dwc2_restore_device_registers()
5244 dwc2_writel(hsotg, dr->diepctl[i], DIEPCTL(i)); in dwc2_restore_device_registers()
5246 dwc2_writel(hsotg, dr->doeptsiz[i], DOEPTSIZ(i)); in dwc2_restore_device_registers()
5252 if (using_desc_dma(hsotg) && in dwc2_restore_device_registers()
5254 dr->doepdma[i] = hsotg->eps_out[i]->desc_list_dma; in dwc2_restore_device_registers()
5255 dwc2_writel(hsotg, dr->doepdma[i], DOEPDMA(i)); in dwc2_restore_device_registers()
5256 dwc2_writel(hsotg, dr->doepctl[i], DOEPCTL(i)); in dwc2_restore_device_registers()
5268 void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg) in dwc2_gadget_init_lpm() argument
5272 if (!hsotg->params.lpm) in dwc2_gadget_init_lpm()
5276 val |= hsotg->params.hird_threshold_en ? GLPMCFG_HIRD_THRES_EN : 0; in dwc2_gadget_init_lpm()
5277 val |= hsotg->params.lpm_clock_gating ? GLPMCFG_ENBLSLPM : 0; in dwc2_gadget_init_lpm()
5278 val |= hsotg->params.hird_threshold << GLPMCFG_HIRD_THRES_SHIFT; in dwc2_gadget_init_lpm()
5279 val |= hsotg->params.besl ? GLPMCFG_ENBESL : 0; in dwc2_gadget_init_lpm()
5282 dwc2_writel(hsotg, val, GLPMCFG); in dwc2_gadget_init_lpm()
5283 dev_dbg(hsotg->dev, "GLPMCFG=0x%08x\n", dwc2_readl(hsotg, GLPMCFG)); in dwc2_gadget_init_lpm()
5286 if (hsotg->params.service_interval) in dwc2_gadget_init_lpm()
5287 dwc2_set_bit(hsotg, GINTMSK2, GINTMSK2_WKUP_ALERT_INT_MSK); in dwc2_gadget_init_lpm()
5296 void dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg) in dwc2_gadget_program_ref_clk() argument
5301 val |= hsotg->params.ref_clk_per << GREFCLK_REFCLKPER_SHIFT; in dwc2_gadget_program_ref_clk()
5302 val |= hsotg->params.sof_cnt_wkup_alert << in dwc2_gadget_program_ref_clk()
5305 dwc2_writel(hsotg, val, GREFCLK); in dwc2_gadget_program_ref_clk()
5306 dev_dbg(hsotg->dev, "GREFCLK=0x%08x\n", dwc2_readl(hsotg, GREFCLK)); in dwc2_gadget_program_ref_clk()
5316 int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg) in dwc2_gadget_enter_hibernation() argument
5322 hsotg->lx_state = DWC2_L2; in dwc2_gadget_enter_hibernation()
5323 dev_dbg(hsotg->dev, "Start of hibernation completed\n"); in dwc2_gadget_enter_hibernation()
5324 ret = dwc2_backup_global_registers(hsotg); in dwc2_gadget_enter_hibernation()
5326 dev_err(hsotg->dev, "%s: failed to backup global registers\n", in dwc2_gadget_enter_hibernation()
5330 ret = dwc2_backup_device_registers(hsotg); in dwc2_gadget_enter_hibernation()
5332 dev_err(hsotg->dev, "%s: failed to backup device registers\n", in dwc2_gadget_enter_hibernation()
5339 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_enter_hibernation()
5343 hsotg->hibernated = 1; in dwc2_gadget_enter_hibernation()
5346 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_enter_hibernation()
5348 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_enter_hibernation()
5352 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_enter_hibernation()
5356 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_enter_hibernation()
5360 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_enter_hibernation()
5362 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_enter_hibernation()
5366 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_enter_hibernation()
5368 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_enter_hibernation()
5372 hsotg->gr_backup.gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_enter_hibernation()
5373 dev_dbg(hsotg->dev, "Hibernation completed\n"); in dwc2_gadget_enter_hibernation()
5389 int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg, in dwc2_gadget_exit_hibernation() argument
5399 gr = &hsotg->gr_backup; in dwc2_gadget_exit_hibernation()
5400 dr = &hsotg->dr_backup; in dwc2_gadget_exit_hibernation()
5402 if (!hsotg->hibernated) { in dwc2_gadget_exit_hibernation()
5403 dev_dbg(hsotg->dev, "Already exited from Hibernation\n"); in dwc2_gadget_exit_hibernation()
5406 dev_dbg(hsotg->dev, in dwc2_gadget_exit_hibernation()
5410 dwc2_hib_restore_common(hsotg, rem_wakeup, 0); in dwc2_gadget_exit_hibernation()
5414 dwc2_writel(hsotg, 0xffffffff, GINTSTS); in dwc2_gadget_exit_hibernation()
5418 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_exit_hibernation()
5420 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_exit_hibernation()
5424 pcgcctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_hibernation()
5426 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_exit_hibernation()
5430 dwc2_writel(hsotg, gr->gusbcfg, GUSBCFG); in dwc2_gadget_exit_hibernation()
5431 dwc2_writel(hsotg, dr->dcfg, DCFG); in dwc2_gadget_exit_hibernation()
5432 dwc2_writel(hsotg, dr->dctl, DCTL); in dwc2_gadget_exit_hibernation()
5436 dwc2_clear_bit(hsotg, DCFG, DCFG_DEVADDR_MASK); in dwc2_gadget_exit_hibernation()
5439 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_exit_hibernation()
5441 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_exit_hibernation()
5446 dwc2_writel(hsotg, dr->dctl | DCTL_RMTWKUPSIG, DCTL); in dwc2_gadget_exit_hibernation()
5450 dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_exit_hibernation()
5452 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_exit_hibernation()
5457 dwc2_writel(hsotg, 0xffffffff, GINTSTS); in dwc2_gadget_exit_hibernation()
5460 ret = dwc2_restore_global_registers(hsotg); in dwc2_gadget_exit_hibernation()
5462 dev_err(hsotg->dev, "%s: failed to restore registers\n", in dwc2_gadget_exit_hibernation()
5468 ret = dwc2_restore_device_registers(hsotg, rem_wakeup); in dwc2_gadget_exit_hibernation()
5470 dev_err(hsotg->dev, "%s: failed to restore device registers\n", in dwc2_gadget_exit_hibernation()
5477 dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_exit_hibernation()
5479 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_exit_hibernation()
5482 hsotg->hibernated = 0; in dwc2_gadget_exit_hibernation()
5483 hsotg->lx_state = DWC2_L0; in dwc2_gadget_exit_hibernation()
5484 dev_dbg(hsotg->dev, "Hibernation recovery completes here\n"); in dwc2_gadget_exit_hibernation()
5499 int dwc2_gadget_enter_partial_power_down(struct dwc2_hsotg *hsotg) in dwc2_gadget_enter_partial_power_down() argument
5504 dev_dbg(hsotg->dev, "Entering device partial power down started.\n"); in dwc2_gadget_enter_partial_power_down()
5507 ret = dwc2_backup_global_registers(hsotg); in dwc2_gadget_enter_partial_power_down()
5509 dev_err(hsotg->dev, "%s: failed to backup global registers\n", in dwc2_gadget_enter_partial_power_down()
5514 ret = dwc2_backup_device_registers(hsotg); in dwc2_gadget_enter_partial_power_down()
5516 dev_err(hsotg->dev, "%s: failed to backup device registers\n", in dwc2_gadget_enter_partial_power_down()
5525 dwc2_writel(hsotg, 0xffffffff, GINTSTS); in dwc2_gadget_enter_partial_power_down()
5528 pcgcctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_enter_partial_power_down()
5531 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_enter_partial_power_down()
5535 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_enter_partial_power_down()
5539 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_enter_partial_power_down()
5542 hsotg->in_ppd = 1; in dwc2_gadget_enter_partial_power_down()
5543 hsotg->lx_state = DWC2_L2; in dwc2_gadget_enter_partial_power_down()
5545 dev_dbg(hsotg->dev, "Entering device partial power down completed.\n"); in dwc2_gadget_enter_partial_power_down()
5561 int dwc2_gadget_exit_partial_power_down(struct dwc2_hsotg *hsotg, in dwc2_gadget_exit_partial_power_down() argument
5569 dr = &hsotg->dr_backup; in dwc2_gadget_exit_partial_power_down()
5571 dev_dbg(hsotg->dev, "Exiting device partial Power Down started.\n"); in dwc2_gadget_exit_partial_power_down()
5573 pcgcctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5575 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5577 pcgcctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5579 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5581 pcgcctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5583 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5587 ret = dwc2_restore_global_registers(hsotg); in dwc2_gadget_exit_partial_power_down()
5589 dev_err(hsotg->dev, "%s: failed to restore registers\n", in dwc2_gadget_exit_partial_power_down()
5594 dwc2_writel(hsotg, dr->dcfg, DCFG); in dwc2_gadget_exit_partial_power_down()
5596 ret = dwc2_restore_device_registers(hsotg, 0); in dwc2_gadget_exit_partial_power_down()
5598 dev_err(hsotg->dev, "%s: failed to restore device registers\n", in dwc2_gadget_exit_partial_power_down()
5605 dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_exit_partial_power_down()
5607 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_exit_partial_power_down()
5610 hsotg->in_ppd = 0; in dwc2_gadget_exit_partial_power_down()
5611 hsotg->lx_state = DWC2_L0; in dwc2_gadget_exit_partial_power_down()
5613 dev_dbg(hsotg->dev, "Exiting device partial Power Down completed.\n"); in dwc2_gadget_exit_partial_power_down()
5626 void dwc2_gadget_enter_clock_gating(struct dwc2_hsotg *hsotg) in dwc2_gadget_enter_clock_gating() argument
5630 dev_dbg(hsotg->dev, "Entering device clock gating.\n"); in dwc2_gadget_enter_clock_gating()
5633 pcgctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_enter_clock_gating()
5635 dwc2_writel(hsotg, pcgctl, PCGCTL); in dwc2_gadget_enter_clock_gating()
5639 pcgctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_enter_clock_gating()
5641 dwc2_writel(hsotg, pcgctl, PCGCTL); in dwc2_gadget_enter_clock_gating()
5644 hsotg->lx_state = DWC2_L2; in dwc2_gadget_enter_clock_gating()
5645 hsotg->bus_suspended = true; in dwc2_gadget_enter_clock_gating()
5656 void dwc2_gadget_exit_clock_gating(struct dwc2_hsotg *hsotg, int rem_wakeup) in dwc2_gadget_exit_clock_gating() argument
5661 dev_dbg(hsotg->dev, "Exiting device clock gating.\n"); in dwc2_gadget_exit_clock_gating()
5664 pcgctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_clock_gating()
5666 dwc2_writel(hsotg, pcgctl, PCGCTL); in dwc2_gadget_exit_clock_gating()
5670 pcgctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_clock_gating()
5672 dwc2_writel(hsotg, pcgctl, PCGCTL); in dwc2_gadget_exit_clock_gating()
5677 dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_exit_clock_gating()
5679 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_exit_clock_gating()
5683 call_gadget(hsotg, resume); in dwc2_gadget_exit_clock_gating()
5684 hsotg->lx_state = DWC2_L0; in dwc2_gadget_exit_clock_gating()
5685 hsotg->bus_suspended = false; in dwc2_gadget_exit_clock_gating()