Lines Matching full:ohci
2 * QEMU USB OHCI Emulation
39 #include "hcd-ohci.h"
144 /* OHCI Local stuff */
256 static void ohci_die(OHCIState *ohci) in ohci_die() argument
258 ohci->ohci_die(ohci); in ohci_die()
262 static inline void ohci_intr_update(OHCIState *ohci) in ohci_intr_update() argument
266 if ((ohci->intr & OHCI_INTR_MIE) && in ohci_intr_update()
267 (ohci->intr_status & ohci->intr)) in ohci_intr_update()
270 qemu_set_irq(ohci->irq, level); in ohci_intr_update()
274 static inline void ohci_set_interrupt(OHCIState *ohci, uint32_t intr) in ohci_set_interrupt() argument
276 ohci->intr_status |= intr; in ohci_set_interrupt()
277 ohci_intr_update(ohci); in ohci_set_interrupt()
280 static USBDevice *ohci_find_device(OHCIState *ohci, uint8_t addr) in ohci_find_device() argument
285 for (i = 0; i < ohci->num_ports; i++) { in ohci_find_device()
286 if ((ohci->rhport[i].ctrl & OHCI_PORT_PES) == 0) { in ohci_find_device()
289 dev = usb_find_device(&ohci->rhport[i].port, addr); in ohci_find_device()
297 void ohci_stop_endpoints(OHCIState *ohci) in ohci_stop_endpoints() argument
302 if (ohci->async_td) { in ohci_stop_endpoints()
303 usb_cancel_packet(&ohci->usb_packet); in ohci_stop_endpoints()
304 ohci->async_td = 0; in ohci_stop_endpoints()
306 for (i = 0; i < ohci->num_ports; i++) { in ohci_stop_endpoints()
307 dev = ohci->rhport[i].port.dev; in ohci_stop_endpoints()
318 static void ohci_roothub_reset(OHCIState *ohci) in ohci_roothub_reset() argument
323 ohci_bus_stop(ohci); in ohci_roothub_reset()
324 ohci->rhdesc_a = OHCI_RHA_NPS | ohci->num_ports; in ohci_roothub_reset()
325 ohci->rhdesc_b = 0x0; /* Impl. specific */ in ohci_roothub_reset()
326 ohci->rhstatus = 0; in ohci_roothub_reset()
328 for (i = 0; i < ohci->num_ports; i++) { in ohci_roothub_reset()
329 port = &ohci->rhport[i]; in ohci_roothub_reset()
335 ohci_stop_endpoints(ohci); in ohci_roothub_reset()
339 static void ohci_soft_reset(OHCIState *ohci) in ohci_soft_reset() argument
341 trace_usb_ohci_reset(ohci->name); in ohci_soft_reset()
343 ohci_bus_stop(ohci); in ohci_soft_reset()
344 ohci->ctl = (ohci->ctl & OHCI_CTL_IR) | OHCI_USB_SUSPEND; in ohci_soft_reset()
345 ohci->old_ctl = 0; in ohci_soft_reset()
346 ohci->status = 0; in ohci_soft_reset()
347 ohci->intr_status = 0; in ohci_soft_reset()
348 ohci->intr = OHCI_INTR_MIE; in ohci_soft_reset()
350 ohci->hcca = 0; in ohci_soft_reset()
351 ohci->ctrl_head = ohci->ctrl_cur = 0; in ohci_soft_reset()
352 ohci->bulk_head = ohci->bulk_cur = 0; in ohci_soft_reset()
353 ohci->per_cur = 0; in ohci_soft_reset()
354 ohci->done = 0; in ohci_soft_reset()
355 ohci->done_count = 7; in ohci_soft_reset()
360 ohci->fsmps = 0x2778; in ohci_soft_reset()
361 ohci->fi = 0x2edf; in ohci_soft_reset()
362 ohci->fit = 0; in ohci_soft_reset()
363 ohci->frt = 0; in ohci_soft_reset()
364 ohci->frame_number = 0; in ohci_soft_reset()
365 ohci->pstart = 0; in ohci_soft_reset()
366 ohci->lst = OHCI_LS_THRESH; in ohci_soft_reset()
369 void ohci_hard_reset(OHCIState *ohci) in ohci_hard_reset() argument
371 ohci_soft_reset(ohci); in ohci_hard_reset()
372 ohci->ctl = 0; in ohci_hard_reset()
373 ohci_roothub_reset(ohci); in ohci_hard_reset()
377 static inline int get_dwords(OHCIState *ohci, in get_dwords() argument
382 addr += ohci->localmem_base; in get_dwords()
385 if (dma_memory_read(ohci->as, addr, in get_dwords()
396 static inline int put_dwords(OHCIState *ohci, in put_dwords() argument
401 addr += ohci->localmem_base; in put_dwords()
405 if (dma_memory_write(ohci->as, addr, in put_dwords()
415 static inline int get_words(OHCIState *ohci, in get_words() argument
420 addr += ohci->localmem_base; in get_words()
423 if (dma_memory_read(ohci->as, addr, in get_words()
434 static inline int put_words(OHCIState *ohci, in put_words() argument
439 addr += ohci->localmem_base; in put_words()
443 if (dma_memory_write(ohci->as, addr, in put_words()
452 static inline int ohci_read_ed(OHCIState *ohci, in ohci_read_ed() argument
455 return get_dwords(ohci, addr, (uint32_t *)ed, sizeof(*ed) >> 2); in ohci_read_ed()
458 static inline int ohci_read_td(OHCIState *ohci, in ohci_read_td() argument
461 return get_dwords(ohci, addr, (uint32_t *)td, sizeof(*td) >> 2); in ohci_read_td()
464 static inline int ohci_read_iso_td(OHCIState *ohci, in ohci_read_iso_td() argument
467 return get_dwords(ohci, addr, (uint32_t *)td, 4) || in ohci_read_iso_td()
468 get_words(ohci, addr + 16, td->offset, 8); in ohci_read_iso_td()
471 static inline int ohci_read_hcca(OHCIState *ohci, in ohci_read_hcca() argument
474 return dma_memory_read(ohci->as, addr + ohci->localmem_base, hcca, in ohci_read_hcca()
478 static inline int ohci_put_ed(OHCIState *ohci, in ohci_put_ed() argument
485 return put_dwords(ohci, addr + ED_WBACK_OFFSET, in ohci_put_ed()
490 static inline int ohci_put_td(OHCIState *ohci, in ohci_put_td() argument
493 return put_dwords(ohci, addr, (uint32_t *)td, sizeof(*td) >> 2); in ohci_put_td()
496 static inline int ohci_put_iso_td(OHCIState *ohci, in ohci_put_iso_td() argument
499 return put_dwords(ohci, addr, (uint32_t *)td, 4) || in ohci_put_iso_td()
500 put_words(ohci, addr + 16, td->offset, 8); in ohci_put_iso_td()
503 static inline int ohci_put_hcca(OHCIState *ohci, in ohci_put_hcca() argument
506 return dma_memory_write(ohci->as, in ohci_put_hcca()
507 addr + ohci->localmem_base + HCCA_WRITEBACK_OFFSET, in ohci_put_hcca()
513 static int ohci_copy_td(OHCIState *ohci, struct ohci_td *td, in ohci_copy_td() argument
523 if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, in ohci_copy_td()
532 if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, in ohci_copy_td()
540 static int ohci_copy_iso_td(OHCIState *ohci, in ohci_copy_iso_td() argument
551 if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, in ohci_copy_iso_td()
560 if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, in ohci_copy_iso_td()
569 static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed) in ohci_service_iso_td() argument
593 ohci_die(ohci); in ohci_service_iso_td()
597 if (ohci_read_iso_td(ohci, addr, &iso_td)) { in ohci_service_iso_td()
599 ohci_die(ohci); in ohci_service_iso_td()
605 relative_frame_number = USUB(ohci->frame_number, starting_frame); in ohci_service_iso_td()
610 ohci->frame_number, starting_frame, in ohci_service_iso_td()
635 iso_td.next = ohci->done; in ohci_service_iso_td()
636 ohci->done = addr; in ohci_service_iso_td()
638 if (i < ohci->done_count) { in ohci_service_iso_td()
639 ohci->done_count = i; in ohci_service_iso_td()
641 if (ohci_put_iso_td(ohci, addr, &iso_td)) { in ohci_service_iso_td()
642 ohci_die(ohci); in ohci_service_iso_td()
729 if (ohci_copy_iso_td(ohci, start_addr, end_addr, buf, len, in ohci_service_iso_td()
731 ohci_die(ohci); in ohci_service_iso_td()
736 dev = ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA)); in ohci_service_iso_td()
767 if (ohci_copy_iso_td(ohci, start_addr, end_addr, buf, ret, in ohci_service_iso_td()
769 ohci_die(ohci); in ohci_service_iso_td()
822 iso_td.next = ohci->done; in ohci_service_iso_td()
823 ohci->done = addr; in ohci_service_iso_td()
825 if (i < ohci->done_count) { in ohci_service_iso_td()
826 ohci->done_count = i; in ohci_service_iso_td()
829 if (ohci_put_iso_td(ohci, addr, &iso_td)) { in ohci_service_iso_td()
830 ohci_die(ohci); in ohci_service_iso_td()
874 static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed) in ohci_service_td() argument
891 ohci_die(ohci); in ohci_service_td()
896 completion = (addr == ohci->async_td); in ohci_service_td()
897 if (completion && !ohci->async_complete) { in ohci_service_td()
901 if (ohci_read_td(ohci, addr, &td)) { in ohci_service_td()
903 ohci_die(ohci); in ohci_service_td()
932 ohci_die(ohci); in ohci_service_td()
946 ohci_die(ohci); in ohci_service_td()
951 if (len > sizeof(ohci->usb_buf)) { in ohci_service_td()
952 len = sizeof(ohci->usb_buf); in ohci_service_td()
963 if (ohci_copy_td(ohci, &td, ohci->usb_buf, pktlen, in ohci_service_td()
965 ohci_die(ohci); in ohci_service_td()
974 ohci_td_pkt("OUT", ohci->usb_buf, pktlen); in ohci_service_td()
977 ohci->async_td = 0; in ohci_service_td()
978 ohci->async_complete = false; in ohci_service_td()
980 dev = ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA)); in ohci_service_td()
986 if (ohci->async_td) { in ohci_service_td()
996 usb_packet_setup(&ohci->usb_packet, pid, ep, 0, addr, !flag_r, in ohci_service_td()
998 usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, pktlen); in ohci_service_td()
999 usb_handle_packet(dev, &ohci->usb_packet); in ohci_service_td()
1000 trace_usb_ohci_td_packet_status(ohci->usb_packet.status); in ohci_service_td()
1002 if (ohci->usb_packet.status == USB_RET_ASYNC) { in ohci_service_td()
1004 ohci->async_td = addr; in ohci_service_td()
1008 if (ohci->usb_packet.status == USB_RET_SUCCESS) { in ohci_service_td()
1009 ret = ohci->usb_packet.actual_length; in ohci_service_td()
1011 ret = ohci->usb_packet.status; in ohci_service_td()
1016 if (ohci_copy_td(ohci, &td, ohci->usb_buf, ret, in ohci_service_td()
1018 ohci_die(ohci); in ohci_service_td()
1020 ohci_td_pkt("IN", ohci->usb_buf, pktlen); in ohci_service_td()
1085 ohci->done_count = 0; in ohci_service_td()
1093 td.next = ohci->done; in ohci_service_td()
1094 ohci->done = addr; in ohci_service_td()
1096 if (i < ohci->done_count) { in ohci_service_td()
1097 ohci->done_count = i; in ohci_service_td()
1100 if (ohci_put_td(ohci, addr, &td)) { in ohci_service_td()
1101 ohci_die(ohci); in ohci_service_td()
1108 static int ohci_service_ed_list(OHCIState *ohci, uint32_t head) in ohci_service_ed_list() argument
1121 if (ohci_read_ed(ohci, cur, &ed)) { in ohci_service_ed_list()
1123 ohci_die(ohci); in ohci_service_ed_list()
1133 if (ohci->async_td && addr == ohci->async_td) { in ohci_service_ed_list()
1134 usb_cancel_packet(&ohci->usb_packet); in ohci_service_ed_list()
1135 ohci->async_td = 0; in ohci_service_ed_list()
1136 usb_device_ep_stopped(ohci->usb_packet.ep->dev, in ohci_service_ed_list()
1137 ohci->usb_packet.ep); in ohci_service_ed_list()
1155 if (ohci_service_td(ohci, &ed)) { in ohci_service_ed_list()
1160 if (ohci_service_iso_td(ohci, &ed)) { in ohci_service_ed_list()
1166 if (ohci_put_ed(ohci, cur, &ed)) { in ohci_service_ed_list()
1167 ohci_die(ohci); in ohci_service_ed_list()
1176 static void ohci_eof_timer(OHCIState *ohci) in ohci_eof_timer() argument
1178 timer_mod(ohci->eof_timer, ohci->sof_time + usb_frame_time); in ohci_eof_timer()
1181 static void ohci_sof(OHCIState *ohci) in ohci_sof() argument
1183 ohci->sof_time += usb_frame_time; in ohci_sof()
1184 ohci_eof_timer(ohci); in ohci_sof()
1185 ohci_set_interrupt(ohci, OHCI_INTR_SF); in ohci_sof()
1189 static void ohci_process_lists(OHCIState *ohci) in ohci_process_lists() argument
1191 if ((ohci->ctl & OHCI_CTL_CLE) && (ohci->status & OHCI_STATUS_CLF)) { in ohci_process_lists()
1192 if (ohci->ctrl_cur && ohci->ctrl_cur != ohci->ctrl_head) { in ohci_process_lists()
1193 trace_usb_ohci_process_lists(ohci->ctrl_head, ohci->ctrl_cur); in ohci_process_lists()
1195 if (!ohci_service_ed_list(ohci, ohci->ctrl_head)) { in ohci_process_lists()
1196 ohci->ctrl_cur = 0; in ohci_process_lists()
1197 ohci->status &= ~OHCI_STATUS_CLF; in ohci_process_lists()
1201 if ((ohci->ctl & OHCI_CTL_BLE) && (ohci->status & OHCI_STATUS_BLF)) { in ohci_process_lists()
1202 if (!ohci_service_ed_list(ohci, ohci->bulk_head)) { in ohci_process_lists()
1203 ohci->bulk_cur = 0; in ohci_process_lists()
1204 ohci->status &= ~OHCI_STATUS_BLF; in ohci_process_lists()
1212 OHCIState *ohci = opaque; in ohci_frame_boundary() local
1215 if (ohci_read_hcca(ohci, ohci->hcca, &hcca)) { in ohci_frame_boundary()
1216 trace_usb_ohci_hcca_read_error(ohci->hcca); in ohci_frame_boundary()
1217 ohci_die(ohci); in ohci_frame_boundary()
1222 if (ohci->ctl & OHCI_CTL_PLE) { in ohci_frame_boundary()
1225 n = ohci->frame_number & 0x1f; in ohci_frame_boundary()
1226 ohci_service_ed_list(ohci, le32_to_cpu(hcca.intr[n])); in ohci_frame_boundary()
1230 if (ohci->old_ctl & (~ohci->ctl) & (OHCI_CTL_BLE | OHCI_CTL_CLE)) { in ohci_frame_boundary()
1231 ohci_stop_endpoints(ohci); in ohci_frame_boundary()
1233 ohci->old_ctl = ohci->ctl; in ohci_frame_boundary()
1234 ohci_process_lists(ohci); in ohci_frame_boundary()
1237 if (ohci->intr_status & OHCI_INTR_UE) { in ohci_frame_boundary()
1242 ohci->frt = ohci->fit; in ohci_frame_boundary()
1245 ohci->frame_number = (ohci->frame_number + 1) & 0xffff; in ohci_frame_boundary()
1246 hcca.frame = cpu_to_le16(ohci->frame_number); in ohci_frame_boundary()
1247 /* When the HC updates frame number, set pad to 0. Ref OHCI Spec 4.4.1*/ in ohci_frame_boundary()
1250 if (ohci->done_count == 0 && !(ohci->intr_status & OHCI_INTR_WD)) { in ohci_frame_boundary()
1251 if (!ohci->done) { in ohci_frame_boundary()
1254 if (ohci->intr & ohci->intr_status) { in ohci_frame_boundary()
1255 ohci->done |= 1; in ohci_frame_boundary()
1257 hcca.done = cpu_to_le32(ohci->done); in ohci_frame_boundary()
1258 ohci->done = 0; in ohci_frame_boundary()
1259 ohci->done_count = 7; in ohci_frame_boundary()
1260 ohci_set_interrupt(ohci, OHCI_INTR_WD); in ohci_frame_boundary()
1263 if (ohci->done_count != 7 && ohci->done_count != 0) { in ohci_frame_boundary()
1264 ohci->done_count--; in ohci_frame_boundary()
1267 ohci_sof(ohci); in ohci_frame_boundary()
1270 if (ohci_put_hcca(ohci, ohci->hcca, &hcca)) { in ohci_frame_boundary()
1271 ohci_die(ohci); in ohci_frame_boundary()
1279 static int ohci_bus_start(OHCIState *ohci) in ohci_bus_start() argument
1281 trace_usb_ohci_start(ohci->name); in ohci_bus_start()
1286 ohci->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); in ohci_bus_start()
1287 ohci_eof_timer(ohci); in ohci_bus_start()
1293 void ohci_bus_stop(OHCIState *ohci) in ohci_bus_stop() argument
1295 trace_usb_ohci_stop(ohci->name); in ohci_bus_stop()
1296 timer_del(ohci->eof_timer); in ohci_bus_stop()
1300 static void ohci_set_frame_interval(OHCIState *ohci, uint16_t val) in ohci_set_frame_interval() argument
1304 if (val != ohci->fi) { in ohci_set_frame_interval()
1305 trace_usb_ohci_set_frame_interval(ohci->name, ohci->fi, ohci->fi); in ohci_set_frame_interval()
1308 ohci->fi = val; in ohci_set_frame_interval()
1311 static void ohci_port_power(OHCIState *ohci, int i, int p) in ohci_port_power() argument
1314 ohci->rhport[i].ctrl |= OHCI_PORT_PPS; in ohci_port_power()
1316 ohci->rhport[i].ctrl &= ~(OHCI_PORT_PPS | OHCI_PORT_CCS | in ohci_port_power()
1322 static void ohci_set_ctl(OHCIState *ohci, uint32_t val) in ohci_set_ctl() argument
1327 old_state = ohci->ctl & OHCI_CTL_HCFS; in ohci_set_ctl()
1328 ohci->ctl = val; in ohci_set_ctl()
1329 new_state = ohci->ctl & OHCI_CTL_HCFS; in ohci_set_ctl()
1335 trace_usb_ohci_set_ctl(ohci->name, new_state); in ohci_set_ctl()
1338 ohci_bus_start(ohci); in ohci_set_ctl()
1341 ohci_bus_stop(ohci); in ohci_set_ctl()
1343 ohci->intr_status &= ~OHCI_INTR_SF; in ohci_set_ctl()
1344 ohci_intr_update(ohci); in ohci_set_ctl()
1347 trace_usb_ohci_resume(ohci->name); in ohci_set_ctl()
1350 ohci_roothub_reset(ohci); in ohci_set_ctl()
1355 static uint32_t ohci_get_frame_remaining(OHCIState *ohci) in ohci_get_frame_remaining() argument
1360 if ((ohci->ctl & OHCI_CTL_HCFS) != OHCI_USB_OPERATIONAL) { in ohci_get_frame_remaining()
1361 return ohci->frt << 31; in ohci_get_frame_remaining()
1364 tks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - ohci->sof_time; in ohci_get_frame_remaining()
1371 return ohci->frt << 31; in ohci_get_frame_remaining()
1374 fr = (uint16_t)(ohci->fi - tks); in ohci_get_frame_remaining()
1376 return (ohci->frt << 31) | fr; in ohci_get_frame_remaining()
1381 static void ohci_set_hub_status(OHCIState *ohci, uint32_t val) in ohci_set_hub_status() argument
1385 old_state = ohci->rhstatus; in ohci_set_hub_status()
1389 ohci->rhstatus &= ~OHCI_RHS_OCIC; in ohci_set_hub_status()
1394 for (i = 0; i < ohci->num_ports; i++) { in ohci_set_hub_status()
1395 ohci_port_power(ohci, i, 0); in ohci_set_hub_status()
1403 for (i = 0; i < ohci->num_ports; i++) { in ohci_set_hub_status()
1404 ohci_port_power(ohci, i, 1); in ohci_set_hub_status()
1410 ohci->rhstatus |= OHCI_RHS_DRWE; in ohci_set_hub_status()
1413 ohci->rhstatus &= ~OHCI_RHS_DRWE; in ohci_set_hub_status()
1415 if (old_state != ohci->rhstatus) { in ohci_set_hub_status()
1416 ohci_set_interrupt(ohci, OHCI_INTR_RHSC); in ohci_set_hub_status()
1436 static int ohci_port_set_if_connected(OHCIState *ohci, int i, uint32_t val) in ohci_port_set_if_connected() argument
1445 if (!(ohci->rhport[i].ctrl & OHCI_PORT_CCS)) { in ohci_port_set_if_connected()
1446 ohci->rhport[i].ctrl |= OHCI_PORT_CSC; in ohci_port_set_if_connected()
1447 if (ohci->rhstatus & OHCI_RHS_DRWE) { in ohci_port_set_if_connected()
1449 if (ohci_resume(ohci)) { in ohci_port_set_if_connected()
1450 ohci_set_interrupt(ohci, OHCI_INTR_RD); in ohci_port_set_if_connected()
1456 if (ohci->rhport[i].ctrl & val) { in ohci_port_set_if_connected()
1460 ohci->rhport[i].ctrl |= val; in ohci_port_set_if_connected()
1466 static void ohci_port_set_status(OHCIState *ohci, int portnum, uint32_t val) in ohci_port_set_status() argument
1471 port = &ohci->rhport[portnum]; in ohci_port_set_status()
1481 ohci_port_set_if_connected(ohci, portnum, val & OHCI_PORT_PES); in ohci_port_set_status()
1483 if (ohci_port_set_if_connected(ohci, portnum, val & OHCI_PORT_PSS)) { in ohci_port_set_status()
1487 if (ohci_port_set_if_connected(ohci, portnum, val & OHCI_PORT_PRS)) { in ohci_port_set_status()
1497 ohci_port_power(ohci, portnum, 0); in ohci_port_set_status()
1500 ohci_port_power(ohci, portnum, 1); in ohci_port_set_status()
1503 ohci_set_interrupt(ohci, OHCI_INTR_RHSC); in ohci_port_set_status()
1511 OHCIState *ohci = opaque; in ohci_mem_read() local
1514 /* Only aligned reads are allowed on OHCI */ in ohci_mem_read()
1518 } else if (addr >= 0x54 && addr < 0x54 + ohci->num_ports * 4) { in ohci_mem_read()
1520 retval = ohci->rhport[(addr - 0x54) >> 2].ctrl | OHCI_PORT_PPS; in ohci_mem_read()
1530 retval = ohci->ctl; in ohci_mem_read()
1534 retval = ohci->status; in ohci_mem_read()
1538 retval = ohci->intr_status; in ohci_mem_read()
1543 retval = ohci->intr; in ohci_mem_read()
1547 retval = ohci->hcca; in ohci_mem_read()
1551 retval = ohci->per_cur; in ohci_mem_read()
1555 retval = ohci->ctrl_head; in ohci_mem_read()
1559 retval = ohci->ctrl_cur; in ohci_mem_read()
1563 retval = ohci->bulk_head; in ohci_mem_read()
1567 retval = ohci->bulk_cur; in ohci_mem_read()
1571 retval = ohci->done; in ohci_mem_read()
1575 retval = (ohci->fit << 31) | (ohci->fsmps << 16) | (ohci->fi); in ohci_mem_read()
1579 retval = ohci_get_frame_remaining(ohci); in ohci_mem_read()
1583 retval = ohci->frame_number; in ohci_mem_read()
1587 retval = ohci->pstart; in ohci_mem_read()
1591 retval = ohci->lst; in ohci_mem_read()
1595 retval = ohci->rhdesc_a; in ohci_mem_read()
1599 retval = ohci->rhdesc_b; in ohci_mem_read()
1603 retval = ohci->rhstatus; in ohci_mem_read()
1608 retval = ohci->hstatus & ohci->hmask; in ohci_mem_read()
1612 retval = ohci->hreset; in ohci_mem_read()
1616 retval = ohci->hmask; in ohci_mem_read()
1620 retval = ohci->htest; in ohci_mem_read()
1641 OHCIState *ohci = opaque; in ohci_mem_write() local
1643 /* Only aligned reads are allowed on OHCI */ in ohci_mem_write()
1649 if (addr >= 0x54 && addr < 0x54 + ohci->num_ports * 4) { in ohci_mem_write()
1653 ohci_port_set_status(ohci, (addr - 0x54) >> 2, val); in ohci_mem_write()
1660 ohci_set_ctl(ohci, val); in ohci_mem_write()
1668 ohci->status |= val; in ohci_mem_write()
1670 if (ohci->status & OHCI_STATUS_HCR) { in ohci_mem_write()
1671 ohci_soft_reset(ohci); in ohci_mem_write()
1676 ohci->intr_status &= ~val; in ohci_mem_write()
1677 ohci_intr_update(ohci); in ohci_mem_write()
1681 ohci->intr |= val; in ohci_mem_write()
1682 ohci_intr_update(ohci); in ohci_mem_write()
1686 ohci->intr &= ~val; in ohci_mem_write()
1687 ohci_intr_update(ohci); in ohci_mem_write()
1691 ohci->hcca = val & OHCI_HCCA_MASK; in ohci_mem_write()
1699 ohci->ctrl_head = val & OHCI_EDPTR_MASK; in ohci_mem_write()
1703 ohci->ctrl_cur = val & OHCI_EDPTR_MASK; in ohci_mem_write()
1707 ohci->bulk_head = val & OHCI_EDPTR_MASK; in ohci_mem_write()
1711 ohci->bulk_cur = val & OHCI_EDPTR_MASK; in ohci_mem_write()
1715 ohci->fsmps = (val & OHCI_FMI_FSMPS) >> 16; in ohci_mem_write()
1716 ohci->fit = (val & OHCI_FMI_FIT) >> 31; in ohci_mem_write()
1717 ohci_set_frame_interval(ohci, val); in ohci_mem_write()
1724 ohci->pstart = val & 0xffff; in ohci_mem_write()
1728 ohci->lst = val & 0xffff; in ohci_mem_write()
1732 ohci->rhdesc_a &= ~OHCI_RHA_RW_MASK; in ohci_mem_write()
1733 ohci->rhdesc_a |= val & OHCI_RHA_RW_MASK; in ohci_mem_write()
1740 ohci_set_hub_status(ohci, val); in ohci_mem_write()
1745 ohci->hstatus &= ~(val & ohci->hmask); in ohci_mem_write()
1749 ohci->hreset = val & ~OHCI_HRESET_FSBIR; in ohci_mem_write()
1751 ohci_hard_reset(ohci); in ohci_mem_write()
1756 ohci->hmask = val; in ohci_mem_write()
1760 ohci->htest = val; in ohci_mem_write()
1806 OHCIState *ohci = port1->opaque; in ohci_child_detach() local
1808 if (ohci->async_td && in ohci_child_detach()
1809 usb_packet_is_inflight(&ohci->usb_packet) && in ohci_child_detach()
1810 ohci->usb_packet.ep->dev == dev) { in ohci_child_detach()
1811 usb_cancel_packet(&ohci->usb_packet); in ohci_child_detach()
1812 ohci->async_td = 0; in ohci_child_detach()
1856 * see the OHCI spec 5.1.2.3. in ohci_wakeup()
1865 OHCIState *ohci = container_of(packet, OHCIState, usb_packet); in ohci_async_complete_packet() local
1868 ohci->async_complete = true; in ohci_async_complete_packet()
1869 ohci_process_lists(ohci); in ohci_async_complete_packet()
1883 void usb_ohci_init(OHCIState *ohci, DeviceState *dev, uint32_t num_ports, in usb_ohci_init() argument
1891 ohci->as = as; in usb_ohci_init()
1892 ohci->ohci_die = ohci_die_fn; in usb_ohci_init()
1895 error_setg(errp, "OHCI num-ports=%u is too big (limit is %u ports)", in usb_ohci_init()
1915 ohci->num_ports = num_ports; in usb_ohci_init()
1919 ports[i] = &ohci->rhport[i].port; in usb_ohci_init()
1922 firstport, ohci, &ohci_port_ops, in usb_ohci_init()
1930 usb_bus_new(&ohci->bus, sizeof(ohci->bus), &ohci_bus_ops, dev); in usb_ohci_init()
1932 usb_register_port(&ohci->bus, &ohci->rhport[i].port, in usb_ohci_init()
1933 ohci, i, &ohci_port_ops, in usb_ohci_init()
1938 memory_region_init_io(&ohci->mem, OBJECT(dev), &ohci_mem_ops, in usb_ohci_init()
1939 ohci, "ohci", 256); in usb_ohci_init()
1940 ohci->localmem_base = localmem_base; in usb_ohci_init()
1942 ohci->name = object_get_typename(OBJECT(dev)); in usb_ohci_init()
1943 usb_packet_init(&ohci->usb_packet); in usb_ohci_init()
1945 ohci->async_td = 0; in usb_ohci_init()
1947 ohci->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, in usb_ohci_init()
1948 ohci_frame_boundary, ohci); in usb_ohci_init()
1952 * A typical OHCI will stop operating and set itself into error state
1955 void ohci_sysbus_die(struct OHCIState *ohci) in ohci_sysbus_die() argument
1959 ohci_set_interrupt(ohci, OHCI_INTR_UE); in ohci_sysbus_die()
1960 ohci_bus_stop(ohci); in ohci_sysbus_die()
1964 .name = "ohci-core/port",
1975 OHCIState *ohci = opaque; in ohci_eof_timer_needed() local
1977 return timer_pending(ohci->eof_timer); in ohci_eof_timer_needed()
1981 .name = "ohci-core/eof-timer",
1992 .name = "ohci-core",