Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/macppc/dev provide a bus_space to child devices



details:   https://anonhg.NetBSD.org/src/rev/e64e38de6cd3
branches:  trunk
changeset: 826598:e64e38de6cd3
user:      macallan <macallan%NetBSD.org@localhost>
date:      Fri Sep 15 21:33:52 2017 +0000

description:
provide a bus_space to child devices

diffstat:

 sys/arch/macppc/dev/uni-n.c |  26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diffs (90 lines):

diff -r 39ac04ed69b6 -r e64e38de6cd3 sys/arch/macppc/dev/uni-n.c
--- a/sys/arch/macppc/dev/uni-n.c       Fri Sep 15 21:31:25 2017 +0000
+++ b/sys/arch/macppc/dev/uni-n.c       Fri Sep 15 21:33:52 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uni-n.c,v 1.6 2011/10/26 13:54:18 macallan Exp $       */
+/*     $NetBSD: uni-n.c,v 1.7 2017/09/15 21:33:52 macallan Exp $       */
 
 /*-
  * Copyright (C) 2005 Michael Lorenz.
@@ -31,7 +31,7 @@
  */
  
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uni-n.c,v 1.6 2011/10/26 13:54:18 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uni-n.c,v 1.7 2017/09/15 21:33:52 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -39,6 +39,7 @@
 #include <sys/device.h>
 
 #include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_pci.h>
 
 #include <machine/autoconf.h>
 
@@ -48,6 +49,7 @@
 
 struct uni_n_softc {
        device_t sc_dev;
+       struct powerpc_bus_space sc_memt;
        int sc_node;
 };
 
@@ -59,14 +61,16 @@
 {
        struct confargs *ca = aux;
        char compat[32];
-       if (strcmp(ca->ca_name, "uni-n") != 0)
+       if ((strcmp(ca->ca_name, "uni-n") != 0) &&
+           (strcmp(ca->ca_name, "u4") != 0))
                return 0;
 
        memset(compat, 0, sizeof(compat));
+#if 0
        OF_getprop(ca->ca_node, "compatible", compat, sizeof(compat));
        if (strcmp(compat, "uni-north") != 0)
                return 0;
-
+#endif
        return 1;
 }
 
@@ -85,10 +89,17 @@
        char name[32];
 
        sc->sc_dev = self;
-       node = OF_finddevice("/uni-n");
+       node = our_ca->ca_node;
        sc->sc_node = node;
        printf(" address 0x%08x\n",our_ca->ca_reg[0]);
-       
+
+       memset(&sc->sc_memt, 0, sizeof(struct powerpc_bus_space));
+       sc->sc_memt.pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE;
+       if (ofwoea_map_space(RANGE_TYPE_MACIO, RANGE_MEM, node, &sc->sc_memt,
+           "uni-n mem-space") != 0) {
+               panic("Can't init uni-n mem tag");
+       }
+
        for (child = OF_child(node); child; child = OF_peer(child)) {
                namelen = OF_getprop(child, "name", name, sizeof(name));
                if (namelen < 0)
@@ -99,7 +110,7 @@
                name[namelen] = 0;
                ca.ca_name = name;
                ca.ca_node = child;
-
+               ca.ca_tag = &sc->sc_memt;
                ca.ca_nreg  = OF_getprop(child, "reg", reg, sizeof(reg));
                ca.ca_nintr = OF_getprop(child, "AAPL,interrupts", intr,
                                sizeof(intr));
@@ -109,7 +120,6 @@
 
                ca.ca_reg = reg;
                ca.ca_intr = intr;
-
                config_found(self, &ca, uni_n_print);
        }
 }



Home | Main Index | Thread Index | Old Index