Lines Matching full:ep

44 /* Maximum number of EP contexts across all instances
45 * This is to static-allocate EP contexts which can accommodate all instances.
46 * The number of effective EP contexts per instance is passed on through its
64 uint8_t ep; member
86 /* EP context */
94 uint8_t ep_hw_idx; /* BSP USBD driver EP index EP0, EP1, EP2, etc */
95 uint32_t ep_hw_cfg; /* BSP USBD driver EP configuration */
97 /* EP DMA buffer */
116 /* EP address */
120 /* EP MPS */
124 usb_dc_ep_callback cb; /* EP callback function */
127 /* EP context manager */
129 /* EP context management
168 struct numaker_usbd_ep_mgmt ep_mgmt; /* EP management */
240 /* USBD EP base by e.g. EP0, EP1, ... */
246 return base->EP + ep_hw_idx; in numaker_usbd_ep_base()
251 /* NOTE: For one-shot implementation, effective size of EP FIFO is limited to EP MPS */ in numaker_usbd_ep_fifo_max()
267 /* Reset EP FIFO
269 * NOTE: EP FIFO is based on EP DMA buffer, which may not be configured yet.
291 /* Set EP to stalled */ in numaker_usbd_ep_set_stall()
295 /* Reset EP to unstalled and data toggle bit to 0 */
301 /* Reset EP to unstalled */ in numaker_usbd_ep_clear_stall_n_data_toggle()
304 /* Reset EP data toggle bit to 0 */ in numaker_usbd_ep_clear_stall_n_data_toggle()
452 /* Cancel EP on-going transaction */ in numaker_usbd_bus_reset_th()
455 /* Reset EP to unstalled */ in numaker_usbd_bus_reset_th()
458 /* Reset EP data toggle bit to 0 */ in numaker_usbd_bus_reset_th()
505 /* Copy data to user buffer from EP FIFO
535 /* Copy data from user buffer to EP FIFO
569 /* Update EP read/write FIFO on DATA OUT/IN completed */
614 /* Abort EP on-going transaction */ in numaker_usbd_ep_abort()
621 /* Configure EP major common parts */
631 /* Configure EP transfer type, DATA0/1 toggle, direction, number, etc. */ in numaker_usbd_ep_config_major()
662 /* For safe, EP (re-)enable from clean state */ in numaker_usbd_ep_enable()
667 /* Enable EP to IN/OUT */ in numaker_usbd_ep_enable()
677 /* For USBD, no separate EP interrupt control */ in numaker_usbd_ep_enable()
685 /* For USBD, no separate EP interrupt control */ in numaker_usbd_ep_disable()
687 /* Disable EP */ in numaker_usbd_ep_disable()
692 /* Start EP data transaction */
714 /* Indicate this EP context is allocated */ in numaker_usbd_ep_mgmt_alloc_ep()
766 /* Initialize all EP contexts */ in numaker_usbd_ep_mgmt_init()
771 /* BSP USBD driver EP handle */ in numaker_usbd_ep_mgmt_init()
775 /* Reserve 1st/2nd EP contexts (BSP USBD driver EP0/EP1) for CTRL OUT/IN */ in numaker_usbd_ep_mgmt_init()
785 /* Reserve 1st EP context (BSP USBD driver EP0) for CTRL OUT */ in numaker_usbd_ep_mgmt_init()
796 /* Reserve 2nd EP context (BSP USBD driver EP1) for CTRL IN */ in numaker_usbd_ep_mgmt_init()
807 /* Find EP context by EP address */
809 const uint8_t ep) in numaker_usbd_ep_mgmt_find_ep() argument
826 if (ep == ep_cur->addr) { in numaker_usbd_ep_mgmt_find_ep()
834 /* Bind EP context to EP address */
836 const uint8_t ep) in numaker_usbd_ep_mgmt_bind_ep() argument
838 struct numaker_usbd_ep *ep_cur = numaker_usbd_ep_mgmt_find_ep(dev, ep); in numaker_usbd_ep_mgmt_bind_ep()
847 /* Bind EP context to EP address */ in numaker_usbd_ep_mgmt_bind_ep()
848 ep_cur->addr = ep; in numaker_usbd_ep_mgmt_bind_ep()
852 /* Assert EP context bound to EP address */ in numaker_usbd_ep_mgmt_bind_ep()
855 __ASSERT_NO_MSG(ep_cur->addr == ep); in numaker_usbd_ep_mgmt_bind_ep()
871 /* Reset EP FIFO */ in numaker_usbd_bus_reset_bh()
874 /* Abort EP on-going transaction and signal H/W relinquishes DMA buffer ownership */ in numaker_usbd_bus_reset_bh()
877 /* Reset EP to unstalled and data toggle bit to 0 */ in numaker_usbd_bus_reset_bh()
884 /* Interrupt bottom half processing for Setup/EP data transaction */
893 /* Zephyr USB device stack passes Setup packet via CTRL OUT EP. */ in numaker_usbd_ep_bh()
900 /* We should have reserved 1st/2nd EP contexts for CTRL OUT/IN */ in numaker_usbd_ep_bh()
918 /* Update EP read FIFO */ in numaker_usbd_ep_bh()
926 /* Update EP write FIFO */ in numaker_usbd_ep_bh()
973 uint8_t ep; in numaker_usbd_msg_cb_ep() local
978 ep = msg->cb_ep.ep; in numaker_usbd_msg_cb_ep()
980 /* Bind EP context to EP address */ in numaker_usbd_msg_cb_ep()
981 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in numaker_usbd_msg_cb_ep()
984 LOG_ERR("Bind EP context: ep=0x%02x", ep); in numaker_usbd_msg_cb_ep()
988 /* Interrupt bottom half processing for EP */ in numaker_usbd_msg_cb_ep()
995 ep_cur->cb(ep, msg->cb_ep.status_code); in numaker_usbd_msg_cb_ep()
997 LOG_WRN("No EP callback: ep=0x%02x, status_code=%d", ep, msg->cb_ep.status_code); in numaker_usbd_msg_cb_ep()
1150 /* USB Setup/EP */ in numaker_udbd_isr()
1174 * CTRL OUT EP in numaker_udbd_isr()
1177 msg.cb_ep.ep = USB_EP_GET_ADDR(0, USB_EP_DIR_OUT); in numaker_udbd_isr()
1182 /* EP events */ in numaker_udbd_isr()
1192 uint8_t ep; in numaker_udbd_isr() local
1194 /* We don't enable INNAKEN interrupt, so as long as EP event occurs, in numaker_udbd_isr()
1200 /* EP direction, number, and address */ in numaker_udbd_isr()
1205 ep = USB_EP_GET_ADDR(ep_idx, ep_dir); in numaker_udbd_isr()
1210 if (ep == USB_EP_GET_ADDR(0, USB_EP_DIR_IN)) { in numaker_udbd_isr()
1217 if (ep == USB_EP_GET_ADDR(0, USB_EP_DIR_OUT)) { in numaker_udbd_isr()
1227 msg.cb_ep.ep = ep; in numaker_udbd_isr()
1229 USB_EP_DIR_IS_IN(ep) ? USB_DC_EP_DATA_IN : USB_DC_EP_DATA_OUT; in numaker_udbd_isr()
1232 /* Have handled this EP and go next */ in numaker_udbd_isr()
1356 /* For safe, require EP number for control transfer to be 0 */ in usb_dc_ep_check_cap()
1358 LOG_ERR("EP number for control transfer must be 0"); in usb_dc_ep_check_cap()
1363 /* Some soc series don't allow ISO IN/OUT to be assigned the same EP number. in usb_dc_ep_check_cap()
1364 * This is addressed by limiting all OUT/IN EP addresses in top/bottom halves, in usb_dc_ep_check_cap()
1368 /* Limit all OUT EP addresses in top-half, except CTRL OUT */ in usb_dc_ep_check_cap()
1370 LOG_DBG("Support only ISO OUT EP address 0x01~0x07: 0x%02x", in usb_dc_ep_check_cap()
1376 /* Limit all IN EP addresses in bottom-half , except CTRL IN */ in usb_dc_ep_check_cap()
1378 LOG_DBG("Support only ISO IN EP address 0x88~0x8F: 0x%02x", in usb_dc_ep_check_cap()
1385 /* To respect this capability check, pre-bind EP context to EP address, in usb_dc_ep_check_cap()
1390 LOG_ERR("Bind EP context: ep=0x%02x", ep_cfg->ep_addr); in usb_dc_ep_check_cap()
1402 int usb_dc_ep_set_callback(const uint8_t ep, const usb_dc_ep_callback cb) in usb_dc_ep_set_callback() argument
1410 /* Bind EP context to EP address */ in usb_dc_ep_set_callback()
1411 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_set_callback()
1414 LOG_ERR("Bind EP context: ep=0x%02x", ep); in usb_dc_ep_set_callback()
1436 LOG_DBG("EP=0x%02x, MPS=%d, Type=%d", ep_cfg->ep_addr, ep_cfg->ep_mps, ep_cfg->ep_type); in usb_dc_ep_configure()
1440 /* Bind EP context to EP address */ in usb_dc_ep_configure()
1444 LOG_ERR("Bind EP context: ep=0x%02x", ep_cfg->ep_addr); in usb_dc_ep_configure()
1449 /* Configure EP DMA buffer */ in usb_dc_ep_configure()
1459 /* Configure EP DMA buffer */ in usb_dc_ep_configure()
1463 /* Configure EP majorly */ in usb_dc_ep_configure()
1473 int usb_dc_ep_set_stall(const uint8_t ep) in usb_dc_ep_set_stall() argument
1479 LOG_DBG("Set stall: ep=0x%02x", ep); in usb_dc_ep_set_stall()
1483 /* Bind EP context to EP address */ in usb_dc_ep_set_stall()
1484 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_set_stall()
1487 LOG_ERR("Bind EP context: ep=0x%02x", ep); in usb_dc_ep_set_stall()
1492 /* Set EP to stalled */ in usb_dc_ep_set_stall()
1502 int usb_dc_ep_clear_stall(const uint8_t ep) in usb_dc_ep_clear_stall() argument
1508 LOG_DBG("Clear stall: ep=0x%02x", ep); in usb_dc_ep_clear_stall()
1512 /* Bind EP context to EP address */ in usb_dc_ep_clear_stall()
1513 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_clear_stall()
1516 LOG_ERR("Bind EP context: ep=0x%02x", ep); in usb_dc_ep_clear_stall()
1521 /* Reset EP to unstalled and data toggle bit to 0 */ in usb_dc_ep_clear_stall()
1531 int usb_dc_ep_is_stalled(const uint8_t ep, uint8_t *const stalled) in usb_dc_ep_is_stalled() argument
1543 /* Bind EP context to EP address */ in usb_dc_ep_is_stalled()
1544 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_is_stalled()
1547 LOG_ERR("Bind EP context: ep=0x%02x", ep); in usb_dc_ep_is_stalled()
1561 int usb_dc_ep_halt(const uint8_t ep) in usb_dc_ep_halt() argument
1563 return usb_dc_ep_set_stall(ep); in usb_dc_ep_halt()
1566 int usb_dc_ep_enable(const uint8_t ep) in usb_dc_ep_enable() argument
1572 LOG_DBG("Enable: ep=0x%02x", ep); in usb_dc_ep_enable()
1576 /* Bind EP context to EP address */ in usb_dc_ep_enable()
1577 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_enable()
1580 LOG_ERR("Bind EP context: ep=0x%02x", ep); in usb_dc_ep_enable()
1592 if (USB_EP_DIR_IS_OUT(ep) && USB_EP_GET_IDX(ep) != 0) { in usb_dc_ep_enable()
1593 rc = usb_dc_ep_read_continue(ep); in usb_dc_ep_enable()
1606 int usb_dc_ep_disable(const uint8_t ep) in usb_dc_ep_disable() argument
1612 LOG_DBG("Disable: ep=0x%02x", ep); in usb_dc_ep_disable()
1616 /* Bind EP context to EP address */ in usb_dc_ep_disable()
1617 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_disable()
1620 LOG_ERR("Bind EP context: ep=0x%02x", ep); in usb_dc_ep_disable()
1634 int usb_dc_ep_flush(const uint8_t ep) in usb_dc_ep_flush() argument
1640 LOG_DBG("ep=0x%02x", ep); in usb_dc_ep_flush()
1644 /* Bind EP context to EP address */ in usb_dc_ep_flush()
1645 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_flush()
1648 LOG_ERR("Bind EP context: ep=0x%02x", ep); in usb_dc_ep_flush()
1662 int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data_buf, const uint32_t data_len, in usb_dc_ep_write() argument
1672 /* Bind EP context to EP address */ in usb_dc_ep_write()
1673 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_write()
1676 LOG_ERR("ep=0x%02x", ep); in usb_dc_ep_write()
1681 if (!USB_EP_DIR_IS_IN(ep)) { in usb_dc_ep_write()
1682 LOG_ERR("Invalid EP address 0x%02x for write", ep); in usb_dc_ep_write()
1689 LOG_WRN("ep 0x%02x busy", ep); in usb_dc_ep_write()
1696 LOG_WRN("ep 0x%02x: Write FIFO not empty for one-shot implementation", ep); in usb_dc_ep_write()
1713 /* Now H/W actually owns EP DMA buffer */ in usb_dc_ep_write()
1735 int usb_dc_ep_read(const uint8_t ep, uint8_t *const data, const uint32_t max_data_len, in usb_dc_ep_read() argument
1743 rc = usb_dc_ep_read_wait(ep, data, max_data_len, read_bytes); in usb_dc_ep_read()
1748 rc = usb_dc_ep_read_continue(ep); in usb_dc_ep_read()
1760 int usb_dc_ep_read_wait(uint8_t ep, uint8_t *data_buf, uint32_t max_data_len, uint32_t *read_bytes) in usb_dc_ep_read_wait() argument
1771 /* Bind EP context to EP address */ in usb_dc_ep_read_wait()
1772 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_read_wait()
1775 LOG_ERR("Bind EP context: ep=0x%02x", ep); in usb_dc_ep_read_wait()
1780 if (!USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_read_wait()
1781 LOG_ERR("Invalid EP address 0x%02x for read", ep); in usb_dc_ep_read_wait()
1787 if (ep == USB_CONTROL_EP_OUT && ep_mgmt->new_setup) { in usb_dc_ep_read_wait()
1804 /* For one-shot implementation, don't read FIFO with EP busy. */ in usb_dc_ep_read_wait()
1806 LOG_WRN("ep 0x%02x busy", ep); in usb_dc_ep_read_wait()
1848 int usb_dc_ep_read_continue(uint8_t ep) in usb_dc_ep_read_continue() argument
1856 /* Bind EP context to EP address */ in usb_dc_ep_read_continue()
1857 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_read_continue()
1860 LOG_ERR("Bind EP context: ep=0x%02x", ep); in usb_dc_ep_read_continue()
1865 if (!USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_read_continue()
1866 LOG_ERR("Invalid EP address 0x%02x for read", ep); in usb_dc_ep_read_continue()
1892 int usb_dc_ep_mps(const uint8_t ep) in usb_dc_ep_mps() argument
1901 /* Bind EP context to EP address */ in usb_dc_ep_mps()
1902 ep_cur = numaker_usbd_ep_mgmt_bind_ep(dev, ep); in usb_dc_ep_mps()
1905 LOG_ERR("Bind EP context: ep=0x%02x", ep); in usb_dc_ep_mps()