UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor vince2018
Visitor
2,609 Views
Registered: ‎10-27-2017

Configure and Enable Userspace I/O driver in Petalinux to access AXI GPIO

Jump to solution

Hi,

 

I am trying to enable User space I/O driver (UIO driver)  in Petalinux and access AXI GPIO from the UIO driver.

 

I want to know how to configure the petalinux kernel driver options for UIO and how to write the relevant device tree file.

 

Is there any document or guide to provide detailed procedures?

 

Thanks,

Regards,

Vincent

0 Kudos
1 Solution

Accepted Solutions
Visitor vince2018
Visitor
3,472 Views
Registered: ‎10-27-2017

Re: Configure and Enable Userspace I/O driver in Petalinux to access AXI GPIO

Jump to solution

Hi,

 

Finally I figured out how to enable uio in petalinux:

 

kernel config:

 

Go to petalinux-config -c kernel
Device drivers
User space io drivers
<*> userspace io platform driver ..

check xilinx-zc706-2017.1/project-spec/meta-user/recipes-kernel/linux/linux-xlnx/user...cfg
CONFIG_UIO=y
CONFIG_UIO_PDRV=y
CONFIG_UIO_PDRV_GENIRQ=y

 

 

Device tree to override:

 

project-spec/meta-user/recipes-bsp/device-tree/files
add sample-user1.dtsi :
/ {
        amba_pl: amba_pl {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "simple-bus";
                ranges ;
                axi_gpio_0: gpio@41200000 {
                        #gpio-cells = <2>;
                        compatible = "generic-uio";
                        gpio-controller ;
                        reg = <0x41200000 0x10000>;
                        xlnx,all-inputs = <0x0>;
                        xlnx,all-inputs-2 = <0x0>;
                        xlnx,all-outputs = <0x1>;
                        xlnx,all-outputs-2 = <0x0>;
                        xlnx,dout-default = <0x00000000>;
                        xlnx,dout-default-2 = <0x00000000>;
                        xlnx,gpio-width = <0x4>;
                        xlnx,gpio2-width = <0x20>;
                        xlnx,interrupt-present = <0x0>;
                        xlnx,is-dual = <0x0>;
                        xlnx,tri-default = <0xFFFFFFFF>;
                        xlnx,tri-default-2 = <0xFFFFFFFF>;
                };
        };
};

View solution in original post

0 Kudos
4 Replies
Explorer
Explorer
2,596 Views
Registered: ‎11-24-2013

Re: Configure and Enable Userspace I/O driver in Petalinux to access AXI GPIO

Jump to solution

Hi @vince2018,

 

the AXI GPIO has already a driver that allows you to read/write from userspace. Here is the wiki of Xilinx about it: http://www.wiki.xilinx.com/AXI+GPIO

 

This driver creates a device on 

/sys/class/gpio

which you can read and write in order to interact with the GPIO. You can find on that website what to write in the device tree and how to configure it.

 

If you use UIO directly, you will have access to the registers of the GPIO from userspace, and you will have to configure it writing and reading the different registers, which is much more work and also a possible source of bugs. If you just want to control the GPIO from userspace, I recommend you to use its specific driver.

 

Regards,

Ignacio

0 Kudos
Moderator
Moderator
2,585 Views
Registered: ‎12-04-2016

Re: Configure and Enable Userspace I/O driver in Petalinux to access AXI GPIO

Jump to solution

Hi Vincent

 

Check to see if this link helps:-

http://svenand.blogdrive.com/archive/203.html#.WglkeVuCypo

 

Best Regards

Shabbir

0 Kudos
Explorer
Explorer
2,540 Views
Registered: ‎10-04-2017

Re: Configure and Enable Userspace I/O driver in Petalinux to access AXI GPIO

Jump to solution
You don’t have to acces the registers directly for UIO to work but you do need to configure the GPIO controller to generate interrupts. You do have to do something to trigger the interrupt which could be a register write or a change of some sort on a gpio input.. Also the blog post does not look up to date since the company string will not match. There have been several post lately discussing this and I recall seeing them modifying the kernel command line so that generic UIO devices will be detected correctly.
0 Kudos
Visitor vince2018
Visitor
3,473 Views
Registered: ‎10-27-2017

Re: Configure and Enable Userspace I/O driver in Petalinux to access AXI GPIO

Jump to solution

Hi,

 

Finally I figured out how to enable uio in petalinux:

 

kernel config:

 

Go to petalinux-config -c kernel
Device drivers
User space io drivers
<*> userspace io platform driver ..

check xilinx-zc706-2017.1/project-spec/meta-user/recipes-kernel/linux/linux-xlnx/user...cfg
CONFIG_UIO=y
CONFIG_UIO_PDRV=y
CONFIG_UIO_PDRV_GENIRQ=y

 

 

Device tree to override:

 

project-spec/meta-user/recipes-bsp/device-tree/files
add sample-user1.dtsi :
/ {
        amba_pl: amba_pl {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "simple-bus";
                ranges ;
                axi_gpio_0: gpio@41200000 {
                        #gpio-cells = <2>;
                        compatible = "generic-uio";
                        gpio-controller ;
                        reg = <0x41200000 0x10000>;
                        xlnx,all-inputs = <0x0>;
                        xlnx,all-inputs-2 = <0x0>;
                        xlnx,all-outputs = <0x1>;
                        xlnx,all-outputs-2 = <0x0>;
                        xlnx,dout-default = <0x00000000>;
                        xlnx,dout-default-2 = <0x00000000>;
                        xlnx,gpio-width = <0x4>;
                        xlnx,gpio2-width = <0x20>;
                        xlnx,interrupt-present = <0x0>;
                        xlnx,is-dual = <0x0>;
                        xlnx,tri-default = <0xFFFFFFFF>;
                        xlnx,tri-default-2 = <0xFFFFFFFF>;
                };
        };
};

View solution in original post

0 Kudos