Changeset 344925c in mainline
- Timestamp:
- 2011-04-08T20:29:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 06c552c
- Parents:
- 6b6e3ed3
- Location:
- uspace/drv/ohci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/hc.c
r6b6e3ed3 r344925c 48 48 static void hc_init_hw(hc_t *instance); 49 49 static int hc_init_transfer_lists(hc_t *instance); 50 static int hc_init_memory(hc_t *instance); 50 51 /*----------------------------------------------------------------------------*/ 51 52 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun) … … 117 118 rh_init(&instance->rh, dev, instance->registers); 118 119 120 hc_init_memory(instance); 119 121 hc_init_hw(instance); 120 122 … … 207 209 assert(instance); 208 210 const uint32_t fm_interval = instance->registers->fm_interval; 211 212 /* reset hc */ 209 213 instance->registers->command_status = CS_HCR; 210 214 async_usleep(10); 215 216 /* restore fm_interval */ 211 217 instance->registers->fm_interval = fm_interval; 212 218 assert((instance->registers->command_status & CS_HCR) == 0); 219 213 220 /* hc is now in suspend state */ 214 /* init queues */ 215 hc_init_transfer_lists(instance); 216 /* TODO: init HCCA block */ 217 /* TODO: enable queues */ 221 222 /* enable queues */ 223 instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE); 218 224 /* TODO: enable interrupts */ 219 /* TODO: set periodic start to 90% */ 225 /* set periodic start to 90% */ 226 instance->registers->periodic_start = (fm_interval / 10) * 9; 220 227 221 228 instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT); … … 226 233 { 227 234 assert(instance); 228 #define CHECK_RET_CLEAR_RETURN(ret, message...) \ 235 236 #define SETUP_TRANSFER_LIST(type, name) \ 237 do { \ 238 int ret = transfer_list_init(&instance->type, name); \ 229 239 if (ret != EOK) { \ 230 usb_log_error(message); \ 240 usb_log_error("Failed(%d) to setup %s transfer list.\n", \ 241 ret, name); \ 231 242 transfer_list_fini(&instance->transfers_isochronous); \ 232 243 transfer_list_fini(&instance->transfers_interrupt); \ 233 244 transfer_list_fini(&instance->transfers_control); \ 234 245 transfer_list_fini(&instance->transfers_bulk); \ 235 return ret; \ 236 } else (void) 0 237 238 int ret; 239 ret = transfer_list_init(&instance->transfers_bulk, "BULK"); 240 CHECK_RET_CLEAR_RETURN(ret, "Failed to init BULK list."); 241 242 ret = transfer_list_init(&instance->transfers_control, "CONTROL"); 243 CHECK_RET_CLEAR_RETURN(ret, "Failed to init CONTROL list."); 244 245 ret = transfer_list_init(&instance->transfers_interrupt, "INTERRUPT"); 246 CHECK_RET_CLEAR_RETURN(ret, "Failed to init INTERRUPT list."); 246 } \ 247 } while (0) 248 249 SETUP_TRANSFER_LIST(transfers_isochronous, "ISOCHRONOUS"); 250 SETUP_TRANSFER_LIST(transfers_interrupt, "INTERRUPT"); 251 SETUP_TRANSFER_LIST(transfers_control, "CONTROL"); 252 SETUP_TRANSFER_LIST(transfers_bulk, "BULK"); 247 253 248 254 transfer_list_set_next(&instance->transfers_interrupt, 249 255 &instance->transfers_isochronous); 250 256 251 257 /* Assign pointers to be used during scheduling */ … … 262 268 #undef CHECK_RET_CLEAR_RETURN 263 269 } 270 /*----------------------------------------------------------------------------*/ 271 int hc_init_memory(hc_t *instance) 272 { 273 assert(instance); 274 /* init queues */ 275 hc_init_transfer_lists(instance); 276 277 /* init HCCA */ 278 instance->hcca = malloc32(sizeof(hcca_t)); 279 if (instance->hcca == NULL) 280 return ENOMEM; 281 bzero(instance->hcca, sizeof(hcca_t)); 282 instance->registers->hcca = addr_to_phys(instance->hcca); 283 284 /* use queues */ 285 instance->registers->bulk_head = instance->transfers_bulk.list_head_pa; 286 instance->registers->control_head = 287 instance->transfers_control.list_head_pa; 288 289 unsigned i = 0; 290 for (; i < 32; ++i) { 291 instance->hcca->int_ep[i] = 292 instance->transfers_interrupt.list_head_pa; 293 } 294 295 return EOK; 296 } 264 297 /** 265 298 * @} -
uspace/drv/ohci/hc.h
r6b6e3ed3 r344925c 56 56 rh_t rh; 57 57 58 hcca_t *hcca; 59 58 60 transfer_list_t transfers_isochronous; 59 61 transfer_list_t transfers_interrupt; -
uspace/drv/ohci/ohci_regs.h
r6b6e3ed3 r344925c 43 43 #define C_CSBR_MASK (0x3) 44 44 #define C_CSBR_SHIFT (0) 45 #define C_CSBR_1_1 (0x0) 46 #define C_CSBR_1_2 (0x1) 47 #define C_CSBR_1_3 (0x2) 48 #define C_CSBR_1_4 (0x3) 49 45 50 #define C_PLE (1 << 2) 46 51 #define C_IE (1 << 3) … … 90 95 volatile uint32_t interrupt_disable; 91 96 volatile uint32_t hcca; 92 volatile uint32_t period_c orrent;97 volatile uint32_t period_current; 93 98 volatile uint32_t control_head; 94 99 volatile uint32_t control_current;
Note:
See TracChangeset
for help on using the changeset viewer.