int udc_endpoint_write(struct usb_endpoint_instance *endpoint) { int ret = 0; /* Transmit only if the hardware is available */ if (endpoint->tx_urb && endpoint->state == 0) { unsigned int ep = endpoint->endpoint_address & USB_ENDPOINT_NUMBER_MASK; u16 peri_txcsr = readw(&musbr->ep[ep].epN.txcsr); /* Error conditions */ if (peri_txcsr & MUSB_TXCSR_P_UNDERRUN) { peri_txcsr &= ~MUSB_TXCSR_P_UNDERRUN; writew(peri_txcsr, &musbr->ep[ep].epN.txcsr); } if (debug_level > 1) musb_print_txcsr(peri_txcsr); /* Check if a packet is waiting to be sent */ if (!(peri_txcsr & MUSB_TXCSR_TXPKTRDY)) { u32 length; u8 *data; struct urb *urb = endpoint->tx_urb; unsigned int remaining_packet = urb->actual_length - endpoint->sent; if (endpoint->tx_packetSize < remaining_packet) length = endpoint->tx_packetSize; else length = remaining_packet; data = (u8 *) urb->buffer; data += endpoint->sent; /* common musb fifo function */ write_fifo(ep, length, data); musb_peri_tx_ready(ep); endpoint->last = length; /* usbd_tx_complete will take care of updating 'sent' */ usbd_tx_complete(endpoint); } musb_peri_wait_tx_done(ep); } else { if (debug_level > 0) serial_printf("ERROR : %s Problem with urb %p " "or ep state %d\n", __PRETTY_FUNCTION__, endpoint->tx_urb, endpoint->state); } return ret; }
static void musb_db_regs(void) { u8 b; u16 w; b = readb(&musbr->faddr); serial_printf("\tfaddr 0x%2.2x\n", b); b = readb(&musbr->power); musb_print_pwr(b); w = readw(&musbr->ep[0].ep0.csr0); musb_print_csr0(w); b = readb(&musbr->devctl); musb_print_devctl(b); b = readb(&musbr->ep[0].ep0.configdata); musb_print_config(b); w = readw(&musbr->frame); serial_printf("\tframe 0x%4.4x\n", w); b = readb(&musbr->index); serial_printf("\tindex 0x%2.2x\n", b); w = readw(&musbr->ep[1].epN.rxmaxp); musb_print_rxmaxp(w); w = readw(&musbr->ep[1].epN.rxcsr); musb_print_rxcsr(w); w = readw(&musbr->ep[1].epN.txmaxp); musb_print_txmaxp(w); w = readw(&musbr->ep[1].epN.txcsr); musb_print_txcsr(w); }