brcm2708: rename target to bcm27xx
[openwrt/staging/stintel.git] / target / linux / bcm27xx / patches-4.19 / 950-0117-i2c-gpio-Also-set-bus-numbers-from-reg-property.patch
1 From b7e22249959b8111e3d8fe7a78afa6a7b0420350 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
5
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.
13
14 Work around this limitation (at least temporarily) by allowing
15 the i2c adapter number to be initialised from the "reg" property
16 if present.
17
18 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
19 ---
20 drivers/i2c/busses/i2c-gpio.c | 4 +++-
21 1 file changed, 3 insertions(+), 1 deletion(-)
22
23 --- a/drivers/i2c/busses/i2c-gpio.c
24 +++ b/drivers/i2c/busses/i2c-gpio.c
25 @@ -350,7 +350,9 @@ static int i2c_gpio_probe(struct platfor
26 adap->dev.parent = dev;
27 adap->dev.of_node = np;
28
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);
34 if (ret)
35 return ret;