如何为连接到I2C gpio扩展器的虚拟mdio-gpio设备配置ACPI * .asl [英] How to configure ACPI *.asl for a virtual mdio-gpio device connected to a I2C gpio expander

查看:205
本文介绍了如何为连接到I2C gpio扩展器的虚拟mdio-gpio设备配置ACPI * .asl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Q7模块(x86),并尝试在Linux上使用ACPI SSDT Overlay配置外围设备.但我为此苦苦挣扎.我想我误解了ACPI的一些核心概念.

I'm working with a Q7 Module (x86) and try to configure our peripherals with ACPI SSDT Overlay on Linux. But I strugle with it. I think I missunderstand some of the core concept of ACPI.

CPU -> I2C -> PCA9575 GPIO Expander -> virtual,mdio-gpio -> Ethernet Phy

有效的方法

DefinitionBlock ("abc.asl", "SSDT", 2, "test", "HAL", 2)
{
    External (\_SB_.PCI0.D01D, DeviceObj)

    Scope (\_SB.PCI0.D01D)
    {
        Device (ABC0)
        {
            Name (_HID, "PRP0001")                      // must be PRP0001 that linux searches for compatible driver
            Name (_CRS, ResourceTemplate () {
                        I2cSerialBusV2 (
                                0x20,                  // SlaveAddress    : I2C Address
                                ControllerInitiated,   // SlaveMode       : ControllerInitiated
                                100000,                // ConnectionSpeed : max Bus Speed for this device
                                AddressingMode7Bit,    // AddressingMode  : Adress Mode
                                "\\_SB.PCI0.D01D",     // ResourceSource  : I2C host controller
                                0x00,                  // ResourceSourceIndex : must be 0
                                ResourceConsumer,      // ResourceUsage   : must be ResourceConsumer
                                ,                      // DescriptorName  : optional name for integer value which is an offset to a buffer field...
                                Exclusive              // Shared          : Shared or Exclusive
                                ,)                     // VendorData      : optional field                                
            })

            Name (_DSD, Package() {
                    ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                    Package () {
                            Package (2) { "compatible", "nxp,pca9575"  },
                            Package ()  { "gpio-line-names", Package ()
                                                        {       "LED_Red",
                                                                "",
                                                                "MDC",
                                                                "MDIO",
                                                        }
                                        },
                        },
                    ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
                    Package () {
                        Package () { "led-red",   "LED0" },
                        Package () { "mdc-gpios",  "MDC0" },
                        Package () { "mdio-gpios", "MDIO" },
                    }
            })

            Name (LED0, Package () {
            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
            Package () {
                Package () {"gpio-hog", 1},
                Package () {"gpios", Package () {0, 1}},
                Package () {"output-low", 1},
              }
            })

... <placeholder for virtual,mdio-gpiocode here> ...

        }
    }
}

它可以识别PCA9575 GPIO扩展器,并在Linux中将其注册为gpiochip.LED被固定为低并且被钩住".看来这部分并不完全错误.

It recognises the PCA9575 GPIO expander and registering it as gpiochip in Linux. The LED is fixed to low and "hogged". It seems that this part is not totally wrong.

我将此代码插入了占位符

I inserted this code into the placeholder

Device (MD00)
        {
            Name (_HID, "PRP0001")                      // must be PRP0001 that linux searches for compatible driver

            Name (_DSD, Package() {
                    ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                    Package () {
                            Package (2) { "compatible", "virtual,mdio-gpio" },
                            Package () {"gpios", Package () {^MDC0, 2, 0, 
                                                             ^MDIO, 3, 0,}},
                            }
            })
        }

但是当我尝试通过configfs加载此文件时,我会在 dmesg 中看到一条错误消息,提示_CRS字段中已定义资源的兼容字段丢失.但是我什至没有定义_CRS字段.

But when I try to load this file via configfs I can see an error message in dmesg that the compatible field for the defined resource in _CRS field is missing. But I don't even defined a _CRS field.

我也不确定我的GPIO是否正确定义.我无法使用 Package(){"gpios",Package(){0,1}},命令设置拉模式.

I'm also not sure if my GPIO's are defined correctly. I'm not able to set the Pull-Modes with the Package () {"gpios", Package () {0, 1}}, command.

我问自己,是否应该在MDO设备中再次将GPIO扩展器端口定义为GgioIo结构?

I question myself, shall the GPIO Expander Ports again defined as GgioIo Structures in the MDO Device?

Name (_CRS, ResourceTemplate () {
        GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionNone,
                "\\_SB.PCI0.D01D.ABC0", 0, ResourceConsumer) {2}
        GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionNone,
                "\\_SB.PCI0.D01D.ABC0", 0, ResourceConsumer) {3}
    })

它似乎也不起作用,我感到困惑.我不确定是否正确使用GPIO PCA9575驱动程序.我在哪里可以配置ACPI中的拉偏?驱动程序从 of _ 加载配置,但是我不知道在ACPI中定义它的位置.我希望这里有人知道.

It doesn't seem to work either and I'm confused. I'm not sure if I use the GPIO PCA9575 driver correctly. Where could I configure the pull bias in ACPI? The driver load the config from of_ but I don't know where to define it in ACPI. I hope somebody here got an idea.

推荐答案

首先让我们看一下设计的主要架构:

First of all let's see the main architecture of the design:

+-------------------+
|  HOST             |       +------+
|              MDIO <------>+ MDIO |
|              Intf |       | Phy  |
|                   |       +--^---+
| +------+          |          |       +-----+
| | I²C  |          |          |       | LED |
| | host |          |          |       +--^--+
| +--^---+          |          |          |
|    |              |       +--+---+      |
+-------------------+       | I²C  |      |
     +----------------------> GPIO +------+
                            +------+

从该示意图中,我们可以看到设备之间的相互关系.现在,让我们转到ACPI表示形式.首先,我们需要定义I²CGPIO扩展器.从 meta-acpi 项目中的示例中,我们可以找到如何描述PCA9535.假设我们找到了I²C主机控制器设备(根据您的帖子,为 \ _ SB_.PCI0.D01D ),并且您具有无需锁定IRQ事件的扩展器,那么以下是原始ASL摘录与如何混合使用的方法使其与驱动程序中的正确配置相匹配:

From this schematic we see how devices are related to each other. Now let's move to ACPI representation. At the beginning we need to define I²C GPIO expander. From the examples in meta-acpi project we can find how PCA9535 can be described. Assuming we found the I²C host controller device (\_SB_.PCI0.D01D as per your post) and the fact that you have expander without latching IRQ events, the following is the mix between original ASL excerpt and how to match it with proper configuration in the driver:

Device (ABC0)
{

    Name (_HID, "PRP0001")
    Name (_DDN, "NXP PCA9575 GPIO expander")

    Name (RBUF, ResourceTemplate()
    {
        I2cSerialBusV2(0x0020, ControllerInitiated, 400000,
            AddressingMode7Bit, "\\_SB.PCI0.D01D",
            0x00, ResourceConsumer, , Exclusive, )
    })

    Name (_DSD, Package () {
        ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
        Package () {
            Package () {"compatible", "nxp,pca9575"},
            Package () {"gpio-line-names", Package () {
                "LED_Red",
                "",
                "MDC",
                "MDIO",
            }},
        }
    })

    Method (_CRS, 0, NotSerialized)
    {
        Return (RBUF)
    }

    Method (_STA, 0, NotSerialized)
    {
        Return (0x0F)
    }
}

此摘录为我们提供了系统中的新GPIO芯片,其资源可以由其他人消耗.

例如,在您的Virtual MDIO Phy情况下(请参见

For example, in your Virtual MDIO Phy case (see _DSD Device Properties Related to GPIO as well)

Device (MD00)
{
    Name (_HID, "PRP0001")

    Name (_CRS, ResourceTemplate () {
        GpioIo (Exclusive, PullDown, 0, 0, IoRestrictionOutputOnly,
            "\\_SB.PCI0.D01D.ABC0", 0, ResourceConsumer) {2} // pin 2
        GpioIo (Exclusive, PullDown, 0, 0, IoRestrictionOutputOnly,
            "\\_SB.PCI0.D01D.ABC0", 0, ResourceConsumer) {3} // pin 3
    })

    Name (_DSD, Package() {
        ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
        Package () {
            Package () { "compatible", "virtual,mdio-gpio" },
            Package () {
                "gpios", Package () {
                    ^MD00, 0, 0, 0, // index 0 in _CRS -> pin 2
                    ^MD00, 1, 0, 0, // index 1 in _CRS -> pin 3
                }
            },
        }
    })
}

现在是时候看看LED绑定代码.为了澄清起见, hogging 是当您希望GPIO provider 自己消耗资源本身时.而且很可能不是您的情况.更好的方法是将其与LED GPIO驱动器连接:

Now it is a time to look at the LED binding code. For the sake of clarification hogging is when you want a GPIO provider to consume a resource itself. And it is quite likely not your case. Better is to connect this with the LED GPIO driver:

Device (LEDS)
{
    Name (_HID, "PRP0001")
    Name (_DDN, "GPIO LEDs device")

    Name (_CRS, ResourceTemplate () {
        GpioIo (
            Exclusive,                  // Not shared
            PullUp,                     // Default off
            0,                          // Debounce timeout
            0,                          // Drive strength
            IoRestrictionOutputOnly,    // Only used as output
            "\\_SB.PCI0.D01D.ABC0",     // GPIO controller
            0)                          // Must be 0
        {
            0,                          // LED_Red
        }
    })

    Name (_DSD, Package () {
        ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
        Package () {
            Package () { "compatible", Package() { "gpio-leds" } },
        },
        ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
        Package () {
            Package () { "led-0", "LED0" },
        }
    })

    /*
     * For more information about these bindings see:
     * Documentation/devicetree/bindings/leds/common.yaml,
     * Documentation/devicetree/bindings/leds/leds-gpio.yaml and
     * Documentation/firmware-guide/acpi/gpio-properties.rst.
     */
    Name (LED0, Package () {
        ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
        Package () {
            Package () { "label", "red" },
            Package () { "default-state", "on" },
            Package () { "gpios", Package () { ^LEDS, 0, 0, 1 } }, // active low
        }
    })
}

此外,您还可以在StackOverflow上查看类似的问题(从给定的链接开始,并引用了其余的问题)网站.

Also you may look into similar questions (starting from the given link and there are references to the rest) on StackOverflow site.

这篇关于如何为连接到I2C gpio扩展器的虚拟mdio-gpio设备配置ACPI * .asl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