Module Name:    src
Committed By:   martin
Date:           Mon Jan 23 12:05:36 UTC 2023

Modified Files:
        src/sys/dev/pci [netbsd-9]: xhci_pci.c
        src/sys/dev/usb [netbsd-9]: xhci.c xhcivar.h

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1570:

        sys/dev/pci/xhci_pci.c                          1.31 via patch
        sys/dev/usb/xhci.c                              1.173-1.175
        sys/dev/usb/xhcivar.h                           1.22

Support xHCI device which has USB 2 port only.


To generate a diff of this commit:
cvs rdiff -u -r1.21.4.1 -r1.21.4.2 src/sys/dev/pci/xhci_pci.c
cvs rdiff -u -r1.107.2.10 -r1.107.2.11 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.11.4.2 -r1.11.4.3 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.21.4.1 src/sys/dev/pci/xhci_pci.c:1.21.4.2
--- src/sys/dev/pci/xhci_pci.c:1.21.4.1	Mon May 17 15:50:35 2021
+++ src/sys/dev/pci/xhci_pci.c	Mon Jan 23 12:05:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.21.4.1 2021/05/17 15:50:35 martin Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.21.4.2 2023/01/23 12:05:36 martin 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.21.4.1 2021/05/17 15:50:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.21.4.2 2023/01/23 12:05:36 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -267,9 +267,11 @@ 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);
+	if (sc->sc_usb3nports != 0)
+		sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
 
- 	sc->sc_child2 = config_found(self, &sc->sc_bus2, usbctlprint);
+	if (sc->sc_usb2nports != 0)
+		sc->sc_child2 = config_found(self, &sc->sc_bus2, usbctlprint);
 
 	return;
 

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.107.2.10 src/sys/dev/usb/xhci.c:1.107.2.11
--- src/sys/dev/usb/xhci.c:1.107.2.10	Fri Sep 16 18:32:49 2022
+++ src/sys/dev/usb/xhci.c	Mon Jan 23 12:05:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.107.2.10 2022/09/16 18:32:49 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.107.2.11 2023/01/23 12:05:36 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.10 2022/09/16 18:32:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.11 2023/01/23 12:05:36 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1177,7 +1177,11 @@ xhci_id_protocols(struct xhci_softc *sc,
 	case 0x0310:
 	case 0x0320:
 		aprint_debug_dev(sc->sc_dev, " %s ports %d - %d\n",
-		    major == 3 ? "ss" : "hs", cpo, cpo + cpc -1);
+		    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",
@@ -1399,11 +1403,13 @@ xhci_init(struct xhci_softc *sc)
 	/* default all ports to bus 0, i.e. usb 3 */
 	sc->sc_ctlrportbus = kmem_zalloc(
 	    howmany(sc->sc_maxports * sizeof(uint8_t), NBBY), KM_SLEEP);
-	sc->sc_ctlrportmap = kmem_zalloc(sc->sc_maxports * sizeof(int), KM_SLEEP);
+	sc->sc_ctlrportmap =
+	    kmem_zalloc(sc->sc_maxports * sizeof(int), KM_SLEEP);
 
 	/* controller port to bus roothub port map */
 	for (size_t j = 0; j < __arraycount(sc->sc_rhportmap); j++) {
-		sc->sc_rhportmap[j] = kmem_zalloc(sc->sc_maxports * sizeof(int), KM_SLEEP);
+		sc->sc_rhportmap[j] =
+		    kmem_zalloc(sc->sc_maxports * sizeof(int), KM_SLEEP);
 	}
 
 	/*

Index: src/sys/dev/usb/xhcivar.h
diff -u src/sys/dev/usb/xhcivar.h:1.11.4.2 src/sys/dev/usb/xhcivar.h:1.11.4.3
--- src/sys/dev/usb/xhcivar.h:1.11.4.2	Tue Jun 22 05:10:50 2021
+++ src/sys/dev/usb/xhcivar.h	Mon Jan 23 12:05:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhcivar.h,v 1.11.4.2 2021/06/22 05:10:50 martin Exp $	*/
+/*	$NetBSD: xhcivar.h,v 1.11.4.3 2023/01/23 12:05:36 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -103,6 +103,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