Module Name: src Committed By: thorpej Date: Fri May 14 01:08:53 UTC 2021
Modified Files: src/sys/arch/macppc/dev [thorpej-i2c-spi-conf]: ki2c.c smu.c src/sys/dev/i2c [thorpej-i2c-spi-conf]: i2c_subr.c i2cmux.c i2cvar.h Log Message: Move the bus/channel number for multi-channel / mux controllers out of i2cbus_attach_args and stash it in the i2c_tag_t instead. This makes it accessible to platform device tree code when enumerating devices. To generate a diff of this commit: cvs rdiff -u -r1.31.2.1 -r1.31.2.2 src/sys/arch/macppc/dev/ki2c.c cvs rdiff -u -r1.13.2.2 -r1.13.2.3 src/sys/arch/macppc/dev/smu.c cvs rdiff -u -r1.1.72.1 -r1.1.72.2 src/sys/dev/i2c/i2c_subr.c cvs rdiff -u -r1.5.2.3 -r1.5.2.4 src/sys/dev/i2c/i2cmux.c cvs rdiff -u -r1.24.2.3 -r1.24.2.4 src/sys/dev/i2c/i2cvar.h 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/macppc/dev/ki2c.c diff -u src/sys/arch/macppc/dev/ki2c.c:1.31.2.1 src/sys/arch/macppc/dev/ki2c.c:1.31.2.2 --- src/sys/arch/macppc/dev/ki2c.c:1.31.2.1 Sat May 8 21:58:12 2021 +++ src/sys/arch/macppc/dev/ki2c.c Fri May 14 01:08:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ki2c.c,v 1.31.2.1 2021/05/08 21:58:12 thorpej Exp $ */ +/* $NetBSD: ki2c.c,v 1.31.2.2 2021/05/14 01:08:53 thorpej Exp $ */ /* Id: ki2c.c,v 1.7 2002/10/05 09:56:05 tsubai Exp */ /*- @@ -326,13 +326,13 @@ ki2c_attach(device_t parent, device_t se ch = &sc->sc_channels[i]; iic_tag_init(&ch->ch_i2c); + ch->ch_i2c.ic_channel = ch->ch_channel = i; ch->ch_i2c.ic_cookie = ch; ch->ch_i2c.ic_acquire_bus = ki2c_i2c_acquire_bus; ch->ch_i2c.ic_release_bus = ki2c_i2c_release_bus; ch->ch_i2c.ic_exec = ki2c_i2c_exec; ch->ch_ki2c = sc; - ch->ch_channel = i; } /* @@ -409,11 +409,10 @@ ki2c_attach(device_t parent, device_t se } devhandle.impl = &sc->sc_devhandle_impl; - locs[I2CBUSCF_BUS] = ch->ch_channel; + locs[I2CBUSCF_BUS] = ch->ch_i2c.ic_channel; memset(&iba, 0, sizeof(iba)); iba.iba_tag = &ch->ch_i2c; - iba.iba_bus = ch->ch_channel; config_found(sc->sc_dev, &iba, iicbus_print_multi, CFARG_SUBMATCH, config_stdsubmatch, CFARG_LOCATORS, locs, Index: src/sys/arch/macppc/dev/smu.c diff -u src/sys/arch/macppc/dev/smu.c:1.13.2.2 src/sys/arch/macppc/dev/smu.c:1.13.2.3 --- src/sys/arch/macppc/dev/smu.c:1.13.2.2 Fri May 14 00:44:13 2021 +++ src/sys/arch/macppc/dev/smu.c Fri May 14 01:08:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: smu.c,v 1.13.2.2 2021/05/14 00:44:13 thorpej Exp $ */ +/* $NetBSD: smu.c,v 1.13.2.3 2021/05/14 01:08:53 thorpej Exp $ */ /*- * Copyright (c) 2013 Phileas Fogg @@ -476,11 +476,11 @@ smu_setup_iicbus(struct smu_softc *sc) iic_tag_init(&iicbus->i2c); iicbus->i2c.ic_cookie = iicbus; + iicbus->i2c.ic_channel = iicbus->reg; iicbus->i2c.ic_exec = smu_iicbus_exec; memset(&iba, 0, sizeof(iba)); iba.iba_tag = &iicbus->i2c; - iba.iba_bus = iicbus->reg; config_found(sc->sc_dev, &iba, iicbus_print_multi, CFARG_DEVHANDLE, devhandle_from_of(node), Index: src/sys/dev/i2c/i2c_subr.c diff -u src/sys/dev/i2c/i2c_subr.c:1.1.72.1 src/sys/dev/i2c/i2c_subr.c:1.1.72.2 --- src/sys/dev/i2c/i2c_subr.c:1.1.72.1 Sat May 8 14:23:15 2021 +++ src/sys/dev/i2c/i2c_subr.c Fri May 14 01:08:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: i2c_subr.c,v 1.1.72.1 2021/05/08 14:23:15 thorpej Exp $ */ +/* $NetBSD: i2c_subr.c,v 1.1.72.2 2021/05/14 01:08:53 thorpej Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: i2c_subr.c,v 1.1.72.1 2021/05/08 14:23:15 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i2c_subr.c,v 1.1.72.2 2021/05/14 01:08:53 thorpej Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -61,7 +61,7 @@ iicbus_print_multi(void *aux, const char if (pnp != NULL) aprint_normal("iic at %s", pnp); - aprint_normal(" bus %d", iba->iba_bus); + aprint_normal(" bus %d", iba->iba_tag->ic_channel); return UNCONF; } Index: src/sys/dev/i2c/i2cmux.c diff -u src/sys/dev/i2c/i2cmux.c:1.5.2.3 src/sys/dev/i2c/i2cmux.c:1.5.2.4 --- src/sys/dev/i2c/i2cmux.c:1.5.2.3 Sat May 8 15:10:44 2021 +++ src/sys/dev/i2c/i2cmux.c Fri May 14 01:08:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: i2cmux.c,v 1.5.2.3 2021/05/08 15:10:44 thorpej Exp $ */ +/* $NetBSD: i2cmux.c,v 1.5.2.4 2021/05/14 01:08:53 thorpej Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.5.2.3 2021/05/08 15:10:44 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.5.2.4 2021/05/14 01:08:53 thorpej Exp $"); #include <sys/types.h> #include <sys/device.h> @@ -131,6 +131,7 @@ iicmux_attach_bus(struct iicmux_softc * iic_tag_init(&bus->controller); bus->controller.ic_cookie = bus; + bus->controller.ic_channel = bus->busidx; bus->controller.ic_acquire_bus = iicmux_acquire_bus; bus->controller.ic_release_bus = iicmux_release_bus; bus->controller.ic_exec = iicmux_exec; @@ -144,7 +145,6 @@ iicmux_attach_bus(struct iicmux_softc * struct i2cbus_attach_args iba = { .iba_tag = &bus->controller, - .iba_bus = bus->busidx, }; int locs[I2CBUSCF_NLOCS]; Index: src/sys/dev/i2c/i2cvar.h diff -u src/sys/dev/i2c/i2cvar.h:1.24.2.3 src/sys/dev/i2c/i2cvar.h:1.24.2.4 --- src/sys/dev/i2c/i2cvar.h:1.24.2.3 Sat May 8 15:51:31 2021 +++ src/sys/dev/i2c/i2cvar.h Fri May 14 01:08:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: i2cvar.h,v 1.24.2.3 2021/05/08 15:51:31 thorpej Exp $ */ +/* $NetBSD: i2cvar.h,v 1.24.2.4 2021/05/14 01:08:53 thorpej Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -90,6 +90,18 @@ typedef struct i2c_controller { void *ic_cookie; /* controller private */ /* + * Multi-channel i2c controllers and i2c muxes allow + * for multiple busses to be driven by a single block + * of controller logic. Different platform device + * tree representations may find it useful to know + * which physical channel a given logical controller + * (represented by the i2c_tag_t) is associated with. + * We allow this to be stashed away here as a convenience. + * This is not used for anything else by the i2c layer. + */ + int ic_channel; + + /* * These provide synchronization in the presence of * multiple users of the i2c bus. When a device * driver wishes to perform transfers on the i2c @@ -131,7 +143,6 @@ typedef struct i2c_controller { /* Used to attach the i2c framework to the controller. */ struct i2cbus_attach_args { i2c_tag_t iba_tag; /* the controller */ - int iba_bus; /* bus number (optional) */ }; /* Used to attach devices on the i2c bus. */