Changeset 5d915b7 in mainline
- Timestamp:
- 2011-09-14T14:25:07Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8e3d17f
- Parents:
- 1e647c7d
- Location:
- uspace/drv/bus/usb/uhci
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/hw_struct/link_pointer.h
r1e647c7d r5d915b7 35 35 #define DRV_UHCI_HW_STRUCT_LINK_POINTER_H 36 36 37 /* UHCI link pointer, used by many data structures */37 /** UHCI link pointer, used by many data structures */ 38 38 typedef uint32_t link_pointer_t; 39 39 -
uspace/drv/bus/usb/uhci/hw_struct/queue_head.h
r1e647c7d r5d915b7 58 58 assert(instance); 59 59 60 instance->element = 0 | LINK_POINTER_TERMINATE_FLAG;61 instance->next = 0 | LINK_POINTER_TERMINATE_FLAG;60 instance->element = LINK_POINTER_TERM; 61 instance->next = LINK_POINTER_TERM; 62 62 } 63 63 /*----------------------------------------------------------------------------*/ … … 71 71 static inline void qh_set_next_qh(qh_t *instance, qh_t *next) 72 72 { 73 uint32_t pa = addr_to_phys(next); 73 /* Physical address has to be below 4GB, 74 * it is an UHCI limitation and malloc32 75 * should guarantee this */ 76 const uint32_t pa = addr_to_phys(next); 74 77 if (pa) { 75 78 instance->next = LINK_POINTER_QH(pa); … … 88 91 static inline void qh_set_element_td(qh_t *instance, td_t *td) 89 92 { 90 uint32_t pa = addr_to_phys(td); 93 /* Physical address has to be below 4GB, 94 * it is an UHCI limitation and malloc32 95 * should guarantee this */ 96 const uint32_t pa = addr_to_phys(td); 91 97 if (pa) { 92 98 instance->element = LINK_POINTER_TD(pa); -
uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c
r1e647c7d r5d915b7 113 113 * @return Error code. 114 114 */ 115 int td_status( td_t *instance)115 int td_status(const td_t *instance) 116 116 { 117 117 assert(instance); … … 119 119 /* This is hc internal error it should never be reported. */ 120 120 if ((instance->status & TD_STATUS_ERROR_BIT_STUFF) != 0) 121 return E AGAIN;121 return EIO; 122 122 123 123 /* CRC or timeout error, like device not present or bad data, … … 150 150 * @param[in] instance TD structure to use. 151 151 */ 152 void td_print_status( td_t *instance)152 void td_print_status(const td_t *instance) 153 153 { 154 154 assert(instance); -
uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h
r1e647c7d r5d915b7 69 69 #define TD_STATUS_ACTLEN_MASK 0x7ff 70 70 71 /* double word with USB device specific info */71 /** Double word with USB device specific info */ 72 72 volatile uint32_t device; 73 73 #define TD_DEVICE_MAXLEN_POS 21 … … 87 87 /* According to UHCI design guide, there is 16 bytes of 88 88 * data available here. 89 * According to linux kernel the hardware does not care,90 * itjust needs to be aligned. We don't use it anyway.89 * According to Linux kernel the hardware does not care, 90 * memory just needs to be aligned. We don't use it anyway. 91 91 */ 92 92 } __attribute__((packed)) td_t; … … 97 97 const void *buffer, const td_t *next); 98 98 99 int td_status( td_t *instance);99 int td_status(const td_t *instance); 100 100 101 void td_print_status( td_t *instance);101 void td_print_status(const td_t *instance); 102 102 /*----------------------------------------------------------------------------*/ 103 103 /** Helper function for parsing actual size out of TD. … … 106 106 * @return Parsed actual size. 107 107 */ 108 static inline size_t td_act_size( td_t *instance)108 static inline size_t td_act_size(const td_t *instance) 109 109 { 110 110 assert(instance); 111 111 const uint32_t s = instance->status; 112 /* Actual size is encoded as n-1 (UHCI design guide p. 23) */ 112 113 return ((s >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK; 113 114 } … … 119 120 * false otherwise. 120 121 */ 121 static inline bool td_is_short( td_t *instance)122 static inline bool td_is_short(const td_t *instance) 122 123 { 123 124 const size_t act_size = td_act_size(instance); … … 134 135 * @return Toggle bit value. 135 136 */ 136 static inline int td_toggle( td_t *instance)137 static inline int td_toggle(const td_t *instance) 137 138 { 138 139 assert(instance); … … 145 146 * @return Active bit value. 146 147 */ 147 static inline bool td_is_active( td_t *instance)148 static inline bool td_is_active(const td_t *instance) 148 149 { 149 150 assert(instance); -
uspace/drv/bus/usb/uhci/main.c
r1e647c7d r5d915b7 64 64 assert(device); 65 65 66 int ret = device_setup_uhci(device);66 const int ret = device_setup_uhci(device); 67 67 if (ret != EOK) { 68 68 usb_log_error("Failed to initialize UHCI driver: %s.\n", 69 69 str_error(ret)); 70 return ret; 70 } else { 71 usb_log_info("Controlling new UHCI device '%s'.\n", 72 device->name); 71 73 } 72 usb_log_info("Controlling new UHCI device '%s'.\n", device->name);73 74 74 return EOK;75 return ret; 75 76 } 76 77 /*----------------------------------------------------------------------------*/ -
uspace/drv/bus/usb/uhci/pci.c
r1e647c7d r5d915b7 61 61 assert(io_reg_size); 62 62 assert(irq_no); 63 63 64 64 async_sess_t *parent_sess = 65 65 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, … … 67 67 if (!parent_sess) 68 68 return ENOMEM; 69 69 70 70 hw_resource_list_t hw_resources; 71 71 int rc = hw_res_get_resource_list(parent_sess, &hw_resources); … … 74 74 return rc; 75 75 } 76 76 77 77 uintptr_t io_address = 0; 78 78 size_t io_size = 0; … … 102 102 } 103 103 } 104 104 105 105 async_hangup(parent_sess); 106 106 107 107 if (!io_found || !irq_found) 108 108 return ENOENT; 109 109 110 110 *io_reg_address = io_address; 111 111 *io_reg_size = io_size; 112 112 *irq_no = irq; 113 113 114 114 return EOK; 115 115 } 116 116 /*----------------------------------------------------------------------------*/ 117 117 /** Call the PCI driver with a request to enable interrupts 118 118 * … … 127 127 if (!parent_sess) 128 128 return ENOMEM; 129 129 130 130 const bool enabled = hw_res_enable_interrupt(parent_sess); 131 131 async_hangup(parent_sess); 132 132 133 133 return enabled ? EOK : EIO; 134 134 } 135 135 /*----------------------------------------------------------------------------*/ 136 136 /** Call the PCI driver with a request to clear legacy support register 137 137 * -
uspace/drv/bus/usb/uhci/root_hub.c
r1e647c7d r5d915b7 50 50 int rh_init(rh_t *instance, ddf_fun_t *fun, uintptr_t reg_addr, size_t reg_size) 51 51 { 52 int ret; 53 52 assert(instance); 54 53 assert(fun); 55 56 ret = ddf_fun_add_match_id(fun, "usb&uhci&root-hub", 100);57 if (ret != EOK) {58 usb_log_error("Failed to add root hub match id: %s\n",59 str_error(ret));60 return ret;61 }62 54 63 55 /* Initialize resource structure */ … … 70 62 instance->io_regs.res.io_range.endianness = LITTLE_ENDIAN; 71 63 72 return EOK; 64 const int ret = ddf_fun_add_match_id(fun, "usb&uhci&root-hub", 100); 65 if (ret != EOK) { 66 usb_log_error("Failed to add root hub match id: %s\n", 67 str_error(ret)); 68 } 69 return ret; 73 70 } 74 71 /** -
uspace/drv/bus/usb/uhci/uhci_batch.c
r1e647c7d r5d915b7 134 134 memcpy(dest, usb_batch->setup_buffer, usb_batch->setup_size); 135 135 dest += usb_batch->setup_size; 136 /* Copy generic data ifunless they are provided by the device */136 /* Copy generic data unless they are provided by the device */ 137 137 if (usb_batch->ep->direction != USB_DIRECTION_IN) { 138 138 memcpy(dest, usb_batch->buffer, usb_batch->buffer_size); … … 142 142 " memory structures ready.\n", usb_batch, 143 143 USB_TRANSFER_BATCH_ARGS(*usb_batch)); 144 144 145 assert( 145 146 batch_setup[usb_batch->ep->transfer_type][usb_batch->ep->direction]); … … 215 216 assert(uhci_batch); 216 217 assert(uhci_batch->usb_batch); 218 assert(uhci_batch->usb_batch->ep); 219 assert(uhci_batch->usb_batch->ep->direction == USB_DIRECTION_OUT || 220 uhci_batch->usb_batch->ep->direction == USB_DIRECTION_IN); 221 217 222 static const usb_packet_id pids[] = { 218 223 [USB_DIRECTION_IN] = USB_PID_IN, 219 224 [USB_DIRECTION_OUT] = USB_PID_OUT, 220 225 }; 221 assert(uhci_batch->usb_batch->ep->direction == USB_DIRECTION_OUT ||222 uhci_batch->usb_batch->ep->direction == USB_DIRECTION_IN);223 226 224 227 const usb_packet_id pid = pids[uhci_batch->usb_batch->ep->direction]; -
uspace/drv/bus/usb/uhci/uhci_batch.h
r1e647c7d r5d915b7 64 64 bool uhci_transfer_batch_is_complete(uhci_transfer_batch_t *uhci_batch); 65 65 66 static inline void * uhci_transfer_batch_setup_buffer( 67 const uhci_transfer_batch_t *uhci_batch) 68 { 69 assert(uhci_batch); 70 assert(uhci_batch->device_buffer); 71 return uhci_batch->device_buffer + sizeof(qh_t) + 72 uhci_batch->td_count * sizeof(td_t); 73 } 74 /*----------------------------------------------------------------------------*/ 66 75 static inline void * uhci_transfer_batch_data_buffer( 67 uhci_transfer_batch_t *uhci_batch)76 const uhci_transfer_batch_t *uhci_batch) 68 77 { 69 78 assert(uhci_batch); 70 79 assert(uhci_batch->usb_batch); 71 assert(uhci_batch->device_buffer); 72 return uhci_batch->device_buffer + sizeof(qh_t) + 73 uhci_batch->td_count * sizeof(td_t) + 80 return uhci_transfer_batch_setup_buffer(uhci_batch) + 74 81 uhci_batch->usb_batch->setup_size; 75 }76 /*----------------------------------------------------------------------------*/77 static inline void * uhci_transfer_batch_setup_buffer(78 uhci_transfer_batch_t *uhci_batch)79 {80 assert(uhci_batch);81 assert(uhci_batch->usb_batch);82 assert(uhci_batch->device_buffer);83 return uhci_batch->device_buffer + sizeof(qh_t) +84 uhci_batch->td_count * sizeof(td_t);85 82 } 86 83 /*----------------------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.