Module Name:    src
Committed By:   matt
Date:           Fri Apr 29 21:54:14 UTC 2011

Modified Files:
        src/sys/arch/mips/rmi: rmixl_ehci.c rmixl_ohci.c rmixl_usbi.c
            rmixl_usbivar.h

Log Message:
Provide OHCI companions devices to EHCI.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/rmi/rmixl_ehci.c \
    src/sys/arch/mips/rmi/rmixl_ohci.c src/sys/arch/mips/rmi/rmixl_usbivar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/rmi/rmixl_usbi.c

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/rmi/rmixl_ehci.c
diff -u src/sys/arch/mips/rmi/rmixl_ehci.c:1.2 src/sys/arch/mips/rmi/rmixl_ehci.c:1.3
--- src/sys/arch/mips/rmi/rmixl_ehci.c:1.2	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixl_ehci.c	Fri Apr 29 21:54:14 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_ehci.c,v 1.2 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixl_ehci.c,v 1.3 2011/04/29 21:54:14 matt Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rmixl_ehci.c,v 1.2 2011/02/20 07:48:37 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rmixl_ehci.c,v 1.3 2011/04/29 21:54:14 matt Exp $");
 
 #include "locators.h"
 
@@ -76,8 +76,9 @@
 void
 rmixl_ehci_attach(device_t parent, device_t self, void *aux)
 {
-	ehci_softc_t *sc = device_private(self);
-	struct rmixl_usbi_attach_args *usbi = aux;
+	ehci_softc_t * const sc = device_private(self);
+	rmixl_usbi_softc_t * const psc = device_private(parent);
+	struct rmixl_usbi_attach_args * const usbi = aux;
 	void *ih = NULL;
 	uint32_t r;
 	usbd_status status;
@@ -97,6 +98,18 @@
 	sc->sc_bus.dmatag = usbi->usbi_dmat;
 	sc->sc_bus.usbrev = USBREV_1_0;
 
+	/*
+	 * Grab the companion OHCI devices from our parent.
+	 */
+	if (psc->sc_ohci_devs[1] != NULL) {
+		sc->sc_comps[0] = psc->sc_ohci_devs[0];
+		sc->sc_comps[1] = psc->sc_ohci_devs[1];
+		sc->sc_ncomp = 2;
+	} else {
+		sc->sc_comps[0] = psc->sc_ohci_devs[0];
+		sc->sc_ncomp = 1;
+	}
+
 	if (bus_space_map(sc->iot, usbi->usbi_addr, sc->sc_size, 0, &sc->ioh)) {
 		aprint_error_dev(self, "unable to map registers\n");
 		return;
Index: src/sys/arch/mips/rmi/rmixl_ohci.c
diff -u src/sys/arch/mips/rmi/rmixl_ohci.c:1.2 src/sys/arch/mips/rmi/rmixl_ohci.c:1.3
--- src/sys/arch/mips/rmi/rmixl_ohci.c:1.2	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixl_ohci.c	Fri Apr 29 21:54:14 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_ohci.c,v 1.2 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixl_ohci.c,v 1.3 2011/04/29 21:54:14 matt Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "locators.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rmixl_ohci.c,v 1.2 2011/02/20 07:48:37 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rmixl_ohci.c,v 1.3 2011/04/29 21:54:14 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -77,8 +77,9 @@
 void
 rmixl_ohci_attach(device_t parent, device_t self, void *aux)
 {
-	ohci_softc_t *sc = device_private(self);
-	struct rmixl_usbi_attach_args *usbi = aux;
+	ohci_softc_t * const sc = device_private(self);
+	rmixl_usbi_softc_t * const psc = device_private(parent);
+	struct rmixl_usbi_attach_args * const usbi = aux;
 	void *ih = NULL;
 	uint32_t r;
 	usbd_status status;
@@ -126,7 +127,14 @@
 		return;
 	}
 
+	if (psc->sc_ohci_devs[0] == NULL) {
+		psc->sc_ohci_devs[0] = self;
+	} else if (psc->sc_ohci_devs[1] == NULL) {
+		psc->sc_ohci_devs[1] = self;
+	} else {
+		panic("%s: too many ohci devices", __func__);
+	}
+
 	/* Attach USB device */
 	sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
 }
-
Index: src/sys/arch/mips/rmi/rmixl_usbivar.h
diff -u src/sys/arch/mips/rmi/rmixl_usbivar.h:1.2 src/sys/arch/mips/rmi/rmixl_usbivar.h:1.3
--- src/sys/arch/mips/rmi/rmixl_usbivar.h:1.2	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixl_usbivar.h	Fri Apr 29 21:54:14 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_usbivar.h,v 1.2 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixl_usbivar.h,v 1.3 2011/04/29 21:54:14 matt Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -44,7 +44,27 @@
 	bus_dma_tag_t	usbi_dmat;
 };
 
