Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c Change fdtbus_register_i2c_controller() to direc...



details:   https://anonhg.NetBSD.org/src/rev/cd6740bccbd7
branches:  trunk
changeset: 948281:cd6740bccbd7
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Dec 23 16:02:11 2020 +0000

description:
Change fdtbus_register_i2c_controller() to directly register the i2c_tag_t,
rather than the device and a set of functions (the only of which was to
return the i2c_tag_t anyway).  Previously, this assumed only a single
i2c controller node per device_t, which is not true with an i2c mux.

diffstat:

 sys/arch/arm/broadcom/bcm2835_bsc_fdt.c |  18 +++---------------
 sys/arch/arm/nvidia/tegra_i2c.c         |  20 +++-----------------
 sys/arch/arm/rockchip/rk_i2c.c          |  18 +++---------------
 sys/arch/arm/samsung/exynos_i2c.c       |  20 +++-----------------
 sys/arch/arm/sociox/sni_i2c.c           |  19 +++----------------
 sys/arch/arm/sunxi/sunxi_rsb.c          |  18 +++---------------
 sys/arch/arm/sunxi/sunxi_twi.c          |  18 +++---------------
 sys/arch/arm/ti/ti_iic.c                |  20 +++-----------------
 sys/dev/fdt/dwiic_fdt.c                 |  19 +++----------------
 sys/dev/fdt/fdt_i2c.c                   |  15 ++++++---------
 sys/dev/fdt/fdtvar.h                    |   9 ++-------
 sys/dev/i2c/motoi2c.c                   |  20 +++-----------------
 12 files changed, 38 insertions(+), 176 deletions(-)

diffs (truncated from 575 to 300 lines):

