Changeset 2ef036a in mainline for uspace/drv/uhci-hcd/uhci_hc.c
- Timestamp:
- 2011-03-14T22:51:09Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2180979
- Parents:
- 7ffe82f (diff), fcf07e6 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/uhci_hc.c
r7ffe82f r2ef036a 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup usb28 /** @addtogroup drvusbuhcihc 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver32 * @brief UHCI Host controller driver routines 33 33 */ 34 34 #include <errno.h> … … 59 59 } 60 60 }; 61 62 /** Gets USB address of the calling device.63 *64 * @param[in] fun UHCI hc function.65 * @param[in] handle Handle of the device seeking address.66 * @param[out] address Place to store found address.67 * @return Error code.68 */69 61 /*----------------------------------------------------------------------------*/ 70 62 static int uhci_hc_init_transfer_lists(uhci_hc_t *instance); … … 78 70 bool low_speed, usb_transfer_type_t transfer, size_t size); 79 71 /*----------------------------------------------------------------------------*/ 80 /** Initialize sUHCI hcd driver structure72 /** Initialize UHCI hcd driver structure 81 73 * 82 74 * @param[in] instance Memory place to initialize. … … 86 78 * @return Error code. 87 79 * @note Should be called only once on any structure. 88 */ 89 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun, void *regs, size_t reg_size) 80 * 81 * Initializes memory structures, starts up hw, and launches debugger and 82 * interrupt fibrils. 83 */ 84 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun, 85 void *regs, size_t reg_size, bool interrupts) 90 86 { 91 87 assert(reg_size >= sizeof(regs_t)); … … 100 96 } else (void) 0 101 97 98 instance->hw_interrupts = interrupts; 102 99 /* Setup UHCI function. */ 103 100 instance->ddf_instance = fun; … … 118 115 119 116 uhci_hc_init_hw(instance); 120 instance->cleaner = 121 fibril_create(uhci_hc_interrupt_emulator, instance); 122 fibril_add_ready(instance->cleaner); 117 if (!interrupts) { 118 instance->cleaner = 119 fibril_create(uhci_hc_interrupt_emulator, instance); 120 fibril_add_ready(instance->cleaner); 121 } 123 122 124 123 instance->debug_checker = fibril_create(uhci_hc_debug_checker, instance); … … 130 129 } 131 130 /*----------------------------------------------------------------------------*/ 132 /** Initialize s UHCI hcdhw resources.131 /** Initialize UHCI hc hw resources. 133 132 * 134 133 * @param[in] instance UHCI structure to use. 134 * For magic values see UHCI Design Guide 135 135 */ 136 136 void uhci_hc_init_hw(uhci_hc_t *instance) … … 153 153 pio_write_32(®isters->flbaseadd, pa); 154 154 155 /* Enable all interrupts, but resume interrupt */ 156 // pio_write_16(&instance->registers->usbintr, 157 // UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET); 155 if (instance->hw_interrupts) { 156 /* Enable all interrupts, but resume interrupt */ 157 pio_write_16(&instance->registers->usbintr, 158 UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET); 159 } 158 160 159 161 uint16_t status = pio_read_16(®isters->usbcmd); … … 166 168 } 167 169 /*----------------------------------------------------------------------------*/ 168 /** Initialize s UHCI hcdmemory structures.170 /** Initialize UHCI hc memory structures. 169 171 * 170 172 * @param[in] instance UHCI structure to use. 171 173 * @return Error code 172 174 * @note Should be called only once on any structure. 175 * 176 * Structures: 177 * - interrupt code (I/O addressses are customized per instance) 178 * - transfer lists (queue heads need to be accessible by the hw) 179 * - frame list page (needs to be one UHCI hw accessible 4K page) 173 180 */ 174 181 int uhci_hc_init_mem_structures(uhci_hc_t *instance) … … 229 236 } 230 237 /*----------------------------------------------------------------------------*/ 231 /** Initialize s UHCI hcdtransfer lists.238 /** Initialize UHCI hc transfer lists. 232 239 * 233 240 * @param[in] instance UHCI structure to use. 234 241 * @return Error code 235 242 * @note Should be called only once on any structure. 243 * 244 * Initializes transfer lists and sets them in one chain to support proper 245 * USB scheduling. Sets pointer table for quick access. 236 246 */ 237 247 int uhci_hc_init_transfer_lists(uhci_hc_t *instance) … … 293 303 } 294 304 /*----------------------------------------------------------------------------*/ 295 /** Schedule sbatch for execution.305 /** Schedule batch for execution. 296 306 * 297 307 * @param[in] instance UHCI structure to use. 298 308 * @param[in] batch Transfer batch to schedule. 299 309 * @return Error code 310 * 311 * Checks for bandwidth availability and appends the batch to the proper queue. 300 312 */ 301 313 int uhci_hc_schedule(uhci_hc_t *instance, batch_t *batch) … … 312 324 return ENOTSUP; 313 325 } 314 /* TODO: check available bandwi th here */326 /* TODO: check available bandwidth here */ 315 327 316 328 transfer_list_t *list = … … 322 334 } 323 335 /*----------------------------------------------------------------------------*/ 324 /** Take saction based on the interrupt cause.336 /** Take action based on the interrupt cause. 325 337 * 326 338 * @param[in] instance UHCI structure to use. 327 * @param[in] status Value of the stsatus regiser at the time of interrupt. 339 * @param[in] status Value of the status register at the time of interrupt. 340 * 341 * Interrupt might indicate: 342 * - transaction completed, either by triggering IOC, SPD, or an error 343 * - some kind of device error 344 * - resume from suspend state (not implemented) 328 345 */ 329 346 void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status) … … 342 359 /** Polling function, emulates interrupts. 343 360 * 344 * @param[in] arg UHCI structure to use.345 * @return EOK 361 * @param[in] arg UHCI hc structure to use. 362 * @return EOK (should never return) 346 363 */ 347 364 int uhci_hc_interrupt_emulator(void* arg) … … 366 383 * 367 384 * @param[in] arg UHCI structure to use. 368 * @return EOK 385 * @return EOK (should never return) 369 386 */ 370 387 int uhci_hc_debug_checker(void *arg) … … 430 447 } 431 448 /*----------------------------------------------------------------------------*/ 432 /** Check stransfer packets, for USB validity449 /** Check transfer packets, for USB validity 433 450 * 434 451 * @param[in] low_speed Transfer speed. 435 452 * @param[in] transfer Transer type 436 453 * @param[in] size Maximum size of used packets 437 * @return EOK454 * @return True if transaction is allowed by USB specs, false otherwise 438 455 */ 439 456 bool allowed_usb_packet(
Note:
See TracChangeset
for help on using the changeset viewer.