Lines Matching refs:dwc3_handle

667 static enum usb_status dwc3_execute_dep_cmd(dwc3_handle_t *dwc3_handle, uint8_t phy_epnum,  in dwc3_execute_dep_cmd()  argument
677 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DEPCMDPAR0(phy_epnum), params->param0); in dwc3_execute_dep_cmd()
678 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DEPCMDPAR1(phy_epnum), params->param1); in dwc3_execute_dep_cmd()
679 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DEPCMDPAR2(phy_epnum), params->param2); in dwc3_execute_dep_cmd()
681 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DEPCMD(phy_epnum), cmd | USB3_DEPCMD_CMDACT); in dwc3_execute_dep_cmd()
685 reg = DWC3_regread(dwc3_handle->usb_device, DWC3_DEPCMD(phy_epnum)); in dwc3_execute_dep_cmd()
708 static bool dwc3_is_ep_enabled(dwc3_handle_t *dwc3_handle, uint8_t phy_epnum) in dwc3_is_ep_enabled() argument
710 if ((DWC3_regread(dwc3_handle->usb_device, in dwc3_is_ep_enabled()
718 static enum usb_status dwc3_ep_start_xfer(dwc3_handle_t *dwc3_handle, struct usbd_ep *ep) in dwc3_ep_start_xfer() argument
724 usb_dwc3_endpoint_t *dwc3_ep = ((ep->is_in) ? &dwc3_handle->IN_ep[ep->num] : in dwc3_ep_start_xfer()
725 &dwc3_handle->OUT_ep[ep->num]); in dwc3_ep_start_xfer()
784 ret = dwc3_execute_dep_cmd(dwc3_handle, dwc3_ep->phy_epnum, cmd, &params); in dwc3_ep_start_xfer()
796 (uint8_t)DWC3_DEPCMD_GET_RSC_IDX(DWC3_regread(dwc3_handle->usb_device, in dwc3_ep_start_xfer()
805 dwc3_handle_t *dwc3_handle = (dwc3_handle_t *)handle; in usb_dwc3_ep_start_xfer() local
806 usb_dwc3_endpoint_t *dwc3_ep = ((ep->is_in) ? &dwc3_handle->IN_ep[ep->num] : in usb_dwc3_ep_start_xfer()
807 &dwc3_handle->OUT_ep[ep->num]); in usb_dwc3_ep_start_xfer()
810 if (!dwc3_is_ep_enabled(dwc3_handle, dwc3_ep->phy_epnum) && ep->num != 0U) { in usb_dwc3_ep_start_xfer()
839 if (__HAL_PCD_SETUP_REQ_LEN(dwc3_handle->setup_addr) == 0U) { in usb_dwc3_ep_start_xfer()
856 return dwc3_ep_start_xfer(dwc3_handle, ep); in usb_dwc3_ep_start_xfer()
859 static enum usb_status dwc3_ep0_out_start(dwc3_handle_t *dwc3_handle, uintptr_t setup_buf_dma_addr) in dwc3_ep0_out_start() argument
861 dwc3_handle->OUT_ep[0].dma_addr = setup_buf_dma_addr; in dwc3_ep0_out_start()
862 dwc3_handle->pcd_handle->out_ep[0].xfer_len = 8; in dwc3_ep0_out_start()
863 dwc3_handle->OUT_ep[0].trb_flag = USB_DWC3_TRBCTL_CONTROL_SETUP; in dwc3_ep0_out_start()
865 return dwc3_ep_start_xfer(dwc3_handle, &dwc3_handle->pcd_handle->out_ep[0]); in dwc3_ep0_out_start()
870 dwc3_handle_t *dwc3_handle = (dwc3_handle_t *)handle; in usb_dwc3_ep0_out_start() local
872 dwc3_handle->EP0_State = HAL_PCD_EP0_SETUP_QUEUED; in usb_dwc3_ep0_out_start()
873 return dwc3_ep0_out_start(dwc3_handle, dwc3_handle->setup_dma_addr); in usb_dwc3_ep0_out_start()
878 dwc3_handle_t *dwc3_handle = (dwc3_handle_t *)handle; in usb_dwc3_start_device() local
881 if (dwc3_handle->EP0_State != HAL_PCD_EP0_SETUP_QUEUED) { in usb_dwc3_start_device()
882 dwc3_handle->EP0_State = HAL_PCD_EP0_SETUP_QUEUED; in usb_dwc3_start_device()
884 ret = dwc3_ep0_out_start(dwc3_handle, dwc3_handle->setup_dma_addr); in usb_dwc3_start_device()
891 DWC3_regupdateset(dwc3_handle->usb_device, DWC3_DCTL, USB3_DCTL_RUN_STOP); in usb_dwc3_start_device()
896 static inline void dwc3_ack_evt_count(dwc3_handle_t *dwc3_handle, uint8_t intr_num, in dwc3_ack_evt_count() argument
899 DWC3_regwrite(dwc3_handle->usb_global, DWC3_GEVNTCOUNT(intr_num), evt_count); in dwc3_ack_evt_count()
902 static inline uint32_t dwc3_read_intr_count(dwc3_handle_t *dwc3_handle, uint8_t intr_num) in dwc3_read_intr_count() argument
904 return DWC3_regread(dwc3_handle->usb_global, DWC3_GEVNTCOUNT(intr_num)) & in dwc3_read_intr_count()
908 static enum usb_status dwc3_ep_stop_xfer(dwc3_handle_t *dwc3_handle, struct usbd_ep *ep) in dwc3_ep_stop_xfer() argument
910 usb_dwc3_endpoint_t *dwc3_ep = ((ep->is_in) ? &dwc3_handle->IN_ep[ep->num] : in dwc3_ep_stop_xfer()
911 &dwc3_handle->OUT_ep[ep->num]); in dwc3_ep_stop_xfer()
931 ret = dwc3_execute_dep_cmd(dwc3_handle, dwc3_ep->phy_epnum, cmd, &params); in dwc3_ep_stop_xfer()
940 dwc3_handle->EP0_State = HAL_PCD_EP0_SETUP_COMPLETED; in dwc3_ep_stop_xfer()
946 static enum usb_status dwc3_ep_set_stall(dwc3_handle_t *dwc3_handle, in dwc3_ep_set_stall() argument
953 return dwc3_execute_dep_cmd(dwc3_handle, dwc3_ep->phy_epnum, USB_DWC3_DEPCMD_SETSTALL, in dwc3_ep_set_stall()
959 dwc3_handle_t *dwc3_handle = (dwc3_handle_t *)handle; in usb_dwc3_stop_device() local
970 dwc3_ep_stop_xfer(dwc3_handle, &dwc3_handle->pcd_handle->in_ep[i]); in usb_dwc3_stop_device()
975 dwc3_ep_stop_xfer(dwc3_handle, &dwc3_handle->pcd_handle->out_ep[i]); in usb_dwc3_stop_device()
979 ret = dwc3_ep_set_stall(dwc3_handle, &dwc3_handle->OUT_ep[0]); in usb_dwc3_stop_device()
994 evtcnt = dwc3_read_intr_count(dwc3_handle, i); in usb_dwc3_stop_device()
1000 __HAL_PCD_INCR_EVENT_POS(dwc3_handle, i, evtcnt); in usb_dwc3_stop_device()
1002 dwc3_ack_evt_count(dwc3_handle, i, evtcnt); in usb_dwc3_stop_device()
1006 DWC3_regupdateclr(dwc3_handle->usb_device, DWC3_DCTL, USB3_DCTL_RUN_STOP); in usb_dwc3_stop_device()
1010 while ((DWC3_regread(dwc3_handle->usb_device, DWC3_DSTS) & in usb_dwc3_stop_device()
1026 dwc3_handle_t *dwc3_handle = (dwc3_handle_t *)handle; in usb_dwc3_set_address() local
1031 DWC3_regupdateclr(dwc3_handle->usb_device, DWC3_DCFG, USB3_DCFG_DEVADDR_MSK); in usb_dwc3_set_address()
1032 DWC3_regupdateset(dwc3_handle->usb_device, DWC3_DCFG, DWC3_DCFG_DEVADDR((uint32_t)address)); in usb_dwc3_set_address()
1044 dwc3_handle_t *dwc3_handle = (dwc3_handle_t *)handle; in usb_dwc3_ep_set_stall() local
1045 usb_dwc3_endpoint_t *dwc3_ep = ((ep->is_in) ? &dwc3_handle->IN_ep[ep->num] : in usb_dwc3_ep_set_stall()
1046 &dwc3_handle->OUT_ep[ep->num]); in usb_dwc3_ep_set_stall()
1054 return dwc3_ep_set_stall(dwc3_handle, dwc3_ep); in usb_dwc3_ep_set_stall()
1112 static enum usb_status dwc3_epaddr_set_stall(dwc3_handle_t *dwc3_handle, uint8_t ep_addr) in dwc3_epaddr_set_stall() argument
1119 ep = &dwc3_handle->pcd_handle->in_ep[ep_addr & ADDRESS_MASK]; in dwc3_epaddr_set_stall()
1120 dwc3_ep = &dwc3_handle->IN_ep[ep_addr & ADDRESS_MASK]; in dwc3_epaddr_set_stall()
1122 ep = &dwc3_handle->pcd_handle->out_ep[ep_addr]; in dwc3_epaddr_set_stall()
1123 dwc3_ep = &dwc3_handle->OUT_ep[ep_addr]; in dwc3_epaddr_set_stall()
1143 ret = dwc3_ep_set_stall(dwc3_handle, dwc3_ep); in dwc3_epaddr_set_stall()
1149 dwc3_handle->EP0_State = HAL_PCD_EP0_SETUP_QUEUED; in dwc3_epaddr_set_stall()
1150 ret = dwc3_ep0_out_start(dwc3_handle, dwc3_handle->setup_dma_addr); in dwc3_epaddr_set_stall()
1166 static enum usb_action dwc3_handle_ep0_xfernotready_event(dwc3_handle_t *dwc3_handle, in dwc3_handle_ep0_xfernotready_event() argument
1171 struct pcd_handle *pcd_handle = dwc3_handle->pcd_handle; in dwc3_handle_ep0_xfernotready_event()
1179 if (__HAL_PCD_SETUP_REQ_LEN(dwc3_handle->setup_addr) == 0U) { in dwc3_handle_ep0_xfernotready_event()
1182 api_memcpy(dwc3_handle->pcd_handle->setup, in dwc3_handle_ep0_xfernotready_event()
1183 dwc3_handle->setup_addr, in dwc3_handle_ep0_xfernotready_event()
1184 sizeof(dwc3_handle->pcd_handle->setup)); in dwc3_handle_ep0_xfernotready_event()
1188 ret = dwc3_epaddr_set_stall(dwc3_handle, ep_num); // OUT EP0 in dwc3_handle_ep0_xfernotready_event()
1211 if (__HAL_PCD_SETUP_REQ_DATA_DIR_IN(dwc3_handle->setup_addr) == in dwc3_handle_ep0_xfernotready_event()
1213 ret = dwc3_ep_stop_xfer(dwc3_handle, in dwc3_handle_ep0_xfernotready_event()
1218 ret = dwc3_epaddr_set_stall(dwc3_handle, ep_num); // OUT EP0 in dwc3_handle_ep0_xfernotready_event()
1229 if (__HAL_PCD_SETUP_REQ_DATA_DIR_IN(dwc3_handle->setup_addr) != in dwc3_handle_ep0_xfernotready_event()
1231 ret = dwc3_ep_stop_xfer(dwc3_handle, in dwc3_handle_ep0_xfernotready_event()
1236 ret = dwc3_epaddr_set_stall(dwc3_handle, ep_num); // OUT EP0 in dwc3_handle_ep0_xfernotready_event()
1252 static enum usb_action dwc3_handle_ep_event(dwc3_handle_t *dwc3_handle, uint32_t event, in dwc3_handle_ep_event() argument
1267 ep = &dwc3_handle->pcd_handle->in_ep[ep_num]; in dwc3_handle_ep_event()
1268 dwc3_ep = &dwc3_handle->IN_ep[ep_num]; in dwc3_handle_ep_event()
1270 ep = &dwc3_handle->pcd_handle->out_ep[ep_num]; in dwc3_handle_ep_event()
1271 dwc3_ep = &dwc3_handle->OUT_ep[ep_num]; in dwc3_handle_ep_event()
1314 ret = dwc3_epaddr_set_stall(dwc3_handle, ep_num); // OUT EP0 in dwc3_handle_ep_event()
1332 dwc3_handle->EP0_State = HAL_PCD_EP0_SETUP_QUEUED; in dwc3_handle_ep_event()
1334 ret = dwc3_ep0_out_start(dwc3_handle, dwc3_handle->setup_dma_addr); in dwc3_handle_ep_event()
1347 (dwc3_handle->EP0_State == HAL_PCD_EP0_SETUP_QUEUED)) { in dwc3_handle_ep_event()
1349 dwc3_handle->EP0_State = HAL_PCD_EP0_SETUP_COMPLETED; in dwc3_handle_ep_event()
1353 dwc3_handle->setup_addr[0], dwc3_handle->setup_addr[1], in dwc3_handle_ep_event()
1354 dwc3_handle->setup_addr[2], dwc3_handle->setup_addr[3], in dwc3_handle_ep_event()
1355 dwc3_handle->setup_addr[4], dwc3_handle->setup_addr[5], in dwc3_handle_ep_event()
1356 dwc3_handle->setup_addr[6], dwc3_handle->setup_addr[7]); in dwc3_handle_ep_event()
1359 if (__HAL_PCD_SETUP_REQ_LEN(dwc3_handle->setup_addr) != 0U) { in dwc3_handle_ep_event()
1360 api_memcpy(dwc3_handle->pcd_handle->setup, in dwc3_handle_ep_event()
1361 dwc3_handle->setup_addr, in dwc3_handle_ep_event()
1362 sizeof(dwc3_handle->pcd_handle->setup)); in dwc3_handle_ep_event()
1389 dwc3_handle->EP0_State = HAL_PCD_EP0_SETUP_QUEUED; in dwc3_handle_ep_event()
1391 ret = dwc3_ep0_out_start(dwc3_handle, in dwc3_handle_ep_event()
1392 dwc3_handle->setup_dma_addr); in dwc3_handle_ep_event()
1405 ep->is_in ? "IN" : "OUT", dwc3_handle->intbuffers.evtbufferpos[0], in dwc3_handle_ep_event()
1436 if (dwc3_handle->EP0_State == HAL_PCD_EP0_SETUP_QUEUED) { in dwc3_handle_ep_event()
1437 ret = dwc3_epaddr_set_stall(dwc3_handle, ep_num); // OUT EP0 in dwc3_handle_ep_event()
1443 action = dwc3_handle_ep0_xfernotready_event(dwc3_handle, event, in dwc3_handle_ep_event()
1527 static enum usb_status dwc3_ep_clear_stall(dwc3_handle_t *dwc3_handle, usb_dwc3_endpoint_t *dwc3_ep) in dwc3_ep_clear_stall() argument
1533 return dwc3_execute_dep_cmd(dwc3_handle, dwc3_ep->phy_epnum, USB_DWC3_DEPCMD_CLEARSTALL, in dwc3_ep_clear_stall()
1538 static uint8_t dwc3_get_dev_speed(dwc3_handle_t *dwc3_handle) in dwc3_get_dev_speed() argument
1543 reg = DWC3_regread(dwc3_handle->usb_device, DWC3_DSTS) & USB3_DSTS_CONNECTSPD; in dwc3_get_dev_speed()
1597 static enum usb_status dwc3_ep_configure(dwc3_handle_t *dwc3_handle, uint8_t epnum, bool is_in, in dwc3_ep_configure() argument
1629 return dwc3_execute_dep_cmd(dwc3_handle, phy_epnum, USB_DWC3_DEPCMD_SETEPCONFIG, &params); in dwc3_ep_configure()
1671 static enum usb_action dwc3_handle_dev_event(dwc3_handle_t *dwc3_handle, uint32_t event, in dwc3_handle_dev_event() argument
1697 if (dwc3_handle->EP0_State != HAL_PCD_EP0_SETUP_QUEUED) { in dwc3_handle_dev_event()
1698 ret = dwc3_ep_stop_xfer(dwc3_handle, &dwc3_handle->pcd_handle->out_ep[0]); in dwc3_handle_dev_event()
1702 ret = dwc3_epaddr_set_stall(dwc3_handle, EP0_OUT); // OUT EP0 in dwc3_handle_dev_event()
1713 dwc3_ep_stop_xfer(dwc3_handle, in dwc3_handle_dev_event()
1714 &dwc3_handle->pcd_handle->in_ep[i]); in dwc3_handle_dev_event()
1720 dwc3_ep_stop_xfer(dwc3_handle, in dwc3_handle_dev_event()
1721 &dwc3_handle->pcd_handle->out_ep[i]); in dwc3_handle_dev_event()
1728 usb_dwc3_endpoint_t *ep = &dwc3_handle->IN_ep[i]; in dwc3_handle_dev_event()
1736 ret = dwc3_ep_clear_stall(dwc3_handle, ep); in dwc3_handle_dev_event()
1747 usb_dwc3_endpoint_t *ep = &dwc3_handle->OUT_ep[i]; in dwc3_handle_dev_event()
1757 ret = dwc3_ep_clear_stall(dwc3_handle, ep); in dwc3_handle_dev_event()
1766 ret = usb_dwc3_set_address(dwc3_handle, 0); in dwc3_handle_dev_event()
1783 speed = dwc3_get_dev_speed(dwc3_handle); in dwc3_handle_dev_event()
1806 ret = dwc3_ep_configure(dwc3_handle, 0, false, EP_TYPE_CTRL, ep0_mps, 0, 0, 0, in dwc3_handle_dev_event()
1807 dwc3_handle->OUT_ep[0].intr_num, in dwc3_handle_dev_event()
1813 ret = dwc3_ep_configure(dwc3_handle, 0, true, EP_TYPE_CTRL, ep0_mps, 0, 0, 1, in dwc3_handle_dev_event()
1814 dwc3_handle->IN_ep[0].intr_num, in dwc3_handle_dev_event()
1821 dwc3_handle->pcd_handle->out_ep[0].maxpacket = ep0_mps; in dwc3_handle_dev_event()
1822 dwc3_handle->pcd_handle->in_ep[0].maxpacket = ep0_mps; in dwc3_handle_dev_event()
1905 dwc3_handle_t *dwc3_handle = (dwc3_handle_t *)handle; in usb_dwc3_it_handler() local
1914 evtcnt = dwc3_read_intr_count(dwc3_handle, i); in usb_dwc3_it_handler()
1922 evt = __HAL_PCD_READ_EVENT(dwc3_handle, i); in usb_dwc3_it_handler()
1926 action = dwc3_handle_ep_event(dwc3_handle, evt, param); in usb_dwc3_it_handler()
1929 action = dwc3_handle_dev_event(dwc3_handle, evt, param); in usb_dwc3_it_handler()
1935 __HAL_PCD_INCR_EVENT_POS(dwc3_handle, i, USB_DWC3_EVENT_SIZE); in usb_dwc3_it_handler()
1937 dwc3_ack_evt_count(dwc3_handle, i, USB_DWC3_EVENT_SIZE); in usb_dwc3_it_handler()
1988 static enum usb_status dwc3_soft_reset(dwc3_handle_t *dwc3_handle) in dwc3_soft_reset() argument
1992 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DCTL, USB3_DCTL_CSFTRST); in dwc3_soft_reset()
1996 while (DWC3_regread(dwc3_handle->usb_device, DWC3_DCTL) & USB3_DCTL_CSFTRST) { in dwc3_soft_reset()
2006 static enum usb_status dwc3_core_init(dwc3_handle_t *dwc3_handle, uint32_t phy_itface) in dwc3_core_init() argument
2010 VERBOSE("Core ID %08x\n", (uint32_t)DWC3_regread(dwc3_handle->usb_global, DWC3_GSNPSID)); in dwc3_core_init()
2021 DWC3_regupdateclr(dwc3_handle->usb_global, DWC3_GUSB2PHYCFG(0UL), in dwc3_core_init()
2025 DWC3_regupdateset(dwc3_handle->usb_global, DWC3_GUSB2PHYCFG(0UL), in dwc3_core_init()
2035 ret = dwc3_soft_reset(dwc3_handle); in dwc3_core_init()
2043 DWC3_regupdateset(dwc3_handle->usb_global, DWC3_GCTL, USB3_GCTL_CORESOFTRESET); in dwc3_core_init()
2047 DWC3_regupdateset(dwc3_handle->usb_global, DWC3_GUSB3PIPECTL(0UL), in dwc3_core_init()
2053 DWC3_regupdateset(dwc3_handle->usb_global, DWC3_GUSB2PHYCFG(0UL), in dwc3_core_init()
2066 DWC3_regupdateclr(dwc3_handle->usb_global, DWC3_GUSB3PIPECTL(0UL), in dwc3_core_init()
2072 DWC3_regupdateclr(dwc3_handle->usb_global, DWC3_GUSB2PHYCFG(0UL), in dwc3_core_init()
2080 DWC3_regupdateclr(dwc3_handle->usb_global, DWC3_GCTL, USB3_GCTL_CORESOFTRESET); in dwc3_core_init()
2089 DWC3_regwrite(dwc3_handle->usb_global, DWC3_GSBUSCFG0, 0xe); in dwc3_core_init()
2090 DWC3_regwrite(dwc3_handle->usb_global, DWC3_GSBUSCFG1, 0xf00); in dwc3_core_init()
2104 static enum usb_status dwc3_set_current_mode(dwc3_handle_t *dwc3_handle, USB_DWC3_modetypedef mode) in dwc3_set_current_mode() argument
2109 reg = DWC3_regread(dwc3_handle->usb_global, DWC3_GCTL) & ~USB3_GCTL_PRTCAPDIR_MSK; in dwc3_set_current_mode()
2113 DWC3_regwrite(dwc3_handle->usb_global, DWC3_GCTL, reg | in dwc3_set_current_mode()
2117 DWC3_regwrite(dwc3_handle->usb_global, DWC3_GCTL, reg | in dwc3_set_current_mode()
2121 DWC3_regwrite(dwc3_handle->usb_global, DWC3_GCTL, reg | in dwc3_set_current_mode()
2132 static enum usb_status dwc3_set_dev_speed(dwc3_handle_t *dwc3_handle, uint8_t speed) in dwc3_set_dev_speed() argument
2137 reg = DWC3_regread(dwc3_handle->usb_device, DWC3_DCFG) & ~USB3_DCFG_DEVSPD_MSK; in dwc3_set_dev_speed()
2141 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DCFG, reg | DWC3_DSTS_SUPERSPEED); in dwc3_set_dev_speed()
2145 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DCFG, reg | DWC3_DSTS_HIGHSPEED); in dwc3_set_dev_speed()
2149 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DCFG, reg | DWC3_DSTS_FULLSPEED1); in dwc3_set_dev_speed()
2153 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DCFG, reg | DWC3_DSTS_FULLSPEED2); in dwc3_set_dev_speed()
2157 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DCFG, reg | DWC3_DSTS_LOWSPEED); in dwc3_set_dev_speed()
2176 enum usb_status dwc3_dev_init(dwc3_handle_t *dwc3_handle, uint8_t speed, uint8_t intr_dev) in dwc3_dev_init() argument
2185 DWC3_regwrite(dwc3_handle->usb_global, DWC3_GEVNTADRLO(i), in dwc3_dev_init()
2186 lower_32_bits(dwc3_handle->intbuffers.evtbuffer_dma_addr[i])); in dwc3_dev_init()
2187 DWC3_regwrite(dwc3_handle->usb_global, DWC3_GEVNTADRHI(i), in dwc3_dev_init()
2188 upper_32_bits(dwc3_handle->intbuffers.evtbuffer_dma_addr[i])); in dwc3_dev_init()
2189 DWC3_regwrite(dwc3_handle->usb_global, DWC3_GEVNTSIZ(i), in dwc3_dev_init()
2191 DWC3_regwrite(dwc3_handle->usb_global, DWC3_GEVNTCOUNT(i), 0); in dwc3_dev_init()
2200 DWC3_regupdateset(dwc3_handle->usb_global, DWC3_GUCTL2, DWC3_GUCTL2_RST_ACTBITLATER); in dwc3_dev_init()
2202 ret = dwc3_set_current_mode(dwc3_handle, USB_DWC3_DEVICE_MODE); in dwc3_dev_init()
2208 ret = dwc3_set_dev_speed(dwc3_handle, speed); in dwc3_dev_init()
2218 ret = dwc3_execute_dep_cmd(dwc3_handle, 0, DWC3_DEPCMD_PARAM(0) | in dwc3_dev_init()
2226 ret = dwc3_ep_configure(dwc3_handle, 0, false, EP_TYPE_CTRL, in dwc3_dev_init()
2227 dwc3_handle->pcd_handle->out_ep[0].maxpacket, 0, 0, 0, in dwc3_dev_init()
2228 dwc3_handle->OUT_ep[0].intr_num, USB_DWC3_DEPCFG_ACTION_INIT); in dwc3_dev_init()
2233 ret = dwc3_ep_configure(dwc3_handle, 0, true, EP_TYPE_CTRL, in dwc3_dev_init()
2234 dwc3_handle->pcd_handle->in_ep[0].maxpacket, 0, 0, 1, in dwc3_dev_init()
2235 dwc3_handle->IN_ep[0].intr_num, USB_DWC3_DEPCFG_ACTION_INIT); in dwc3_dev_init()
2256 ret = dwc3_execute_dep_cmd(dwc3_handle, i, USB_DWC3_DEPCMD_SETTRANSFRESOURCE, in dwc3_dev_init()
2265 ret = dwc3_ep0_out_start(dwc3_handle, dwc3_handle->setup_dma_addr); in dwc3_dev_init()
2272 DWC3_regupdateset(dwc3_handle->usb_device, DWC3_DALEPENA, DWC3_DALEPENA_EP(0) | in dwc3_dev_init()
2279 reg = DWC3_regread(dwc3_handle->usb_device, DWC3_DCFG) & ~USB3_DCFG_INTRNUM_MSK; in dwc3_dev_init()
2280 DWC3_regwrite(dwc3_handle->usb_device, DWC3_DCFG, reg | in dwc3_dev_init()
2284 DWC3_regupdateset(dwc3_handle->usb_device, DWC3_DEVTEN, USB3_DEVTEN_VENDEVTSTRCVDEN | in dwc3_dev_init()
2295 __HAL_PCD_ENABLE_INTR(dwc3_handle, i); in dwc3_dev_init()
2302 dwc3_handle_t *dwc3_handle, void *base_addr) in usb_dwc3_init_driver() argument
2308 dwc3_handle->usb_global = (usb_dwc3_global_t *) in usb_dwc3_init_driver()
2311 dwc3_handle->usb_device = (usb_dwc3_device_t *) in usb_dwc3_init_driver()
2314 dwc3_handle->pcd_handle = pcd_handle; in usb_dwc3_init_driver()
2317 assert(dwc3_handle->State == HAL_PCD_STATE_RESET); in usb_dwc3_init_driver()
2319 dwc3_handle->State = HAL_PCD_STATE_BUSY; in usb_dwc3_init_driver()
2324 __HAL_PCD_DISABLE_INTR(dwc3_handle, i); in usb_dwc3_init_driver()
2328 ret = dwc3_core_init(dwc3_handle, USBPHY_UTMI); in usb_dwc3_init_driver()
2338 dwc3_handle->IN_ep[i].tx_fifo_num = i; in usb_dwc3_init_driver()
2349 dwc3_handle->IN_ep[i].phy_epnum = __HAL_PCD_EPADDR_TO_PHYEPNUM(i | EP_DIR_IN); in usb_dwc3_init_driver()
2351 dwc3_handle->IN_ep[i].phy_epnum = 1U; in usb_dwc3_init_driver()
2354 dwc3_handle->IN_ep[i].intr_num = PCD_DEV_EVENTS_INTR; in usb_dwc3_init_driver()
2361 dwc3_handle->OUT_ep[i].tx_fifo_num = i; in usb_dwc3_init_driver()
2371 dwc3_handle->OUT_ep[i].phy_epnum = __HAL_PCD_EPADDR_TO_PHYEPNUM(i); in usb_dwc3_init_driver()
2373 dwc3_handle->OUT_ep[i].intr_num = PCD_DEV_EVENTS_INTR; in usb_dwc3_init_driver()
2375 dwc3_handle->OUT_ep[i].bounce_buf = dwc3_handle->bounce_bufs[i].bounce_buf; in usb_dwc3_init_driver()
2392 dwc3_handle->setup_dma_addr = (uintptr_t)api_getdmaaddr((void *)SETUP_AREA, in usb_dwc3_init_driver()
2394 assert(dwc3_handle->setup_dma_addr != 0U); in usb_dwc3_init_driver()
2396 dwc3_handle->setup_addr = SETUP_AREA; in usb_dwc3_init_driver()
2397 assert(dwc3_handle->setup_addr != NULL); in usb_dwc3_init_driver()
2401 dwc3_handle->intbuffers.evtbuffer_dma_addr[i] = in usb_dwc3_init_driver()
2403 assert(dwc3_handle->intbuffers.evtbuffer_dma_addr[i] != 0U); in usb_dwc3_init_driver()
2405 dwc3_handle->intbuffers.evtbuffer_addr[i] = EVTBUF_AREA; in usb_dwc3_init_driver()
2406 assert(dwc3_handle->intbuffers.evtbuffer_addr[i] != NULL); in usb_dwc3_init_driver()
2408 dwc3_handle->intbuffers.evtbufferpos[i] = 0; in usb_dwc3_init_driver()
2412 (uint32_t)dwc3_handle->intbuffers.evtbuffer_dma_addr[i], in usb_dwc3_init_driver()
2413 dwc3_handle->intbuffers.evtbuffer_addr[i]); in usb_dwc3_init_driver()
2417 dwc3_handle->IN_ep[0].trb_dma_addr = (uint32_t)api_getdmaaddr((void *)TRB_IN_AREA, in usb_dwc3_init_driver()
2419 assert(dwc3_handle->IN_ep[0].trb_dma_addr != 0U); in usb_dwc3_init_driver()
2421 dwc3_handle->IN_ep[0].trb_addr = (usb_dwc3_trb_t *)TRB_IN_AREA; in usb_dwc3_init_driver()
2422 assert(dwc3_handle->IN_ep[0].trb_addr != NULL); in usb_dwc3_init_driver()
2424 dwc3_handle->OUT_ep[0].trb_dma_addr = (uint32_t)api_getdmaaddr((void *)TRB_OUT_AREA, in usb_dwc3_init_driver()
2427 assert(dwc3_handle->OUT_ep[0].trb_dma_addr != 0U); in usb_dwc3_init_driver()
2429 dwc3_handle->OUT_ep[0].trb_addr = (usb_dwc3_trb_t *)TRB_OUT_AREA; in usb_dwc3_init_driver()
2430 assert(dwc3_handle->OUT_ep[0].trb_addr != NULL); in usb_dwc3_init_driver()
2433 dwc3_handle->EP0_State = HAL_PCD_EP0_SETUP_QUEUED; in usb_dwc3_init_driver()
2435 ret = dwc3_dev_init(dwc3_handle, USB_DWC3_SPEED_HIGH, PCD_DEV_EVENTS_INTR); in usb_dwc3_init_driver()
2438 dwc3_handle->State = HAL_PCD_STATE_READY; in usb_dwc3_init_driver()
2441 dwc3_handle); in usb_dwc3_init_driver()