I'd like to print the version of the xHCI controller in the dmesg like
we do for AHCI.  I've been looking at some xHCI 1.1 peculiarities lately
and apparently our driver also need some love for pre 1.0 chips.

With the diff below, we will now print:

xhci0 at pci0 dev 20 function 0 "Intel 9 Series xHCI" rev 0x03: msi, xHCI 1.0

or

xhci1 at imxxhci1, xHCI 1.16

ok?

Index: arch/armv7/marvell/mvxhci.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/marvell/mvxhci.c,v
retrieving revision 1.1
diff -u -p -r1.1 mvxhci.c
--- arch/armv7/marvell/mvxhci.c 24 Mar 2017 20:27:27 -0000      1.1
+++ arch/armv7/marvell/mvxhci.c 8 May 2018 08:24:03 -0000
@@ -149,8 +149,6 @@ mvxhci_attach(struct device *parent, str
                goto unmap;
        }
 
-       printf("\n");
-
        strlcpy(sc->sc.sc_vendor, "Marvell", sizeof(sc->sc.sc_vendor));
        if ((error = xhci_init(&sc->sc)) != 0) {
                printf("%s: init failed, error=%d\n",
Index: dev/pci/xhci_pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/xhci_pci.c,v
retrieving revision 1.8
diff -u -p -r1.8 xhci_pci.c
--- dev/pci/xhci_pci.c  1 Jun 2016 06:19:59 -0000       1.8
+++ dev/pci/xhci_pci.c  8 May 2018 08:22:07 -0000
@@ -173,7 +173,7 @@ xhci_pci_attach(struct device *parent, s
                printf("\n");
                goto unmap_ret;
        }
-       printf(": %s\n", intrstr);
+       printf(": %s", intrstr);
 
        /* Figure out vendor for root hub descriptor. */
        vendor = pci_findvendor(pa->pa_id);
Index: dev/usb/xhci.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/xhci.c,v
retrieving revision 1.84
diff -u -p -r1.84 xhci.c
--- dev/usb/xhci.c      29 Apr 2018 09:00:42 -0000      1.84
+++ dev/usb/xhci.c      8 May 2018 08:24:45 -0000
@@ -286,12 +286,6 @@ xhci_init(struct xhci_softc *sc)
        uint32_t hcr;
        int npage, error;
 
-#ifdef XHCI_DEBUG
-       uint16_t vers;
-
-       vers = XREAD2(sc, XHCI_HCIVERSION);
-       printf("%s: xHCI version %x.%x\n", DEVNAME(sc), vers >> 8, vers & 0xff);
-#endif
        sc->sc_bus.usbrev = USBREV_3_0;
        sc->sc_bus.methods = &xhci_bus_methods;
        sc->sc_bus.pipe_size = sizeof(struct xhci_pipe);
@@ -299,6 +293,9 @@ xhci_init(struct xhci_softc *sc)
        sc->sc_oper_off = XREAD1(sc, XHCI_CAPLENGTH);
        sc->sc_door_off = XREAD4(sc, XHCI_DBOFF);
        sc->sc_runt_off = XREAD4(sc, XHCI_RTSOFF);
+
+       sc->sc_version = XREAD2(sc, XHCI_HCIVERSION);
+       printf(", xHCI %u.%u\n", sc->sc_version >> 8, sc->sc_version & 0xff);
 
 #ifdef XHCI_DEBUG
        printf("%s: CAPLENGTH=%#lx\n", DEVNAME(sc), sc->sc_oper_off);
Index: dev/usb/xhcivar.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/xhcivar.h,v
retrieving revision 1.8
diff -u -p -r1.8 xhcivar.h
--- dev/usb/xhcivar.h   18 Jan 2015 20:35:11 -0000      1.8
+++ dev/usb/xhcivar.h   8 May 2018 08:18:21 -0000
@@ -91,6 +91,7 @@ struct xhci_softc {
        bus_size_t               sc_runt_off;   /* Runtime */
        bus_size_t               sc_door_off;   /* Doorbell  */
 
+       uint16_t                 sc_version;    /* xHCI version */
        uint32_t                 sc_pagesize;   /* xHCI page size, minimum 4k */
        uint32_t                 sc_ctxsize;    /* 32/64 byte context structs */
 
Index: dev/fdt/xhci_fdt.c
===================================================================
RCS file: /cvs/src/sys/dev/fdt/xhci_fdt.c,v
retrieving revision 1.10
diff -u -p -r1.10 xhci_fdt.c
--- dev/fdt/xhci_fdt.c  3 May 2018 10:57:37 -0000       1.10
+++ dev/fdt/xhci_fdt.c  8 May 2018 08:23:40 -0000
@@ -95,8 +95,6 @@ xhci_fdt_attach(struct device *parent, s
                goto unmap;
        }
 
-       printf("\n");
-
        /* Set up power domain */
        power_domain_enable(sc->sc_node);
 

Reply via email to