Skip to contentSkip to conversation

i2c: fsi: Fixes for systems with more ports

PATCH Superseded Eddie James 2 participants 5 messages Jun 8, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Eddie James

author maintainer
#0 lore raw

cover i2c: fsi: Fixes for systems with more ports

This series fixes a register definition for the FSI-attached I2C master to allow all the available ports. In addition, the code to add an adapter for each port is modified to require a device-tree entry for the bus. This is so that systems with lots of busses that have no devices on them don't add lots of unecessary devices.

Eddie James (2):
i2c: fsi: Fix the port number field in status register
i2c: fsi: Prevent adding adapters for ports without dts nodes

 drivers/i2c/busses/i2c-fsi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.24.0
author maintainer
#1 lore raw

PATCH 1/2 i2c: fsi: Fix the port number field in status register

The port number field in the status register was not correct, so fix it.

Fixes d6ffb6300116 ("i2c: Add FSI-attached I2C master algorithm")
---
 drivers/i2c/busses/i2c-fsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-fsi.c +1 -1
index e0c256922d4f..977d6f524649 100644
@@ -98,7 +98,7 @@
 #define I2C_STAT_DAT_REQ	BIT(25)
 #define I2C_STAT_CMD_COMP	BIT(24)
 #define I2C_STAT_STOP_ERR	BIT(23)
-#define I2C_STAT_MAX_PORT	GENMASK(19, 16)
+#define I2C_STAT_MAX_PORT	GENMASK(22, 16)
 #define I2C_STAT_ANY_INT	BIT(15)
 #define I2C_STAT_SCL_IN		BIT(11)
 #define I2C_STAT_SDA_IN		BIT(10)
Signature · 1 line
2.24.0
author maintainer
#2 lore raw

PATCH 2/2 i2c: fsi: Prevent adding adapters for ports without dts nodes

In reply to Eddie James

Ports should be defined in the devicetree if they are to be enabled on the system.

---
 drivers/i2c/busses/i2c-fsi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-fsi.c +6 -1
index 977d6f524649..95b6b6bc1d78 100644
@@ -703,7 +703,12 @@ static int fsi_i2c_probe(struct device *dev)
 
 	for (port_no = 0; port_no < ports; port_no++) {
 		np = fsi_i2c_find_port_of_node(dev->of_node, port_no);
-		if (np && !of_device_is_available(np))
+		/* Do not add port if it is not described in the device tree */
+		if (!np)
+			continue;
+
+		/* Do not add port if it is described as disabled */
+		if (!of_device_is_available(np))
 			continue;
 
 		port = kzalloc(sizeof(*port), GFP_KERNEL);
Signature · 1 line
2.24.0
#3 lore raw

Re: [PATCH 2/2] i2c: fsi: Prevent adding adapters for ports without dts nodes

Quoted 3 lines · Eddie James

Ports should be defined in the devicetree if they are to be enabled on the system.

...

drivers/i2c/busses/i2c-fsi.c static int fsi_i2c_probe(struct device *dev) · line 708

Quoted 7 lines
        for (port_no = 0; port_no < ports; port_no++) {
                np = fsi_i2c_find_port_of_node(dev->of_node, port_no);
drivers/i2c/busses/i2c-fsi.c +3 -1
-               if (np && !of_device_is_available(np))
 
+               /* Do not add port if it is not described in the device tree */
+               if (!np)
+                       continue;

I believe this is redundant, since below will do the same second time.

Quoted 3 lines
drivers/i2c/busses/i2c-fsi.c +2 -0
+               /* Do not add port if it is described as disabled */
+               if (!of_device_is_available(np))
                        continue;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#4 lore raw

Re: [PATCH 2/2] i2c: fsi: Prevent adding adapters for ports without dts nodes

Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Eddie James

Ports should be defined in the devicetree if they are to be enabled on the system.

...

Quoted 7 lines

drivers/i2c/busses/i2c-fsi.c static int fsi_i2c_probe(struct device *dev) · line 708

Quoted 6 lines
         for (port_no = 0; port_no < ports; port_no++) {
                 np = fsi_i2c_find_port_of_node(dev->of_node, port_no);
drivers/i2c/busses/i2c-fsi.c +3 -1
-               if (np && !of_device_is_available(np))
+               /* Do not add port if it is not described in the device tree */
+               if (!np)
+                       continue;

I believe this is redundant, since below will do the same second time.

Good point, thanks, I'll update that.

Quoted 4 lines
Quoted 4 lines
drivers/i2c/busses/i2c-fsi.c +2 -0
+               /* Do not add port if it is described as disabled */
+               if (!of_device_is_available(np))
                         continue;