gpt4 book ai didi

linux-kernel - 基于 BBB DT 的方法

转载 作者:行者123 更新时间:2023-12-05 01:30:53 25 4
gpt4 key购买 nike

我已经使用平台设备模型为我的自定义协议(protocol)成功实现了基于 GPIO 的驱动程序。我想使用设备树方法升级它。因此,对于初学者来说,我有一个黑色的 beaglebone,并且我已经使用设备树配置交叉编译了内核,并在显示

的 uboot 控制台消息期间启用和验证

Verifying Checksum ... OK

Flattened Device Tree blob at 80f80000

Booting using the fdt blob at 0x80f80000

XIP Kernel Image ... OK

OK

Using Device Tree in place at 80f80000, end 80f899de

我将我的条目添加到板公共(public)文件节点名称 my_gpio {compatible = "my_gpio"}

然后我构建通常的过程 make uImages dtbs LOADADDR....

我终于得到了带有 dtb 的 uImage。在我的驱动程序中,我使用了与 .name 属性相同的字符串“my_gpio”。

但是我的探测方法没有被调用,AFAIK 是因为它没有找到任何兼容的设备。

任何帮助建议都会很棒。

在我的驱动程序中:

static struct platform_driver d_driver = {
.driver = {
.name = "d_gpio",
.of_match_table = d_of_match,
},
.probe = D_probe,
.remove = D_remove
};

谢谢

最佳答案

您需要准备一个类型为struct of_device_id 的结构,并在其上使用compatible 属性。尝试以下方式:

static struct of_device_id my_devs[] = {
{ .compatible = "my_gpio" }, /* This should be the name given in the device tree */
{ }
};
MODULE_DEVICE_TABLE(of, my_devs);

现在构建platform_driver 结构,并将上面的表传递给它:

static struct platform_driver my_plat_driver = {
.probe = my_probe,
.remove = my_remove,
.driver = {
.name = "my_gpio_driver", /* This name is for sysfs, not for matching */
.of_match_table = my_devs /* This turns out as the matching logic */
}
};

关于linux-kernel - 基于 BBB DT 的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26992858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com