Search code examples
linux-kernellinux-device-driveracpi

How to bind my platform driver to an ACPI Container device


My Laptop has following SuperIO device in the SSDT Table:

DefinitionBlock ("", "SSDT", 1, "VENDORx", "TABLEx", 0x00001000)
{
    Device (\_SB.PC00.LPCB.SIO0)
    {
        Name (_HID, EisaId ("PNP0A05") /* Generic Container Device */)
        Name (_UID, "SD28301")
    }

This ID claimed by the ACPI container driver but I see in /sys/bus/container/* that there is no driver associated with this device.

I wanted to write a platform driver to attach with this device. I have the following in my driver code:

static const struct acpi_device_id sio_device_ids[] = {
    { "PNP0A05", 0},
    { "", 0}
};
MODULE_DEVICE_TABLE(acpi, sio_device_ids);

Upon calling platform_driver_register(), my driver does not get bound to the SIO device. To see if kernel is even trying to match the acpi_device_id entries, I changed PNP0A05 in my kernel code to MHF1234 (custom _HID). Then I inserted an SSDT with a device that had _HID same as acpi_device_id in kernel driver like this: Name (_HID, EisaId ("MHF1234"). Now, upon inserting my driver, the probe function got called so my driver matched with the ACPI device.

Question: How do I match my driver with PNP0A05 device? I see that the ACPI container driver already detected and added this to /sys but there is no driver bound to it. Any hints to debug would be appreciated.


Solution

  • The device is being created by the code under drivers/acpi/container.c. However, it's purely ACPI device for now. The platform devices for ACPI ones are created by acpi_create_platform_device() which is supposed to be called by acpi_bus_attach() (via acpi_default_enumeration() because it's not enumerated by parent). However, container_device_attach() on success returns positive number, i.e. 1, and acpi_bus_attach() skips platform device creation due to the conditional. That's why it's not being represented as platform device and hence may not be enumerated via platform bus.

    Besides that, ACPI specification tells us the following: PNP0A05 Generic Container Device. A device whose settings are totally controlled by its ACPI resource information, and otherwise needs no device or bus-specific driver support. This was originally known as Generic ISA Bus Device. This ID should only be used for containers that do not produce resources for consumption by child devices. Any system resources claimed by a PNP0A05 device’s _CRS object must be consumed by the container itself.