Example #1
0
void usb_drv_stall(int endpoint, bool stall, bool in)
{
    if (in)
    {
        if (stall) DIEPCTL(endpoint) |= 0x00200000;
        else DIEPCTL(endpoint) &= ~0x00200000;
    }
    else
    {
        if (stall) DOEPCTL(endpoint) |= 0x00200000;
        else DOEPCTL(endpoint) &= ~0x00200000;
    }
}
Example #2
0
 FOR_EACH_OUT_EP_AND_EP0(i, ep)
 {
     endpoints[ep][DIR_OUT].active = false;
     endpoints[ep][DIR_OUT].busy = false;
     endpoints[ep][DIR_OUT].status = -1;
     if(endpoints[ep][DIR_OUT].wait)
         wakeup_signal(&endpoints[ep][DIR_OUT].complete);
     endpoints[ep][DIR_OUT].wait = false;
     if(DOEPCTL(ep) & DEPCTL_epena)
         DOEPCTL(ep) =  DEPCTL_snak;
     else
         DOEPCTL(ep) = 0;
 }
Example #3
0
 FOR_EACH_OUT_EP_AND_EP0(i, ep)
 {
     endpoints[ep][DIR_OUT].active = false;
     endpoints[ep][DIR_OUT].busy = false;
     endpoints[ep][DIR_OUT].status = -1;
     if(endpoints[ep][DIR_OUT].wait)
     {
         endpoints[ep][DIR_OUT].wait = false;
         semaphore_release(&endpoints[ep][DIR_OUT].complete);
     }
     if(DOEPCTL(ep) & DEPCTL_epena)
         DOEPCTL(ep) =  DEPCTL_snak;
     else
         DOEPCTL(ep) = 0;
 }
Example #4
0
static void ep_recv(int ep, void *ptr, int length)
{
    endpoints[ep].busy = true;
    endpoints[ep].size = length;
    DOEPCTL(ep) &= ~0x20000;  /* EPx UNSTALL */
    DOEPCTL(ep) |= 0x8000;  /* EPx OUT ACTIVE */
    int blocksize = usb_drv_port_speed() ? 512 : 64;
    int packets = (length + blocksize - 1) / blocksize;
    if (!length)
    {
        DOEPTSIZ(ep) = 1 << 19;  /* one empty packet */
        DOEPDMA(ep) = NULL;
    }
    else
    {
        DOEPTSIZ(ep) = length | (packets << 19);
        DOEPDMA(ep) = ptr;
    }
    clean_dcache();
    DOEPCTL(ep) |= 0x84000000;  /* EPx OUT ENABLE CLEARNAK */
}
Example #5
0
int usb_drv_request_endpoint(int type, int dir)
{
    size_t ep;
    int ret = -1;

    if (dir == USB_DIR_IN) ep = 1;
    else ep = 2;

    while (ep < USB_NUM_ENDPOINTS)
    {
        if (!endpoints[ep].active)
        {
            endpoints[ep].active = true;
            ret = ep | dir;
            uint32_t newbits = (type << 18) | 0x10000000;
            if (dir) DIEPCTL(ep) = (DIEPCTL(ep) & ~0x000C0000) | newbits;
            else DOEPCTL(ep) = (DOEPCTL(ep) & ~0x000C0000) | newbits;
            break;
        }
        ep += 2;
    }

    return ret;
}
Example #6
0
static void prepare_setup_ep0(void)
{
    logf("usb-drv: prepare EP0");
    /* setup DMA */
    DOEPDMA(0) = (unsigned long)AS3525_PHYSICAL_ADDR(&_ep0_setup_pkt);

    /* Setup EP0 OUT with the following parameters:
     * packet count = 1
     * setup packet count = 1
     * transfer size = 8 (setup packet)
     */
    DOEPTSIZ(0) = (1 << DEPTSIZ0_supcnt_bitp)
                | (1 << DEPTSIZ0_pkcnt_bitp)
                | 8;

    /* Enable endpoint, clear nak */
    ep0_state = EP0_WAIT_SETUP;
    DOEPCTL(0) |= DEPCTL_epena | DEPCTL_cnak;
}
Example #7
0
bool usb_drv_stalled(int endpoint, bool in)
{
    if (in) return DIEPCTL(endpoint) & 0x00200000 ? true : false;
    else return DOEPCTL(endpoint) & 0x00200000 ? true : false;
}