Lines Matching +full:iso +full:- +full:out +full:- +full:mps
5 * SPDX-License-Identifier: Apache-2.0
25 #include <zephyr/dt-bindings/regulator/nrf5x.h>
192 /** Number of OUT Endpoints configured (including control) */
196 /** Number of ISO IN Endpoints */
199 /** Number of ISO OUT Endpoints */
202 /** ISO endpoint index */
212 * Max buffers size possible: 1536 Bytes (8 EP * 64B + 1 ISO * 1024B)
234 * @param drv_lock Mutex for thread-safe nrfx driver use
261 * device stack, for executing the endpoints callbacks, etc.) out of the ISR
285 return get_usbd_ctx()->attached; in dev_attached()
290 return get_usbd_ctx()->ready; in dev_ready()
346 return &ctx->ep_ctx[EP_ISOIN_INDEX]; in endpoint_ctx()
348 return &ctx->ep_ctx[ep_num]; in endpoint_ctx()
352 return &ctx->ep_ctx[EP_ISOOUT_INDEX]; in endpoint_ctx()
354 return &ctx->ep_ctx[CFG_EPIN_CNT + in endpoint_ctx()
380 k_work_submit_to_queue(&usbd_work_queue, &get_usbd_ctx()->usb_work); in usbd_work_schedule()
392 k_mem_slab_free(&fifo_elem_slab, (void *)ev->block.data); in usbd_evt_free()
459 ev->block = block; in usbd_evt_alloc()
460 ev->evt_type = USBD_EVT_REINIT; in usbd_evt_alloc()
468 ev->block = block; in usbd_evt_alloc()
481 ev->evt_type = USBD_EVT_POWER; in submit_dc_power_event()
482 ev->evt.pwr_evt.state = state; in submit_dc_power_event()
536 if (atomic_cas(&ctx->clk_requested, 1, 0)) { in hfxo_stop()
537 return onoff_cancel_or_release(ctx->hfxo_mgr, &ctx->hfxo_cli); in hfxo_stop()
545 if (atomic_cas(&ctx->clk_requested, 0, 1)) { in hfxo_start()
546 sys_notify_init_spinwait(&ctx->hfxo_cli.notify); in hfxo_start()
548 return onoff_request(ctx->hfxo_mgr, &ctx->hfxo_cli); in hfxo_start()
563 if (ep_ctx->cfg.en) { in usbd_enable_endpoints()
564 nrf_usbd_common_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr)); in usbd_enable_endpoints()
572 if (ep_ctx->cfg.en) { in usbd_enable_endpoints()
573 nrf_usbd_common_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr)); in usbd_enable_endpoints()
581 if (ep_ctx->cfg.en) { in usbd_enable_endpoints()
582 nrf_usbd_common_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr)); in usbd_enable_endpoints()
590 if (ep_ctx->cfg.en) { in usbd_enable_endpoints()
591 nrf_usbd_common_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr)); in usbd_enable_endpoints()
605 ep_ctx->buf.data = ep_ctx->buf.block.data; in ep_ctx_reset()
606 ep_ctx->buf.curr = ep_ctx->buf.data; in ep_ctx_reset()
607 ep_ctx->buf.len = 0U; in ep_ctx_reset()
610 if (ep_ctx->write_in_progress) { in ep_ctx_reset()
611 nrf_usbd_common_ep_abort(ep_addr_to_nrfx(ep_ctx->cfg.addr)); in ep_ctx_reset()
614 ep_ctx->read_complete = true; in ep_ctx_reset()
615 ep_ctx->read_pending = false; in ep_ctx_reset()
616 ep_ctx->write_in_progress = false; in ep_ctx_reset()
617 ep_ctx->trans_zlp = false; in ep_ctx_reset()
642 if (!ep_ctx->buf.block.data) { in eps_ctx_init()
643 ep_ctx->buf.block.data = ep_out_bufs[i]; in eps_ctx_init()
661 if (!ep_ctx->buf.block.data) { in eps_ctx_init()
662 ep_ctx->buf.block.data = ep_isoout_bufs[0]; in eps_ctx_init()
676 switch (pwr_evt->state) { in usbd_work_process_pwr_events()
693 ctx->ready = true; in usbd_work_process_pwr_events()
697 if (ctx->status_cb) { in usbd_work_process_pwr_events()
698 ctx->status_cb(USB_DC_CONNECTED, NULL); in usbd_work_process_pwr_events()
703 ctx->ready = false; in usbd_work_process_pwr_events()
710 if (ctx->status_cb) { in usbd_work_process_pwr_events()
711 ctx->status_cb(USB_DC_DISCONNECTED, NULL); in usbd_work_process_pwr_events()
720 if (ctx->status_cb) { in usbd_work_process_pwr_events()
721 ctx->status_cb(USB_DC_SUSPEND, NULL); in usbd_work_process_pwr_events()
726 if (ctx->status_cb && dev_ready()) { in usbd_work_process_pwr_events()
728 ctx->status_cb(USB_DC_RESUME, NULL); in usbd_work_process_pwr_events()
740 __ASSERT(ep_ctx->cfg.type == USB_DC_EP_CONTROL, in usbd_work_process_setup()
749 usbd_setup = (struct usb_setup_packet *)ep_ctx->buf.data; in usbd_work_process_setup()
751 usbd_setup->bmRequestType = nrf_usbd_setup_bmrequesttype_get(NRF_USBD); in usbd_work_process_setup()
752 usbd_setup->bRequest = nrf_usbd_setup_brequest_get(NRF_USBD); in usbd_work_process_setup()
753 usbd_setup->wValue = nrf_usbd_setup_wvalue_get(NRF_USBD); in usbd_work_process_setup()
754 usbd_setup->wIndex = nrf_usbd_setup_windex_get(NRF_USBD); in usbd_work_process_setup()
755 usbd_setup->wLength = nrf_usbd_setup_wlength_get(NRF_USBD); in usbd_work_process_setup()
756 ep_ctx->buf.len = sizeof(struct usb_setup_packet); in usbd_work_process_setup()
762 (uint32_t)usbd_setup->bRequest, in usbd_work_process_setup()
763 (uint32_t)usbd_setup->bmRequestType, in usbd_work_process_setup()
764 (uint32_t)usbd_setup->wValue, in usbd_work_process_setup()
765 (uint32_t)usbd_setup->wIndex, in usbd_work_process_setup()
766 (uint32_t)usbd_setup->wLength); in usbd_work_process_setup()
769 ep_ctx->cfg.cb(ep_ctx->cfg.addr, USB_DC_EP_SETUP); in usbd_work_process_setup()
773 if (usb_reqtype_is_to_device(usbd_setup) && usbd_setup->wLength) { in usbd_work_process_setup()
774 ctx->ctrl_read_len = usbd_setup->wLength; in usbd_work_process_setup()
775 /* Allow data chunk on EP0 OUT */ in usbd_work_process_setup()
778 ctx->ctrl_read_len = 0U; in usbd_work_process_setup()
785 if (!ep_ctx->read_pending) { in usbd_work_process_recvreq()
788 if (!ep_ctx->read_complete) { in usbd_work_process_recvreq()
792 ep_ctx->read_pending = false; in usbd_work_process_recvreq()
793 ep_ctx->read_complete = false; in usbd_work_process_recvreq()
795 k_mutex_lock(&ctx->drv_lock, K_FOREVER); in usbd_work_process_recvreq()
796 NRF_USBD_COMMON_TRANSFER_OUT(transfer, ep_ctx->buf.data, in usbd_work_process_recvreq()
797 ep_ctx->cfg.max_sz); in usbd_work_process_recvreq()
799 ep_addr_to_nrfx(ep_ctx->cfg.addr), &transfer); in usbd_work_process_recvreq()
801 LOG_ERR("nRF USBD transfer error (OUT): 0x%02x", err); in usbd_work_process_recvreq()
803 k_mutex_unlock(&ctx->drv_lock); in usbd_work_process_recvreq()
810 struct nrf_usbd_ep_ctx *ep_ctx = ep_evt->ep; in usbd_work_process_ep_events()
814 switch (ep_evt->evt_type) { in usbd_work_process_ep_events()
824 ep_ctx->cfg.cb(ep_ctx->cfg.addr, in usbd_work_process_ep_events()
829 if (ep_ctx->cfg.type == USB_DC_EP_CONTROL && in usbd_work_process_ep_events()
830 !ep_ctx->trans_zlp) { in usbd_work_process_ep_events()
835 k_mutex_lock(&ctx->drv_lock, K_FOREVER); in usbd_work_process_ep_events()
837 k_mutex_unlock(&ctx->drv_lock); in usbd_work_process_ep_events()
839 ep_ctx->cfg.cb(ep_ctx->cfg.addr, in usbd_work_process_ep_events()
850 endpoint_ctx(p_event->data.eptransfer.ep); in usbd_event_transfer_ctrl()
852 if (NRF_USBD_EPIN_CHECK(p_event->data.eptransfer.ep)) { in usbd_event_transfer_ctrl()
853 switch (p_event->data.eptransfer.status) { in usbd_event_transfer_ctrl()
861 ep_ctx->write_in_progress = false; in usbd_event_transfer_ctrl()
862 ev->evt_type = USBD_EVT_EP; in usbd_event_transfer_ctrl()
863 ev->evt.ep_evt.evt_type = EP_EVT_WRITE_COMPLETE; in usbd_event_transfer_ctrl()
864 ev->evt.ep_evt.ep = ep_ctx; in usbd_event_transfer_ctrl()
874 p_event->data.eptransfer.ep); in usbd_event_transfer_ctrl()
880 p_event->data.eptransfer.status, in usbd_event_transfer_ctrl()
881 p_event->data.eptransfer.ep); in usbd_event_transfer_ctrl()
886 switch (p_event->data.eptransfer.status) { in usbd_event_transfer_ctrl()
896 ep_ctx->read_pending = true; in usbd_event_transfer_ctrl()
897 ev->evt_type = USBD_EVT_EP; in usbd_event_transfer_ctrl()
898 ev->evt.ep_evt.evt_type = EP_EVT_RECV_REQ; in usbd_event_transfer_ctrl()
899 ev->evt.ep_evt.ep = ep_ctx; in usbd_event_transfer_ctrl()
915 ev->evt_type = USBD_EVT_EP; in usbd_event_transfer_ctrl()
916 ev->evt.ep_evt.evt_type = EP_EVT_RECV_COMPLETE; in usbd_event_transfer_ctrl()
917 ev->evt.ep_evt.ep = ep_ctx; in usbd_event_transfer_ctrl()
920 p_event->data.eptransfer.ep, &ep_ctx->buf.len); in usbd_event_transfer_ctrl()
927 LOG_DBG("ctrl read done: %d", ep_ctx->buf.len); in usbd_event_transfer_ctrl()
929 if (ctx->ctrl_read_len > ep_ctx->buf.len) { in usbd_event_transfer_ctrl()
930 ctx->ctrl_read_len -= ep_ctx->buf.len; in usbd_event_transfer_ctrl()
931 /* Allow next data chunk on EP0 OUT */ in usbd_event_transfer_ctrl()
934 ctx->ctrl_read_len = 0U; in usbd_event_transfer_ctrl()
944 p_event->data.eptransfer.status, in usbd_event_transfer_ctrl()
945 p_event->data.eptransfer.ep); in usbd_event_transfer_ctrl()
955 endpoint_ctx(p_event->data.eptransfer.ep); in usbd_event_transfer_data()
957 if (NRF_USBD_EPIN_CHECK(p_event->data.eptransfer.ep)) { in usbd_event_transfer_data()
958 switch (p_event->data.eptransfer.status) { in usbd_event_transfer_data()
967 (uint32_t)p_event->data.eptransfer.ep); in usbd_event_transfer_data()
969 ep_ctx->write_in_progress = false; in usbd_event_transfer_data()
970 ev->evt_type = USBD_EVT_EP; in usbd_event_transfer_data()
971 ev->evt.ep_evt.evt_type = EP_EVT_WRITE_COMPLETE; in usbd_event_transfer_data()
972 ev->evt.ep_evt.ep = ep_ctx; in usbd_event_transfer_data()
980 p_event->data.eptransfer.ep); in usbd_event_transfer_data()
986 p_event->data.eptransfer.status, in usbd_event_transfer_data()
987 p_event->data.eptransfer.ep); in usbd_event_transfer_data()
993 switch (p_event->data.eptransfer.status) { in usbd_event_transfer_data()
1002 (uint32_t)p_event->data.eptransfer.ep); in usbd_event_transfer_data()
1004 ep_ctx->read_pending = true; in usbd_event_transfer_data()
1005 ev->evt_type = USBD_EVT_EP; in usbd_event_transfer_data()
1006 ev->evt.ep_evt.evt_type = EP_EVT_RECV_REQ; in usbd_event_transfer_data()
1007 ev->evt.ep_evt.ep = ep_ctx; in usbd_event_transfer_data()
1021 ep_ctx->buf.len = nrf_usbd_ep_amount_get(NRF_USBD, in usbd_event_transfer_data()
1022 p_event->data.eptransfer.ep); in usbd_event_transfer_data()
1025 (uint32_t)p_event->data.eptransfer.ep, in usbd_event_transfer_data()
1026 ep_ctx->buf.len); in usbd_event_transfer_data()
1028 ev->evt_type = USBD_EVT_EP; in usbd_event_transfer_data()
1029 ev->evt.ep_evt.evt_type = EP_EVT_RECV_COMPLETE; in usbd_event_transfer_data()
1030 ev->evt.ep_evt.ep = ep_ctx; in usbd_event_transfer_data()
1039 p_event->data.eptransfer.status, in usbd_event_transfer_data()
1040 p_event->data.eptransfer.ep); in usbd_event_transfer_data()
1055 switch (p_event->type) { in usbd_event_handler()
1088 ep_ctx = endpoint_ctx(p_event->data.eptransfer.ep); in usbd_event_handler()
1089 switch (ep_ctx->cfg.type) { in usbd_event_handler()
1139 ev->evt_type = evt.evt_type; in usbd_event_handler()
1140 ev->evt = evt.evt; in usbd_event_handler()
1171 * ISO OUT EP.
1173 * ISO OUT endpoint does not generate irq by itself and reading
1174 * from ISO OUT ep is synchronized with SOF frame. For more details
1184 LOG_ERR("There is no ISO ep"); in usbd_sof_trigger_iso_read()
1188 if (ep_ctx->cfg.en) { in usbd_sof_trigger_iso_read()
1190 * if the iso OUT ep is enabled in usbd_sof_trigger_iso_read()
1192 ep_ctx->read_pending = true; in usbd_sof_trigger_iso_read()
1193 ep_ctx->read_complete = true; in usbd_sof_trigger_iso_read()
1199 ev->evt_type = USBD_EVT_EP; in usbd_sof_trigger_iso_read()
1200 ev->evt.ep_evt.evt_type = EP_EVT_RECV_REQ; in usbd_sof_trigger_iso_read()
1201 ev->evt.ep_evt.ep = ep_ctx; in usbd_sof_trigger_iso_read()
1218 if (!dev_ready() && ev->evt_type != USBD_EVT_POWER) { in usbd_work_handler()
1219 /* Drop non-power events when cable is detached. */ in usbd_work_handler()
1224 switch (ev->evt_type) { in usbd_work_handler()
1226 if (!ctx->attached) { in usbd_work_handler()
1228 (uint32_t)ev->evt.ep_evt.ep->cfg.addr); in usbd_work_handler()
1230 usbd_work_process_ep_events(&ev->evt.ep_evt); in usbd_work_handler()
1233 usbd_work_process_pwr_events(&ev->evt.pwr_evt); in usbd_work_handler()
1237 k_mutex_lock(&ctx->drv_lock, K_FOREVER); in usbd_work_handler()
1239 k_mutex_unlock(&ctx->drv_lock); in usbd_work_handler()
1241 if (ctx->status_cb) { in usbd_work_handler()
1242 ctx->status_cb(USB_DC_RESET, NULL); in usbd_work_handler()
1248 if (ctx->status_cb) { in usbd_work_handler()
1249 ctx->status_cb(USB_DC_SOF, NULL); in usbd_work_handler()
1262 LOG_ERR("Unknown USBD event: %"PRId16, ev->evt_type); in usbd_work_handler()
1274 if (ctx->attached) { in usb_dc_attach()
1278 k_mutex_init(&ctx->drv_lock); in usb_dc_attach()
1279 ctx->hfxo_mgr = in usb_dc_attach()
1292 ctx->attached = true; in usb_dc_attach()
1302 * the peripheral is re-enabled. in usb_dc_attach()
1303 * When USB-enabled bootloader is used, target application in usb_dc_attach()
1317 k_mutex_lock(&ctx->drv_lock, K_FOREVER); in usb_dc_detach()
1328 ctx->attached = false; in usb_dc_detach()
1329 k_mutex_unlock(&ctx->drv_lock); in usb_dc_detach()
1339 return -ENODEV; in usb_dc_reset()
1362 return -ENODEV; in usb_dc_set_address()
1369 __ASSERT(addr == (uint8_t)NRF_USBD->USBADDR, "USB Address incorrect!"); in usb_dc_set_address()
1381 uint8_t ep_idx = NRF_USBD_EP_NR_GET(ep_cfg->ep_addr); in usb_dc_ep_check_cap()
1383 LOG_DBG("ep 0x%02x, mps %d, type %d", ep_cfg->ep_addr, ep_cfg->ep_mps, in usb_dc_ep_check_cap()
1384 ep_cfg->ep_type); in usb_dc_ep_check_cap()
1386 if ((ep_cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) { in usb_dc_ep_check_cap()
1388 return -1; in usb_dc_ep_check_cap()
1391 if (!NRF_USBD_EP_VALIDATE(ep_cfg->ep_addr)) { in usb_dc_ep_check_cap()
1393 return -1; in usb_dc_ep_check_cap()
1396 if ((ep_cfg->ep_type == USB_DC_EP_ISOCHRONOUS) && in usb_dc_ep_check_cap()
1397 (!NRF_USBD_EPISO_CHECK(ep_cfg->ep_addr))) { in usb_dc_ep_check_cap()
1399 return -1; in usb_dc_ep_check_cap()
1402 if ((ep_cfg->ep_type != USB_DC_EP_ISOCHRONOUS) && in usb_dc_ep_check_cap()
1403 (NRF_USBD_EPISO_CHECK(ep_cfg->ep_addr))) { in usb_dc_ep_check_cap()
1404 LOG_WRN("iso endpoint can only be iso"); in usb_dc_ep_check_cap()
1405 return -1; in usb_dc_ep_check_cap()
1416 return -ENODEV; in usb_dc_ep_configure()
1421 * For ISO endpoints, application has to use EPIN/OUT 8 in usb_dc_ep_configure()
1429 ep_ctx = endpoint_ctx(ep_cfg->ep_addr); in usb_dc_ep_configure()
1431 return -EINVAL; in usb_dc_ep_configure()
1434 ep_ctx->cfg.addr = ep_cfg->ep_addr; in usb_dc_ep_configure()
1435 ep_ctx->cfg.type = ep_cfg->ep_type; in usb_dc_ep_configure()
1436 ep_ctx->cfg.max_sz = ep_cfg->ep_mps; in usb_dc_ep_configure()
1438 if (!NRF_USBD_EPISO_CHECK(ep_cfg->ep_addr)) { in usb_dc_ep_configure()
1439 if ((ep_cfg->ep_mps & (ep_cfg->ep_mps - 1)) != 0U) { in usb_dc_ep_configure()
1441 return -EINVAL; in usb_dc_ep_configure()
1445 nrf_usbd_common_ep_max_packet_size_set(ep_addr_to_nrfx(ep_cfg->ep_addr), in usb_dc_ep_configure()
1446 ep_cfg->ep_mps); in usb_dc_ep_configure()
1456 return -ENODEV; in usb_dc_ep_set_stall()
1461 return -EINVAL; in usb_dc_ep_set_stall()
1464 switch (ep_ctx->cfg.type) { in usb_dc_ep_set_stall()
1473 LOG_ERR("STALL unsupported on ISO endpoint"); in usb_dc_ep_set_stall()
1474 return -EINVAL; in usb_dc_ep_set_stall()
1477 ep_ctx->buf.len = 0U; in usb_dc_ep_set_stall()
1478 ep_ctx->buf.curr = ep_ctx->buf.data; in usb_dc_ep_set_stall()
1491 return -ENODEV; in usb_dc_ep_clear_stall()
1496 return -EINVAL; in usb_dc_ep_clear_stall()
1500 /* ISO transactions do not support a handshake phase. */ in usb_dc_ep_clear_stall()
1501 return -EINVAL; in usb_dc_ep_clear_stall()
1521 return -ENODEV; in usb_dc_ep_is_stalled()
1526 return -EINVAL; in usb_dc_ep_is_stalled()
1530 return -EINVAL; in usb_dc_ep_is_stalled()
1543 return -ENODEV; in usb_dc_ep_enable()
1548 return -EINVAL; in usb_dc_ep_enable()
1552 /* ISO transactions for full-speed device do not support in usb_dc_ep_enable()
1561 if (ep_ctx->cfg.en) { in usb_dc_ep_enable()
1562 return -EALREADY; in usb_dc_ep_enable()
1567 ep_ctx->cfg.en = true; in usb_dc_ep_enable()
1583 return -EINVAL; in usb_dc_ep_disable()
1586 if (!ep_ctx->cfg.en) { in usb_dc_ep_disable()
1587 return -EALREADY; in usb_dc_ep_disable()
1596 ep_ctx->write_in_progress = false; in usb_dc_ep_disable()
1598 ep_ctx->cfg.en = false; in usb_dc_ep_disable()
1608 return -ENODEV; in usb_dc_ep_flush()
1613 return -EINVAL; in usb_dc_ep_flush()
1616 ep_ctx->buf.len = 0U; in usb_dc_ep_flush()
1617 ep_ctx->buf.curr = ep_ctx->buf.data; in usb_dc_ep_flush()
1633 return -ENODEV; in usb_dc_ep_write()
1637 return -EINVAL; in usb_dc_ep_write()
1642 return -EINVAL; in usb_dc_ep_write()
1645 if (!ep_ctx->cfg.en) { in usb_dc_ep_write()
1647 return -EINVAL; in usb_dc_ep_write()
1650 k_mutex_lock(&ctx->drv_lock, K_FOREVER); in usb_dc_ep_write()
1656 if (ep_ctx->write_in_progress) { in usb_dc_ep_write()
1657 k_mutex_unlock(&ctx->drv_lock); in usb_dc_ep_write()
1658 return -EAGAIN; in usb_dc_ep_write()
1664 if (!data_len && ep_ctx->trans_zlp) { in usb_dc_ep_write()
1665 ep_ctx->trans_zlp = false; in usb_dc_ep_write()
1675 if (ep_ctx->cfg.type == USB_DC_EP_CONTROL) { in usb_dc_ep_write()
1677 !(data_len % ep_ctx->cfg.max_sz)) { in usb_dc_ep_write()
1678 ep_ctx->trans_zlp = true; in usb_dc_ep_write()
1686 if ((ep_ctx->cfg.type == USB_DC_EP_CONTROL) in usb_dc_ep_write()
1689 k_mutex_unlock(&ctx->drv_lock); in usb_dc_ep_write()
1693 ep_ctx->write_in_progress = true; in usb_dc_ep_write()
1698 ep_ctx->write_in_progress = false; in usb_dc_ep_write()
1702 result = -EIO; in usb_dc_ep_write()
1710 k_mutex_unlock(&ctx->drv_lock); in usb_dc_ep_write()
1722 return -ENODEV; in usb_dc_ep_read_wait()
1726 return -EINVAL; in usb_dc_ep_read_wait()
1730 return -EINVAL; in usb_dc_ep_read_wait()
1735 return -EINVAL; in usb_dc_ep_read_wait()
1738 if (!ep_ctx->cfg.en) { in usb_dc_ep_read_wait()
1740 return -EINVAL; in usb_dc_ep_read_wait()
1743 k_mutex_lock(&ctx->drv_lock, K_FOREVER); in usb_dc_ep_read_wait()
1745 bytes_to_copy = MIN(max_data_len, ep_ctx->buf.len); in usb_dc_ep_read_wait()
1749 *read_bytes = ep_ctx->buf.len; in usb_dc_ep_read_wait()
1751 k_mutex_unlock(&ctx->drv_lock); in usb_dc_ep_read_wait()
1755 memcpy(data, ep_ctx->buf.curr, bytes_to_copy); in usb_dc_ep_read_wait()
1757 ep_ctx->buf.curr += bytes_to_copy; in usb_dc_ep_read_wait()
1758 ep_ctx->buf.len -= bytes_to_copy; in usb_dc_ep_read_wait()
1763 k_mutex_unlock(&ctx->drv_lock); in usb_dc_ep_read_wait()
1773 return -ENODEV; in usb_dc_ep_read_continue()
1777 return -EINVAL; in usb_dc_ep_read_continue()
1782 return -EINVAL; in usb_dc_ep_read_continue()
1785 if (!ep_ctx->cfg.en) { in usb_dc_ep_read_continue()
1787 return -EINVAL; in usb_dc_ep_read_continue()
1790 k_mutex_lock(&ctx->drv_lock, K_FOREVER); in usb_dc_ep_read_continue()
1791 if (!ep_ctx->buf.len) { in usb_dc_ep_read_continue()
1792 ep_ctx->buf.curr = ep_ctx->buf.data; in usb_dc_ep_read_continue()
1793 ep_ctx->read_complete = true; in usb_dc_ep_read_continue()
1795 if (ep_ctx->read_pending) { in usb_dc_ep_read_continue()
1799 k_mutex_unlock(&ctx->drv_lock); in usb_dc_ep_read_continue()
1800 return -ENOMEM; in usb_dc_ep_read_continue()
1803 ev->evt_type = USBD_EVT_EP; in usb_dc_ep_read_continue()
1804 ev->evt.ep_evt.ep = ep_ctx; in usb_dc_ep_read_continue()
1805 ev->evt.ep_evt.evt_type = EP_EVT_RECV_REQ; in usb_dc_ep_read_continue()
1810 k_mutex_unlock(&ctx->drv_lock); in usb_dc_ep_read_continue()
1839 return -ENODEV; in usb_dc_ep_set_callback()
1844 return -EINVAL; in usb_dc_ep_set_callback()
1847 ep_ctx->cfg.cb = cb; in usb_dc_ep_set_callback()
1854 get_usbd_ctx()->status_cb = cb; in usb_dc_set_status_callback()
1862 return -ENODEV; in usb_dc_ep_mps()
1867 return -EINVAL; in usb_dc_ep_mps()
1870 return ep_ctx->cfg.max_sz; in usb_dc_ep_mps()
1878 return -EAGAIN; in usb_dc_wakeup_request()
1915 return -EIO; in usb_init()
1930 k_work_init(&ctx->usb_work, usbd_work_handler); in usb_init()