Ignore:
Timestamp:
2011-10-16T19:33:47Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1f131fb9
Parents:
721d4b6e (diff), f8dfb40 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge OHCI related changes and improvements.

Rework some routines and use asserts to verify that the device follows OHCI specs.
Add explanatory comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c

    r721d4b6e r98fb010  
    3434#include "endpoint_descriptor.h"
    3535
    36 static unsigned direc[3] =
    37     { ED_STATUS_D_IN, ED_STATUS_D_OUT, ED_STATUS_D_TRANSFER };
     36/** USB direction to OHCI values translation table. */
     37static const uint32_t dir[] = {
     38        [USB_DIRECTION_IN] = ED_STATUS_D_IN,
     39        [USB_DIRECTION_OUT] = ED_STATUS_D_OUT,
     40        [USB_DIRECTION_BOTH] = ED_STATUS_D_TD,
     41};
    3842
    39 void ed_init(ed_t *instance, endpoint_t *ep)
     43/**
     44 * Initialize ED.
     45 *
     46 * @param instance ED structure to initialize.
     47 * @param ep Driver endpoint to use.
     48 * @param td TD to put in the list.
     49 *
     50 * If @param ep is NULL, dummy ED is initalized with only skip flag set.
     51 */
     52void ed_init(ed_t *instance, const endpoint_t *ep, const td_t *td)
    4053{
    4154        assert(instance);
    4255        bzero(instance, sizeof(ed_t));
     56
    4357        if (ep == NULL) {
     58                /* Mark as dead, used for dummy EDs at the beginning of
     59                 * endpoint lists. */
    4460                instance->status = ED_STATUS_K_FLAG;
    4561                return;
    4662        }
    47         assert(ep);
     63        /* Non-dummy ED must have TD assigned */
     64        assert(td);
     65
     66        /* Status: address, endpoint nr, direction mask and max packet size. */
    4867        instance->status = 0
    4968            | ((ep->address & ED_STATUS_FA_MASK) << ED_STATUS_FA_SHIFT)
    5069            | ((ep->endpoint & ED_STATUS_EN_MASK) << ED_STATUS_EN_SHIFT)
    51             | ((direc[ep->direction] & ED_STATUS_D_MASK) << ED_STATUS_D_SHIFT)
     70            | ((dir[ep->direction] & ED_STATUS_D_MASK) << ED_STATUS_D_SHIFT)
    5271            | ((ep->max_packet_size & ED_STATUS_MPS_MASK)
    5372                << ED_STATUS_MPS_SHIFT);
    5473
    55 
     74        /* Low speed flag */
    5675        if (ep->speed == USB_SPEED_LOW)
    5776                instance->status |= ED_STATUS_S_FLAG;
     77
     78        /* Isochronous format flag */
    5879        if (ep->transfer_type == USB_TRANSFER_ISOCHRONOUS)
    5980                instance->status |= ED_STATUS_F_FLAG;
    6081
     82        /* Set TD to the list */
     83        const uintptr_t pa = addr_to_phys(td);
     84        instance->td_head = pa & ED_TDHEAD_PTR_MASK;
     85        instance->td_tail = pa & ED_TDTAIL_PTR_MASK;
     86
     87        /* Set toggle bit */
    6188        if (ep->toggle)
    6289                instance->td_head |= ED_TDHEAD_TOGGLE_CARRY;
     90
    6391}
    6492/**
Note: See TracChangeset for help on using the changeset viewer.