cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
nunu
Contributor
Contributor
419 Views
Registered: ‎06-08-2017

Petalinux 2019.1 Interrupt Handling Zynq 7000

Hi at all, 

this topic has been discussed from different perspectives.

Let me describe the basic infomation:

HostMachine: Ubuntu 18.04.3 LTS

Eval-Board: Myir Z-Turn Board 7020

Fpga-Design: is attached in a picture

A bare-metal version of the Interrupt-Handler is running.

The main task is to receive an input signal, which is detected by an IRQ and the Interrupt-Handler generates as a consequence a signal on a output pin.

 

 

Now I want to impliment a petalinux driver module with the same task.

During research I have found different methods to control the Interrupts.

The current state is that a petalinux image is running and skeleton of a driver module ist generate with:

  •   petalinux-create -t modules --name mymodule --enable

The first question is: How to connect the "Concate" IP-Block with the IRQ_F2P of the PS form a petalinux module? The input signal is a gpio without the AXI interface. 

Some posts show the modification of device tree in this file:

  • project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

I don't have fine a way to control the GIC like in the bare-metal version.

These entries should be a part of the system-user.dtsi file:

  • interrupt-parent = <&irq_cntlr>;
  • interrupts = <0 96 4>;

But which is the component that enclose them? intc?

I have seen that different Petalinux version has different approaches. How is the right way to handle Interrupts with the Petalinux ersion 2019.1?

 

Thx in advance.

 

 

 

FpgaDesign.jpg
0 Kudos
2 Replies
thenumberdevil
Explorer
Explorer
347 Views
Registered: ‎04-21-2020

I too have the same question.

  1. In Bare-metal application I could see interrupt handler registered at #define XPS_FPGA0_INT_ID 61U. 
  2. What are the steps which we need to do to get the interrupt in the platform Linux driver module.
0 Kudos
nunu
Contributor
Contributor
294 Views
Registered: ‎06-08-2017

Hi have change the design on the input site and use now also AXI_GPIO:


 
After this the following device-tree part was created by the petalinux scripts:

folder: <proj>components/plnx_workspace/device-tree/device-tree/pl.dtsi

/ {
amba_pl: amba_pl {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges ;
Dip_Switches: gpio@41220000 {
#gpio-cells = <3>;
#interrupt-cells = <2>;
clock-names = "s_axi_aclk";
clocks = <&clkc 15>;
compatible = "xlnx,axi-gpio-2.0", "xlnx,xps-gpio-1.00.a";
gpio-controller ;
interrupt-controller ;
interrupt-names = "ip2intc_irpt";
interrupt-parent = <&intc>;
interrupts = <0 29 4>;
reg = <0x41220000 0x10000>;
xlnx,all-inputs = <0x1>;
xlnx,all-inputs-2 = <0x0>;
xlnx,all-outputs = <0x0>;
xlnx,all-outputs-2 = <0x0>;
xlnx,dout-default = <0x00000000>;
xlnx,dout-default-2 = <0x00000000>;
xlnx,gpio-width = <0x1>;
xlnx,gpio2-width = <0x20>;
xlnx,interrupt-present = <0x1>;
xlnx,is-dual = <0x0>;
xlnx,tri-default = <0xFFFFFFFF>;
xlnx,tri-default-2 = <0xFFFFFFFF>;
};
Input_Axi_Gpio: gpio@41230000 {
#gpio-cells = <3>;
#interrupt-cells = <2>;
clock-names = "s_axi_aclk";
clocks = <&clkc 15>;
compatible = "xlnx,axi-gpio-2.0", "xlnx,xps-gpio-1.00.a";
gpio-controller ;
interrupt-controller ;
interrupt-names = "ip2intc_irpt";
interrupt-parent = <&intc>;
interrupts = <0 30 4>;
reg = <0x41230000 0x10000>;
xlnx,all-inputs = <0x1>;
xlnx,all-inputs-2 = <0x0>;
xlnx,all-outputs = <0x0>;
xlnx,all-outputs-2 = <0x0>;
xlnx,dout-default = <0x00000000>;
xlnx,dout-default-2 = <0x00000000>;
xlnx,gpio-width = <0x1>;
xlnx,gpio2-width = <0x20>;
xlnx,interrupt-present = <0x1>;
xlnx,is-dual = <0x0>;
xlnx,tri-default = <0xFFFFFFFF>;
xlnx,tri-default-2 = <0xFFFFFFFF>;
};
axi_gpio_0: gpio@41200000 {
#gpio-cells = <3>;
clock-names = "s_axi_aclk";
clocks = <&clkc 15>;
compatible = "xlnx,axi-gpio-2.0", "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 = <0x3>;
xlnx,gpio2-width = <0x20>;
xlnx,interrupt-present = <0x0>;
xlnx,is-dual = <0x0>;
xlnx,tri-default = <0xFFFFFFFF>;
xlnx,tri-default-2 = <0xFFFFFFFF>;
};
axi_gpio_1: gpio@41210000 {
#gpio-cells = <3>;
clock-names = "s_axi_aclk";
clocks = <&clkc 15>;
compatible = "xlnx,axi-gpio-2.0", "xlnx,xps-gpio-1.00.a";
gpio-controller ;
reg = <0x41210000 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 = <0x1>;
xlnx,gpio2-width = <0x20>;
xlnx,interrupt-present = <0x0>;
xlnx,is-dual = <0x0>;
xlnx,tri-default = <0xFFFFFFFF>;
xlnx,tri-default-2 = <0xFFFFFFFF>;
};
};
};

In the following user file, I have modified the single Gpio-nodes:

/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

/include/ "system-conf.dtsi"
/ {
amba_pl: amba_pl {
Dip_Switches: gpio@41220000 {
compatible = "dip_switches";interrupts = <0 29 1>;};
Input_Axi_Gpio: gpio@41230000 {
compatible = "input_axi_gpio";interrupts = <0 30 1>;};
axi_gpio_0: gpio@41200000 {
compatible = "axi_gpio_0";};
axi_gpio_1: gpio@41210000 {
compatible = "axi_gpio_1";};
};
};

The driver module is modified in the following section:

#ifdef CONFIG_OF
static struct of_device_id interruptdrv_of_match[] = {
{ .compatible = "dip_switches", },
{ .compatible = "input_axi_gpio", },
{ .compatible = "axi_gpio_0", },
{ .compatible = "axi_gpio_1", }, 
{ /* end of list */ },
};
MODULE_DEVICE_TABLE(of, interruptdrv_of_match);
#else
# define interruptdrv_of_match
#endif

With this configuration a boot up on the board is possible without errors of the driver (output dmesg).

From the output I see that the _probe function is called four time

like the amount of entries in the system-user.dtsi.

So the first question is:

  • How could be single gpio pins be manipulate through the driver?

The second questions is:

  • What are the advantages and 
    disadvantage to this approach compared to the Sysfs approach? 
*GPIO access

echo -n 906 > /sys/class/gpio/export
ls /sys/class/gpio

*chang to direction
cat /sys/class/gpio/gpio906/direction
->in

echo out > /sys/class/gpio/gpio906/direction
cat /sys/class/gpio/gpio906/direction
->out

*change value
echo 0 > /sys/class/gpio/gpio906/value
echo 1 > /sys/class/gpio/gpio906/value

A driver module Sysfs example could be found under this link: 

https://gist.github.com/itrobotics/224a0c549ae073ce991c 

 

Regards

Nunu

FpgaDesign001.jpg
dirverModule_Bootup.jpg
0 Kudos