Changes in / [501e5df:709e868] in mainline
- Location:
- uspace/drv
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/batch.c
r501e5df r709e868 227 227 ed_init(data->ed, instance->ep); 228 228 ed_add_tds(data->ed, &data->tds[0], &data->tds[data->td_count - 1]); 229 usb_log_debug("Created ED(%p): %x:%x:%x:%x.\n", data->ed, 230 data->ed->status, data->ed->td_tail, data->ed->td_head, 231 data->ed->next); 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); 232 231 int toggle = 0; 233 232 /* setup stage */ -
uspace/drv/ohci/hc.c
r501e5df r709e868 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 116 rh_init(&instance->rh, dev, instance->registers);117 118 110 if (!interrupts) { 119 111 instance->interrupt_emulator = … … 122 114 } 123 115 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 124 return EOK; 125 125 } … … 140 140 switch (batch->transfer_type) { 141 141 case USB_TRANSFER_CONTROL: 142 instance->registers->control &= ~C_CLE;143 142 instance->registers->command_status |= CS_CLF; 144 usb_log_debug2("Set control transfer filled: %x.\n",145 instance->registers->command_status);146 instance->registers->control |= C_CLE;147 143 break; 148 144 case USB_TRANSFER_BULK: 149 145 instance->registers->command_status |= CS_BLF; 150 usb_log_debug2("Set bulk transfer filled: %x.\n",151 instance->registers->command_status);152 146 break; 153 147 default: … … 160 154 { 161 155 assert(instance); 162 if ( (status & ~IS_SF) == 0) /* ignore sof status */156 if (status == 0) 163 157 return; 164 158 if (status & IS_RHSC) … … 166 160 167 161 usb_log_info("OHCI interrupt: %x.\n", status); 168 169 162 170 163 LIST_INITIALIZE(done); … … 199 192 { 200 193 assert(instance); 201 /* Turn off legacy emulation */202 volatile uint32_t *ohci_emulation_reg =203 (uint32_t*)((char*)instance->registers + 0x100);204 usb_log_debug("OHCI legacy register %p: %x.\n",205 ohci_emulation_reg, *ohci_emulation_reg);206 *ohci_emulation_reg = 0;207 208 194 /* Interrupt routing enabled => smm driver is active */ 209 195 if (instance->registers->control & C_IR) { 210 usb_log_ debug("SMM driver: requestownership change.\n");196 usb_log_info("Found SMM driver requesting ownership change.\n"); 211 197 instance->registers->command_status |= CS_OCR; 212 198 while (instance->registers->control & C_IR) { 213 199 async_usleep(1000); 214 200 } 215 usb_log_info(" SMM driver: Ownership taken.\n");201 usb_log_info("Ownership taken from SMM driver.\n"); 216 202 return; 217 203 } … … 221 207 /* Interrupt routing disabled && status != USB_RESET => BIOS active */ 222 208 if (hc_status != C_HCFS_RESET) { 223 usb_log_ debug("BIOS driver found.\n");209 usb_log_info("Found BIOS driver.\n"); 224 210 if (hc_status == C_HCFS_OPERATIONAL) { 225 usb_log_info(" BIOS driver: HC operational.\n");211 usb_log_info("HC operational(BIOS).\n"); 226 212 return; 227 213 } … … 229 215 instance->registers->control &= (C_HCFS_RESUME << C_HCFS_SHIFT); 230 216 async_usleep(20000); 231 usb_log_info("BIOS driver: HC resumed.\n");232 217 return; 233 218 } … … 235 220 /* HC is in reset (hw startup) => no other driver 236 221 * maintain reset for at least the time specified in USB spec (50 ms)*/ 237 usb_log_info("HC found in reset.\n");238 222 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 239 231 } 240 232 /*----------------------------------------------------------------------------*/ 241 233 void hc_init_hw(hc_t *instance) 242 234 { 243 /* OHCI guide page 42 */ 244 assert(instance); 245 usb_log_debug2("Started hc initialization routine.\n"); 246 247 /* Save contents of fm_interval register */ 235 assert(instance); 248 236 const uint32_t fm_interval = instance->registers->fm_interval; 249 usb_log_debug2("Old value of HcFmInterval: %x.\n", fm_interval); 250 251 /* Reset hc */ 252 usb_log_debug2("HC reset.\n"); 253 size_t time = 0; 237 238 /* reset hc */ 254 239 instance->registers->command_status = CS_HCR; 255 while (instance->registers->command_status & CS_HCR) { 256 async_usleep(10); 257 time += 10; 258 } 259 usb_log_debug2("HC reset complete in %zu us.\n", time); 260 261 /* Restore fm_interval */ 240 async_usleep(10); 241 242 /* restore fm_interval */ 262 243 instance->registers->fm_interval = fm_interval; 263 244 assert((instance->registers->command_status & CS_HCR) == 0); 264 245 265 246 /* hc is now in suspend state */ 266 usb_log_debug2("HC should be in suspend state(%x).\n", 267 instance->registers->control); 268 269 /* Enable queues */ 247 248 /* enable queues */ 270 249 instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE); 271 usb_log_debug2("All queues enabled(%x).\n", 272 instance->registers->control); 273 274 /* Disable interrupts */ 275 instance->registers->interrupt_disable = I_SF | I_OC; 276 usb_log_debug2("Disabling interrupts: %x.\n", 277 instance->registers->interrupt_disable); 278 instance->registers->interrupt_disable = I_MI; 279 usb_log_debug2("Enabled interrupts: %x.\n", 280 instance->registers->interrupt_enable); 281 282 /* Set periodic start to 90% */ 283 uint32_t frame_length = ((fm_interval >> FMI_FI_SHIFT) & FMI_FI_MASK); 284 instance->registers->periodic_start = (frame_length / 10) * 9; 285 usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d).\n", 286 instance->registers->periodic_start, 287 instance->registers->periodic_start, frame_length); 250 /* TODO: enable interrupts */ 251 /* set periodic start to 90% */ 252 instance->registers->periodic_start = (fm_interval / 10) * 9; 288 253 289 254 instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT); 290 usb_log_info("OHCI HC up and running(%x).\n", 291 instance->registers->control); 255 usb_log_info("OHCI HC up and running.\n"); 292 256 } 293 257 /*----------------------------------------------------------------------------*/ … … 334 298 { 335 299 assert(instance); 336 /* Init queues */300 /* init queues */ 337 301 hc_init_transfer_lists(instance); 338 302 339 /* Init HCCA */303 /* init HCCA */ 340 304 instance->hcca = malloc32(sizeof(hcca_t)); 341 305 if (instance->hcca == NULL) … … 343 307 bzero(instance->hcca, sizeof(hcca_t)); 344 308 instance->registers->hcca = addr_to_phys(instance->hcca); 345 usb_log_debug2("OHCI HCCA initialized at %p(%p).\n", 346 instance->hcca, instance->registers->hcca); 347 348 /* Use queues */ 309 310 /* use queues */ 349 311 instance->registers->bulk_head = instance->transfers_bulk.list_head_pa; 350 usb_log_debug2("Bulk HEAD set to: %p(%p).\n",351 instance->transfers_bulk.list_head,352 instance->transfers_bulk.list_head_pa);353 354 312 instance->registers->control_head = 355 313 instance->transfers_control.list_head_pa; 356 usb_log_debug2("Control HEAD set to: %p(%p).\n",357 instance->transfers_control.list_head,358 instance->transfers_control.list_head_pa);359 314 360 315 unsigned i = 0; … … 363 318 instance->transfers_interrupt.list_head_pa; 364 319 } 365 usb_log_debug2("Interrupt HEADs set to: %p(%p).\n",366 instance->transfers_interrupt.list_head,367 instance->transfers_interrupt.list_head_pa);368 320 369 321 return EOK; -
uspace/drv/ohci/hw_struct/endpoint_descriptor.c
r501e5df r709e868 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 } … … 57 57 if (ep->transfer_type == USB_TRANSFER_ISOCHRONOUS) 58 58 instance->status |= ED_STATUS_F_FLAG; 59 59 60 } 61 60 62 /** 61 63 * @} -
uspace/drv/ohci/ohci_regs.h
r501e5df r709e868 84 84 /** Interupt enable/disable, reads give the same value, writing causes 85 85 * enable/disable */ 86 volatile uint32_t inter rupt_enable;86 volatile uint32_t interupt_enable; 87 87 volatile uint32_t interrupt_disable; 88 88 #define I_SO (1 << 0) /* Scheduling overrun */ … … 120 120 /** Frame time and max packet size for all transfers */ 121 121 volatile uint32_t fm_interval; 122 #define FMI_FI_MASK (0x 3fff) /* Frame interval in bit times (should be 11999)*/122 #define FMI_FI_MASK (0x1fff) /* 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 3fff) /* bit time when periodic get priority (0x3e67) */140 #define PS_PS_MASK (0x1fff) /* bit time when periodic get priority (0x3e67) */ 141 141 142 142 /** Threshold for starting LS transaction */ -
uspace/drv/ohci/root_hub.c
r501e5df r709e868 210 210 instance->registers = regs; 211 211 instance->device = dev; 212 instance->port_count = 213 (instance->registers->rh_desc_a >> RHDA_NDS_SHIFT) & RHDA_NDS_MASK; 212 instance->port_count = instance->registers->rh_desc_a & 0xff; 214 213 rh_init_descriptors(instance); 215 214 // set port power mode to no-power-switching -
uspace/drv/ohci/transfer_list.c
r501e5df r709e868 122 122 usb_transfer_batch_t *first = list_get_instance( 123 123 instance->batch_list.next, usb_transfer_batch_t, link); 124 usb_log_debug("Batch(%p) added to list %s, first is %p(%p).\n", 125 batch, instance->name, first, batch_ed(first)); 126 if (last_ed == instance->list_head) { 127 usb_log_debug2("%s head ED: %x:%x:%x:%x.\n", instance->name, 128 last_ed->status, last_ed->td_tail, last_ed->td_head, 129 last_ed->next); 130 } 124 usb_log_debug("Batch(%p) added to queue %s, first is %p.\n", 125 batch, instance->name, first); 131 126 fibril_mutex_unlock(&instance->guard); 132 127 }
Note:
See TracChangeset
for help on using the changeset viewer.