All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anders Roxell <anders.roxell@linaro.org>
To: u-boot@lists.denx.de, marex@denx.de
Cc: mkorpershoek@kernel.org, ilias.apalodimas@linaro.org,
	trini@konsulko.com, michal.simek@amd.com, alchark@flipper.net,
	jerome.forissier@arm.com,
	Jerome Forissier <jerome.forissier@linaro.org>,
	Jens Wiklander <jens.wiklander@linaro.org>,
	Anders Roxell <anders.roxell@linaro.org>,
	Bin Meng <bmeng.cn@gmail.com>,
	Marek Vasut <marek.vasut+usb@mailbox.org>,
	u-boot@lists.u-boot-project.org
Subject: [PATCH v6 01/87] usb: host: re-import xhci-ext-caps.h from kernel v6.16
Date: Fri, 21 Aug 2026 10:46:37 +0200	[thread overview]
Message-ID: <20260821084829.2070426-2-anders.roxell@linaro.org> (raw)
In-Reply-To: <20260821084829.2070426-1-anders.roxell@linaro.org>

From: Jerome Forissier <jerome.forissier@linaro.org>

Import drivers/usb/host/xhci-ext-caps.h from Linux v6.16. The file
is needed by the updated DWC3 code.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
---
 drivers/usb/host/xhci-ext-caps.h | 158 +++++++++++++++++++++++++++++++
 1 file changed, 158 insertions(+)
 create mode 100644 drivers/usb/host/xhci-ext-caps.h

diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
new file mode 100644
index 000000000000..c93bcf4f4f7d
--- /dev/null
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -0,0 +1,158 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Imported from Linux v6.16 */
+/*
+ * xHCI host controller driver
+ *
+ * Copyright (C) 2008 Intel Corp.
+ *
+ * Author: Sarah Sharp
+ * Some code borrowed from the Linux EHCI driver.
+ */
+
+/* HC should halt within 16 ms, but use 32 ms as some hosts take longer */
+#define XHCI_MAX_HALT_USEC	(32 * 1000)
+/* HC not running - set to 1 when run/stop bit is cleared. */
+#define XHCI_STS_HALT		(1<<0)
+
+/* HCCPARAMS offset from PCI base address */
+#define XHCI_HCC_PARAMS_OFFSET	0x10
+/* HCCPARAMS contains the first extended capability pointer */
+#define XHCI_HCC_EXT_CAPS(p)	(((p)>>16)&0xffff)
+
+/* Command and Status registers offset from the Operational Registers address */
+#define XHCI_CMD_OFFSET		0x00
+#define XHCI_STS_OFFSET		0x04
+
+#define XHCI_MAX_EXT_CAPS		50
+
+/* Capability Register */
+/* bits 7:0 - how long is the Capabilities register */
+#define XHCI_HC_LENGTH(p)	(((p)>>00)&0x00ff)
+
+/* Extended capability register fields */
+#define XHCI_EXT_CAPS_ID(p)	(((p)>>0)&0xff)
+#define XHCI_EXT_CAPS_NEXT(p)	(((p)>>8)&0xff)
+#define	XHCI_EXT_CAPS_VAL(p)	((p)>>16)
+/* Extended capability IDs - ID 0 reserved */
+#define XHCI_EXT_CAPS_LEGACY	1
+#define XHCI_EXT_CAPS_PROTOCOL	2
+#define XHCI_EXT_CAPS_PM	3
+#define XHCI_EXT_CAPS_VIRT	4
+#define XHCI_EXT_CAPS_ROUTE	5
+/* IDs 6-9 reserved */
+#define XHCI_EXT_CAPS_DEBUG	10
+/* Vendor caps */
+#define XHCI_EXT_CAPS_VENDOR_INTEL	192
+#define XHCI_EXT_CAPS_INTEL_SPR_SHADOW	206
+/* USB Legacy Support Capability - section 7.1.1 */
+#define XHCI_HC_BIOS_OWNED	(1 << 16)
+#define XHCI_HC_OS_OWNED	(1 << 24)
+
+/* USB Legacy Support Capability - section 7.1.1 */
+/* Add this offset, plus the value of xECP in HCCPARAMS to the base address */
+#define XHCI_LEGACY_SUPPORT_OFFSET	(0x00)
+
+/* USB Legacy Support Control and Status Register  - section 7.1.2 */
+/* Add this offset, plus the value of xECP in HCCPARAMS to the base address */
+#define XHCI_LEGACY_CONTROL_OFFSET	(0x04)
+/* bits 1:3, 5:12, and 17:19 need to be preserved; bits 21:28 should be zero */
+#define	XHCI_LEGACY_DISABLE_SMI		((0x7 << 1) + (0xff << 5) + (0x7 << 17))
+#define XHCI_LEGACY_SMI_EVENTS		(0x7 << 29)
+
+/* USB 2.0 xHCI 0.96 L1C capability - section 7.2.2.1.3.2 */
+#define XHCI_L1C               (1 << 16)
+
+/* USB 2.0 xHCI 1.0 hardware LMP capability - section 7.2.2.1.3.2 */
+#define XHCI_HLC               (1 << 19)
+#define XHCI_BLC               (1 << 20)
+
+/* Intel SPR shadow capability */
+#define XHCI_INTEL_SPR_ESS_PORT_OFFSET  0x8ac4	/* SuperSpeed port control */
+#define XHCI_INTEL_SPR_TUNEN	BIT(4)		/* Tunnel mode enabled */
+
+/* command register values to disable interrupts and halt the HC */
+/* start/stop HC execution - do not write unless HC is halted*/
+#define XHCI_CMD_RUN		(1 << 0)
+/* Event Interrupt Enable - get irq when EINT bit is set in USBSTS register */
+#define XHCI_CMD_EIE		(1 << 2)
+/* Host System Error Interrupt Enable - get irq when HSEIE bit set in USBSTS */
+#define XHCI_CMD_HSEIE		(1 << 3)
+/* Enable Wrap Event - '1' means xHC generates an event when MFINDEX wraps. */
+#define XHCI_CMD_EWE		(1 << 10)
+
+#define XHCI_IRQS		(XHCI_CMD_EIE | XHCI_CMD_HSEIE | XHCI_CMD_EWE)
+
+/* true: Controller Not Ready to accept doorbell or op reg writes after reset */
+#define XHCI_STS_CNR		(1 << 11)
+
+/**
+ * struct xhci_protocol_caps
+ * @revision:		major revision, minor revision, capability ID,
+ *			and next capability pointer.
+ * @name_string:	Four ASCII characters to say which spec this xHC
+ *			follows, typically "USB ".
+ * @port_info:		Port offset, count, and protocol-defined information.
+ */
+struct xhci_protocol_caps {
+	u32	revision;
+	u32	name_string;
+	u32	port_info;
+};
+
+#define	XHCI_EXT_PORT_MAJOR(x)	(((x) >> 24) & 0xff)
+#define	XHCI_EXT_PORT_MINOR(x)	(((x) >> 16) & 0xff)
+#define	XHCI_EXT_PORT_PSIC(x)	(((x) >> 28) & 0x0f)
+#define	XHCI_EXT_PORT_OFF(x)	((x) & 0xff)
+#define	XHCI_EXT_PORT_COUNT(x)	(((x) >> 8) & 0xff)
+
+#define	XHCI_EXT_PORT_PSIV(x)	(((x) >> 0) & 0x0f)
+#define	XHCI_EXT_PORT_PSIE(x)	(((x) >> 4) & 0x03)
+#define	XHCI_EXT_PORT_PLT(x)	(((x) >> 6) & 0x03)
+#define	XHCI_EXT_PORT_PFD(x)	(((x) >> 8) & 0x01)
+#define	XHCI_EXT_PORT_LP(x)	(((x) >> 14) & 0x03)
+#define	XHCI_EXT_PORT_PSIM(x)	(((x) >> 16) & 0xffff)
+
+#include <linux/io.h>
+
+/**
+ * Find the offset of the extended capabilities with capability ID id.
+ *
+ * @base	PCI MMIO registers base address.
+ * @start	address at which to start looking, (0 or HCC_PARAMS to start at
+ *		beginning of list)
+ * @id		Extended capability ID to search for, or 0 for the next
+ *		capability
+ *
+ * Returns the offset of the next matching extended capability structure.
+ * Some capabilities can occur several times, e.g., the XHCI_EXT_CAPS_PROTOCOL,
+ * and this provides a way to find them all.
+ */
+
+static inline int xhci_find_next_ext_cap(void __iomem *base, u32 start, int id)
+{
+	u32 val;
+	u32 next;
+	u32 offset;
+
+	offset = start;
+	if (!start || start == XHCI_HCC_PARAMS_OFFSET) {
+		val = readl(base + XHCI_HCC_PARAMS_OFFSET);
+		if (val == ~0)
+			return 0;
+		offset = XHCI_HCC_EXT_CAPS(val) << 2;
+		if (!offset)
+			return 0;
+	}
+	do {
+		val = readl(base + offset);
+		if (val == ~0)
+			return 0;
+		if (offset != start && (id == 0 || XHCI_EXT_CAPS_ID(val) == id))
+			return offset;
+
+		next = XHCI_EXT_CAPS_NEXT(val);
+		offset += next << 2;
+	} while (next);
+
+	return 0;
+}
-- 
2.53.0


       reply	other threads:[~2026-08-21 13:11 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260821084829.2070426-1-anders.roxell@linaro.org>
2026-08-21  8:46 ` Anders Roxell [this message]
2026-08-21 19:44   ` [PATCH v6 01/87] usb: host: re-import xhci-ext-caps.h from kernel v6.16 Tom Rini
2026-08-22  4:22     ` Marek Vasut
2026-08-23 18:44       ` Anders Roxell
2026-08-23 18:59         ` Tom Rini
2026-08-23 19:08           ` Anders Roxell
2026-08-23 20:57             ` Tom Rini
2026-08-21  8:46 ` [PATCH v6 02/87] usb: dwc3: restore to original v3.19-rc1 kernel import Anders Roxell
2026-08-21  8:46 ` [PATCH v6 03/87] usb: dwc3: import from kernel v3.19 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 04/87] usb: dwc3: import from kernel v4.0 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 05/87] usb: dwc3: import from kernel v4.1 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 06/87] usb: dwc3: import from kernel v4.2 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 07/87] usb: dwc3: import from kernel v4.3 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 08/87] usb: dwc3: import from kernel v4.4 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 09/87] usb: dwc3: import from kernel v4.5 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 10/87] usb: dwc3: import from kernel v4.6 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 11/87] usb: dwc3: import from kernel v4.7 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 12/87] usb: dwc3: import from kernel v4.8 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 13/87] usb: dwc3: import from kernel v4.9 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 14/87] usb: dwc3: import from kernel v4.10 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 15/87] usb: dwc3: import from kernel v4.11 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 16/87] usb: dwc3: import from kernel v4.12 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 17/87] usb: dwc3: import from kernel v4.13 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 18/87] usb: dwc3: import from kernel v4.14 Anders Roxell
2026-08-24  8:54   ` Mattijs Korpershoek
2026-08-21  8:46 ` [PATCH v6 19/87] usb: dwc3: import from kernel v4.15 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 20/87] usb: dwc3: import from kernel v4.16 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 21/87] usb: dwc3: import from kernel v4.17 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 22/87] usb: dwc3: import from kernel v4.18 Anders Roxell
2026-08-21  8:46 ` [PATCH v6 23/87] usb: dwc3: import from kernel v4.19 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 24/87] usb: dwc3: import from kernel v4.20 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 25/87] usb: dwc3: import from kernel v5.0 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 26/87] usb: dwc3: import from kernel v5.1 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 27/87] usb: dwc3: import from kernel v5.2 Anders Roxell
2026-08-24  8:57   ` Mattijs Korpershoek
2026-08-21  8:47 ` [PATCH v6 28/87] usb: dwc3: import from kernel v5.3 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 29/87] usb: dwc3: import from kernel v5.4 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 30/87] usb: dwc3: import from kernel v5.5 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 31/87] usb: dwc3: import from kernel v5.6 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 32/87] usb: dwc3: import from kernel v5.7 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 33/87] usb: dwc3: import from kernel v5.8 Anders Roxell
2026-08-24  8:59   ` Mattijs Korpershoek
2026-08-21  8:47 ` [PATCH v6 34/87] usb: dwc3: import from kernel v5.9 Anders Roxell
2026-08-24  9:00   ` Mattijs Korpershoek
2026-08-21  8:47 ` [PATCH v6 35/87] usb: dwc3: import from kernel v5.10 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 36/87] usb: dwc3: import from kernel v5.11 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 37/87] usb: dwc3: import from kernel v5.12 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 38/87] usb: dwc3: import from kernel v5.13 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 39/87] usb: dwc3: import from kernel v5.14 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 40/87] usb: dwc3: import from kernel v5.15 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 41/87] usb: dwc3: import from kernel v5.16 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 42/87] usb: dwc3: import from kernel v5.17 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 43/87] usb: dwc3: import from kernel v5.18 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 44/87] usb: dwc3: import from kernel v5.19 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 45/87] usb: dwc3: import from kernel v6.0 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 46/87] usb: dwc3: import from kernel v6.1 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 47/87] usb: dwc3: import from kernel v6.2 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 48/87] usb: dwc3: import from kernel v6.3 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 49/87] usb: dwc3: import from kernel v6.4 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 50/87] usb: dwc3: import from kernel v6.5 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 51/87] usb: dwc3: import from kernel v6.6 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 52/87] usb: dwc3: import from kernel v6.7 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 53/87] usb: dwc3: import from kernel v6.8 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 54/87] usb: dwc3: import from kernel v6.9 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 55/87] usb: dwc3: import from kernel v6.10 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 56/87] usb: dwc3: import from kernel v6.11 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 57/87] usb: dwc3: import from kernel v6.12 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 58/87] usb: dwc3: import from kernel v6.13 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 59/87] usb: dwc3: import from kernel v6.14 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 60/87] usb: dwc3: import from kernel v6.15 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 61/87] usb: dwc3: import from kernel v6.16 Anders Roxell
2026-08-21  8:47 ` [PATCH v6 62/87] usb: gadget: re-import epautoconf.c " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 63/87] usb: udc: re-import udc-core.c " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 64/87] dm: add helpers needed by the resynced DWC3 code Anders Roxell
2026-08-21  8:47 ` [PATCH v6 65/87] usb: phy: add the usb_phy " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 66/87] usb: gadget: adapt the gadget API after the resync Anders Roxell
2026-08-21  8:47 ` [PATCH v6 67/87] usb: gadget: udc: make udc-core build in u-boot Anders Roxell
2026-08-21  8:47 ` [PATCH v6 68/87] usb: dwc3: make the core driver " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 69/87] usb: dwc3: bring back the samsung usb phy driver Anders Roxell
2026-08-21  8:47 ` [PATCH v6 70/87] usb: dwc3: make gadget and ep0 build in u-boot Anders Roxell
2026-08-21  8:47 ` [PATCH v6 71/87] usb: gadget: udc: enable async callbacks on bind Anders Roxell
2026-08-21  8:47 ` [PATCH v6 72/87] usb: dwc3: ep0: flush and invalidate cache around ep0 transfers Anders Roxell
2026-08-21  8:47 ` [PATCH v6 73/87] usb: dwc3: make the am62 glue build in u-boot Anders Roxell
2026-08-21  8:47 ` [PATCH v6 74/87] usb: gadget: ci_udc: move to the udc-core registration Anders Roxell
2026-08-21  8:47 ` [PATCH v6 75/87] usb: gadget: ci_udc: set endpoint capabilities Anders Roxell
2026-08-21  8:47 ` [PATCH v6 76/87] usb: gadget: dwc2_udc_otg: fix up after the resync Anders Roxell
2026-08-21  8:47 ` [PATCH v6 77/87] usb: gadget: fix up the function drivers " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 78/87] usb: gadget: fix up the last UDC " Anders Roxell
2026-08-21  8:47 ` [PATCH v6 79/87] usb: gadget: atmel_usba_udc: set endpoint capabilities Anders Roxell
2026-08-21  8:47 ` [PATCH v6 80/87] usb: gadget: at91_udc: register with udc-core Anders Roxell
2026-08-21  8:47 ` [PATCH v6 81/87] usb: gadget: at91_udc: set endpoint capabilities Anders Roxell
2026-08-21  8:47 ` [PATCH v6 82/87] usb: musb-new: fix up after the resync Anders Roxell
2026-08-21  8:47 ` [PATCH v6 83/87] usb: musb-new: set endpoint capabilities Anders Roxell
2026-08-21  8:48 ` [PATCH v6 84/87] usb: mtu3: fix up after the resync Anders Roxell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260821084829.2070426-2-anders.roxell@linaro.org \
    --to=anders.roxell@linaro.org \
    --cc=alchark@flipper.net \
    --cc=bmeng.cn@gmail.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jens.wiklander@linaro.org \
    --cc=jerome.forissier@arm.com \
    --cc=jerome.forissier@linaro.org \
    --cc=marek.vasut+usb@mailbox.org \
    --cc=marex@denx.de \
    --cc=michal.simek@amd.com \
    --cc=mkorpershoek@kernel.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=u-boot@lists.u-boot-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.