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