Lines Matching refs:id

29 static int xhci_hc_stop(int id);
30 static int xhci_hc_reset(int id);
31 static int xhci_hc_stop_legacy(int id);
32 static int xhci_hc_start_sched(int id);
33 static int xhci_hc_stop_sched(int id);
34 static uint32_t xhci_hc_get_protocol_offset(int id, uint32_t list_off, const int version, uint32_t …
36 static int xhci_hc_pair_ports(int id);
40 static int xhci_hc_init_intr(int id);
41 static int xhci_hc_start_ports(int id);
43 static int xhci_send_command(int id, struct xhci_TRB_t *trb, const bool do_ring);
44 static uint64_t xhci_initialize_slot(const int id, const int port, const int speed, const int max_p…
45 static void xhci_initialize_ep(const int id, const uint64_t slot_vaddr, const int port_id, const in…
48 static int xhci_set_address(const int id, const uint64_t slot_vaddr, const int slot_id, const bool …
49 static int xhci_control_in(const int id, struct usb_request_packet_t *packet, void *target, const i…
51 static int xhci_control_out(const int id, struct usb_request_packet_t *packet, void *target, const …
58 static int xhci_wait_for_interrupt(const int id, uint64_t status_vaddr);
59 static inline int xhci_get_desc(const int id, const int port_id, void *target, const uint16_t desc_…
61 static int xhci_get_config_desc(const int id, const int port_id, struct usb_config_desc *conf_desc);
62 static inline int xhci_get_config_desc_full(const int id, const int port_id, const struct usb_confi…
67 static int xhci_get_descriptor(const int id, const int port_id, struct usb_device_desc *dev_desc);
68 static int xhci_configure_port(const int id, const int port_id);
69 static int xhci_configure_endpoint(const int id, const int port_id, const uint8_t ep_num, const uin…
71 static int xhci_get_hid_report(int id, int port_id, int interface_number, void *ret_hid_report,
73 static int xhci_get_hid_descriptor(int id, int port_id, const void *full_conf, int interface_number,
137 static __always_inline void __write_ep(int id, uint64_t slot_vaddr, int ep_num, struct xhci_ep_cont… in __write_ep() argument
139 …memcpy((void *)(slot_vaddr + ep_num * xhci_hc[id].context_size), ep, sizeof(struct xhci_ep_context… in __write_ep()
150 static __always_inline void __read_from_ep(int id, uint64_t slot_vaddr, int ep_num, struct xhci_ep_… in __read_from_ep() argument
152 …memcpy(ep, (void *)(slot_vaddr + ep_num * xhci_hc[id].context_size), sizeof(struct xhci_ep_context… in __read_from_ep()
185 static __always_inline void __xhci_write_doorbell(const int id, const uint16_t slot_id, const uint3… in __xhci_write_doorbell() argument
189 xhci_write_cap_reg32(id, xhci_hc[id].db_offset + slot_id * sizeof(uint32_t), value); in __xhci_write_doorbell()
223 static __always_inline uint64_t xhci_get_device_context_vaddr(const int id, const int port_id) in xhci_get_device_context_vaddr() argument
226 … __read8b(xhci_hc[id].dcbaap_vaddr + (xhci_hc[id].ports[port_id].slot_id * sizeof(uint64_t)))); in xhci_get_device_context_vaddr()
235 static int xhci_hc_stop(int id) in xhci_hc_stop() argument
239 if (unlikely((xhci_read_op_reg32(id, XHCI_OPS_USBSTS) & (1 << 0)) == 1)) in xhci_hc_stop()
242 xhci_write_op_reg32(id, XHCI_OPS_USBCMD, 0x00000000); in xhci_hc_stop()
245 while ((xhci_read_op_reg32(id, XHCI_OPS_USBSTS) & (1 << 0)) == 0) in xhci_hc_stop()
262 static int xhci_hc_reset(int id) in xhci_hc_reset() argument
267 if ((xhci_read_op_reg32(id, XHCI_OPS_USBSTS) & (1 << 0)) == 0) in xhci_hc_reset()
272 retval = xhci_hc_stop(id); in xhci_hc_reset()
278 uint32_t cmd = xhci_read_op_reg32(id, XHCI_OPS_USBCMD); in xhci_hc_reset()
282 xhci_write_op_reg32(id, XHCI_OPS_USBCMD, cmd); in xhci_hc_reset()
285 while (xhci_read_op_reg32(id, XHCI_OPS_USBCMD) & (1 << 1)) in xhci_hc_reset()
302 static int xhci_hc_stop_legacy(int id) in xhci_hc_stop_legacy() argument
304 uint64_t current_offset = xhci_hc[id].ext_caps_off; in xhci_hc_stop_legacy()
309 if ((xhci_read_cap_reg32(id, current_offset) & 0xff) == XHCI_XECP_ID_LEGACY) in xhci_hc_stop_legacy()
313 xhci_write_cap_reg32(id, current_offset, in xhci_hc_stop_legacy()
314 … xhci_read_cap_reg32(id, current_offset) | XHCI_XECP_LEGACY_OS_OWNED); in xhci_hc_stop_legacy()
318 while ((xhci_read_cap_reg32(id, current_offset) & XHCI_XECP_LEGACY_OWNING_MASK) != in xhci_hc_stop_legacy()
334 int next_off = ((xhci_read_cap_reg32(id, current_offset) & 0xff00) >> 8) << 2; in xhci_hc_stop_legacy()
350 static int xhci_hc_start_sched(int id) in xhci_hc_start_sched() argument
353 xhci_write_op_reg32(id, XHCI_OPS_USBCMD, (1 << 0) | (1 << 2) | (1 << 3)); in xhci_hc_start_sched()
364 static int xhci_hc_stop_sched(int id) in xhci_hc_stop_sched() argument
367 xhci_write_op_reg32(id, XHCI_OPS_USBCMD, 0x00); in xhci_hc_stop_sched()
382 static uint32_t xhci_hc_get_protocol_offset(int id, uint32_t list_off, const int version, uint32_t … in xhci_hc_get_protocol_offset() argument
390 uint32_t dw0 = xhci_read_cap_reg32(id, list_off); in xhci_hc_get_protocol_offset()
397 uint32_t dw2 = xhci_read_cap_reg32(id, list_off + 8); in xhci_hc_get_protocol_offset()
420 static int xhci_hc_pair_ports(int id) in xhci_hc_pair_ports() argument
425 …memcpy(&hcs1, xhci_get_ptr_cap_reg32(id, XHCI_CAPS_HCSPARAMS1), sizeof(struct xhci_caps_HCSPARAMS1… in xhci_hc_pair_ports()
428 xhci_hc[id].port_num = hcs1.max_ports; in xhci_hc_pair_ports()
432 xhci_hc[id].port_num_u2 = 0; in xhci_hc_pair_ports()
433 xhci_hc[id].port_num_u3 = 0; in xhci_hc_pair_ports()
435 uint32_t next_off = xhci_hc[id].ext_caps_off; in xhci_hc_pair_ports()
443 next_off = xhci_hc_get_protocol_offset(id, next_off, 2, &offset, &cnt, &protocol_flags); in xhci_hc_pair_ports()
451 xhci_hc[id].ports[offset + i].offset = xhci_hc[id].port_num_u2++; in xhci_hc_pair_ports()
452 xhci_hc[id].ports[offset + i].flags = XHCI_PROTOCOL_USB2; in xhci_hc_pair_ports()
456 xhci_hc[id].ports[offset + i].flags |= XHCI_PROTOCOL_HSO; in xhci_hc_pair_ports()
462 next_off = xhci_hc[id].ext_caps_off; in xhci_hc_pair_ports()
466 next_off = xhci_hc_get_protocol_offset(id, next_off, 3, &offset, &cnt, &protocol_flags); in xhci_hc_pair_ports()
474 xhci_hc[id].ports[offset + i].offset = xhci_hc[id].port_num_u3++; in xhci_hc_pair_ports()
475 xhci_hc[id].ports[offset + i].flags = XHCI_PROTOCOL_USB3; in xhci_hc_pair_ports()
481 for (int i = 0; i < xhci_hc[id].port_num; ++i) in xhci_hc_pair_ports()
483 for (int j = 0; j < xhci_hc[id].port_num; ++j) in xhci_hc_pair_ports()
488 if ((xhci_hc[id].ports[i].offset == xhci_hc[id].ports[j].offset) && in xhci_hc_pair_ports()
489 ((xhci_hc[id].ports[i].flags & XHCI_PROTOCOL_INFO) != in xhci_hc_pair_ports()
490 (xhci_hc[id].ports[j].flags & XHCI_PROTOCOL_INFO))) in xhci_hc_pair_ports()
492 xhci_hc[id].ports[i].paired_port_num = j; in xhci_hc_pair_ports()
493 xhci_hc[id].ports[i].flags |= XHCI_PROTOCOL_HAS_PAIR; in xhci_hc_pair_ports()
495 xhci_hc[id].ports[j].paired_port_num = i; in xhci_hc_pair_ports()
496 xhci_hc[id].ports[j].flags |= XHCI_PROTOCOL_HAS_PAIR; in xhci_hc_pair_ports()
502 for (int i = 0; i < xhci_hc[id].port_num; ++i) in xhci_hc_pair_ports()
505 if (XHCI_PORT_IS_USB3(id, i) || (XHCI_PORT_IS_USB2(id, i) && (!XHCI_PORT_HAS_PAIR(id, i)))) in xhci_hc_pair_ports()
506 xhci_hc[id].ports[i].flags |= XHCI_PROTOCOL_ACTIVE; in xhci_hc_pair_ports()
508 …nd %d ports on root hub, usb2 ports:%d, usb3 ports:%d", xhci_hc[id].port_num, xhci_hc[id].port_num… in xhci_hc_pair_ports()
509 xhci_hc[id].port_num_u3); in xhci_hc_pair_ports()
780 static int xhci_reset_port(const int id, const int port) in xhci_reset_port() argument
788 if ((xhci_read_op_reg32(id, port_status_offset + XHCI_PORT_PORTSC) & (1 << 9)) == 0) in xhci_reset_port()
792 xhci_write_cap_reg32(id, port_status_offset + XHCI_PORT_PORTSC, (1 << 9)); in xhci_reset_port()
796 if ((xhci_read_op_reg32(id, port_status_offset + XHCI_PORT_PORTSC) & (1 << 9)) == 0) in xhci_reset_port()
805 …xhci_write_op_reg32(id, port_status_offset + XHCI_PORT_PORTSC, (1 << 9) | XHCI_PORTUSB_CHANGE_BITS… in xhci_reset_port()
809 if (XHCI_PORT_IS_USB3(id, port)) in xhci_reset_port()
810 xhci_write_op_reg32(id, port_status_offset + XHCI_PORT_PORTSC, (1 << 9) | (1U << 31)); in xhci_reset_port()
812 xhci_write_op_reg32(id, port_status_offset + XHCI_PORT_PORTSC, (1 << 9) | (1 << 4)); in xhci_reset_port()
821 uint32_t val = xhci_read_op_reg32(id, port_status_offset + XHCI_PORT_PORTSC); in xhci_reset_port()
828 if (XHCI_PORT_IS_USB3(id, port) && (val & (1U << 31)) == 0) in xhci_reset_port()
830 else if (XHCI_PORT_IS_USB2(id, port) && (val & (1 << 4)) == 0) in xhci_reset_port()
842 uint32_t val = xhci_read_op_reg32(id, port_status_offset + XHCI_PORT_PORTSC); in xhci_reset_port()
854 …xhci_write_op_reg32(id, port_status_offset + XHCI_PORT_PORTSC, (1 << 9) | XHCI_PORTUSB_CHANGE_BITS… in xhci_reset_port()
862 if (retval == 0 && XHCI_PORT_IS_USB2(id, port)) in xhci_reset_port()
864 xhci_hc[id].ports[port].flags |= XHCI_PROTOCOL_ACTIVE; in xhci_reset_port()
865 if (XHCI_PORT_HAS_PAIR(id, port)) // 如果有对应的usb3端口,则将usb3端口设置为未激活 in xhci_reset_port()
866 … xhci_hc[id].ports[xhci_hc[id].ports[port].paired_port_num].flags &= ~(XHCI_PROTOCOL_ACTIVE); in xhci_reset_port()
870 if (retval != 0 && XHCI_PORT_IS_USB3(id, port)) in xhci_reset_port()
872 xhci_hc[id].ports[port].flags &= ~XHCI_PROTOCOL_ACTIVE; in xhci_reset_port()
873 xhci_hc[id].ports[xhci_hc[id].ports[port].paired_port_num].flags |= XHCI_PROTOCOL_ACTIVE; in xhci_reset_port()
890 static uint64_t xhci_initialize_slot(const int id, const int port, const int speed, const int max_p… in xhci_initialize_slot() argument
894 uint64_t device_context_vaddr = (uint64_t)kzalloc(xhci_hc[id].context_size * 32, 0); in xhci_initialize_slot()
897 __write8b(xhci_hc[id].dcbaap_vaddr + (xhci_hc[id].ports[port].slot_id * sizeof(uint64_t)), in xhci_initialize_slot()
913 …xhci_initialize_ep(id, device_context_vaddr, port, XHCI_EP_CONTROL, max_packet, 0, USB_EP_CONTROL,… in xhci_initialize_slot()
931 static void xhci_initialize_ep(const int id, const uint64_t slot_vaddr, const int port_id, const in… in xhci_initialize_ep() argument
941 xhci_hc[id].ports[port_id].ep_info[ep_num].ep_ring_vbase = xhci_create_ring(XHCI_TRBS_PER_RING); in xhci_initialize_ep()
943 ep_ctx.tr_dequeue_ptr = virt_2_phys(xhci_hc[id].ports[port_id].ep_info[ep_num].ep_ring_vbase); in xhci_initialize_ep()
946 xhci_hc[id].ports[port_id].ep_info[ep_num].current_ep_ring_vaddr = in xhci_initialize_ep()
947 xhci_hc[id].ports[port_id].ep_info[ep_num].ep_ring_vbase; in xhci_initialize_ep()
948 …xhci_hc[id].ports[port_id].ep_info[ep_num].current_ep_ring_cycle = xhci_ep_get_dequeue_cycle_state… in xhci_initialize_ep()
989 __write_ep(id, slot_vaddr, ep_num, &ep_ctx); in xhci_initialize_ep()
1001 static int xhci_set_address(const int id, const uint64_t slot_vaddr, const int slot_id, const bool … in xhci_set_address() argument
1007 uint64_t input_ctx_buffer = (uint64_t)kzalloc(xhci_hc[id].context_size * 33, 0); in xhci_set_address()
1016 __read_from_ep(id, slot_vaddr, 1, &ep); in xhci_set_address()
1021 __write_slot(input_ctx_buffer + xhci_hc[id].context_size, &slot); in xhci_set_address()
1022 __write_ep(id, input_ctx_buffer, 2, &ep); in xhci_set_address()
1029 trb.cycle = xhci_hc[id].cmd_trb_cycle; in xhci_set_address()
1032 retval = xhci_send_command(id, (struct xhci_TRB_t *)&trb, true); in xhci_set_address()
1195 static int xhci_wait_for_interrupt(const int id, uint64_t status_vaddr) in xhci_wait_for_interrupt() argument
1237 static int xhci_control_in(const int id, struct usb_request_packet_t *packet, void *target, const i… in xhci_control_in() argument
1247 xhci_setup_stage(&xhci_hc[id].ports[port_id].ep_info[XHCI_EP_CONTROL], packet, XHCI_DIR_IN); in xhci_control_in()
1251 …xhci_data_stage(&xhci_hc[id].ports[port_id].ep_info[XHCI_EP_CONTROL], data_buf_vaddr, TRB_TYPE_DAT… in xhci_control_in()
1269 __xhci_write_doorbell(id, xhci_hc[id].ports[port_id].slot_id, XHCI_EP_CONTROL); in xhci_control_in()
1270 retval = xhci_wait_for_interrupt(id, status_buf_vaddr); in xhci_control_in()
1275 …xhci_status_stage(&xhci_hc[id].ports[port_id].ep_info[XHCI_EP_CONTROL], XHCI_DIR_OUT_BIT, status_b… in xhci_control_in()
1277 __xhci_write_doorbell(id, xhci_hc[id].ports[port_id].slot_id, XHCI_EP_CONTROL); in xhci_control_in()
1279 retval = xhci_wait_for_interrupt(id, status_buf_vaddr); in xhci_control_in()
1311 static int xhci_control_out(const int id, struct usb_request_packet_t *packet, void *target, const … in xhci_control_out() argument
1319 xhci_setup_stage(&xhci_hc[id].ports[port_id].ep_info[XHCI_EP_CONTROL], packet, XHCI_DIR_OUT); in xhci_control_out()
1324 …xhci_data_stage(&xhci_hc[id].ports[port_id].ep_info[XHCI_EP_CONTROL], data_buf_vaddr, TRB_TYPE_DAT… in xhci_control_out()
1330 __xhci_write_doorbell(id, xhci_hc[id].ports[port_id].slot_id, XHCI_EP_CONTROL); in xhci_control_out()
1331 retval = xhci_wait_for_interrupt(id, status_buf_vaddr); in xhci_control_out()
1337 …xhci_status_stage(&xhci_hc[id].ports[port_id].ep_info[XHCI_EP_CONTROL], XHCI_DIR_IN_BIT, status_bu… in xhci_control_out()
1339 __xhci_write_doorbell(id, xhci_hc[id].ports[port_id].slot_id, XHCI_EP_CONTROL); in xhci_control_out()
1342 retval = xhci_wait_for_interrupt(id, status_buf_vaddr); in xhci_control_out()
1376 static inline int xhci_get_desc(const int id, const int port_id, void *target, const uint16_t desc_… in xhci_get_desc() argument
1379 struct usb_device_desc *dev_desc = xhci_hc[id].ports[port_id].dev_desc; in xhci_get_desc()
1393 count = xhci_control_in(id, &ctrl_in_packet, target, port_id, dev_desc->max_packet_size); in xhci_get_desc()
1399 static inline int xhci_set_configuration(const int id, const int port_id, const uint8_t conf_value) in xhci_set_configuration() argument
1401 struct usb_device_desc *dev_desc = xhci_hc[id].ports[port_id].dev_desc; in xhci_set_configuration()
1410 count = xhci_control_out(id, &ctrl_out_packet, NULL, port_id, dev_desc->max_packet_size); in xhci_set_configuration()
1423 static int xhci_get_config_desc(const int id, const int port_id, struct usb_config_desc *conf_desc) in xhci_get_config_desc() argument
1429 int retval = xhci_get_desc(id, port_id, conf_desc, USB_DT_CONFIG, 0, 0, 9); in xhci_get_config_desc()
1434 (xhci_get_port_speed(id, port_id) == XHCI_PORT_SPEED_SUPER) ? (conf_desc->max_power * 8) in xhci_get_config_desc()
1448 static inline int xhci_get_config_desc_full(const int id, const int port_id, const struct usb_confi… in xhci_get_config_desc_full() argument
1454 return xhci_get_desc(id, port_id, target, USB_DT_CONFIG, 0, 0, conf_desc->total_len); in xhci_get_config_desc_full()
1525 static int xhci_get_descriptor(const int id, const int port_id, struct usb_device_desc *dev_desc) in xhci_get_descriptor() argument
1532 uint32_t speed = xhci_get_port_speed(id, port_id); in xhci_get_descriptor()
1542 if (xhci_send_command(id, (struct xhci_TRB_t *)&trb, true) != 0) in xhci_get_descriptor()
1571 xhci_hc[id].ports[port_id].slot_id = slot_id; in xhci_get_descriptor()
1574 uint64_t slot_vaddr = xhci_initialize_slot(id, port_id, speed, max_packet); in xhci_get_descriptor()
1576 retval = xhci_set_address(id, slot_vaddr, slot_id, true); in xhci_get_descriptor()
1580 retval = xhci_set_address(id, slot_vaddr, slot_id, false); in xhci_get_descriptor()
1586 count = xhci_control_in(id, &ctrl_in_packet, dev_desc, port_id, max_packet); in xhci_get_descriptor()
1595 xhci_hc[id].ports[port_id].dev_desc = dev_desc; in xhci_get_descriptor()
1628 static int xhci_hc_start_ports(int id) in xhci_hc_start_ports() argument
1634 for (int i = 0; i < xhci_hc[id].port_num; ++i) in xhci_hc_start_ports()
1636 if (XHCI_PORT_IS_USB3(id, i) && XHCI_PORT_IS_ACTIVE(id, i)) in xhci_hc_start_ports()
1640 int rst_ret = xhci_reset_port(id, i); in xhci_hc_start_ports()
1648 if (xhci_get_descriptor(id, i, &dev_desc) == 0) in xhci_hc_start_ports()
1650 xhci_configure_port(id, i); in xhci_hc_start_ports()
1660 for (int i = 0; i < xhci_hc[id].port_num; ++i) in xhci_hc_start_ports()
1662 if (XHCI_PORT_IS_USB2(id, i) && XHCI_PORT_IS_ACTIVE(id, i)) in xhci_hc_start_ports()
1667 if (likely(xhci_reset_port(id, i) == in xhci_hc_start_ports()
1674 if (xhci_get_descriptor(id, i, &dev_desc) == 0) in xhci_hc_start_ports()
1676 xhci_configure_port(id, i); in xhci_hc_start_ports()
1683 kinfo("xHCI controller %d: Started %d ports.", id, cnt); in xhci_hc_start_ports()
1695 static int xhci_hid_set_idle(const int id, const int port_id, struct usb_interface_desc *if_desc) in xhci_hid_set_idle() argument
1697 struct usb_device_desc *dev_desc = xhci_hc[id].ports[port_id].dev_desc; in xhci_hid_set_idle()
1705 xhci_control_out(id, &ctrl_out_packet, NULL, port_id, dev_desc->max_packet_size); in xhci_hid_set_idle()
1720 static int xhci_configure_endpoint(const int id, const int port_id, const uint8_t ep_num, const uin… in xhci_configure_endpoint() argument
1725 uint64_t slot_context_vaddr = xhci_get_device_context_vaddr(id, port_id); in xhci_configure_endpoint()
1727 …xhci_initialize_ep(id, slot_context_vaddr, port_id, ep_num, xhci_hc[id].ports[port_id].dev_desc->m… in xhci_configure_endpoint()
1729 xhci_get_port_speed(id, port_id), ep_desc->interval); in xhci_configure_endpoint()
1734 uint64_t input_ctx_buffer = (uint64_t)kzalloc(xhci_hc[id].context_size * 33, 0); in xhci_configure_endpoint()
1744 __write_slot(input_ctx_buffer + xhci_hc[id].context_size, &slot); in xhci_configure_endpoint()
1749 __read_from_ep(id, slot_context_vaddr, ep_num, &ep); in xhci_configure_endpoint()
1753 __write_ep(id, input_ctx_buffer, ep_num + 1, &ep); in xhci_configure_endpoint()
1758 trb.cycle = xhci_hc[id].cmd_trb_cycle; in xhci_configure_endpoint()
1759 trb.Reserved |= (((uint16_t)xhci_hc[id].ports[port_id].slot_id) << 8) & 0xffff; in xhci_configure_endpoint()
1764 retval = xhci_send_command(id, (struct xhci_TRB_t *)&trb, true); in xhci_configure_endpoint()
1795 static int xhci_configure_port(const int id, const int port_id) in xhci_configure_port() argument
1806 retval = xhci_get_config_desc(id, port_id, &conf_desc); in xhci_configure_port()
1814 retval = xhci_get_config_desc_full(id, port_id, &conf_desc, full_conf); in xhci_configure_port()
1832 retval = xhci_set_configuration(id, port_id, ((struct usb_config_desc *)full_conf)->value); in xhci_configure_port()
1838 … retval = xhci_configure_endpoint(id, port_id, ep_desc->endpoint_addr, USB_EP_INTERRUPT, ep_desc); in xhci_configure_port()
1842 retval = xhci_hid_set_idle(id, port_id, if_desc); in xhci_configure_port()
1849 … retval = xhci_get_hid_descriptor(id, port_id, full_conf, if_desc->interface_number, &hid_desc); in xhci_configure_port()
1858 …xhci_get_hid_report(id, port_id, if_desc->interface_number, hid_report_data, hid_desc->report_desc… in xhci_configure_port()
1895 static int xhci_hc_init_intr(int id) in xhci_hc_init_intr() argument
1902 …memcpy(&hcs1, xhci_get_ptr_cap_reg32(id, XHCI_CAPS_HCSPARAMS1), sizeof(struct xhci_caps_HCSPARAMS1… in xhci_hc_init_intr()
1904 …memcpy(&hcs2, xhci_get_ptr_cap_reg32(id, XHCI_CAPS_HCSPARAMS2), sizeof(struct xhci_caps_HCSPARAMS2… in xhci_hc_init_intr()
1911 retval = xhci_create_event_ring(4096, &xhci_hc[id].event_ring_vaddr); in xhci_hc_init_intr()
1915 xhci_hc[id].event_ring_table_vaddr = retval; in xhci_hc_init_intr()
1916 xhci_hc[id].current_event_ring_vaddr = in xhci_hc_init_intr()
1917 xhci_hc[id].event_ring_vaddr; // 设置驱动程序要读取的下一个event ring trb的地址 in xhci_hc_init_intr()
1920 xhci_hc[id].current_event_ring_cycle = 1; in xhci_hc_init_intr()
1924 xhci_write_intr_reg32(id, 0, XHCI_IR_MAN, 0x3); // 使能中断并清除pending位(这个pending位是写入1就清0的) in xhci_hc_init_intr()
1926 xhci_write_intr_reg32(id, 0, XHCI_IR_MOD, 0); // 关闭中断管制 in xhci_hc_init_intr()
1928 xhci_write_intr_reg32(id, 0, XHCI_IR_TABLE_SIZE, 1); // 当前只有1个segment in xhci_hc_init_intr()
1930 xhci_write_intr_reg64(id, 0, XHCI_IR_DEQUEUE, in xhci_hc_init_intr()
1931 virt_2_phys(xhci_hc[id].current_event_ring_vaddr) | in xhci_hc_init_intr()
1934 …xhci_write_intr_reg64(id, 0, XHCI_IR_TABLE_ADDR, virt_2_phys(xhci_hc[id].event_ring_table_vaddr));… in xhci_hc_init_intr()
1938 xhci_write_op_reg32(id, XHCI_OPS_USBSTS, (1 << 10) | (1 << 4) | (1 << 3) | (1 << 2)); in xhci_hc_init_intr()
1949 sprintk(buf, "xHCI HC%d", id); in xhci_hc_init_intr()
1951 …irq_register(xhci_controller_irq_num[id], &install_info, &xhci_hc_irq_handler, id, &xhci_hc_intr_c… in xhci_hc_init_intr()
1955 …ebug("xhci host controller %d: interrupt registered. irq num=%d", id, xhci_controller_irq_num[id]); in xhci_hc_init_intr()
1968 static int xhci_send_command(int id, struct xhci_TRB_t *trb, const bool do_ring) in xhci_send_command() argument
1970 uint64_t origin_trb_vaddr = xhci_hc[id].cmd_trb_vaddr; in xhci_send_command()
1973 __write8b(xhci_hc[id].cmd_trb_vaddr, trb->param); // 参数 in xhci_send_command()
1974 __write4b(xhci_hc[id].cmd_trb_vaddr + 8, trb->status); // 状态 in xhci_send_command()
1975 __write4b(xhci_hc[id].cmd_trb_vaddr + 12, trb->command | xhci_hc[id].cmd_trb_cycle); // 命令 in xhci_send_command()
1977 xhci_hc[id].cmd_trb_vaddr += sizeof(struct xhci_TRB_t); // 跳转到下一个trb in xhci_send_command()
1981 struct xhci_TRB_normal_t *ptr = (struct xhci_TRB_normal_t *)xhci_hc[id].cmd_trb_vaddr; in xhci_send_command()
1984 ptr->cycle = xhci_hc[id].cmd_trb_cycle; in xhci_send_command()
1985 xhci_hc[id].cmd_trb_vaddr = xhci_hc[id].cmd_ring_vaddr; in xhci_send_command()
1986 xhci_hc[id].cmd_trb_cycle ^= 1; in xhci_send_command()
1992 __xhci_write_doorbell(id, 0, 0); in xhci_send_command()
1996 const uint32_t iman0 = xhci_read_intr_reg32(id, 0, XHCI_IR_MAN); in xhci_send_command()
2005 uint32_t x = xhci_read_cap_reg32(id, xhci_hc[id].rts_offset + 0x20); in xhci_send_command()
2027 static int xhci_get_hid_descriptor(int id, int port_id, const void *full_conf, int interface_number, in xhci_get_hid_descriptor() argument
2066 static int xhci_get_hid_report(int id, int port_id, int interface_number, void *ret_hid_report, uin… in xhci_get_hid_report() argument
2068 …int retval = xhci_get_desc(id, port_id, ret_hid_report, USB_DT_HID_REPORT, 0, interface_number, hi… in xhci_get_hid_report()
2070 …kerror("xhci_get_hid_report failed: host_controller:%d, port:%d, interface %d", id, port_id, inter… in xhci_get_hid_report()