Message ID | cover.1663835855.git.zhoubinbin@loongson.cn |
---|---|
Headers | show |
Series | i2c: ls2x: Add support for the Loongson-2K/LS7A I2C | expand |
Hi, On Thu, Sep 22, 2022 at 07:39:54PM +0800, Binbin Zhou wrote: > Under LoongARCH based on ACPI(such as Loongson-3A + LS7A), the ls2x i2c > driver obtains the i2c bus number from ACPI table. Why this is needed? The I2CSerialBusV2() resource should be enough to identify the adapter, and I don't see why static number would be needed for anything?
On 2022/9/22 下午7:39, Binbin Zhou wrote: > 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> > --- > drivers/i2c/i2c-core-base.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index 91007558bcb2..ffab4cc2c6ba 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -1559,7 +1559,8 @@ 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"); > @@ -1567,6 +1568,13 @@ int i2c_add_adapter(struct i2c_adapter *adapter) > 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)) { Hi, Binbin, Emm, the id is unsigned and it always return true if (id>=0). And I think you should check the other patches. Jinyang > + adapter->nr = id; > + return __i2c_add_numbered_adapter(adapter); > + } > } > > mutex_lock(&core_lock);
Hi, On Fri, Sep 23, 2022 at 03:16:03PM +0800, Huacai Chen wrote: > Hi, Mika, > > On Thu, Sep 22, 2022 at 8:23 PM Mika Westerberg > <mika.westerberg@linux.intel.com> wrote: > > > > Hi, > > > > On Thu, Sep 22, 2022 at 07:39:54PM +0800, Binbin Zhou wrote: > > > Under LoongARCH based on ACPI(such as Loongson-3A + LS7A), the ls2x i2c > > > driver obtains the i2c bus number from ACPI table. > > > > Why this is needed? The I2CSerialBusV2() resource should be enough to > > identify the adapter, and I don't see why static number would be needed > > for anything? > > > In later patches we will add LS7A i2c driver, this driver is shared by > MIPS-based Loongson-3A4000 system (use FDT) and LoongArch-based > Loongson-3A5000 system (use ACPI). > > FDT systems support static bus numbers, so we want to do the same > thing on ACPI systems. I think keep this consistency can make user > feel better I don't think the user cares to be honest. As long as all the devices work as expected ;-) And this saves a couple of lines of code too so if not really needed, I would just drop that part.