Lines Matching refs:priv_dev
114 static int cdns3_get_dma_pos(struct cdns3_device *priv_dev, in cdns3_get_dma_pos() argument
119 dma_index = readl(&priv_dev->regs->ep_traddr) - priv_ep->trb_pool_dma; in cdns3_get_dma_pos()
162 void cdns3_select_ep(struct cdns3_device *priv_dev, u32 ep) in cdns3_select_ep() argument
164 if (priv_dev->selected_ep == ep) in cdns3_select_ep()
167 priv_dev->selected_ep = ep; in cdns3_select_ep()
168 writel(ep, &priv_dev->regs->ep_sel); in cdns3_select_ep()
178 static int cdns3_get_tdl(struct cdns3_device *priv_dev) in cdns3_get_tdl() argument
180 if (priv_dev->dev_ver < DEV_VER_V3) in cdns3_get_tdl()
181 return EP_CMD_TDL_GET(readl(&priv_dev->regs->ep_cmd)); in cdns3_get_tdl()
183 return readl(&priv_dev->regs->ep_tdl); in cdns3_get_tdl()
196 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_free_trb_pool() local
199 dma_pool_free(priv_dev->eps_dma_pool, in cdns3_free_trb_pool()
213 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_allocate_trb_pool() local
222 priv_ep->trb_pool = dma_pool_alloc(priv_dev->eps_dma_pool, in cdns3_allocate_trb_pool()
263 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_ep_stall_flush() local
269 &priv_dev->regs->ep_cmd); in cdns3_ep_stall_flush()
272 readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val, in cdns3_ep_stall_flush()
282 void cdns3_hw_reset_eps_config(struct cdns3_device *priv_dev) in cdns3_hw_reset_eps_config() argument
286 writel(USB_CONF_CFGRST, &priv_dev->regs->usb_conf); in cdns3_hw_reset_eps_config()
288 cdns3_allow_enable_l1(priv_dev, 0); in cdns3_hw_reset_eps_config()
289 priv_dev->hw_configured_flag = 0; in cdns3_hw_reset_eps_config()
290 priv_dev->onchip_used_size = 0; in cdns3_hw_reset_eps_config()
291 priv_dev->out_mem_is_allocated = 0; in cdns3_hw_reset_eps_config()
292 priv_dev->wait_for_setup = 0; in cdns3_hw_reset_eps_config()
293 priv_dev->using_streams = 0; in cdns3_hw_reset_eps_config()
296 if (priv_dev->eps[i]) in cdns3_hw_reset_eps_config()
297 priv_dev->eps[i]->flags &= ~EP_CONFIGURED; in cdns3_hw_reset_eps_config()
350 void cdns3_allow_enable_l1(struct cdns3_device *priv_dev, int enable) in cdns3_allow_enable_l1() argument
353 writel(USB_CONF_L1EN, &priv_dev->regs->usb_conf); in cdns3_allow_enable_l1()
355 writel(USB_CONF_L1DS, &priv_dev->regs->usb_conf); in cdns3_allow_enable_l1()
358 enum usb_device_speed cdns3_get_speed(struct cdns3_device *priv_dev) in cdns3_get_speed() argument
362 reg = readl(&priv_dev->regs->usb_sts); in cdns3_get_speed()
383 static int cdns3_start_all_request(struct cdns3_device *priv_dev, in cdns3_start_all_request() argument
403 dev_dbg(priv_dev->dev, "Blocking external request\n"); in cdns3_start_all_request()
435 #define cdns3_wa2_enable_detection(priv_dev, priv_ep, reg) do { \ argument
507 static struct usb_request *cdns3_wa2_gadget_giveback(struct cdns3_device *priv_dev, in cdns3_wa2_gadget_giveback() argument
523 usb_gadget_unmap_request_by_dev(priv_dev->sysdev, req, in cdns3_wa2_gadget_giveback()
531 usb_gadget_map_request_by_dev(priv_dev->sysdev, req, in cdns3_wa2_gadget_giveback()
540 cdns3_start_all_request(priv_dev, priv_ep); in cdns3_wa2_gadget_giveback()
547 static int cdns3_wa2_gadget_ep_queue(struct cdns3_device *priv_dev, in cdns3_wa2_gadget_ep_queue() argument
561 cdns3_select_ep(priv_dev, priv_ep->num | priv_ep->dir); in cdns3_wa2_gadget_ep_queue()
563 reg = readl(&priv_dev->regs->ep_sts_en); in cdns3_wa2_gadget_ep_queue()
566 writel(reg, &priv_dev->regs->ep_sts_en); in cdns3_wa2_gadget_ep_queue()
709 static void cdns3_wa2_reset_tdl(struct cdns3_device *priv_dev) in cdns3_wa2_reset_tdl() argument
711 u16 tdl = EP_CMD_TDL_GET(readl(&priv_dev->regs->ep_cmd)); in cdns3_wa2_reset_tdl()
717 &priv_dev->regs->ep_cmd); in cdns3_wa2_reset_tdl()
721 static void cdns3_wa2_check_outq_status(struct cdns3_device *priv_dev) in cdns3_wa2_check_outq_status() argument
726 cdns3_select_ep(priv_dev, 0); in cdns3_wa2_check_outq_status()
728 ep_sts_reg = readl(&priv_dev->regs->ep_sts); in cdns3_wa2_check_outq_status()
732 struct cdns3_endpoint *outq_ep = priv_dev->eps[outq_ep_num]; in cdns3_wa2_check_outq_status()
745 cdns3_select_ep(priv_dev, outq_ep->num | in cdns3_wa2_check_outq_status()
747 ep_sts_en_reg = readl(&priv_dev->regs->ep_sts_en); in cdns3_wa2_check_outq_status()
748 ep_cmd_reg = readl(&priv_dev->regs->ep_cmd); in cdns3_wa2_check_outq_status()
751 cdns3_set_register_bit(&priv_dev->regs->ep_cfg, in cdns3_wa2_check_outq_status()
754 cdns3_wa2_enable_detection(priv_dev, outq_ep, in cdns3_wa2_check_outq_status()
757 &priv_dev->regs->ep_sts_en); in cdns3_wa2_check_outq_status()
759 cdns3_wa2_reset_tdl(priv_dev); in cdns3_wa2_check_outq_status()
774 &priv_dev->regs->ep_cmd); in cdns3_wa2_check_outq_status()
795 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_gadget_giveback() local
803 usb_gadget_unmap_request_by_dev(priv_dev->sysdev, request, in cdns3_gadget_giveback()
809 dma_sync_single_for_cpu(priv_dev->sysdev, in cdns3_gadget_giveback()
822 if (priv_dev->dev_ver < DEV_VER_V2) { in cdns3_gadget_giveback()
823 request = cdns3_wa2_gadget_giveback(priv_dev, priv_ep, in cdns3_gadget_giveback()
830 spin_unlock(&priv_dev->lock); in cdns3_gadget_giveback()
833 spin_lock(&priv_dev->lock); in cdns3_gadget_giveback()
836 if (request->buf == priv_dev->zlp_buf) in cdns3_gadget_giveback()
860 struct cdns3_device *priv_dev = container_of(work, struct cdns3_device, in cdns3_free_aligned_request_buf() local
865 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_free_aligned_request_buf()
867 list_for_each_entry_safe(buf, tmp, &priv_dev->aligned_buf_list, list) { in cdns3_free_aligned_request_buf()
876 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_free_aligned_request_buf()
877 dma_free_noncoherent(priv_dev->sysdev, buf->size, in cdns3_free_aligned_request_buf()
880 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_free_aligned_request_buf()
884 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_free_aligned_request_buf()
890 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_prepare_aligned_request_buf() local
908 buf->buf = dma_alloc_noncoherent(priv_dev->sysdev, in cdns3_prepare_aligned_request_buf()
922 &priv_dev->aligned_buf_wq); in cdns3_prepare_aligned_request_buf()
929 &priv_dev->aligned_buf_list); in cdns3_prepare_aligned_request_buf()
934 dma_sync_single_for_cpu(priv_dev->sysdev, in cdns3_prepare_aligned_request_buf()
941 dma_sync_single_for_device(priv_dev->sysdev, in cdns3_prepare_aligned_request_buf()
953 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_wa1_update_guard() local
958 doorbell = !!(readl(&priv_dev->regs->ep_cmd) & EP_CMD_DRDY); in cdns3_wa1_update_guard()
972 static void cdns3_wa1_tray_restore_cycle_bit(struct cdns3_device *priv_dev, in cdns3_wa1_tray_restore_cycle_bit() argument
978 doorbell = !!(readl(&priv_dev->regs->ep_cmd) & EP_CMD_DRDY); in cdns3_wa1_tray_restore_cycle_bit()
979 dma_index = cdns3_get_dma_pos(priv_dev, priv_ep); in cdns3_wa1_tray_restore_cycle_bit()
988 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_ep_run_stream_transfer() local
1037 if (priv_dev->dev_ver >= DEV_VER_V2) { in cdns3_ep_run_stream_transfer()
1038 if (priv_dev->gadget.speed == USB_SPEED_SUPER) in cdns3_ep_run_stream_transfer()
1055 &priv_dev->regs->ep_traddr); in cdns3_ep_run_stream_transfer()
1060 writel(EP_STS_TRBERR | EP_STS_DESCMIS, &priv_dev->regs->ep_sts); in cdns3_ep_run_stream_transfer()
1069 if (priv_dev->dev_ver < DEV_VER_V2) in cdns3_ep_run_stream_transfer()
1071 &priv_dev->regs->ep_cmd); in cdns3_ep_run_stream_transfer()
1072 else if (priv_dev->dev_ver > DEV_VER_V2) in cdns3_ep_run_stream_transfer()
1073 writel(tdl, &priv_dev->regs->ep_tdl); in cdns3_ep_run_stream_transfer()
1076 writel(EP_CMD_DRDY, &priv_dev->regs->ep_cmd); in cdns3_ep_run_stream_transfer()
1078 EP_CMD_ERDY, &priv_dev->regs->ep_cmd); in cdns3_ep_run_stream_transfer()
1081 readl(&priv_dev->regs->ep_traddr)); in cdns3_ep_run_stream_transfer()
1085 __cdns3_gadget_wakeup(priv_dev); in cdns3_ep_run_stream_transfer()
1092 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_rearm_drdy_if_needed() local
1094 if (priv_dev->dev_ver < DEV_VER_V3) in cdns3_rearm_drdy_if_needed()
1097 if (readl(&priv_dev->regs->ep_sts) & EP_STS_TRBERR) { in cdns3_rearm_drdy_if_needed()
1098 writel(EP_STS_TRBERR, &priv_dev->regs->ep_sts); in cdns3_rearm_drdy_if_needed()
1099 writel(EP_CMD_DRDY, &priv_dev->regs->ep_cmd); in cdns3_rearm_drdy_if_needed()
1113 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_ep_run_transfer() local
1160 doorbell = !!(readl(&priv_dev->regs->ep_cmd) & EP_CMD_DRDY); in cdns3_ep_run_transfer()
1161 dma_index = cdns3_get_dma_pos(priv_dev, priv_ep); in cdns3_ep_run_transfer()
1207 if (priv_dev->dev_ver <= DEV_VER_V2) in cdns3_ep_run_transfer()
1213 if (priv_dev->dev_ver >= DEV_VER_V2) { in cdns3_ep_run_transfer()
1218 if (priv_dev->gadget.speed == USB_SPEED_SUPER) in cdns3_ep_run_transfer()
1268 if (priv_ep->type == USB_ENDPOINT_XFER_ISOC && priv_dev->dev_ver <= DEV_VER_V2) in cdns3_ep_run_transfer()
1322 if (priv_dev->dev_ver < DEV_VER_V2 && in cdns3_ep_run_transfer()
1325 u16 old_tdl = EP_CMD_TDL_GET(readl(&priv_dev->regs->ep_cmd)); in cdns3_ep_run_transfer()
1335 &priv_dev->regs->ep_cmd); in cdns3_ep_run_transfer()
1348 if (priv_dev->dev_ver <= DEV_VER_V2) in cdns3_ep_run_transfer()
1349 cdns3_wa1_tray_restore_cycle_bit(priv_dev, priv_ep); in cdns3_ep_run_transfer()
1387 cdns3_set_register_bit(&priv_dev->regs->ep_cfg, in cdns3_ep_run_transfer()
1393 &priv_dev->regs->ep_traddr); in cdns3_ep_run_transfer()
1401 writel(EP_STS_TRBERR | EP_STS_DESCMIS, &priv_dev->regs->ep_sts); in cdns3_ep_run_transfer()
1402 writel(EP_CMD_DRDY, &priv_dev->regs->ep_cmd); in cdns3_ep_run_transfer()
1405 readl(&priv_dev->regs->ep_traddr)); in cdns3_ep_run_transfer()
1409 __cdns3_gadget_wakeup(priv_dev); in cdns3_ep_run_transfer()
1414 void cdns3_set_hw_configuration(struct cdns3_device *priv_dev) in cdns3_set_hw_configuration() argument
1419 if (priv_dev->hw_configured_flag) in cdns3_set_hw_configuration()
1422 writel(USB_CONF_CFGSET, &priv_dev->regs->usb_conf); in cdns3_set_hw_configuration()
1424 cdns3_set_register_bit(&priv_dev->regs->usb_conf, in cdns3_set_hw_configuration()
1427 priv_dev->hw_configured_flag = 1; in cdns3_set_hw_configuration()
1429 list_for_each_entry(ep, &priv_dev->gadget.ep_list, ep_list) { in cdns3_set_hw_configuration()
1432 cdns3_start_all_request(priv_dev, priv_ep); in cdns3_set_hw_configuration()
1436 cdns3_allow_enable_l1(priv_dev, 1); in cdns3_set_hw_configuration()
1481 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_trb_handled() local
1487 current_index = cdns3_get_dma_pos(priv_dev, priv_ep); in cdns3_trb_handled()
1488 doorbell = !!(readl(&priv_dev->regs->ep_cmd) & EP_CMD_DRDY); in cdns3_trb_handled()
1541 static void cdns3_transfer_completed(struct cdns3_device *priv_dev, in cdns3_transfer_completed() argument
1560 if (priv_ep->dequeue == cdns3_get_dma_pos(priv_dev, priv_ep) && in cdns3_transfer_completed()
1573 cdns3_select_ep(priv_dev, priv_ep->endpoint.address); in cdns3_transfer_completed()
1614 cdns3_select_ep(priv_dev, priv_ep->endpoint.address); in cdns3_transfer_completed()
1620 dev_warn(priv_dev->dev, in cdns3_transfer_completed()
1642 cdns3_start_all_request(priv_dev, priv_ep); in cdns3_transfer_completed()
1647 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_rearm_transfer() local
1656 writel(EP_CMD_DRDY, &priv_dev->regs->ep_cmd); in cdns3_rearm_transfer()
1658 __cdns3_gadget_wakeup(priv_dev); in cdns3_rearm_transfer()
1661 readl(&priv_dev->regs->ep_traddr)); in cdns3_rearm_transfer()
1668 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_reprogram_tdl() local
1677 writel(EP_CMD_TDL_SET(tdl) | EP_CMD_STDL, &priv_dev->regs->ep_cmd); in cdns3_reprogram_tdl()
1688 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_check_ep_interrupt_proceed() local
1694 cdns3_select_ep(priv_dev, priv_ep->endpoint.address); in cdns3_check_ep_interrupt_proceed()
1696 trace_cdns3_epx_irq(priv_dev, priv_ep); in cdns3_check_ep_interrupt_proceed()
1698 ep_sts_reg = readl(&priv_dev->regs->ep_sts); in cdns3_check_ep_interrupt_proceed()
1699 writel(ep_sts_reg, &priv_dev->regs->ep_sts); in cdns3_check_ep_interrupt_proceed()
1704 tdl = cdns3_get_tdl(priv_dev); in cdns3_check_ep_interrupt_proceed()
1717 &priv_dev->regs->ep_cmd); in cdns3_check_ep_interrupt_proceed()
1726 cdns3_start_all_request(priv_dev, priv_ep); in cdns3_check_ep_interrupt_proceed()
1734 priv_dev->dev_ver < DEV_VER_V2)) { in cdns3_check_ep_interrupt_proceed()
1748 u32 ep_cfg = readl(&priv_dev->regs->ep_cfg); in cdns3_check_ep_interrupt_proceed()
1751 writel(ep_cfg, &priv_dev->regs->ep_cfg); in cdns3_check_ep_interrupt_proceed()
1755 cdns3_transfer_completed(priv_dev, priv_ep); in cdns3_check_ep_interrupt_proceed()
1760 cdns3_start_all_request(priv_dev, priv_ep); in cdns3_check_ep_interrupt_proceed()
1780 cdns3_transfer_completed(priv_dev, priv_ep); in cdns3_check_ep_interrupt_proceed()
1789 cdns3_transfer_completed(priv_dev, priv_ep); in cdns3_check_ep_interrupt_proceed()
1800 cdns3_transfer_completed(priv_dev, priv_ep); in cdns3_check_ep_interrupt_proceed()
1809 if (ep_sts_reg & EP_STS_DESCMIS && priv_dev->dev_ver < DEV_VER_V2 && in cdns3_check_ep_interrupt_proceed()
1816 static void cdns3_disconnect_gadget(struct cdns3_device *priv_dev) in cdns3_disconnect_gadget() argument
1818 if (priv_dev->gadget_driver && priv_dev->gadget_driver->disconnect) in cdns3_disconnect_gadget()
1819 priv_dev->gadget_driver->disconnect(&priv_dev->gadget); in cdns3_disconnect_gadget()
1828 static void cdns3_check_usb_interrupt_proceed(struct cdns3_device *priv_dev, in cdns3_check_usb_interrupt_proceed() argument
1830 __must_hold(&priv_dev->lock) in cdns3_check_usb_interrupt_proceed()
1834 trace_cdns3_usb_irq(priv_dev, usb_ists); in cdns3_check_usb_interrupt_proceed()
1841 if (readl(&priv_dev->regs->drbl)) in cdns3_check_usb_interrupt_proceed()
1842 __cdns3_gadget_wakeup(priv_dev); in cdns3_check_usb_interrupt_proceed()
1847 speed = cdns3_get_speed(priv_dev); in cdns3_check_usb_interrupt_proceed()
1848 priv_dev->gadget.speed = speed; in cdns3_check_usb_interrupt_proceed()
1849 usb_gadget_set_state(&priv_dev->gadget, USB_STATE_POWERED); in cdns3_check_usb_interrupt_proceed()
1850 cdns3_ep0_config(priv_dev); in cdns3_check_usb_interrupt_proceed()
1855 spin_unlock(&priv_dev->lock); in cdns3_check_usb_interrupt_proceed()
1856 cdns3_disconnect_gadget(priv_dev); in cdns3_check_usb_interrupt_proceed()
1857 spin_lock(&priv_dev->lock); in cdns3_check_usb_interrupt_proceed()
1858 priv_dev->gadget.speed = USB_SPEED_UNKNOWN; in cdns3_check_usb_interrupt_proceed()
1859 usb_gadget_set_state(&priv_dev->gadget, USB_STATE_NOTATTACHED); in cdns3_check_usb_interrupt_proceed()
1860 cdns3_hw_reset_eps_config(priv_dev); in cdns3_check_usb_interrupt_proceed()
1864 if (priv_dev->gadget_driver && in cdns3_check_usb_interrupt_proceed()
1865 priv_dev->gadget_driver->suspend) { in cdns3_check_usb_interrupt_proceed()
1866 spin_unlock(&priv_dev->lock); in cdns3_check_usb_interrupt_proceed()
1867 priv_dev->gadget_driver->suspend(&priv_dev->gadget); in cdns3_check_usb_interrupt_proceed()
1868 spin_lock(&priv_dev->lock); in cdns3_check_usb_interrupt_proceed()
1873 if (priv_dev->gadget_driver && in cdns3_check_usb_interrupt_proceed()
1874 priv_dev->gadget_driver->resume) { in cdns3_check_usb_interrupt_proceed()
1875 spin_unlock(&priv_dev->lock); in cdns3_check_usb_interrupt_proceed()
1876 priv_dev->gadget_driver->resume(&priv_dev->gadget); in cdns3_check_usb_interrupt_proceed()
1877 spin_lock(&priv_dev->lock); in cdns3_check_usb_interrupt_proceed()
1883 if (priv_dev->gadget_driver) { in cdns3_check_usb_interrupt_proceed()
1884 spin_unlock(&priv_dev->lock); in cdns3_check_usb_interrupt_proceed()
1885 usb_gadget_udc_reset(&priv_dev->gadget, in cdns3_check_usb_interrupt_proceed()
1886 priv_dev->gadget_driver); in cdns3_check_usb_interrupt_proceed()
1887 spin_lock(&priv_dev->lock); in cdns3_check_usb_interrupt_proceed()
1890 speed = cdns3_get_speed(priv_dev); in cdns3_check_usb_interrupt_proceed()
1891 priv_dev->gadget.speed = speed; in cdns3_check_usb_interrupt_proceed()
1892 cdns3_hw_reset_eps_config(priv_dev); in cdns3_check_usb_interrupt_proceed()
1893 cdns3_ep0_config(priv_dev); in cdns3_check_usb_interrupt_proceed()
1908 struct cdns3_device *priv_dev = data; in cdns3_device_irq_handler() local
1909 struct cdns *cdns = dev_get_drvdata(priv_dev->dev); in cdns3_device_irq_handler()
1917 reg = readl(&priv_dev->regs->usb_ists); in cdns3_device_irq_handler()
1926 reg = ~reg & readl(&priv_dev->regs->usb_ien); in cdns3_device_irq_handler()
1928 writel(reg, &priv_dev->regs->usb_ien); in cdns3_device_irq_handler()
1933 reg = readl(&priv_dev->regs->ep_ists); in cdns3_device_irq_handler()
1935 writel(0, &priv_dev->regs->ep_ien); in cdns3_device_irq_handler()
1953 struct cdns3_device *priv_dev = data; in cdns3_device_thread_irq_handler() local
1959 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_device_thread_irq_handler()
1961 reg = readl(&priv_dev->regs->usb_ists); in cdns3_device_thread_irq_handler()
1963 writel(reg, &priv_dev->regs->usb_ists); in cdns3_device_thread_irq_handler()
1964 writel(USB_IEN_INIT, &priv_dev->regs->usb_ien); in cdns3_device_thread_irq_handler()
1965 cdns3_check_usb_interrupt_proceed(priv_dev, reg); in cdns3_device_thread_irq_handler()
1969 reg = readl(&priv_dev->regs->ep_ists); in cdns3_device_thread_irq_handler()
1973 cdns3_check_ep0_interrupt_proceed(priv_dev, USB_DIR_OUT); in cdns3_device_thread_irq_handler()
1979 cdns3_check_ep0_interrupt_proceed(priv_dev, USB_DIR_IN); in cdns3_device_thread_irq_handler()
1990 cdns3_check_ep_interrupt_proceed(priv_dev->eps[bit]); in cdns3_device_thread_irq_handler()
1994 if (priv_dev->dev_ver < DEV_VER_V2 && priv_dev->using_streams) in cdns3_device_thread_irq_handler()
1995 cdns3_wa2_check_outq_status(priv_dev); in cdns3_device_thread_irq_handler()
1998 writel(~0, &priv_dev->regs->ep_ien); in cdns3_device_thread_irq_handler()
1999 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_device_thread_irq_handler()
2016 static int cdns3_ep_onchip_buffer_reserve(struct cdns3_device *priv_dev, in cdns3_ep_onchip_buffer_reserve() argument
2022 remained = priv_dev->onchip_buffers - priv_dev->onchip_used_size - 2; in cdns3_ep_onchip_buffer_reserve()
2028 priv_dev->onchip_used_size += size; in cdns3_ep_onchip_buffer_reserve()
2036 if (priv_dev->out_mem_is_allocated >= size) in cdns3_ep_onchip_buffer_reserve()
2039 required = size - priv_dev->out_mem_is_allocated; in cdns3_ep_onchip_buffer_reserve()
2044 priv_dev->out_mem_is_allocated += required; in cdns3_ep_onchip_buffer_reserve()
2045 priv_dev->onchip_used_size += required; in cdns3_ep_onchip_buffer_reserve()
2051 static void cdns3_configure_dmult(struct cdns3_device *priv_dev, in cdns3_configure_dmult() argument
2054 struct cdns3_usb_regs __iomem *regs = priv_dev->regs; in cdns3_configure_dmult()
2057 if (priv_dev->dev_ver <= DEV_VER_V2) in cdns3_configure_dmult()
2060 if (priv_dev->dev_ver == DEV_VER_V2) in cdns3_configure_dmult()
2063 if (priv_dev->dev_ver >= DEV_VER_V3 && priv_ep) { in cdns3_configure_dmult()
2093 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_ep_config() local
2101 buffering = priv_dev->ep_buf_size - 1; in cdns3_ep_config()
2103 cdns3_configure_dmult(priv_dev, priv_ep); in cdns3_ep_config()
2109 if (priv_dev->dev_ver >= DEV_VER_V2 && !priv_ep->dir) in cdns3_ep_config()
2115 if (priv_dev->dev_ver >= DEV_VER_V2 && !priv_ep->dir) in cdns3_ep_config()
2123 switch (priv_dev->gadget.speed) { in cdns3_ep_config()
2133 maxburst = priv_dev->ep_buf_size - 1; in cdns3_ep_config()
2158 if (priv_dev->dev_ver < DEV_VER_V2) in cdns3_ep_config()
2165 if (!priv_dev->hw_configured_flag) { in cdns3_ep_config()
2166 ret = cdns3_ep_onchip_buffer_reserve(priv_dev, buffering + 1, in cdns3_ep_config()
2169 dev_err(priv_dev->dev, "onchip mem is full, ep is invalid\n"); in cdns3_ep_config()
2177 if (priv_ep->use_streams && priv_dev->gadget.speed >= USB_SPEED_SUPER) { in cdns3_ep_config()
2178 if (priv_dev->dev_ver >= DEV_VER_V3) { in cdns3_ep_config()
2185 cdns3_clear_register_bit(&priv_dev->regs->tdl_from_trb, in cdns3_ep_config()
2198 cdns3_select_ep(priv_dev, bEndpointAddress); in cdns3_ep_config()
2199 writel(ep_cfg, &priv_dev->regs->ep_cfg); in cdns3_ep_config()
2202 dev_dbg(priv_dev->dev, "Configure %s: with val %08x\n", in cdns3_ep_config()
2217 cdns3_endpoint *cdns3_find_available_ep(struct cdns3_device *priv_dev, in cdns3_find_available_ep() argument
2223 list_for_each_entry(ep, &priv_dev->gadget.ep_list, ep_list) { in cdns3_find_available_ep()
2266 struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); in cdns3_gadget_match_ep() local
2270 priv_ep = cdns3_find_available_ep(priv_dev, desc); in cdns3_gadget_match_ep()
2272 dev_err(priv_dev->dev, "no available ep\n"); in cdns3_gadget_match_ep()
2276 dev_dbg(priv_dev->dev, "match endpoint: %s\n", priv_ep->name); in cdns3_gadget_match_ep()
2278 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_gadget_match_ep()
2292 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_gadget_match_ep()
2347 struct cdns3_device *priv_dev; in cdns3_gadget_ep_enable() local
2362 priv_dev = priv_ep->cdns3_dev; in cdns3_gadget_ep_enable()
2366 dev_dbg(priv_dev->dev, "usbss: invalid parameters\n"); in cdns3_gadget_ep_enable()
2371 dev_err(priv_dev->dev, "usbss: missing wMaxPacketSize\n"); in cdns3_gadget_ep_enable()
2375 if (dev_WARN_ONCE(priv_dev->dev, priv_ep->flags & EP_ENABLED, in cdns3_gadget_ep_enable()
2379 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_gadget_ep_enable()
2387 dev_err(priv_dev->dev, "Driver is limited to %d period\n", in cdns3_gadget_ep_enable()
2395 cdns3_select_ep(priv_dev, bEndpointAddress); in cdns3_gadget_ep_enable()
2413 if (priv_dev->gadget.speed >= USB_SPEED_SUPER) { in cdns3_gadget_ep_enable()
2419 priv_dev->using_streams |= true; in cdns3_gadget_ep_enable()
2433 cdns3_select_ep(priv_dev, bEndpointAddress); in cdns3_gadget_ep_enable()
2437 writel(EP_CMD_EPRST, &priv_dev->regs->ep_cmd); in cdns3_gadget_ep_enable()
2439 ret = readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val, in cdns3_gadget_ep_enable()
2450 cdns3_set_register_bit(&priv_dev->regs->ep_ien, in cdns3_gadget_ep_enable()
2453 if (priv_dev->dev_ver < DEV_VER_V2) in cdns3_gadget_ep_enable()
2454 cdns3_wa2_enable_detection(priv_dev, priv_ep, reg); in cdns3_gadget_ep_enable()
2456 writel(reg, &priv_dev->regs->ep_sts_en); in cdns3_gadget_ep_enable()
2465 reg = readl(&priv_dev->regs->ep_sts); in cdns3_gadget_ep_enable()
2471 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_gadget_ep_enable()
2486 struct cdns3_device *priv_dev; in cdns3_gadget_ep_disable() local
2499 priv_dev = priv_ep->cdns3_dev; in cdns3_gadget_ep_disable()
2501 if (dev_WARN_ONCE(priv_dev->dev, !(priv_ep->flags & EP_ENABLED), in cdns3_gadget_ep_disable()
2505 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_gadget_ep_disable()
2509 cdns3_select_ep(priv_dev, ep->desc->bEndpointAddress); in cdns3_gadget_ep_disable()
2511 ep_cfg = readl(&priv_dev->regs->ep_cfg); in cdns3_gadget_ep_disable()
2513 writel(ep_cfg, &priv_dev->regs->ep_cfg); in cdns3_gadget_ep_disable()
2520 readl_poll_timeout_atomic(&priv_dev->regs->ep_sts, val, in cdns3_gadget_ep_disable()
2522 writel(EP_CMD_EPRST, &priv_dev->regs->ep_cmd); in cdns3_gadget_ep_disable()
2524 readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val, in cdns3_gadget_ep_disable()
2528 dev_err(priv_dev->dev, "Timeout: %s resetting failed.\n", in cdns3_gadget_ep_disable()
2561 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_gadget_ep_disable()
2579 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in __cdns3_gadget_ep_queue() local
2588 if (priv_dev->dev_ver < DEV_VER_V2) { in __cdns3_gadget_ep_queue()
2589 ret = cdns3_wa2_gadget_ep_queue(priv_dev, priv_ep, in __cdns3_gadget_ep_queue()
2600 ret = usb_gadget_map_request_by_dev(priv_dev->sysdev, request, in __cdns3_gadget_ep_queue()
2615 if (priv_dev->hw_configured_flag && in __cdns3_gadget_ep_queue()
2618 cdns3_start_all_request(priv_dev, priv_ep); in __cdns3_gadget_ep_queue()
2620 if (priv_dev->hw_configured_flag && priv_ep->prime_flag) in __cdns3_gadget_ep_queue()
2621 cdns3_start_all_request(priv_dev, priv_ep); in __cdns3_gadget_ep_queue()
2632 struct cdns3_device *priv_dev; in cdns3_gadget_ep_queue() local
2640 priv_dev = priv_ep->cdns3_dev; in cdns3_gadget_ep_queue()
2642 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_gadget_ep_queue()
2651 zlp_request->buf = priv_dev->zlp_buf; in cdns3_gadget_ep_queue()
2657 dev_dbg(priv_dev->dev, "Queuing ZLP for endpoint: %s\n", in cdns3_gadget_ep_queue()
2662 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_gadget_ep_queue()
2677 struct cdns3_device *priv_dev; in cdns3_gadget_ep_dequeue() local
2689 priv_dev = priv_ep->cdns3_dev; in cdns3_gadget_ep_dequeue()
2691 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_gadget_ep_dequeue()
2697 cdns3_select_ep(priv_dev, ep->desc->bEndpointAddress); in cdns3_gadget_ep_dequeue()
2721 writel(EP_CMD_DFLUSH, &priv_dev->regs->ep_cmd); in cdns3_gadget_ep_dequeue()
2724 readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val, in cdns3_gadget_ep_dequeue()
2743 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_gadget_ep_dequeue()
2754 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in __cdns3_gadget_ep_set_halt() local
2759 u32 ep_sts_reg = readl(&priv_dev->regs->ep_sts); in __cdns3_gadget_ep_set_halt()
2775 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in __cdns3_gadget_ep_clear_halt() local
2795 writel(EP_CMD_CSTALL | EP_CMD_EPRST, &priv_dev->regs->ep_cmd); in __cdns3_gadget_ep_clear_halt()
2798 ret = readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val, in __cdns3_gadget_ep_clear_halt()
2812 cdns3_start_all_request(priv_dev, priv_ep); in __cdns3_gadget_ep_clear_halt()
2826 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; in cdns3_gadget_ep_set_halt() local
2833 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_gadget_ep_set_halt()
2835 cdns3_select_ep(priv_dev, ep->desc->bEndpointAddress); in cdns3_gadget_ep_set_halt()
2844 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_gadget_ep_set_halt()
2870 struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); in cdns3_gadget_get_frame() local
2872 return readl(&priv_dev->regs->usb_itpn); in cdns3_gadget_get_frame()
2875 int __cdns3_gadget_wakeup(struct cdns3_device *priv_dev) in __cdns3_gadget_wakeup() argument
2879 speed = cdns3_get_speed(priv_dev); in __cdns3_gadget_wakeup()
2885 writel(USB_CONF_LGO_L0, &priv_dev->regs->usb_conf); in __cdns3_gadget_wakeup()
2892 struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); in cdns3_gadget_wakeup() local
2896 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_gadget_wakeup()
2897 ret = __cdns3_gadget_wakeup(priv_dev); in cdns3_gadget_wakeup()
2898 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_gadget_wakeup()
2905 struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); in cdns3_gadget_set_selfpowered() local
2908 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_gadget_set_selfpowered()
2909 priv_dev->is_selfpowered = !!is_selfpowered; in cdns3_gadget_set_selfpowered()
2910 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_gadget_set_selfpowered()
2916 struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); in cdns3_gadget_pullup() local
2919 writel(USB_CONF_DEVEN, &priv_dev->regs->usb_conf); in cdns3_gadget_pullup()
2921 writel(~0, &priv_dev->regs->ep_ists); in cdns3_gadget_pullup()
2922 writel(~0, &priv_dev->regs->usb_ists); in cdns3_gadget_pullup()
2923 writel(USB_CONF_DEVDS, &priv_dev->regs->usb_conf); in cdns3_gadget_pullup()
2929 static void cdns3_gadget_config(struct cdns3_device *priv_dev) in cdns3_gadget_config() argument
2931 struct cdns3_usb_regs __iomem *regs = priv_dev->regs; in cdns3_gadget_config()
2934 cdns3_ep0_config(priv_dev); in cdns3_gadget_config()
2943 if (priv_dev->dev_ver == DEV_VER_TI_V1) { in cdns3_gadget_config()
2966 writel(PUSB_PWR_FST_REG_ACCESS, &priv_dev->regs->usb_pwr); in cdns3_gadget_config()
2968 cdns3_configure_dmult(priv_dev, NULL); in cdns3_gadget_config()
2981 struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); in cdns3_gadget_udc_start() local
2985 spin_lock_irqsave(&priv_dev->lock, flags); in cdns3_gadget_udc_start()
2986 priv_dev->gadget_driver = driver; in cdns3_gadget_udc_start()
2993 writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf); in cdns3_gadget_udc_start()
2994 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); in cdns3_gadget_udc_start()
2997 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); in cdns3_gadget_udc_start()
3002 dev_err(priv_dev->dev, in cdns3_gadget_udc_start()
3012 cdns3_gadget_config(priv_dev); in cdns3_gadget_udc_start()
3013 spin_unlock_irqrestore(&priv_dev->lock, flags); in cdns3_gadget_udc_start()
3025 struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); in cdns3_gadget_udc_stop() local
3031 priv_dev->gadget_driver = NULL; in cdns3_gadget_udc_stop()
3033 priv_dev->onchip_used_size = 0; in cdns3_gadget_udc_stop()
3034 priv_dev->out_mem_is_allocated = 0; in cdns3_gadget_udc_stop()
3035 priv_dev->gadget.speed = USB_SPEED_UNKNOWN; in cdns3_gadget_udc_stop()
3037 list_for_each_entry(ep, &priv_dev->gadget.ep_list, ep_list) { in cdns3_gadget_udc_stop()
3040 cdns3_select_ep(priv_dev, bEndpointAddress); in cdns3_gadget_udc_stop()
3041 writel(EP_CMD_EPRST, &priv_dev->regs->ep_cmd); in cdns3_gadget_udc_stop()
3042 readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val, in cdns3_gadget_udc_stop()
3049 writel(0, &priv_dev->regs->usb_ien); in cdns3_gadget_udc_stop()
3050 writel(0, &priv_dev->regs->usb_pwr); in cdns3_gadget_udc_stop()
3051 writel(USB_CONF_DEVDS, &priv_dev->regs->usb_conf); in cdns3_gadget_udc_stop()
3068 struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); in cdns3_gadget_check_config() local
3102 if (total > priv_dev->onchip_buffers) in cdns3_gadget_check_config()
3105 priv_dev->ep_buf_size = (priv_dev->onchip_buffers - 2 - iso) / (n_in + out); in cdns3_gadget_check_config()
3121 static void cdns3_free_all_eps(struct cdns3_device *priv_dev) in cdns3_free_all_eps() argument
3126 priv_dev->eps[16] = NULL; in cdns3_free_all_eps()
3129 if (priv_dev->eps[i]) { in cdns3_free_all_eps()
3130 cdns3_free_trb_pool(priv_dev->eps[i]); in cdns3_free_all_eps()
3131 devm_kfree(priv_dev->dev, priv_dev->eps[i]); in cdns3_free_all_eps()
3141 static int cdns3_init_eps(struct cdns3_device *priv_dev) in cdns3_init_eps() argument
3151 ep_enabled_reg = readl(&priv_dev->regs->usb_cap3); in cdns3_init_eps()
3152 iso_ep_reg = readl(&priv_dev->regs->usb_cap4); in cdns3_init_eps()
3154 dev_dbg(priv_dev->dev, "Initializing non-zero endpoints\n"); in cdns3_init_eps()
3165 priv_dev->eps[i] = priv_dev->eps[0]; in cdns3_init_eps()
3169 priv_ep = devm_kzalloc(priv_dev->dev, sizeof(*priv_ep), in cdns3_init_eps()
3175 priv_ep->cdns3_dev = priv_dev; in cdns3_init_eps()
3176 priv_dev->eps[i] = priv_ep; in cdns3_init_eps()
3181 ret = cdns3_init_ep0(priv_dev, priv_ep); in cdns3_init_eps()
3183 dev_err(priv_dev->dev, "Failed to init ep0\n"); in cdns3_init_eps()
3207 &priv_dev->gadget.ep_list); in cdns3_init_eps()
3212 dev_dbg(priv_dev->dev, "Initialized %s support: %s %s\n", in cdns3_init_eps()
3224 cdns3_free_all_eps(priv_dev); in cdns3_init_eps()
3230 struct cdns3_device *priv_dev = container_of(dev, in cdns3_gadget_release() local
3233 kfree(priv_dev); in cdns3_gadget_release()
3238 struct cdns3_device *priv_dev; in cdns3_gadget_exit() local
3240 priv_dev = cdns->gadget_dev; in cdns3_gadget_exit()
3246 usb_del_gadget(&priv_dev->gadget); in cdns3_gadget_exit()
3247 devm_free_irq(cdns->dev, cdns->dev_irq, priv_dev); in cdns3_gadget_exit()
3249 cdns3_free_all_eps(priv_dev); in cdns3_gadget_exit()
3251 while (!list_empty(&priv_dev->aligned_buf_list)) { in cdns3_gadget_exit()
3254 buf = cdns3_next_align_buf(&priv_dev->aligned_buf_list); in cdns3_gadget_exit()
3255 dma_free_noncoherent(priv_dev->sysdev, buf->size, in cdns3_gadget_exit()
3264 dma_free_coherent(priv_dev->sysdev, 8, priv_dev->setup_buf, in cdns3_gadget_exit()
3265 priv_dev->setup_dma); in cdns3_gadget_exit()
3266 dma_pool_destroy(priv_dev->eps_dma_pool); in cdns3_gadget_exit()
3268 kfree(priv_dev->zlp_buf); in cdns3_gadget_exit()
3269 usb_put_gadget(&priv_dev->gadget); in cdns3_gadget_exit()
3276 struct cdns3_device *priv_dev; in cdns3_gadget_start() local
3280 priv_dev = kzalloc(sizeof(*priv_dev), GFP_KERNEL); in cdns3_gadget_start()
3281 if (!priv_dev) in cdns3_gadget_start()
3284 usb_initialize_gadget(cdns->dev, &priv_dev->gadget, in cdns3_gadget_start()
3286 cdns->gadget_dev = priv_dev; in cdns3_gadget_start()
3287 priv_dev->sysdev = cdns->dev; in cdns3_gadget_start()
3288 priv_dev->dev = cdns->dev; in cdns3_gadget_start()
3289 priv_dev->regs = cdns->dev_regs; in cdns3_gadget_start()
3291 device_property_read_u16(priv_dev->dev, "cdns,on-chip-buff-size", in cdns3_gadget_start()
3292 &priv_dev->onchip_buffers); in cdns3_gadget_start()
3294 if (priv_dev->onchip_buffers <= 0) { in cdns3_gadget_start()
3295 u32 reg = readl(&priv_dev->regs->usb_cap2); in cdns3_gadget_start()
3297 priv_dev->onchip_buffers = USB_CAP2_ACTUAL_MEM_SIZE(reg); in cdns3_gadget_start()
3300 if (!priv_dev->onchip_buffers) in cdns3_gadget_start()
3301 priv_dev->onchip_buffers = 256; in cdns3_gadget_start()
3322 priv_dev->gadget.max_speed = max_speed; in cdns3_gadget_start()
3323 priv_dev->gadget.speed = USB_SPEED_UNKNOWN; in cdns3_gadget_start()
3324 priv_dev->gadget.ops = &cdns3_gadget_ops; in cdns3_gadget_start()
3325 priv_dev->gadget.name = "usb-ss-gadget"; in cdns3_gadget_start()
3326 priv_dev->gadget.quirk_avoids_skb_reserve = 1; in cdns3_gadget_start()
3327 priv_dev->gadget.irq = cdns->dev_irq; in cdns3_gadget_start()
3329 spin_lock_init(&priv_dev->lock); in cdns3_gadget_start()
3330 INIT_WORK(&priv_dev->pending_status_wq, in cdns3_gadget_start()
3333 INIT_WORK(&priv_dev->aligned_buf_wq, in cdns3_gadget_start()
3337 INIT_LIST_HEAD(&priv_dev->gadget.ep_list); in cdns3_gadget_start()
3338 INIT_LIST_HEAD(&priv_dev->aligned_buf_list); in cdns3_gadget_start()
3339 priv_dev->eps_dma_pool = dma_pool_create("cdns3_eps_dma_pool", in cdns3_gadget_start()
3340 priv_dev->sysdev, in cdns3_gadget_start()
3342 if (!priv_dev->eps_dma_pool) { in cdns3_gadget_start()
3343 dev_err(priv_dev->dev, "Failed to create TRB dma pool\n"); in cdns3_gadget_start()
3348 ret = cdns3_init_eps(priv_dev); in cdns3_gadget_start()
3350 dev_err(priv_dev->dev, "Failed to create endpoints\n"); in cdns3_gadget_start()
3355 priv_dev->setup_buf = dma_alloc_coherent(priv_dev->sysdev, 8, in cdns3_gadget_start()
3356 &priv_dev->setup_dma, GFP_DMA); in cdns3_gadget_start()
3357 if (!priv_dev->setup_buf) { in cdns3_gadget_start()
3362 priv_dev->dev_ver = readl(&priv_dev->regs->usb_cap6); in cdns3_gadget_start()
3364 dev_dbg(priv_dev->dev, "Device Controller version: %08x\n", in cdns3_gadget_start()
3365 readl(&priv_dev->regs->usb_cap6)); in cdns3_gadget_start()
3366 dev_dbg(priv_dev->dev, "USB Capabilities:: %08x\n", in cdns3_gadget_start()
3367 readl(&priv_dev->regs->usb_cap1)); in cdns3_gadget_start()
3368 dev_dbg(priv_dev->dev, "On-Chip memory configuration: %08x\n", in cdns3_gadget_start()
3369 readl(&priv_dev->regs->usb_cap2)); in cdns3_gadget_start()
3371 priv_dev->dev_ver = GET_DEV_BASE_VERSION(priv_dev->dev_ver); in cdns3_gadget_start()
3372 if (priv_dev->dev_ver >= DEV_VER_V2) in cdns3_gadget_start()
3373 priv_dev->gadget.sg_supported = 1; in cdns3_gadget_start()
3375 priv_dev->zlp_buf = kzalloc(CDNS3_EP_ZLP_BUF_SIZE, GFP_KERNEL); in cdns3_gadget_start()
3376 if (!priv_dev->zlp_buf) { in cdns3_gadget_start()
3382 ret = usb_add_gadget(&priv_dev->gadget); in cdns3_gadget_start()
3384 dev_err(priv_dev->dev, "Failed to add gadget\n"); in cdns3_gadget_start()
3390 kfree(priv_dev->zlp_buf); in cdns3_gadget_start()
3392 dma_free_coherent(priv_dev->sysdev, 8, priv_dev->setup_buf, in cdns3_gadget_start()
3393 priv_dev->setup_dma); in cdns3_gadget_start()
3395 cdns3_free_all_eps(priv_dev); in cdns3_gadget_start()
3397 dma_pool_destroy(priv_dev->eps_dma_pool); in cdns3_gadget_start()
3399 usb_put_gadget(&priv_dev->gadget); in cdns3_gadget_start()
3446 struct cdns3_device *priv_dev = cdns->gadget_dev; in cdns3_gadget_suspend() local
3449 cdns3_disconnect_gadget(priv_dev); in cdns3_gadget_suspend()
3452 priv_dev->gadget.speed = USB_SPEED_UNKNOWN; in cdns3_gadget_suspend()
3453 usb_gadget_set_state(&priv_dev->gadget, USB_STATE_NOTATTACHED); in cdns3_gadget_suspend()
3454 cdns3_hw_reset_eps_config(priv_dev); in cdns3_gadget_suspend()
3457 writel(0, &priv_dev->regs->usb_ien); in cdns3_gadget_suspend()
3464 struct cdns3_device *priv_dev = cdns->gadget_dev; in cdns3_gadget_resume() local
3466 if (!priv_dev->gadget_driver) in cdns3_gadget_resume()
3469 cdns3_gadget_config(priv_dev); in cdns3_gadget_resume()
3471 writel(USB_CONF_DEVEN, &priv_dev->regs->usb_conf); in cdns3_gadget_resume()