Module Name:    src
Committed By:   jmcneill
Date:           Sun Jan 24 18:01:14 UTC 2021

Modified Files:
        src/sys/dev/i2c: motoi2c.c motoi2cvar.h

Log Message:
Support non-FDT attachment.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/motoi2c.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/motoi2cvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/motoi2c.c
diff -u src/sys/dev/i2c/motoi2c.c:1.8 src/sys/dev/i2c/motoi2c.c:1.9
--- src/sys/dev/i2c/motoi2c.c:1.8	Wed Dec 23 16:02:11 2020
+++ src/sys/dev/i2c/motoi2c.c	Sun Jan 24 18:01:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: motoi2c.c,v 1.8 2020/12/23 16:02:11 thorpej Exp $ */
+/* $NetBSD: motoi2c.c,v 1.9 2021/01/24 18:01:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.8 2020/12/23 16:02:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.9 2021/01/24 18:01:13 jmcneill Exp $");
 
 #if defined(__arm__) || defined(__aarch64__)
 #include "opt_fdt.h"
@@ -107,6 +107,7 @@ motoi2c_attach_common(device_t self, str
 		sc->sc_iowr = motoi2c_iowr1;
 	memset(&iba, 0, sizeof(iba));
 	iba.iba_tag = &sc->sc_i2c;
+	iba.iba_child_devices = sc->sc_child_devices;
 
 	I2C_WRITE(I2CCR, 0);		/* reset before changing anything */
 	I2C_WRITE(I2CDFSRR, i2c->i2c_dfsrr);	/* sampling units */
@@ -115,13 +116,13 @@ motoi2c_attach_common(device_t self, str
 	I2C_WRITE(I2CSR, 0);		/* clear status flags */
 
 #ifdef FDT
-	KASSERT(sc->sc_phandle != 0);
-	fdtbus_register_i2c_controller(&sc->sc_i2c, sc->sc_phandle);
-
-	fdtbus_attach_i2cbus(self, sc->sc_phandle, &sc->sc_i2c, iicbus_print);
-#else
-	config_found_ia(self, "i2cbus", &iba, iicbus_print);
+	if (sc->sc_phandle != 0) {
+		fdtbus_register_i2c_controller(&sc->sc_i2c, sc->sc_phandle);
+		fdtbus_attach_i2cbus(self, sc->sc_phandle, &sc->sc_i2c,
+		    iicbus_print);
+	} else
 #endif
+	config_found_ia(self, "i2cbus", &iba, iicbus_print);
 }
 
 static int

Index: src/sys/dev/i2c/motoi2cvar.h
diff -u src/sys/dev/i2c/motoi2cvar.h:1.6 src/sys/dev/i2c/motoi2cvar.h:1.7
--- src/sys/dev/i2c/motoi2cvar.h:1.6	Sun Dec 22 23:23:32 2019
+++ src/sys/dev/i2c/motoi2cvar.h	Sun Jan 24 18:01:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: motoi2cvar.h,v 1.6 2019/12/22 23:23:32 thorpej Exp $ */
+/* $NetBSD: motoi2cvar.h,v 1.7 2021/01/24 18:01:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
@@ -51,6 +51,7 @@ struct motoi2c_softc {
 	motoi2c_iord_t		sc_iord;
 	motoi2c_iowr_t		sc_iowr;
 	int			sc_phandle;
+	prop_array_t		sc_child_devices;
 };
 
 #define	MOTOI2C_ADR_DEFAULT	(0x7e << 1)

Reply via email to