Module Name:    src
Committed By:   nisimura
Date:           Sat May 12 13:13:24 UTC 2012

Modified Files:
        src/sys/arch/sandpoint/sandpoint: autoconf.c iic_eumb.c

Log Message:
Move I2C node adjustment stuff to autoconf.c from iic_eumb.c for
the ease of maintainance.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/sandpoint/sandpoint/autoconf.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/sandpoint/iic_eumb.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/sandpoint/sandpoint/autoconf.c
diff -u src/sys/arch/sandpoint/sandpoint/autoconf.c:1.24 src/sys/arch/sandpoint/sandpoint/autoconf.c:1.25
--- src/sys/arch/sandpoint/sandpoint/autoconf.c:1.24	Thu Jan 19 07:38:06 2012
+++ src/sys/arch/sandpoint/sandpoint/autoconf.c	Sat May 12 13:13:24 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.24 2012/01/19 07:38:06 nisimura Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.25 2012/05/12 13:13:24 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.24 2012/01/19 07:38:06 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.25 2012/05/12 13:13:24 nisimura Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -54,6 +54,25 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 static struct btinfo_rootdevice *bi_rdev;
 static struct btinfo_bootpath *bi_path;
 static struct btinfo_net *bi_net;
+static struct btinfo_prodfamily *bi_pfam;
+
+struct i2cdev {
+	const char *family;
+	const char *name;
+	int addr;
+};
+
+static struct i2cdev rtcmodel[] = {
+    { "dlink",    "strtc",      0x68 },
+    { "iomega",   "dsrtc",      0x68 },
+    { "kurobox",  "rs5c372rtc", 0x32 },
+    { "kurot4",   "rs5c372rtc", 0x32 },
+    { "nhnas",    "pcf8563rtc", 0x51 },
+    { "qnap",     "s390rtc",    0x30 },
+    { "synology", "rs5c372rtc", 0x32 },
+};
+
+static void add_i2c_child_devices(device_t, const char *);
 
 /*
  * Determine i/o configuration for a machine.
@@ -65,6 +84,7 @@ cpu_configure(void)
 	bi_rdev = lookup_bootinfo(BTINFO_ROOTDEVICE);
 	bi_path = lookup_bootinfo(BTINFO_BOOTPATH);
 	bi_net = lookup_bootinfo(BTINFO_NET);
+	bi_pfam = lookup_bootinfo(BTINFO_PRODFAMILY);
 
 	if (config_rootfound("mainbus", NULL) == NULL)
 		panic("configure: mainbus not configured");
@@ -105,8 +125,7 @@ device_register(device_t dev, void *aux)
 			net_tag = pa->pa_tag;
 		}
 	}
-
-	if (device_class(dev) == DV_IFNET) {
+	else if (device_class(dev) == DV_IFNET) {
 		if (device_is_a(device_parent(dev), "pci")) {
 			pa = aux;
 			tag = pa->pa_tag;
@@ -136,10 +155,41 @@ device_register(device_t dev, void *aux)
 			bi_net = NULL;	/* do it just once */
 		}
 	}
-	if (bi_rdev != NULL && device_class(dev) == DV_DISK
+	else if (bi_rdev != NULL && device_class(dev) == DV_DISK
 	    && device_is_a(dev, bi_rdev->devname)
 	    && device_unit(dev) == (bi_rdev->cookie >> 8)) {
 		booted_device = dev;
 		booted_partition = bi_rdev->cookie & 0xff;
 	}
+	else if (device_is_a(dev, "ociic") && bi_pfam != NULL) {
+		add_i2c_child_devices(dev, bi_pfam->name);
+	}
+}
+
+static void
+add_i2c_child_devices(device_t self, const char *family)
+{
+	struct i2cdev *rtc;
+	prop_dictionary_t pd;
+	prop_array_t pa;
+	int i;
+
+	rtc = NULL;
+	for (i = 0; i < (int)(sizeof(rtcmodel)/sizeof(rtcmodel[0])); i++) {
+		if (strcmp(family, rtcmodel[i].family) == 0) {
+			rtc = &rtcmodel[i];
+			goto found;
+		}
+	}
+	return;
+
+ found:
+	pd = prop_dictionary_create();
+	pa = prop_array_create();
+	prop_dictionary_set_cstring_nocopy(pd, "name", rtc->name);
+	prop_dictionary_set_uint32(pd, "addr", rtc->addr);
+	prop_array_add(pa, pd);
+	prop_dictionary_set(device_properties(self), "i2c-child-devices", pa);
+	prop_object_release(pd);
+	prop_object_release(pa);
 }

