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 Build and use "i2c-child-device...
details: https://anonhg.NetBSD.org/src/rev/b1837aba30ee
branches: trunk
changeset: 763701:b1837aba30ee
user: nisimura <nisimura%NetBSD.org@localhost>
date: Thu Mar 31 02:32:35 2011 +0000
description:
Build and use "i2c-child-devices" property to choose the correct RTC
chip among various models.
diffstat:
sys/arch/sandpoint/sandpoint/iic_eumb.c | 50 +++++++++++++++++++++++++++++++-
1 files changed, 48 insertions(+), 2 deletions(-)
diffs (96 lines):
diff -r e731cfa7960e -r b1837aba30ee sys/arch/sandpoint/sandpoint/iic_eumb.c
--- a/sys/arch/sandpoint/sandpoint/iic_eumb.c Thu Mar 31 01:19:37 2011 +0000
+++ b/sys/arch/sandpoint/sandpoint/iic_eumb.c Thu Mar 31 02:32:35 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iic_eumb.c,v 1.10 2011/01/12 18:09:03 phx Exp $ */
+/* $NetBSD: iic_eumb.c,v 1.11 2011/03/31 02:32:35 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.10 2011/01/12 18:09:03 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iic_eumb.c,v 1.11 2011/03/31 02:32:35 nisimura Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -37,6 +37,7 @@
#include <machine/bus.h>
#include <dev/i2c/motoi2cvar.h>
#include <sandpoint/sandpoint/eumbvar.h>
+#include <machine/bootinfo.h>
struct iic_eumb_softc {
device_t sc_dev;
@@ -51,6 +52,19 @@
static int found;
+struct i2cdev {
+ const char *family;
+ const char *name;
+ int addr;
+};
+
+static struct i2cdev rtcmodel[] = {
+ { "kurobox", "rs5c372rtc", 0x32 },
+ { "synology", "rs5c372rtc", 0x32 },
+};
+
+void add_i2c_child_devices(device_t, const char *);
+
static int
iic_eumb_match(device_t parent, cfdata_t cf, void *aux)
{
@@ -64,6 +78,7 @@
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;
@@ -73,6 +88,9 @@
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
*/
@@ -81,3 +99,31 @@
sc->sc_motoi2c.sc_ioh = ioh;
motoi2c_attach_common(self, &sc->sc_motoi2c, NULL);
}
+
+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