Changeset 9515f674 in mainline
- Timestamp:
- 2011-10-16T14:21:49Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 70d72dd
- Parents:
- 721d4b6e
- Location:
- uspace/drv/bus/usb/ohci
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/endpoint_list.c
r721d4b6e r9515f674 60 60 name, instance->list_head, instance->list_head_pa); 61 61 62 ed_init(instance->list_head, NULL );62 ed_init(instance->list_head, NULL, NULL); 63 63 list_initialize(&instance->endpoint_list); 64 64 fibril_mutex_initialize(&instance->guard); -
uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c
r721d4b6e r9515f674 34 34 #include "endpoint_descriptor.h" 35 35 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. */ 37 static 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 }; 38 42 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 */ 52 void ed_init(ed_t *instance, const endpoint_t *ep, const td_t *td) 40 53 { 41 54 assert(instance); 42 55 bzero(instance, sizeof(ed_t)); 56 43 57 if (ep == NULL) { 58 /* Mark as dead, used for dummy EDs at the beginning of 59 * endpoint lists. */ 44 60 instance->status = ED_STATUS_K_FLAG; 45 61 return; 46 62 } 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. */ 48 67 instance->status = 0 49 68 | ((ep->address & ED_STATUS_FA_MASK) << ED_STATUS_FA_SHIFT) 50 69 | ((ep->endpoint & ED_STATUS_EN_MASK) << ED_STATUS_EN_SHIFT) 51 | ((dir ec[ep->direction] & ED_STATUS_D_MASK) << ED_STATUS_D_SHIFT)70 | ((dir[ep->direction] & ED_STATUS_D_MASK) << ED_STATUS_D_SHIFT) 52 71 | ((ep->max_packet_size & ED_STATUS_MPS_MASK) 53 72 << ED_STATUS_MPS_SHIFT); 54 73 55 74 /* Low speed flag */ 56 75 if (ep->speed == USB_SPEED_LOW) 57 76 instance->status |= ED_STATUS_S_FLAG; 77 78 /* Isochronous format flag */ 58 79 if (ep->transfer_type == USB_TRANSFER_ISOCHRONOUS) 59 80 instance->status |= ED_STATUS_F_FLAG; 60 81 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 */ 61 88 if (ep->toggle) 62 89 instance->td_head |= ED_TDHEAD_TOGGLE_CARRY; 90 63 91 } 64 92 /** -
uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.h
r721d4b6e r9515f674 45 45 #include "completion_codes.h" 46 46 47 /** 48 * OHCI Endpoint Descriptor representation. 49 * 50 * See OHCI spec. Chapter 4.2, page 16 (pdf page 30) for details */ 47 51 typedef struct ed { 52 /** 53 * Status field. 54 * 55 * See table 4-1, p. 17 OHCI spec (pdf page 31). 56 */ 48 57 volatile uint32_t status; 49 58 #define ED_STATUS_FA_MASK (0x7f) /* USB device address */ … … 51 60 #define ED_STATUS_EN_MASK (0xf) /* USB endpoint address */ 52 61 #define ED_STATUS_EN_SHIFT (7) 53 #define ED_STATUS_D_MASK (0x3) /* direction */62 #define ED_STATUS_D_MASK (0x3) /* Direction */ 54 63 #define ED_STATUS_D_SHIFT (11) 55 64 #define ED_STATUS_D_OUT (0x1) 56 65 #define ED_STATUS_D_IN (0x2) 57 #define ED_STATUS_D_T RANSFER (0x3)66 #define ED_STATUS_D_TD (0x3) /* Direction is specified by TD */ 58 67 59 #define ED_STATUS_S_FLAG (1 << 13) /* speed flag: 1 = low */60 #define ED_STATUS_K_FLAG (1 << 14) /* skip flag (no not execute this ED) */61 #define ED_STATUS_F_FLAG (1 << 15) /* format: 1 = isochronous*/62 #define ED_STATUS_MPS_MASK (0x3ff) /* max_packet_size*/68 #define ED_STATUS_S_FLAG (1 << 13) /* Speed flag: 1 = low */ 69 #define ED_STATUS_K_FLAG (1 << 14) /* Skip flag (no not execute this ED) */ 70 #define ED_STATUS_F_FLAG (1 << 15) /* Format: 1 = isochronous */ 71 #define ED_STATUS_MPS_MASK (0x3ff) /* Maximum packet size */ 63 72 #define ED_STATUS_MPS_SHIFT (16) 64 73 74 /** 75 * Pointer to the last TD. 76 * 77 * OHCI hw never changes this field and uses it only for a reference. 78 */ 65 79 volatile uint32_t td_tail; 66 80 #define ED_TDTAIL_PTR_MASK (0xfffffff0) 67 81 #define ED_TDTAIL_PTR_SHIFT (0) 68 82 83 /** 84 * Pointer to the first TD. 85 * 86 * Driver should not change this field if the ED is active. 87 * This field is updated by OHCI hw and points to the next TD 88 * to be executed. 89 */ 69 90 volatile uint32_t td_head; 70 91 #define ED_TDHEAD_PTR_MASK (0xfffffff0) … … 75 96 #define ED_TDHEAD_HALTED_FLAG (0x1) 76 97 98 /** 99 * Pointer to the next ED. 100 * 101 * Driver should not change this field on active EDs. 102 */ 77 103 volatile uint32_t next; 78 104 #define ED_NEXT_PTR_MASK (0xfffffff0) … … 80 106 } __attribute__((packed)) ed_t; 81 107 82 void ed_init(ed_t *instance, endpoint_t *ep);108 void ed_init(ed_t *instance, const endpoint_t *ep, const td_t *td); 83 109 84 static inline void ed_set_td(ed_t *instance, td_t *td) 110 /** 111 * Set the last element of TD list 112 * @param instance ED 113 * @param instance TD to set as the last item. 114 */ 115 static inline void ed_set_tail_td(ed_t *instance, const td_t *td) 85 116 { 86 117 assert(instance); 87 uintptr_t pa = addr_to_phys(td); 88 instance->td_head = 89 ((pa & ED_TDHEAD_PTR_MASK) 90 | (instance->td_head & ~ED_TDHEAD_PTR_MASK)); 118 const uintptr_t pa = addr_to_phys(td); 91 119 instance->td_tail = pa & ED_TDTAIL_PTR_MASK; 92 120 } 93 121 94 static inline void ed_set_end_td(ed_t *instance, td_t *td) 95 { 96 assert(instance); 97 uintptr_t pa = addr_to_phys(td); 98 instance->td_tail = pa & ED_TDTAIL_PTR_MASK; 99 } 100 101 static inline void ed_append_ed(ed_t *instance, ed_t *next) 122 /** 123 * Set next ED in ED chain. 124 * @param instance ED to modify 125 * @param next ED to append 126 */ 127 static inline void ed_append_ed(ed_t *instance, const ed_t *next) 102 128 { 103 129 assert(instance); 104 130 assert(next); 105 uint32_t pa = addr_to_phys(next);131 const uint32_t pa = addr_to_phys(next); 106 132 assert((pa & ED_NEXT_PTR_MASK) << ED_NEXT_PTR_SHIFT == pa); 107 133 instance->next = pa; 108 134 } 109 135 110 static inline int ed_toggle_get(ed_t *instance) 136 /** 137 * Get toggle bit value stored in this ED 138 * @param instance ED 139 * @return Toggle bit value 140 */ 141 static inline int ed_toggle_get(const ed_t *instance) 111 142 { 112 143 assert(instance); … … 114 145 } 115 146 116 static inline void ed_toggle_set(ed_t *instance, int toggle) 147 /** 148 * Set toggle bit value stored in this ED 149 * @param instance ED 150 * @param toggle Toggle bit value 151 */ 152 static inline void ed_toggle_set(ed_t *instance, bool toggle) 117 153 { 118 154 assert(instance); 119 assert(toggle == 0 || toggle == 1); 120 if (toggle == 1) { 155 if (toggle) { 121 156 instance->td_head |= ED_TDHEAD_TOGGLE_CARRY; 122 157 } else { 123 /* clear halted flag when reseting toggle*/158 /* Clear halted flag when reseting toggle TODO: Why? */ 124 159 instance->td_head &= ~ED_TDHEAD_TOGGLE_CARRY; 125 160 instance->td_head &= ~ED_TDHEAD_HALTED_FLAG; -
uspace/drv/bus/usb/ohci/ohci_batch.c
r721d4b6e r9515f674 217 217 { 218 218 assert(ohci_batch); 219 ed_set_ end_td(ohci_batch->ed, ohci_batch->tds[ohci_batch->td_count]);219 ed_set_tail_td(ohci_batch->ed, ohci_batch->tds[ohci_batch->td_count]); 220 220 } 221 221 /*----------------------------------------------------------------------------*/ -
uspace/drv/bus/usb/ohci/ohci_endpoint.c
r721d4b6e r9515f674 102 102 } 103 103 104 ed_init(ohci_ep->ed, ep); 105 ed_set_td(ohci_ep->ed, ohci_ep->td); 104 ed_init(ohci_ep->ed, ep, ohci_ep->td); 106 105 endpoint_set_hc_data( 107 106 ep, ohci_ep, ohci_endpoint_fini, ohci_ep_toggle_get, ohci_ep_toggle_set);
Note:
See TracChangeset
for help on using the changeset viewer.