Changeset 620c710 in mainline for uspace/drv/bus/usb/ohci/hc.c
- Timestamp:
- 2011-08-25T14:21:57Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 961c29e8
- Parents:
- e20eaed
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hc.c
re20eaed r620c710 61 61 static int hc_init_memory(hc_t *instance); 62 62 static int interrupt_emulator(hc_t *instance); 63 63 /*----------------------------------------------------------------------------*/ 64 static int schedule(hcd_t *hcd, usb_transfer_batch_t *batch) 65 { 66 assert(hcd); 67 return hc_schedule(hcd->private_data, batch); 68 } 64 69 /*----------------------------------------------------------------------------*/ 65 70 /** Get number of commands used in IRQ code. … … 163 168 } 164 169 /*----------------------------------------------------------------------------*/ 165 static int schedule(hcd_t *hcd, usb_transfer_batch_t *batch)166 {167 assert(hcd);168 return hc_schedule(hcd->private_data, batch);169 }170 /*----------------------------------------------------------------------------*/171 170 /** Initialize OHCI hc driver structure 172 171 * … … 203 202 instance->generic.private_data = instance; 204 203 instance->generic.schedule = schedule; 205 instance->generic.ep_add_hook = ohci_endpoint_ assign;204 instance->generic.ep_add_hook = ohci_endpoint_init; 206 205 207 206 ret = hc_init_memory(instance); … … 224 223 225 224 return EOK; 225 } 226 /*----------------------------------------------------------------------------*/ 227 void hc_enqueue_endpoint(hc_t *instance, endpoint_t *ep) 228 { 229 endpoint_list_t *list = &instance->lists[ep->transfer_type]; 230 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 231 /* Enqueue ep */ 232 switch (ep->transfer_type) { 233 case USB_TRANSFER_CONTROL: 234 instance->registers->control &= ~C_CLE; 235 endpoint_list_add_ep(list, ohci_ep); 236 instance->registers->control_current = 0; 237 instance->registers->control |= C_CLE; 238 break; 239 case USB_TRANSFER_BULK: 240 instance->registers->control &= ~C_BLE; 241 endpoint_list_add_ep( 242 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 243 instance->registers->control |= C_BLE; 244 break; 245 case USB_TRANSFER_ISOCHRONOUS: 246 case USB_TRANSFER_INTERRUPT: 247 instance->registers->control &= (~C_PLE & ~C_IE); 248 endpoint_list_add_ep( 249 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 250 instance->registers->control |= C_PLE | C_IE; 251 break; 252 } 253 } 254 /*----------------------------------------------------------------------------*/ 255 void hc_dequeue_endpoint(hc_t *instance, endpoint_t *ep) 256 { 257 /* Dequeue ep */ 258 endpoint_list_t *list = &instance->lists[ep->transfer_type]; 259 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 260 switch (ep->transfer_type) { 261 case USB_TRANSFER_CONTROL: 262 instance->registers->control &= ~C_CLE; 263 endpoint_list_remove_ep(list, ohci_ep); 264 instance->registers->control_current = 0; 265 instance->registers->control |= C_CLE; 266 break; 267 case USB_TRANSFER_BULK: 268 instance->registers->control &= ~C_BLE; 269 endpoint_list_remove_ep(list, ohci_ep); 270 instance->registers->control |= C_BLE; 271 break; 272 case USB_TRANSFER_ISOCHRONOUS: 273 case USB_TRANSFER_INTERRUPT: 274 instance->registers->control &= (~C_PLE & ~C_IE); 275 endpoint_list_remove_ep(list, ohci_ep); 276 instance->registers->control |= C_PLE | C_IE; 277 break; 278 default: 279 break; 280 } 226 281 } 227 282 /*----------------------------------------------------------------------------*/ … … 249 304 return ENOMEM; 250 305 251 int ret = ohci_endpoint_ assign(&instance->generic, ep);306 int ret = ohci_endpoint_init(&instance->generic, ep); 252 307 if (ret != EOK) { 253 308 endpoint_destroy(ep); … … 260 315 return ret; 261 316 } 262 263 /* Enqueue ep */ 264 switch (ep->transfer_type) { 265 case USB_TRANSFER_CONTROL: 266 instance->registers->control &= ~C_CLE; 267 endpoint_list_add_ep( 268 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 269 instance->registers->control_current = 0; 270 instance->registers->control |= C_CLE; 271 break; 272 case USB_TRANSFER_BULK: 273 instance->registers->control &= ~C_BLE; 274 endpoint_list_add_ep( 275 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 276 instance->registers->control |= C_BLE; 277 break; 278 case USB_TRANSFER_ISOCHRONOUS: 279 case USB_TRANSFER_INTERRUPT: 280 instance->registers->control &= (~C_PLE & ~C_IE); 281 endpoint_list_add_ep( 282 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 283 instance->registers->control |= C_PLE | C_IE; 284 break; 285 } 317 hc_enqueue_endpoint(instance, ep); 286 318 287 319 return EOK; … … 311 343 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 312 344 if (ohci_ep) { 313 /* Dequeue ep */ 314 switch (ep->transfer_type) { 315 case USB_TRANSFER_CONTROL: 316 instance->registers->control &= ~C_CLE; 317 endpoint_list_remove_ep( 318 &instance->lists[ep->transfer_type], ohci_ep); 319 instance->registers->control_current = 0; 320 instance->registers->control |= C_CLE; 321 break; 322 case USB_TRANSFER_BULK: 323 instance->registers->control &= ~C_BLE; 324 endpoint_list_remove_ep( 325 &instance->lists[ep->transfer_type], ohci_ep); 326 instance->registers->control |= C_BLE; 327 break; 328 case USB_TRANSFER_ISOCHRONOUS: 329 case USB_TRANSFER_INTERRUPT: 330 instance->registers->control &= (~C_PLE & ~C_IE); 331 endpoint_list_remove_ep( 332 &instance->lists[ep->transfer_type], ohci_ep); 333 instance->registers->control |= C_PLE | C_IE; 334 break; 335 default: 336 break; 337 } 345 hc_dequeue_endpoint(instance, ep); 338 346 } else { 339 347 usb_log_warning("Endpoint without hcd equivalent structure.\n");
Note:
See TracChangeset
for help on using the changeset viewer.