summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2006-01-02 01:58:56 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2006-01-02 01:58:56 +0000
commitd45b66087c747ba180951d66880a5d908f5a109a (patch)
tree13d7f2d1cf3a6ad5eccd526e50cc6d1a0a6f0aba /sys/arch
parent19c2190d65b50ccbcb1385e2ef74f7e2f1c6c92d (diff)
do i2c initialization using ofw data instead of scanning; ok kettenis
this may require some changes for non-pmu controllers later, which may do the ofw tables slightly differently
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc64/conf/files.sparc643
-rw-r--r--sys/arch/sparc64/dev/ofwi2c.c72
-rw-r--r--sys/arch/sparc64/dev/ofwi2cvar.h21
3 files changed, 95 insertions, 1 deletions
diff --git a/sys/arch/sparc64/conf/files.sparc64 b/sys/arch/sparc64/conf/files.sparc64
index b1edcf151cc..9ac379993f3 100644
--- a/sys/arch/sparc64/conf/files.sparc64
+++ b/sys/arch/sparc64/conf/files.sparc64
@@ -1,4 +1,4 @@
-# $OpenBSD: files.sparc64,v 1.62 2005/12/27 23:19:01 deraadt Exp $
+# $OpenBSD: files.sparc64,v 1.63 2006/01/02 01:58:55 deraadt Exp $
# $NetBSD: files.sparc64,v 1.50 2001/08/10 20:53:50 eeh Exp $
# maxpartitions must be first item in files.${ARCH}
@@ -252,6 +252,7 @@ major {rd = 5}
# Machine-independent I2C drivers
#
include "dev/i2c/files.i2c"
+file arch/sparc64/dev/ofwi2c.c i2cbus
#
# Machine-independent USB drivers
diff --git a/sys/arch/sparc64/dev/ofwi2c.c b/sys/arch/sparc64/dev/ofwi2c.c
new file mode 100644
index 00000000000..1a7107992ef
--- /dev/null
+++ b/sys/arch/sparc64/dev/ofwi2c.c
@@ -0,0 +1,72 @@
+/* $OpenBSD: ofwi2c.c,v 1.1 2006/01/02 01:58:55 deraadt Exp $ */
+
+/*
+ * Copyright (c) 2006 Theo de Raadt
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <dev/i2c/i2cvar.h>
+#include <dev/ofw/openfirm.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <sparc64/pci_machdep.h>
+
+#include <arch/sparc64/dev/ofwi2cvar.h>
+
+void
+ofwiic_scan(struct device *self, struct i2cbus_attach_args *iba, void *aux)
+{
+ struct pci_attach_args *pa = aux;
+ pcitag_t tag = pa->pa_tag;
+ int iba_node = PCITAG_NODE(tag);
+ extern int iic_print(void *, const char *);
+ struct i2c_attach_args ia;
+ char name[32];
+ u_int32_t reg[2];
+ int node;
+
+ for (node = OF_child(iba_node); node; node = OF_peer(node)) {
+ memset(name, 0, sizeof name);
+ if (OF_getprop(node, "compatible", &name,
+ sizeof name) && name[0])
+ ia.ia_name = name;
+
+ if (strcmp(name, "i2c-smbus") == 0) {
+ for (node = OF_child(node); node; node = OF_peer(node)) {
+ ia.ia_tag = iba->iba_tag;
+ ia.ia_name = NULL;
+ memset(name, 0, sizeof name);
+ if (OF_getprop(node, "compatible", &name,
+ sizeof name) && name[0]) {
+ ia.ia_name = name;
+ if (strncmp(ia.ia_name, "i2c-",
+ strlen("i2c-")) == 0)
+ ia.ia_name += strlen("i2c-");
+ }
+ if (OF_getprop(node, "reg", &reg,
+ sizeof reg) != sizeof reg)
+ continue;
+ ia.ia_addr = (reg[1] >> 1);
+ if (ia.ia_name)
+ config_found(self, &ia, iic_print);
+ }
+ return;
+ }
+ }
+}
diff --git a/sys/arch/sparc64/dev/ofwi2cvar.h b/sys/arch/sparc64/dev/ofwi2cvar.h
new file mode 100644
index 00000000000..d4cd0ef90ea
--- /dev/null
+++ b/sys/arch/sparc64/dev/ofwi2cvar.h
@@ -0,0 +1,21 @@
+/* $OpenBSD: ofwi2cvar.h,v 1.1 2006/01/02 01:58:55 deraadt Exp $ */
+
+/*
+ * Copyright (c) 2006 Theo de Raadt
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <dev/i2c/i2cvar.h>
+
+void ofwiic_scan(struct device *sc, struct i2cbus_attach_args *iba, void *aux);