static void handle_out_ep(int ep) { struct usb_ctrlrequest *req = (void*)AS3525_UNCACHED_ADDR(&setup_desc->data1); int ep_sts = USB_OEP_STS(ep) & ~USB_OEP_STS_MASK(ep); if (ep > 3) panicf("out_ep > 3!?"); USB_OEP_STS(ep) = ep_sts; /* ACK */ if (ep_sts & USB_EP_STAT_BNA) { /* Buffer was not set up */ int ctrl = USB_OEP_CTRL(ep); logf("ep%d OUT, status %x ctrl %x (BNA)\n", ep, ep_sts, ctrl); panicf("ep%d OUT 0x%x 0x%x (BNA)", ep, ep_sts, ctrl); ep_sts &= ~USB_EP_STAT_BNA; } if (ep_sts & USB_EP_STAT_OUT_RCVD) { struct usb_dev_dma_desc *uc_desc = endpoints[ep][1].uc_desc; int dma_sts = uc_desc->status; int dma_len = dma_sts & 0xffff; if (!(dma_sts & USB_DMA_DESC_ZERO_LEN)) { logf("EP%d OUT token, st:%08x len:%d frm:%x data=%s epstate=%d\n", ep, dma_sts & 0xf8000000, dma_len, (dma_sts >> 16) & 0x7ff, make_hex(uc_desc->data_ptr, dma_len), endpoints[ep][1].state); /* * If parts of the just dmaed range are in cache, dump them now. */ discard_dcache_range(uc_desc->data_ptr, dma_len); } else{
static void setup_desc_init(struct usb_dev_setup_buf *desc) { struct usb_dev_setup_buf *uc_desc = AS3525_UNCACHED_ADDR(desc); uc_desc->status = USB_DMA_DESC_BS_HST_RDY; uc_desc->resv = 0xffffffff; uc_desc->data1 = 0xffffffff; uc_desc->data2 = 0xffffffff; }
const void * pcm_play_dma_get_peak_buffer(int *count) { int oldstatus = disable_irq_save(); size_t addr = DMAC_CH_SRC_ADDR(0); size_t start_addr = (size_t)dma_start_addr; size_t start_size = dma_start_size; restore_interrupt(oldstatus); *count = (start_size - addr + start_addr) >> 2; return (void*)AS3525_UNCACHED_ADDR(addr); }
static void dma_desc_init(int ep, int dir) { struct usb_dev_dma_desc *desc = &dmadescs[ep][dir]; struct usb_dev_dma_desc *uc_desc = AS3525_UNCACHED_ADDR(desc); endpoints[ep][dir].uc_desc = uc_desc; uc_desc->status = USB_DMA_DESC_BS_DMA_DONE | \ USB_DMA_DESC_LAST | \ USB_DMA_DESC_ZERO_LEN; uc_desc->resv = 0xffffffff; uc_desc->data_ptr = 0; uc_desc->next_desc = 0; }
char *make_hex(char *data, int len) { int i; if (!((int)data & 0x40000000)) data = AS3525_UNCACHED_ADDR(data); /* don't pollute the cache */ if (len > 512) len = 512; for (i=0; i<len; i++) { hexbuf[2*i ] = hextab[(unsigned char)data[i] >> 4 ]; hexbuf[2*i+1] = hextab[(unsigned char)data[i] & 0xf]; } hexbuf[2*i] = 0; return hexbuf; }
/* Waiting for ack (either IN or OUT) */ EP0_WAIT_ACK = 1, /* Ack complete, waiting for data (either IN or OUT) * This state is necessary because if both ack and data complete in the * same interrupt, we might process data completion before ack completion * so we need this bizarre state */ EP0_WAIT_DATA = 2, /* Setup packet complete, waiting for ack and data */ EP0_WAIT_DATA_ACK = 3, }; /* endpoints[ep_num][DIR_IN/DIR_OUT] */ static struct usb_endpoint endpoints[USB_NUM_ENDPOINTS][2]; /* setup packet for EP0 */ static struct usb_ctrlrequest _ep0_setup_pkt __attribute__((aligned(32))); static struct usb_ctrlrequest *ep0_setup_pkt = AS3525_UNCACHED_ADDR(&_ep0_setup_pkt); /* state of EP0 */ static enum ep0state ep0_state; void usb_attach(void) { logf("usb-drv: attach"); usb_enable(true); } static inline void usb_delay(void) { int i = 0; while(i < 0x300) {
void * pcm_dma_addr(void *addr) { if (addr != NULL) addr = AS3525_UNCACHED_ADDR(addr); return addr; }