Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm Use fdtbus_attach_i2cbus



details:   https://anonhg.NetBSD.org/src/rev/f581790e1cb2
branches:  trunk
changeset: 320325:f581790e1cb2
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jul 01 21:15:02 2018 +0000

description:
Use fdtbus_attach_i2cbus

diffstat:

 sys/arch/arm/nvidia/tegra_i2c.c |  24 +++---------------------
 sys/arch/arm/sunxi/sunxi_rsb.c  |  22 +++-------------------
 sys/arch/arm/sunxi/sunxi_twi.c  |  22 +++-------------------
 3 files changed, 9 insertions(+), 59 deletions(-)

diffs (163 lines):

diff -r 6e3e7f35954f -r f581790e1cb2 sys/arch/arm/nvidia/tegra_i2c.c
--- a/sys/arch/arm/nvidia/tegra_i2c.c   Sun Jul 01 18:18:18 2018 +0000
+++ b/sys/arch/arm/nvidia/tegra_i2c.c   Sun Jul 01 21:15:02 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_i2c.c,v 1.17 2018/05/09 02:53:00 thorpej Exp $ */
+/* $NetBSD: tegra_i2c.c,v 1.18 2018/07/01 21:18:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_i2c.c,v 1.17 2018/05/09 02:53:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_i2c.c,v 1.18 2018/07/01 21:18:00 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -65,7 +65,6 @@
        struct i2c_controller   sc_ic;
        kmutex_t                sc_lock;
        kcondvar_t              sc_cv;
-       device_t                sc_i2cdev;
 };
 
 static void    tegra_i2c_init(struct tegra_i2c_softc *);
@@ -112,12 +111,9 @@
        struct tegra_i2c_softc * const sc = device_private(self);
        struct fdt_attach_args * const faa = aux;
        const int phandle = faa->faa_phandle;
-       struct i2cbus_attach_args iba;
-       prop_dictionary_t devs;
        char intrstr[128];
        bus_addr_t addr;
        bus_size_t size;
-       u_int address_cells;
        int error;
 
        if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
@@ -189,21 +185,7 @@
 
        fdtbus_register_i2c_controller(self, phandle, &tegra_i2c_funcs);
 
-       devs = prop_dictionary_create();
-
-       if (of_getprop_uint32(phandle, "#address-cells", &address_cells))
-               address_cells = 1;
-
-       of_enter_i2c_devs(devs, faa->faa_phandle, address_cells * 4, 0);
-
-       memset(&iba, 0, sizeof(iba));
-       iba.iba_tag = &sc->sc_ic;
-       iba.iba_child_devices = prop_dictionary_get(devs, "i2c-child-devices");
-       if (iba.iba_child_devices != NULL)
-               prop_object_retain(iba.iba_child_devices);
-       prop_object_release(devs);
-
-       sc->sc_i2cdev = config_found_ia(self, "i2cbus", &iba, iicbus_print);
+       fdtbus_attach_i2cbus(self, phandle, &sc->sc_ic, iicbus_print);
 }
 
 static i2c_tag_t
diff -r 6e3e7f35954f -r f581790e1cb2 sys/arch/arm/sunxi/sunxi_rsb.c
--- a/sys/arch/arm/sunxi/sunxi_rsb.c    Sun Jul 01 18:18:18 2018 +0000
+++ b/sys/arch/arm/sunxi/sunxi_rsb.c    Sun Jul 01 21:15:02 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_rsb.c,v 1.2 2018/05/09 02:53:00 thorpej Exp $ */
+/* $NetBSD: sunxi_rsb.c,v 1.3 2018/07/01 21:15:02 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_rsb.c,v 1.2 2018/05/09 02:53:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_rsb.c,v 1.3 2018/07/01 21:15:02 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -141,9 +141,6 @@
        struct sunxi_rsb_softc * const sc = device_private(self);
        struct fdt_attach_args * const faa = aux;
        const int phandle = faa->faa_phandle;
-       struct i2cbus_attach_args iba;
-       prop_dictionary_t devs;
-       uint32_t address_cells;
        struct fdtbus_reset *rst;
        struct clk *clk;
        char intrstr[128];
@@ -209,20 +206,7 @@
 
        fdtbus_register_i2c_controller(self, phandle, &sunxi_rsb_funcs);
 
-       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 = &sc->sc_ic;
-       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);
-
-       sc->sc_i2cdev = config_found_ia(self, "i2cbus", &iba, iicbus_print);
+       fdtbus_attach_i2cbus(self, phandle, &sc->sc_ic, iicbus_print);
 }
 
 static int
diff -r 6e3e7f35954f -r f581790e1cb2 sys/arch/arm/sunxi/sunxi_twi.c
--- a/sys/arch/arm/sunxi/sunxi_twi.c    Sun Jul 01 18:18:18 2018 +0000
+++ b/sys/arch/arm/sunxi/sunxi_twi.c    Sun Jul 01 21:15:02 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_twi.c,v 1.9 2018/05/09 02:53:00 thorpej Exp $ */
+/* $NetBSD: sunxi_twi.c,v 1.10 2018/07/01 21:16:19 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_twi.c,v 1.9 2018/05/09 02:53:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_twi.c,v 1.10 2018/07/01 21:16:19 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -161,12 +161,9 @@
        struct gttwsi_softc * const sc = device_private(self);
        struct fdt_attach_args * const faa = aux;
        const struct sunxi_twi_config *conf;
-       struct i2cbus_attach_args iba;
        const int phandle = faa->faa_phandle;
        bus_space_tag_t bst = faa->faa_bst;
        bus_space_handle_t bsh;
-       prop_dictionary_t devs;
-       uint32_t address_cells;
        struct fdtbus_reset *rst;
        struct clk *clk;
        char intrstr[128];
@@ -225,18 +222,5 @@
 
        fdtbus_register_i2c_controller(self, phandle, &sunxi_twi_funcs);
 
-       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 = &sc->sc_i2c;
-       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);
-
-       config_found_ia(self, "i2cbus", &iba, iicbus_print);
+       fdtbus_attach_i2cbus(self, phandle, &sc->sc_i2c, iicbus_print);
 }



Home | Main Index | Thread Index | Old Index