-extern void *rmixl_usbi_intr_establish(void *, u_int, int (*)(void *), void *);
-extern void  rmixl_usbi_intr_disestablish(void *, void *);
+typedef struct rmixl_usbi_dispatch {
+	int (*func)(void *);
+	void *arg; 
+	struct evcnt count;
+} rmixl_usbi_dispatch_t;
+
+typedef struct rmixl_usbi_softc {
+	device_t		sc_dev;
+	bus_space_tag_t		sc_eb_bst;
+	bus_space_tag_t		sc_el_bst;
+	bus_addr_t		sc_addr;
+	bus_size_t		sc_size;
+	bus_dma_tag_t		sc_dmat;
+	device_t		sc_ohci_devs[2];
+	rmixl_usbi_dispatch_t	sc_dispatch[RMIXL_UB_INTERRUPT_MAX + 1];
+} rmixl_usbi_softc_t;
+
+
+#ifdef _KERNEL
+void *rmixl_usbi_intr_establish(void *, u_int, int (*)(void *), void *);
+void  rmixl_usbi_intr_disestablish(void *, void *);
+#endif
 
 #endif /* _MIPS_RMI_RMIXL_USBIVAR_H_ */

Index: src/sys/arch/mips/rmi/rmixl_usbi.c
diff -u src/sys/arch/mips/rmi/rmixl_usbi.c:1.3 src/sys/arch/mips/rmi/rmixl_usbi.c:1.4
--- src/sys/arch/mips/rmi/rmixl_usbi.c:1.3	Thu Apr 14 05:20:52 2011
+++ src/sys/arch/mips/rmi/rmixl_usbi.c	Fri Apr 29 21:54:14 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_usbi.c,v 1.3 2011/04/14 05:20:52 cliff Exp $	*/
+/*	$NetBSD: rmixl_usbi.c,v 1.4 2011/04/29 21:54:14 matt Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rmixl_usbi.c,v 1.3 2011/04/14 05:20:52 cliff Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rmixl_usbi.c,v 1.4 2011/04/29 21:54:14 matt Exp $");
 
 #include "locators.h"
 
@@ -61,7 +61,7 @@
 #define RMIXL_USBI_GEN_READ(o)     le32toh(*RMIXL_USBI_GEN_VADDR(o))
 #define RMIXL_USBI_GEN_WRITE(o,v)  *RMIXL_USBI_GEN_VADDR(o) = htole32(v)
 
-static const char *rmixl_usbi_intrnames[RMIXL_UB_INTERRUPT_MAX+1] = {
+static const char rmixl_usbi_intrnames[RMIXL_UB_INTERRUPT_MAX+1][16] = {
 	"int 0 (ohci0)",
 	"int 1 (ohci1)",
 	"int 2 (ehci)",
@@ -70,23 +70,6 @@
 	"int 5 (force)"
 };
 
-typedef struct rmixl_usbi_dispatch {
-	int (*func)(void *);
-	void *arg; 
-	struct evcnt count;
-} rmixl_usbi_dispatch_t;
-
-typedef struct rmixl_usbi_softc {
-	device_t		sc_dev;
-	bus_space_tag_t		sc_eb_bst;
-	bus_space_tag_t		sc_el_bst;
-	bus_addr_t		sc_addr;
-	bus_size_t		sc_size;
-	bus_dma_tag_t		sc_dmat;
-	rmixl_usbi_dispatch_t	sc_dispatch[RMIXL_UB_INTERRUPT_MAX + 1];
-} rmixl_usbi_softc_t;
-
-
 static int	rmixl_usbi_match(device_t, cfdata_t, void *);
 static void	rmixl_usbi_attach(device_t, device_t, void *);
 static int  	rmixl_usbi_print(void *, const char *);
@@ -146,12 +129,8 @@
 	 * fail attach if USB interface BIST failed
 	 */
         r = RMIXL_IOREG_READ(RMIXL_IO_DEV_GPIO + RMIXL_GPIO_BIST_EACH_STS);
-	aprint_normal(": BIST status=");
-	if ((r & __BIT(18)) == 0) {			/* XXX USB_BIST */
-		aprint_normal("FAIL,");
-	} else {
-		aprint_normal("OK,");
-	}
+	aprint_normal(": BIST status=%s,",
+	    (r & __BIT(18)) ? "OK" : "FAIL");		/* XXX USB_BIST */
 
 	/*
 	 * set BYTESWAP_EN register nonzero when software is little endian

Reply via email to