summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--sys/dev/pci/alipm.c10
4 files changed, 104 insertions, 2 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);
diff --git a/sys/dev/pci/alipm.c b/sys/dev/pci/alipm.c
index 4c7588a3156..a82ca8479a0 100644
--- a/sys/dev/pci/alipm.c
+++ b/sys/dev/pci/alipm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: alipm.c,v 1.4 2006/01/01 20:52:26 deraadt Exp $ */
+/* $OpenBSD: alipm.c,v 1.5 2006/01/02 01:58:53 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -29,6 +29,10 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#ifdef __sparc64__
+#include <arch/sparc64/dev/ofwi2cvar.h>
+#endif
+
/*
* Acer Labs M7101 Power register definitions.
*/
@@ -215,6 +219,10 @@ alipm_attach(struct device *parent, struct device *self, void *aux)
bzero(&iba, sizeof iba);
iba.iba_name = "iic";
iba.iba_tag = &sc->sc_smb_tag;
+#ifdef __sparc64__
+ iba.iba_bus_scan = ofwiic_scan;
+ iba.iba_bus_scan_arg = pa;
+#endif
config_found(&sc->sc_dev, &iba, iicbus_print);
}