Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c FDT-ize AC100 driver



details:   https://anonhg.NetBSD.org/src/rev/86ed8a1016bb
branches:  trunk
changeset: 999278:86ed8a1016bb
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon May 27 21:11:13 2019 +0000

description:
FDT-ize AC100 driver

diffstat:

 sys/dev/i2c/ac100.c |  33 ++++++++++++++++++++++++++++++---
 1 files changed, 30 insertions(+), 3 deletions(-)

diffs (77 lines):

diff -r 274c759eb1f5 -r 86ed8a1016bb sys/dev/i2c/ac100.c
--- a/sys/dev/i2c/ac100.c       Mon May 27 21:10:44 2019 +0000
+++ b/sys/dev/i2c/ac100.c       Mon May 27 21:11:13 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ac100.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $ */
+/* $NetBSD: ac100.c,v 1.3 2019/05/27 21:11:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,8 +26,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_fdt.h"
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ac100.c,v 1.2 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ac100.c,v 1.3 2019/05/27 21:11:13 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -41,6 +43,10 @@
 
 #include <dev/i2c/i2cvar.h>
 
+#ifdef FDT
+#include <dev/fdt/fdtvar.h>
+#endif
+
 #define AC100_CHIP_AUDIO_RST_REG       0x00
 #define AC100_PLL_CTRL1_REG            0x02
 #define AC100_PLL_CTRL2_REG            0x03
@@ -86,6 +92,11 @@
 
 #define AC100_RTC_UPD_TRIG_WRITE       __BIT(15)
 
+static const struct device_compatible_entry compat_data[] = {
+       { "x-powers,ac100",             0 },
+       { NULL,                         0 }
+};
+
 struct ac100_softc {
        device_t        sc_dev;
        i2c_tag_t       sc_i2c;
@@ -109,7 +120,15 @@
 static int
 ac100_match(device_t parent, cfdata_t match, void *aux)
 {
-       return I2C_MATCH_ADDRESS_ONLY;  /* XXX */
+       struct i2c_attach_args *ia = aux;
+       int match_result;
+
+       if (iic_use_direct_match(ia, match, compat_data, &match_result))
+               return match_result;
+
+       /* This device is direct-config only. */
+
+       return 0;
 }
 
 static void
@@ -132,7 +151,15 @@
        sc->sc_todr.todr_gettime_ymdhms = ac100_rtc_gettime;
        sc->sc_todr.todr_settime_ymdhms = ac100_rtc_settime;
        sc->sc_todr.cookie = sc;
+
+#ifdef FDT
+       const int phandle = ia->ia_cookie;
+       const int rtc_phandle = of_find_firstchild_byname(phandle, "rtc");
+       if (rtc_phandle > 0)
+               fdtbus_todr_attach(self, rtc_phandle, &sc->sc_todr);
+#else
        todr_attach(&sc->sc_todr);
+#endif
 }
 
 static int



Home | Main Index | Thread Index | Old Index