amusbss.c: properly attach ammusb drivers to parent simplebus(4) device
authorkremlin <ian@kremlin.cc>
Sun, 12 Feb 2017 02:19:21 +0000 (20:19 -0600)
committerkremlin <ian@kremlin.cc>
Sun, 12 Feb 2017 02:19:21 +0000 (20:19 -0600)
src/sys/arch/armv7/omap/amusbss.c

index 9d5abe665c3a06de380b5d97771bfc22f1bf8d6d..d18796710edd9e213a71fdf992acdb2c1c1562ce 100644 (file)
@@ -22,6 +22,8 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
+ *
+ * USB subsystem driver for am335x. Derived from FreeBSD version.
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -84,22 +86,25 @@ int amusbss_debug = 20;
 
 struct amusbss_softc {
        struct device           sc_dev;
 
 struct amusbss_softc {
        struct device           sc_dev;
-//     struct simplebus_softc  sc_dev;
        bus_space_tag_t         sc_iot;
        bus_space_handle_t      sc_ioh;
 };
 
        bus_space_tag_t         sc_iot;
        bus_space_handle_t      sc_ioh;
 };
 
-/*  core decl */
+/* Needed in attaching ammusb devices via config_search(9) */
+extern struct cfattach ammusb_ca;
+//extern void simplebus_attach_node(struct device *, int);
+
+/* core decl */
 int  amusbss_match(struct device *, void *, void *);
 void amusbss_attach(struct device *, struct device *, void *);
 int  amusbss_detach(struct device *, int);
 void amusbss_reset(struct amusbss_softc *);
 
 int  amusbss_match(struct device *, void *, void *);
 void amusbss_attach(struct device *, struct device *, void *);
 int  amusbss_detach(struct device *, int);
 void amusbss_reset(struct amusbss_softc *);
 
-/*  debug decl */
+/* debug decl */
 void amusbss_preg(uint32_t, char *, struct amusbss_softc *);
 void amusbss_dumpregs(struct amusbss_softc *);
 
 void amusbss_preg(uint32_t, char *, struct amusbss_softc *);
 void amusbss_dumpregs(struct amusbss_softc *);
 
-/*  core/iomux.c def */
+/*  core/iomux.c defs */
 struct cfattach amusbss_ca = {
        sizeof (struct amusbss_softc), amusbss_match, amusbss_attach, amusbss_detach
 };
 struct cfattach amusbss_ca = {
        sizeof (struct amusbss_softc), amusbss_match, amusbss_attach, amusbss_detach
 };
@@ -112,7 +117,6 @@ int
 amusbss_match(struct device *parent, void *v, void *aux)
 {
        struct fdt_attach_args *faa = aux;
 amusbss_match(struct device *parent, void *v, void *aux)
 {
        struct fdt_attach_args *faa = aux;
-panic("its openbsd");
        return OF_is_compatible(faa->fa_node, "ti,am33xx-usb");
 }
 
        return OF_is_compatible(faa->fa_node, "ti,am33xx-usb");
 }
 
@@ -121,19 +125,14 @@ amusbss_attach(struct device *parent, struct device *self, void *args)
 {
        struct amusbss_softc    *sc = (struct amusbss_softc *) self;
        struct fdt_attach_args  *faa = args;
 {
        struct amusbss_softc    *sc = (struct amusbss_softc *) self;
        struct fdt_attach_args  *faa = args;
-
        int i, node;
        uint32_t rev;
 
        int i, node;
        uint32_t rev;
 
-//     struct fdt_attach_args
-//     char *name
-
        sc->sc_iot = faa->fa_iot;
        if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, faa->fa_reg[0].size, 0,
            &sc->sc_ioh))
                panic("%s: bus_space_map failed!", __func__);
 
        sc->sc_iot = faa->fa_iot;
        if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, faa->fa_reg[0].size, 0,
            &sc->sc_ioh))
                panic("%s: bus_space_map failed!", __func__);
 
-
        /* Enable device clocks */
        prcm_enablemodule(PRCM_USB);
 
        /* Enable device clocks */
        prcm_enablemodule(PRCM_USB);
 
@@ -153,9 +152,8 @@ amusbss_attach(struct device *parent, struct device *self, void *args)
        printf(": rev %d.%d\n", rev >> 4 &0xf, rev & 0xf);
 
        /* Walk the OFW tree and attach top-level devices */
        printf(": rev %d.%d\n", rev >> 4 &0xf, rev & 0xf);
 
        /* Walk the OFW tree and attach top-level devices */
-       for (node = OF_child(faa->fa_node); node > 0; node = OF_peer(node)) {
-               
-       }
+       for (node = OF_child(faa->fa_node); node > 0; node = OF_peer(node))
+           simplebus_attach_node(parent, node);
 }
 
 int
 }
 
 int