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

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

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

        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.8.6.3 -r1.8.6.4 src/sys/dev/pci/xhci_pci.c
cvs rdiff -u -r1.72.2.13 -r1.72.2.14 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.7.6.1 -r1.7.6.2 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.8.6.3 src/sys/dev/pci/xhci_pci.c:1.8.6.4
--- src/sys/dev/pci/xhci_pci.c:1.8.6.3	Sat Nov 16 16:30:09 2019
+++ src/sys/dev/pci/xhci_pci.c	Mon Jan 23 12:10:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.8.6.3 2019/11/16 16:30:09 martin Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.8.6.4 2023/01/23 12:10:12 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.8.6.3 2019/11/16 16:30:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.8.6.4 2023/01/23 12:10:12 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -245,9 +245,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.72.2.13 src/sys/dev/usb/xhci.c:1.72.2.14
--- src/sys/dev/usb/xhci.c:1.72.2.13	Fri Sep 16 18:34:20 2022
+++ src/sys/dev/usb/xhci.c	Mon Jan 23 12:10:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.72.2.13 2022/09/16 18:34:20 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.72.2.14 2023/01/23 12:10:12 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.72.2.13 2022/09/16 18:34:20 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.72.2.14 2023/01/23 12:10:12 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -783,7 +783,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_debug_dev(sc->sc_dev, " unknown major/minor (%d/%d)\n",
@@ -987,11 +991,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.7.6.1 src/sys/dev/usb/xhcivar.h:1.7.6.2
--- src/sys/dev/usb/xhcivar.h:1.7.6.1	Sat Aug 25 11:29:52 2018
+++ src/sys/dev/usb/xhcivar.h	Mon Jan 23 12:10:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhcivar.h,v 1.7.6.1 2018/08/25 11:29:52 martin Exp $	*/
+/*	$NetBSD: xhcivar.h,v 1.7.6.2 2023/01/23 12:10:12 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -100,6 +100,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