Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/mips/rmi Provide OHCI companions devices to EHCI.



details:   https://anonhg.NetBSD.org/src/rev/4ac73f5f95b8
branches:  trunk
changeset: 764635:4ac73f5f95b8
user:      matt <matt%NetBSD.org@localhost>
date:      Fri Apr 29 21:54:14 2011 +0000

description:
Provide OHCI companions devices to EHCI.

diffstat:

 sys/arch/mips/rmi/rmixl_ehci.c    |  21 +++++++++++++++++----
 sys/arch/mips/rmi/rmixl_ohci.c    |  18 +++++++++++++-----
 sys/arch/mips/rmi/rmixl_usbi.c    |  31 +++++--------------------------
 sys/arch/mips/rmi/rmixl_usbivar.h |  26 +++++++++++++++++++++++---
 4 files changed, 58 insertions(+), 38 deletions(-)

diffs (200 lines):

diff -r dfa79deda6a7 -r 4ac73f5f95b8 sys/arch/mips/rmi/rmixl_ehci.c
--- a/sys/arch/mips/rmi/rmixl_ehci.c    Fri Apr 29 21:43:51 2011 +0000
+++ b/sys/arch/mips/rmi/rmixl_ehci.c    Fri Apr 29 21:54:14 2011 +0000
@@ -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;
diff -r dfa79deda6a7 -r 4ac73f5f95b8 sys/arch/mips/rmi/rmixl_ohci.c
--- a/sys/arch/mips/rmi/rmixl_ohci.c    Fri Apr 29 21:43:51 2011 +0000
+++ b/sys/arch/mips/rmi/rmixl_ohci.c    Fri Apr 29 21:54:14 2011 +0000
@@ -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);
 }
-
diff -r dfa79deda6a7 -r 4ac73f5f95b8 sys/arch/mips/rmi/rmixl_usbi.c
--- a/sys/arch/mips/rmi/rmixl_usbi.c    Fri Apr 29 21:43:51 2011 +0000
+++ b/sys/arch/mips/rmi/rmixl_usbi.c    Fri Apr 29 21:54:14 2011 +0000
@@ -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
diff -r dfa79deda6a7 -r 4ac73f5f95b8 sys/arch/mips/rmi/rmixl_usbivar.h
--- a/sys/arch/mips/rmi/rmixl_usbivar.h Fri Apr 29 21:43:51 2011 +0000
+++ b/sys/arch/mips/rmi/rmixl_usbivar.h Fri Apr 29 21:54:14 2011 +0000
@@ -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_ */



Home | Main Index | Thread Index | Old Index