i2c: mux: Add support for generic base-nr property

i2c_mux_add_adapter takes a force_nr parameter that allows an explicit
bus number to be associated with a channel. However, only i2c-mux-reg
and i2c-mux-gpio make use of it.

To help with situations where it is desirable to have a fixed, known
base address for the channels of a mux, create a "base-nr" property.
When force_nr is 0 and base-nr is set and non-zero, form a force_nr
value from the sum of base-nr and the channel ID.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
This commit is contained in:
Phil Elwell
2024-03-14 09:55:31 +00:00
committed by Dom Cobley
parent ad4abeaeb2
commit 87c8dbdf87

View File

@@ -330,8 +330,13 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,
if (muxc->dev->of_node) { if (muxc->dev->of_node) {
struct device_node *dev_node = muxc->dev->of_node; struct device_node *dev_node = muxc->dev->of_node;
struct device_node *mux_node, *child = NULL; struct device_node *mux_node, *child = NULL;
u32 base_nr = 0;
u32 reg; u32 reg;
of_property_read_u32(dev_node, "base-nr", &base_nr);
if (!force_nr && base_nr)
force_nr = base_nr + chan_id;
if (muxc->arbitrator) if (muxc->arbitrator)
mux_node = of_get_child_by_name(dev_node, "i2c-arb"); mux_node = of_get_child_by_name(dev_node, "i2c-arb");
else if (muxc->gate) else if (muxc->gate)