3
votes

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

2
Please edit your question and add a pastebin link of your complete DTS file (where your custom node is defined). It might just be that your node is under the wrong parent, or that its format is wrong. Also add a pastebin link of the source code part where your struct platform_driver is set (where you set .of_match_table, as well as the referenced table). - eepp
@eepp Edited the Question. Please Have a look. - RootPhoenix
It seems correct. I don't see why your probe function is not called. Are you sure you are using the updated DTB and driver, and that your driver is loaded at all? - eepp
@eepp yes I am appending the device tree blob to the kernel image ...in one of the make commands internally cat dtb > Image is getting called.. also init is executing in dmesg. - RootPhoenix
I will try what you're doing later and see if I find anything wrong. Normally, everything under OCP is automatically added as a platform device, when it's missing a status property (your case) or when status is "okay". - eepp

2 Answers

0
votes

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

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