Changeset 26858040 in mainline
- Timestamp:
- 2011-07-12T18:53:14Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 408d3c9
- Parents:
- dfe4955
- Location:
- uspace/drv/bus/usb/uhci
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/hc.c
rdfe4955 r26858040 126 126 uhci_regs_t *io; 127 127 ret = pio_enable(regs, reg_size, (void **)&io); 128 CHECK_RET_RETURN(ret, 129 "Failed(%d) to gain access to registers at %p: %s.\n", 130 ret, io, str_error(ret)); 128 CHECK_RET_RETURN(ret, "Failed to gain access to registers at %p: %s.\n", 129 io, str_error(ret)); 131 130 instance->registers = io; 132 usb_log_debug( "Device registers at %p (%zuB) accessible.\n",133 io, reg_size);131 usb_log_debug( 132 "Device registers at %p (%zuB) accessible.\n", io, reg_size); 134 133 135 134 ret = hc_init_mem_structures(instance); 136 135 CHECK_RET_RETURN(ret, 137 "Failed (%d)to initialize UHCI memory structures: %s.\n",138 ret,str_error(ret));136 "Failed to initialize UHCI memory structures: %s.\n", 137 str_error(ret)); 139 138 140 139 hc_init_hw(instance); … … 162 161 /* Reset everything, who knows what touched it before us */ 163 162 pio_write_16(®isters->usbcmd, UHCI_CMD_GLOBAL_RESET); 164 async_usleep( 10000); /* 10ms according to USB spec*/163 async_usleep(50000); /* 50ms according to USB spec(root hub reset) */ 165 164 pio_write_16(®isters->usbcmd, 0); 166 165 167 /* Reset hc, all states and counters */166 /* Reset hc, all states and counters. Hope that hw is not broken */ 168 167 pio_write_16(®isters->usbcmd, UHCI_CMD_HCRESET); 169 168 do { async_usleep(10); } … … 183 182 } 184 183 185 const uint16_t status= pio_read_16(®isters->usbcmd);186 if ( status!= 0)187 usb_log_warning("Previous command value: %x.\n", status);184 const uint16_t cmd = pio_read_16(®isters->usbcmd); 185 if (cmd != 0) 186 usb_log_warning("Previous command value: %x.\n", cmd); 188 187 189 188 /* Start the hc with large(64B) packet FSBR */ … … 212 211 } else (void) 0 213 212 214 /* Init interrupt code */215 instance->interrupt_code.cmds = instance->interrupt_commands;216 {217 /* Read status register */218 instance->interrupt_commands[0].cmd = CMD_PIO_READ_16;219 instance->interrupt_commands[0].dstarg = 1;220 instance->interrupt_commands[0].addr =221 &instance->registers->usbsts;222 223 /* Test whether we are the interrupt cause */224 instance->interrupt_commands[1].cmd = CMD_BTEST;225 instance->interrupt_commands[1].value =226 UHCI_STATUS_USED_INTERRUPTS | UHCI_STATUS_NM_INTERRUPTS;227 instance->interrupt_commands[1].srcarg = 1;228 instance->interrupt_commands[1].dstarg = 2;229 230 /* Predicate cleaning and accepting */231 instance->interrupt_commands[2].cmd = CMD_PREDICATE;232 instance->interrupt_commands[2].value = 2;233 instance->interrupt_commands[2].srcarg = 2;234 235 /* Write clean status register */236 instance->interrupt_commands[3].cmd = CMD_PIO_WRITE_A_16;237 instance->interrupt_commands[3].srcarg = 1;238 instance->interrupt_commands[3].addr =239 &instance->registers->usbsts;240 241 /* Accept interrupt */242 instance->interrupt_commands[4].cmd = CMD_ACCEPT;243 244 instance->interrupt_code.cmdcount = UHCI_NEEDED_IRQ_COMMANDS;245 }246 247 213 /* Init transfer lists */ 248 214 int ret = hc_init_transfer_lists(instance); 249 CHECK_RET_RETURN(ret, "Failed to init transfer lists.\n");215 CHECK_RET_RETURN(ret, "Failed to initialize transfer lists.\n"); 250 216 usb_log_debug("Initialized transfer lists.\n"); 251 252 /* Init USB frame list page*/253 instance->frame_list = get_page();254 ret = instance->frame_list ? EOK : ENOMEM;255 CHECK_RET_RETURN(ret, "Failed to get frame list page.\n");256 usb_log_debug("Initialized frame list at %p.\n", instance->frame_list);257 258 /* Set all frames to point to the first queue head */259 const uint32_t queue = LINK_POINTER_QH(260 addr_to_phys(instance->transfers_interrupt.queue_head));261 262 unsigned i = 0;263 for(; i < UHCI_FRAME_LIST_COUNT; ++i) {264 instance->frame_list[i] = queue;265 }266 217 267 218 /* Init device keeper */ 268 219 usb_device_keeper_init(&instance->manager); 269 usb_log_debug("Initialized device manager.\n");220 usb_log_debug("Initialized device keeper.\n"); 270 221 271 222 ret = usb_endpoint_manager_init(&instance->ep_manager, … … 274 225 str_error(ret)); 275 226 227 /* Init USB frame list page*/ 228 instance->frame_list = get_page(); 229 if (!instance->frame_list) { 230 usb_log_error("Failed to get frame list page.\n"); 231 usb_endpoint_manager_destroy(&instance->ep_manager); 232 return ENOMEM; 233 } 234 usb_log_debug("Initialized frame list at %p.\n", instance->frame_list); 235 236 /* Set all frames to point to the first queue head */ 237 const uint32_t queue = LINK_POINTER_QH( 238 addr_to_phys(instance->transfers_interrupt.queue_head)); 239 unsigned i = 0; 240 for(; i < UHCI_FRAME_LIST_COUNT; ++i) { 241 instance->frame_list[i] = queue; 242 } 243 276 244 return EOK; 277 245 #undef CHECK_RET_RETURN … … 294 262 int ret = transfer_list_init(&instance->transfers_##type, name); \ 295 263 if (ret != EOK) { \ 296 usb_log_error("Failed (%d)to setup %s transfer list: %s.\n", \297 ret,name, str_error(ret)); \264 usb_log_error("Failed to setup %s transfer list: %s.\n", \ 265 name, str_error(ret)); \ 298 266 transfer_list_fini(&instance->transfers_bulk_full); \ 299 267 transfer_list_fini(&instance->transfers_control_full); \ -
uspace/drv/bus/usb/uhci/hc.h
rdfe4955 r26858040 116 116 /** Pointer table to the above lists, helps during scheduling */ 117 117 transfer_list_t *transfers[2][4]; 118 119 /** Code to be executed in kernel interrupt handler */120 irq_code_t interrupt_code;121 122 /** Commands that form interrupt code */123 irq_cmd_t interrupt_commands[UHCI_NEEDED_IRQ_COMMANDS];124 125 118 /** Fibril periodically checking status register*/ 126 119 fid_t interrupt_emulator; 127 128 120 /** Indicator of hw interrupts availability */ 129 121 bool hw_interrupts;
Note:
See TracChangeset
for help on using the changeset viewer.