* ACPI I2C device-driver matching issue
@ 2015-10-22 18:05 Ben Gardner
2015-10-24 15:32 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Ben Gardner @ 2015-10-22 18:05 UTC (permalink / raw)
To: Linux I2C; +Cc: linux-acpi
Hi all,
I have a custom Baytrail board with a M24C02 EEPROM attached to I2C bus 3.
I am using coreboot/SeaBIOS, so I have complete control over the ACPI tables.
I am using Linux 4.2.3.
I have defined a EEPROM device on I2C3 using I2cSerialBus() and it
shows up as expected.
Scope (\_SB.PCI0.I2C3) {
Device (EEP0) {
Name (_CID, Package() { "24c02" })
Name (_CRS, ResourceTemplate () {
I2cSerialBus (0x0057, ControllerInitiated, 400000,
AddressingMode7Bit, "\\_SB.PCI0.I2C3", 0x00,
ResourceConsumer,,)
})
}
}
Everything is nearly working, except that acpi_i2c_add_device() is
using the ACPI name to match the driver, which is "24C02:00".
The "at42" driver supports the device with the "24c02" alias.
i2c_match_id() in i2c-core.c uses strcmp() to match the device.
That obviously doesn't match, as "24c02" != "24C02:00".
When I modified acpi_i2c_add_device() to truncate at the colon and
convert it to lower case, it matches and works.
What is the right way to declare a I2C device in ACPI so that it
matches existing drivers?
For reference only, I included the change I made to get it to work below.
(Copy/pasted into gmail, so tabs are lost.)
Thanks,
Ben Gardner
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index c83e4d1..64caddc 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -144,7 +144,13 @@ static acpi_status
acpi_i2c_add_device(acpi_handle handle, u32 level,
return AE_OK;
adev->power.flags.ignore_parent = true;
- strlcpy(info.type, dev_name(&adev->dev), sizeof(info.type));
+ {
+ const char *dn = dev_name(&adev->dev);
+ int idx;
+ for (idx = 0; idx < sizeof(info.type) - 1 && dn[idx]
&& dn[idx] != ':'; idx++)
+ info.type[idx] = tolower(dn[idx]);
+ }
if (!i2c_new_device(adapter, &info)) {
adev->power.flags.ignore_parent = false;
dev_err(&adapter->dev,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: ACPI I2C device-driver matching issue
2015-10-22 18:05 ACPI I2C device-driver matching issue Ben Gardner
@ 2015-10-24 15:32 ` Rafael J. Wysocki
2015-10-26 9:29 ` Mika Westerberg
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2015-10-24 15:32 UTC (permalink / raw)
To: Ben Gardner; +Cc: Linux I2C, linux-acpi, Mika Westerberg
CC: Mika
On Thursday, October 22, 2015 01:05:42 PM Ben Gardner wrote:
> Hi all,
>
> I have a custom Baytrail board with a M24C02 EEPROM attached to I2C bus 3.
> I am using coreboot/SeaBIOS, so I have complete control over the ACPI tables.
> I am using Linux 4.2.3.
>
> I have defined a EEPROM device on I2C3 using I2cSerialBus() and it
> shows up as expected.
>
> Scope (\_SB.PCI0.I2C3) {
> Device (EEP0) {
> Name (_CID, Package() { "24c02" })
> Name (_CRS, ResourceTemplate () {
> I2cSerialBus (0x0057, ControllerInitiated, 400000,
> AddressingMode7Bit, "\\_SB.PCI0.I2C3", 0x00,
> ResourceConsumer,,)
> })
> }
> }
>
> Everything is nearly working, except that acpi_i2c_add_device() is
> using the ACPI name to match the driver, which is "24C02:00".
> The "at42" driver supports the device with the "24c02" alias.
> i2c_match_id() in i2c-core.c uses strcmp() to match the device.
> That obviously doesn't match, as "24c02" != "24C02:00".
>
> When I modified acpi_i2c_add_device() to truncate at the colon and
> convert it to lower case, it matches and works.
>
>
> What is the right way to declare a I2C device in ACPI so that it
> matches existing drivers?
>
>
> For reference only, I included the change I made to get it to work below.
> (Copy/pasted into gmail, so tabs are lost.)
>
> Thanks,
> Ben Gardner
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index c83e4d1..64caddc 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -144,7 +144,13 @@ static acpi_status
> acpi_i2c_add_device(acpi_handle handle, u32 level,
> return AE_OK;
>
> adev->power.flags.ignore_parent = true;
> - strlcpy(info.type, dev_name(&adev->dev), sizeof(info.type));
> + {
> + const char *dn = dev_name(&adev->dev);
> + int idx;
> + for (idx = 0; idx < sizeof(info.type) - 1 && dn[idx]
> && dn[idx] != ':'; idx++)
> + info.type[idx] = tolower(dn[idx]);
> + }
> if (!i2c_new_device(adapter, &info)) {
> adev->power.flags.ignore_parent = false;
> dev_err(&adapter->dev,
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ACPI I2C device-driver matching issue
2015-10-24 15:32 ` Rafael J. Wysocki
@ 2015-10-26 9:29 ` Mika Westerberg
0 siblings, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2015-10-26 9:29 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: Ben Gardner, Linux I2C, linux-acpi
On Sat, Oct 24, 2015 at 05:32:29PM +0200, Rafael J. Wysocki wrote:
> CC: Mika
>
> On Thursday, October 22, 2015 01:05:42 PM Ben Gardner wrote:
> > Hi all,
> >
> > I have a custom Baytrail board with a M24C02 EEPROM attached to I2C bus 3.
> > I am using coreboot/SeaBIOS, so I have complete control over the ACPI tables.
> > I am using Linux 4.2.3.
> >
> > I have defined a EEPROM device on I2C3 using I2cSerialBus() and it
> > shows up as expected.
> >
> > Scope (\_SB.PCI0.I2C3) {
> > Device (EEP0) {
> > Name (_CID, Package() { "24c02" })
> > Name (_CRS, ResourceTemplate () {
> > I2cSerialBus (0x0057, ControllerInitiated, 400000,
> > AddressingMode7Bit, "\\_SB.PCI0.I2C3", 0x00,
> > ResourceConsumer,,)
> > })
> > }
> > }
This is being discussed in another thread:
http://marc.info/?l=linux-acpi&m=144562104914442&w=2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-26 9:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-22 18:05 ACPI I2C device-driver matching issue Ben Gardner
2015-10-24 15:32 ` Rafael J. Wysocki
2015-10-26 9:29 ` Mika Westerberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).