Module Name:    src
Committed By:   msaitoh
Date:           Tue Oct 11 09:18:22 UTC 2022

Modified Files:
        src/sys/dev/pci: xhci_pci.c
        src/sys/dev/usb: xhci.c xhcivar.h

Log Message:
There is an xHCI device which has USB 2 port only. Support it.

 - Example:

xhci4 at pci17 dev 0 function 0: AMD product 15b8 (rev. 0x00)
xhci4: 64-bit DMA
allocated pic msix10 type edge pin 0 level 6 to cpu0 slot 32 idt entry 107
xhci4: interrupting at msix10 vec 0
xhci4: xHCI version 1.20
xhci4: hcs1=1000840 hcs2=140000f1 hcs3=7000a
xhci4: hcc=0x110ffc5<XECP=0x110,MAXPSA=0xf,CFC,SEC,SPC,PAE,NSS,LTC,CSZ,AC64>
xhci4: xECP 440
xhci4: hcc2=0x3f<CIC,LEC,CTC,FSC,CMC,U3C>
xhci4: ECR: 0x00000401
xhci4: ECR: 0x02000402
xhci4:  SP: 0x02000402 0x20425355 0x00180101 0x00000000
xhci4:  hs ports 1 - 1
xhci4: ECR: 0x000f000a
xhci4: PAGESIZE 0x00000001
xhci4: sc_pgsz 0x00001000
xhci4: sc_maxslots 0x00000040
xhci4: sc_maxports 1
xhci4: sc_maxspbuf 2
xhci4: eventst: 0x000000013ee60fc0 0xffffb08826f5afc0 1000
xhci4: dcbaa: 0x000000013ee63000 0xffffb08826f5b000 1000
xhci4: current IMOD 0
(snip)
usb8 at xhci4: USB revision 3.1
usb9 at xhci4: USB revision 2.0
uhub8 at usb8: NetBSD (0x0000) xHCI root hub (0x0000), class 9/0, rev 
3.00/1.00, addr 0
uhub8: 0 ports with 0 removable, self powered
uhub8: no ports, hub ignored
uhub8: WARNING: power management not supported
autoconfiguration error: usb8: root device is not a hub
usb8: WARNING: power management not supported
uhub9 at usb9: NetBSD (0x0000) xHCI root hub (0x0000), class 9/0, rev 
2.00/1.00, addr 0
uhub9: 1 port with 1 removable, self powered

 - To resolve this problem, keep number of ports of SS and HS and use
   it to attach child device(s).
 - Tested on ASUS TUF GAMING X670E-PLUS.
 - OK'd by skrll@.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/xhci_pci.c
cvs rdiff -u -r1.172 -r1.173 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/usb/xhcivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.30 src/sys/dev/pci/xhci_pci.c:1.31
--- src/sys/dev/pci/xhci_pci.c:1.30	Sat Aug  7 16:19:14 2021
+++ src/sys/dev/pci/xhci_pci.c	Tue Oct 11 09:18:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.30 2021/08/07 16:19:14 thorpej Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.31 2022/10/11 09:18:22 msaitoh Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.30 2021/08/07 16:19:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.31 2022/10/11 09:18:22 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -287,10 +287,13 @@ xhci_pci_attach(device_t parent, device_
 		aprint_error_dev(self, "couldn't establish power handler\n");
 
 	/* Attach usb buses. */
-	sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint, CFARGS_NONE);
-
- 	sc->sc_child2 = config_found(self, &sc->sc_bus2, usbctlprint,
- 	    CFARGS_NONE);
+	if (sc->sc_usb3nports != 0)
+		sc->sc_child =
+		    config_found(self, &sc->sc_bus, usbctlprint, CFARGS_NONE);
+
+	if (sc->sc_usb2nports != 0)
+		sc->sc_child2 =
+		    config_found(self, &sc->sc_bus2, usbctlprint, CFARGS_NONE);
 
 	return;
 

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.172 src/sys/dev/usb/xhci.c:1.173
--- src/sys/dev/usb/xhci.c:1.172	Sun Sep 25 07:23:07 2022
+++ src/sys/dev/usb/xhci.c	Tue Oct 11 09:18:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.172 2022/09/25 07:23:07 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.173 2022/10/11 09:18:22 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.172 2022/09/25 07:23:07 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.173 2022/10/11 09:18:22 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1214,6 +1214,10 @@ xhci_id_protocols(struct xhci_softc *sc,
 	case 0x0320:
 		aprint_debug_dev(sc->sc_dev, " %s ports %d - %d\n",
 		    major == 3 ? "ss" : "hs", cpo, cpo + cpc -1);
+		if (major == 3)
+			sc->sc_usb3nports = cpo + cpc -1;
+		else
+			sc->sc_usb2nports = cpo + cpc -1;
 		break;
 	default:
 		aprint_error_dev(sc->sc_dev, " unknown major/minor (%d/%d)\n",

Index: src/sys/dev/usb/xhcivar.h
diff -u src/sys/dev/usb/xhcivar.h:1.21 src/sys/dev/usb/xhcivar.h:1.22
--- src/sys/dev/usb/xhcivar.h:1.21	Sun Mar 13 11:30:04 2022
+++ src/sys/dev/usb/xhcivar.h	Tue Oct 11 09:18:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhcivar.h,v 1.21 2022/03/13 11:30:04 riastradh Exp $	*/
+/*	$NetBSD: xhcivar.h,v 1.22 2022/10/11 09:18:22 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -112,6 +112,8 @@ struct xhci_softc {
 	 * Port routing and root hub - xHCI 4.19.7
 	 */
 	int sc_maxports;		/* number of controller ports */
+	int sc_usb3nports;
+	int sc_usb2nports;
 
 	uint8_t *sc_ctlrportbus;	/* a bus bit per port */
 

Reply via email to