Module Name: src
Committed By: skrll
Date: Fri Sep 11 06:51:44 UTC 2015
Modified Files:
src/sys/arch/mips/atheros/dev: ehci_arbus.c
src/sys/arch/powerpc/booke/dev: pq3ehci.c
src/sys/dev/usb: ehci.c ehcireg.h
Log Message:
Fix up USBMODE registers in sc_vendor_init functions and not in the ehci
driver.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/atheros/dev/ehci_arbus.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/booke/dev/pq3ehci.c
cvs rdiff -u -r1.244 -r1.245 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/usb/ehcireg.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/arch/mips/atheros/dev/ehci_arbus.c
diff -u src/sys/arch/mips/atheros/dev/ehci_arbus.c:1.2 src/sys/arch/mips/atheros/dev/ehci_arbus.c:1.3
--- src/sys/arch/mips/atheros/dev/ehci_arbus.c:1.2 Fri Jul 20 02:14:02 2012
+++ src/sys/arch/mips/atheros/dev/ehci_arbus.c Fri Sep 11 06:51:43 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci_arbus.c,v 1.2 2012/07/20 02:14:02 matt Exp $ */
+/* $NetBSD: ehci_arbus.c,v 1.3 2015/09/11 06:51:43 skrll Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci_arbus.c,v 1.2 2012/07/20 02:14:02 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci_arbus.c,v 1.3 2015/09/11 06:51:43 skrll Exp $");
#include "locators.h"
@@ -50,12 +50,24 @@ __KERNEL_RCSID(0, "$NetBSD: ehci_arbus.c
#include <dev/usb/ehcireg.h>
#include <dev/usb/ehcivar.h>
+/*
+ * This is relative to the start of the unreserved registers in USB contoller
+ * block and not the full USB block which would be 0x1a8.
+ */
+#define ARBUS_USBMODE 0xa8 /* USB mode */
+#define USBMODE_CM __BITS(0,1) /* Controller Mode */
+#define USBMODE_CM_IDLE __SHIFTIN(0,USBMODE_CM) /* Idle (both) */
+#define USBMODE_CM_DEVICE __SHIFTIN(2,USBMODE_CM) /* Device Controller */
+#define USBMODE_CM_HOST __SHIFTIN(3,USBMODE_CM) /* Host Controller */
+
static int ehci_arbus_match(device_t, cfdata_t, void *);
static void ehci_arbus_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(ehci_arbus, sizeof (ehci_softc_t),
ehci_arbus_match, ehci_arbus_attach, NULL, NULL);
+static void ehci_arbus_init(struct ehci_soft *);
+
int
ehci_arbus_match(device_t parent, cfdata_t cf, void *aux)
{
@@ -85,6 +97,7 @@ ehci_arbus_attach(device_t parent, devic
sc->sc_bus.dmatag = aa->aa_dmat;
sc->sc_bus.usbrev = USBREV_1_0;
sc->sc_flags |= EHCIF_ETTF;
+ sc->sc_vendor_init = ehci_arbus_init;
error = bus_space_map(aa->aa_bst, aa->aa_addr, aa->aa_size, 0,
&sc->ioh);
@@ -136,3 +149,16 @@ ehci_arbus_attach(device_t parent, devic
sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
}
+static void
+ehci_arbus_init(struct ehci_softc *sc)
+{
+ /* Set host mode */
+ uint32_t old = bus_space_read_4(sc->iot, sc->ioh, ARBUS_USBMODE);
+ uint32_t reg = old;
+
+ reg &= ~USBMODE_CM;
+ reg |= USBMODE_CM_HOST;
+ if (reg != old)
+ bus_space_write_4(sc->iot, sc->ioh, ARBUS_USBMODE, reg);
+
+}
Index: src/sys/arch/powerpc/booke/dev/pq3ehci.c
diff -u src/sys/arch/powerpc/booke/dev/pq3ehci.c:1.5 src/sys/arch/powerpc/booke/dev/pq3ehci.c:1.6
--- src/sys/arch/powerpc/booke/dev/pq3ehci.c:1.5 Fri Jul 20 02:14:01 2012
+++ src/sys/arch/powerpc/booke/dev/pq3ehci.c Fri Sep 11 06:51:43 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: pq3ehci.c,v 1.5 2012/07/20 02:14:01 matt Exp $ */
+/* $NetBSD: pq3ehci.c,v 1.6 2015/09/11 06:51:43 skrll Exp $ */
/*-
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pq3ehci.c,v 1.5 2012/07/20 02:14:01 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3ehci.c,v 1.6 2015/09/11 06:51:43 skrll Exp $");
#include "opt_usb.h"
@@ -54,6 +54,16 @@ __KERNEL_RCSID(0, "$NetBSD: pq3ehci.c,v
#include <dev/usb/ehcireg.h>
#include <dev/usb/ehcivar.h>
+/*
+ * This is relative to the start of the unreserved registers in USB contoller
+ * block and not the full USB block which would be 0x1a8.
+ */
+#define PQ3_USBMODE 0xa8 /* USB mode */
+#define USBMODE_CM __BITS(0,1) /* Controller Mode */
+#define USBMODE_CM_IDLE __SHIFTIN(0,USBMODE_CM) /* Idle (both) */
+#define USBMODE_CM_DEVICE __SHIFTIN(2,USBMODE_CM) /* Device Controller */
+#define USBMODE_CM_HOST __SHIFTIN(3,USBMODE_CM) /* Host Controller */
+
#ifdef EHCI_DEBUG
#define DPRINTF(x) if (ehcidebug) printf x
extern int ehcidebug;
@@ -69,6 +79,8 @@ struct pq3ehci_softc {
void *sc_ih; /* interrupt vectoring */
};
+static void pq3ehci_init(struct ehci_softc *);
+
CFATTACH_DECL_NEW(pq3ehci, sizeof(struct pq3ehci_softc),
pq3ehci_match, pq3ehci_attach, NULL, NULL);
@@ -99,6 +111,7 @@ pq3ehci_attach(device_t parent, device_t
sc->sc.sc_bus.usbrev = USBREV_2_0;
sc->sc.sc_ncomp = 0;
sc->sc.sc_flags |= EHCIF_ETTF;
+ sc->sc.sc_vendor_init = pq3ehci_init;
aprint_naive(": USB controller\n");
aprint_normal(": USB controller\n");
@@ -161,3 +174,15 @@ fail:
}
return;
}
+
+static void
+pq3ehci_init(struct ehci_softc *hsc)
+{
+ uint32_t old = bus_space_read_4(hsc->iot, hsc->ioh, PQ3_USBMODE);
+ uint32_t reg = old;
+
+ reg &= ~USBMODE_CM;
+ reg |= USBMODE_CM_HOST;
+ if (reg != old)
+ bus_space_write_4(hsc->iot, hsc->ioh, PQ3_USBMODE, reg);
+}
Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.244 src/sys/dev/usb/ehci.c:1.245
--- src/sys/dev/usb/ehci.c:1.244 Mon Aug 24 23:55:04 2015
+++ src/sys/dev/usb/ehci.c Fri Sep 11 06:51:43 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci.c,v 1.244 2015/08/24 23:55:04 pooka Exp $ */
+/* $NetBSD: ehci.c,v 1.245 2015/09/11 06:51:43 skrll Exp $ */
/*
* Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.244 2015/08/24 23:55:04 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.245 2015/09/11 06:51:43 skrll Exp $");
#include "ohci.h"
#include "uhci.h"
@@ -450,17 +450,6 @@ ehci_init(ehci_softc_t *sc)
if (sc->sc_vendor_init)
sc->sc_vendor_init(sc);
- /*
- * If we are doing embedded transaction translation function, force
- * the controller to host mode.
- */
- if (sc->sc_flags & EHCIF_ETTF) {
- uint32_t usbmode = EOREAD4(sc, EHCI_USBMODE);
- usbmode &= ~EHCI_USBMODE_CM;
- usbmode |= EHCI_USBMODE_CM_HOST;
- EOWRITE4(sc, EHCI_USBMODE, usbmode);
- }
-
/* XXX need proper intr scheduling */
sc->sc_rand = 96;
Index: src/sys/dev/usb/ehcireg.h
diff -u src/sys/dev/usb/ehcireg.h:1.35 src/sys/dev/usb/ehcireg.h:1.36
--- src/sys/dev/usb/ehcireg.h:1.35 Sat Sep 5 06:13:54 2015
+++ src/sys/dev/usb/ehcireg.h Fri Sep 11 06:51:43 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: ehcireg.h,v 1.35 2015/09/05 06:13:54 skrll Exp $ */
+/* $NetBSD: ehcireg.h,v 1.36 2015/09/11 06:51:43 skrll Exp $ */
/*
* Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
@@ -175,15 +175,6 @@
#define EHCI_PORT_RESET_COMPLETE 2 /* ms */
-#define EHCI_USBMODE 0xa8 /* USB Device mode */
-#define EHCI_USBMODE_SDIS __BIT(4) /* Stream disable mode 1=act */
-#define EHCI_USBMODE_SLOM __BIT(3) /* setup lockouts on */
-#define EHCI_USBMODE_ES __BIT(2) /* Endian Select ES=1 */
-#define EHCI_USBMODE_CM __BITS(0,1) /* Controller Mode */
-#define EHCI_USBMODE_CM_IDLE 0x00 /* Idle (combo host/device) */
-#define EHCI_USBMODE_CM_DEV 0x02 /* Device Controller */
-#define EHCI_USBMODE_CM_HOST 0x03 /* Host Controller */
-
#define EHCI_FLALIGN_ALIGN 0x1000
#define EHCI_MAX_PORTS 16 /* only 4 bits available in EHCI_HCS_N_PORTS */