Module Name: src Committed By: thorpej Date: Wed Dec 23 16:02:12 UTC 2020
Modified Files: src/sys/arch/arm/broadcom: bcm2835_bsc_fdt.c src/sys/arch/arm/nvidia: tegra_i2c.c src/sys/arch/arm/rockchip: rk_i2c.c src/sys/arch/arm/samsung: exynos_i2c.c src/sys/arch/arm/sociox: sni_i2c.c src/sys/arch/arm/sunxi: sunxi_rsb.c sunxi_twi.c src/sys/arch/arm/ti: ti_iic.c src/sys/dev/fdt: dwiic_fdt.c fdt_i2c.c fdtvar.h src/sys/dev/i2c: motoi2c.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/broadcom/bcm2835_bsc_fdt.c cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/nvidia/tegra_i2c.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/rockchip/rk_i2c.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/samsung/exynos_i2c.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sociox/sni_i2c.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_rsb.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sunxi/sunxi_twi.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/ti_iic.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/fdt/dwiic_fdt.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/fdt/fdt_i2c.c cvs rdiff -u -r1.63 -r1.64 src/sys/dev/fdt/fdtvar.h cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/motoi2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/broadcom/bcm2835_bsc_fdt.c diff -u src/sys/arch/arm/broadcom/bcm2835_bsc_fdt.c:1.3 src/sys/arch/arm/broadcom/bcm2835_bsc_fdt.c:1.4 --- src/sys/arch/arm/broadcom/bcm2835_bsc_fdt.c:1.3 Wed Dec 23 02:56:11 2020 +++ src/sys/arch/arm/broadcom/bcm2835_bsc_fdt.c Wed Dec 23 16:02:11 2020 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc_ #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 @@ bsciic_fdt_attach(device_t parent, devic 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); } Index: src/sys/arch/arm/nvidia/tegra_i2c.c diff -u src/sys/arch/arm/nvidia/tegra_i2c.c:1.23 src/sys/arch/arm/nvidia/tegra_i2c.c:1.24 --- src/sys/arch/arm/nvidia/tegra_i2c.c:1.23 Sun Dec 22 23:40:49 2019 +++ src/sys/arch/arm/nvidia/tegra_i2c.c Wed Dec 23 16:02:11 2020 @@ -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 <jmcne...@invisible.ca> @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: tegra_i2c.c, 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 @@ tegra_i2c_attach(device_t parent, device 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) { Index: src/sys/arch/arm/rockchip/rk_i2c.c diff -u src/sys/arch/arm/rockchip/rk_i2c.c:1.8 src/sys/arch/arm/rockchip/rk_i2c.c:1.9 --- src/sys/arch/arm/rockchip/rk_i2c.c:1.8 Sat Sep 19 18:19:09 2020 +++ src/sys/arch/arm/rockchip/rk_i2c.c Wed Dec 23 16:02:11 2020 @@ -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 <jmcne...@invisible.ca> @@ -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 @@ rk_i2c_exec(void *priv, i2c_op_t op, i2c 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 @@ rk_i2c_attach(device_t parent, device_t 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); } Index: src/sys/arch/arm/samsung/exynos_i2c.c diff -u src/sys/arch/arm/samsung/exynos_i2c.c:1.19 src/sys/arch/arm/samsung/exynos_i2c.c:1.20 --- src/sys/arch/arm/samsung/exynos_i2c.c:1.19 Tue Mar 17 21:24:30 2020 +++ src/sys/arch/arm/samsung/exynos_i2c.c Wed Dec 23 16:02:11 2020 @@ -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 <jmcne...@invisible.ca> @@ -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_wait(struct exynos 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 @@ exynos_i2c_attach(device_t parent, devic 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) { Index: src/sys/arch/arm/sociox/sni_i2c.c diff -u src/sys/arch/arm/sociox/sni_i2c.c:1.8 src/sys/arch/arm/sociox/sni_i2c.c:1.9 --- src/sys/arch/arm/sociox/sni_i2c.c:1.8 Mon Jun 1 00:00:37 2020 +++ src/sys/arch/arm/sociox/sni_i2c.c Wed Dec 23 16:02:11 2020 @@ -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 int sni_i2c_intr(void *); 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 @@ sniiic_fdt_attach(device_t parent, devic 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 @@ sni_i2c_flush(struct sniiic_softc *sc) { /* AAA */ } - -static i2c_tag_t -sni_i2c_get_tag(device_t dev) -{ - struct sniiic_softc * const sc = device_private(dev); - - return &sc->sc_ic; -} Index: src/sys/arch/arm/sunxi/sunxi_rsb.c diff -u src/sys/arch/arm/sunxi/sunxi_rsb.c:1.8 src/sys/arch/arm/sunxi/sunxi_rsb.c:1.9 --- src/sys/arch/arm/sunxi/sunxi_rsb.c:1.8 Sun Dec 22 23:23:30 2019 +++ src/sys/arch/arm/sunxi/sunxi_rsb.c Wed Dec 23 16:02:12 2020 @@ -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 <jmcne...@invisible.ca> @@ -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_rsb_config(struct s 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 @@ sunxi_rsb_attach(device_t parent, device 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); } Index: src/sys/arch/arm/sunxi/sunxi_twi.c diff -u src/sys/arch/arm/sunxi/sunxi_twi.c:1.11 src/sys/arch/arm/sunxi/sunxi_twi.c:1.12 --- src/sys/arch/arm/sunxi/sunxi_twi.c:1.11 Sun Jan 12 17:48:42 2020 +++ src/sys/arch/arm/sunxi/sunxi_twi.c Wed Dec 23 16:02:12 2020 @@ -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 $ */ /*- * Copyright (c) 2017 Jared McNeill <jmcne...@invisible.ca> @@ -28,7 +28,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sunxi_twi.c,v 1.11 2020/01/12 17:48:42 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_twi.c,v 1.12 2020/12/23 16:02:12 thorpej Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -81,18 +81,6 @@ static const struct of_compat_data compa CFATTACH_DECL_NEW(sunxi_twi, sizeof(struct gttwsi_softc), sunxi_twi_match, sunxi_twi_attach, NULL, NULL); -static i2c_tag_t -sunxi_twi_get_tag(device_t dev) -{ - struct gttwsi_softc * const sc = device_private(dev); - - return &sc->sc_i2c; -} - -const struct fdtbus_i2c_controller_func sunxi_twi_funcs = { - .get_tag = sunxi_twi_get_tag, -}; - static u_int sunxi_twi_calc_rate(u_int parent_rate, u_int n, u_int m) { @@ -194,7 +182,7 @@ sunxi_twi_attach(device_t parent, device } aprint_normal_dev(self, "interrupting on %s\n", intrstr); - fdtbus_register_i2c_controller(self, phandle, &sunxi_twi_funcs); + fdtbus_register_i2c_controller(&sc->sc_i2c, phandle); fdtbus_attach_i2cbus(self, phandle, &sc->sc_i2c, iicbus_print); } Index: src/sys/arch/arm/ti/ti_iic.c diff -u src/sys/arch/arm/ti/ti_iic.c:1.7 src/sys/arch/arm/ti/ti_iic.c:1.8 --- src/sys/arch/arm/ti/ti_iic.c:1.7 Sun Aug 16 03:48:59 2020 +++ src/sys/arch/arm/ti/ti_iic.c Wed Dec 23 16:02:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ti_iic.c,v 1.7 2020/08/16 03:48:59 riastradh Exp $ */ +/* $NetBSD: ti_iic.c,v 1.8 2020/12/23 16:02:12 thorpej Exp $ */ /* * Copyright (c) 2013 Manuel Bouyer. All rights reserved. @@ -50,7 +50,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.7 2020/08/16 03:48:59 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.8 2020/12/23 16:02:12 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -217,12 +217,6 @@ static int ti_iic_wait(struct ti_iic_sof static uint32_t ti_iic_stat(struct ti_iic_softc *, uint32_t); static int ti_iic_flush(struct ti_iic_softc *); -static i2c_tag_t ti_iic_get_tag(device_t); - -static const struct fdtbus_i2c_controller_func ti_iic_funcs = { - .get_tag = ti_iic_get_tag, -}; - CFATTACH_DECL_NEW(ti_iic, sizeof(struct ti_iic_softc), ti_iic_match, ti_iic_attach, NULL, NULL); @@ -302,7 +296,7 @@ ti_iic_attach(device_t parent, device_t ti_iic_reset(sc); ti_iic_flush(sc); - fdtbus_register_i2c_controller(self, phandle, &ti_iic_funcs); + fdtbus_register_i2c_controller(&sc->sc_ic, phandle); fdtbus_attach_i2cbus(self, phandle, &sc->sc_ic, iicbus_print); } @@ -705,11 +699,3 @@ ti_iic_flush(struct ti_iic_softc *sc) I2C_WRITE_REG(sc, I2C_CNT, 0); return 0; } - -static i2c_tag_t -ti_iic_get_tag(device_t dev) -{ - struct ti_iic_softc * const sc = device_private(dev); - - return &sc->sc_ic; -} Index: src/sys/dev/fdt/dwiic_fdt.c diff -u src/sys/dev/fdt/dwiic_fdt.c:1.1 src/sys/dev/fdt/dwiic_fdt.c:1.2 --- src/sys/dev/fdt/dwiic_fdt.c:1.1 Wed Sep 26 19:06:33 2018 +++ src/sys/dev/fdt/dwiic_fdt.c Wed Dec 23 16:02:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dwiic_fdt.c,v 1.1 2018/09/26 19:06:33 jakllsch Exp $ */ +/* $NetBSD: dwiic_fdt.c,v 1.2 2020/12/23 16:02:11 thorpej Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dwiic_fdt.c,v 1.1 2018/09/26 19:06:33 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwiic_fdt.c,v 1.2 2020/12/23 16:02:11 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -52,11 +52,6 @@ struct dwiic_fdt_softc { static int dwiic_fdt_match(device_t, cfdata_t, void *); static void dwiic_fdt_attach(device_t, device_t, void *); -static i2c_tag_t dwiic_fdt_i2c_get_tag(device_t); - -struct fdtbus_i2c_controller_func dwiic_fdt_i2c_funcs = { - .get_tag = dwiic_fdt_i2c_get_tag, -}; CFATTACH_DECL_NEW(dwiic_fdt, sizeof(struct dwiic_fdt_softc), dwiic_fdt_match, dwiic_fdt_attach, dwiic_detach, NULL); @@ -114,18 +109,10 @@ dwiic_fdt_attach(device_t parent, device pmf_device_register(self, dwiic_suspend, dwiic_resume); - fdtbus_register_i2c_controller(self, phandle, &dwiic_fdt_i2c_funcs); + fdtbus_register_i2c_controller(&sc->sc_dwiic.sc_i2c_tag, phandle); fdtbus_attach_i2cbus(self, phandle, &sc->sc_dwiic.sc_i2c_tag, iicbus_print); out: return; } - -static i2c_tag_t -dwiic_fdt_i2c_get_tag(device_t dev) -{ - struct dwiic_fdt_softc * const sc = device_private(dev); - - return &sc->sc_dwiic.sc_i2c_tag; -} Index: src/sys/dev/fdt/fdt_i2c.c diff -u src/sys/dev/fdt/fdt_i2c.c:1.8 src/sys/dev/fdt/fdt_i2c.c:1.9 --- src/sys/dev/fdt/fdt_i2c.c:1.8 Fri Jun 12 03:32:30 2020 +++ src/sys/dev/fdt/fdt_i2c.c Wed Dec 23 16:02:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_i2c.c,v 1.8 2020/06/12 03:32:30 thorpej Exp $ */ +/* $NetBSD: fdt_i2c.c,v 1.9 2020/12/23 16:02:11 thorpej Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcne...@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_i2c.c,v 1.8 2020/06/12 03:32:30 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_i2c.c,v 1.9 2020/12/23 16:02:11 thorpej Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -38,9 +38,8 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_i2c.c,v #include <dev/fdt/fdtvar.h> struct fdtbus_i2c_controller { - device_t i2c_dev; + i2c_tag_t i2c_tag; int i2c_phandle; - const struct fdtbus_i2c_controller_func *i2c_funcs; LIST_ENTRY(fdtbus_i2c_controller) i2c_next; }; @@ -49,15 +48,13 @@ static LIST_HEAD(, fdtbus_i2c_controller LIST_HEAD_INITIALIZER(fdtbus_i2c_controllers); int -fdtbus_register_i2c_controller(device_t dev, int phandle, - const struct fdtbus_i2c_controller_func *funcs) +fdtbus_register_i2c_controller(i2c_tag_t tag, int phandle) { struct fdtbus_i2c_controller *i2c; i2c = kmem_alloc(sizeof(*i2c), KM_SLEEP); - i2c->i2c_dev = dev; + i2c->i2c_tag = tag; i2c->i2c_phandle = phandle; - i2c->i2c_funcs = funcs; LIST_INSERT_HEAD(&fdtbus_i2c_controllers, i2c, i2c_next); @@ -86,7 +83,7 @@ fdtbus_get_i2c_tag(int phandle) if (i2c == NULL) return NULL; - return i2c->i2c_funcs->get_tag(i2c->i2c_dev); + return i2c->i2c_tag; } i2c_tag_t Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.63 src/sys/dev/fdt/fdtvar.h:1.64 --- src/sys/dev/fdt/fdtvar.h:1.63 Wed Dec 23 04:07:34 2020 +++ src/sys/dev/fdt/fdtvar.h Wed Dec 23 16:02:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.63 2020/12/23 04:07:34 thorpej Exp $ */ +/* $NetBSD: fdtvar.h,v 1.64 2020/12/23 16:02:11 thorpej Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcne...@invisible.ca> @@ -79,10 +79,6 @@ struct fdtbus_interrupt_controller_func void (*unmask)(device_t, void *); }; -struct fdtbus_i2c_controller_func { - i2c_tag_t (*get_tag)(device_t); -}; - struct fdtbus_spi_controller_func { struct spi_controller * (*get_controller)(device_t); }; @@ -277,8 +273,7 @@ struct fdt_dma_range { int fdtbus_register_interrupt_controller(device_t, int, const struct fdtbus_interrupt_controller_func *); -int fdtbus_register_i2c_controller(device_t, int, - const struct fdtbus_i2c_controller_func *); +int fdtbus_register_i2c_controller(i2c_tag_t, int); int fdtbus_register_spi_controller(device_t, int, const struct fdtbus_spi_controller_func *); int fdtbus_register_gpio_controller(device_t, int, Index: src/sys/dev/i2c/motoi2c.c diff -u src/sys/dev/i2c/motoi2c.c:1.7 src/sys/dev/i2c/motoi2c.c:1.8 --- src/sys/dev/i2c/motoi2c.c:1.7 Sun Dec 22 23:23:32 2019 +++ src/sys/dev/i2c/motoi2c.c Wed Dec 23 16:02:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: motoi2c.c,v 1.7 2019/12/22 23:23:32 thorpej Exp $ */ +/* $NetBSD: motoi2c.c,v 1.8 2020/12/23 16:02:11 thorpej Exp $ */ /*- * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.7 2019/12/22 23:23:32 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.8 2020/12/23 16:02:11 thorpej Exp $"); #if defined(__arm__) || defined(__aarch64__) #include "opt_fdt.h" @@ -58,20 +58,6 @@ int motoi2c_debug = 0; #define DPRINTF(x) #endif -#ifdef FDT -static i2c_tag_t -motoi2c_get_tag(device_t dev) -{ - struct motoi2c_softc * const sc = device_private(dev); - - return &sc->sc_i2c; -} - -static const struct fdtbus_i2c_controller_func motoi2c_funcs = { - .get_tag = motoi2c_get_tag, -}; -#endif - static int motoi2c_acquire_bus(void *, int); static void motoi2c_release_bus(void *, int); static int motoi2c_exec(void *, i2c_op_t, i2c_addr_t, const void *, size_t, @@ -130,7 +116,7 @@ motoi2c_attach_common(device_t self, str #ifdef FDT KASSERT(sc->sc_phandle != 0); - fdtbus_register_i2c_controller(self, sc->sc_phandle, &motoi2c_funcs); + fdtbus_register_i2c_controller(&sc->sc_i2c, sc->sc_phandle); fdtbus_attach_i2cbus(self, sc->sc_phandle, &sc->sc_i2c, iicbus_print); #else