Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c Add FDT support



details:   https://anonhg.NetBSD.org/src/rev/7694d79bdaf0
branches:  trunk
changeset: 826974:7694d79bdaf0
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Oct 07 20:18:16 2017 +0000

description:
Add FDT support

diffstat:

 sys/dev/i2c/pcf8563.c |  26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diffs (63 lines):

diff -r 5ca119be5971 -r 7694d79bdaf0 sys/dev/i2c/pcf8563.c
--- a/sys/dev/i2c/pcf8563.c     Sat Oct 07 20:17:38 2017 +0000
+++ b/sys/dev/i2c/pcf8563.c     Sat Oct 07 20:18:16 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcf8563.c,v 1.7 2015/04/11 20:05:44 joerg Exp $        */
+/*     $NetBSD: pcf8563.c,v 1.8 2017/10/07 20:18:16 jmcneill Exp $     */
 
 /*
  * Copyright (c) 2011 Jonathan A. Kollasch
@@ -26,8 +26,13 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* XXX */
+#if defined(__arm__) || defined(__aarch64__)
+#include "opt_fdt.h"
+#endif
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcf8563.c,v 1.7 2015/04/11 20:05:44 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8563.c,v 1.8 2017/10/07 20:18:16 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -39,6 +44,16 @@
 #include <dev/i2c/i2cvar.h>
 #include <dev/i2c/pcf8563reg.h>
 
+#ifdef FDT
+#include <dev/fdt/fdtvar.h>
+#endif
+
+static const char *compatible[] = {
+       "nxp,pcf8563",
+       "pcf8563rtc",
+       NULL
+};
+
 struct pcf8563rtc_softc {
        device_t sc_dev;
        i2c_tag_t sc_tag;
@@ -64,8 +79,7 @@
 
        if (ia->ia_name) {
                /* direct config - check name */
-               if (strcmp(ia->ia_name, "pcf8563rtc") == 0)
-                       return 1;
+               return iic_compat_match(ia, compatible);
        } else {
                /* indirect config - check typical address */
                if (ia->ia_addr == PCF8563_ADDR)
@@ -98,7 +112,11 @@
            I2C_F_POLL);
        iic_release_bus(sc->sc_tag, I2C_F_POLL);
 
+#ifdef FDT
+       fdtbus_todr_attach(self, ia->ia_cookie, &sc->sc_todr);
+#else
        todr_attach(&sc->sc_todr);
+#endif
 }
 
 static int



Home | Main Index | Thread Index | Old Index