Changeset 32fb6bce in mainline for uspace/drv/bus/usb/ehci/hc.c
- Timestamp:
- 2017-12-18T22:50:21Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7f70d1c
- Parents:
- 1ea0bbf
- git-author:
- Ondřej Hlavatý <aearsis@…> (2017-12-18 22:04:50)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2017-12-18 22:50:21)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/hc.c
r1ea0bbf r32fb6bce 97 97 * @return Error code. 98 98 */ 99 int ehci_hc_gen_irq_code(irq_code_t *code, hcd_t *hcd, const hw_res_list_parsed_t *hw_res)99 int hc_gen_irq_code(irq_code_t *code, hc_device_t *hcd, const hw_res_list_parsed_t *hw_res) 100 100 { 101 101 assert(code); 102 102 assert(hw_res); 103 104 hc_t *instance = hcd_get_driver_data(hcd); 103 hc_t *instance = hcd_to_hc(hcd); 105 104 106 105 if (hw_res->irqs.count != 1 || hw_res->mem_ranges.count != 1) … … 149 148 * @return Error code 150 149 */ 151 int hc_ init(hc_t *instance, hcd_t *hcd, const hw_res_list_parsed_t *hw_res)152 { 153 assert(instance);150 int hc_add(hc_device_t *hcd, const hw_res_list_parsed_t *hw_res) 151 { 152 hc_t *instance = hcd_to_hc(hcd); 154 153 assert(hw_res); 155 154 if (hw_res->mem_ranges.count != 1 || … … 190 189 &instance->rh, instance->caps, instance->registers, "ehci rh"); 191 190 192 ehci_bus_init(&instance->bus, hcd, instance); 191 ehci_bus_init(&instance->bus, instance); 192 hc_device_setup(hcd, (bus_t *) &instance->bus); 193 193 return EOK; 194 194 } … … 198 198 * @param[in] instance Host controller structure to use. 199 199 */ 200 void hc_fini(hc_t *instance)200 int hc_gone(hc_device_t *instance) 201 201 { 202 202 assert(instance); 203 return EOK; 203 204 //TODO: stop the hw 204 205 #if 0 … … 263 264 } 264 265 265 int ehci_hc_status(hcd_t *hcd, uint32_t *status) 266 { 267 assert(hcd); 268 hc_t *instance = hcd_get_driver_data(hcd); 269 assert(instance); 266 int ehci_hc_status(bus_t *bus_base, uint32_t *status) 267 { 268 assert(bus_base); 270 269 assert(status); 270 271 ehci_bus_t *bus = (ehci_bus_t *) bus_base; 272 hc_t *hc = bus->hc; 273 assert(hc); 274 271 275 *status = 0; 272 if ( instance->registers) {273 *status = EHCI_RD( instance->registers->usbsts);274 EHCI_WR( instance->registers->usbsts, *status);275 } 276 usb_log_debug2("HC(%p): Read status: %x", instance, *status);276 if (hc->registers) { 277 *status = EHCI_RD(hc->registers->usbsts); 278 EHCI_WR(hc->registers->usbsts, *status); 279 } 280 usb_log_debug2("HC(%p): Read status: %x", hc, *status); 277 281 return EOK; 278 282 } … … 284 288 * @return Error code. 285 289 */ 286 int ehci_hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch) 287 { 288 assert(hcd); 289 hc_t *instance = hcd_get_driver_data(hcd); 290 assert(instance); 290 int ehci_hc_schedule(usb_transfer_batch_t *batch) 291 { 292 assert(batch); 293 294 ehci_bus_t *bus = (ehci_bus_t *) endpoint_get_bus(batch->ep); 295 hc_t *hc = bus->hc; 296 assert(hc); 291 297 292 298 /* Check for root hub communication */ 293 if (batch->target.address == ehci_rh_get_address(& instance->rh)) {299 if (batch->target.address == ehci_rh_get_address(&hc->rh)) { 294 300 usb_log_debug("HC(%p): Scheduling BATCH(%p) for RH(%p)", 295 instance, batch, &instance->rh);296 return ehci_rh_schedule(& instance->rh, batch);301 hc, batch, &hc->rh); 302 return ehci_rh_schedule(&hc->rh, batch); 297 303 } 298 304 … … 303 309 return err; 304 310 305 fibril_mutex_lock(& instance->guard);306 usb_log_debug2("HC(%p): Appending BATCH(%p)", instance, batch);307 list_append(&ehci_batch->link, & instance->pending_batches);308 usb_log_debug("HC(%p): Committing BATCH(%p)", instance, batch);311 fibril_mutex_lock(&hc->guard); 312 usb_log_debug2("HC(%p): Appending BATCH(%p)", hc, batch); 313 list_append(&ehci_batch->link, &hc->pending_batches); 314 usb_log_debug("HC(%p): Committing BATCH(%p)", hc, batch); 309 315 ehci_transfer_batch_commit(ehci_batch); 310 316 311 fibril_mutex_unlock(& instance->guard);317 fibril_mutex_unlock(&hc->guard); 312 318 return EOK; 313 319 } … … 318 324 * @param[in] status Value of the status register at the time of interrupt. 319 325 */ 320 void ehci_hc_interrupt(hcd_t *hcd, uint32_t status) 321 { 322 assert(hcd); 323 hc_t *instance = hcd_get_driver_data(hcd); 324 status = EHCI_RD(status); 325 assert(instance); 326 327 usb_log_debug2("HC(%p): Interrupt: %"PRIx32, instance, status); 326 void ehci_hc_interrupt(bus_t *bus_base, uint32_t status) 327 { 328 assert(bus_base); 329 330 ehci_bus_t *bus = (ehci_bus_t *) bus_base; 331 hc_t *hc = bus->hc; 332 assert(hc); 333 334 usb_log_debug2("HC(%p): Interrupt: %"PRIx32, hc, status); 328 335 if (status & USB_STS_PORT_CHANGE_FLAG) { 329 ehci_rh_interrupt(& instance->rh);336 ehci_rh_interrupt(&hc->rh); 330 337 } 331 338 332 339 if (status & USB_STS_IRQ_ASYNC_ADVANCE_FLAG) { 333 fibril_mutex_lock(& instance->guard);334 usb_log_debug2("HC(%p): Signaling doorbell", instance);335 fibril_condvar_broadcast(& instance->async_doorbell);336 fibril_mutex_unlock(& instance->guard);340 fibril_mutex_lock(&hc->guard); 341 usb_log_debug2("HC(%p): Signaling doorbell", hc); 342 fibril_condvar_broadcast(&hc->async_doorbell); 343 fibril_mutex_unlock(&hc->guard); 337 344 } 338 345 339 346 if (status & (USB_STS_IRQ_FLAG | USB_STS_ERR_IRQ_FLAG)) { 340 fibril_mutex_lock(& instance->guard);341 342 usb_log_debug2("HC(%p): Scanning %lu pending batches", instance,343 list_count(& instance->pending_batches));344 list_foreach_safe( instance->pending_batches, current, next) {347 fibril_mutex_lock(&hc->guard); 348 349 usb_log_debug2("HC(%p): Scanning %lu pending batches", hc, 350 list_count(&hc->pending_batches)); 351 list_foreach_safe(hc->pending_batches, current, next) { 345 352 ehci_transfer_batch_t *batch = 346 353 ehci_transfer_batch_from_link(current); … … 351 358 } 352 359 } 353 fibril_mutex_unlock(& instance->guard);360 fibril_mutex_unlock(&hc->guard); 354 361 } 355 362 356 363 if (status & USB_STS_HOST_ERROR_FLAG) { 357 usb_log_fatal("HCD(%p): HOST SYSTEM ERROR!", instance);364 usb_log_fatal("HCD(%p): HOST SYSTEM ERROR!", hc); 358 365 //TODO do something here 359 366 } … … 364 371 * @param[in] instance EHCI hc driver structure. 365 372 */ 366 int hc_start(hc_ t *instance, bool interrupts)367 { 368 assert(instance);373 int hc_start(hc_device_t *hcd) 374 { 375 hc_t *instance = hcd_to_hc(hcd); 369 376 usb_log_debug("HC(%p): Starting HW.", instance); 370 377
Note:
See TracChangeset
for help on using the changeset viewer.