2

I'm trying to modify an hwmon driver from being Device Tree specific to use the generic property APIs (for compatibility with ACPI). For the purposes of testing I'm trying to bind with the device through _HID instead of PRP0001 at the moment.

I'm running into an issue where the device is never bound to the driver though.

Through some profiling I've found that setup fails at the __acpi_match_device() function call; the !device check fails every time.

I've modified the DSDT as follows, and verified that an entry for this device is present in sysfs (/sys/devices/LNXSYSTM:00/LNXSYBUS:00/).

Device (I2C1) {
    ...
    Device (DEVC) {
        Name (_HID, "DEVC1111")
        Name (_CRS, ResourceTemplate () {
            I2cSerialBusV2   (0x45,ControllerInitiated,
                              100000,AddressingMode7Bit,
                              "\\_SB.I2C1",0,ResourceConsumer)
        })

        Name (_DSD, Package () {
            ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
            Package () {
                  Package () {"reg", 45},
                  Package () {"ch0-reg", 0},
                  Package () {"ch1-reg", 1},
                  Package () {"ch2-reg", 2},
             }
         })
    }
}

Adding some prints to i2c_acpi_get_i2c_resource() shows that the properties in the I2cSerialBusV2() are being read by the kernel as expected at some point.

I've added the relevant ACPI HID entry to the driver as follows (modified driver excerpt):

static const struct acpi_device_id device_acpi_match_table[] = {
        { "DEVC1111" },
        { }
};
MODULE_DEVICE_TABLE(acpi, device_acpi_match_table);

static struct i2c_driver device_i2c_driver = {
    .probe_new = device_probe,
    .remove = device_remove,
    .driver = {
        .name = DRIVER_NAME,
        .of_match_table = device_of_match_table,
        .acpi_match_table = ACPI_PTR(device_acpi_match_table),
        .pm = &device_pm,
    },
    .id_table = device_ids,
};
module_i2c_driver(device_i2c_driver);

The device is visible on the relevant I2C bus: i2cdetect -r -y 1 shows the address (45) of the device as expected.

echo my_device 0x45 > /sys/bus/i2c/devices/i2c-1/new_device

also probes the driver, but does not recognize the device as an ACPI device: ACPI_HANDLE(&i2c_client->dev) returns false.

I noticed that this devices directory in /sys/devices/LNXSYSTM:00/LNXSYBUS:00/ is the only entry that does not have a physical_node entry. I assume that this may be related to the issue but I am not sure how to fix it; I am quite new to most of this; ACPI and i2c device drivers.

Other ACPI devices in the system bind to their drivers just fine, but none of them are on an I2C bus, so it seems to be possibly an issue with my I2C/ACPI setup.

I am not sure where to go from here; how can I go about root causing this?

0andriy
  • 4,183
  • 1
  • 24
  • 37
  • 1
    I was able to get to the bottom of this. It was an incorrect configuration of the I2C adapter driver for my system. – PlasticGlass Nov 06 '22 at 20:48
  • Just a side note: You may not create an ACPI HID by yourself, it can only be done by the registered companies (see ACPI and PNP registries at https://uefi.org). OTOH it's fine for private purposes. – 0andriy Nov 16 '22 at 21:16
  • 1
    Another side note, don't use `ACPI_PTR()`, it's useless and sometimes even a bit harmful. – 0andriy Nov 16 '22 at 21:20

0 Answers0