Skip to contentSkip to conversation

i2c / ACPI: Pick the first address if device has multiple

PATCH Applied Mika Westerberg 3 participants 6 messages Dec 29, 2014 – Jan 14, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c / ACPI: Pick the first address if device has multiple

ACPI specification allows I2C devices with multiple addresses. The current implementation goes over all addresses and assigns the last one to the device. This is typically not the primary address of the device.

Instead of doing that we assign the first address to the device and then let the driver handle rest of the addresses as it wishes.

Cc Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/[email protected]>
---
 drivers/i2c/i2c-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core.c +1 -1
index 39d25a8cb1ad..a06be43b7842 100644
@@ -102,7 +102,7 @@ static int acpi_i2c_add_resource(struct acpi_resource *ares, void *data)
 		struct acpi_resource_i2c_serialbus *sb;
 
 		sb = &ares->data.i2c_serial_bus;
-		if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+		if (!info->addr && sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
 			info->addr = sb->slave_address;
 			if (sb->access_mode == ACPI_I2C_10BIT_MODE)
 				info->flags |= I2C_CLIENT_TEN;
Signature · 1 line
2.1.4
#1 lore raw
Quoted 9 lines · Mika Westerberg

ACPI specification allows I2C devices with multiple addresses. The current implementation goes over all addresses and assigns the last one to the device. This is typically not the primary address of the device.

Instead of doing that we assign the first address to the device and then let the driver handle rest of the addresses as it wishes.

Cc Srinivas Pandruvada <[email protected]>

Yes, seems better than what we do know. But maybe taking the lowest address is a bit better heuristic than taking the first address? Not sure, though...

Quoted 24 lines
---
 drivers/i2c/i2c-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core.c +1 -1
index 39d25a8cb1ad..a06be43b7842 100644
@@ -102,7 +102,7 @@ static int acpi_i2c_add_resource(struct acpi_resource *ares, void *data)
 		struct acpi_resource_i2c_serialbus *sb;
 
 		sb = &ares->data.i2c_serial_bus;
-		if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+		if (!info->addr && sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
 			info->addr = sb->slave_address;
 			if (sb->access_mode == ACPI_I2C_10BIT_MODE)
 				info->flags |= I2C_CLIENT_TEN;
Signature · 6 lines
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 8 lines · Wolfram Sang
Quoted 7 lines · Mika Westerberg

ACPI specification allows I2C devices with multiple addresses. The current implementation goes over all addresses and assigns the last one to the device. This is typically not the primary address of the device.

Instead of doing that we assign the first address to the device and then let the driver handle rest of the addresses as it wishes.

Quoted 6 lines
Quoted 2 lines
Cc Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/[email protected]>

Yes, seems better than what we do know. But maybe taking the lowest address is a bit better heuristic than taking the first address? Not sure, though...

The problem in taking lowest is that in many cases in current devices, the lowest address may end being 0x0C, which is reserved address for SMBUS (ARA). This will require different handling. Unfortunately ACPI doesn't have a way to distinguish whether SMBUS support is desired or not.
The other option is to skip all reserved addresses for SMBUS also and then create on the lowest.

Thanks,
Srinivas

Quoted 25 lines
Quoted 25 lines
---
 drivers/i2c/i2c-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core.c +1 -1
index 39d25a8cb1ad..a06be43b7842 100644
@@ -102,7 +102,7 @@ static int acpi_i2c_add_resource(struct acpi_resource *ares, void *data)
 		struct acpi_resource_i2c_serialbus *sb;
 
 		sb = &ares->data.i2c_serial_bus;
-		if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+		if (!info->addr && sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
 			info->addr = sb->slave_address;
 			if (sb->access_mode == ACPI_I2C_10BIT_MODE)
 				info->flags |= I2C_CLIENT_TEN;
Signature · 6 lines
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 15 lines · Srinivas Pandruvada
Quoted 8 lines · Wolfram Sang
Quoted 7 lines · Mika Westerberg

ACPI specification allows I2C devices with multiple addresses. The current implementation goes over all addresses and assigns the last one to the device. This is typically not the primary address of the device.

Instead of doing that we assign the first address to the device and then let the driver handle rest of the addresses as it wishes.

Quoted 6 lines
Quoted 2 lines
Cc Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/[email protected]>

Yes, seems better than what we do know. But maybe taking the lowest address is a bit better heuristic than taking the first address? Not sure, though...

Quoted 7 lines

The problem in taking lowest is that in many cases in current devices, the lowest address may end being 0x0C, which is reserved address for SMBUS (ARA). This will require different handling. Unfortunately ACPI doesn't have a way to distinguish whether SMBUS support is desired or not.
The other option is to skip all reserved addresses for SMBUS also and then create on the lowest.

Well, this makes me think that Mika's approach is probably the sanest one...

#4 lore raw
Quoted 24 lines · Wolfram Sang
Quoted 15 lines · Srinivas Pandruvada
Quoted 8 lines · Wolfram Sang
Quoted 7 lines · Mika Westerberg

ACPI specification allows I2C devices with multiple addresses. The current implementation goes over all addresses and assigns the last one to the device. This is typically not the primary address of the device.

Instead of doing that we assign the first address to the device and then let the driver handle rest of the addresses as it wishes.

Quoted 6 lines
Quoted 2 lines
Cc Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/[email protected]>

Yes, seems better than what we do know. But maybe taking the lowest address is a bit better heuristic than taking the first address? Not sure, though...

Quoted 7 lines

The problem in taking lowest is that in many cases in current devices, the lowest address may end being 0x0C, which is reserved address for SMBUS (ARA). This will require different handling. Unfortunately ACPI doesn't have a way to distinguish whether SMBUS support is desired or not.
The other option is to skip all reserved addresses for SMBUS also and then create on the lowest.

Quoted 2 lines

Well, this makes me think that Mika's approach is probably the sanest one...

Also I think it is more consistent that way.

Applied
#5 lore raw
In reply to Mika Westerberg
Quoted 9 lines · Mika Westerberg

ACPI specification allows I2C devices with multiple addresses. The current implementation goes over all addresses and assigns the last one to the device. This is typically not the primary address of the device.

Instead of doing that we assign the first address to the device and then let the driver handle rest of the addresses as it wishes.

Cc Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/[email protected]>

Applied to for-next, thanks!