diff -r cb8cea9906e4 -r cd6740bccbd7 sys/arch/arm/broadcom/bcm2835_bsc_fdt.c
--- a/sys/arch/arm/broadcom/bcm2835_bsc_fdt.c   Wed Dec 23 15:56:43 2020 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_bsc_fdt.c   Wed Dec 23 16:02:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_bsc_fdt.c,v 1.3 2020/12/23 02:56:11 thorpej Exp $      */
+/*     $NetBSD: bcm2835_bsc_fdt.c,v 1.4 2020/12/23 16:02:11 thorpej Exp $      */
 
 /*
  * Copyright (c) 2019 Jason R. Thorpe
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc_fdt.c,v 1.3 2020/12/23 02:56:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc_fdt.c,v 1.4 2020/12/23 16:02:11 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -46,18 +46,6 @@
 
 #include <dev/fdt/fdtvar.h>
 
-static i2c_tag_t
-bsciic_fdt_get_tag(device_t dev)
-{
-       struct bsciic_softc * const sc = device_private(dev);
-
-       return &sc->sc_i2c;
-}
-
-static const struct fdtbus_i2c_controller_func bsciic_fdt_funcs = {
-       .get_tag = bsciic_fdt_get_tag,
-};
-
 static int bsciic_fdt_match(device_t, cfdata_t, void *);
 static void bsciic_fdt_attach(device_t, device_t, void *);
 
@@ -141,7 +129,7 @@
        sc->sc_i2c.ic_release_bus = bsciic_release_bus;
        sc->sc_i2c.ic_exec = bsciic_exec;
 
-       fdtbus_register_i2c_controller(self, phandle, &bsciic_fdt_funcs);
+       fdtbus_register_i2c_controller(&sc->sc_i2c, phandle);
 
        fdtbus_attach_i2cbus(self, phandle, &sc->sc_i2c, iicbus_print);
 }
diff -r cb8cea9906e4 -r cd6740bccbd7 sys/arch/arm/nvidia/tegra_i2c.c
--- a/sys/arch/arm/nvidia/tegra_i2c.c   Wed Dec 23 15:56:43 2020 +0000
+++ b/sys/arch/arm/nvidia/tegra_i2c.c   Wed Dec 23 16:02:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_i2c.c,v 1.23 2019/12/22 23:40:49 thorpej Exp $ */
+/* $NetBSD: tegra_i2c.c,v 1.24 2020/12/23 16:02:11 thorpej 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.23 2019/12/22 23:40:49 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_i2c.c,v 1.24 2020/12/23 16:02:11 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -47,12 +47,6 @@
 static int     tegra_i2c_match(device_t, cfdata_t, void *);
 static void    tegra_i2c_attach(device_t, device_t, void *);
 
-static i2c_tag_t tegra_i2c_get_tag(device_t);
-
-struct fdtbus_i2c_controller_func tegra_i2c_funcs = {
-       .get_tag = tegra_i2c_get_tag
-};
-
 struct tegra_i2c_softc {
        device_t                sc_dev;
        bus_space_tag_t         sc_bst;
@@ -183,19 +177,11 @@
        sc->sc_ic.ic_cookie = sc;
        sc->sc_ic.ic_exec = tegra_i2c_exec;
 
-       fdtbus_register_i2c_controller(self, phandle, &tegra_i2c_funcs);
+       fdtbus_register_i2c_controller(&sc->sc_ic, phandle);
 
        fdtbus_attach_i2cbus(self, phandle, &sc->sc_ic, iicbus_print);
 }
 
-static i2c_tag_t
-tegra_i2c_get_tag(device_t dev)
-{
-       struct tegra_i2c_softc * const sc = device_private(dev);
-
-       return &sc->sc_ic;
-}
-
 static void
 tegra_i2c_init(struct tegra_i2c_softc *sc)
 {
diff -r cb8cea9906e4 -r cd6740bccbd7 sys/arch/arm/rockchip/rk_i2c.c
--- a/sys/arch/arm/rockchip/rk_i2c.c    Wed Dec 23 15:56:43 2020 +0000
+++ b/sys/arch/arm/rockchip/rk_i2c.c    Wed Dec 23 16:02:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_i2c.c,v 1.8 2020/09/19 18:19:09 ryo Exp $ */
+/* $NetBSD: rk_i2c.c,v 1.9 2020/12/23 16:02:11 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: rk_i2c.c,v 1.8 2020/09/19 18:19:09 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_i2c.c,v 1.9 2020/12/23 16:02:11 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -361,18 +361,6 @@
        return error;
 }
 
-static i2c_tag_t
-rk_i2c_get_tag(device_t dev)
-{
-       struct rk_i2c_softc * const sc = device_private(dev);
-
-       return &sc->sc_ic;
-}
-
-static const struct fdtbus_i2c_controller_func rk_i2c_funcs = {
-       .get_tag = rk_i2c_get_tag,
-};
-
 static int
 rk_i2c_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -428,7 +416,7 @@
        sc->sc_ic.ic_cookie = sc;
        sc->sc_ic.ic_exec = rk_i2c_exec;
 
-       fdtbus_register_i2c_controller(self, phandle, &rk_i2c_funcs);
+       fdtbus_register_i2c_controller(&sc->sc_ic, phandle);
 
        fdtbus_attach_i2cbus(self, phandle, &sc->sc_ic, iicbus_print);
 }
diff -r cb8cea9906e4 -r cd6740bccbd7 sys/arch/arm/samsung/exynos_i2c.c
--- a/sys/arch/arm/samsung/exynos_i2c.c Wed Dec 23 15:56:43 2020 +0000
+++ b/sys/arch/arm/samsung/exynos_i2c.c Wed Dec 23 16:02:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exynos_i2c.c,v 1.19 2020/03/17 21:24:30 skrll Exp $ */
+/*     $NetBSD: exynos_i2c.c,v 1.20 2020/12/23 16:02:11 thorpej Exp $ */
 
 /*
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
 #include "opt_arm_debug.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exynos_i2c.c,v 1.19 2020/03/17 21:24:30 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exynos_i2c.c,v 1.20 2020/12/23 16:02:11 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -83,12 +83,6 @@
 static int exynos_i2c_match(device_t, cfdata_t, void *);
 static void exynos_i2c_attach(device_t, device_t, void *);
 
-static i2c_tag_t exynos_i2c_get_tag(device_t);
-
-struct fdtbus_i2c_controller_func exynos_i2c_funcs = {
-       .get_tag = exynos_i2c_get_tag
-};
-
 CFATTACH_DECL_NEW(exynos_i2c, sizeof(struct exynos_i2c_softc),
     exynos_i2c_match, exynos_i2c_attach, NULL, NULL);
 
@@ -178,19 +172,11 @@
        sc->sc_ic.ic_read_byte   = exynos_i2c_read_byte;
        sc->sc_ic.ic_write_byte  = exynos_i2c_write_byte;
 
-       fdtbus_register_i2c_controller(self, phandle, &exynos_i2c_funcs);
+       fdtbus_register_i2c_controller(&sc->sc_ic, phandle);
 
        fdtbus_attach_i2cbus(self, phandle, &sc->sc_ic, iicbus_print);
 }
 
-static i2c_tag_t
-exynos_i2c_get_tag(device_t dev)
-{
-       struct exynos_i2c_softc * const sc = device_private(dev);
-
-       return &sc->sc_ic;
-}
-
 static int
 exynos_i2c_intr(void *priv)
 {
diff -r cb8cea9906e4 -r cd6740bccbd7 sys/arch/arm/sociox/sni_i2c.c
--- a/sys/arch/arm/sociox/sni_i2c.c     Wed Dec 23 15:56:43 2020 +0000
+++ b/sys/arch/arm/sociox/sni_i2c.c     Wed Dec 23 16:02:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sni_i2c.c,v 1.8 2020/06/01 00:00:37 thorpej Exp $      */
+/*     $NetBSD: sni_i2c.c,v 1.9 2020/12/23 16:02:11 thorpej Exp $      */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.8 2020/06/01 00:00:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.9 2020/12/23 16:02:11 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -90,11 +90,6 @@
 static void sni_i2c_reset(struct sniiic_softc *);
 static void sni_i2c_flush(struct sniiic_softc *);
 
