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 gee
Visitor
11,417 Views
Registered: ‎06-17-2015

Accessing PS GPIO through Petalinux

Hi All,

 

I would like to ask some help as I'm starting learning zynq petalinux.

I have a zynq zc702 rev1.1 development board to play with and looking into its schematic I found SW13/14 connected to PS bank 500. I've read somewhere in the internet that gpio connected in PS can be access directly without constraint, thinking this will be a good start.

 

I tried accessing the two buttons by using the given Xilinx-ZC702-v2015.2-final.bsp and edited the dts file and using http://svenand.blogdrive.com/files/gpio-uio-test.c as my test code which I got from https://forums.xilinx.com/t5/Zynq-All-Programmable-SoC/Using-generic-uio-with-PS-GPIO/m-p/643791#M9938

 

This is my system-top.dts file after adding @gpio0 referrence:

/dts-v1/;
/include/ "system-conf.dtsi"
/ {
};

/{    
  chosen 
	{
		bootargs = "console=ttyPS0,115200 earlyprintk uio_pdrv_genirq.of_id=generic-uio";
	};
};

&clkc {
	fclk-enable = <0xff>;
};

&leds_4bits
{
 compatible = "generic-uio";
 xlnx,gpio-width = <0x20>;
 xlnx,all-inputs-2 = <0x20>;
 xlnx,is-dual = <0x1>;
};

&gpio0
{
  compatible = "generic-uio";
  xlnx,is-dual = <0x1>;
  xlnx,all-inputs-2 = <0x1>;
  xlnx,gpio2-width = <0x2>;
  xlnx,tri-default-2 = <0xffffffff>;
  xlnx,gpio2-width = <0x20>;
};

&i2c0 {
	#address-cells = <1>;

... //more here

};
...// qspi last entry here

I build it, program it through jtag and it was successful, I saw uio0 and uio1, which I believed uio0 = &Leds_4bits and uio1 = &gpio0 from my dts above.

dev.JPG

 

However, when I debug the code, I received zero's while SW13/14 is pressed.

output.JPG

 

I also changed in the code the offset from GPIO_TRI_OFFSET to GPIO2_TRI_OFFSET as well as the GPIO_DATA_OFFSET to GPIO2_DATA_OFFSET but got same result.

 

I know there is something that I've missed, but don't know where.

If you could help me point it out, that would be great.

 

This is the default pl.dtsi generated from the bsp (unedited):

/*
 * CAUTION: This file is automatically generated by Xilinx.
 * Version: HSI 
 * Today is: Mon Jul 13 05:19:46 2015
*/


/ {
	amba_pl: amba_pl {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "simple-bus";
		ranges ;
		leds_4bits: gpio@41200000 {
			#gpio-cells = <2>;
			compatible = "xlnx,xps-gpio-1.00.a";
			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>;
		};
	};
};

 

Thanks

gee

0 Kudos
6 Replies
Visitor gee
Visitor
11,235 Views
Registered: ‎06-17-2015

Re: Accessing PS GPIO through Petalinux

 

I'm still not able to talk to ps gpio on my board, particularly the sw13/14 and ds12/23. I tried using the code from

https://forums.xilinx.com/xlnx/attachments/xlnx/ELINUX/12938/1/gpio_uio_app.c

 

I don't know what to put in my system-top.dts file. I tried this:

 

/dts-v1/;
/include/ "system-conf.dtsi"
/ {
};

/{    
  chosen 
	{
		bootargs = "console=ttyPS0,115200 earlyprintk      uio_pdrv_genirq.of_id=generic-uio";
	};
};

&clkc {
	fclk-enable = <0xff>;
};

&axi_gpio_0
{
 compatible = "generic-uio"; 
};

&gpio0
{
compatible = "generic-uio";
};

and modify the code to read the two buttons

 

 

