Skip to contentSkip to conversation

checks: Remove warning for I2C_OWN_SLAVE_ADDRESS

PATCH In review Joel Stanley 3 participants 4 messages May 20, 2020 – May 22, 2020 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checks: Remove warning for I2C_OWN_SLAVE_ADDRESS

dtc does a sanity check on reg properties that they are within the 10 bit address range for i2c slave addresses. In the case of multi-master buses the binding may describe an address that the bus will listen on as a device. Do not warn when this flag is set.

This fixes the following build warnings reported by Stephen:

arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:126.11-130.4:
Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:
I2C bus unit address format error, expected "40000010"
arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:128.3-30:
Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:reg:

    I2C address must be less than 10-bits, got "0x40000010"
---
 checks.c | 6 ++++++
 1 file changed, 6 insertions(+)
checks.c +6 -0
index a8213c0e13a8..2c23dd4f7778 100644
@@ -1022,6 +1022,8 @@ static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct no
 }
 WARNING(i2c_bus_bridge, check_i2c_bus_bridge, NULL, &addr_size_cells);
 
+#define I2C_OWN_SLAVE_ADDRESS	(1 << 30)
+
 static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
 {
 	struct property *prop;
@@ -1044,6 +1046,8 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node
 	}
 
 	reg = fdt32_to_cpu(*cells);
+	/* Ingore I2C_OWN_SLAVE_ADDRESS */
+	reg &= ~I2C_OWN_SLAVE_ADDRESS;
 	snprintf(unit_addr, sizeof(unit_addr), "%x", reg);
 	if (!streq(unitname, unit_addr))
 		FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"",
@@ -1051,6 +1055,8 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node
 
 	for (len = prop->val.len; len > 0; len -= 4) {
 		reg = fdt32_to_cpu(*(cells++));
+		/* Ingore I2C_OWN_SLAVE_ADDRESS */
+		reg &= ~I2C_OWN_SLAVE_ADDRESS;
 		if (reg > 0x3ff)
 			FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
 				  reg);
Signature · 1 line
2.26.2

A message that is not in the archive (sent off-list or not yet received): 20200520075134.1048589-1-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org

#2 lore raw
Quoted 12 lines · Joel Stanley

dtc does a sanity check on reg properties that they are within the 10 bit address range for i2c slave addresses. In the case of multi-master buses the binding may describe an address that the bus will listen on as a device. Do not warn when this flag is set.

This fixes the following build warnings reported by Stephen:

arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:126.11-130.4:
Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:
I2C bus unit address format error, expected "40000010"
arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:128.3-30:
Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:reg:

Quoted 4 lines
    I2C address must be less than 10-bits, got "0x40000010"

Any document you can give a pointer two explaining the special meaning of this bit?

Quoted 18 lines
---
 checks.c | 6 ++++++
 1 file changed, 6 insertions(+)
checks.c +2 -0
index a8213c0e13a8..2c23dd4f7778 100644
@@ -1022,6 +1022,8 @@ static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct no
 }
 WARNING(i2c_bus_bridge, check_i2c_bus_bridge, NULL, &addr_size_cells);
 
+#define I2C_OWN_SLAVE_ADDRESS	(1 << 30)
+
 static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
 {
 	struct property *prop;

checks.c static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node · line 1049

Quoted 4 lines
checks.c +1 -0
@@ -1044,6 +1046,8 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node
 	}
 
 	reg = fdt32_to_cpu(*cells);
+	/* Ingore I2C_OWN_SLAVE_ADDRESS */

Also, s/Ingore/Ignore/g

Quoted 13 lines
checks.c +3 -0
+	reg &= ~I2C_OWN_SLAVE_ADDRESS;
 	snprintf(unit_addr, sizeof(unit_addr), "%x", reg);
 	if (!streq(unitname, unit_addr))
 		FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"",
@@ -1051,6 +1055,8 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node
 
 	for (len = prop->val.len; len > 0; len -= 4) {
 		reg = fdt32_to_cpu(*(cells++));
+		/* Ingore I2C_OWN_SLAVE_ADDRESS */
+		reg &= ~I2C_OWN_SLAVE_ADDRESS;
 		if (reg > 0x3ff)
 			FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
 				  reg);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Hi David,

Quoted 16 lines · On Thu, 21 May 2020 15:09:14 +1000 David Gibson…
Quoted 14 lines · Joel Stanley

dtc does a sanity check on reg properties that they are within the 10 bit address range for i2c slave addresses. In the case of multi-master buses the binding may describe an address that the bus will listen on as a device. Do not warn when this flag is set.

This fixes the following build warnings reported by Stephen:

arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:126.11-130.4:
Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:
I2C bus unit address format error, expected "40000010"
arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:128.3-30:
Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:reg:

    I2C address must be less than 10-bits, got "0x40000010"
Quoted 5 lines
Quoted 2 lines

Any document you can give a pointer two explaining the special meaning of this bit?

include/dt-bindings/i2c/i2c.h
Is Documentation/devicetree/bindings/i2c/i2c.txt in the kernel tree sufficient? I2C_OWN_SLAVE_ADDRESS has been in there since the file was introduced in August 2015. The actual value has been in include/dt-bindings/i2c/i2c.h since the same time.

Signature · 2 lines
Cheers,
Stephen Rothwell

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 19 lines · Stephen Rothwell

Hi David,

Quoted 16 lines · On Thu, 21 May 2020 15:09:14 +1000 David Gibson…
Quoted 14 lines · Joel Stanley

dtc does a sanity check on reg properties that they are within the 10 bit address range for i2c slave addresses. In the case of multi-master buses the binding may describe an address that the bus will listen on as a device. Do not warn when this flag is set.

This fixes the following build warnings reported by Stephen:

arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:126.11-130.4:
Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:
I2C bus unit address format error, expected "40000010"
arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:128.3-30:
Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:reg:

    I2C address must be less than 10-bits, got "0x40000010"
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Any document you can give a pointer two explaining the special meaning of this bit?

include/dt-bindings/i2c/i2c.h
Is Documentation/devicetree/bindings/i2c/i2c.txt in the kernel tree sufficient?

Good enough.

Quoted 3 lines

I2C_OWN_SLAVE_ADDRESS has been in there since the file was introduced in August 2015. The actual value has been in include/dt-bindings/i2c/i2c.h since the same time.

Looking at that, though, it seems like we should also ignore the I2C_TEN_BIT_ADDRESS flag. Or better yet, not ignore it but validate the base addres is under 7 bits unless its set.

Can we refine that a bit, and fix the spelling errors?

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson