cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
1,192 Views
Registered: ‎02-08-2017

disable Default driver from Petalinux build

Jump to solution

Hello,

I followed UG1209 to build simple GPIO module in ZCU102 board (ch 06). I used Petalinux to build my system, then I have built simple dirver to control these GPIOs.

 

/*
 * GPIO minimal kernel module
 *
 * Mohammed Ibrahim
 *
 */


#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/printk.h>

#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/gpio/consumer.h>


static int gpio_probe(struct platform_device *pdev) {
    printk(KERN_ALERT "GPIO: Starting Module\n");
    return 0;
}


static int gpio_remove(struct platform_device *pdev) {
    printk(KERN_ALERT "GPIO: Closing Module\n");
   return 0;
}

static const struct of_device_id ZCU102_leds_dev[] = {
                    {.compatible = "xlnx,xps-gpio-1.00.a"},
                    {}
};

MODULE_DEVICE_TABLE(of, ZCU102_leds_dev);


static const struct platform_device_id ZCU102_id_table[] = {
                    { "xlnx,xps-gpio-1.00.a", 0 },
                    {}
};
MODULE_DEVICE_TABLE(platform, ZCU102_id_table);


static struct platform_driver ZCU102_leds_drv = {
       .probe = gpio_probe,
       .remove = gpio_remove,
       .driver = {
                 .name = "moi_driver",
                 .owner = THIS_MODULE, //this macro is defined in module.h
                 .of_match_table = ZCU102_leds_dev,
       },
       .id_table = ZCU102_id_table,
};


static int hello_init(void)
{
int retVal=89;
	printk("GPIO: Hello, ZynqMP world!\n");
	retVal= platform_driver_register(&ZCU102_leds_drv);
    printk("GPIO: Driver Registeration ret %d\n", retVal);
    return 0;
}


static void hello_exit(void)
{
        platform_driver_unregister(&ZCU102_leds_drv);	
        printk("GPIO: Goodbye, ZynqMP world!\n");
}



module_init(hello_init);
module_exit(hello_exit);


MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mohammed Ibrahim");

 

My problem was this driver is not binded to the created GPIO devices. The driver should print  "GPIO: Starting Module", buts ss you can see in the following shot it is not printed.

loaded_no_message.PNG

 

I spent a lot of time trying to figure out what could be the problem until I noticed that there are ready drivers built into the linux system and the GPIO device is binded to one of them. So I tried to unbind it and finally I got my message.

 

loaded_with_message.PNG

 

My Questions now,

* Is it Petalinux including this default driver "xilinx-gpio"?

* How to direct Petalinux not to include it during build process and use mine instead?

 

Thanks in Advance

0 Kudos
1 Solution

Accepted Solutions
Explorer
Explorer
1,369 Views
Registered: ‎03-22-2016

There are a couple ways to achieve what you want.

 

1. You can reconfigure your kernel to not build the GPIO module. Run "petalinux-config -c kernel" and look for the GPIO driver (I'm not sure where it is, exactly). Once you find it, disable it.

 

2. You can change the compatible string in your module to be something else, then change the device tree so that your GPIO presents itself as something else. This is a nice clean solution, since it allows you to still use the generic GPIO driver for the blocks you don't modify. You can edit the system-user.dtsi file in project-spec/meta-user/recipes-bsp/device-tree/files/ to do that.

 

3. You can blacklist the xilinx GPIO module so that it doesn't automatically load. I'm not sure the details on how to do this in petalinux.

 

 

I think #2 is the best option, personally.

 

Step 1: Look in your components/plnx_workspace/device-tree-generation/pl.dtsi file to see which gpio block you want to modify. In mine, they are labeled "axi_gpio_0", "axi_gpio_1", etc, but they should be named whatever you named them in your block design.

 

Step 2: Add this to your system-user.dtsi file, replacing "axi_gpio_0" with the name of your gpio IP block and replacing "this-is-the-compatible-string" to any string you like (no spaces). Xilinx drivers seem to always start with "xlnx," as a namepsace of sorts to make sure they don't conflict. You may choose to do that with your own as well.

 

 

&axi_gpio_0 {
compatible = "this-is-the-compatible-string";
};

 

 

Step 3: Modify your kernel module to use your new compatible string instead of "xlnx,xps-gpio-1.00.a"

View solution in original post

0 Kudos
1 Reply
Explorer
Explorer
1,370 Views
Registered: ‎03-22-2016

There are a couple ways to achieve what you want.

 

1. You can reconfigure your kernel to not build the GPIO module. Run "petalinux-config -c kernel" and look for the GPIO driver (I'm not sure where it is, exactly). Once you find it, disable it.

 

2. You can change the compatible string in your module to be something else, then change the device tree so that your GPIO presents itself as something else. This is a nice clean solution, since it allows you to still use the generic GPIO driver for the blocks you don't modify. You can edit the system-user.dtsi file in project-spec/meta-user/recipes-bsp/device-tree/files/ to do that.

 

3. You can blacklist the xilinx GPIO module so that it doesn't automatically load. I'm not sure the details on how to do this in petalinux.

 

 

I think #2 is the best option, personally.

 

Step 1: Look in your components/plnx_workspace/device-tree-generation/pl.dtsi file to see which gpio block you want to modify. In mine, they are labeled "axi_gpio_0", "axi_gpio_1", etc, but they should be named whatever you named them in your block design.

 

Step 2: Add this to your system-user.dtsi file, replacing "axi_gpio_0" with the name of your gpio IP block and replacing "this-is-the-compatible-string" to any string you like (no spaces). Xilinx drivers seem to always start with "xlnx," as a namepsace of sorts to make sure they don't conflict. You may choose to do that with your own as well.

 

 

&axi_gpio_0 {
compatible = "this-is-the-compatible-string";
};

 

 

Step 3: Modify your kernel module to use your new compatible string instead of "xlnx,xps-gpio-1.00.a"

View solution in original post

0 Kudos