Module Name:    src
Committed By:   skrll
Date:           Tue Jan 28 17:24:42 UTC 2014

Modified Files:
        src/sys/dev/pci: ohci_pci.c
        src/sys/dev/usb: ohci.c ohcireg.h ohcivar.h

Log Message:
Support the OHCI in the NS "SUPERIO" chip as found in hppa machines by
twiddling the same bits as Linux.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/pci/ohci_pci.c
cvs rdiff -u -r1.248 -r1.249 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/usb/ohcireg.h
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/usb/ohcivar.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/ohci_pci.c
diff -u src/sys/dev/pci/ohci_pci.c:1.50 src/sys/dev/pci/ohci_pci.c:1.51
--- src/sys/dev/pci/ohci_pci.c:1.50	Sun Jun 10 06:15:53 2012
+++ src/sys/dev/pci/ohci_pci.c	Tue Jan 28 17:24:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci_pci.c,v 1.50 2012/06/10 06:15:53 mrg Exp $	*/
+/*	$NetBSD: ohci_pci.c,v 1.51 2014/01/28 17:24:42 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci_pci.c,v 1.50 2012/06/10 06:15:53 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci_pci.c,v 1.51 2014/01/28 17:24:42 skrll Exp $");
 
 #include "ehci.h"
 
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: ohci_pci.c,v
 #include <sys/bus.h>
 
 #include <dev/pci/pcivar.h>
+#include <dev/pci/pcidevs.h>
 #include <dev/pci/usb_pci.h>
 
 #include <dev/usb/usb.h>
@@ -94,6 +95,11 @@ ohci_pci_attach(device_t parent, device_
 	sc->sc.sc_dev = self;
 	sc->sc.sc_bus.hci_private = sc;
 
+	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_NS &&
+	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NS_USB) {
+		sc->sc.sc_flags = OHCIF_SUPERIO;
+	}
+
 	pci_aprint_devinfo(pa, "USB Controller");
 
 	/* check if memory space access is enabled */

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.248 src/sys/dev/usb/ohci.c:1.249
--- src/sys/dev/usb/ohci.c:1.248	Mon Dec 16 10:04:20 2013
+++ src/sys/dev/usb/ohci.c	Tue Jan 28 17:24:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.248 2013/12/16 10:04:20 skrll Exp $	*/
+/*	$NetBSD: ohci.c,v 1.249 2014/01/28 17:24:42 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.248 2013/12/16 10:04:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.249 2014/01/28 17:24:42 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -859,6 +859,18 @@ ohci_init(ohci_softc_t *sc)
 	per = OHCI_PERIODIC(ival); /* 90% periodic */
 	OWRITE4(sc, OHCI_PERIODIC_START, per);
 
+	if (sc->sc_flags & OHCIF_SUPERIO) {
+		/* no overcurrent protection */
+		desca |= OHCI_NOCP;
+		/*
+		 * Clear NoPowerSwitching and PowerOnToPowerGoodTime meaning
+		 * that
+		 *  - ports are always power switched
+		 *  - don't wait for powered root hub port
+		 */
+		desca &= ~(__SHIFTIN(0xff, OHCI_POTPGT_MASK) | OHCI_NPS);
+	}
+
 	/* Fiddle the No OverCurrent Protection bit to avoid chip bug. */
 	OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca | OHCI_NOCP);
 	OWRITE4(sc, OHCI_RH_STATUS, OHCI_LPSC); /* Enable port power */

Index: src/sys/dev/usb/ohcireg.h
diff -u src/sys/dev/usb/ohcireg.h:1.23 src/sys/dev/usb/ohcireg.h:1.24
--- src/sys/dev/usb/ohcireg.h:1.23	Mon Apr 28 20:23:59 2008
+++ src/sys/dev/usb/ohcireg.h	Tue Jan 28 17:24:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohcireg.h,v 1.23 2008/04/28 20:23:59 martin Exp $	*/
+/*	$NetBSD: ohcireg.h,v 1.24 2014/01/28 17:24:42 skrll Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/ohcireg.h,v 1.8 1999/11/17 22:33:40 n_hibma Exp $	*/
 
 
@@ -107,6 +107,7 @@
 #define  OHCI_OCPM		0x0800     /* Overcurrent Protection Mode */
 #define  OHCI_NOCP		0x1000     /* No Overcurrent Protection */
 #define  OHCI_GET_POTPGT(s)	((s) >> 24)
+#define  OHCI_POTPGT_MASK	0xff000000
 #define OHCI_RH_DESCRIPTOR_B	0x4c
 #define OHCI_RH_STATUS		0x50
 #define  OHCI_LPS		0x00000001 /* Local Power Status */

Index: src/sys/dev/usb/ohcivar.h
diff -u src/sys/dev/usb/ohcivar.h:1.54 src/sys/dev/usb/ohcivar.h:1.55
--- src/sys/dev/usb/ohcivar.h:1.54	Tue Jan 29 00:00:15 2013
+++ src/sys/dev/usb/ohcivar.h	Tue Jan 28 17:24:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohcivar.h,v 1.54 2013/01/29 00:00:15 christos Exp $	*/
+/*	$NetBSD: ohcivar.h,v 1.55 2014/01/28 17:24:42 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -117,6 +117,9 @@ typedef struct ohci_softc {
 #define	OHCI_BIG_ENDIAN		1	/* big endian OHCI? never seen it */
 #define	OHCI_HOST_ENDIAN	2	/* if OHCI always matches CPU */
 
+	int sc_flags;
+#define OHCIF_SUPERIO		0x0001
+
 	char sc_softwake;
 	kcondvar_t sc_softwake_cv;
 

Reply via email to