summaryrefslogtreecommitdiff
path: root/sys/dev/i2c
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2017-10-07 20:18:16 +0000
committerjmcneill <jmcneill@NetBSD.org>2017-10-07 20:18:16 +0000
commit30ddda18caa3b0a42b82a87edda1d84db30fbef3 (patch)
treec79f8ea9bf58a8b6cab9a3a9e546a89061d10d55 /sys/dev/i2c
parent8e2432413c1b6330ab30c53205e34f24ccd421a0 (diff)
Add FDT support
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r--sys/dev/i2c/pcf8563.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/sys/dev/i2c/pcf8563.c b/sys/dev/i2c/pcf8563.c
index e4624a08684..ee44d74ce40 100644
--- a/sys/dev/i2c/pcf8563.c
+++ b/sys/dev/i2c/pcf8563.c
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8563.c,v 1.7 2015/04/11 20:05:44 joerg Exp $");
#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 @@ pcf8563rtc_match(device_t parent, cfdata_t cf, void *aux)
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 @@ pcf8563rtc_attach(device_t parent, device_t self, void *aux)
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