Changeset 3f3afb9 in mainline for uspace/drv/ohci
- Timestamp:
- 2011-04-11T20:38:37Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1324ff3, a39cfb8
- Parents:
- 58226b4 (diff), d91645ab (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. - Location:
- uspace/drv/ohci
- Files:
-
- 14 edited
-
batch.c (modified) (8 diffs)
-
hc.c (modified) (13 diffs)
-
hc.h (modified) (1 diff)
-
hw_struct/endpoint_descriptor.c (modified) (3 diffs)
-
hw_struct/endpoint_descriptor.h (modified) (3 diffs)
-
hw_struct/hcca.h (modified) (1 diff)
-
hw_struct/transfer_descriptor.c (modified) (1 diff)
-
hw_struct/transfer_descriptor.h (modified) (2 diffs)
-
iface.c (modified) (7 diffs)
-
ohci.ma (modified) (1 diff)
-
ohci_regs.h (modified) (4 diffs)
-
root_hub.c (modified) (1 diff)
-
transfer_list.c (modified) (3 diffs)
-
utils/malloc32.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/batch.c
r58226b4 r3f3afb9 51 51 static void batch_control(usb_transfer_batch_t *instance, 52 52 usb_direction_t data_dir, usb_direction_t status_dir); 53 static void batch_data(usb_transfer_batch_t *instance); 53 54 static void batch_call_in_and_dispose(usb_transfer_batch_t *instance); 54 55 static void batch_call_out_and_dispose(usb_transfer_batch_t *instance); … … 134 135 assert(data); 135 136 size_t tds = data->td_count - 1; 136 usb_log_debug 2("Batch(%p) checking %d td(s) for completion.\n",137 usb_log_debug("Batch(%p) checking %d td(s) for completion.\n", 137 138 instance, tds); 139 usb_log_debug("ED: %x:%x:%x:%x.\n", 140 data->ed->status, data->ed->td_head, data->ed->td_tail, 141 data->ed->next); 138 142 size_t i = 0; 139 143 for (; i < tds; ++i) { 140 if (!td_is_finished(&data->tds[i])) 144 usb_log_debug("TD %d: %x:%x:%x:%x.\n", i, 145 data->tds[i].status, data->tds[i].cbp, data->tds[i].next, 146 data->tds[i].be); 147 if (!td_is_finished(&data->tds[i])) { 141 148 return false; 149 } 142 150 instance->error = td_error(&data->tds[i]); 143 151 /* FIXME: calculate real transfered size */ … … 177 185 assert(instance->direction == USB_DIRECTION_IN); 178 186 instance->next_step = batch_call_in_and_dispose; 179 /* TODO: implement */187 batch_data(instance); 180 188 usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance); 181 189 } … … 189 197 instance->buffer_size); 190 198 instance->next_step = batch_call_out_and_dispose; 191 /* TODO: implement */199 batch_data(instance); 192 200 usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance); 193 201 } … … 198 206 instance->direction = USB_DIRECTION_IN; 199 207 instance->next_step = batch_call_in_and_dispose; 200 /* TODO: implement */208 batch_data(instance); 201 209 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); 202 210 } … … 207 215 instance->direction = USB_DIRECTION_IN; 208 216 instance->next_step = batch_call_in_and_dispose; 209 /* TODO: implement */217 batch_data(instance); 210 218 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); 211 219 } … … 227 235 ed_init(data->ed, instance->ep); 228 236 ed_add_tds(data->ed, &data->tds[0], &data->tds[data->td_count - 1]); 229 usb_log_debug("Created ED: %x:%x:%x:%x.\n", data->ed->status, 230 data->ed->td_tail, data->ed->td_head, data->ed->next); 237 usb_log_debug("Created ED(%p): %x:%x:%x:%x.\n", data->ed, 238 data->ed->status, data->ed->td_tail, data->ed->td_head, 239 data->ed->next); 231 240 int toggle = 0; 232 241 /* setup stage */ … … 267 276 } 268 277 /*----------------------------------------------------------------------------*/ 278 void batch_data(usb_transfer_batch_t *instance) 279 { 280 assert(instance); 281 ohci_batch_t *data = instance->private_data; 282 assert(data); 283 ed_init(data->ed, instance->ep); 284 ed_add_tds(data->ed, &data->tds[0], &data->tds[data->td_count - 1]); 285 usb_log_debug("Created ED(%p): %x:%x:%x:%x.\n", data->ed, 286 data->ed->status, data->ed->td_tail, data->ed->td_head, 287 data->ed->next); 288 289 /* data stage */ 290 size_t td_current = 0; 291 size_t remain_size = instance->buffer_size; 292 char *transfer_buffer = instance->transport_buffer; 293 while (remain_size > 0) { 294 size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER ? 295 OHCI_TD_MAX_TRANSFER : remain_size; 296 297 td_init(&data->tds[td_current], instance->ep->direction, 298 transfer_buffer, transfer_size, -1); 299 td_set_next(&data->tds[td_current], &data->tds[td_current + 1]); 300 usb_log_debug("Created DATA TD: %x:%x:%x:%x.\n", 301 data->tds[td_current].status, data->tds[td_current].cbp, 302 data->tds[td_current].next, data->tds[td_current].be); 303 304 transfer_buffer += transfer_size; 305 remain_size -= transfer_size; 306 assert(td_current < data->td_count); 307 ++td_current; 308 } 309 } 310 /*----------------------------------------------------------------------------*/ 269 311 /** Helper function calls callback and correctly disposes of batch structure. 270 312 * -
uspace/drv/ohci/hc.c
r58226b4 r3f3afb9 108 108 ret, str_error(ret)); 109 109 110 hc_gain_control(instance); 111 ret = hc_init_memory(instance); 112 CHECK_RET_RETURN(ret, "Failed to create OHCI memory structures:%s.\n", 113 ret, str_error(ret)); 114 hc_init_hw(instance); 115 fibril_mutex_initialize(&instance->guard); 116 117 rh_init(&instance->rh, dev, instance->registers); 118 110 119 if (!interrupts) { 111 120 instance->interrupt_emulator = … … 114 123 } 115 124 116 hc_gain_control(instance);117 118 rh_init(&instance->rh, dev, instance->registers);119 120 hc_init_memory(instance);121 hc_init_hw(instance);122 123 /* TODO: implement */124 125 return EOK; 125 126 } … … 135 136 } 136 137 137 transfer_list_add_batch( 138 instance->transfers[batch->transfer_type], batch); 139 138 fibril_mutex_lock(&instance->guard); 140 139 switch (batch->transfer_type) { 141 140 case USB_TRANSFER_CONTROL: 141 instance->registers->control &= ~C_CLE; 142 transfer_list_add_batch( 143 instance->transfers[batch->transfer_type], batch); 142 144 instance->registers->command_status |= CS_CLF; 145 usb_log_debug2("Set CS control transfer filled: %x.\n", 146 instance->registers->command_status); 147 instance->registers->control_current = 0; 148 instance->registers->control |= C_CLE; 143 149 break; 144 150 case USB_TRANSFER_BULK: 151 instance->registers->control &= ~C_BLE; 152 transfer_list_add_batch( 153 instance->transfers[batch->transfer_type], batch); 145 154 instance->registers->command_status |= CS_BLF; 155 usb_log_debug2("Set bulk transfer filled: %x.\n", 156 instance->registers->command_status); 157 instance->registers->control |= C_BLE; 158 break; 159 case USB_TRANSFER_INTERRUPT: 160 case USB_TRANSFER_ISOCHRONOUS: 161 instance->registers->control &= (~C_PLE & ~C_IE); 162 transfer_list_add_batch( 163 instance->transfers[batch->transfer_type], batch); 164 instance->registers->control |= C_PLE | C_IE; 165 usb_log_debug2("Added periodic transfer: %x.\n", 166 instance->registers->periodic_current); 146 167 break; 147 168 default: 148 169 break; 149 170 } 171 fibril_mutex_unlock(&instance->guard); 150 172 return EOK; 151 173 } … … 154 176 { 155 177 assert(instance); 156 if ( status == 0)178 if ((status & ~IS_SF) == 0) /* ignore sof status */ 157 179 return; 158 180 if (status & IS_RHSC) 159 181 rh_interrupt(&instance->rh); 160 182 161 usb_log_info("OHCI interrupt: %x.\n", status); 162 163 LIST_INITIALIZE(done); 164 transfer_list_remove_finished(&instance->transfers_interrupt, &done); 165 transfer_list_remove_finished(&instance->transfers_isochronous, &done); 166 transfer_list_remove_finished(&instance->transfers_control, &done); 167 transfer_list_remove_finished(&instance->transfers_bulk, &done); 168 169 while (!list_empty(&done)) { 170 link_t *item = done.next; 171 list_remove(item); 172 usb_transfer_batch_t *batch = 173 list_get_instance(item, usb_transfer_batch_t, link); 174 usb_transfer_batch_finish(batch); 183 usb_log_debug("OHCI interrupt: %x.\n", status); 184 185 if (status & IS_WDH) { 186 fibril_mutex_lock(&instance->guard); 187 usb_log_debug2("HCCA: %p-%p(%p).\n", instance->hcca, 188 instance->registers->hcca, addr_to_phys(instance->hcca)); 189 usb_log_debug2("Periodic current: %p.\n", 190 instance->registers->periodic_current); 191 LIST_INITIALIZE(done); 192 transfer_list_remove_finished( 193 &instance->transfers_interrupt, &done); 194 transfer_list_remove_finished( 195 &instance->transfers_isochronous, &done); 196 transfer_list_remove_finished( 197 &instance->transfers_control, &done); 198 transfer_list_remove_finished( 199 &instance->transfers_bulk, &done); 200 201 while (!list_empty(&done)) { 202 link_t *item = done.next; 203 list_remove(item); 204 usb_transfer_batch_t *batch = 205 list_get_instance(item, usb_transfer_batch_t, link); 206 usb_transfer_batch_finish(batch); 207 } 208 fibril_mutex_unlock(&instance->guard); 175 209 } 176 210 } … … 184 218 instance->registers->interrupt_status = status; 185 219 hc_interrupt(instance, status); 186 async_usleep( 1000);220 async_usleep(50000); 187 221 } 188 222 return EOK; … … 192 226 { 193 227 assert(instance); 228 /* Turn off legacy emulation */ 229 volatile uint32_t *ohci_emulation_reg = 230 (uint32_t*)((char*)instance->registers + 0x100); 231 usb_log_debug("OHCI legacy register %p: %x.\n", 232 ohci_emulation_reg, *ohci_emulation_reg); 233 *ohci_emulation_reg = 0; 234 194 235 /* Interrupt routing enabled => smm driver is active */ 195 236 if (instance->registers->control & C_IR) { 196 usb_log_ info("Found SMM driver requestingownership change.\n");237 usb_log_debug("SMM driver: request ownership change.\n"); 197 238 instance->registers->command_status |= CS_OCR; 198 239 while (instance->registers->control & C_IR) { 199 240 async_usleep(1000); 200 241 } 201 usb_log_info(" Ownership taken from SMM driver.\n");242 usb_log_info("SMM driver: Ownership taken.\n"); 202 243 return; 203 244 } … … 207 248 /* Interrupt routing disabled && status != USB_RESET => BIOS active */ 208 249 if (hc_status != C_HCFS_RESET) { 209 usb_log_ info("Found BIOS driver.\n");250 usb_log_debug("BIOS driver found.\n"); 210 251 if (hc_status == C_HCFS_OPERATIONAL) { 211 usb_log_info(" HC operational(BIOS).\n");252 usb_log_info("BIOS driver: HC operational.\n"); 212 253 return; 213 254 } … … 215 256 instance->registers->control &= (C_HCFS_RESUME << C_HCFS_SHIFT); 216 257 async_usleep(20000); 258 usb_log_info("BIOS driver: HC resumed.\n"); 217 259 return; 218 260 } … … 220 262 /* HC is in reset (hw startup) => no other driver 221 263 * maintain reset for at least the time specified in USB spec (50 ms)*/ 264 usb_log_info("HC found in reset.\n"); 222 265 async_usleep(50000); 223 224 /* turn off legacy emulation */225 volatile uint32_t *ohci_emulation_reg =226 (uint32_t*)((char*)instance->registers + 0x100);227 usb_log_info("OHCI legacy register status %p: %x.\n",228 ohci_emulation_reg, *ohci_emulation_reg);229 *ohci_emulation_reg = 0;230 231 266 } 232 267 /*----------------------------------------------------------------------------*/ 233 268 void hc_init_hw(hc_t *instance) 234 269 { 235 assert(instance); 270 /* OHCI guide page 42 */ 271 assert(instance); 272 usb_log_debug2("Started hc initialization routine.\n"); 273 274 /* Save contents of fm_interval register */ 236 275 const uint32_t fm_interval = instance->registers->fm_interval; 237 238 /* reset hc */ 276 usb_log_debug2("Old value of HcFmInterval: %x.\n", fm_interval); 277 278 /* Reset hc */ 279 usb_log_debug2("HC reset.\n"); 280 size_t time = 0; 239 281 instance->registers->command_status = CS_HCR; 240 async_usleep(10); 241 242 /* restore fm_interval */ 282 while (instance->registers->command_status & CS_HCR) { 283 async_usleep(10); 284 time += 10; 285 } 286 usb_log_debug2("HC reset complete in %zu us.\n", time); 287 288 /* Restore fm_interval */ 243 289 instance->registers->fm_interval = fm_interval; 244 290 assert((instance->registers->command_status & CS_HCR) == 0); 245 291 246 292 /* hc is now in suspend state */ 247 248 /* enable queues */ 293 usb_log_debug2("HC should be in suspend state(%x).\n", 294 instance->registers->control); 295 296 /* Use HCCA */ 297 instance->registers->hcca = addr_to_phys(instance->hcca); 298 299 /* Use queues */ 300 instance->registers->bulk_head = instance->transfers_bulk.list_head_pa; 301 usb_log_debug2("Bulk HEAD set to: %p(%p).\n", 302 instance->transfers_bulk.list_head, 303 instance->transfers_bulk.list_head_pa); 304 305 instance->registers->control_head = 306 instance->transfers_control.list_head_pa; 307 usb_log_debug2("Control HEAD set to: %p(%p).\n", 308 instance->transfers_control.list_head, 309 instance->transfers_control.list_head_pa); 310 311 /* Enable queues */ 249 312 instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE); 250 /* TODO: enable interrupts */ 251 /* set periodic start to 90% */ 252 instance->registers->periodic_start = (fm_interval / 10) * 9; 313 usb_log_debug2("All queues enabled(%x).\n", 314 instance->registers->control); 315 316 /* Disable interrupts */ 317 instance->registers->interrupt_disable = I_SF | I_OC; 318 usb_log_debug2("Disabling interrupts: %x.\n", 319 instance->registers->interrupt_disable); 320 instance->registers->interrupt_disable = I_MI; 321 usb_log_debug2("Enabled interrupts: %x.\n", 322 instance->registers->interrupt_enable); 323 324 /* Set periodic start to 90% */ 325 uint32_t frame_length = ((fm_interval >> FMI_FI_SHIFT) & FMI_FI_MASK); 326 instance->registers->periodic_start = (frame_length / 10) * 9; 327 usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d).\n", 328 instance->registers->periodic_start, 329 instance->registers->periodic_start, frame_length); 253 330 254 331 instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT); 255 usb_log_info("OHCI HC up and running.\n"); 332 usb_log_info("OHCI HC up and running(%x).\n", 333 instance->registers->control); 256 334 } 257 335 /*----------------------------------------------------------------------------*/ … … 277 355 SETUP_TRANSFER_LIST(transfers_control, "CONTROL"); 278 356 SETUP_TRANSFER_LIST(transfers_bulk, "BULK"); 279 357 #undef SETUP_TRANSFER_LIST 280 358 transfer_list_set_next(&instance->transfers_interrupt, 281 359 &instance->transfers_isochronous); … … 292 370 293 371 return EOK; 294 #undef CHECK_RET_CLEAR_RETURN295 372 } 296 373 /*----------------------------------------------------------------------------*/ … … 298 375 { 299 376 assert(instance); 300 /* init queues */377 /* Init queues */ 301 378 hc_init_transfer_lists(instance); 302 379 303 /* init HCCA */380 /*Init HCCA */ 304 381 instance->hcca = malloc32(sizeof(hcca_t)); 305 382 if (instance->hcca == NULL) 306 383 return ENOMEM; 307 384 bzero(instance->hcca, sizeof(hcca_t)); 308 instance->registers->hcca = addr_to_phys(instance->hcca); 309 310 /* use queues */ 311 instance->registers->bulk_head = instance->transfers_bulk.list_head_pa; 312 instance->registers->control_head = 313 instance->transfers_control.list_head_pa; 385 usb_log_debug2("OHCI HCCA initialized at %p.\n", instance->hcca); 314 386 315 387 unsigned i = 0; … … 318 390 instance->transfers_interrupt.list_head_pa; 319 391 } 392 usb_log_debug2("Interrupt HEADs set to: %p(%p).\n", 393 instance->transfers_interrupt.list_head, 394 instance->transfers_interrupt.list_head_pa); 320 395 321 396 return EOK; -
uspace/drv/ohci/hc.h
r58226b4 r3f3afb9 69 69 usb_endpoint_manager_t ep_manager; 70 70 fid_t interrupt_emulator; 71 fibril_mutex_t guard; 71 72 } hc_t; 72 73 -
uspace/drv/ohci/hw_struct/endpoint_descriptor.c
r58226b4 r3f3afb9 42 42 bzero(instance, sizeof(ed_t)); 43 43 if (ep == NULL) { 44 instance->status |= ED_STATUS_K_FLAG;44 instance->status = ED_STATUS_K_FLAG; 45 45 return; 46 46 } … … 53 53 << ED_STATUS_MPS_SHIFT); 54 54 55 55 56 if (ep->speed == USB_SPEED_LOW) 56 57 instance->status |= ED_STATUS_S_FLAG; … … 58 59 instance->status |= ED_STATUS_F_FLAG; 59 60 61 if (ep->toggle) 62 instance->td_head |= ED_TDHEAD_TOGGLE_CARRY; 60 63 } 61 62 64 /** 63 65 * @} -
uspace/drv/ohci/hw_struct/endpoint_descriptor.h
r58226b4 r3f3afb9 53 53 #define ED_STATUS_D_MASK (0x3) /* direction */ 54 54 #define ED_STATUS_D_SHIFT (11) 55 #define ED_STATUS_D_ IN(0x1)56 #define ED_STATUS_D_ OUT(0x2)55 #define ED_STATUS_D_OUT (0x1) 56 #define ED_STATUS_D_IN (0x2) 57 57 #define ED_STATUS_D_TRANSFER (0x3) 58 58 … … 84 84 { 85 85 assert(instance); 86 instance->td_head = addr_to_phys(head) & ED_TDHEAD_PTR_MASK; 86 instance->td_head = 87 ((addr_to_phys(head) & ED_TDHEAD_PTR_MASK) 88 | (instance->td_head & ~ED_TDHEAD_PTR_MASK)); 87 89 instance->td_tail = addr_to_phys(tail) & ED_TDTAIL_PTR_MASK; 88 90 } … … 96 98 instance->next = pa; 97 99 } 98 99 100 #endif 100 101 /** -
uspace/drv/ohci/hw_struct/hcca.h
r58226b4 r3f3afb9 43 43 uint32_t done_head; 44 44 uint32_t reserved[29]; 45 } __attribute__((packed )) hcca_t;45 } __attribute__((packed, aligned)) hcca_t; 46 46 47 47 #endif -
uspace/drv/ohci/hw_struct/transfer_descriptor.c
r58226b4 r3f3afb9 53 53 } 54 54 if (buffer != NULL) { 55 assert(size != 0); 55 56 instance->cbp = addr_to_phys(buffer); 56 57 instance->be = addr_to_phys(buffer + size - 1); -
uspace/drv/ohci/hw_struct/transfer_descriptor.h
r58226b4 r3f3afb9 50 50 #define TD_STATUS_DP_SHIFT (19) 51 51 #define TD_STATUS_DP_SETUP (0x0) 52 #define TD_STATUS_DP_ IN(0x1)53 #define TD_STATUS_DP_ OUT(0x2)52 #define TD_STATUS_DP_OUT (0x1) 53 #define TD_STATUS_DP_IN (0x2) 54 54 #define TD_STATUS_DI_MASK (0x7) /* delay interrupt, wait DI frames before int */ 55 55 #define TD_STATUS_DI_SHIFT (21) … … 86 86 int cc = (instance->status >> TD_STATUS_CC_SHIFT) & TD_STATUS_CC_MASK; 87 87 /* something went wrong, error code is set */ 88 if (cc != CC_NOACCESS1 && cc != CC_NOACCESS2 && cc != CC_NOERROR) {88 if (cc != CC_NOACCESS1 && cc != CC_NOACCESS2) { 89 89 return true; 90 90 } -
uspace/drv/ohci/iface.c
r58226b4 r3f3afb9 63 63 } 64 64 65 usb_log_debug("%s %d:%d %zu(%zu).\n", 66 name, target.address, target.endpoint, size, ep->max_packet_size); 67 65 68 const size_t bw = bandwidth_count_usb11( 66 69 ep->speed, ep->transfer_type, size, ep->max_packet_size); … … 68 71 usb_log_error("Endpoint(%d:%d) %s needs %zu bw " 69 72 "but only %zu is reserved.\n", 70 name, target.address, target.endpoint, bw, res_bw);73 target.address, target.endpoint, name, bw, res_bw); 71 74 return ENOSPC; 72 75 } 73 usb_log_debug("%s %d:%d %zu(%zu).\n", 74 name, target.address, target.endpoint, size, ep->max_packet_size); 75 76 assert(ep->speed == 77 usb_device_keeper_get_speed(&(*hc)->manager, target.address)); 78 // assert(ep->max_packet_size == max_packet_size); 79 // assert(ep->transfer_type == USB_TRANSFER_CONTROL); 80 81 *batch = 82 batch_get(fun, ep, data, size, setup_data, setup_size, 83 in, out, arg); 84 if (!batch) 76 77 *batch = batch_get( 78 fun, ep, data, size, setup_data, setup_size, in, out, arg); 79 if (!*batch) 85 80 return ENOMEM; 86 return EOK;87 }88 89 90 /** Reserve default address interface function91 *92 * @param[in] fun DDF function that was called.93 * @param[in] speed Speed to associate with the new default address.94 * @return Error code.95 */96 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)97 {98 assert(fun);99 hc_t *hc = fun_to_hc(fun);100 assert(hc);101 usb_log_debug("Default address request with speed %d.\n", speed);102 usb_device_keeper_reserve_default_address(&hc->manager, speed);103 return EOK;104 #if 0105 endpoint_t *ep = malloc(sizeof(endpoint_t));106 if (ep == NULL)107 return ENOMEM;108 const size_t max_packet_size = speed == USB_SPEED_LOW ? 8 : 64;109 endpoint_init(ep, USB_TRANSFER_CONTROL, speed, max_packet_size);110 int ret;111 try_retgister:112 ret = usb_endpoint_manager_register_ep(&hc->ep_manager,113 USB_ADDRESS_DEFAULT, 0, USB_DIRECTION_BOTH, ep, endpoint_destroy, 0);114 if (ret == EEXISTS) {115 async_usleep(1000);116 goto try_retgister;117 }118 if (ret != EOK) {119 endpoint_destroy(ep);120 }121 return ret;122 #endif123 }124 /*----------------------------------------------------------------------------*/125 /** Release default address interface function126 *127 * @param[in] fun DDF function that was called.128 * @return Error code.129 */130 static int release_default_address(ddf_fun_t *fun)131 {132 assert(fun);133 hc_t *hc = fun_to_hc(fun);134 assert(hc);135 usb_log_debug("Default address release.\n");136 // return usb_endpoint_manager_unregister_ep(&hc->ep_manager,137 // USB_ADDRESS_DEFAULT, 0, USB_DIRECTION_BOTH);138 usb_device_keeper_release_default_address(&hc->manager);139 81 return EOK; 140 82 } … … 216 158 hc_t *hc = fun_to_hc(fun); 217 159 assert(hc); 218 if (address == hc->rh.address) 219 return EOK; 160 220 161 usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, address); 221 162 if (speed >= USB_SPEED_MAX) { 222 163 speed = ep_speed; 223 164 } 224 const size_t size = 225 (transfer_type == USB_TRANSFER_INTERRUPT 226 || transfer_type == USB_TRANSFER_ISOCHRONOUS) ? 227 max_packet_size : 0; 165 const size_t size = max_packet_size; 228 166 int ret; 167 168 usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n", 169 address, endpoint, usb_str_transfer_type(transfer_type), 170 usb_str_speed(speed), direction, size, max_packet_size, interval); 229 171 230 172 endpoint_t *ep = malloc(sizeof(endpoint_t)); … … 238 180 } 239 181 240 usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",241 address, endpoint, usb_str_transfer_type(transfer_type),242 usb_str_speed(speed), direction, size, max_packet_size, interval);243 244 182 ret = usb_endpoint_manager_register_ep(&hc->ep_manager, ep, size); 245 183 if (ret != EOK) { 246 184 endpoint_destroy(ep); 247 } else {248 usb_device_keeper_add_ep(&hc->manager, address, ep);249 185 } 250 186 return ret; … … 259 195 usb_log_debug("Unregister endpoint %d:%d %d.\n", 260 196 address, endpoint, direction); 261 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,262 address, endpoint, direction, NULL);263 if (ep != NULL) {264 usb_device_keeper_del_ep(&hc->manager, address, ep);265 }266 197 return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address, 267 198 endpoint, direction); … … 435 366 if (ret != EOK) 436 367 return ret; 437 usb_ device_keeper_reset_if_need(&hc->manager, target, setup_data);368 usb_endpoint_manager_reset_if_need(&hc->ep_manager, target, setup_data); 438 369 batch_control_write(batch); 439 370 ret = hc_schedule(hc, batch); … … 484 415 /*----------------------------------------------------------------------------*/ 485 416 usbhc_iface_t hc_iface = { 486 .reserve_default_address = reserve_default_address,487 .release_default_address = release_default_address,488 417 .request_address = request_address, 489 418 .bind_address = bind_address, -
uspace/drv/ohci/ohci.ma
r58226b4 r3f3afb9 1 1 10 pci/ven=106b&dev=003f 2 10 pci/ven=10de&dev=0aa5 3 10 pci/ven=10de&dev=0aa5 -
uspace/drv/ohci/ohci_regs.h
r58226b4 r3f3afb9 84 84 /** Interupt enable/disable, reads give the same value, writing causes 85 85 * enable/disable */ 86 volatile uint32_t inter upt_enable;86 volatile uint32_t interrupt_enable; 87 87 volatile uint32_t interrupt_disable; 88 88 #define I_SO (1 << 0) /* Scheduling overrun */ … … 100 100 #define HCCA_PTR_MASK 0xffffff00 /* HCCA is 256B aligned */ 101 101 102 /** Currently executed period endpoint */103 const volatile uint32_t period _current;102 /** Currently executed periodic endpoint */ 103 const volatile uint32_t periodic_current; 104 104 105 105 /** The first control endpoint */ … … 120 120 /** Frame time and max packet size for all transfers */ 121 121 volatile uint32_t fm_interval; 122 #define FMI_FI_MASK (0x 1fff) /* Frame interval in bit times (should be 11999)*/122 #define FMI_FI_MASK (0x3fff) /* Frame interval in bit times (should be 11999)*/ 123 123 #define FMI_FI_SHIFT (0) 124 124 #define FMI_FSMPS_MASK (0x7fff) /* Full speed max packet size */ … … 138 138 /** Remaining bit time in frame to start periodic transfers */ 139 139 volatile uint32_t periodic_start; 140 #define PS_PS_MASK (0x 1fff) /* bit time when periodic get priority (0x3e67) */140 #define PS_PS_MASK (0x3fff) /* bit time when periodic get priority (0x3e67) */ 141 141 142 142 /** Threshold for starting LS transaction */ -
uspace/drv/ohci/root_hub.c
r58226b4 r3f3afb9 210 210 instance->registers = regs; 211 211 instance->device = dev; 212 instance->port_count = instance->registers->rh_desc_a & 0xff; 212 instance->port_count = 213 (instance->registers->rh_desc_a >> RHDA_NDS_SHIFT) & RHDA_NDS_MASK; 213 214 rh_init_descriptors(instance); 214 215 // set port power mode to no-power-switching -
uspace/drv/ohci/transfer_list.c
r58226b4 r3f3afb9 79 79 assert(instance); 80 80 assert(next); 81 /* Set both queue_head.next to point to the follower */82 81 ed_append_ed(instance->list_head, next->list_head); 83 82 } … … 122 121 usb_transfer_batch_t *first = list_get_instance( 123 122 instance->batch_list.next, usb_transfer_batch_t, link); 124 usb_log_debug("Batch(%p) added to queue %s, first is %p.\n", 125 batch, instance->name, first); 123 usb_log_debug("Batch(%p) added to list %s, first is %p(%p).\n", 124 batch, instance->name, first, batch_ed(first)); 125 if (last_ed == instance->list_head) { 126 usb_log_debug2("%s head ED(%p-%p): %x:%x:%x:%x.\n", 127 instance->name, last_ed, instance->list_head_pa, 128 last_ed->status, last_ed->td_tail, last_ed->td_head, 129 last_ed->next); 130 } 126 131 fibril_mutex_unlock(&instance->guard); 127 132 } … … 138 143 139 144 fibril_mutex_lock(&instance->guard); 145 usb_log_debug2("Checking list %s for completed batches(%d).\n", 146 instance->name, list_count(&instance->batch_list)); 140 147 link_t *current = instance->batch_list.next; 141 148 while (current != &instance->batch_list) { -
uspace/drv/ohci/utils/malloc32.h
r58226b4 r3f3afb9 41 41 #include <as.h> 42 42 43 #define UHCI_STRCUTURES_ALIGNMENT 1644 43 #define UHCI_REQUIRED_PAGE_SIZE 4096 45 44 … … 65 64 */ 66 65 static inline void * malloc32(size_t size) 67 { return memalign( UHCI_STRCUTURES_ALIGNMENT, size); }66 { return memalign(size, size); } 68 67 /*----------------------------------------------------------------------------*/ 69 68 /** Physical mallocator simulator
Note:
See TracChangeset
for help on using the changeset viewer.
