BBB DT based approach

試著忘記壹切 提交于 2019-12-06 06:25:01

问题


I have successfully implemented a GPIO based driver for my custom protocol using platform device model. I want to upgrade it using device tree approach. So for starters I have a beaglebone black, and I have cross compiled the kernel using the device tree config enabled and verified during uboot console messages showing

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

I added my entry into the board common file node name my_gpio {compatible = "my_gpio" }

Then I build the usual process make uImages dtbs LOADADDR....

Finally i get my uImage with dtb. In my driver i have used the same string "my_gpio" as .name property.

but my probe method is not getting called, which AFAIK is because it is not finding any compatible devices.

Any help suggestions would be great.

In my driver:

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

Thanks


回答1:


You need to prepare a structure of type struct of_device_id and use the compatible property on that. Try in the following manner :

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);

Now build the platform_driver structure, and pass the above table into it :

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 */   
    }
};



回答2:


May be your board support doesn't understand this protocol, so a node is needed to put in a place where the platform code actually processes it. Please go through below discussion and add a "virtual-devices" node in dtb , hope it would help.

http://web.archiveorange.com/archive/v/9IQA2s6aeZUFXdm6P87Z



来源:https://stackoverflow.com/questions/26992858/bbb-dt-based-approach

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!