Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Add fdtbus_attach_i2cbus, used to attach an i2cb...



details:   https://anonhg.NetBSD.org/src/rev/5953c4e39b59
branches:  trunk
changeset: 991187:5953c4e39b59
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jul 01 18:16:40 2018 +0000

description:
Add fdtbus_attach_i2cbus, used to attach an i2cbus to an fdt device node.

diffstat:

 sys/dev/fdt/fdt_i2c.c |  27 +++++++++++++++++++++++++--
 sys/dev/fdt/fdtvar.h  |   4 +++-
 2 files changed, 28 insertions(+), 3 deletions(-)

diffs (63 lines):

diff -r 299b4696826f -r 5953c4e39b59 sys/dev/fdt/fdt_i2c.c
--- a/sys/dev/fdt/fdt_i2c.c     Sun Jul 01 18:15:19 2018 +0000
+++ b/sys/dev/fdt/fdt_i2c.c     Sun Jul 01 18:16:40 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_i2c.c,v 1.3 2018/06/30 20:34:43 jmcneill Exp $ */
+/* $NetBSD: fdt_i2c.c,v 1.4 2018/07/01 18:16:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_i2c.c,v 1.3 2018/06/30 20:34:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_i2c.c,v 1.4 2018/07/01 18:16:40 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -88,3 +88,26 @@
 
        return i2c->i2c_funcs->get_tag(i2c->i2c_dev);
 }
+
+device_t
+fdtbus_attach_i2cbus(device_t dev, int phandle, i2c_tag_t tag, cfprint_t print)
+{
+       struct i2cbus_attach_args iba;
+       prop_dictionary_t devs;
+       u_int address_cells;
+
+       devs = prop_dictionary_create();
+       if (of_getprop_uint32(phandle, "#address-cells", &address_cells))
+               address_cells = 1;
+
+       of_enter_i2c_devs(devs, phandle, address_cells * 4, 0);
+
+       memset(&iba, 0, sizeof(iba));
+       iba.iba_tag = tag;
+       iba.iba_child_devices = prop_dictionary_get(devs, "i2c-child-devices");
+       if (iba.iba_child_devices)
+               prop_object_retain(iba.iba_child_devices);
+       prop_object_release(devs);
+
+       return config_found_ia(dev, "i2cbus", &iba, print);
+}
diff -r 299b4696826f -r 5953c4e39b59 sys/dev/fdt/fdtvar.h
--- a/sys/dev/fdt/fdtvar.h      Sun Jul 01 18:15:19 2018 +0000
+++ b/sys/dev/fdt/fdtvar.h      Sun Jul 01 18:16:40 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.37 2018/06/30 18:07:12 jmcneill Exp $ */
+/* $NetBSD: fdtvar.h,v 1.38 2018/07/01 18:16:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -333,6 +333,8 @@
 void           fdtbus_power_reset(void);
 void           fdtbus_power_poweroff(void);
 
+device_t       fdtbus_attach_i2cbus(device_t, int, i2c_tag_t, cfprint_t);
+
 bool           fdtbus_set_data(const void *);
 const void *   fdtbus_get_data(void);
 int            fdtbus_phandle2offset(int);



Home | Main Index | Thread Index | Old Index