Changeset 112d159 in mainline
- Timestamp:
- 2011-04-09T13:14:51Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ff0e354
- Parents:
- 39db23f
- Location:
- uspace/drv/ohci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/hc.c
r39db23f r112d159 154 154 { 155 155 assert(instance); 156 if ( status == 0)156 if ((status & ~IS_SF) == 0) /* ignore sof status */ 157 157 return; 158 158 if (status & IS_RHSC) … … 192 192 { 193 193 assert(instance); 194 /* Turn off legacy emulation */ 195 volatile uint32_t *ohci_emulation_reg = 196 (uint32_t*)((char*)instance->registers + 0x100); 197 usb_log_debug("OHCI legacy register %p: %x.\n", 198 ohci_emulation_reg, *ohci_emulation_reg); 199 *ohci_emulation_reg = 0; 200 194 201 /* Interrupt routing enabled => smm driver is active */ 195 202 if (instance->registers->control & C_IR) { 196 usb_log_ info("Found SMM driver requestingownership change.\n");203 usb_log_debug("SMM driver: request ownership change.\n"); 197 204 instance->registers->command_status |= CS_OCR; 198 205 while (instance->registers->control & C_IR) { 199 206 async_usleep(1000); 200 207 } 201 usb_log_info(" Ownership taken from SMM driver.\n");208 usb_log_info("SMM driver: Ownership taken.\n"); 202 209 return; 203 210 } … … 207 214 /* Interrupt routing disabled && status != USB_RESET => BIOS active */ 208 215 if (hc_status != C_HCFS_RESET) { 209 usb_log_ info("Found BIOS driver.\n");216 usb_log_debug("BIOS driver found.\n"); 210 217 if (hc_status == C_HCFS_OPERATIONAL) { 211 usb_log_info(" HC operational(BIOS).\n");218 usb_log_info("BIOS driver: HC operational.\n"); 212 219 return; 213 220 } … … 215 222 instance->registers->control &= (C_HCFS_RESUME << C_HCFS_SHIFT); 216 223 async_usleep(20000); 224 usb_log_info("BIOS driver: HC resumed.\n"); 217 225 return; 218 226 } … … 220 228 /* HC is in reset (hw startup) => no other driver 221 229 * maintain reset for at least the time specified in USB spec (50 ms)*/ 230 usb_log_info("HC found in reset.\n"); 222 231 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 231 232 } 232 233 /*----------------------------------------------------------------------------*/ 233 234 void hc_init_hw(hc_t *instance) 234 235 { 235 assert(instance); 236 /* OHCI guide page 42 */ 237 assert(instance); 238 usb_log_debug2("Started hc initialization routine.\n"); 239 240 /* Save contents of fm_interval register */ 236 241 const uint32_t fm_interval = instance->registers->fm_interval; 237 238 /* reset hc */ 242 usb_log_debug2("Old value of HcFmInterval: %x.\n", fm_interval); 243 244 /* Reset hc */ 245 usb_log_debug2("HC reset.\n"); 246 size_t time = 0; 239 247 instance->registers->command_status = CS_HCR; 240 async_usleep(10); 241 242 /* restore fm_interval */ 248 while (instance->registers->command_status & CS_HCR) { 249 async_usleep(10); 250 time += 10; 251 } 252 usb_log_debug2("HC reset complete in %zu us.\n", time); 253 254 /* Restore fm_interval */ 243 255 instance->registers->fm_interval = fm_interval; 244 256 assert((instance->registers->command_status & CS_HCR) == 0); 245 257 246 258 /* hc is now in suspend state */ 247 248 /* enable queues */ 259 usb_log_debug2("HC should be in suspend state(%x).\n", 260 instance->registers->control); 261 262 /* Enable queues */ 249 263 instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE); 250 /* TODO: enable interrupts */ 251 /* set periodic start to 90% */ 252 instance->registers->periodic_start = (fm_interval / 10) * 9; 264 usb_log_debug2("All queues enabled(%x).\n", 265 instance->registers->control); 266 267 /* Disable interrupts */ 268 instance->registers->interrupt_disable = I_SF | I_OC; 269 usb_log_debug2("Disabling interrupts: %x.\n", 270 instance->registers->interrupt_disable); 271 instance->registers->interrupt_disable = I_MI; 272 usb_log_debug2("Enabled interrupts: %x.\n", 273 instance->registers->interrupt_enable); 274 275 /* Set periodic start to 90% */ 276 uint32_t frame_length = ((fm_interval >> FMI_FI_SHIFT) & FMI_FI_MASK); 277 instance->registers->periodic_start = (frame_length / 10) * 9; 278 usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d).\n", 279 instance->registers->periodic_start, 280 instance->registers->periodic_start, frame_length); 253 281 254 282 instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT); 255 usb_log_info("OHCI HC up and running.\n"); 283 usb_log_info("OHCI HC up and running(%x).\n", 284 instance->registers->control); 256 285 } 257 286 /*----------------------------------------------------------------------------*/ -
uspace/drv/ohci/ohci_regs.h
r39db23f r112d159 84 84 /** Interupt enable/disable, reads give the same value, writing causes 85 85 * enable/disable */ 86 volatile uint32_t inter upt_enable;86 volatile uint32_t interrupt_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 1fff) /* Frame interval in bit times (should be 11999)*/122 #define FMI_FI_MASK (0x3fff) /* 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 1fff) /* bit time when periodic get priority (0x3e67) */140 #define PS_PS_MASK (0x3fff) /* bit time when periodic get priority (0x3e67) */ 141 141 142 142 /** Threshold for starting LS transaction */ -
uspace/drv/ohci/root_hub.c
r39db23f r112d159 209 209 instance->registers = regs; 210 210 instance->device = dev; 211 instance->port_count = instance->registers->rh_desc_a & 0xff; 211 instance->port_count = 212 (instance->registers->rh_desc_a >> RHDA_NDS_SHIFT) & RHDA_NDS_MASK; 212 213 rh_init_descriptors(instance); 213 214 // set port power mode to no-power-switching
Note:
See TracChangeset
for help on using the changeset viewer.