1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-02-15 04:42:02 +00:00
openmptcprouter/root/target/linux/bcm27xx/patches-5.15/950-0097-i2c-gpio-Also-set-bus-numbers-from-reg-property.patch

36 lines
1.3 KiB
Diff
Raw Normal View History

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