Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/thorpej-i2c-spi-conf]: src/sys/dev/i2c Move the bus/channel number for m...
details: https://anonhg.NetBSD.org/src/rev/dfec8f211532
branches: thorpej-i2c-spi-conf
changeset: 378770:dfec8f211532
user: thorpej <thorpej%NetBSD.org@localhost>
date: Fri May 14 01:08:53 2021 +0000
description:
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.
diffstat:
sys/arch/macppc/dev/ki2c.c | 7 +++----
sys/arch/macppc/dev/smu.c | 4 ++--
sys/dev/i2c/i2c_subr.c | 6 +++---
sys/dev/i2c/i2cmux.c | 6 +++---
sys/dev/i2c/i2cvar.h | 15 +++++++++++++--
5 files changed, 24 insertions(+), 14 deletions(-)
diffs (156 lines):
diff -r f921e1f59861 -r dfec8f211532 sys/arch/macppc/dev/ki2c.c
--- a/sys/arch/macppc/dev/ki2c.c Fri May 14 00:44:13 2021 +0000
+++ b/sys/arch/macppc/dev/ki2c.c Fri May 14 01:08:53 2021 +0000
@@ -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,
diff -r f921e1f59861 -r dfec8f211532 sys/arch/macppc/dev/smu.c
--- a/sys/arch/macppc/dev/smu.c Fri May 14 00:44:13 2021 +0000
+++ b/sys/arch/macppc/dev/smu.c Fri May 14 01:08:53 2021 +0000
@@ -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),
diff -r f921e1f59861 -r dfec8f211532 sys/dev/i2c/i2c_subr.c
--- a/sys/dev/i2c/i2c_subr.c Fri May 14 00:44:13 2021 +0000
+++ b/sys/dev/i2c/i2c_subr.c Fri May 14 01:08:53 2021 +0000
@@ -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;
}
diff -r f921e1f59861 -r dfec8f211532 sys/dev/i2c/i2cmux.c
--- a/sys/dev/i2c/i2cmux.c Fri May 14 00:44:13 2021 +0000
+++ b/sys/dev/i2c/i2cmux.c Fri May 14 01:08:53 2021 +0000
@@ -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];
diff -r f921e1f59861 -r dfec8f211532 sys/dev/i2c/i2cvar.h
--- a/sys/dev/i2c/i2cvar.h Fri May 14 00:44:13 2021 +0000
+++ b/sys/dev/i2c/i2cvar.h Fri May 14 01:08:53 2021 +0000
@@ -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. */
Home |
Main Index |
Thread Index |
Old Index