Lines Matching refs:ep_cur
227 static inline void numaker_usbd_ep_sync_udc_halt(struct numaker_usbd_ep *ep_cur, bool stalled) in numaker_usbd_ep_sync_udc_halt() argument
229 const struct device *dev = ep_cur->dev; in numaker_usbd_ep_sync_udc_halt()
232 __ASSERT_NO_MSG(ep_cur->addr_valid); in numaker_usbd_ep_sync_udc_halt()
233 ep_cfg = udc_get_ep_cfg(dev, ep_cur->addr); in numaker_usbd_ep_sync_udc_halt()
237 static inline void numaker_usbd_ep_set_stall(struct numaker_usbd_ep *ep_cur) in numaker_usbd_ep_set_stall() argument
239 const struct device *dev = ep_cur->dev; in numaker_usbd_ep_set_stall()
240 USBD_EP_T *ep_base = numaker_usbd_ep_base(dev, ep_cur->ep_hw_idx); in numaker_usbd_ep_set_stall()
244 numaker_usbd_ep_sync_udc_halt(ep_cur, true); in numaker_usbd_ep_set_stall()
248 static inline void numaker_usbd_ep_clear_stall_n_data_toggle(struct numaker_usbd_ep *ep_cur) in numaker_usbd_ep_clear_stall_n_data_toggle() argument
250 const struct device *dev = ep_cur->dev; in numaker_usbd_ep_clear_stall_n_data_toggle()
251 USBD_EP_T *ep_base = numaker_usbd_ep_base(dev, ep_cur->ep_hw_idx); in numaker_usbd_ep_clear_stall_n_data_toggle()
255 numaker_usbd_ep_sync_udc_halt(ep_cur, false); in numaker_usbd_ep_clear_stall_n_data_toggle()
440 static void numaker_usbd_ep_copy_to_user(struct numaker_usbd_ep *ep_cur, uint8_t *usrbuf, in numaker_usbd_ep_copy_to_user() argument
443 const struct device *dev = ep_cur->dev; in numaker_usbd_ep_copy_to_user()
444 USBD_EP_T *ep_base = numaker_usbd_ep_base(dev, ep_cur->ep_hw_idx); in numaker_usbd_ep_copy_to_user()
449 __ASSERT_NO_MSG(ep_cur->dmabuf_valid); in numaker_usbd_ep_copy_to_user()
454 if (ep_cur->addr == USB_CONTROL_EP_OUT) { in numaker_usbd_ep_copy_to_user()
455 data_rmn = ep_cur->mxpld_ctrlout; in numaker_usbd_ep_copy_to_user()
474 static void numaker_usbd_ep_copy_from_user(struct numaker_usbd_ep *ep_cur, const uint8_t *usrbuf, in numaker_usbd_ep_copy_from_user() argument
477 const struct device *dev = ep_cur->dev; in numaker_usbd_ep_copy_from_user()
478 USBD_EP_T *ep_base = numaker_usbd_ep_base(dev, ep_cur->ep_hw_idx); in numaker_usbd_ep_copy_from_user()
482 __ASSERT_NO_MSG(ep_cur->dmabuf_valid); in numaker_usbd_ep_copy_from_user()
483 __ASSERT_NO_MSG(ep_cur->mps_valid); in numaker_usbd_ep_copy_from_user()
484 __ASSERT_NO_MSG(ep_cur->mps <= ep_cur->dmabuf_size); in numaker_usbd_ep_copy_from_user()
488 *size_p = MIN(*size_p, ep_cur->mps); in numaker_usbd_ep_copy_from_user()
493 static void numaker_usbd_ep_config_dmabuf(struct numaker_usbd_ep *ep_cur, uint32_t dmabuf_base, in numaker_usbd_ep_config_dmabuf() argument
496 const struct device *dev = ep_cur->dev; in numaker_usbd_ep_config_dmabuf()
497 USBD_EP_T *ep_base = numaker_usbd_ep_base(dev, ep_cur->ep_hw_idx); in numaker_usbd_ep_config_dmabuf()
501 ep_cur->dmabuf_valid = true; in numaker_usbd_ep_config_dmabuf()
502 ep_cur->dmabuf_base = dmabuf_base; in numaker_usbd_ep_config_dmabuf()
503 ep_cur->dmabuf_size = dmabuf_size; in numaker_usbd_ep_config_dmabuf()
506 static void numaker_usbd_ep_abort(struct numaker_usbd_ep *ep_cur) in numaker_usbd_ep_abort() argument
508 const struct device *dev = ep_cur->dev; in numaker_usbd_ep_abort()
509 USBD_EP_T *ep_base = numaker_usbd_ep_base(dev, ep_cur->ep_hw_idx); in numaker_usbd_ep_abort()
514 if (ep_cur->addr_valid) { in numaker_usbd_ep_abort()
515 udc_ep_set_busy(dev, ep_cur->addr, false); in numaker_usbd_ep_abort()
520 static void numaker_usbd_ep_config_major(struct numaker_usbd_ep *ep_cur, in numaker_usbd_ep_config_major() argument
523 const struct device *dev = ep_cur->dev; in numaker_usbd_ep_config_major()
524 USBD_EP_T *ep_base = numaker_usbd_ep_base(dev, ep_cur->ep_hw_idx); in numaker_usbd_ep_config_major()
526 ep_cur->mps_valid = true; in numaker_usbd_ep_config_major()
527 ep_cur->mps = ep_cfg->mps; in numaker_usbd_ep_config_major()
530 ep_cur->ep_hw_cfg = 0; in numaker_usbd_ep_config_major()
534 ep_cur->ep_hw_cfg |= USBD_CFG_CSTALL; in numaker_usbd_ep_config_major()
538 ep_cur->ep_hw_cfg &= ~USBD_CFG_DSQSYNC_Msk; in numaker_usbd_ep_config_major()
541 ep_cur->ep_hw_cfg |= USBD_CFG_EPMODE_DISABLE; in numaker_usbd_ep_config_major()
545 ep_cur->ep_hw_cfg |= USBD_CFG_TYPE_ISO; in numaker_usbd_ep_config_major()
549 ep_cur->ep_hw_cfg |= in numaker_usbd_ep_config_major()
552 ep_base->CFG = ep_cur->ep_hw_cfg; in numaker_usbd_ep_config_major()
555 static void numaker_usbd_ep_enable(struct numaker_usbd_ep *ep_cur) in numaker_usbd_ep_enable() argument
557 const struct device *dev = ep_cur->dev; in numaker_usbd_ep_enable()
558 USBD_EP_T *ep_base = numaker_usbd_ep_base(dev, ep_cur->ep_hw_idx); in numaker_usbd_ep_enable()
561 numaker_usbd_ep_abort(ep_cur); in numaker_usbd_ep_enable()
562 numaker_usbd_ep_clear_stall_n_data_toggle(ep_cur); in numaker_usbd_ep_enable()
565 ep_cur->ep_hw_cfg &= ~USBD_CFG_STATE_Msk; in numaker_usbd_ep_enable()
566 if (USB_EP_DIR_IS_IN(ep_cur->addr)) { in numaker_usbd_ep_enable()
567 ep_cur->ep_hw_cfg |= USBD_CFG_EPMODE_IN; in numaker_usbd_ep_enable()
569 ep_cur->ep_hw_cfg |= USBD_CFG_EPMODE_OUT; in numaker_usbd_ep_enable()
572 ep_base->CFG = ep_cur->ep_hw_cfg; in numaker_usbd_ep_enable()
577 static void numaker_usbd_ep_disable(struct numaker_usbd_ep *ep_cur) in numaker_usbd_ep_disable() argument
579 const struct device *dev = ep_cur->dev; in numaker_usbd_ep_disable()
580 USBD_EP_T *ep_base = numaker_usbd_ep_base(dev, ep_cur->ep_hw_idx); in numaker_usbd_ep_disable()
585 ep_cur->ep_hw_cfg = (ep_cur->ep_hw_cfg & ~USBD_CFG_STATE_Msk) | USBD_CFG_EPMODE_DISABLE; in numaker_usbd_ep_disable()
586 ep_base->CFG = ep_cur->ep_hw_cfg; in numaker_usbd_ep_disable()
590 static void udc_numaker_ep_trigger(struct numaker_usbd_ep *ep_cur, uint32_t len) in udc_numaker_ep_trigger() argument
592 const struct device *dev = ep_cur->dev; in udc_numaker_ep_trigger()
593 USBD_EP_T *ep_base = numaker_usbd_ep_base(dev, ep_cur->ep_hw_idx); in udc_numaker_ep_trigger()
595 if (ep_cur->addr_valid) { in udc_numaker_ep_trigger()
596 udc_ep_set_busy(dev, ep_cur->addr, true); in udc_numaker_ep_trigger()
606 struct numaker_usbd_ep *ep_cur = NULL; in numaker_usbd_ep_mgmt_alloc_ep() local
609 ep_cur = priv->ep_pool + ep_mgmt->ep_idx; in numaker_usbd_ep_mgmt_alloc_ep()
612 __ASSERT_NO_MSG(!ep_cur->valid); in numaker_usbd_ep_mgmt_alloc_ep()
615 ep_cur->valid = true; in numaker_usbd_ep_mgmt_alloc_ep()
618 return ep_cur; in numaker_usbd_ep_mgmt_alloc_ep()
657 struct numaker_usbd_ep *ep_cur; in numaker_usbd_ep_mgmt_init() local
663 ep_cur = priv->ep_pool; in numaker_usbd_ep_mgmt_init()
667 for (; ep_cur != ep_end; ep_cur++) { in numaker_usbd_ep_mgmt_init()
669 memset(ep_cur, 0x00, sizeof(*ep_cur)); in numaker_usbd_ep_mgmt_init()
672 ep_cur->dev = dev; in numaker_usbd_ep_mgmt_init()
675 ep_cur->ep_hw_idx = EP0 + (ep_cur - priv->ep_pool); in numaker_usbd_ep_mgmt_init()
689 ep_cur = priv->ep_pool + 0; in numaker_usbd_ep_mgmt_init()
690 ep_cur->valid = true; in numaker_usbd_ep_mgmt_init()
691 ep_cur->addr_valid = true; in numaker_usbd_ep_mgmt_init()
692 ep_cur->addr = USB_EP_GET_ADDR(0, USB_EP_DIR_OUT); in numaker_usbd_ep_mgmt_init()
693 numaker_usbd_ep_config_dmabuf(ep_cur, ep_mgmt->dmabuf_pos, in numaker_usbd_ep_mgmt_init()
696 ep_cur->mps_valid = true; in numaker_usbd_ep_mgmt_init()
697 ep_cur->mps = NUMAKER_USBD_DMABUF_SIZE_CTRLOUT; in numaker_usbd_ep_mgmt_init()
700 ep_cur = priv->ep_pool + 1; in numaker_usbd_ep_mgmt_init()
701 ep_cur->valid = true; in numaker_usbd_ep_mgmt_init()
702 ep_cur->addr_valid = true; in numaker_usbd_ep_mgmt_init()
703 ep_cur->addr = USB_EP_GET_ADDR(0, USB_EP_DIR_IN); in numaker_usbd_ep_mgmt_init()
704 numaker_usbd_ep_config_dmabuf(ep_cur, ep_mgmt->dmabuf_pos, NUMAKER_USBD_DMABUF_SIZE_CTRLIN); in numaker_usbd_ep_mgmt_init()
706 ep_cur->mps_valid = true; in numaker_usbd_ep_mgmt_init()
707 ep_cur->mps = NUMAKER_USBD_DMABUF_SIZE_CTRLIN; in numaker_usbd_ep_mgmt_init()
715 struct numaker_usbd_ep *ep_cur = priv->ep_pool; in numaker_usbd_ep_mgmt_find_ep() local
718 for (; ep_cur != ep_end; ep_cur++) { in numaker_usbd_ep_mgmt_find_ep()
719 if (!ep_cur->valid) { in numaker_usbd_ep_mgmt_find_ep()
723 if (!ep_cur->addr_valid) { in numaker_usbd_ep_mgmt_find_ep()
727 if (ep == ep_cur->addr) { in numaker_usbd_ep_mgmt_find_ep()
728 return ep_cur; in numaker_usbd_ep_mgmt_find_ep()
739 struct numaker_usbd_ep *ep_cur = numaker_usbd_ep_mgmt_find_ep(dev, ep); in numaker_usbd_ep_mgmt_bind_ep() local
741 if (!ep_cur) { in numaker_usbd_ep_mgmt_bind_ep()
742 ep_cur = numaker_usbd_ep_mgmt_alloc_ep(dev); in numaker_usbd_ep_mgmt_bind_ep()
744 if (!ep_cur) { in numaker_usbd_ep_mgmt_bind_ep()
749 ep_cur->addr = ep; in numaker_usbd_ep_mgmt_bind_ep()
750 ep_cur->addr_valid = true; in numaker_usbd_ep_mgmt_bind_ep()
754 __ASSERT_NO_MSG(ep_cur->valid); in numaker_usbd_ep_mgmt_bind_ep()
755 __ASSERT_NO_MSG(ep_cur->addr_valid); in numaker_usbd_ep_mgmt_bind_ep()
756 __ASSERT_NO_MSG(ep_cur->addr == ep); in numaker_usbd_ep_mgmt_bind_ep()
758 return ep_cur; in numaker_usbd_ep_mgmt_bind_ep()
764 struct numaker_usbd_ep *ep_cur; in numaker_usbd_xfer_out() local
791 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in numaker_usbd_xfer_out()
792 if (!ep_cur) { in numaker_usbd_xfer_out()
797 udc_numaker_ep_trigger(ep_cur, ep_cur->mps); in numaker_usbd_xfer_out()
805 struct numaker_usbd_ep *ep_cur; in numaker_usbd_xfer_in() local
833 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in numaker_usbd_xfer_in()
834 if (!ep_cur) { in numaker_usbd_xfer_in()
841 numaker_usbd_ep_copy_from_user(ep_cur, buf->data, &data_len); in numaker_usbd_xfer_in()
850 udc_numaker_ep_trigger(ep_cur, data_len); in numaker_usbd_xfer_in()
884 struct numaker_usbd_ep *ep_cur; in numaker_usbd_msg_handle_setup() local
893 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in numaker_usbd_msg_handle_setup()
894 if (!ep_cur) { in numaker_usbd_msg_handle_setup()
900 __ASSERT_NO_MSG(ep_cur->addr == USB_CONTROL_EP_OUT); in numaker_usbd_msg_handle_setup()
901 __ASSERT_NO_MSG((ep_cur + 1)->addr == USB_CONTROL_EP_IN); in numaker_usbd_msg_handle_setup()
904 numaker_usbd_ep_abort(ep_cur); in numaker_usbd_msg_handle_setup()
905 numaker_usbd_ep_abort(ep_cur + 1); in numaker_usbd_msg_handle_setup()
908 numaker_usbd_ep_sync_udc_halt(ep_cur, false); in numaker_usbd_msg_handle_setup()
909 numaker_usbd_ep_sync_udc_halt(ep_cur + 1, false); in numaker_usbd_msg_handle_setup()
946 struct numaker_usbd_ep *ep_cur; in numaker_usbd_msg_handle_out() local
959 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in numaker_usbd_msg_handle_out()
960 if (!ep_cur) { in numaker_usbd_msg_handle_out()
978 numaker_usbd_ep_copy_to_user(ep_cur, data_ptr, &data_len, &data_rmn); in numaker_usbd_msg_handle_out()
1039 struct numaker_usbd_ep *ep_cur; in numaker_usbd_msg_handle_in() local
1049 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in numaker_usbd_msg_handle_in()
1050 if (!ep_cur) { in numaker_usbd_msg_handle_in()
1400 struct numaker_usbd_ep *ep_cur; in udc_numaker_ep_dequeue() local
1403 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep_cfg->addr); in udc_numaker_ep_dequeue()
1404 if (!ep_cur) { in udc_numaker_ep_dequeue()
1409 numaker_usbd_ep_abort(ep_cur); in udc_numaker_ep_dequeue()
1421 struct numaker_usbd_ep *ep_cur; in udc_numaker_ep_set_halt() local
1426 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep_cfg->addr); in udc_numaker_ep_set_halt()
1427 if (!ep_cur) { in udc_numaker_ep_set_halt()
1433 numaker_usbd_ep_set_stall(ep_cur); in udc_numaker_ep_set_halt()
1440 struct numaker_usbd_ep *ep_cur; in udc_numaker_ep_clear_halt() local
1446 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep_cfg->addr); in udc_numaker_ep_clear_halt()
1447 if (!ep_cur) { in udc_numaker_ep_clear_halt()
1453 numaker_usbd_ep_clear_stall_n_data_toggle(ep_cur); in udc_numaker_ep_clear_halt()
1468 struct numaker_usbd_ep *ep_cur; in udc_numaker_ep_enable() local
1473 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep_cfg->addr); in udc_numaker_ep_enable()
1474 if (!ep_cur) { in udc_numaker_ep_enable()
1480 if (!ep_cur->dmabuf_valid || ep_cur->dmabuf_size < ep_cfg->mps) { in udc_numaker_ep_enable()
1490 numaker_usbd_ep_config_dmabuf(ep_cur, dmabuf_base, dmabuf_size); in udc_numaker_ep_enable()
1494 numaker_usbd_ep_config_major(ep_cur, ep_cfg); in udc_numaker_ep_enable()
1497 numaker_usbd_ep_enable(ep_cur); in udc_numaker_ep_enable()
1504 struct numaker_usbd_ep *ep_cur; in udc_numaker_ep_disable() local
1509 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep_cfg->addr); in udc_numaker_ep_disable()
1510 if (!ep_cur) { in udc_numaker_ep_disable()
1516 numaker_usbd_ep_disable(ep_cur); in udc_numaker_ep_disable()