Changeset 05b51e37 in mainline
- Timestamp:
- 2015-07-03T22:06:22Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 56b5569
- Parents:
- 605db7f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/hc.c
r605db7f r05b51e37 168 168 (void **)&instance->caps); 169 169 if (ret != EOK) { 170 usb_log_error(" Failed to gain access to device registers: %s.\n",171 str_error(ret));170 usb_log_error("HC(%p): Failed to gain access to device " 171 "registers: %s.\n", instance, str_error(ret)); 172 172 return ret; 173 173 } 174 usb_log_info(" Device registers at %" PRIx64 " (%zuB) accessible.\n",175 hw_res->mem_ranges.ranges[0].address.absolute,174 usb_log_info("HC(%p): Device registers at %"PRIx64" (%zuB) accessible.", 175 instance, hw_res->mem_ranges.ranges[0].address.absolute, 176 176 hw_res->mem_ranges.ranges[0].size); 177 177 instance->registers = 178 178 (void*)instance->caps + EHCI_RD8(instance->caps->caplength); 179 usb_log_info(" Device control registers at %" PRIx64 "\n",179 usb_log_info("HC(%p): Device control registers at %" PRIx64, instance, 180 180 hw_res->mem_ranges.ranges[0].address.absolute 181 181 + EHCI_RD8(instance->caps->caplength)); … … 187 187 ret = hc_init_memory(instance); 188 188 if (ret != EOK) { 189 usb_log_error(" Failed to create EHCI memory structures: %s.\n",190 str_error(ret));189 usb_log_error("HC(%p): Failed to create EHCI memory structures:" 190 " %s.", instance, str_error(ret)); 191 191 return ret; 192 192 } 193 193 194 usb_log_info("HC(%p): Initializing RH(%p).", instance, &instance->rh); 194 195 ehci_rh_init( 195 196 &instance->rh, instance->caps, instance->registers, "ehci rh"); 197 usb_log_debug("HC(%p): Starting HW.", instance); 196 198 hc_start(instance); 197 199 … … 219 221 assert(ep); 220 222 ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep); 221 usb_log_debug("HC D(%p) enqueue EP(%d:%d:%s:%s)\n", instance,223 usb_log_debug("HC(%p) enqueue EP(%d:%d:%s:%s)\n", instance, 222 224 ep->address, ep->endpoint, 223 225 usb_str_transfer_type_short(ep->transfer_type), … … 243 245 assert(ep); 244 246 ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep); 245 usb_log_debug("HC D(%p) dequeue EP(%d:%d:%s:%s)\n", instance,247 usb_log_debug("HC(%p) dequeue EP(%d:%d:%s:%s)\n", instance, 246 248 ep->address, ep->endpoint, 247 249 usb_str_transfer_type_short(ep->transfer_type), … … 261 263 } 262 264 fibril_mutex_lock(&instance->guard); 265 usb_log_debug("HC(%p): Waiting for doorbell", instance); 263 266 EHCI_SET(instance->registers->usbcmd, USB_CMD_IRQ_ASYNC_DOORBELL); 264 267 fibril_condvar_wait(&instance->async_doorbell, &instance->guard); 268 usb_log_debug2("HC(%p): Got doorbell", instance); 265 269 fibril_mutex_unlock(&instance->guard); 266 270 } … … 277 281 EHCI_WR(instance->registers->usbsts, *status); 278 282 } 283 usb_log_debug2("HC(%p): Read status: %x", instance, *status); 279 284 return EOK; 280 285 } … … 294 299 /* Check for root hub communication */ 295 300 if (batch->ep->address == ehci_rh_get_address(&instance->rh)) { 301 usb_log_debug("HC(%p): Scheduling BATCH(%p) for RH(%p)", 302 instance, batch, &instance->rh); 296 303 return ehci_rh_schedule(&instance->rh, batch); 297 304 } … … 301 308 302 309 fibril_mutex_lock(&instance->guard); 310 usb_log_debug2("HC(%p): Appending BATCH(%p)", instance, batch); 303 311 list_append(&ehci_batch->link, &instance->pending_batches); 312 usb_log_debug("HC(%p): Committing BATCH(%p)", instance, batch); 304 313 ehci_transfer_batch_commit(ehci_batch); 305 314 … … 320 329 assert(instance); 321 330 331 usb_log_debug2("HC(%p): Interrupt: %"PRIx32, instance, status); 322 332 if (status & USB_STS_PORT_CHANGE_FLAG) { 323 333 ehci_rh_interrupt(&instance->rh); … … 326 336 if (status & USB_STS_IRQ_ASYNC_ADVANCE_FLAG) { 327 337 fibril_mutex_lock(&instance->guard); 338 usb_log_debug2("HC(%p): Signaling doorbell", instance); 328 339 fibril_condvar_broadcast(&instance->async_doorbell); 329 340 fibril_mutex_unlock(&instance->guard); … … 333 344 fibril_mutex_lock(&instance->guard); 334 345 346 usb_log_debug2("HC(%p): Scanning %u pending batches", instance, 347 list_count(&instance->pending_batches)); 335 348 list_foreach_safe(instance->pending_batches, current, next) { 336 349 ehci_transfer_batch_t *batch = … … 346 359 347 360 if (status & USB_STS_HOST_ERROR_FLAG) { 348 usb_log_fatal("H OST CONTROLLER SYSTEM ERROR!\n");361 usb_log_fatal("HCD(%p): HOST SYSTEM ERROR!", instance); 349 362 //TODO do something here 350 363 } … … 371 384 async_usleep(1); 372 385 } 373 usb_log_info(" EHCI turned off.\n");386 usb_log_info("HC(%p): EHCI turned off.", instance); 374 387 } else { 375 usb_log_info(" EHCI was not running.\n");388 usb_log_info("HC(%p): EHCI was not running.", instance); 376 389 } 377 390 378 391 /* Hw initialization sequence, see page 53 (pdf 63) */ 379 392 EHCI_SET(instance->registers->usbcmd, USB_CMD_HC_RESET_FLAG); 393 usb_log_info("HC(%p): Waiting for HW reset.", instance); 380 394 while (EHCI_RD(instance->registers->usbcmd) & USB_CMD_HC_RESET_FLAG) { 381 395 async_usleep(1); 382 396 } 397 usb_log_debug("HC(%p): HW reset OK.", instance); 398 399 //TODO: Do this last 383 400 /* Enable interrupts */ 384 401 EHCI_WR(instance->registers->usbintr, EHCI_USED_INTERRUPTS); … … 393 410 EHCI_WR(instance->registers->periodiclistbase, phys_base); 394 411 EHCI_SET(instance->registers->usbcmd, USB_CMD_PERIODIC_SCHEDULE_FLAG); 412 usb_log_debug("HC(%p): Enabled periodic list.", instance); 395 413 396 414 … … 400 418 EHCI_WR(instance->registers->asynclistaddr, phys_base); 401 419 EHCI_SET(instance->registers->usbcmd, USB_CMD_ASYNC_SCHEDULE_FLAG); 420 usb_log_debug("HC(%p): Enabled async list.", instance); 402 421 403 422 /* Start hc and get all ports */ 404 423 EHCI_SET(instance->registers->usbcmd, USB_CMD_RUN_FLAG); 405 424 EHCI_SET(instance->registers->configflag, USB_CONFIG_FLAG_FLAG); 406 407 usb_log_debug("Registers: \n" 408 "\t USBCMD(%p): %x(0x00080000 = at least 1ms between interrupts)\n" 409 "\t USBSTS(%p): %x(0x00001000 = HC halted)\n" 410 "\t USBINT(%p): %x(0x0 = no interrupts).\n" 411 "\t CONFIG(%p): %x(0x0 = ports controlled by companion hc).\n", 425 usb_log_debug("HC(%p): HW started.", instance); 426 427 usb_log_debug2("HC(%p): Registers: \n" 428 "\tUSBCMD(%p): %x(0x00080000 = at least 1ms between interrupts)\n" 429 "\tUSBSTS(%p): %x(0x00001000 = HC halted)\n" 430 "\tUSBINT(%p): %x(0x0 = no interrupts).\n" 431 "\tCONFIG(%p): %x(0x0 = ports controlled by companion hc).\n", 432 instance, 412 433 &instance->registers->usbcmd, EHCI_RD(instance->registers->usbcmd), 413 434 &instance->registers->usbsts, EHCI_RD(instance->registers->usbsts), … … 424 445 { 425 446 assert(instance); 447 usb_log_debug2("HC(%p): Initializing Async list(%p).", instance, 448 &instance->async_list); 426 449 int ret = endpoint_list_init(&instance->async_list, "ASYNC"); 427 450 if (ret != EOK) { 428 usb_log_error("Failed to setup ASYNC list: %s", str_error(ret)); 451 usb_log_error("HC(%p): Failed to setup ASYNC list: %s", 452 instance, str_error(ret)); 429 453 return ret; 430 454 } … … 435 459 endpoint_list_chain(&instance->async_list, &instance->async_list); 436 460 461 usb_log_debug2("HC(%p): Initializing Interrupt list (%p).", instance, 462 &instance->int_list); 437 463 ret = endpoint_list_init(&instance->int_list, "INT"); 438 464 if (ret != EOK) { 439 usb_log_error("Failed to setup INT list: %s", str_error(ret)); 465 usb_log_error("HC(%p): Failed to setup INT list: %s", 466 instance, str_error(ret)); 440 467 endpoint_list_fini(&instance->async_list); 441 468 return ret; … … 445 472 instance->periodic_list_base = get_page(); 446 473 if (!instance->periodic_list_base) { 447 usb_log_error("Failed to get ISO schedule page."); 474 usb_log_error("HC(%p): Failed to get ISO schedule page.", 475 instance); 448 476 endpoint_list_fini(&instance->async_list); 449 477 endpoint_list_fini(&instance->int_list); 450 478 return ENOMEM; 451 479 } 480 481 usb_log_debug2("HC(%p): Initializing Periodic list.", instance); 452 482 for (unsigned i = 0; 453 483 i < PAGE_SIZE/sizeof(instance->periodic_list_base[0]); ++i)
Note:
See TracChangeset
for help on using the changeset viewer.