Index: src/sys/arch/sandpoint/sandpoint/iic_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.18 src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.19
--- src/sys/arch/sandpoint/sandpoint/iic_eumb.c:1.18	Fri May 11 21:12:34 2012
+++ src/sys/arch/sandpoint/sandpoint/iic_eumb.c	Sat May 12 13:13:24 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: iic_eumb.c,v 1.18 2012/05/11 21:12:34 nisimura Exp $ */
+/* $NetBSD: iic_eumb.c,v 1.19 2012/05/12 13:13:24 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010,2011 Frank Wille.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: iic_eumb.c,v 1.18 2012/05/11 21:12:34 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iic_eumb.c,v 1.19 2012/05/12 13:13:24 nisimura Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -37,7 +37,6 @@ __KERNEL_RCSID(0, "$NetBSD: iic_eumb.c,v
 #include <sys/bus.h>
 #include <dev/i2c/motoi2cvar.h>
 #include <sandpoint/sandpoint/eumbvar.h>
-#include <machine/bootinfo.h>
 
 struct iic_eumb_softc {
 	device_t		sc_dev;
@@ -52,24 +51,6 @@ CFATTACH_DECL_NEW(iic_eumb, sizeof(struc
 
 static int found;
 
-struct i2cdev {
-	const char *family;
-	const char *name;
-	int addr;
-};
-
-static struct i2cdev rtcmodel[] = {
-    { "dlink",    "strtc",      0x68 },
-    { "iomega",   "dsrtc",      0x68 },
-    { "kurobox",  "rs5c372rtc", 0x32 },
-    { "kurot4",   "rs5c372rtc", 0x32 },
-    { "qnap",     "s390rtc",    0x30 },
-    { "synology", "rs5c372rtc", 0x32 },
-    { "nhnas",    "pcf8563rtc", 0x51 }
-};
-
-static void add_i2c_child_devices(device_t, const char *);
-
 static int
 iic_eumb_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -83,7 +64,6 @@ iic_eumb_attach(device_t parent, device_
 	struct iic_eumb_softc *sc;
 	struct eumb_attach_args *eaa;
 	bus_space_handle_t ioh;
-	struct btinfo_prodfamily *pfam;
 
 	sc = device_private(self);
 	sc->sc_dev = self;
@@ -93,9 +73,6 @@ iic_eumb_attach(device_t parent, device_
 	aprint_naive("\n");
 	aprint_normal("\n");
 
-	if ((pfam = lookup_bootinfo(BTINFO_PRODFAMILY)) != NULL)
-		add_i2c_child_devices(self, pfam->name);
-
 	/*
 	 * map EUMB registers and attach MI motoi2c with default settings
 	 */
@@ -104,31 +81,3 @@ iic_eumb_attach(device_t parent, device_
 	sc->sc_motoi2c.sc_ioh = ioh;
 	motoi2c_attach_common(self, &sc->sc_motoi2c, NULL);
 }
-
-static void
-add_i2c_child_devices(device_t self, const char *family)
-{
-	struct i2cdev *rtc;
-	prop_dictionary_t pd;
-	prop_array_t pa;
-	int i;
-
-	rtc = NULL;
-	for (i = 0; i < (int)(sizeof(rtcmodel)/sizeof(rtcmodel[0])); i++) {
-		if (strcmp(family, rtcmodel[i].family) == 0) {
-			rtc = &rtcmodel[i];
-			goto found;
-		}
-	}
-	return;
-
- found:
-	pd = prop_dictionary_create();
-	pa = prop_array_create();
-	prop_dictionary_set_cstring_nocopy(pd, "name", rtc->name);
-	prop_dictionary_set_uint32(pd, "addr", rtc->addr);
-	prop_array_add(pa, pd);
-	prop_dictionary_set(device_properties(self), "i2c-child-devices", pa);
-	prop_object_release(pd);
-	prop_object_release(pa);
-}

Reply via email to