大佬教程收集整理的这篇文章主要介绍了在 GPIO 引脚上为 PPS 配置 ACPI,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
更新:这是一次很好的学习经历,但我发现我的 GPIO 扩展器没有连接中断线,所以我无法实现我希望做的事情。
相反,我将尝试使用串行连接上的引脚之一进行调查,这可能会产生中断。
我使用的是嵌入式 linux (4.15.0) 单板计算机,它在 I2C 总线上有一个 NXP PCA9535 GPIO 扩展器。我想将每秒脉冲 (PPS) 源连接到 GPIO 引脚之一,并将其显示在 /sys/class/pps/
下。
多亏了 this question and @0andriy's terrific answer,我已经成功地让 linux 枚举了 GPIO 引脚。
现在,我正在尝试 (i) 让其中一个引脚在其电平变化时生成中断,并且 (ii) 让 pps-gpio
驱动程序将此引脚公开为 PPS 设备。
(关于上面的 (i),我已经用 CONfig_GPIO_PCA953X_IRQ=y
重建了我的内核,所以我认为理论上应该是可能的。)
当我运行到目前为止的结果时,我得到(使用 CONfig_DEBUG_GPIO=y
):
[ 29.906616] ACPI: Host-directed Dynamic ACPI table Load:
[ 29.906635] ACPI: SSDT 0xFFFF989EFD4AC400 00037A (v05 GPIO 20210212 INTL 20180105)
[ 29.907108] ACPI: Executed 1 blocks of module-level executable AML code
[ 29.933345] acpi PRP0001:00: GPIO: looking up 0 in _CRS
[ 29.933398] pca953x i2c-PRP0001:00: GPIO lookup for consumer reset
[ 29.933401] pca953x i2c-PRP0001:00: using ACPI for GPIO lookup
[ 29.933405] acpi PRP0001:00: GPIO: looking up reset-gpios
[ 29.933410] acpi PRP0001:00: GPIO: looking up reset-gpio
[ 29.933413] pca953x i2c-PRP0001:00: using lookup tables for GPIO lookup
[ 29.933417] pca953x i2c-PRP0001:00: lookup for GPIO reset Failed
[ 29.933424] pca953x i2c-PRP0001:00: i2c-PRP0001:00 supply vcc not found,using dummy regulator
[ 29.936087] gpiochip_find_base: found new base at 322
[ 29.936946] gpio gpiochip3: (pca9535): added GPIO chardev (254:3)
[ 29.937000] gpiochip_setup_dev: registered GPIOs 322 to 337 on device: gpiochip3 (pca9535)
[ 29.944603] pps-gpio PRP0001:01: Failed to get GPIO from device tree
[ 29.951505] pps-gpio: probe of PRP0001:01 Failed with error -38
非常感谢您提供任何指导,因为我对 ACPI 完全陌生,并且不确定如何开始调试。
DeFinitionBlock ("gpio.aml","SSDT",5,"","GPIO",0x20210212)
{
External (_SB.PCI0.SBUS,DeviceObj)
Scope (\_SB.PCI0.SBUS)
{
Device (GPI0)
{
// This special _HID (HarDWare ID) tells linux to use Device Tree-
// compatible device IDentification.
name (_HID,"PRP0001")
name (_DDN,"NXP PCA9535 GPIO expander")
name (_CRS,resourceTemplate () {
I2cserialBusV2(
0x0020,// I2C address
ControllerInitiated,400000,// Bus speed (see PCA9535 datasheet)
AddressingMode7Bit,"\\_SB.PCI0.SBUS",// SMBus controller
0x00,resourceConsumer,/* omitted */,Exclusive,/* omitted */
)
})
name (_DSD,Package () {
// Device PropertIEs
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),Package () {
// these correspond to linux Device Tree propertIEs
Package () {"compatible","nxp,pca9535"},Package () {"gpio-line-names",Package () {
"GPIOA.0","GPIOA.1","GPIOA.2","GPIOA.3","GPIOA.4","GPIOA.5","GPIOA.6","GPIOA.7","GPIOB.0","GPIOB.1","GPIOB.2","GPIOB.3","GPIOB.4","GPIOB.5","GPIOB.6","GPIOB.7",}},}
})
}
}
Device (PPS0)
{
name (_HID,"PRP0001")
name (_CRS,resourceTemplate () {
GpioInt (Edge,ActiveLow,Shared,PullDefault,"\\_SB.PCI0.SBUs.GPI0",iPPS /* ref */)
{
0 // GPIOA.0 pin
}
})
name (_DSD,Package() {
// Device PropertIEs
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),Package () {
// https://github.com/torvalds/linux/blob/v4.15/documentation/deviCETree/bindings/pps/pps-gpio.txt
Package () { "compatible","pps-gpio" },Package () {
"gpios",Package () {
^PPS0,iPPS,0 /* required for GpioInt */
}
},}
})
}
}
我还尝试在 @L_403_1@ 之后为其中一个引脚分配一个按钮,我得到:
[ 29.953160] gpio-323 (button A): gpiod_set_debounce: missing set() or set_config() operations
[ 29.953170] gpio-keys PRP0001:02: Unable to get irq number for GPIO 0,error -6
也许值得注意的是 SMBus 和串行设备共享相同的 IRQ 编号?我问过一个关于 over here 的问题。
来自gpioinfo
的 libgpiod
似乎无法检查我的 PCA9535 GPIO 控制器,但我不知道这是否相关。我可以使用 sysfs 导出引脚并检查它们的值。
$ sudo ./gpioinfo 3
gpiochip3 - 16 lines:
gpioinfo: unable to retrIEve the line object from chip: InvalID argument
最后,考虑到相关驱动有一些最近的发展,我构建了linux 5.4.0并尝试使用相同的配置。大致相同,但日志稍微冗长:
[ 63.930115] ACPI: Host-directed Dynamic ACPI table Load:
[ 63.930140] ACPI: SSDT 0xFFFF8B55770F3800 00037A (v05 GPIO 20210212 INTL 20180105)
[ 63.996036] acpi PRP0001:00: GPIO: looking up 0 in _CRS
[ 63.996136] pca953x i2c-PRP0001:00: GPIO lookup for consumer reset
[ 63.996139] pca953x i2c-PRP0001:00: using ACPI for GPIO lookup
[ 63.996143] acpi PRP0001:00: GPIO: looking up reset-gpios
[ 63.996147] acpi PRP0001:00: GPIO: looking up reset-gpio
[ 63.996150] pca953x i2c-PRP0001:00: using lookup tables for GPIO lookup
[ 63.996159] pca953x i2c-PRP0001:00: No GPIO consumer reset found
[ 63.996168] pca953x i2c-PRP0001:00: i2c-PRP0001:00 supply vcc not found,using dummy regulator
[ 63.996210] pca953x i2c-PRP0001:00: using no AI
[ 63.996875] gpiochip_find_base: found new base at 322
[ 63.998604] gpio gpiochip3: (i2c-PRP0001:00): added GPIO chardev (254:3)
[ 63.998672] gpiochip_setup_dev: registered GPIOs 322 to 337 on device: gpiochip3 (i2c-PRP0001:00)
[ 64.009748] pps-gpio PRP0001:01: GPIO lookup for consumer (null)
[ 64.009753] pps-gpio PRP0001:01: using ACPI for GPIO lookup
[ 64.009756] acpi PRP0001:01: GPIO: looking up gpios
[ 64.009763] acpi PRP0001:01: GPIO: _DSD returned PRP0001:01 0 0 0
[ 64.009800] gpio gpiochip3: Persistence not supported for GPIO 0
[ 64.010245] pps-gpio PRP0001:01: GPIO lookup for consumer echo
[ 64.010248] pps-gpio PRP0001:01: using ACPI for GPIO lookup
[ 64.010251] acpi PRP0001:01: GPIO: looking up echo-gpios
[ 64.010254] acpi PRP0001:01: GPIO: looking up echo-gpio
[ 64.010257] pps-gpio PRP0001:01: using lookup tables for GPIO lookup
[ 64.010260] pps-gpio PRP0001:01: No GPIO consumer echo found
[ 64.010264] pps-gpio PRP0001:01: Failed to map GPIO to IRQ: -6
[ 64.016241] pps-gpio: probe of PRP0001:01 Failed with error -22
[ 64.016493] gpio gpiochip3: Persistence not supported for GPIO 1
[ 64.017007] gpio-keys PRP0001:02: Unable to get irq number for GPIO 0,error -6
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的在 GPIO 引脚上为 PPS 配置 ACPI全部内容,希望文章能够帮你解决在 GPIO 引脚上为 PPS 配置 ACPI所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。