1 From 82b910794d378403d6a9a82487bf89ecc1fc13e1 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Tue, 20 Feb 2018 10:07:27 +0000
4 Subject: [PATCH] i2c-gpio: Also set bus numbers from reg property
6 I2C busses can be assigned specific bus numbers using aliases in
7 Device Tree - string properties where the name is the alias and the
8 value is the path to the node. The current DT parameter mechanism
9 does not allow property names to be derived from a parameter value
10 in any way, so it isn't possible to generate unique or matching
11 aliases for nodes from an overlay that can generate multiple
12 instances, e.g. i2c-gpio.
14 Work around this limitation (at least temporarily) by allowing
15 the i2c adapter number to be initialised from the "reg" property
18 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
20 drivers/i2c/busses/i2c-gpio.c | 4 +++-
21 1 file changed, 3 insertions(+), 1 deletion(-)
23 --- a/drivers/i2c/busses/i2c-gpio.c
24 +++ b/drivers/i2c/busses/i2c-gpio.c
25 @@ -445,7 +445,9 @@ static int i2c_gpio_probe(struct platfor
26 adap->dev.parent = dev;
27 adap->dev.of_node = np;
29 - adap->nr = pdev->id;
30 + if (pdev->id != PLATFORM_DEVID_NONE || !pdev->dev.of_node ||
31 + of_property_read_u32(pdev->dev.of_node, "reg", &adap->nr))
32 + adap->nr = pdev->id;
33 ret = i2c_bit_add_numbered_bus(adap);