Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sandpoint/sandpoint Move I2C node adjustment stuff ...



details:   https://anonhg.NetBSD.org/src/rev/2a924b7a6e66
branches:  trunk
changeset: 779229:2a924b7a6e66
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Sat May 12 13:13:24 2012 +0000

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

diffstat:

 sys/arch/sandpoint/sandpoint/autoconf.c |  60 ++++++++++++++++++++++++++++++--
 sys/arch/sandpoint/sandpoint/iic_eumb.c |  55 +-----------------------------
 2 files changed, 57 insertions(+), 58 deletions(-)

diffs (206 lines):

diff -r e8e4254233aa -r 2a924b7a6e66 sys/arch/sandpoint/sandpoint/autoconf.c
--- a/sys/arch/sandpoint/sandpoint/autoconf.c   Sat May 12 10:27:17 2012 +0000
+++ b/sys/arch/sandpoint/sandpoint/autoconf.c   Sat May 12 13:13:24 2012 +0000
@@ -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 @@
 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 @@
        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 @@
                        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 @@
                        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);
+}
diff -r e8e4254233aa -r 2a924b7a6e66 sys/arch/sandpoint/sandpoint/iic_eumb.c
--- a/sys/arch/sandpoint/sandpoint/iic_eumb.c   Sat May 12 10:27:17 2012 +0000
+++ b/sys/arch/sandpoint/sandpoint/iic_eumb.c   Sat May 12 13:13:24 2012 +0000
@@ -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 @@
 #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 @@
 
 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 @@
        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 @@
        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 @@
        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);
-}



Home | Main Index | Thread Index | Old Index