-static i2c_tag_t sni_i2c_get_tag(device_t);
-static const struct fdtbus_i2c_controller_func sni_i2c_funcs = {
-       .get_tag = sni_i2c_get_tag,
-};
-
 #define I2C_READ(sc, reg) \
     bus_space_read_4((sc)->sc_ioh,(sc)->sc_ioh,(reg))
 #define I2C_WRITE(sc, reg, val) \
@@ -150,7 +145,7 @@
 
        sni_i2c_common_i(sc);
 
-       fdtbus_register_i2c_controller(self, phandle, &sni_i2c_funcs);
+       fdtbus_register_i2c_controller(&sc->sc_ic, phandle);
 #if 0
        fdtbus_attach_i2cbus(self, phandle, &sc->sc_ic, iicbus_print);
 #endif
@@ -322,11 +317,3 @@
 {
        /* AAA */
 }
-
-static i2c_tag_t
-sni_i2c_get_tag(device_t dev)
-{
-       struct sniiic_softc * const sc = device_private(dev);
-
-       return &sc->sc_ic;
-}
diff -r cb8cea9906e4 -r cd6740bccbd7 sys/arch/arm/sunxi/sunxi_rsb.c
--- a/sys/arch/arm/sunxi/sunxi_rsb.c    Wed Dec 23 15:56:43 2020 +0000
+++ b/sys/arch/arm/sunxi/sunxi_rsb.c    Wed Dec 23 16:02:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_rsb.c,v 1.8 2019/12/22 23:23:30 thorpej Exp $ */
+/* $NetBSD: sunxi_rsb.c,v 1.9 2020/12/23 16:02:12 thorpej 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.8 2019/12/22 23:23:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_rsb.c,v 1.9 2020/12/23 16:02:12 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -111,18 +111,6 @@
 static int     sunxi_rsb_match(device_t, cfdata_t, void *);
 static void    sunxi_rsb_attach(device_t, device_t, void *);
 
-static i2c_tag_t
-sunxi_rsb_get_tag(device_t dev)
-{
-       struct sunxi_rsb_softc * const sc = device_private(dev);
-
-       return &sc->sc_ic;
-}
-
-static const struct fdtbus_i2c_controller_func sunxi_rsb_funcs = {
-       .get_tag = sunxi_rsb_get_tag,
-};
-
 CFATTACH_DECL_NEW(sunxi_rsb, sizeof(struct sunxi_rsb_softc),
        sunxi_rsb_match, sunxi_rsb_attach, NULL, NULL);
 
@@ -194,7 +182,7 @@
        sc->sc_ic.ic_cookie = sc;
        sc->sc_ic.ic_exec = sunxi_rsb_exec;
 
-       fdtbus_register_i2c_controller(self, phandle, &sunxi_rsb_funcs);
+       fdtbus_register_i2c_controller(&sc->sc_ic, phandle);
 
        fdtbus_attach_i2cbus(self, phandle, &sc->sc_ic, iicbus_print);
 }
diff -r cb8cea9906e4 -r cd6740bccbd7 sys/arch/arm/sunxi/sunxi_twi.c
--- a/sys/arch/arm/sunxi/sunxi_twi.c    Wed Dec 23 15:56:43 2020 +0000
+++ b/sys/arch/arm/sunxi/sunxi_twi.c    Wed Dec 23 16:02:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_twi.c,v 1.11 2020/01/12 17:48:42 thorpej Exp $ */
+/* $NetBSD: sunxi_twi.c,v 1.12 2020/12/23 16:02:12 thorpej Exp $ */
 



Home | Main Index | Thread Index | Old Index