spi:ACPI 内核模块自动加载损坏

问题描述 投票:0回答:0

使用 ACPI SSDT 检索设备配置数据的 SPI 客户端驱动程序的内核模块自动加载不是自动加载(执行探测功能)。内核模块自动加载适用于 platform_driver(可以成功地从 _DSD 获取属性),但不适用于 spi_driver。阅读必须定义 spi_device_id 并且驱动程序将仅使用 spi_device_id 自动加载。有任何已知的解决方法吗?是否有与 spi_device_id 结构关联的任何 ACPI 命名对象?

ACPI SSDT 表

DefinitionBlock ("ili9488.aml", "SSDT", 5, "", "ILI9488", 0x1)
{
    Device (TFTD)
    {
        Name (_HID, "ILI9488")  // _HID: Hardware ID
        Name (_CID, "ILI9488")  // _CID: Compatible ID
        Name (_UID, One)        // _UID: Unique ID

        Name (_DSD, Package() { // Device Specific Data - used to return EC static resources (Defined in _CRS) to the driver.
            /*
             * Known as the Device Properties UUID
             * A generic UUID recognized by the ACPI subsystem in the Linux kernel which automatically
             * processes the data packages associated with it and makes data available to device driver
             * as "device properties".
             */
            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
            Package()
            {
                // Define compatible property (Not actually used CONFIG_OF not set)
                Package () { "compatible", Package () { "garosa,garosanvkr25fawd" } },
            }
        })

        Method (_CRS, 0, Serialized) {
            local0 = ResourceTemplate() { // Current Resource Settings (ACPI Resource to Buffer function)
                SpiSerialBus(
                    0,                    // Chip Select
                    PolarityLow,          // Chip Select is Active Low
                    FourWireMode,         // Full Duplex Mode (MISO Unused)
                    8,                    // 8-bits per word (1 byte)
                    ControllerInitiated,  // Slave Mode
                    32000000,             // 32 MHz
                    ClockPolarityLow,     // SPI Mode 0
                    ClockPhaseFirst,      // SPI Mode 0
                    "\\EC17.SPI0",        // SPI bus host controller name (unconfirmed)
                    0                     // Resource Index. Should be 0
                )
                // _SB.GPIO: GPIO bus host controller (unconfirmed)
                GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionOutputOnly, "\\_SB.GPI0", 0, ResourceConsumer, , ) { 40 } // Pin 13
                GpioIo (Exclusive, PullUp,   0, 0, IoRestrictionOutputOnly, "\\_SB.GPI0", 0, ResourceConsumer, , ) { 45 } // Pin 15
            }
            Return(local0)
        }
    }
}

驱动程序片段

static int ili9488_probe(struct spi_device *spidev)
{
    struct device *device;
    const char *compatible_propery;

    device = &spidev->dev;
    device_property_read_string(device, "compatible", &compatible_propery);
    dev_warn(device, "compatible: %s", compatible_propery);

    return 0;
}

static void ili9488_remove(struct spi_device *spidev)
{
    dev_warn(&spidev->dev, "ENTER ili9488_remove function driver bound to ACPI table");
    return;
}

/* Device Tree Node to be compatible with */
static const struct of_device_id ili9488_of_match[] = {
    { .compatible = "garosa,garosanvkr25fawd" },
    {},
};

MODULE_DEVICE_TABLE(of, ili9488_of_match);

/*
 * Make compatible with ACPI SSDT via the
 * Compatible ID (_CID) name object
 */
static const struct acpi_device_id ili9488_acpi_match[] = {
    { "ILI9488", 0 },
    { }
};

MODULE_DEVICE_TABLE(acpi, ili9488_acpi_match);

static const struct spi_device_id ili9488_spi_devid[] = {
    { "ILI9488", 0 },
    { }
};

MODULE_DEVICE_TABLE(spi, ili9488_spi_devid);

/* Driver declaration */
static struct spi_driver ili9488_spi_driver = {
    .driver = {
        .name = "ili9488",
        .acpi_match_table = ili9488_acpi_match,
        .of_match_table = ili9488_of_match, // not necessary CONFIG_OF not even set
    },
    .id_table = ili9488_spi_devid,
    .probe    = ili9488_probe,
    .remove   = ili9488_remove,
};

module_spi_driver(ili9488_spi_driver);

编译 ACPI 表和内核模块后,我尝试加载波纹管结果。如果您添加 ACPI_PTR 或删除 of_match_table,您不会看到 SPI 驱动程序警告。

$ mount -t configfs none /sys/kernel/config
$ modprobe acpi-configfs
$ mkdir -p /sys/kernel/config/acpi/table/ili9488
$ cat "ili9488.aml" > "/sys/kernel/config/acpi/table/ili9488/aml"
$ insmod ili9488.ko ; rmmod ili9488.ko 
SPI driver ili9488 has no spi_device_id for garosa,garosanvkr25fawd
c linux-kernel linux-device-driver spi acpi
© www.soinside.com 2019 - 2024. All rights reserved.