>From da44e961605d382829f90fdcfb90b61fa5ca9590 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Tue, 19 Sep 2017 14:58:40 +0300 Subject: [PATCH 2/2] xhci: test xhci_find_next_ext_cap with 0 id NOT for UPSTREAM, just testing/reference code Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ext-caps.h | 3 +++ drivers/usb/host/xhci.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h index c1b4042..7deb9e7 100644 --- a/drivers/usb/host/xhci-ext-caps.h +++ b/drivers/usb/host/xhci-ext-caps.h @@ -51,6 +51,9 @@ #define XHCI_EXT_CAPS_ROUTE 5 /* IDs 6-9 reserved */ #define XHCI_EXT_CAPS_DEBUG 10 +/* IDs 192 - 255 vendor specific extensions */ +#define XHCI_EXT_CAPS_VENDOR_INTEL 192 + /* USB Legacy Support Capability - section 7.1.1 */ #define XHCI_HC_BIOS_OWNED (1 << 16) #define XHCI_HC_OS_OWNED (1 << 24) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 870093a..99c804a 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4772,6 +4772,34 @@ static int xhci_get_frame(struct usb_hcd *hcd) return readl(&xhci->run_regs->microframe_index) >> 3; } +int xhci_ext_cap_init(struct xhci_hcd *xhci) +{ + void __iomem *base; + u32 cap_offset; + u32 val; + + base = &xhci->cap_regs->hc_capbase; + cap_offset = xhci_find_next_ext_cap(base, 0, 0); + + do { + val = readl(base + cap_offset); + + switch (XHCI_EXT_CAPS_ID(val)) { + case XHCI_EXT_CAPS_VENDOR_INTEL: + printk(KERN_ERR "TEST EXT_CAPS_VENDOR_INTEL\n"); + break; + default: + break; + } + + printk(KERN_ERR "TEST EXT_CAP id %d\n", XHCI_EXT_CAPS_ID(val)); + + cap_offset = xhci_find_next_ext_cap(base, cap_offset, 0); + } while (cap_offset); + + return 0; +} + int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) { struct xhci_hcd *xhci; @@ -4886,6 +4914,8 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) dma_set_coherent_mask(dev, DMA_BIT_MASK(32)); } + xhci_ext_cap_init(xhci); + xhci_dbg(xhci, "Calling HCD init\n"); /* Initialize HCD and host controller data structures. */ retval = xhci_init(hcd); -- 1.9.1