Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c Support non-FDT attachment.



details:   https://anonhg.NetBSD.org/src/rev/409b62726bf2
branches:  trunk
changeset: 958916:409b62726bf2
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jan 24 18:01:13 2021 +0000

description:
Support non-FDT attachment.

diffstat:

 sys/dev/i2c/motoi2c.c    |  17 +++++++++--------
 sys/dev/i2c/motoi2cvar.h |   3 ++-
 2 files changed, 11 insertions(+), 9 deletions(-)

diffs (63 lines):

diff -r f1b20d75b457 -r 409b62726bf2 sys/dev/i2c/motoi2c.c
--- a/sys/dev/i2c/motoi2c.c     Sun Jan 24 17:55:41 2021 +0000
+++ b/sys/dev/i2c/motoi2c.c     Sun Jan 24 18:01:13 2021 +0000
@@ -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 @@
                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 @@
        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
+       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);
-#endif
 }
 
 static int
diff -r f1b20d75b457 -r 409b62726bf2 sys/dev/i2c/motoi2cvar.h
--- a/sys/dev/i2c/motoi2cvar.h  Sun Jan 24 17:55:41 2021 +0000
+++ b/sys/dev/i2c/motoi2cvar.h  Sun Jan 24 18:01:13 2021 +0000
@@ -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 @@
        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)



Home | Main Index | Thread Index | Old Index