Skip to content

Commit

Permalink
i2c: core: Pick i2c bus number from ACPI if present
Browse files Browse the repository at this point in the history
Under LoongARCH based on ACPI(such as Loongson-3A + LS7A), the ls2x i2c
driver obtains the i2c bus number from ACPI table.

Similar to the DT-base system, this is also a static bus number.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
  • Loading branch information
Binbin Zhou authored and intel-lab-lkp committed Sep 22, 2022
1 parent c36b475 commit 749fc79
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/i2c/i2c-core-base.c
Expand Up @@ -1555,14 +1555,22 @@ static int __i2c_add_numbered_adapter(struct i2c_adapter *adap)
int i2c_add_adapter(struct i2c_adapter *adapter)
{
struct device *dev = &adapter->dev;
int id;
acpi_status status;
unsigned long long id;

if (dev->of_node) {
id = of_alias_get_id(dev->of_node, "i2c");
if (id >= 0) {
adapter->nr = id;
return __i2c_add_numbered_adapter(adapter);
}
} else if (dev->parent->fwnode) {
status = acpi_evaluate_integer(ACPI_HANDLE(dev->parent),
"_UID", NULL, &id);
if (ACPI_SUCCESS(status) && (id >= 0)) {
adapter->nr = id;
return __i2c_add_numbered_adapter(adapter);
}
}

mutex_lock(&core_lock);
Expand Down

0 comments on commit 749fc79

Please sign in to comment.