Lines Matching refs:hsotg
52 static inline void dwc2_set_bit(struct dwc2_hsotg *hsotg, u32 offset, u32 val) in dwc2_set_bit() argument
54 dwc2_writel(hsotg, dwc2_readl(hsotg, offset) | val, offset); in dwc2_set_bit()
57 static inline void dwc2_clear_bit(struct dwc2_hsotg *hsotg, u32 offset, u32 val) in dwc2_clear_bit() argument
59 dwc2_writel(hsotg, dwc2_readl(hsotg, offset) & ~val, offset); in dwc2_clear_bit()
62 static inline struct dwc2_hsotg_ep *index_to_ep(struct dwc2_hsotg *hsotg, in index_to_ep() argument
66 return hsotg->eps_in[ep_index]; in index_to_ep()
68 return hsotg->eps_out[ep_index]; in index_to_ep()
72 static void dwc2_hsotg_dump(struct dwc2_hsotg *hsotg);
93 static inline bool using_dma(struct dwc2_hsotg *hsotg) in using_dma() argument
95 return hsotg->params.g_dma; in using_dma()
104 static inline bool using_desc_dma(struct dwc2_hsotg *hsotg) in using_desc_dma() argument
106 return hsotg->params.g_dma_desc; in using_desc_dma()
118 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_incr_frame_num() local
121 if (hsotg->gadget.speed != USB_SPEED_HIGH) in dwc2_gadget_incr_frame_num()
145 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_dec_frame_num_by_one() local
148 if (hsotg->gadget.speed != USB_SPEED_HIGH) in dwc2_gadget_dec_frame_num_by_one()
162 static void dwc2_hsotg_en_gsint(struct dwc2_hsotg *hsotg, u32 ints) in dwc2_hsotg_en_gsint() argument
164 u32 gsintmsk = dwc2_readl(hsotg, GINTMSK); in dwc2_hsotg_en_gsint()
170 dev_dbg(hsotg->dev, "gsintmsk now 0x%08x\n", new_gsintmsk); in dwc2_hsotg_en_gsint()
171 dwc2_writel(hsotg, new_gsintmsk, GINTMSK); in dwc2_hsotg_en_gsint()
180 static void dwc2_hsotg_disable_gsint(struct dwc2_hsotg *hsotg, u32 ints) in dwc2_hsotg_disable_gsint() argument
182 u32 gsintmsk = dwc2_readl(hsotg, GINTMSK); in dwc2_hsotg_disable_gsint()
188 dwc2_writel(hsotg, new_gsintmsk, GINTMSK); in dwc2_hsotg_disable_gsint()
201 static void dwc2_hsotg_ctrl_epint(struct dwc2_hsotg *hsotg, in dwc2_hsotg_ctrl_epint() argument
213 daint = dwc2_readl(hsotg, DAINTMSK); in dwc2_hsotg_ctrl_epint()
218 dwc2_writel(hsotg, daint, DAINTMSK); in dwc2_hsotg_ctrl_epint()
227 int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg) in dwc2_hsotg_tx_fifo_count() argument
229 if (hsotg->hw_params.en_multiple_tx_fifo) in dwc2_hsotg_tx_fifo_count()
231 return hsotg->hw_params.num_dev_in_eps; in dwc2_hsotg_tx_fifo_count()
234 return hsotg->hw_params.num_dev_perio_in_ep; in dwc2_hsotg_tx_fifo_count()
243 int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) in dwc2_hsotg_tx_fifo_total_depth() argument
249 np_tx_fifo_size = min_t(u32, hsotg->hw_params.dev_nperio_tx_fifo_size, in dwc2_hsotg_tx_fifo_total_depth()
250 hsotg->params.g_np_tx_fifo_size); in dwc2_hsotg_tx_fifo_total_depth()
253 tx_addr_max = hsotg->hw_params.total_fifo_size; in dwc2_hsotg_tx_fifo_total_depth()
255 addr = hsotg->params.g_rx_fifo_size + np_tx_fifo_size; in dwc2_hsotg_tx_fifo_total_depth()
268 static void dwc2_gadget_wkup_alert_handler(struct dwc2_hsotg *hsotg) in dwc2_gadget_wkup_alert_handler() argument
273 gintsts2 = dwc2_readl(hsotg, GINTSTS2); in dwc2_gadget_wkup_alert_handler()
274 gintmsk2 = dwc2_readl(hsotg, GINTMSK2); in dwc2_gadget_wkup_alert_handler()
278 dev_dbg(hsotg->dev, "%s: Wkup_Alert_Int\n", __func__); in dwc2_gadget_wkup_alert_handler()
279 dwc2_set_bit(hsotg, GINTSTS2, GINTSTS2_WKUP_ALERT_INT); in dwc2_gadget_wkup_alert_handler()
280 dwc2_set_bit(hsotg, DCTL, DCTL_RMTWKUPSIG); in dwc2_gadget_wkup_alert_handler()
290 int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg) in dwc2_hsotg_tx_fifo_average_depth() argument
295 tx_fifo_depth = dwc2_hsotg_tx_fifo_total_depth(hsotg); in dwc2_hsotg_tx_fifo_average_depth()
297 tx_fifo_count = dwc2_hsotg_tx_fifo_count(hsotg); in dwc2_hsotg_tx_fifo_average_depth()
309 static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg) in dwc2_hsotg_init_fifo() argument
316 u32 *txfsz = hsotg->params.g_tx_fifo_size; in dwc2_hsotg_init_fifo()
319 WARN_ON(hsotg->fifo_map); in dwc2_hsotg_init_fifo()
320 hsotg->fifo_map = 0; in dwc2_hsotg_init_fifo()
323 dwc2_writel(hsotg, hsotg->params.g_rx_fifo_size, GRXFSIZ); in dwc2_hsotg_init_fifo()
324 dwc2_writel(hsotg, (hsotg->params.g_rx_fifo_size << in dwc2_hsotg_init_fifo()
326 (hsotg->params.g_np_tx_fifo_size << FIFOSIZE_DEPTH_SHIFT), in dwc2_hsotg_init_fifo()
337 addr = hsotg->params.g_rx_fifo_size + hsotg->params.g_np_tx_fifo_size; in dwc2_hsotg_init_fifo()
349 WARN_ONCE(addr + txfsz[ep] > hsotg->fifo_mem, in dwc2_hsotg_init_fifo()
353 dwc2_writel(hsotg, val, DPTXFSIZN(ep)); in dwc2_hsotg_init_fifo()
354 val = dwc2_readl(hsotg, DPTXFSIZN(ep)); in dwc2_hsotg_init_fifo()
357 dwc2_writel(hsotg, hsotg->hw_params.total_fifo_size | in dwc2_hsotg_init_fifo()
365 dwc2_writel(hsotg, GRSTCTL_TXFNUM(0x10) | GRSTCTL_TXFFLSH | in dwc2_hsotg_init_fifo()
371 val = dwc2_readl(hsotg, GRSTCTL); in dwc2_hsotg_init_fifo()
377 dev_err(hsotg->dev, in dwc2_hsotg_init_fifo()
386 dev_dbg(hsotg->dev, "FIFOs reset, timeout at %d\n", timeout); in dwc2_hsotg_init_fifo()
431 static void dwc2_hsotg_unmap_dma(struct dwc2_hsotg *hsotg, in dwc2_hsotg_unmap_dma() argument
437 usb_gadget_unmap_request(&hsotg->gadget, req, hs_ep->map_dir); in dwc2_hsotg_unmap_dma()
448 static int dwc2_gadget_alloc_ctrl_desc_chains(struct dwc2_hsotg *hsotg) in dwc2_gadget_alloc_ctrl_desc_chains() argument
450 hsotg->setup_desc[0] = in dwc2_gadget_alloc_ctrl_desc_chains()
451 dmam_alloc_coherent(hsotg->dev, in dwc2_gadget_alloc_ctrl_desc_chains()
453 &hsotg->setup_desc_dma[0], in dwc2_gadget_alloc_ctrl_desc_chains()
455 if (!hsotg->setup_desc[0]) in dwc2_gadget_alloc_ctrl_desc_chains()
458 hsotg->setup_desc[1] = in dwc2_gadget_alloc_ctrl_desc_chains()
459 dmam_alloc_coherent(hsotg->dev, in dwc2_gadget_alloc_ctrl_desc_chains()
461 &hsotg->setup_desc_dma[1], in dwc2_gadget_alloc_ctrl_desc_chains()
463 if (!hsotg->setup_desc[1]) in dwc2_gadget_alloc_ctrl_desc_chains()
466 hsotg->ctrl_in_desc = in dwc2_gadget_alloc_ctrl_desc_chains()
467 dmam_alloc_coherent(hsotg->dev, in dwc2_gadget_alloc_ctrl_desc_chains()
469 &hsotg->ctrl_in_desc_dma, in dwc2_gadget_alloc_ctrl_desc_chains()
471 if (!hsotg->ctrl_in_desc) in dwc2_gadget_alloc_ctrl_desc_chains()
474 hsotg->ctrl_out_desc = in dwc2_gadget_alloc_ctrl_desc_chains()
475 dmam_alloc_coherent(hsotg->dev, in dwc2_gadget_alloc_ctrl_desc_chains()
477 &hsotg->ctrl_out_desc_dma, in dwc2_gadget_alloc_ctrl_desc_chains()
479 if (!hsotg->ctrl_out_desc) in dwc2_gadget_alloc_ctrl_desc_chains()
504 static int dwc2_hsotg_write_fifo(struct dwc2_hsotg *hsotg, in dwc2_hsotg_write_fifo() argument
509 u32 gnptxsts = dwc2_readl(hsotg, GNPTXSTS); in dwc2_hsotg_write_fifo()
523 if (periodic && !hsotg->dedicated_fifos) { in dwc2_hsotg_write_fifo()
524 u32 epsize = dwc2_readl(hsotg, DIEPTSIZ(hs_ep->index)); in dwc2_hsotg_write_fifo()
540 dwc2_hsotg_en_gsint(hsotg, GINTSTS_PTXFEMP); in dwc2_hsotg_write_fifo()
544 dev_dbg(hsotg->dev, "%s: left=%d, load=%d, fifo=%d, size %d\n", in dwc2_hsotg_write_fifo()
553 dev_dbg(hsotg->dev, "%s: => can_write1=%d\n", in dwc2_hsotg_write_fifo()
557 dev_dbg(hsotg->dev, "%s: => can_write2=%d\n", in dwc2_hsotg_write_fifo()
561 dwc2_hsotg_en_gsint(hsotg, GINTSTS_PTXFEMP); in dwc2_hsotg_write_fifo()
564 } else if (hsotg->dedicated_fifos && hs_ep->index != 0) { in dwc2_hsotg_write_fifo()
565 can_write = dwc2_readl(hsotg, in dwc2_hsotg_write_fifo()
572 dev_dbg(hsotg->dev, in dwc2_hsotg_write_fifo()
576 dwc2_hsotg_en_gsint(hsotg, GINTSTS_NPTXFEMP); in dwc2_hsotg_write_fifo()
586 dev_dbg(hsotg->dev, "%s: GNPTXSTS=%08x, can=%d, to=%d, max_transfer %d\n", in dwc2_hsotg_write_fifo()
606 if (!hsotg->dedicated_fifos) in dwc2_hsotg_write_fifo()
607 dwc2_hsotg_en_gsint(hsotg, in dwc2_hsotg_write_fifo()
635 if (!hsotg->dedicated_fifos) in dwc2_hsotg_write_fifo()
636 dwc2_hsotg_en_gsint(hsotg, in dwc2_hsotg_write_fifo()
641 dev_dbg(hsotg->dev, "write %d/%d, can_write %d, done %d\n", in dwc2_hsotg_write_fifo()
656 dwc2_writel_rep(hsotg, EPFIFO(hs_ep->index), data, to_write); in dwc2_hsotg_write_fifo()
706 static u32 dwc2_hsotg_read_frameno(struct dwc2_hsotg *hsotg) in dwc2_hsotg_read_frameno() argument
710 dsts = dwc2_readl(hsotg, DSTS); in dwc2_hsotg_read_frameno()
914 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_fill_isoc_desc() local
927 dev_dbg(hsotg->dev, "%s: desc chain full\n", __func__); in dwc2_gadget_fill_isoc_desc()
935 dev_dbg(hsotg->dev, "%s: Filling ep %d, dir %s isoc desc # %d\n", in dwc2_gadget_fill_isoc_desc()
983 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_start_isoc_ddma() local
995 dev_dbg(hsotg->dev, "%s: No requests in queue\n", __func__); in dwc2_gadget_start_isoc_ddma()
1026 dwc2_writel(hsotg, hs_ep->desc_list_dma, dma_reg); in dwc2_gadget_start_isoc_ddma()
1028 ctrl = dwc2_readl(hsotg, depctl); in dwc2_gadget_start_isoc_ddma()
1030 dwc2_writel(hsotg, ctrl, depctl); in dwc2_gadget_start_isoc_ddma()
1034 static void dwc2_hsotg_complete_request(struct dwc2_hsotg *hsotg,
1049 static void dwc2_hsotg_start_req(struct dwc2_hsotg *hsotg, in dwc2_hsotg_start_req() argument
1068 dev_err(hsotg->dev, "%s: active request\n", __func__); in dwc2_hsotg_start_req()
1072 dev_err(hsotg->dev, in dwc2_hsotg_start_req()
1083 dev_dbg(hsotg->dev, "%s: DxEPCTL=0x%08x, ep %d, dir %s\n", in dwc2_hsotg_start_req()
1084 __func__, dwc2_readl(hsotg, epctrl_reg), index, in dwc2_hsotg_start_req()
1088 ctrl = dwc2_readl(hsotg, epctrl_reg); in dwc2_hsotg_start_req()
1091 dev_warn(hsotg->dev, "%s: ep%d is stalled\n", __func__, index); in dwc2_hsotg_start_req()
1096 dev_dbg(hsotg->dev, "ureq->length:%d ureq->actual:%d\n", in dwc2_hsotg_start_req()
1099 if (!using_desc_dma(hsotg)) in dwc2_hsotg_start_req()
1107 dev_dbg(hsotg->dev, "%s: length %d, max-req %d, r %d\n", in dwc2_hsotg_start_req()
1144 dev_dbg(hsotg->dev, "%s: %d@%d/%d, 0x%08x => 0x%08x\n", in dwc2_hsotg_start_req()
1150 if (using_desc_dma(hsotg)) { in dwc2_hsotg_start_req()
1170 dwc2_writel(hsotg, hs_ep->desc_list_dma, dma_reg); in dwc2_hsotg_start_req()
1172 dev_dbg(hsotg->dev, "%s: %08x pad => 0x%08x\n", in dwc2_hsotg_start_req()
1176 dwc2_writel(hsotg, epsize, epsize_reg); in dwc2_hsotg_start_req()
1178 if (using_dma(hsotg) && !continuing && (length != 0)) { in dwc2_hsotg_start_req()
1184 dwc2_writel(hsotg, ureq->dma, dma_reg); in dwc2_hsotg_start_req()
1186 dev_dbg(hsotg->dev, "%s: %pad => 0x%08x\n", in dwc2_hsotg_start_req()
1203 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, -ENODATA); in dwc2_hsotg_start_req()
1210 dev_dbg(hsotg->dev, "ep0 state:%d\n", hsotg->ep0_state); in dwc2_hsotg_start_req()
1213 if (!(index == 0 && hsotg->ep0_state == DWC2_EP0_SETUP)) in dwc2_hsotg_start_req()
1216 dev_dbg(hsotg->dev, "%s: DxEPCTL=0x%08x\n", __func__, ctrl); in dwc2_hsotg_start_req()
1217 dwc2_writel(hsotg, ctrl, epctrl_reg); in dwc2_hsotg_start_req()
1227 if (dir_in && !using_dma(hsotg)) { in dwc2_hsotg_start_req()
1231 dwc2_hsotg_write_fifo(hsotg, hs_ep, hs_req); in dwc2_hsotg_start_req()
1240 if (!(dwc2_readl(hsotg, epctrl_reg) & DXEPCTL_EPENA)) in dwc2_hsotg_start_req()
1241 dev_dbg(hsotg->dev, in dwc2_hsotg_start_req()
1243 index, dwc2_readl(hsotg, epctrl_reg)); in dwc2_hsotg_start_req()
1245 dev_dbg(hsotg->dev, "%s: DXEPCTL=0x%08x\n", in dwc2_hsotg_start_req()
1246 __func__, dwc2_readl(hsotg, epctrl_reg)); in dwc2_hsotg_start_req()
1249 dwc2_hsotg_ctrl_epint(hsotg, hs_ep->index, hs_ep->dir_in, 1); in dwc2_hsotg_start_req()
1264 static int dwc2_hsotg_map_dma(struct dwc2_hsotg *hsotg, in dwc2_hsotg_map_dma() argument
1271 ret = usb_gadget_map_request(&hsotg->gadget, req, hs_ep->dir_in); in dwc2_hsotg_map_dma()
1278 dev_err(hsotg->dev, "%s: failed to map buffer %p, %d bytes\n", in dwc2_hsotg_map_dma()
1284 static int dwc2_hsotg_handle_unaligned_buf_start(struct dwc2_hsotg *hsotg, in dwc2_hsotg_handle_unaligned_buf_start() argument
1291 if (!using_dma(hsotg) || !((long)req_buf & 3)) in dwc2_hsotg_handle_unaligned_buf_start()
1296 dev_dbg(hsotg->dev, "%s: %s: buf=%p length=%d\n", __func__, in dwc2_hsotg_handle_unaligned_buf_start()
1302 dev_err(hsotg->dev, in dwc2_hsotg_handle_unaligned_buf_start()
1317 dwc2_hsotg_handle_unaligned_buf_complete(struct dwc2_hsotg *hsotg, in dwc2_hsotg_handle_unaligned_buf_complete() argument
1322 if (!using_dma(hsotg) || !hs_req->saved_req_buf) in dwc2_hsotg_handle_unaligned_buf_complete()
1325 dev_dbg(hsotg->dev, "%s: %s: status=%d actual-length=%d\n", __func__, in dwc2_hsotg_handle_unaligned_buf_complete()
1349 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_target_frame_elapsed() local
1351 u32 current_frame = hsotg->frame_number; in dwc2_gadget_target_frame_elapsed()
1355 if (hsotg->gadget.speed != USB_SPEED_HIGH) in dwc2_gadget_target_frame_elapsed()
1376 static int dwc2_gadget_set_ep0_desc_chain(struct dwc2_hsotg *hsotg, in dwc2_gadget_set_ep0_desc_chain() argument
1379 switch (hsotg->ep0_state) { in dwc2_gadget_set_ep0_desc_chain()
1382 hs_ep->desc_list = hsotg->setup_desc[0]; in dwc2_gadget_set_ep0_desc_chain()
1383 hs_ep->desc_list_dma = hsotg->setup_desc_dma[0]; in dwc2_gadget_set_ep0_desc_chain()
1387 hs_ep->desc_list = hsotg->ctrl_in_desc; in dwc2_gadget_set_ep0_desc_chain()
1388 hs_ep->desc_list_dma = hsotg->ctrl_in_desc_dma; in dwc2_gadget_set_ep0_desc_chain()
1391 hs_ep->desc_list = hsotg->ctrl_out_desc; in dwc2_gadget_set_ep0_desc_chain()
1392 hs_ep->desc_list_dma = hsotg->ctrl_out_desc_dma; in dwc2_gadget_set_ep0_desc_chain()
1395 dev_err(hsotg->dev, "invalid EP 0 state in queue %d\n", in dwc2_gadget_set_ep0_desc_chain()
1396 hsotg->ep0_state); in dwc2_gadget_set_ep0_desc_chain()
1558 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_hsotg_complete_oursetup() local
1560 dev_dbg(hsotg->dev, "%s: ep %p, req %p\n", __func__, ep, req); in dwc2_hsotg_complete_oursetup()
1573 static struct dwc2_hsotg_ep *ep_from_windex(struct dwc2_hsotg *hsotg, in ep_from_windex() argument
1582 if (idx > hsotg->num_of_eps) in ep_from_windex()
1585 return index_to_ep(hsotg, idx, dir); in ep_from_windex()
1594 int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode) in dwc2_hsotg_set_test_mode() argument
1596 int dctl = dwc2_readl(hsotg, DCTL); in dwc2_hsotg_set_test_mode()
1610 dwc2_writel(hsotg, dctl, DCTL); in dwc2_hsotg_set_test_mode()
1624 static int dwc2_hsotg_send_reply(struct dwc2_hsotg *hsotg, in dwc2_hsotg_send_reply() argument
1632 dev_dbg(hsotg->dev, "%s: buff %p, len %d\n", __func__, buff, length); in dwc2_hsotg_send_reply()
1635 hsotg->ep0_reply = req; in dwc2_hsotg_send_reply()
1637 dev_warn(hsotg->dev, "%s: cannot alloc req\n", __func__); in dwc2_hsotg_send_reply()
1641 req->buf = hsotg->ep0_buff; in dwc2_hsotg_send_reply()
1655 dev_warn(hsotg->dev, "%s: cannot queue req\n", __func__); in dwc2_hsotg_send_reply()
1667 static int dwc2_hsotg_process_req_status(struct dwc2_hsotg *hsotg, in dwc2_hsotg_process_req_status() argument
1670 struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0]; in dwc2_hsotg_process_req_status()
1676 dev_dbg(hsotg->dev, "%s: USB_REQ_GET_STATUS\n", __func__); in dwc2_hsotg_process_req_status()
1679 dev_warn(hsotg->dev, "%s: direction out?\n", __func__); in dwc2_hsotg_process_req_status()
1685 status = hsotg->gadget.is_selfpowered << in dwc2_hsotg_process_req_status()
1687 status |= hsotg->remote_wakeup_allowed << in dwc2_hsotg_process_req_status()
1698 ep = ep_from_windex(hsotg, le16_to_cpu(ctrl->wIndex)); in dwc2_hsotg_process_req_status()
1712 ret = dwc2_hsotg_send_reply(hsotg, ep0, &reply, 2); in dwc2_hsotg_process_req_status()
1714 dev_err(hsotg->dev, "%s: failed to send reply\n", __func__); in dwc2_hsotg_process_req_status()
1745 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_start_next_request() local
1751 dwc2_hsotg_start_req(hsotg, hs_ep, hs_req, false); in dwc2_gadget_start_next_request()
1758 dev_dbg(hsotg->dev, "%s: No more ISOC-IN requests\n", in dwc2_gadget_start_next_request()
1761 dev_dbg(hsotg->dev, "%s: No more ISOC-OUT requests\n", in dwc2_gadget_start_next_request()
1771 static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg, in dwc2_hsotg_process_req_feature() argument
1774 struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0]; in dwc2_hsotg_process_req_feature()
1784 dev_dbg(hsotg->dev, "%s: %s_FEATURE\n", in dwc2_hsotg_process_req_feature()
1796 hsotg->remote_wakeup_allowed = 1; in dwc2_hsotg_process_req_feature()
1798 hsotg->remote_wakeup_allowed = 0; in dwc2_hsotg_process_req_feature()
1807 hsotg->test_mode = wIndex >> 8; in dwc2_hsotg_process_req_feature()
1813 ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0); in dwc2_hsotg_process_req_feature()
1815 dev_err(hsotg->dev, in dwc2_hsotg_process_req_feature()
1822 ep = ep_from_windex(hsotg, wIndex); in dwc2_hsotg_process_req_feature()
1824 dev_dbg(hsotg->dev, "%s: no endpoint for 0x%04x\n", in dwc2_hsotg_process_req_feature()
1836 ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0); in dwc2_hsotg_process_req_feature()
1838 dev_err(hsotg->dev, in dwc2_hsotg_process_req_feature()
1858 spin_unlock(&hsotg->lock); in dwc2_hsotg_process_req_feature()
1861 spin_lock(&hsotg->lock); in dwc2_hsotg_process_req_feature()
1882 static void dwc2_hsotg_enqueue_setup(struct dwc2_hsotg *hsotg);
1890 static void dwc2_hsotg_stall_ep0(struct dwc2_hsotg *hsotg) in dwc2_hsotg_stall_ep0() argument
1892 struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0]; in dwc2_hsotg_stall_ep0()
1896 dev_dbg(hsotg->dev, "ep0 stall (dir=%d)\n", ep0->dir_in); in dwc2_hsotg_stall_ep0()
1904 ctrl = dwc2_readl(hsotg, reg); in dwc2_hsotg_stall_ep0()
1907 dwc2_writel(hsotg, ctrl, reg); in dwc2_hsotg_stall_ep0()
1909 dev_dbg(hsotg->dev, in dwc2_hsotg_stall_ep0()
1911 ctrl, reg, dwc2_readl(hsotg, reg)); in dwc2_hsotg_stall_ep0()
1917 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_stall_ep0()
1929 static void dwc2_hsotg_process_control(struct dwc2_hsotg *hsotg, in dwc2_hsotg_process_control() argument
1932 struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0]; in dwc2_hsotg_process_control()
1936 dev_dbg(hsotg->dev, in dwc2_hsotg_process_control()
1943 hsotg->ep0_state = DWC2_EP0_STATUS_IN; in dwc2_hsotg_process_control()
1946 hsotg->ep0_state = DWC2_EP0_DATA_IN; in dwc2_hsotg_process_control()
1949 hsotg->ep0_state = DWC2_EP0_DATA_OUT; in dwc2_hsotg_process_control()
1955 hsotg->connected = 1; in dwc2_hsotg_process_control()
1956 dcfg = dwc2_readl(hsotg, DCFG); in dwc2_hsotg_process_control()
1960 dwc2_writel(hsotg, dcfg, DCFG); in dwc2_hsotg_process_control()
1962 dev_info(hsotg->dev, "new address %d\n", ctrl->wValue); in dwc2_hsotg_process_control()
1964 ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0); in dwc2_hsotg_process_control()
1968 ret = dwc2_hsotg_process_req_status(hsotg, ctrl); in dwc2_hsotg_process_control()
1973 ret = dwc2_hsotg_process_req_feature(hsotg, ctrl); in dwc2_hsotg_process_control()
1980 if (ret == 0 && hsotg->driver) { in dwc2_hsotg_process_control()
1981 spin_unlock(&hsotg->lock); in dwc2_hsotg_process_control()
1982 ret = hsotg->driver->setup(&hsotg->gadget, ctrl); in dwc2_hsotg_process_control()
1983 spin_lock(&hsotg->lock); in dwc2_hsotg_process_control()
1985 dev_dbg(hsotg->dev, "driver->setup() ret %d\n", ret); in dwc2_hsotg_process_control()
1988 hsotg->delayed_status = false; in dwc2_hsotg_process_control()
1990 hsotg->delayed_status = true; in dwc2_hsotg_process_control()
1998 dwc2_hsotg_stall_ep0(hsotg); in dwc2_hsotg_process_control()
2013 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_hsotg_complete_setup() local
2016 dev_dbg(hsotg->dev, "%s: failed %d\n", __func__, req->status); in dwc2_hsotg_complete_setup()
2020 spin_lock(&hsotg->lock); in dwc2_hsotg_complete_setup()
2022 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_complete_setup()
2024 dwc2_hsotg_process_control(hsotg, req->buf); in dwc2_hsotg_complete_setup()
2025 spin_unlock(&hsotg->lock); in dwc2_hsotg_complete_setup()
2035 static void dwc2_hsotg_enqueue_setup(struct dwc2_hsotg *hsotg) in dwc2_hsotg_enqueue_setup() argument
2037 struct usb_request *req = hsotg->ctrl_req; in dwc2_hsotg_enqueue_setup()
2041 dev_dbg(hsotg->dev, "%s: queueing setup request\n", __func__); in dwc2_hsotg_enqueue_setup()
2045 req->buf = hsotg->ctrl_buff; in dwc2_hsotg_enqueue_setup()
2049 dev_dbg(hsotg->dev, "%s already queued???\n", __func__); in dwc2_hsotg_enqueue_setup()
2053 hsotg->eps_out[0]->dir_in = 0; in dwc2_hsotg_enqueue_setup()
2054 hsotg->eps_out[0]->send_zlp = 0; in dwc2_hsotg_enqueue_setup()
2055 hsotg->ep0_state = DWC2_EP0_SETUP; in dwc2_hsotg_enqueue_setup()
2057 ret = dwc2_hsotg_ep_queue(&hsotg->eps_out[0]->ep, req, GFP_ATOMIC); in dwc2_hsotg_enqueue_setup()
2059 dev_err(hsotg->dev, "%s: failed queue (%d)\n", __func__, ret); in dwc2_hsotg_enqueue_setup()
2067 static void dwc2_hsotg_program_zlp(struct dwc2_hsotg *hsotg, in dwc2_hsotg_program_zlp() argument
2076 dev_dbg(hsotg->dev, "Sending zero-length packet on ep%d\n", in dwc2_hsotg_program_zlp()
2079 dev_dbg(hsotg->dev, "Receiving zero-length packet on ep%d\n", in dwc2_hsotg_program_zlp()
2081 if (using_desc_dma(hsotg)) { in dwc2_hsotg_program_zlp()
2086 dwc2_gadget_set_ep0_desc_chain(hsotg, hs_ep); in dwc2_hsotg_program_zlp()
2090 dwc2_writel(hsotg, DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) | in dwc2_hsotg_program_zlp()
2095 ctrl = dwc2_readl(hsotg, epctl_reg); in dwc2_hsotg_program_zlp()
2099 dwc2_writel(hsotg, ctrl, epctl_reg); in dwc2_hsotg_program_zlp()
2115 static void dwc2_hsotg_complete_request(struct dwc2_hsotg *hsotg, in dwc2_hsotg_complete_request() argument
2121 dev_dbg(hsotg->dev, "%s: nothing to complete?\n", __func__); in dwc2_hsotg_complete_request()
2125 dev_dbg(hsotg->dev, "complete: ep %p %s, req %p, %d => %p\n", in dwc2_hsotg_complete_request()
2136 if (using_dma(hsotg)) in dwc2_hsotg_complete_request()
2137 dwc2_hsotg_unmap_dma(hsotg, hs_ep, hs_req); in dwc2_hsotg_complete_request()
2139 dwc2_hsotg_handle_unaligned_buf_complete(hsotg, hs_ep, hs_req); in dwc2_hsotg_complete_request()
2150 spin_unlock(&hsotg->lock); in dwc2_hsotg_complete_request()
2152 spin_lock(&hsotg->lock); in dwc2_hsotg_complete_request()
2156 if (using_desc_dma(hsotg) && hs_ep->isochronous) in dwc2_hsotg_complete_request()
2180 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_complete_isoc_request_ddma() local
2194 dev_warn(hsotg->dev, "%s: ISOC EP queue empty\n", __func__); in dwc2_gadget_complete_isoc_request_ddma()
2219 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0); in dwc2_gadget_complete_isoc_request_ddma()
2239 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_handle_isoc_bna() local
2242 dwc2_flush_rx_fifo(hsotg); in dwc2_gadget_handle_isoc_bna()
2243 dwc2_hsotg_complete_request(hsotg, hs_ep, get_ep_head(hs_ep), 0); in dwc2_gadget_handle_isoc_bna()
2260 static void dwc2_hsotg_rx_data(struct dwc2_hsotg *hsotg, int ep_idx, int size) in dwc2_hsotg_rx_data() argument
2262 struct dwc2_hsotg_ep *hs_ep = hsotg->eps_out[ep_idx]; in dwc2_hsotg_rx_data()
2269 u32 epctl = dwc2_readl(hsotg, DOEPCTL(ep_idx)); in dwc2_hsotg_rx_data()
2272 dev_dbg(hsotg->dev, in dwc2_hsotg_rx_data()
2278 (void)dwc2_readl(hsotg, EPFIFO(ep_idx)); in dwc2_hsotg_rx_data()
2287 dev_dbg(hsotg->dev, "%s: read %d/%d, done %d/%d\n", in dwc2_hsotg_rx_data()
2308 dwc2_readl_rep(hsotg, EPFIFO(ep_idx), in dwc2_hsotg_rx_data()
2324 static void dwc2_hsotg_ep0_zlp(struct dwc2_hsotg *hsotg, bool dir_in) in dwc2_hsotg_ep0_zlp() argument
2327 hsotg->eps_out[0]->dir_in = dir_in; in dwc2_hsotg_ep0_zlp()
2328 hsotg->ep0_state = dir_in ? DWC2_EP0_STATUS_IN : DWC2_EP0_STATUS_OUT; in dwc2_hsotg_ep0_zlp()
2330 dwc2_hsotg_program_zlp(hsotg, hsotg->eps_out[0]); in dwc2_hsotg_ep0_zlp()
2343 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_get_xfersize_ddma() local
2366 dev_err(hsotg->dev, "descriptor %d closed with %x\n", in dwc2_gadget_get_xfersize_ddma()
2387 static void dwc2_hsotg_handle_outdone(struct dwc2_hsotg *hsotg, int epnum) in dwc2_hsotg_handle_outdone() argument
2389 u32 epsize = dwc2_readl(hsotg, DOEPTSIZ(epnum)); in dwc2_hsotg_handle_outdone()
2390 struct dwc2_hsotg_ep *hs_ep = hsotg->eps_out[epnum]; in dwc2_hsotg_handle_outdone()
2397 dev_dbg(hsotg->dev, "%s: no request active\n", __func__); in dwc2_hsotg_handle_outdone()
2401 if (epnum == 0 && hsotg->ep0_state == DWC2_EP0_STATUS_OUT) { in dwc2_hsotg_handle_outdone()
2402 dev_dbg(hsotg->dev, "zlp packet received\n"); in dwc2_hsotg_handle_outdone()
2403 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0); in dwc2_hsotg_handle_outdone()
2404 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_handle_outdone()
2408 if (using_desc_dma(hsotg)) in dwc2_hsotg_handle_outdone()
2411 if (using_dma(hsotg)) { in dwc2_hsotg_handle_outdone()
2431 dwc2_hsotg_start_req(hsotg, hs_ep, hs_req, true); in dwc2_hsotg_handle_outdone()
2436 dev_dbg(hsotg->dev, "%s: got %d/%d (short not ok) => error\n", in dwc2_hsotg_handle_outdone()
2446 if (!using_desc_dma(hsotg) && epnum == 0 && in dwc2_hsotg_handle_outdone()
2447 hsotg->ep0_state == DWC2_EP0_DATA_OUT) { in dwc2_hsotg_handle_outdone()
2449 if (!hsotg->delayed_status) in dwc2_hsotg_handle_outdone()
2450 dwc2_hsotg_ep0_zlp(hsotg, true); in dwc2_hsotg_handle_outdone()
2454 if (!using_desc_dma(hsotg) && hs_ep->isochronous) { in dwc2_hsotg_handle_outdone()
2459 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, result); in dwc2_hsotg_handle_outdone()
2478 static void dwc2_hsotg_handle_rx(struct dwc2_hsotg *hsotg) in dwc2_hsotg_handle_rx() argument
2480 u32 grxstsr = dwc2_readl(hsotg, GRXSTSP); in dwc2_hsotg_handle_rx()
2483 WARN_ON(using_dma(hsotg)); in dwc2_hsotg_handle_rx()
2491 dev_dbg(hsotg->dev, "%s: GRXSTSP=0x%08x (%d@%d)\n", in dwc2_hsotg_handle_rx()
2496 dev_dbg(hsotg->dev, "GLOBALOUTNAK\n"); in dwc2_hsotg_handle_rx()
2500 dev_dbg(hsotg->dev, "OutDone (Frame=0x%08x)\n", in dwc2_hsotg_handle_rx()
2501 dwc2_hsotg_read_frameno(hsotg)); in dwc2_hsotg_handle_rx()
2503 if (!using_dma(hsotg)) in dwc2_hsotg_handle_rx()
2504 dwc2_hsotg_handle_outdone(hsotg, epnum); in dwc2_hsotg_handle_rx()
2508 dev_dbg(hsotg->dev, in dwc2_hsotg_handle_rx()
2510 dwc2_hsotg_read_frameno(hsotg), in dwc2_hsotg_handle_rx()
2511 dwc2_readl(hsotg, DOEPCTL(0))); in dwc2_hsotg_handle_rx()
2517 if (hsotg->ep0_state == DWC2_EP0_SETUP) in dwc2_hsotg_handle_rx()
2518 dwc2_hsotg_handle_outdone(hsotg, epnum); in dwc2_hsotg_handle_rx()
2522 dwc2_hsotg_rx_data(hsotg, epnum, size); in dwc2_hsotg_handle_rx()
2526 dev_dbg(hsotg->dev, in dwc2_hsotg_handle_rx()
2528 dwc2_hsotg_read_frameno(hsotg), in dwc2_hsotg_handle_rx()
2529 dwc2_readl(hsotg, DOEPCTL(0))); in dwc2_hsotg_handle_rx()
2531 WARN_ON(hsotg->ep0_state != DWC2_EP0_SETUP); in dwc2_hsotg_handle_rx()
2533 dwc2_hsotg_rx_data(hsotg, epnum, size); in dwc2_hsotg_handle_rx()
2537 dev_warn(hsotg->dev, "%s: unknown status %08x\n", in dwc2_hsotg_handle_rx()
2540 dwc2_hsotg_dump(hsotg); in dwc2_hsotg_handle_rx()
2578 static void dwc2_hsotg_set_ep_maxpacket(struct dwc2_hsotg *hsotg, in dwc2_hsotg_set_ep_maxpacket() argument
2585 hs_ep = index_to_ep(hsotg, ep, dir_in); in dwc2_hsotg_set_ep_maxpacket()
2608 reg = dwc2_readl(hsotg, DIEPCTL(ep)); in dwc2_hsotg_set_ep_maxpacket()
2611 dwc2_writel(hsotg, reg, DIEPCTL(ep)); in dwc2_hsotg_set_ep_maxpacket()
2613 reg = dwc2_readl(hsotg, DOEPCTL(ep)); in dwc2_hsotg_set_ep_maxpacket()
2616 dwc2_writel(hsotg, reg, DOEPCTL(ep)); in dwc2_hsotg_set_ep_maxpacket()
2622 dev_err(hsotg->dev, "ep%d: bad mps of %d\n", ep, mps); in dwc2_hsotg_set_ep_maxpacket()
2630 static void dwc2_hsotg_txfifo_flush(struct dwc2_hsotg *hsotg, unsigned int idx) in dwc2_hsotg_txfifo_flush() argument
2632 dwc2_writel(hsotg, GRSTCTL_TXFNUM(idx) | GRSTCTL_TXFFLSH, in dwc2_hsotg_txfifo_flush()
2636 if (dwc2_hsotg_wait_bit_clear(hsotg, GRSTCTL, GRSTCTL_TXFFLSH, 100)) in dwc2_hsotg_txfifo_flush()
2637 dev_warn(hsotg->dev, "%s: timeout flushing fifo GRSTCTL_TXFFLSH\n", in dwc2_hsotg_txfifo_flush()
2649 static int dwc2_hsotg_trytx(struct dwc2_hsotg *hsotg, in dwc2_hsotg_trytx() argument
2660 dwc2_hsotg_ctrl_epint(hsotg, hs_ep->index, in dwc2_hsotg_trytx()
2666 dev_dbg(hsotg->dev, "trying to write more for ep%d\n", in dwc2_hsotg_trytx()
2668 return dwc2_hsotg_write_fifo(hsotg, hs_ep, hs_req); in dwc2_hsotg_trytx()
2682 static void dwc2_hsotg_complete_in(struct dwc2_hsotg *hsotg, in dwc2_hsotg_complete_in() argument
2686 u32 epsize = dwc2_readl(hsotg, DIEPTSIZ(hs_ep->index)); in dwc2_hsotg_complete_in()
2690 dev_dbg(hsotg->dev, "XferCompl but no req\n"); in dwc2_hsotg_complete_in()
2695 if (hs_ep->index == 0 && hsotg->ep0_state == DWC2_EP0_STATUS_IN) { in dwc2_hsotg_complete_in()
2696 dev_dbg(hsotg->dev, "zlp packet sent\n"); in dwc2_hsotg_complete_in()
2704 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0); in dwc2_hsotg_complete_in()
2705 if (hsotg->test_mode) { in dwc2_hsotg_complete_in()
2708 ret = dwc2_hsotg_set_test_mode(hsotg, hsotg->test_mode); in dwc2_hsotg_complete_in()
2710 dev_dbg(hsotg->dev, "Invalid Test #%d\n", in dwc2_hsotg_complete_in()
2711 hsotg->test_mode); in dwc2_hsotg_complete_in()
2712 dwc2_hsotg_stall_ep0(hsotg); in dwc2_hsotg_complete_in()
2716 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_complete_in()
2729 if (using_desc_dma(hsotg)) { in dwc2_hsotg_complete_in()
2732 dev_err(hsotg->dev, "error parsing DDMA results %d\n", in dwc2_hsotg_complete_in()
2742 dev_dbg(hsotg->dev, "%s: adjusting size done %d => %d\n", in dwc2_hsotg_complete_in()
2746 dev_dbg(hsotg->dev, "req->length:%d req->actual:%d req->zero:%d\n", in dwc2_hsotg_complete_in()
2750 dev_dbg(hsotg->dev, "%s trying more for req...\n", __func__); in dwc2_hsotg_complete_in()
2751 dwc2_hsotg_start_req(hsotg, hs_ep, hs_req, true); in dwc2_hsotg_complete_in()
2758 if (!using_desc_dma(hsotg)) { in dwc2_hsotg_complete_in()
2759 dwc2_hsotg_program_zlp(hsotg, hs_ep); in dwc2_hsotg_complete_in()
2765 if (hs_ep->index == 0 && hsotg->ep0_state == DWC2_EP0_DATA_IN) { in dwc2_hsotg_complete_in()
2767 dwc2_hsotg_ep0_zlp(hsotg, false); in dwc2_hsotg_complete_in()
2772 if (!using_desc_dma(hsotg) && hs_ep->isochronous) { in dwc2_hsotg_complete_in()
2777 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0); in dwc2_hsotg_complete_in()
2789 static u32 dwc2_gadget_read_ep_interrupts(struct dwc2_hsotg *hsotg, in dwc2_gadget_read_ep_interrupts() argument
2798 mask = dwc2_readl(hsotg, epmsk_reg); in dwc2_gadget_read_ep_interrupts()
2799 diepempmsk = dwc2_readl(hsotg, DIEPEMPMSK); in dwc2_gadget_read_ep_interrupts()
2803 ints = dwc2_readl(hsotg, epint_reg); in dwc2_gadget_read_ep_interrupts()
2823 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_handle_ep_disabled() local
2828 int dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_handle_ep_disabled()
2830 dev_dbg(hsotg->dev, "%s: EPDisbld\n", __func__); in dwc2_gadget_handle_ep_disabled()
2833 int epctl = dwc2_readl(hsotg, epctl_reg); in dwc2_gadget_handle_ep_disabled()
2835 dwc2_hsotg_txfifo_flush(hsotg, hs_ep->fifo_index); in dwc2_gadget_handle_ep_disabled()
2838 int dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_handle_ep_disabled()
2841 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_handle_ep_disabled()
2847 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_handle_ep_disabled()
2855 dev_dbg(hsotg->dev, "%s: complete_ep 0x%p, ep->queue empty!\n", in dwc2_gadget_handle_ep_disabled()
2865 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, in dwc2_gadget_handle_ep_disabled()
2870 hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg); in dwc2_gadget_handle_ep_disabled()
2887 struct dwc2_hsotg *hsotg = ep->parent; in dwc2_gadget_handle_out_token_ep_disabled() local
2894 if (using_desc_dma(hsotg)) { in dwc2_gadget_handle_out_token_ep_disabled()
2897 ep->target_frame = hsotg->frame_number; in dwc2_gadget_handle_out_token_ep_disabled()
2906 ep->target_frame = hsotg->frame_number; in dwc2_gadget_handle_out_token_ep_disabled()
2908 ctrl = dwc2_readl(hsotg, DOEPCTL(ep->index)); in dwc2_gadget_handle_out_token_ep_disabled()
2914 dwc2_writel(hsotg, ctrl, DOEPCTL(ep->index)); in dwc2_gadget_handle_out_token_ep_disabled()
2923 dwc2_hsotg_complete_request(hsotg, ep, hs_req, -ENODATA); in dwc2_gadget_handle_out_token_ep_disabled()
2928 hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg); in dwc2_gadget_handle_out_token_ep_disabled()
2936 static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg,
2955 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_gadget_handle_nak() local
2965 if (using_desc_dma(hsotg)) { in dwc2_gadget_handle_nak()
2966 hs_ep->target_frame = hsotg->frame_number; in dwc2_gadget_handle_nak()
2972 if (hsotg->params.service_interval) { in dwc2_gadget_handle_nak()
2989 hs_ep->target_frame = hsotg->frame_number; in dwc2_gadget_handle_nak()
2991 u32 ctrl = dwc2_readl(hsotg, in dwc2_gadget_handle_nak()
2998 dwc2_writel(hsotg, ctrl, DIEPCTL(hs_ep->index)); in dwc2_gadget_handle_nak()
3002 if (using_desc_dma(hsotg)) in dwc2_gadget_handle_nak()
3005 ctrl = dwc2_readl(hsotg, DIEPCTL(hs_ep->index)); in dwc2_gadget_handle_nak()
3007 dwc2_hsotg_ep_stop_xfr(hsotg, hs_ep); in dwc2_gadget_handle_nak()
3009 dwc2_hsotg_txfifo_flush(hsotg, hs_ep->fifo_index); in dwc2_gadget_handle_nak()
3016 dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, -ENODATA); in dwc2_gadget_handle_nak()
3021 hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg); in dwc2_gadget_handle_nak()
3036 static void dwc2_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, in dwc2_hsotg_epint() argument
3039 struct dwc2_hsotg_ep *hs_ep = index_to_ep(hsotg, idx, dir_in); in dwc2_hsotg_epint()
3045 ints = dwc2_gadget_read_ep_interrupts(hsotg, idx, dir_in); in dwc2_hsotg_epint()
3048 dwc2_writel(hsotg, ints, epint_reg); in dwc2_hsotg_epint()
3051 dev_err(hsotg->dev, "%s:Interrupt for unconfigured ep%d(%s)\n", in dwc2_hsotg_epint()
3056 dev_dbg(hsotg->dev, "%s: ep%d(%s) DxEPINT=0x%08x\n", in dwc2_hsotg_epint()
3069 if (using_desc_dma(hsotg) && idx == 0 && !hs_ep->dir_in && in dwc2_hsotg_epint()
3070 hsotg->ep0_state == DWC2_EP0_SETUP && !(ints & DXEPINT_SETUP)) in dwc2_hsotg_epint()
3074 dev_dbg(hsotg->dev, in dwc2_hsotg_epint()
3076 __func__, dwc2_readl(hsotg, epctl_reg), in dwc2_hsotg_epint()
3077 dwc2_readl(hsotg, epsiz_reg)); in dwc2_hsotg_epint()
3080 if (using_desc_dma(hsotg) && hs_ep->isochronous) { in dwc2_hsotg_epint()
3089 dwc2_hsotg_complete_in(hsotg, hs_ep); in dwc2_hsotg_epint()
3092 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_epint()
3093 } else if (using_dma(hsotg)) { in dwc2_hsotg_epint()
3099 dwc2_hsotg_handle_outdone(hsotg, idx); in dwc2_hsotg_epint()
3113 dev_dbg(hsotg->dev, "%s: AHBErr\n", __func__); in dwc2_hsotg_epint()
3116 dev_dbg(hsotg->dev, "%s: Setup/Timeout\n", __func__); in dwc2_hsotg_epint()
3118 if (using_dma(hsotg) && idx == 0) { in dwc2_hsotg_epint()
3129 dwc2_hsotg_handle_outdone(hsotg, 0); in dwc2_hsotg_epint()
3134 dev_dbg(hsotg->dev, "%s: StsPhseRcvd\n", __func__); in dwc2_hsotg_epint()
3137 if (hsotg->ep0_state == DWC2_EP0_DATA_OUT) { in dwc2_hsotg_epint()
3139 if (using_desc_dma(hsotg)) { in dwc2_hsotg_epint()
3140 if (!hsotg->delayed_status) in dwc2_hsotg_epint()
3141 dwc2_hsotg_ep0_zlp(hsotg, true); in dwc2_hsotg_epint()
3150 dwc2_set_bit(hsotg, DIEPCTL(0), in dwc2_hsotg_epint()
3158 dev_dbg(hsotg->dev, "%s: B2BSetup/INEPNakEff\n", __func__); in dwc2_hsotg_epint()
3161 dev_dbg(hsotg->dev, "%s: BNA interrupt\n", __func__); in dwc2_hsotg_epint()
3169 dev_dbg(hsotg->dev, "%s: ep%d: INTknTXFEmpMsk\n", in dwc2_hsotg_epint()
3175 dev_warn(hsotg->dev, "%s: ep%d: INTknEP\n", in dwc2_hsotg_epint()
3180 if (hsotg->dedicated_fifos && in dwc2_hsotg_epint()
3182 dev_dbg(hsotg->dev, "%s: ep%d: TxFIFOEmpty\n", in dwc2_hsotg_epint()
3184 if (!using_dma(hsotg)) in dwc2_hsotg_epint()
3185 dwc2_hsotg_trytx(hsotg, hs_ep); in dwc2_hsotg_epint()
3197 static void dwc2_hsotg_irq_enumdone(struct dwc2_hsotg *hsotg) in dwc2_hsotg_irq_enumdone() argument
3199 u32 dsts = dwc2_readl(hsotg, DSTS); in dwc2_hsotg_irq_enumdone()
3208 dev_dbg(hsotg->dev, "EnumDone (DSTS=0x%08x)\n", dsts); in dwc2_hsotg_irq_enumdone()
3220 hsotg->gadget.speed = USB_SPEED_FULL; in dwc2_hsotg_irq_enumdone()
3226 hsotg->gadget.speed = USB_SPEED_HIGH; in dwc2_hsotg_irq_enumdone()
3232 hsotg->gadget.speed = USB_SPEED_LOW; in dwc2_hsotg_irq_enumdone()
3242 dev_info(hsotg->dev, "new device is %s\n", in dwc2_hsotg_irq_enumdone()
3243 usb_speed_string(hsotg->gadget.speed)); in dwc2_hsotg_irq_enumdone()
3253 dwc2_hsotg_set_ep_maxpacket(hsotg, 0, ep0_mps, 0, 1); in dwc2_hsotg_irq_enumdone()
3254 dwc2_hsotg_set_ep_maxpacket(hsotg, 0, ep0_mps, 0, 0); in dwc2_hsotg_irq_enumdone()
3255 for (i = 1; i < hsotg->num_of_eps; i++) { in dwc2_hsotg_irq_enumdone()
3256 if (hsotg->eps_in[i]) in dwc2_hsotg_irq_enumdone()
3257 dwc2_hsotg_set_ep_maxpacket(hsotg, i, ep_mps, in dwc2_hsotg_irq_enumdone()
3259 if (hsotg->eps_out[i]) in dwc2_hsotg_irq_enumdone()
3260 dwc2_hsotg_set_ep_maxpacket(hsotg, i, ep_mps, in dwc2_hsotg_irq_enumdone()
3267 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_irq_enumdone()
3269 dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", in dwc2_hsotg_irq_enumdone()
3270 dwc2_readl(hsotg, DIEPCTL0), in dwc2_hsotg_irq_enumdone()
3271 dwc2_readl(hsotg, DOEPCTL0)); in dwc2_hsotg_irq_enumdone()
3283 static void kill_all_requests(struct dwc2_hsotg *hsotg, in kill_all_requests() argument
3294 dwc2_hsotg_complete_request(hsotg, ep, req, result); in kill_all_requests()
3297 if (!hsotg->dedicated_fifos) in kill_all_requests()
3299 size = (dwc2_readl(hsotg, DTXFSTS(ep->fifo_index)) & 0xffff) * 4; in kill_all_requests()
3301 dwc2_hsotg_txfifo_flush(hsotg, ep->fifo_index); in kill_all_requests()
3312 void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg) in dwc2_hsotg_disconnect() argument
3316 if (!hsotg->connected) in dwc2_hsotg_disconnect()
3319 hsotg->connected = 0; in dwc2_hsotg_disconnect()
3320 hsotg->test_mode = 0; in dwc2_hsotg_disconnect()
3323 for (ep = 0; ep < hsotg->num_of_eps; ep++) { in dwc2_hsotg_disconnect()
3324 if (hsotg->eps_in[ep]) in dwc2_hsotg_disconnect()
3325 kill_all_requests(hsotg, hsotg->eps_in[ep], in dwc2_hsotg_disconnect()
3327 if (hsotg->eps_out[ep]) in dwc2_hsotg_disconnect()
3328 kill_all_requests(hsotg, hsotg->eps_out[ep], in dwc2_hsotg_disconnect()
3332 call_gadget(hsotg, disconnect); in dwc2_hsotg_disconnect()
3333 hsotg->lx_state = DWC2_L3; in dwc2_hsotg_disconnect()
3335 usb_gadget_set_state(&hsotg->gadget, USB_STATE_NOTATTACHED); in dwc2_hsotg_disconnect()
3343 static void dwc2_hsotg_irq_fifoempty(struct dwc2_hsotg *hsotg, bool periodic) in dwc2_hsotg_irq_fifoempty() argument
3349 for (epno = 0; epno < hsotg->num_of_eps; epno++) { in dwc2_hsotg_irq_fifoempty()
3350 ep = index_to_ep(hsotg, epno, 1); in dwc2_hsotg_irq_fifoempty()
3362 ret = dwc2_hsotg_trytx(hsotg, ep); in dwc2_hsotg_irq_fifoempty()
3381 void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, in dwc2_hsotg_core_init_disconnected() argument
3391 kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET); in dwc2_hsotg_core_init_disconnected()
3394 if (dwc2_core_reset(hsotg, true)) in dwc2_hsotg_core_init_disconnected()
3398 for (ep = 1; ep < hsotg->num_of_eps; ep++) { in dwc2_hsotg_core_init_disconnected()
3399 if (hsotg->eps_in[ep]) in dwc2_hsotg_core_init_disconnected()
3400 dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep); in dwc2_hsotg_core_init_disconnected()
3401 if (hsotg->eps_out[ep]) in dwc2_hsotg_core_init_disconnected()
3402 dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep); in dwc2_hsotg_core_init_disconnected()
3412 usbcfg = dwc2_readl(hsotg, GUSBCFG); in dwc2_hsotg_core_init_disconnected()
3418 dwc2_writel(hsotg, usbcfg, GUSBCFG); in dwc2_hsotg_core_init_disconnected()
3420 dwc2_phy_init(hsotg, true); in dwc2_hsotg_core_init_disconnected()
3422 dwc2_hsotg_init_fifo(hsotg); in dwc2_hsotg_core_init_disconnected()
3425 dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON); in dwc2_hsotg_core_init_disconnected()
3429 switch (hsotg->params.speed) { in dwc2_hsotg_core_init_disconnected()
3434 if (hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM_FS) in dwc2_hsotg_core_init_disconnected()
3443 if (hsotg->params.ipg_isoc_en) in dwc2_hsotg_core_init_disconnected()
3446 dwc2_writel(hsotg, dcfg, DCFG); in dwc2_hsotg_core_init_disconnected()
3449 dwc2_writel(hsotg, 0xffffffff, GOTGINT); in dwc2_hsotg_core_init_disconnected()
3452 dwc2_writel(hsotg, 0xffffffff, GINTSTS); in dwc2_hsotg_core_init_disconnected()
3460 if (!using_desc_dma(hsotg)) in dwc2_hsotg_core_init_disconnected()
3463 if (!hsotg->params.external_id_pin_ctl) in dwc2_hsotg_core_init_disconnected()
3466 dwc2_writel(hsotg, intmsk, GINTMSK); in dwc2_hsotg_core_init_disconnected()
3468 if (using_dma(hsotg)) { in dwc2_hsotg_core_init_disconnected()
3469 dwc2_writel(hsotg, GAHBCFG_GLBL_INTR_EN | GAHBCFG_DMA_EN | in dwc2_hsotg_core_init_disconnected()
3470 hsotg->params.ahbcfg, in dwc2_hsotg_core_init_disconnected()
3474 if (using_desc_dma(hsotg)) in dwc2_hsotg_core_init_disconnected()
3475 dwc2_set_bit(hsotg, DCFG, DCFG_DESCDMA_EN); in dwc2_hsotg_core_init_disconnected()
3478 dwc2_writel(hsotg, ((hsotg->dedicated_fifos) ? in dwc2_hsotg_core_init_disconnected()
3490 dwc2_writel(hsotg, ((hsotg->dedicated_fifos && !using_dma(hsotg)) ? in dwc2_hsotg_core_init_disconnected()
3500 dwc2_writel(hsotg, (using_dma(hsotg) ? (DIEPMSK_XFERCOMPLMSK | in dwc2_hsotg_core_init_disconnected()
3507 if (using_desc_dma(hsotg)) { in dwc2_hsotg_core_init_disconnected()
3508 dwc2_set_bit(hsotg, DOEPMSK, DOEPMSK_BNAMSK); in dwc2_hsotg_core_init_disconnected()
3509 dwc2_set_bit(hsotg, DIEPMSK, DIEPMSK_BNAININTRMSK); in dwc2_hsotg_core_init_disconnected()
3513 if (using_desc_dma(hsotg) && hsotg->params.service_interval) in dwc2_hsotg_core_init_disconnected()
3514 dwc2_set_bit(hsotg, DCTL, DCTL_SERVICE_INTERVAL_SUPPORTED); in dwc2_hsotg_core_init_disconnected()
3516 dwc2_writel(hsotg, 0, DAINTMSK); in dwc2_hsotg_core_init_disconnected()
3518 dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", in dwc2_hsotg_core_init_disconnected()
3519 dwc2_readl(hsotg, DIEPCTL0), in dwc2_hsotg_core_init_disconnected()
3520 dwc2_readl(hsotg, DOEPCTL0)); in dwc2_hsotg_core_init_disconnected()
3523 dwc2_hsotg_en_gsint(hsotg, GINTSTS_OEPINT | GINTSTS_IEPINT); in dwc2_hsotg_core_init_disconnected()
3530 if (!using_dma(hsotg)) in dwc2_hsotg_core_init_disconnected()
3531 dwc2_hsotg_en_gsint(hsotg, GINTSTS_RXFLVL); in dwc2_hsotg_core_init_disconnected()
3534 dwc2_hsotg_ctrl_epint(hsotg, 0, 0, 1); in dwc2_hsotg_core_init_disconnected()
3535 dwc2_hsotg_ctrl_epint(hsotg, 0, 1, 1); in dwc2_hsotg_core_init_disconnected()
3538 dwc2_set_bit(hsotg, DCTL, DCTL_PWRONPRGDONE); in dwc2_hsotg_core_init_disconnected()
3540 dwc2_clear_bit(hsotg, DCTL, DCTL_PWRONPRGDONE); in dwc2_hsotg_core_init_disconnected()
3543 dev_dbg(hsotg->dev, "DCTL=0x%08x\n", dwc2_readl(hsotg, DCTL)); in dwc2_hsotg_core_init_disconnected()
3551 dwc2_writel(hsotg, DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) | in dwc2_hsotg_core_init_disconnected()
3554 dwc2_writel(hsotg, dwc2_hsotg_ep0_mps(hsotg->eps_out[0]->ep.maxpacket) | in dwc2_hsotg_core_init_disconnected()
3560 dwc2_writel(hsotg, dwc2_hsotg_ep0_mps(hsotg->eps_out[0]->ep.maxpacket) | in dwc2_hsotg_core_init_disconnected()
3567 dwc2_set_bit(hsotg, DCTL, val); in dwc2_hsotg_core_init_disconnected()
3570 dwc2_gadget_init_lpm(hsotg); in dwc2_hsotg_core_init_disconnected()
3573 if (using_desc_dma(hsotg) && hsotg->params.service_interval) in dwc2_hsotg_core_init_disconnected()
3574 dwc2_gadget_program_ref_clk(hsotg); in dwc2_hsotg_core_init_disconnected()
3579 hsotg->lx_state = DWC2_L0; in dwc2_hsotg_core_init_disconnected()
3581 dwc2_hsotg_enqueue_setup(hsotg); in dwc2_hsotg_core_init_disconnected()
3583 dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", in dwc2_hsotg_core_init_disconnected()
3584 dwc2_readl(hsotg, DIEPCTL0), in dwc2_hsotg_core_init_disconnected()
3585 dwc2_readl(hsotg, DOEPCTL0)); in dwc2_hsotg_core_init_disconnected()
3588 void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) in dwc2_hsotg_core_disconnect() argument
3591 dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON); in dwc2_hsotg_core_disconnect()
3594 void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg) in dwc2_hsotg_core_connect() argument
3597 if (!hsotg->role_sw || (dwc2_readl(hsotg, GOTGCTL) & GOTGCTL_BSESVLD)) in dwc2_hsotg_core_connect()
3598 dwc2_clear_bit(hsotg, DCTL, DCTL_SFTDISCON); in dwc2_hsotg_core_connect()
3614 static void dwc2_gadget_handle_incomplete_isoc_in(struct dwc2_hsotg *hsotg) in dwc2_gadget_handle_incomplete_isoc_in() argument
3621 dev_dbg(hsotg->dev, "Incomplete isoc in interrupt received:\n"); in dwc2_gadget_handle_incomplete_isoc_in()
3623 daintmsk = dwc2_readl(hsotg, DAINTMSK); in dwc2_gadget_handle_incomplete_isoc_in()
3625 for (idx = 1; idx < hsotg->num_of_eps; idx++) { in dwc2_gadget_handle_incomplete_isoc_in()
3626 hs_ep = hsotg->eps_in[idx]; in dwc2_gadget_handle_incomplete_isoc_in()
3631 epctrl = dwc2_readl(hsotg, DIEPCTL(idx)); in dwc2_gadget_handle_incomplete_isoc_in()
3636 dwc2_writel(hsotg, epctrl, DIEPCTL(idx)); in dwc2_gadget_handle_incomplete_isoc_in()
3641 dwc2_writel(hsotg, GINTSTS_INCOMPL_SOIN, GINTSTS); in dwc2_gadget_handle_incomplete_isoc_in()
3657 static void dwc2_gadget_handle_incomplete_isoc_out(struct dwc2_hsotg *hsotg) in dwc2_gadget_handle_incomplete_isoc_out() argument
3666 dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOOUT\n", __func__); in dwc2_gadget_handle_incomplete_isoc_out()
3668 daintmsk = dwc2_readl(hsotg, DAINTMSK); in dwc2_gadget_handle_incomplete_isoc_out()
3671 for (idx = 1; idx < hsotg->num_of_eps; idx++) { in dwc2_gadget_handle_incomplete_isoc_out()
3672 hs_ep = hsotg->eps_out[idx]; in dwc2_gadget_handle_incomplete_isoc_out()
3677 epctrl = dwc2_readl(hsotg, DOEPCTL(idx)); in dwc2_gadget_handle_incomplete_isoc_out()
3681 gintmsk = dwc2_readl(hsotg, GINTMSK); in dwc2_gadget_handle_incomplete_isoc_out()
3683 dwc2_writel(hsotg, gintmsk, GINTMSK); in dwc2_gadget_handle_incomplete_isoc_out()
3685 gintsts = dwc2_readl(hsotg, GINTSTS); in dwc2_gadget_handle_incomplete_isoc_out()
3687 dwc2_set_bit(hsotg, DCTL, DCTL_SGOUTNAK); in dwc2_gadget_handle_incomplete_isoc_out()
3694 dwc2_writel(hsotg, GINTSTS_INCOMPL_SOOUT, GINTSTS); in dwc2_gadget_handle_incomplete_isoc_out()
3704 struct dwc2_hsotg *hsotg = pw; in dwc2_hsotg_irq() local
3709 if (!dwc2_is_device_mode(hsotg)) in dwc2_hsotg_irq()
3712 spin_lock(&hsotg->lock); in dwc2_hsotg_irq()
3714 gintsts = dwc2_readl(hsotg, GINTSTS); in dwc2_hsotg_irq()
3715 gintmsk = dwc2_readl(hsotg, GINTMSK); in dwc2_hsotg_irq()
3717 dev_dbg(hsotg->dev, "%s: %08x %08x (%08x) retry %d\n", in dwc2_hsotg_irq()
3723 dev_dbg(hsotg->dev, "%s: USBRstDet\n", __func__); in dwc2_hsotg_irq()
3725 dwc2_writel(hsotg, GINTSTS_RESETDET, GINTSTS); in dwc2_hsotg_irq()
3728 if (hsotg->in_ppd && hsotg->lx_state == DWC2_L2) in dwc2_hsotg_irq()
3729 dwc2_exit_partial_power_down(hsotg, 0, true); in dwc2_hsotg_irq()
3731 hsotg->lx_state = DWC2_L0; in dwc2_hsotg_irq()
3735 u32 usb_status = dwc2_readl(hsotg, GOTGCTL); in dwc2_hsotg_irq()
3736 u32 connected = hsotg->connected; in dwc2_hsotg_irq()
3738 dev_dbg(hsotg->dev, "%s: USBRst\n", __func__); in dwc2_hsotg_irq()
3739 dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n", in dwc2_hsotg_irq()
3740 dwc2_readl(hsotg, GNPTXSTS)); in dwc2_hsotg_irq()
3742 dwc2_writel(hsotg, GINTSTS_USBRST, GINTSTS); in dwc2_hsotg_irq()
3745 dwc2_hsotg_disconnect(hsotg); in dwc2_hsotg_irq()
3748 dwc2_clear_bit(hsotg, DCFG, DCFG_DEVADDR_MASK); in dwc2_hsotg_irq()
3751 dwc2_hsotg_core_init_disconnected(hsotg, true); in dwc2_hsotg_irq()
3755 dwc2_writel(hsotg, GINTSTS_ENUMDONE, GINTSTS); in dwc2_hsotg_irq()
3757 dwc2_hsotg_irq_enumdone(hsotg); in dwc2_hsotg_irq()
3761 u32 daint = dwc2_readl(hsotg, DAINT); in dwc2_hsotg_irq()
3762 u32 daintmsk = dwc2_readl(hsotg, DAINTMSK); in dwc2_hsotg_irq()
3770 dev_dbg(hsotg->dev, "%s: daint=%08x\n", __func__, daint); in dwc2_hsotg_irq()
3772 for (ep = 0; ep < hsotg->num_of_eps && daint_out; in dwc2_hsotg_irq()
3775 dwc2_hsotg_epint(hsotg, ep, 0); in dwc2_hsotg_irq()
3778 for (ep = 0; ep < hsotg->num_of_eps && daint_in; in dwc2_hsotg_irq()
3781 dwc2_hsotg_epint(hsotg, ep, 1); in dwc2_hsotg_irq()
3788 dev_dbg(hsotg->dev, "NPTxFEmp\n"); in dwc2_hsotg_irq()
3796 dwc2_hsotg_disable_gsint(hsotg, GINTSTS_NPTXFEMP); in dwc2_hsotg_irq()
3797 dwc2_hsotg_irq_fifoempty(hsotg, false); in dwc2_hsotg_irq()
3801 dev_dbg(hsotg->dev, "PTxFEmp\n"); in dwc2_hsotg_irq()
3805 dwc2_hsotg_disable_gsint(hsotg, GINTSTS_PTXFEMP); in dwc2_hsotg_irq()
3806 dwc2_hsotg_irq_fifoempty(hsotg, true); in dwc2_hsotg_irq()
3816 dwc2_hsotg_handle_rx(hsotg); in dwc2_hsotg_irq()
3820 dev_dbg(hsotg->dev, "GINTSTS_ErlySusp\n"); in dwc2_hsotg_irq()
3821 dwc2_writel(hsotg, GINTSTS_ERLYSUSP, GINTSTS); in dwc2_hsotg_irq()
3837 daintmsk = dwc2_readl(hsotg, DAINTMSK); in dwc2_hsotg_irq()
3840 gintmsk = dwc2_readl(hsotg, GINTMSK); in dwc2_hsotg_irq()
3842 dwc2_writel(hsotg, gintmsk, GINTMSK); in dwc2_hsotg_irq()
3844 dev_dbg(hsotg->dev, "GOUTNakEff triggered\n"); in dwc2_hsotg_irq()
3845 for (idx = 1; idx < hsotg->num_of_eps; idx++) { in dwc2_hsotg_irq()
3846 hs_ep = hsotg->eps_out[idx]; in dwc2_hsotg_irq()
3851 epctrl = dwc2_readl(hsotg, DOEPCTL(idx)); in dwc2_hsotg_irq()
3857 dwc2_writel(hsotg, epctrl, DOEPCTL(idx)); in dwc2_hsotg_irq()
3867 dwc2_writel(hsotg, epctrl, DOEPCTL(idx)); in dwc2_hsotg_irq()
3875 dev_info(hsotg->dev, "GINNakEff triggered\n"); in dwc2_hsotg_irq()
3877 dwc2_set_bit(hsotg, DCTL, DCTL_CGNPINNAK); in dwc2_hsotg_irq()
3879 dwc2_hsotg_dump(hsotg); in dwc2_hsotg_irq()
3883 dwc2_gadget_handle_incomplete_isoc_in(hsotg); in dwc2_hsotg_irq()
3886 dwc2_gadget_handle_incomplete_isoc_out(hsotg); in dwc2_hsotg_irq()
3897 if (hsotg->params.service_interval) in dwc2_hsotg_irq()
3898 dwc2_gadget_wkup_alert_handler(hsotg); in dwc2_hsotg_irq()
3900 spin_unlock(&hsotg->lock); in dwc2_hsotg_irq()
3905 static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg, in dwc2_hsotg_ep_stop_xfr() argument
3916 dev_dbg(hsotg->dev, "%s: stopping transfer on %s\n", __func__, in dwc2_hsotg_ep_stop_xfr()
3920 if (hsotg->dedicated_fifos || hs_ep->periodic) { in dwc2_hsotg_ep_stop_xfr()
3921 dwc2_set_bit(hsotg, epctrl_reg, DXEPCTL_SNAK); in dwc2_hsotg_ep_stop_xfr()
3923 if (dwc2_hsotg_wait_bit_set(hsotg, epint_reg, in dwc2_hsotg_ep_stop_xfr()
3925 dev_warn(hsotg->dev, in dwc2_hsotg_ep_stop_xfr()
3929 dwc2_set_bit(hsotg, DCTL, DCTL_SGNPINNAK); in dwc2_hsotg_ep_stop_xfr()
3931 if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS, in dwc2_hsotg_ep_stop_xfr()
3933 dev_warn(hsotg->dev, in dwc2_hsotg_ep_stop_xfr()
3939 dwc2_hsotg_disable_gsint(hsotg, GINTSTS_GOUTNAKEFF); in dwc2_hsotg_ep_stop_xfr()
3941 if (!(dwc2_readl(hsotg, GINTSTS) & GINTSTS_GOUTNAKEFF)) in dwc2_hsotg_ep_stop_xfr()
3942 dwc2_set_bit(hsotg, DCTL, DCTL_SGOUTNAK); in dwc2_hsotg_ep_stop_xfr()
3944 if (!using_dma(hsotg)) { in dwc2_hsotg_ep_stop_xfr()
3946 if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS, in dwc2_hsotg_ep_stop_xfr()
3948 dev_warn(hsotg->dev, "%s: timeout GINTSTS.RXFLVL\n", in dwc2_hsotg_ep_stop_xfr()
3955 dwc2_readl(hsotg, GRXSTSP); in dwc2_hsotg_ep_stop_xfr()
3960 if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS, in dwc2_hsotg_ep_stop_xfr()
3962 dev_warn(hsotg->dev, "%s: timeout GINTSTS.GOUTNAKEFF\n", in dwc2_hsotg_ep_stop_xfr()
3967 dwc2_set_bit(hsotg, epctrl_reg, DXEPCTL_EPDIS | DXEPCTL_SNAK); in dwc2_hsotg_ep_stop_xfr()
3970 if (dwc2_hsotg_wait_bit_set(hsotg, epint_reg, DXEPINT_EPDISBLD, 100)) in dwc2_hsotg_ep_stop_xfr()
3971 dev_warn(hsotg->dev, in dwc2_hsotg_ep_stop_xfr()
3975 dwc2_set_bit(hsotg, epint_reg, DXEPINT_EPDISBLD); in dwc2_hsotg_ep_stop_xfr()
3980 if (hsotg->dedicated_fifos || hs_ep->periodic) in dwc2_hsotg_ep_stop_xfr()
3986 dwc2_flush_tx_fifo(hsotg, fifo_index); in dwc2_hsotg_ep_stop_xfr()
3989 if (!hsotg->dedicated_fifos && !hs_ep->periodic) in dwc2_hsotg_ep_stop_xfr()
3990 dwc2_set_bit(hsotg, DCTL, DCTL_CGNPINNAK); in dwc2_hsotg_ep_stop_xfr()
3994 dwc2_set_bit(hsotg, DCTL, DCTL_CGOUTNAK); in dwc2_hsotg_ep_stop_xfr()
4009 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_hsotg_ep_enable() local
4023 dev_dbg(hsotg->dev, in dwc2_hsotg_ep_enable()
4030 dev_err(hsotg->dev, "%s: called for EP 0\n", __func__); in dwc2_hsotg_ep_enable()
4036 dev_err(hsotg->dev, "%s: direction mismatch!\n", __func__); in dwc2_hsotg_ep_enable()
4045 if (using_desc_dma(hsotg) && ep_type == USB_ENDPOINT_XFER_ISOC && in dwc2_hsotg_ep_enable()
4047 dev_err(hsotg->dev, in dwc2_hsotg_ep_enable()
4053 if (using_desc_dma(hsotg) && ep_type == USB_ENDPOINT_XFER_ISOC && in dwc2_hsotg_ep_enable()
4055 dev_err(hsotg->dev, in dwc2_hsotg_ep_enable()
4063 epctrl = dwc2_readl(hsotg, epctrl_reg); in dwc2_hsotg_ep_enable()
4065 dev_dbg(hsotg->dev, "%s: read DxEPCTL=0x%08x from 0x%08x\n", in dwc2_hsotg_ep_enable()
4068 if (using_desc_dma(hsotg) && ep_type == USB_ENDPOINT_XFER_ISOC) in dwc2_hsotg_ep_enable()
4074 if (using_desc_dma(hsotg) && !hs_ep->desc_list) { in dwc2_hsotg_ep_enable()
4075 hs_ep->desc_list = dmam_alloc_coherent(hsotg->dev, in dwc2_hsotg_ep_enable()
4084 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_ep_enable()
4096 dwc2_hsotg_set_ep_maxpacket(hsotg, hs_ep->index, mps, mc, dir_in); in dwc2_hsotg_ep_enable()
4116 mask = dwc2_readl(hsotg, DIEPMSK); in dwc2_hsotg_ep_enable()
4118 dwc2_writel(hsotg, mask, DIEPMSK); in dwc2_hsotg_ep_enable()
4121 mask = dwc2_readl(hsotg, DOEPMSK); in dwc2_hsotg_ep_enable()
4123 dwc2_writel(hsotg, mask, DOEPMSK); in dwc2_hsotg_ep_enable()
4135 if (hsotg->gadget.speed == USB_SPEED_HIGH) in dwc2_hsotg_ep_enable()
4150 if (dir_in && hsotg->dedicated_fifos) { in dwc2_hsotg_ep_enable()
4151 unsigned fifo_count = dwc2_hsotg_tx_fifo_count(hsotg); in dwc2_hsotg_ep_enable()
4157 if (hsotg->fifo_map & (1 << i)) in dwc2_hsotg_ep_enable()
4159 val = dwc2_readl(hsotg, DPTXFSIZN(i)); in dwc2_hsotg_ep_enable()
4170 dev_err(hsotg->dev, in dwc2_hsotg_ep_enable()
4176 hsotg->fifo_map |= 1 << fifo_index; in dwc2_hsotg_ep_enable()
4192 if (hsotg->gadget.speed == USB_SPEED_FULL && in dwc2_hsotg_ep_enable()
4198 u32 gsnpsid = dwc2_readl(hsotg, GSNPSID); in dwc2_hsotg_ep_enable()
4207 dev_dbg(hsotg->dev, "%s: write DxEPCTL=0x%08x\n", in dwc2_hsotg_ep_enable()
4210 dwc2_writel(hsotg, epctrl, epctrl_reg); in dwc2_hsotg_ep_enable()
4211 dev_dbg(hsotg->dev, "%s: read DxEPCTL=0x%08x\n", in dwc2_hsotg_ep_enable()
4212 __func__, dwc2_readl(hsotg, epctrl_reg)); in dwc2_hsotg_ep_enable()
4215 dwc2_hsotg_ctrl_epint(hsotg, index, dir_in, 1); in dwc2_hsotg_ep_enable()
4218 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_ep_enable()
4221 if (ret && using_desc_dma(hsotg) && hs_ep->desc_list) { in dwc2_hsotg_ep_enable()
4222 dmam_free_coherent(hsotg->dev, desc_num * in dwc2_hsotg_ep_enable()
4238 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_hsotg_ep_disable() local
4244 dev_dbg(hsotg->dev, "%s(ep %p)\n", __func__, ep); in dwc2_hsotg_ep_disable()
4246 if (ep == &hsotg->eps_out[0]->ep) { in dwc2_hsotg_ep_disable()
4247 dev_err(hsotg->dev, "%s: called for ep0\n", __func__); in dwc2_hsotg_ep_disable()
4251 if (hsotg->op_state != OTG_STATE_B_PERIPHERAL) { in dwc2_hsotg_ep_disable()
4252 dev_err(hsotg->dev, "%s: called in host mode?\n", __func__); in dwc2_hsotg_ep_disable()
4258 ctrl = dwc2_readl(hsotg, epctrl_reg); in dwc2_hsotg_ep_disable()
4261 dwc2_hsotg_ep_stop_xfr(hsotg, hs_ep); in dwc2_hsotg_ep_disable()
4267 dev_dbg(hsotg->dev, "%s: DxEPCTL=0x%08x\n", __func__, ctrl); in dwc2_hsotg_ep_disable()
4268 dwc2_writel(hsotg, ctrl, epctrl_reg); in dwc2_hsotg_ep_disable()
4271 dwc2_hsotg_ctrl_epint(hsotg, hs_ep->index, hs_ep->dir_in, 0); in dwc2_hsotg_ep_disable()
4274 kill_all_requests(hsotg, hs_ep, -ESHUTDOWN); in dwc2_hsotg_ep_disable()
4276 hsotg->fifo_map &= ~(1 << hs_ep->fifo_index); in dwc2_hsotg_ep_disable()
4286 struct dwc2_hsotg *hsotg = hs_ep->parent; in dwc2_hsotg_ep_disable_lock() local
4290 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_ep_disable_lock()
4292 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_ep_disable_lock()
4484 static void dwc2_hsotg_init(struct dwc2_hsotg *hsotg) in dwc2_hsotg_init() argument
4488 dwc2_writel(hsotg, DIEPMSK_TIMEOUTMSK | DIEPMSK_AHBERRMSK | in dwc2_hsotg_init()
4492 dwc2_writel(hsotg, DOEPMSK_SETUPMSK | DOEPMSK_AHBERRMSK | in dwc2_hsotg_init()
4496 dwc2_writel(hsotg, 0, DAINTMSK); in dwc2_hsotg_init()
4499 dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON); in dwc2_hsotg_init()
4503 dev_dbg(hsotg->dev, "GRXFSIZ=0x%08x, GNPTXFSIZ=0x%08x\n", in dwc2_hsotg_init()
4504 dwc2_readl(hsotg, GRXFSIZ), in dwc2_hsotg_init()
4505 dwc2_readl(hsotg, GNPTXFSIZ)); in dwc2_hsotg_init()
4507 dwc2_hsotg_init_fifo(hsotg); in dwc2_hsotg_init()
4509 if (using_dma(hsotg)) in dwc2_hsotg_init()
4510 dwc2_set_bit(hsotg, GAHBCFG, GAHBCFG_DMA_EN); in dwc2_hsotg_init()
4524 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_udc_start() local
4528 if (!hsotg) { in dwc2_hsotg_udc_start()
4534 dev_err(hsotg->dev, "%s: no driver\n", __func__); in dwc2_hsotg_udc_start()
4539 dev_err(hsotg->dev, "%s: bad speed\n", __func__); in dwc2_hsotg_udc_start()
4542 dev_err(hsotg->dev, "%s: missing entry points\n", __func__); in dwc2_hsotg_udc_start()
4546 WARN_ON(hsotg->driver); in dwc2_hsotg_udc_start()
4548 hsotg->driver = driver; in dwc2_hsotg_udc_start()
4549 hsotg->gadget.dev.of_node = hsotg->dev->of_node; in dwc2_hsotg_udc_start()
4550 hsotg->gadget.speed = USB_SPEED_UNKNOWN; in dwc2_hsotg_udc_start()
4552 if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) { in dwc2_hsotg_udc_start()
4553 ret = dwc2_lowlevel_hw_enable(hsotg); in dwc2_hsotg_udc_start()
4558 if (!IS_ERR_OR_NULL(hsotg->uphy)) in dwc2_hsotg_udc_start()
4559 otg_set_peripheral(hsotg->uphy->otg, &hsotg->gadget); in dwc2_hsotg_udc_start()
4561 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_udc_start()
4562 if (dwc2_hw_is_device(hsotg)) { in dwc2_hsotg_udc_start()
4563 dwc2_hsotg_init(hsotg); in dwc2_hsotg_udc_start()
4564 dwc2_hsotg_core_init_disconnected(hsotg, false); in dwc2_hsotg_udc_start()
4567 hsotg->enabled = 0; in dwc2_hsotg_udc_start()
4568 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_udc_start()
4570 gadget->sg_supported = using_desc_dma(hsotg); in dwc2_hsotg_udc_start()
4571 dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name); in dwc2_hsotg_udc_start()
4576 hsotg->driver = NULL; in dwc2_hsotg_udc_start()
4588 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_udc_stop() local
4592 if (!hsotg) in dwc2_hsotg_udc_stop()
4596 for (ep = 1; ep < hsotg->num_of_eps; ep++) { in dwc2_hsotg_udc_stop()
4597 if (hsotg->eps_in[ep]) in dwc2_hsotg_udc_stop()
4598 dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep); in dwc2_hsotg_udc_stop()
4599 if (hsotg->eps_out[ep]) in dwc2_hsotg_udc_stop()
4600 dwc2_hsotg_ep_disable_lock(&hsotg->eps_out[ep]->ep); in dwc2_hsotg_udc_stop()
4603 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_udc_stop()
4605 hsotg->driver = NULL; in dwc2_hsotg_udc_stop()
4606 hsotg->gadget.speed = USB_SPEED_UNKNOWN; in dwc2_hsotg_udc_stop()
4607 hsotg->enabled = 0; in dwc2_hsotg_udc_stop()
4609 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_udc_stop()
4611 if (!IS_ERR_OR_NULL(hsotg->uphy)) in dwc2_hsotg_udc_stop()
4612 otg_set_peripheral(hsotg->uphy->otg, NULL); in dwc2_hsotg_udc_stop()
4614 if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) in dwc2_hsotg_udc_stop()
4615 dwc2_lowlevel_hw_disable(hsotg); in dwc2_hsotg_udc_stop()
4641 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_set_selfpowered() local
4644 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_set_selfpowered()
4646 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_set_selfpowered()
4660 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_pullup() local
4663 dev_dbg(hsotg->dev, "%s: is_on: %d op_state: %d\n", __func__, is_on, in dwc2_hsotg_pullup()
4664 hsotg->op_state); in dwc2_hsotg_pullup()
4667 if (hsotg->op_state != OTG_STATE_B_PERIPHERAL) { in dwc2_hsotg_pullup()
4668 hsotg->enabled = is_on; in dwc2_hsotg_pullup()
4672 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_pullup()
4674 hsotg->enabled = 1; in dwc2_hsotg_pullup()
4675 dwc2_hsotg_core_init_disconnected(hsotg, false); in dwc2_hsotg_pullup()
4677 dwc2_enable_acg(hsotg); in dwc2_hsotg_pullup()
4678 dwc2_hsotg_core_connect(hsotg); in dwc2_hsotg_pullup()
4680 dwc2_hsotg_core_disconnect(hsotg); in dwc2_hsotg_pullup()
4681 dwc2_hsotg_disconnect(hsotg); in dwc2_hsotg_pullup()
4682 hsotg->enabled = 0; in dwc2_hsotg_pullup()
4685 hsotg->gadget.speed = USB_SPEED_UNKNOWN; in dwc2_hsotg_pullup()
4686 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_pullup()
4693 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_vbus_session() local
4696 dev_dbg(hsotg->dev, "%s: is_active: %d\n", __func__, is_active); in dwc2_hsotg_vbus_session()
4697 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_vbus_session()
4703 if (hsotg->lx_state == DWC2_L2 && hsotg->in_ppd) in dwc2_hsotg_vbus_session()
4708 dwc2_exit_partial_power_down(hsotg, 0, false); in dwc2_hsotg_vbus_session()
4711 hsotg->op_state = OTG_STATE_B_PERIPHERAL; in dwc2_hsotg_vbus_session()
4713 dwc2_hsotg_core_init_disconnected(hsotg, false); in dwc2_hsotg_vbus_session()
4714 if (hsotg->enabled) { in dwc2_hsotg_vbus_session()
4716 dwc2_enable_acg(hsotg); in dwc2_hsotg_vbus_session()
4717 dwc2_hsotg_core_connect(hsotg); in dwc2_hsotg_vbus_session()
4720 dwc2_hsotg_core_disconnect(hsotg); in dwc2_hsotg_vbus_session()
4721 dwc2_hsotg_disconnect(hsotg); in dwc2_hsotg_vbus_session()
4724 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_vbus_session()
4737 struct dwc2_hsotg *hsotg = to_hsotg(gadget); in dwc2_hsotg_vbus_draw() local
4739 if (IS_ERR_OR_NULL(hsotg->uphy)) in dwc2_hsotg_vbus_draw()
4741 return usb_phy_set_power(hsotg->uphy, mA); in dwc2_hsotg_vbus_draw()
4746 struct dwc2_hsotg *hsotg = to_hsotg(g); in dwc2_gadget_set_speed() local
4749 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_gadget_set_speed()
4752 hsotg->params.speed = DWC2_SPEED_PARAM_HIGH; in dwc2_gadget_set_speed()
4755 hsotg->params.speed = DWC2_SPEED_PARAM_FULL; in dwc2_gadget_set_speed()
4758 hsotg->params.speed = DWC2_SPEED_PARAM_LOW; in dwc2_gadget_set_speed()
4761 dev_err(hsotg->dev, "invalid speed (%d)\n", speed); in dwc2_gadget_set_speed()
4763 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_gadget_set_speed()
4788 static void dwc2_hsotg_initep(struct dwc2_hsotg *hsotg, in dwc2_hsotg_initep() argument
4812 list_add_tail(&hs_ep->ep.ep_list, &hsotg->gadget.ep_list); in dwc2_hsotg_initep()
4814 hs_ep->parent = hsotg; in dwc2_hsotg_initep()
4817 if (hsotg->params.speed == DWC2_SPEED_PARAM_LOW) in dwc2_hsotg_initep()
4827 if (hsotg->params.speed != DWC2_SPEED_PARAM_LOW) { in dwc2_hsotg_initep()
4844 if (using_dma(hsotg)) { in dwc2_hsotg_initep()
4848 dwc2_writel(hsotg, next, DIEPCTL(epnum)); in dwc2_hsotg_initep()
4850 dwc2_writel(hsotg, next, DOEPCTL(epnum)); in dwc2_hsotg_initep()
4860 static int dwc2_hsotg_hw_cfg(struct dwc2_hsotg *hsotg) in dwc2_hsotg_hw_cfg() argument
4868 hsotg->num_of_eps = hsotg->hw_params.num_dev_ep; in dwc2_hsotg_hw_cfg()
4871 hsotg->num_of_eps++; in dwc2_hsotg_hw_cfg()
4873 hsotg->eps_in[0] = devm_kzalloc(hsotg->dev, in dwc2_hsotg_hw_cfg()
4876 if (!hsotg->eps_in[0]) in dwc2_hsotg_hw_cfg()
4879 hsotg->eps_out[0] = hsotg->eps_in[0]; in dwc2_hsotg_hw_cfg()
4881 cfg = hsotg->hw_params.dev_ep_dirs; in dwc2_hsotg_hw_cfg()
4882 for (i = 1, cfg >>= 2; i < hsotg->num_of_eps; i++, cfg >>= 2) { in dwc2_hsotg_hw_cfg()
4886 hsotg->eps_in[i] = devm_kzalloc(hsotg->dev, in dwc2_hsotg_hw_cfg()
4888 if (!hsotg->eps_in[i]) in dwc2_hsotg_hw_cfg()
4893 hsotg->eps_out[i] = devm_kzalloc(hsotg->dev, in dwc2_hsotg_hw_cfg()
4895 if (!hsotg->eps_out[i]) in dwc2_hsotg_hw_cfg()
4900 hsotg->fifo_mem = hsotg->hw_params.total_fifo_size; in dwc2_hsotg_hw_cfg()
4901 hsotg->dedicated_fifos = hsotg->hw_params.en_multiple_tx_fifo; in dwc2_hsotg_hw_cfg()
4903 dev_info(hsotg->dev, "EPs: %d, %s fifos, %d entries in SPRAM\n", in dwc2_hsotg_hw_cfg()
4904 hsotg->num_of_eps, in dwc2_hsotg_hw_cfg()
4905 hsotg->dedicated_fifos ? "dedicated" : "shared", in dwc2_hsotg_hw_cfg()
4906 hsotg->fifo_mem); in dwc2_hsotg_hw_cfg()
4915 static void dwc2_hsotg_dump(struct dwc2_hsotg *hsotg) in dwc2_hsotg_dump() argument
4918 struct device *dev = hsotg->dev; in dwc2_hsotg_dump()
4923 dwc2_readl(hsotg, DCFG), dwc2_readl(hsotg, DCTL), in dwc2_hsotg_dump()
4924 dwc2_readl(hsotg, DIEPMSK)); in dwc2_hsotg_dump()
4927 dwc2_readl(hsotg, GAHBCFG), dwc2_readl(hsotg, GHWCFG1)); in dwc2_hsotg_dump()
4930 dwc2_readl(hsotg, GRXFSIZ), dwc2_readl(hsotg, GNPTXFSIZ)); in dwc2_hsotg_dump()
4934 for (idx = 1; idx < hsotg->num_of_eps; idx++) { in dwc2_hsotg_dump()
4935 val = dwc2_readl(hsotg, DPTXFSIZN(idx)); in dwc2_hsotg_dump()
4941 for (idx = 0; idx < hsotg->num_of_eps; idx++) { in dwc2_hsotg_dump()
4944 dwc2_readl(hsotg, DIEPCTL(idx)), in dwc2_hsotg_dump()
4945 dwc2_readl(hsotg, DIEPTSIZ(idx)), in dwc2_hsotg_dump()
4946 dwc2_readl(hsotg, DIEPDMA(idx))); in dwc2_hsotg_dump()
4948 val = dwc2_readl(hsotg, DOEPCTL(idx)); in dwc2_hsotg_dump()
4951 idx, dwc2_readl(hsotg, DOEPCTL(idx)), in dwc2_hsotg_dump()
4952 dwc2_readl(hsotg, DOEPTSIZ(idx)), in dwc2_hsotg_dump()
4953 dwc2_readl(hsotg, DOEPDMA(idx))); in dwc2_hsotg_dump()
4957 dwc2_readl(hsotg, DVBUSDIS), dwc2_readl(hsotg, DVBUSPULSE)); in dwc2_hsotg_dump()
4966 int dwc2_gadget_init(struct dwc2_hsotg *hsotg) in dwc2_gadget_init() argument
4968 struct device *dev = hsotg->dev; in dwc2_gadget_init()
4974 hsotg->params.g_np_tx_fifo_size); in dwc2_gadget_init()
4975 dev_dbg(dev, "RXFIFO size: %d\n", hsotg->params.g_rx_fifo_size); in dwc2_gadget_init()
4977 switch (hsotg->params.speed) { in dwc2_gadget_init()
4979 hsotg->gadget.max_speed = USB_SPEED_LOW; in dwc2_gadget_init()
4982 hsotg->gadget.max_speed = USB_SPEED_FULL; in dwc2_gadget_init()
4985 hsotg->gadget.max_speed = USB_SPEED_HIGH; in dwc2_gadget_init()
4989 hsotg->gadget.ops = &dwc2_hsotg_gadget_ops; in dwc2_gadget_init()
4990 hsotg->gadget.name = dev_name(dev); in dwc2_gadget_init()
4991 hsotg->gadget.otg_caps = &hsotg->params.otg_caps; in dwc2_gadget_init()
4992 hsotg->remote_wakeup_allowed = 0; in dwc2_gadget_init()
4994 if (hsotg->params.lpm) in dwc2_gadget_init()
4995 hsotg->gadget.lpm_capable = true; in dwc2_gadget_init()
4997 if (hsotg->dr_mode == USB_DR_MODE_OTG) in dwc2_gadget_init()
4998 hsotg->gadget.is_otg = 1; in dwc2_gadget_init()
4999 else if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) in dwc2_gadget_init()
5000 hsotg->op_state = OTG_STATE_B_PERIPHERAL; in dwc2_gadget_init()
5002 ret = dwc2_hsotg_hw_cfg(hsotg); in dwc2_gadget_init()
5004 dev_err(hsotg->dev, "Hardware configuration failed: %d\n", ret); in dwc2_gadget_init()
5008 hsotg->ctrl_buff = devm_kzalloc(hsotg->dev, in dwc2_gadget_init()
5010 if (!hsotg->ctrl_buff) in dwc2_gadget_init()
5013 hsotg->ep0_buff = devm_kzalloc(hsotg->dev, in dwc2_gadget_init()
5015 if (!hsotg->ep0_buff) in dwc2_gadget_init()
5018 if (using_desc_dma(hsotg)) { in dwc2_gadget_init()
5019 ret = dwc2_gadget_alloc_ctrl_desc_chains(hsotg); in dwc2_gadget_init()
5024 ret = devm_request_irq(hsotg->dev, hsotg->irq, dwc2_hsotg_irq, in dwc2_gadget_init()
5025 IRQF_SHARED, dev_name(hsotg->dev), hsotg); in dwc2_gadget_init()
5033 if (hsotg->num_of_eps == 0) { in dwc2_gadget_init()
5040 INIT_LIST_HEAD(&hsotg->gadget.ep_list); in dwc2_gadget_init()
5041 hsotg->gadget.ep0 = &hsotg->eps_out[0]->ep; in dwc2_gadget_init()
5045 hsotg->ctrl_req = dwc2_hsotg_ep_alloc_request(&hsotg->eps_out[0]->ep, in dwc2_gadget_init()
5047 if (!hsotg->ctrl_req) { in dwc2_gadget_init()
5053 for (epnum = 0; epnum < hsotg->num_of_eps; epnum++) { in dwc2_gadget_init()
5054 if (hsotg->eps_in[epnum]) in dwc2_gadget_init()
5055 dwc2_hsotg_initep(hsotg, hsotg->eps_in[epnum], in dwc2_gadget_init()
5057 if (hsotg->eps_out[epnum]) in dwc2_gadget_init()
5058 dwc2_hsotg_initep(hsotg, hsotg->eps_out[epnum], in dwc2_gadget_init()
5062 dwc2_hsotg_dump(hsotg); in dwc2_gadget_init()
5072 int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg) in dwc2_hsotg_remove() argument
5074 usb_del_gadget_udc(&hsotg->gadget); in dwc2_hsotg_remove()
5075 dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, hsotg->ctrl_req); in dwc2_hsotg_remove()
5080 int dwc2_hsotg_suspend(struct dwc2_hsotg *hsotg) in dwc2_hsotg_suspend() argument
5084 if (hsotg->lx_state != DWC2_L0) in dwc2_hsotg_suspend()
5087 if (hsotg->driver) { in dwc2_hsotg_suspend()
5090 dev_info(hsotg->dev, "suspending usb gadget %s\n", in dwc2_hsotg_suspend()
5091 hsotg->driver->driver.name); in dwc2_hsotg_suspend()
5093 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_suspend()
5094 if (hsotg->enabled) in dwc2_hsotg_suspend()
5095 dwc2_hsotg_core_disconnect(hsotg); in dwc2_hsotg_suspend()
5096 dwc2_hsotg_disconnect(hsotg); in dwc2_hsotg_suspend()
5097 hsotg->gadget.speed = USB_SPEED_UNKNOWN; in dwc2_hsotg_suspend()
5098 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_suspend()
5100 for (ep = 1; ep < hsotg->num_of_eps; ep++) { in dwc2_hsotg_suspend()
5101 if (hsotg->eps_in[ep]) in dwc2_hsotg_suspend()
5102 dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep); in dwc2_hsotg_suspend()
5103 if (hsotg->eps_out[ep]) in dwc2_hsotg_suspend()
5104 dwc2_hsotg_ep_disable_lock(&hsotg->eps_out[ep]->ep); in dwc2_hsotg_suspend()
5111 int dwc2_hsotg_resume(struct dwc2_hsotg *hsotg) in dwc2_hsotg_resume() argument
5115 if (hsotg->lx_state == DWC2_L2) in dwc2_hsotg_resume()
5118 if (hsotg->driver) { in dwc2_hsotg_resume()
5119 dev_info(hsotg->dev, "resuming usb gadget %s\n", in dwc2_hsotg_resume()
5120 hsotg->driver->driver.name); in dwc2_hsotg_resume()
5122 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hsotg_resume()
5123 dwc2_hsotg_core_init_disconnected(hsotg, false); in dwc2_hsotg_resume()
5124 if (hsotg->enabled) { in dwc2_hsotg_resume()
5126 dwc2_enable_acg(hsotg); in dwc2_hsotg_resume()
5127 dwc2_hsotg_core_connect(hsotg); in dwc2_hsotg_resume()
5129 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hsotg_resume()
5142 int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg) in dwc2_backup_device_registers() argument
5147 dev_dbg(hsotg->dev, "%s\n", __func__); in dwc2_backup_device_registers()
5150 dr = &hsotg->dr_backup; in dwc2_backup_device_registers()
5152 dr->dcfg = dwc2_readl(hsotg, DCFG); in dwc2_backup_device_registers()
5153 dr->dctl = dwc2_readl(hsotg, DCTL); in dwc2_backup_device_registers()
5154 dr->daintmsk = dwc2_readl(hsotg, DAINTMSK); in dwc2_backup_device_registers()
5155 dr->diepmsk = dwc2_readl(hsotg, DIEPMSK); in dwc2_backup_device_registers()
5156 dr->doepmsk = dwc2_readl(hsotg, DOEPMSK); in dwc2_backup_device_registers()
5158 for (i = 0; i < hsotg->num_of_eps; i++) { in dwc2_backup_device_registers()
5160 dr->diepctl[i] = dwc2_readl(hsotg, DIEPCTL(i)); in dwc2_backup_device_registers()
5168 dr->dieptsiz[i] = dwc2_readl(hsotg, DIEPTSIZ(i)); in dwc2_backup_device_registers()
5169 dr->diepdma[i] = dwc2_readl(hsotg, DIEPDMA(i)); in dwc2_backup_device_registers()
5172 dr->doepctl[i] = dwc2_readl(hsotg, DOEPCTL(i)); in dwc2_backup_device_registers()
5180 dr->doeptsiz[i] = dwc2_readl(hsotg, DOEPTSIZ(i)); in dwc2_backup_device_registers()
5181 dr->doepdma[i] = dwc2_readl(hsotg, DOEPDMA(i)); in dwc2_backup_device_registers()
5182 dr->dtxfsiz[i] = dwc2_readl(hsotg, DPTXFSIZN(i)); in dwc2_backup_device_registers()
5198 int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup) in dwc2_restore_device_registers() argument
5203 dev_dbg(hsotg->dev, "%s\n", __func__); in dwc2_restore_device_registers()
5206 dr = &hsotg->dr_backup; in dwc2_restore_device_registers()
5208 dev_err(hsotg->dev, "%s: no device registers to restore\n", in dwc2_restore_device_registers()
5215 dwc2_writel(hsotg, dr->dctl, DCTL); in dwc2_restore_device_registers()
5217 dwc2_writel(hsotg, dr->daintmsk, DAINTMSK); in dwc2_restore_device_registers()
5218 dwc2_writel(hsotg, dr->diepmsk, DIEPMSK); in dwc2_restore_device_registers()
5219 dwc2_writel(hsotg, dr->doepmsk, DOEPMSK); in dwc2_restore_device_registers()
5221 for (i = 0; i < hsotg->num_of_eps; i++) { in dwc2_restore_device_registers()
5223 dwc2_writel(hsotg, dr->dieptsiz[i], DIEPTSIZ(i)); in dwc2_restore_device_registers()
5224 dwc2_writel(hsotg, dr->diepdma[i], DIEPDMA(i)); in dwc2_restore_device_registers()
5225 dwc2_writel(hsotg, dr->doeptsiz[i], DOEPTSIZ(i)); in dwc2_restore_device_registers()
5231 if (using_desc_dma(hsotg) && in dwc2_restore_device_registers()
5233 dr->diepdma[i] = hsotg->eps_in[i]->desc_list_dma; in dwc2_restore_device_registers()
5234 dwc2_writel(hsotg, dr->dtxfsiz[i], DPTXFSIZN(i)); in dwc2_restore_device_registers()
5235 dwc2_writel(hsotg, dr->diepctl[i], DIEPCTL(i)); in dwc2_restore_device_registers()
5237 dwc2_writel(hsotg, dr->doeptsiz[i], DOEPTSIZ(i)); in dwc2_restore_device_registers()
5243 if (using_desc_dma(hsotg) && in dwc2_restore_device_registers()
5245 dr->doepdma[i] = hsotg->eps_out[i]->desc_list_dma; in dwc2_restore_device_registers()
5246 dwc2_writel(hsotg, dr->doepdma[i], DOEPDMA(i)); in dwc2_restore_device_registers()
5247 dwc2_writel(hsotg, dr->doepctl[i], DOEPCTL(i)); in dwc2_restore_device_registers()
5259 void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg) in dwc2_gadget_init_lpm() argument
5263 if (!hsotg->params.lpm) in dwc2_gadget_init_lpm()
5267 val |= hsotg->params.hird_threshold_en ? GLPMCFG_HIRD_THRES_EN : 0; in dwc2_gadget_init_lpm()
5268 val |= hsotg->params.lpm_clock_gating ? GLPMCFG_ENBLSLPM : 0; in dwc2_gadget_init_lpm()
5269 val |= hsotg->params.hird_threshold << GLPMCFG_HIRD_THRES_SHIFT; in dwc2_gadget_init_lpm()
5270 val |= hsotg->params.besl ? GLPMCFG_ENBESL : 0; in dwc2_gadget_init_lpm()
5273 dwc2_writel(hsotg, val, GLPMCFG); in dwc2_gadget_init_lpm()
5274 dev_dbg(hsotg->dev, "GLPMCFG=0x%08x\n", dwc2_readl(hsotg, GLPMCFG)); in dwc2_gadget_init_lpm()
5277 if (hsotg->params.service_interval) in dwc2_gadget_init_lpm()
5278 dwc2_set_bit(hsotg, GINTMSK2, GINTMSK2_WKUP_ALERT_INT_MSK); in dwc2_gadget_init_lpm()
5287 void dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg) in dwc2_gadget_program_ref_clk() argument
5292 val |= hsotg->params.ref_clk_per << GREFCLK_REFCLKPER_SHIFT; in dwc2_gadget_program_ref_clk()
5293 val |= hsotg->params.sof_cnt_wkup_alert << in dwc2_gadget_program_ref_clk()
5296 dwc2_writel(hsotg, val, GREFCLK); in dwc2_gadget_program_ref_clk()
5297 dev_dbg(hsotg->dev, "GREFCLK=0x%08x\n", dwc2_readl(hsotg, GREFCLK)); in dwc2_gadget_program_ref_clk()
5307 int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg) in dwc2_gadget_enter_hibernation() argument
5313 hsotg->lx_state = DWC2_L2; in dwc2_gadget_enter_hibernation()
5314 dev_dbg(hsotg->dev, "Start of hibernation completed\n"); in dwc2_gadget_enter_hibernation()
5315 ret = dwc2_backup_global_registers(hsotg); in dwc2_gadget_enter_hibernation()
5317 dev_err(hsotg->dev, "%s: failed to backup global registers\n", in dwc2_gadget_enter_hibernation()
5321 ret = dwc2_backup_device_registers(hsotg); in dwc2_gadget_enter_hibernation()
5323 dev_err(hsotg->dev, "%s: failed to backup device registers\n", in dwc2_gadget_enter_hibernation()
5330 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_enter_hibernation()
5334 hsotg->hibernated = 1; in dwc2_gadget_enter_hibernation()
5337 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_enter_hibernation()
5339 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_enter_hibernation()
5343 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_enter_hibernation()
5347 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_enter_hibernation()
5351 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_enter_hibernation()
5353 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_enter_hibernation()
5357 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_enter_hibernation()
5359 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_enter_hibernation()
5363 hsotg->gr_backup.gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_enter_hibernation()
5364 dev_dbg(hsotg->dev, "Hibernation completed\n"); in dwc2_gadget_enter_hibernation()
5380 int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg, in dwc2_gadget_exit_hibernation() argument
5390 gr = &hsotg->gr_backup; in dwc2_gadget_exit_hibernation()
5391 dr = &hsotg->dr_backup; in dwc2_gadget_exit_hibernation()
5393 if (!hsotg->hibernated) { in dwc2_gadget_exit_hibernation()
5394 dev_dbg(hsotg->dev, "Already exited from Hibernation\n"); in dwc2_gadget_exit_hibernation()
5397 dev_dbg(hsotg->dev, in dwc2_gadget_exit_hibernation()
5401 dwc2_hib_restore_common(hsotg, rem_wakeup, 0); in dwc2_gadget_exit_hibernation()
5405 dwc2_writel(hsotg, 0xffffffff, GINTSTS); in dwc2_gadget_exit_hibernation()
5409 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_exit_hibernation()
5411 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_exit_hibernation()
5415 pcgcctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_hibernation()
5417 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_exit_hibernation()
5421 dwc2_writel(hsotg, gr->gusbcfg, GUSBCFG); in dwc2_gadget_exit_hibernation()
5422 dwc2_writel(hsotg, dr->dcfg, DCFG); in dwc2_gadget_exit_hibernation()
5423 dwc2_writel(hsotg, dr->dctl, DCTL); in dwc2_gadget_exit_hibernation()
5427 dwc2_clear_bit(hsotg, DCFG, DCFG_DEVADDR_MASK); in dwc2_gadget_exit_hibernation()
5430 gpwrdn = dwc2_readl(hsotg, GPWRDN); in dwc2_gadget_exit_hibernation()
5432 dwc2_writel(hsotg, gpwrdn, GPWRDN); in dwc2_gadget_exit_hibernation()
5437 dwc2_writel(hsotg, dr->dctl | DCTL_RMTWKUPSIG, DCTL); in dwc2_gadget_exit_hibernation()
5441 dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_exit_hibernation()
5443 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_exit_hibernation()
5448 dwc2_writel(hsotg, 0xffffffff, GINTSTS); in dwc2_gadget_exit_hibernation()
5451 ret = dwc2_restore_global_registers(hsotg); in dwc2_gadget_exit_hibernation()
5453 dev_err(hsotg->dev, "%s: failed to restore registers\n", in dwc2_gadget_exit_hibernation()
5459 ret = dwc2_restore_device_registers(hsotg, rem_wakeup); in dwc2_gadget_exit_hibernation()
5461 dev_err(hsotg->dev, "%s: failed to restore device registers\n", in dwc2_gadget_exit_hibernation()
5468 dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_exit_hibernation()
5470 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_exit_hibernation()
5473 hsotg->hibernated = 0; in dwc2_gadget_exit_hibernation()
5474 hsotg->lx_state = DWC2_L0; in dwc2_gadget_exit_hibernation()
5475 dev_dbg(hsotg->dev, "Hibernation recovery completes here\n"); in dwc2_gadget_exit_hibernation()
5490 int dwc2_gadget_enter_partial_power_down(struct dwc2_hsotg *hsotg) in dwc2_gadget_enter_partial_power_down() argument
5495 dev_dbg(hsotg->dev, "Entering device partial power down started.\n"); in dwc2_gadget_enter_partial_power_down()
5498 ret = dwc2_backup_global_registers(hsotg); in dwc2_gadget_enter_partial_power_down()
5500 dev_err(hsotg->dev, "%s: failed to backup global registers\n", in dwc2_gadget_enter_partial_power_down()
5505 ret = dwc2_backup_device_registers(hsotg); in dwc2_gadget_enter_partial_power_down()
5507 dev_err(hsotg->dev, "%s: failed to backup device registers\n", in dwc2_gadget_enter_partial_power_down()
5516 dwc2_writel(hsotg, 0xffffffff, GINTSTS); in dwc2_gadget_enter_partial_power_down()
5519 pcgcctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_enter_partial_power_down()
5522 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_enter_partial_power_down()
5526 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_enter_partial_power_down()
5530 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_enter_partial_power_down()
5533 hsotg->in_ppd = 1; in dwc2_gadget_enter_partial_power_down()
5534 hsotg->lx_state = DWC2_L2; in dwc2_gadget_enter_partial_power_down()
5536 dev_dbg(hsotg->dev, "Entering device partial power down completed.\n"); in dwc2_gadget_enter_partial_power_down()
5552 int dwc2_gadget_exit_partial_power_down(struct dwc2_hsotg *hsotg, in dwc2_gadget_exit_partial_power_down() argument
5560 dr = &hsotg->dr_backup; in dwc2_gadget_exit_partial_power_down()
5562 dev_dbg(hsotg->dev, "Exiting device partial Power Down started.\n"); in dwc2_gadget_exit_partial_power_down()
5564 pcgcctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5566 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5568 pcgcctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5570 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5572 pcgcctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5574 dwc2_writel(hsotg, pcgcctl, PCGCTL); in dwc2_gadget_exit_partial_power_down()
5578 ret = dwc2_restore_global_registers(hsotg); in dwc2_gadget_exit_partial_power_down()
5580 dev_err(hsotg->dev, "%s: failed to restore registers\n", in dwc2_gadget_exit_partial_power_down()
5585 dwc2_writel(hsotg, dr->dcfg, DCFG); in dwc2_gadget_exit_partial_power_down()
5587 ret = dwc2_restore_device_registers(hsotg, 0); in dwc2_gadget_exit_partial_power_down()
5589 dev_err(hsotg->dev, "%s: failed to restore device registers\n", in dwc2_gadget_exit_partial_power_down()
5596 dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_exit_partial_power_down()
5598 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_exit_partial_power_down()
5601 hsotg->in_ppd = 0; in dwc2_gadget_exit_partial_power_down()
5602 hsotg->lx_state = DWC2_L0; in dwc2_gadget_exit_partial_power_down()
5604 dev_dbg(hsotg->dev, "Exiting device partial Power Down completed.\n"); in dwc2_gadget_exit_partial_power_down()
5617 void dwc2_gadget_enter_clock_gating(struct dwc2_hsotg *hsotg) in dwc2_gadget_enter_clock_gating() argument
5621 dev_dbg(hsotg->dev, "Entering device clock gating.\n"); in dwc2_gadget_enter_clock_gating()
5624 pcgctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_enter_clock_gating()
5626 dwc2_writel(hsotg, pcgctl, PCGCTL); in dwc2_gadget_enter_clock_gating()
5630 pcgctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_enter_clock_gating()
5632 dwc2_writel(hsotg, pcgctl, PCGCTL); in dwc2_gadget_enter_clock_gating()
5635 hsotg->lx_state = DWC2_L2; in dwc2_gadget_enter_clock_gating()
5636 hsotg->bus_suspended = true; in dwc2_gadget_enter_clock_gating()
5647 void dwc2_gadget_exit_clock_gating(struct dwc2_hsotg *hsotg, int rem_wakeup) in dwc2_gadget_exit_clock_gating() argument
5652 dev_dbg(hsotg->dev, "Exiting device clock gating.\n"); in dwc2_gadget_exit_clock_gating()
5655 pcgctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_clock_gating()
5657 dwc2_writel(hsotg, pcgctl, PCGCTL); in dwc2_gadget_exit_clock_gating()
5661 pcgctl = dwc2_readl(hsotg, PCGCTL); in dwc2_gadget_exit_clock_gating()
5663 dwc2_writel(hsotg, pcgctl, PCGCTL); in dwc2_gadget_exit_clock_gating()
5668 dctl = dwc2_readl(hsotg, DCTL); in dwc2_gadget_exit_clock_gating()
5670 dwc2_writel(hsotg, dctl, DCTL); in dwc2_gadget_exit_clock_gating()
5674 call_gadget(hsotg, resume); in dwc2_gadget_exit_clock_gating()
5675 hsotg->lx_state = DWC2_L0; in dwc2_gadget_exit_clock_gating()
5676 hsotg->bus_suspended = false; in dwc2_gadget_exit_clock_gating()