Subject: port-sparc/24199: SUN4D clock doesnt attach to the bootbus
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <ssukovich@tampabay.rr.com>
List: netbsd-bugs
Date: 01/23/2004 01:26:29
>Number:         24199
>Category:       port-sparc
>Synopsis:       SUN4D clock doesnt attach to the bootbus
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    port-sparc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 23 01:27:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Stephen Sukovich
>Release:        1.6ZH
>Organization:
>Environment:
NetBSD foxden 1.6ZH NetBSD 1.6ZH (GENERIC.MP) #0: Tue Jan 20 15:54:51 EST 2004  root@foxden:/usr/obj/sys/arch/i386/compile/GENERIC.MP i386

>Description:
the clock doesnt attach at boot to the bootbus since there is no code for it
>How-To-Repeat:
just compile a kernel for a SUN4D machine and boot :)
>Fix:
here are 2 patches should fix it

Index: files.sparc
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/conf/files.sparc,v
retrieving revision 1.124
diff -u -r1.124 files.sparc
--- files.sparc 2003/11/15 17:52:30     1.124
+++ files.sparc 2004/01/23 01:24:41
@@ -74,6 +74,7 @@
 device clock: mk48txx
 attach clock at mainbus with clock_mainbus
 attach clock at obio with clock_obio
+attach clock at bootbus with clock_bootbus
 file   arch/sparc/sparc/mkclock.c              clock


Index: mkclock.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/sparc/mkclock.c,v
retrieving revision 1.9
diff -u -r1.9 mkclock.c
--- mkclock.c   2003/11/02 12:59:18     1.9
+++ mkclock.c   2004/01/23 01:16:01
@@ -58,6 +58,8 @@
 #include <machine/promlib.h>
 #include <machine/cpu.h>

+#include <sparc/dev/bootbusvar.h>
+
 #include <dev/clock_subr.h>
 #include <dev/ic/mk48txxreg.h>
 #include <dev/ic/mk48txxvar.h>
@@ -70,8 +72,10 @@
 static int     mk_nvram_wenable(int);

 static int     clockmatch_mainbus (struct device *, struct cfdata *, void *);
+static int     clockmatch_bootbus (struct device *, struct cfdata *, void *);
 static int     clockmatch_obio(struct device *, struct cfdata *, void *);
 static void    clockattach_mainbus(struct device *, struct device *, void *);
+static void    clockattach_bootbus(struct device *, struct device *, void *);
 static void    clockattach_obio(struct device *, struct device *, void *);

 static void    clockattach(struct mk48txx_softc *, int);
@@ -82,6 +86,9 @@
 CFATTACH_DECL(clock_obio, sizeof(struct mk48txx_softc),
     clockmatch_obio, clockattach_obio, NULL, NULL);

+CFATTACH_DECL(clock_bootbus, sizeof(struct mk48txx_softc),
+    clockmatch_bootbus, clockattach_bootbus, NULL, NULL);
+
 /* Imported from clock.c: */
 extern todr_chip_handle_t todr_handle;
 extern int (*eeprom_nvram_wenable)(int);
@@ -103,6 +110,18 @@
 }

 static int
+clockmatch_bootbus(parent, cf, aux)
+       struct device *parent;
+       struct cfdata *cf;
+       void *aux;
+{
+       struct bootbus_attach_args *baa = aux;
+
+       return (strcmp("eeprom", baa->ba_name) == 0);
+
+}
+
+static int
 clockmatch_obio(parent, cf, aux)
        struct device *parent;
        struct cfdata *cf;
@@ -162,6 +181,27 @@
        }

        clockattach(sc, ma->ma_node);
+}
+
+static void
+clockattach_bootbus(parent, self, aux)
+       struct device *parent, *self;
+       void *aux;
+{
+       struct mk48txx_softc *sc = (void *)self;
+        struct bootbus_attach_args *baa = aux;
+        sc->sc_bst = baa->ba_bustag;
+
+        if (bus_space_map(sc->sc_bst,
+                          BUS_ADDR(baa->ba_reg[0].oa_space, baa->ba_reg[0].oa_base),
+                          baa->ba_reg[0].oa_size,
+                           BUS_SPACE_MAP_LINEAR,
+                           &sc->sc_bsh) != 0) {
+                printf("%s: can't map register\n", self->dv_xname);
+                return;
+        }
+
+        clockattach(sc, baa->ba_node);
 }

 static void

>Release-Note:
>Audit-Trail:
>Unformatted: