基于 BBB DT 的方法

2024-04-05

我已经使用平台设备模型成功为我的自定义协议实现了基于 GPIO 的驱动程序。 我想使用设备树方法升级它。因此,对于初学者来说,我有一个 beaglebone black,并且我使用在 uboot 控制台消息显示期间启用和验证的设备树配置交叉编译了内核

正在验证校验和...确定

80f80000 处的扁平化设备树 blob

使用 0x80f80000 处的 fdt blob 进行引导

XIP 内核映像...好的

OK

在 80f80000、end 80f899de 处使用设备树

我将我的条目添加到板公共文件节点名称 my_gpio {兼容=“my_gpio”}

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

最后我用 dtb 得到了我的 uImage。 在我的驱动程序中,我使用了相同的字符串“my_gpio”作为 .name 属性。

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

任何帮助建议都会很棒。

在我的驱动程序中:

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

Thanks


您需要准备一个类型的结构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 */   
    }
};
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

基于 BBB DT 的方法 的相关文章

随机推荐