static void ep0_setup(void) { mxc_ep_qh_setup(0, USB_RECV, USB_ENDPOINT_XFER_CONTROL, USB_MAX_CTRL_PAYLOAD, 0, 0); mxc_ep_qh_setup(0, USB_SEND, USB_ENDPOINT_XFER_CONTROL, USB_MAX_CTRL_PAYLOAD, 0, 0); mxc_ep_setup(0, USB_RECV, USB_ENDPOINT_XFER_CONTROL); mxc_ep_setup(0, USB_SEND, USB_ENDPOINT_XFER_CONTROL); mxc_init_ep_dtd(0 * 2 + USB_RECV); mxc_init_ep_dtd(0 * 2 + USB_SEND); }
void udc_setup_ep(struct usb_device_instance *device, u32 index, struct usb_endpoint_instance *epi) { u8 dir, epnum, zlt, mult; u8 ep_type; u32 max_pkt_size; int ep_addr; struct mxc_ep_t *ep; if (epi) { zlt = 1; mult = 0; ep_addr = epi->endpoint_address; epnum = ep_addr & USB_ENDPOINT_NUMBER_MASK; DBG("setup ep %d\n", epnum); if ((ep_addr & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) { dir = USB_SEND; ep_type = epi->tx_attributes; max_pkt_size = epi->tx_packetSize; } else { dir = USB_RECV; ep_type = epi->rcv_attributes; max_pkt_size = epi->rcv_packetSize; } if (ep_type == USB_ENDPOINT_XFER_ISOC) { mult = (u32)(1 + ((max_pkt_size >> 11) & 0x03)); max_pkt_size = max_pkt_size & 0x7ff; DBG("mult = %d\n", mult); } ep = mxc_udc.mxc_ep + (epnum * 2 + dir); ep->epi = epi; if (epnum) { struct ep_queue_item *tqi; int i; mxc_ep_qh_setup(epnum, dir, ep_type, max_pkt_size, zlt, mult); mxc_ep_setup(epnum, dir, ep_type); mxc_init_ep_dtd(epnum * 2 + dir); /* malloc endpoint's dtd's data buffer*/ ep->max_pkt_size = max_pkt_size; for (i = 0; i < EP_TQ_ITEM_SIZE; i++) { tqi = ep->ep_dtd[i]; tqi->page_vir = (u32)malloc_aligned_buffer( &tqi->page_unaligned, max_pkt_size, USB_MEM_ALIGN_BYTE); if ((void *)tqi->page_vir == NULL) { printf("malloc dtd bufer failure\n"); return; } mxc_tqi_init_page(tqi); flush_dcache_range((unsigned long)tqi, CACHE_ALIGNED_END(tqi, sizeof(struct ep_queue_item))); } } }