Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d5e01fb authored by Mayank Rana's avatar Mayank Rana Committed by Jack Pham
Browse files

usb/xhci: Add support for EHSET tests for host compliance



USB 2.0 specification defines following test modes for host electrical
compliance: TEST_J/K/SE0_NAK and TEST_PACKET. Hence add support for
same.

CRs-Fixed: 868394
Change-Id: I885ae66be2d8cca17bcc0b87b7635a71c734e4b2
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 900cea2a
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -886,6 +886,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
	u16 link_state = 0;
	u16 wake_mask = 0;
	u16 timeout = 0;
	u16 test_mode = 0;

	max_ports = xhci_get_ports(hcd, &port_array);
	bus_state = &xhci->bus_state[hcd_index(hcd)];
@@ -959,8 +960,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
			link_state = (wIndex & 0xff00) >> 3;
		if (wValue == USB_PORT_FEAT_REMOTE_WAKE_MASK)
			wake_mask = wIndex & 0xff00;
		/* The MSB of wIndex is the U1/U2 timeout */
		timeout = (wIndex & 0xff00) >> 8;
		/* The MSB of wIndex is the U1/U2 timeout OR TEST mode*/
		test_mode = timeout = (wIndex & 0xff00) >> 8;
		wIndex &= 0xff;
		if (!wIndex || wIndex > max_ports)
			goto error;
@@ -1134,6 +1135,27 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
			temp |= PORT_U2_TIMEOUT(timeout);
			writel(temp, port_array[wIndex] + PORTPMSC);
			break;
		case USB_PORT_FEAT_TEST:
			slot_id = xhci_find_slot_id_by_port(hcd, xhci,
							wIndex + 1);
			if (test_mode && test_mode <= 5) {
				/* unlock to execute stop endpoint commands */
				spin_unlock_irqrestore(&xhci->lock, flags);
				xhci_stop_device(xhci, slot_id, 1);
				spin_lock_irqsave(&xhci->lock, flags);
				xhci_halt(xhci);

				temp = readl_relaxed(port_array[wIndex] +
								PORTPMSC);
				temp |= test_mode << 28;
				writel_relaxed(temp, port_array[wIndex] +
								PORTPMSC);
				/* to make sure above write goes through */
				mb();
			} else {
				goto error;
			}
			break;
		default:
			goto error;
		}