while(1)
  {
//determine which button was pressed regs = gpio_read(ptr, GPIO_DATA_OFFSET);//was GPIO_DATA2_OFFSET if(regs != 0) printf("Im getting something here. \n"); else printf("Nothing is coming. \n"); }

but still nothing I received.

 

I'm getting button presses in sw5/7 using GPIO_DATA2_OFFSET but nothing on sw13/14.

 

I also observed that sw5/7 won't interrupt if &gpio0 {}; is added in my dts file like above, why is that?

 

Hope someone can shade some light here.

 

thanks in advance

gee

 

Tags (2)
0 Kudos
Visitor gee
Visitor
10,996 Views
Registered: ‎06-17-2015

Re: Accessing PS GPIO through Petalinux

Ok, I found something in xilinx (http://goo.gl/IqlSB2) it uses DS12/23 SW13/14.

I copied the nodes to my zynq-7000.dtsi just below my gpio0 node.

And it works after I load it into the board, DS23 is blinking like a heartbeat.

 

My questions:

1. Can I make it into UIO (/dev/uiox) so I can create uio driver app for that using mmap instead of /sys/class/leds...?

2. I tried adding a single sub-node inside gpio-leds node, this time the DS12 to blink like heartbeat, why it doesn't blink at all, it stays off, see my .dtsi entry below?

gpio-leds
    {
      compatible = "gpio-leds";
      led-ds12
      {
        label = "led-ds12";
        gpios = <&gpio0 8 0>;
        default-state = "on";
        linux,default-trigger = "heartbeat";
      };    
      led-ds23
      {
        label = "led-ds23";
        gpios = <&gpio0 10 0>;
        default-state = "on";
        linux,default-trigger = "heartbeat";
      };         
    };
    

3. It says, only the dts file to edit, what is the proper way or syntax to use so that I can put gpio-leds and gpio-keys node under amba in system-top.dts rather in zynq-7000.dtsi? I tried but it failed,  it says "ERROR: Failed to allocate 0x2000 bytes below 0x0" this error appear after boot up.

 

Hope someone can help me on this.

 

Thanks

gee

0 Kudos
Visitor gee
Visitor
10,629 Views
Registered: ‎06-17-2015

Re: Accessing PS GPIO through Petalinux

After hours of research, the DS23 finally works using UIO, this is my dts now:

gpio0: gpio@e000a000 {
			compatible = "xlnx,zynq-gpio-1.0";
			#gpio-cells = <2>;
			clocks = <&clkc 42>;
			gpio-controller;
			interrupt-parent = <&intc>;
			interrupts = <0 20 4>;
			reg = <0xe000a000 0x1000>;						
		};	/*
		gpio-leds
                {
                  compatible = "generic-uio";
                  reg = <0xe000a000 0x1000>;	
                  led-ds12
                  {
                    label = "led-ds12";
                    gpios = <&gpio0 8 0>;
                    default-state = "on";
                    linux,default-trigger = "heartbeat";
                  };    
                  led-ds23
                  {
                    label = "led-ds23";
                    gpios = <&gpio0 10 0>;
                    default-state = "on";
                    linux,default-trigger = "heartbeat";
                  };         
               };
0 Kudos
Visitor gee
Visitor
10,625 Views
Registered: ‎06-17-2015

Re: Accessing PS GPIO through Petalinux

The above dts works only with DS23, DS12 will not blink I'm wondering if it has to do with the PS_MIO8_500 line pulled-up to VCCMIO.
Has anyone knows why DS12 can't be controlled in UIO?

Also, has anybody tried to control the two switches sw13 & 14 of zc702 board? What syntax did you use in dts? What properties did you add? On what node did you add it?

I tried putting the sample node gpio-keys just below the gpio-leds but it doesn't work.

I really appreciate if someone could help me on this.

Thanks
gee
0 Kudos
Xilinx Employee
Xilinx Employee
10,507 Views
Registered: ‎07-01-2010

Re: Accessing PS GPIO through Petalinux

@gee

 

Have you verified the MIO8 configuration , check the link to configure MIO8 as GPIO so that i can used to control DS12 LED.

http://www.wiki.xilinx.com/Zc702+Linux

 

Reference DTS file for LED & SW on ZC702 https://github.com/cambridgehackers/adiboot/blob/master/dts-files/zynq-zc702.dtsi

 

Regards,

Achutha

---------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------
0 Kudos
Visitor gee
Visitor
10,444 Views
Registered: ‎06-17-2015

Re: Accessing PS GPIO through Petalinux

Hi achutha,

 

I'm very thankful for your reply. This is very helpful as a newbie to zynq.


Those two LEDS and two switches works when I used this: compatible = "gpio-leds" and compatible = "gpio-keys" using the demo application from http://www.wiki.xilinx.com/Linux+GPIO+Driver.

 

However, when I changed it to this compatible = "generic-uio" so I can use http://svenand.blogdrive.com/files/gpio-uio-test.c to both leds and switches, only DS23 works and the rest are like it doesn't exist on the board.

 

My questions:
1. When you say UIO application in accessing gpios does it mean you have to use only "generic-uio" as compatible?

2. I've read from the net that, it is not recommended to use /dev/mem instead use /dev/uioX, then use mmap(), how can I use it by not using "generic-uio" as compatible?

3. In pl.dtsi, I saw properties like xlnx,all-inputs, xlnx,all-inputs-2, xlnx,all-outputs, etc under axi_gpio, will these properties work if I put it in gpio@e000a000 node?

4. Is there any documents, that explains how to configure the dts, what properties to use on this node and not on that node, values to set and not to set, different kind of compatible string how it works, etc, particularly on zynq zc702?

 

Thanks
gee

0 Kudos