Lines Matching +full:remote +full:- +full:endpoint
36 #include "hw/qdev-dma.h"
37 #include "hw/qdev-properties.h"
39 #include "hcd-ohci.h"
61 /* Bitfields for the first word of an Endpoint Descriptor. */
74 /* Flags in the head field of an Endpoint Descriptor. */
92 /* CC & DI - same as in the General Transfer Descriptor */
98 /* Isochronous Transfer Descriptor - Offset / PacketStatusWord */
117 /* endpoint descriptor */
258 ohci->ohci_die(ohci); in ohci_die()
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()
276 ohci->intr_status |= intr; in ohci_set_interrupt()
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()
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()
308 if (dev && dev->attached) { in ohci_stop_endpoints()
309 usb_device_ep_stopped(dev, &dev->ep_ctl); in ohci_stop_endpoints()
311 usb_device_ep_stopped(dev, &dev->ep_in[j]); in ohci_stop_endpoints()
312 usb_device_ep_stopped(dev, &dev->ep_out[j]); in ohci_stop_endpoints()
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()
330 port->ctrl = 0; in ohci_roothub_reset()
331 if (port->port.dev && port->port.dev->attached) { in ohci_roothub_reset()
332 usb_port_reset(&port->port); in ohci_roothub_reset()
341 trace_usb_ohci_reset(ohci->name); 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()
372 ohci->ctl = 0; in ohci_hard_reset()
382 addr += ohci->localmem_base; in get_dwords()
385 if (dma_memory_read(ohci->as, addr, in get_dwords()
387 return -1; in get_dwords()
401 addr += ohci->localmem_base; in put_dwords()
405 if (dma_memory_write(ohci->as, addr, in put_dwords()
407 return -1; in put_dwords()
420 addr += ohci->localmem_base; in get_words()
423 if (dma_memory_read(ohci->as, addr, in get_words()
425 return -1; in get_words()
439 addr += ohci->localmem_base; in put_words()
443 if (dma_memory_write(ohci->as, addr, in put_words()
445 return -1; in put_words()
468 get_words(ohci, addr + 16, td->offset, 8); in ohci_read_iso_td()
474 return dma_memory_read(ohci->as, addr + ohci->localmem_base, hcca, in ohci_read_hcca()
482 * ed->tail is under control of the HCD. in ohci_put_ed()
483 * Since just ed->head is changed by HC, just write back this in ohci_put_ed()
500 put_words(ohci, addr + 16, td->offset, 8); in ohci_put_iso_td()
506 return dma_memory_write(ohci->as, in ohci_put_hcca()
507 addr + ohci->localmem_base + HCCA_WRITEBACK_OFFSET, in ohci_put_hcca()
518 ptr = td->cbp; in ohci_copy_td()
519 n = 0x1000 - (ptr & 0xfff); in ohci_copy_td()
523 if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, in ohci_copy_td()
525 return -1; in ohci_copy_td()
530 ptr = td->be & ~0xfffu; in ohci_copy_td()
532 if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, in ohci_copy_td()
533 len - n, dir, MEMTXATTRS_UNSPECIFIED)) { in ohci_copy_td()
534 return -1; in ohci_copy_td()
547 n = 0x1000 - (ptr & 0xfff); in ohci_copy_iso_td()
551 if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, in ohci_copy_iso_td()
553 return -1; in ohci_copy_iso_td()
560 if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, in ohci_copy_iso_td()
561 len - n, dir, MEMTXATTRS_UNSPECIFIED)) { in ohci_copy_iso_td()
562 return -1; in ohci_copy_iso_td()
567 #define USUB(a, b) ((int16_t)((uint16_t)(a) - (uint16_t)(b)))
590 addr = ed->head & OHCI_DPTR_MASK; in ohci_service_iso_td()
605 relative_frame_number = USUB(ohci->frame_number, starting_frame); in ohci_service_iso_td()
608 ed->head & OHCI_DPTR_MASK, ed->tail & OHCI_DPTR_MASK, in ohci_service_iso_td()
610 ohci->frame_number, starting_frame, in ohci_service_iso_td()
623 * ISO TD expired - retire the TD to the Done Queue and continue with in ohci_service_iso_td()
633 ed->head &= ~OHCI_DPTR_MASK; in ohci_service_iso_td()
634 ed->head |= (iso_td.next & OHCI_DPTR_MASK); 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()
648 dir = OHCI_BM(ed->flags, ED_D); in ohci_service_iso_td()
700 end_offset = next_offset - 1; in ohci_service_iso_td()
720 - (start_addr & OHCI_OFFSET_MASK); in ohci_service_iso_td()
722 len = end_addr - start_addr + 1; in ohci_service_iso_td()
736 dev = ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA)); in ohci_service_iso_td()
741 ep = usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN)); in ohci_service_iso_td()
749 if (pkt->status == USB_RET_ASYNC) { in ohci_service_iso_td()
754 if (pkt->status == USB_RET_SUCCESS) { in ohci_service_iso_td()
755 ret = pkt->actual_length; in ohci_service_iso_td()
757 ret = pkt->status; in ohci_service_iso_td()
818 /* Last data packet of ISO TD - retire the TD to the Done Queue */ in ohci_service_iso_td()
820 ed->head &= ~OHCI_DPTR_MASK; in ohci_service_iso_td()
821 ed->head |= (iso_td.next & OHCI_DPTR_MASK); 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()
872 * Returns nonzero to terminate processing of this endpoint.
889 addr = ed->head & OHCI_DPTR_MASK; in ohci_service_td()
896 completion = (addr == ohci->async_td); in ohci_service_td()
897 if (completion && !ohci->async_complete) { in ohci_service_td()
907 dir = OHCI_BM(ed->flags, ED_D); in ohci_service_td()
930 if (OHCI_BM(ed->flags, ED_EN) > 0) { /* setup only allowed to ep 0 */ in ohci_service_td()
931 trace_usb_ohci_td_bad_pid(str, ed->flags, td.flags); in ohci_service_td()
942 len = (td.be & 0xfff) + 0x1001 - (td.cbp & 0xfff); in ohci_service_td()
944 if (td.cbp - 1 > td.be) { /* rely on td.cbp != 0 */ in ohci_service_td()
949 len = (td.be - td.cbp) + 1; 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()
957 /* The endpoint may not allow us to transfer it all now */ in ohci_service_td()
958 pktlen = (ed->flags & OHCI_ED_MPS_MASK) >> OHCI_ED_MPS_SHIFT; in ohci_service_td()
963 if (ohci_copy_td(ohci, &td, ohci->usb_buf, pktlen, 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()
985 ep = usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN)); in ohci_service_td()
986 if (ohci->async_td) { in ohci_service_td()
989 * endpoint. We only allow one active packet per controller. in ohci_service_td()
993 trace_usb_ohci_td_too_many_pending(ep->nr); 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()
1020 ohci_td_pkt("IN", ohci->usb_buf, pktlen); in ohci_service_td()
1049 ed->head &= ~OHCI_ED_C; in ohci_service_td()
1051 ed->head |= OHCI_ED_C; in ohci_service_td()
1085 ohci->done_count = 0; in ohci_service_td()
1087 ed->head |= OHCI_ED_H; in ohci_service_td()
1091 ed->head &= ~OHCI_DPTR_MASK; in ohci_service_td()
1092 ed->head |= td.next & OHCI_DPTR_MASK; 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()
1107 /* Service an endpoint list. Returns nonzero if active TD were found. */
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()
1178 timer_mod(ohci->eof_timer, ohci->sof_time + usb_frame_time); in ohci_eof_timer()
1183 ohci->sof_time += usb_frame_time; in ohci_sof()
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()
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()
1222 if (ohci->ctl & OHCI_CTL_PLE) { in ohci_frame_boundary()
1225 n = ohci->frame_number & 0x1f; in ohci_frame_boundary()
1230 if (ohci->old_ctl & (~ohci->ctl) & (OHCI_CTL_BLE | OHCI_CTL_CLE)) { in ohci_frame_boundary()
1233 ohci->old_ctl = ohci->ctl; 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()
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()
1263 if (ohci->done_count != 7 && ohci->done_count != 0) { in ohci_frame_boundary()
1264 ohci->done_count--; in ohci_frame_boundary()
1270 if (ohci_put_hcca(ohci, ohci->hcca, &hcca)) { in ohci_frame_boundary()
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()
1295 trace_usb_ohci_stop(ohci->name); in ohci_bus_stop()
1296 timer_del(ohci->eof_timer); in ohci_bus_stop()
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()
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()
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()
1343 ohci->intr_status &= ~OHCI_INTR_SF; in ohci_set_ctl()
1347 trace_usb_ohci_resume(ohci->name); in ohci_set_ctl()
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()
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()
1403 for (i = 0; i < ohci->num_ports; i++) { 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()
1423 if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) { in ohci_resume()
1424 trace_usb_ohci_remote_wakeup(s->name); in ohci_resume()
1425 s->ctl &= ~OHCI_CTL_HCFS; in ohci_resume()
1426 s->ctl |= OHCI_USB_RESUME; in ohci_resume()
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()
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()
1471 port = &ohci->rhport[portnum]; in ohci_port_set_status()
1472 old_state = port->ctrl; in ohci_port_set_status()
1476 port->ctrl &= ~(val & OHCI_PORT_WTC); in ohci_port_set_status()
1479 port->ctrl &= ~OHCI_PORT_PES; in ohci_port_set_status()
1489 usb_device_reset(port->port.dev); in ohci_port_set_status()
1490 port->ctrl &= ~OHCI_PORT_PRS; in ohci_port_set_status()
1492 port->ctrl |= OHCI_PORT_PES | OHCI_PORT_PRSC; in ohci_port_set_status()
1502 if (old_state != port->ctrl) { in ohci_port_set_status()
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()
1521 trace_usb_ohci_mem_port_read(size, "HcRhPortStatus", (addr - 0x50) >> 2, 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()
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()
1649 if (addr >= 0x54 && addr < 0x54 + ohci->num_ports * 4) { in ohci_mem_write()
1652 (addr - 0x50) >> 2, addr, addr >> 2, val); in ohci_mem_write()
1653 ohci_port_set_status(ohci, (addr - 0x54) >> 2, val); in ohci_mem_write()
1664 /* SOC is read-only */ in ohci_mem_write()
1668 ohci->status |= val; in ohci_mem_write()
1670 if (ohci->status & OHCI_STATUS_HCR) { in ohci_mem_write()
1676 ohci->intr_status &= ~val; in ohci_mem_write()
1681 ohci->intr |= val; in ohci_mem_write()
1686 ohci->intr &= ~val; in ohci_mem_write()
1691 ohci->hcca = val & OHCI_HCCA_MASK; in ohci_mem_write()
1695 /* Ignore writes to this read-only register, Linux does them */ 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()
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()
1745 ohci->hstatus &= ~(val & ohci->hmask); in ohci_mem_write()
1749 ohci->hreset = val & ~OHCI_HRESET_FSBIR; in ohci_mem_write()
1756 ohci->hmask = val; in ohci_mem_write()
1760 ohci->htest = val; in ohci_mem_write()
1778 OHCIState *s = port1->opaque; in ohci_attach()
1779 OHCIPort *port = &s->rhport[port1->index]; in ohci_attach()
1780 uint32_t old_state = port->ctrl; in ohci_attach()
1783 port->ctrl |= OHCI_PORT_CCS | OHCI_PORT_CSC; in ohci_attach()
1786 if (port->port.dev->speed == USB_SPEED_LOW) { in ohci_attach()
1787 port->ctrl |= OHCI_PORT_LSDA; in ohci_attach()
1789 port->ctrl &= ~OHCI_PORT_LSDA; in ohci_attach()
1792 /* notify of remote-wakeup */ in ohci_attach()
1793 if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) { in ohci_attach()
1797 trace_usb_ohci_port_attach(port1->index); in ohci_attach()
1799 if (old_state != port->ctrl) { in ohci_attach()
1806 OHCIState *ohci = port1->opaque; in ohci_child_detach()
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()
1818 OHCIState *s = port1->opaque; in ohci_detach()
1819 OHCIPort *port = &s->rhport[port1->index]; in ohci_detach()
1820 uint32_t old_state = port->ctrl; in ohci_detach()
1822 ohci_child_detach(port1, port1->dev); in ohci_detach()
1825 if (port->ctrl & OHCI_PORT_CCS) { in ohci_detach()
1826 port->ctrl &= ~OHCI_PORT_CCS; in ohci_detach()
1827 port->ctrl |= OHCI_PORT_CSC; in ohci_detach()
1830 if (port->ctrl & OHCI_PORT_PES) { in ohci_detach()
1831 port->ctrl &= ~OHCI_PORT_PES; in ohci_detach()
1832 port->ctrl |= OHCI_PORT_PESC; in ohci_detach()
1834 trace_usb_ohci_port_detach(port1->index); in ohci_detach()
1836 if (old_state != port->ctrl) { in ohci_detach()
1843 OHCIState *s = port1->opaque; in ohci_wakeup()
1844 OHCIPort *port = &s->rhport[port1->index]; in ohci_wakeup()
1846 if (port->ctrl & OHCI_PORT_PSS) { in ohci_wakeup()
1847 trace_usb_ohci_port_wakeup(port1->index); in ohci_wakeup()
1848 port->ctrl |= OHCI_PORT_PSSC; in ohci_wakeup()
1849 port->ctrl &= ~OHCI_PORT_PSS; in ohci_wakeup()
1868 ohci->async_complete = true; in ohci_async_complete_packet()
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()
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()
1938 memory_region_init_io(&ohci->mem, OBJECT(dev), &ohci_mem_ops, 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()
1964 .name = "ohci-core/port",
1977 return timer_pending(ohci->eof_timer); in ohci_eof_timer_needed()
1981 .name = "ohci-core/eof-timer",
1992 .name = "ohci-core",