Lines Matching full:ep
81 uint16_t mps; /* Max ep pkt size */
202 LOG_DBG("\n EP %d registers: DIEPCTL : 0x%x DIEPINT : " in usb_dw_reg_dump()
216 static uint8_t usb_dw_ep_is_valid(uint8_t ep) in usb_dw_ep_is_valid() argument
218 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dw_ep_is_valid()
220 /* Check if ep enabled */ in usb_dw_ep_is_valid()
221 if ((USB_EP_DIR_IS_OUT(ep)) && ep_idx < USB_DW_OUT_EP_NUM) { in usb_dw_ep_is_valid()
223 } else if ((USB_EP_DIR_IS_IN(ep)) && ep_idx < USB_DW_IN_EP_NUM) { in usb_dw_ep_is_valid()
230 static uint8_t usb_dw_ep_is_enabled(uint8_t ep) in usb_dw_ep_is_enabled() argument
232 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dw_ep_is_enabled()
234 /* Check if ep enabled */ in usb_dw_ep_is_enabled()
235 if ((USB_EP_DIR_IS_OUT(ep)) && in usb_dw_ep_is_enabled()
238 } else if ((USB_EP_DIR_IS_IN(ep)) && in usb_dw_ep_is_enabled()
293 static void usb_dw_flush_tx_fifo(int ep) in usb_dw_flush_tx_fifo() argument
296 int fnum = usb_dw_ctrl.in_ep_ctrl[ep].fifo_num; in usb_dw_flush_tx_fifo()
303 static int usb_dw_tx_fifo_avail(int ep) in usb_dw_tx_fifo_avail() argument
307 return base->in_ep[ep].dtxfsts & USB_DWC2_DTXFSTS_INEPTXFSPCAVAIL_MASK; in usb_dw_tx_fifo_avail()
311 static int usb_dw_set_fifo(uint8_t ep) in usb_dw_set_fifo() argument
314 int ep_idx = USB_EP_GET_IDX(ep); in usb_dw_set_fifo()
359 static int usb_dw_ep_set(uint8_t ep, in usb_dw_ep_set() argument
364 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dw_ep_set()
366 LOG_DBG("%s ep %x, mps %d, type %d", __func__, ep, ep_mps, ep_type); in usb_dw_ep_set()
368 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dw_ep_set()
402 /* Set max packet size for EP */ in usb_dw_ep_set()
435 if (USB_EP_DIR_IS_IN(ep)) { in usb_dw_ep_set()
436 int ret = usb_dw_set_fifo(ep); in usb_dw_ep_set()
446 static void usb_dw_prep_rx(const uint8_t ep, uint8_t setup) in usb_dw_prep_rx() argument
449 enum usb_dw_out_ep_idx ep_idx = USB_EP_GET_IDX(ep); in usb_dw_prep_rx()
452 /* Set max RX size to EP mps so we get an interrupt in usb_dw_prep_rx()
460 /* Clear NAK and enable ep */ in usb_dw_prep_rx()
467 LOG_DBG("USB OUT EP%d armed", ep_idx); in usb_dw_prep_rx()
470 static int usb_dw_tx(uint8_t ep, const uint8_t *const data, in usb_dw_tx() argument
474 enum usb_dw_in_ep_idx ep_idx = USB_EP_GET_IDX(ep); in usb_dw_tx()
494 LOG_ERR("USB IN EP%d no space available, DTXFSTS %x", ep_idx, in usb_dw_tx()
501 * we force available fifo size to be a multiple of ep mps in order to in usb_dw_tx()
510 /* Get max packet size and packet count for ep */ in usb_dw_tx()
529 LOG_WRN("USB IN EP%d len too big (%d->%d)", ep_idx, in usb_dw_tx()
543 LOG_WRN("USB IN EP%d pkt count too big (%d->%d)", in usb_dw_tx()
557 /* Clear NAK and enable ep */ in usb_dw_tx()
588 LOG_DBG("USB IN EP%d write %u bytes", ep_idx, data_len); in usb_dw_tx()
596 uint8_t ep; in usb_dw_init() local
624 for (ep = 0U; ep < USB_DW_OUT_EP_NUM; ep++) { in usb_dw_init()
625 base->out_ep[ep].doepctl = USB_DWC2_DEPCTL_SNAK; in usb_dw_init()
669 /* enable global EP interrupts */ in usb_dw_handle_reset()
709 LOG_DBG("USB OUT EP%u: RX_FLVL status %u, size %u", in usb_dw_int_rx_flvl_handler()
748 /* Read IN EP interrupt status */ in usb_dw_int_iep_handler()
752 /* Clear IN EP interrupts */ in usb_dw_int_iep_handler()
755 LOG_DBG("USB IN EP%u interrupt status: 0x%x", in usb_dw_int_iep_handler()
781 /* Read OUT EP interrupt status */ in usb_dw_int_oep_handler()
785 /* Clear OUT EP interrupts */ in usb_dw_int_oep_handler()
788 LOG_DBG("USB OUT EP%u interrupt status: 0x%x\n", in usb_dw_int_oep_handler()
849 /* IN EP interrupt */ in usb_dw_isr_handler()
943 LOG_DBG("ep %x, mps %d, type %d", cfg->ep_addr, cfg->ep_mps, in usb_dc_ep_check_cap()
971 uint8_t ep; in usb_dc_ep_configure() local
977 ep = ep_cfg->ep_addr; in usb_dc_ep_configure()
979 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_configure()
980 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_configure()
984 usb_dw_ep_set(ep, ep_cfg->ep_mps, ep_cfg->ep_type); in usb_dc_ep_configure()
989 int usb_dc_ep_set_stall(const uint8_t ep) in usb_dc_ep_set_stall() argument
992 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_set_stall()
994 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_set_stall()
995 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_set_stall()
999 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_set_stall()
1008 int usb_dc_ep_clear_stall(const uint8_t ep) in usb_dc_ep_clear_stall() argument
1011 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_clear_stall()
1013 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_clear_stall()
1014 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_clear_stall()
1023 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_clear_stall()
1032 int usb_dc_ep_halt(const uint8_t ep) in usb_dc_ep_halt() argument
1035 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_halt()
1038 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_halt()
1039 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_halt()
1045 usb_dc_ep_set_stall(ep); in usb_dc_ep_halt()
1047 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_halt()
1064 int usb_dc_ep_is_stalled(const uint8_t ep, uint8_t *const stalled) in usb_dc_ep_is_stalled() argument
1067 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_is_stalled()
1069 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_is_stalled()
1070 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_is_stalled()
1079 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_is_stalled()
1092 int usb_dc_ep_enable(const uint8_t ep) in usb_dc_ep_enable() argument
1095 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_enable()
1097 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_enable()
1098 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_enable()
1102 /* enable EP interrupts */ in usb_dc_ep_enable()
1103 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_enable()
1109 /* Activate Ep */ in usb_dc_ep_enable()
1110 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_enable()
1118 if (USB_EP_DIR_IS_OUT(ep) && in usb_dc_ep_enable()
1121 usb_dw_prep_rx(ep, 0); in usb_dc_ep_enable()
1127 int usb_dc_ep_disable(const uint8_t ep) in usb_dc_ep_disable() argument
1130 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_disable()
1132 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_disable()
1133 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_disable()
1137 /* Disable EP interrupts */ in usb_dc_ep_disable()
1138 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_disable()
1147 /* De-activate, disable and set NAK for Ep */ in usb_dc_ep_disable()
1148 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_disable()
1165 int usb_dc_ep_flush(const uint8_t ep) in usb_dc_ep_flush() argument
1168 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_flush()
1171 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_flush()
1172 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_flush()
1176 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_flush()
1177 /* RX FIFO is global and cannot be flushed per EP */ in usb_dc_ep_flush()
1198 int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data, in usb_dc_ep_write() argument
1203 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_write()
1204 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_write()
1208 /* Check if IN ep */ in usb_dc_ep_write()
1209 if (USB_EP_GET_DIR(ep) != USB_EP_DIR_IN) { in usb_dc_ep_write()
1213 /* Check if ep enabled */ in usb_dc_ep_write()
1214 if (!usb_dw_ep_is_enabled(ep)) { in usb_dc_ep_write()
1218 ret = usb_dw_tx(ep, data, data_len); in usb_dc_ep_write()
1230 int usb_dc_ep_read_wait(uint8_t ep, uint8_t *data, uint32_t max_data_len, in usb_dc_ep_read_wait() argument
1234 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_read_wait()
1237 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_read_wait()
1238 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_read_wait()
1242 /* Check if OUT ep */ in usb_dc_ep_read_wait()
1243 if (USB_EP_GET_DIR(ep) != USB_EP_DIR_OUT) { in usb_dc_ep_read_wait()
1254 /* Check if ep enabled */ in usb_dc_ep_read_wait()
1255 if (!usb_dw_ep_is_enabled(ep)) { in usb_dc_ep_read_wait()
1280 LOG_DBG("Read EP%d, req %d, read %d bytes", ep, max_data_len, in usb_dc_ep_read_wait()
1307 int usb_dc_ep_read_continue(uint8_t ep) in usb_dc_ep_read_continue() argument
1309 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_read_continue()
1311 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_read_continue()
1312 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_read_continue()
1316 /* Check if OUT ep */ in usb_dc_ep_read_continue()
1317 if (USB_EP_GET_DIR(ep) != USB_EP_DIR_OUT) { in usb_dc_ep_read_continue()
1329 int usb_dc_ep_read(const uint8_t ep, uint8_t *const data, in usb_dc_ep_read() argument
1332 if (usb_dc_ep_read_wait(ep, data, max_data_len, read_bytes) != 0) { in usb_dc_ep_read()
1343 if (usb_dc_ep_read_continue(ep) != 0) { in usb_dc_ep_read()
1350 int usb_dc_ep_set_callback(const uint8_t ep, const usb_dc_ep_callback cb) in usb_dc_ep_set_callback() argument
1352 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_set_callback()
1354 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_set_callback()
1355 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_set_callback()
1359 if (USB_EP_DIR_IS_IN(ep)) { in usb_dc_ep_set_callback()
1373 int usb_dc_ep_mps(const uint8_t ep) in usb_dc_ep_mps() argument
1375 enum usb_dw_out_ep_idx ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_mps()
1377 if (!usb_dw_ctrl.attached || !usb_dw_ep_is_valid(ep)) { in usb_dc_ep_mps()
1378 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_mps()
1382 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_mps()