cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer
Observer
16,034 Views
Registered: ‎03-05-2012

MIO GPIO interrupt in device tree

Hi

 

I am trying to specify a MIO GPIO as an interrupt source for a linux driver. The driver in question is for the ADS7846 touchscreen controller. I have been able to get the touchscreen working by modifying the PCB to take the interrupt line to the PL, then connecting this to a PL-PS interrupt. I would like to know how to use the MIO GPIO instead.

 

My dev tree:

 

&spi0 {
    is-decoded-cs = <0>;
    num-cs = <2>;
    status = "okay";
    touchscreen@0 {
                reg = <0>;
                compatible = "ti,ads7846";

 

               /* I have been able to get it working by using a PL-PS interrupt */
                /*interrupt-parent = <&intc>;
                interrupts = <0 29 1>;*/

 

               /* I can't find how to specify the MIO GPIO as an interrupt source */

                interrupt-parent = <&gpio0>;

                interrupts = <&gpio0 52 0x2>;


                spi-max-frequency = <1000000>;
                pendown-gpio = <&gpio0 52 0>;
                vcc-supply = <&regulator_vccpint>;
        };

};

 

Does anyone have examples of setting up a MIO GPIO as an interrupt source in the device tree? Or links to good documentation?

 

Thanks in advance,

Will

0 Kudos
15 Replies
Highlighted
Scholar
Scholar
16,009 Views
Registered: ‎10-26-2012

Re: MIO GPIO interrupt in device tree

interrupt-parent = <&gpio>;

interrupts = <64 0x2>; /* GPIO 64 (EMIO 10), falling edge */

 

Where "gpio" is the label of the GPIO controller in the DT.

 

See here:

https://github.com/topic-embedded-products/linux/blob/topic-miami/arch/arm/boot/dts/topic-miami-florida-gen.dtsi

 

The AD7879 touchscreen also uses a GPIO line here.

0 Kudos
Highlighted
Observer
Observer
16,000 Views
Registered: ‎03-05-2012

Re: MIO GPIO interrupt in device tree

Hi Milosoftware

 

Thanks for replying. I think I'm getting there..

 

Did you have to change your gpio node in the DT?

 

When I use the following DT for the touchscreen controller:

&spi0 {
    is-decoded-cs = <0>;
    num-cs = <1>;
    status = "okay";
    touchscreen@0 {
                reg = <0>;
                compatible = "ti,ads7846";

                 interrupt-parent = <&gpio0>;
                 interrupts = <52 2>;
                spi-max-frequency = <1000000>;
                pendown-gpio = <&gpio0 52 0>;
                vcc-supply = <&regulator_vccpint>;
        };
};

 

The driver fails to probe:

genirq: Setting trigger mode 2 for irq 61 failed (gic_set_type+0x0/0x84)
ads7846 spi32766.0: trying pin change workaround on irq 61
genirq: Setting trigger mode 3 for irq 61 failed (gic_set_type+0x0/0x84)
ads7846 spi32766.0: irq 61 busy?

 

I think it is requesting IRQ 61 (a IRQF2P) which cannot have falling edge sensitivity? As a test, I also modified the driver to request a rising edge interrupt, and this successfully probes, but the driver does not work, presumably due to the incorrect IRQ. Changing this, however, allowed me to look in /proc/interrupts, which shows that a GIC interrupt 61 is registered.

 

I then tried adding interrupt-controller; to the gpio node:

&gpio0 {
    emio-gpio-width = <6>;
    gpio-mask-high = <0x0>;
    gpio-mask-low = <0x5600>;
    interrupt-controller;
    #interrupt-cells = <2>;
};

 

The driver then does probe:

 

ads7846 spi32766.0: touchscreen, irq 148
ads7846 spi32766.0: SPI transfer timed out
input: ADS7846 Touchscreen as /devices/soc0/amba/e0006000.spi/spi_master/spi32766/spi32766.0/input/input0

 

And /proc/interrupts shows an IRQ registered with zynq-gpio as the controller:

 

116: 59210 0 zynq-gpio 20
148: 0 0 zynq-gpio 52 ads7846

 

This seems promising, but as shown in the messages above, the SPI seems to have stopped working.

 

I tried clarifying the SPI interrupt as follows:

&spi0 {
   is-decoded-cs = <0>;
  num-cs = <1>;
  status = "okay";
   interrupt-parent = <&intc>;
   interrupts = <0 26 4>;
   touchscreen@0 {
     reg = <0>;
     compatible = "ti,ads7846";

     interrupt-parent = <&gpio0>;
     interrupts = <52 2>;
     spi-max-frequency = <1000000>;
    pendown-gpio = <&gpio0 52 0>;
     vcc-supply = <&regulator_vccpint>;
   };
};

 

But the SPI transfer still times out.

 

It seems close, any ideas on what might be the problem? And should the GPIO DT entry be modified as I have?

 

Thanks in advance

Will

0 Kudos
Highlighted
Scholar
Scholar
15,983 Views
Registered: ‎10-26-2012

Re: MIO GPIO interrupt in device tree

Marking the GPIO controller as "interrupt-parent" is indeed needed. It should support both edges. Since your devicetree did not already mark the gpio controller as interrupt parent, I suspect you have an old kernel version where GPIO interrupt support is simply broken, it won't work regardless of what you do in the devicetree.

 

What kernel are you using?

0 Kudos
Highlighted
Scholar
Scholar
15,982 Views
Registered: ‎10-26-2012

Re: MIO GPIO interrupt in device tree

From lookign at your DT, I'd derive that the driver expects EITHER a gpio pin OR an interrupt, but not both, especially not when they both point to the same pin.

0 Kudos
Highlighted
Observer
Observer
15,973 Views
Registered: ‎03-05-2012

Re: MIO GPIO interrupt in device tree

Hi

 

I'm using kernel 3.17, from linux-xlnx releases for Vivado 2014.4. It's very interesting to know that the GPIO entry should have interrupt-parent set. I think the kernel version should be OK, I assume the device tree generator will affect this, so I will check this is up to date.

 

As far as the driver DT goes, I am fairly sure it needs both GPIO and interrupt; in the device tree binding documentation they are both listed as required. I did try not including an IRQ entry, and the probe failed.

 

Will

0 Kudos
Highlighted
Observer
Observer
15,955 Views
Registered: ‎03-05-2012

Re: MIO GPIO interrupt in device tree

Hi,

 

I have just checked my kernel and device tree generator. I'm using the 2014.4 release "xilinx-v2014.4" from https://github.com/Xilinx/device-tree-xlnx/releases. This doesn't seem to set interrupt-controller for gpio. Also, from what I can tell, the 2015.1 version wouldn't set it either. (Looking in the 2015.1 release, /device_tree/data/kernel_dtsi/2015.1/zynq/zynq-700.dtsi)

 

What kernel/device tree/Vivado version are you using?

 

Thanks

Will

0 Kudos
Highlighted
Scholar
Scholar
15,864 Views
Registered: ‎10-26-2012

Re: MIO GPIO interrupt in device tree

Currently using kernel 3.19, and avoiding Vivado for anything else than generating bitstreams.

 

There have been quite some changes in the GPIO driver, I don't know it Xilinx integrated all the required fixes to get the GPIO controller to actually work as interrupt provider, but i'd expect so.

0 Kudos
Highlighted
Observer
Observer
15,584 Views
Registered: ‎03-05-2012

Re: MIO GPIO interrupt in device tree

(Sorry for late reply)

 

Just tried updating to Vivado 2015.1. Generated device tree, and there is still no interrupt controller property.

 

How do you create device tree if not using "Export Hardware.." and "device-tree-xlnx" generator?

 

Thanks

Will

0 Kudos
Highlighted
Contributor
Contributor
15,351 Views
Registered: ‎12-18-2012

Re: MIO GPIO interrupt in device tree

Hi,

I am facing the same kind of issue ( using vivado 2015.1 / linux 3.17 from Xilinx Git)

I need to specify an MIO as IRQ source in my DTS for sdio wifi support (wlcore device).

Did you find a way to fix it?

Thanks in advance,

Fred

0 Kudos
Highlighted
Observer
Observer
11,710 Views
Registered: ‎03-05-2012

Re: MIO GPIO interrupt in device tree

Sorry, no fix yet. On the next Rev of my PCB I have added the option of routing all the interrupts to the fabric so I can avoid GPIO interrupts. It's not ideal, I'd like to know how to get GPIO MIO interrupts working.

 

If I find out I will post back here.

0 Kudos
Highlighted
Contributor
Contributor
11,697 Views
Registered: ‎12-18-2012

Re: MIO GPIO interrupt in device tree

Thanks for your feedback.

I also did the same. My first prototype was using MIO as IRQ, I plan to move it to EMIO on next board release.

Anyway, I will try to find how to fix this. I suspect that IRQ feature is not supported by the current PS_GPIO linux driver.

I will post an update if I can found something.

Thanks,

Regards

Frederic

0 Kudos
Highlighted
Scholar
Scholar
11,691 Views
Registered: ‎10-26-2012

Re: MIO GPIO interrupt in device tree

I'm using GPIO interrupts on both MIO and EMIO, works fine on the Zynq.

 

You DO need a recent kernel, and you DO need the interrupt-controller entries in the devicetree for the GPIO controller, as was discussed here in another thread I think.

 

 

0 Kudos
Highlighted
Observer
Observer
11,668 Views
Registered: ‎03-05-2012

Re: MIO GPIO interrupt in device tree

Hi milosoftware

 

Thanks for the encouragement. I have a recent kernel, and have added interrupt-controller; to the GPIO dts, but not got round to switching the board back to test it yet.

 

Out of interest, how do you generate your device tree source? I export to SDK,  but this does not correctly set the GPIO interrupt controller.

 

Will

0 Kudos
Highlighted
Scholar
Scholar
11,637 Views
Registered: ‎10-26-2012

Re: MIO GPIO interrupt in device tree

I just hand-craft the devicetree.

 

99% of the tree is "static", it's just a description of the board. The few parts that require changes are easy to do manually. It also prevents running into problems because of bugs in Vivado or the generator software, the GPIO interrupts not working is one of those bugs.

0 Kudos
Highlighted
Observer
Observer
11,613 Views
Registered: ‎03-05-2012

Re: MIO GPIO interrupt in device tree

OK - so it's taken a while, but I think I have now worked it out!

 

I changed the gpio entry in the "zynq-7000.dtsi" file to the following:

 

gpio0: gpio@e000a000 {
            compatible = "xlnx,zynq-gpio-1.0";
            #gpio-cells = <2>;
            clocks = <&clkc 42>;
            gpio-controller;
            interrupt-parent = <&intc>;
            interrupts = <0 20 4>;

            #interrupt-cells = <2>;
            interrupt-controller;
            
            reg = <0xe000a000 0x1000>;
        };

 

 

And then specified interrupts for devices as follows:

 

&spi0 {
    is-decoded-cs = <0>;
    num-cs = <2>;
    status = "okay";
    touchscreen@0 {
        reg = <0>;                                                         /* CS0 */
        compatible = "ti,ads7846";
        interrupt-parent = <&gpio0>;
        interrupts = <52 2>;                                       /* MIO 52, falling edge */
        spi-max-frequency = <1000000>;
        pendown-gpio = <&gpio0 52 0>;
        vcc-supply = <&regulator_vccpint>;              /* dummy */
        };
    nfc@0 {
        compatible = "ti,trf7970a";
        reg = <1>;
        pinctrl-names = "default";
        spi-max-frequency = <2000000>;
        interrupt-parent = <&gpio0>;
        interrupts = <15 1>;                                            /* GPIO MIO 15, rising edge */
        ti,enable-gpios = <&gpio0 14 0>,
                <&gpio0 13 0>;                                          /* 13 = dummy- don't need EN2 support */
        vin-supply = <&regulator_vccpint>;              /* dummy */
        autosuspend-delay = <30000>;
        /*irq-status-read-quirk;
        en2-rf-quirk;*/
        status = "okay";
    };
};

 

For info,

 

# dmesg | grep ads
ads7846 spi32766.0: touchscreen, irq 148

 

# cat /proc/interrupts
CPU0 CPU1
27: 0 0 GIC 27 gt
29: 891 540 GIC 29 twd
35: 0 0 GIC 35 f800c000.ocmc
40: 0 0 GIC 40 f8007000.devcfg
41: 0 0 GIC 41 f8005000.watchdog
43: 0 0 GIC 43 ttc_clockevent
45: 0 0 GIC 45 f8003000.dmac
46: 0 0 GIC 46 f8003000.dmac
47: 0 0 GIC 47 f8003000.dmac
48: 0 0 GIC 48 f8003000.dmac
49: 0 0 GIC 49 f8003000.dmac
51: 4513 0 GIC 51 e000d000.spi
53: 0 0 GIC 53 zynq-udc
56: 88 0 GIC 56 mmc0
57: 26 0 GIC 57 cdns-i2c
58: 724 0 GIC 58 e0006000.spi
72: 0 0 GIC 72 f8003000.dmac
73: 0 0 GIC 73 f8003000.dmac
74: 0 0 GIC 74 f8003000.dmac
75: 0 0 GIC 75 f8003000.dmac
79: 52 0 GIC 79 mmc1
82: 334 0 GIC 82 xuartps
111: 0 0 zynq-gpio 15 trf7970a
148: 21 1 zynq-gpio 52 ads7846
IPI1: 0 0 Timer broadcast interrupts
IPI2: 2061 2277 Rescheduling interrupts
IPI3: 0 0 Function call interrupts
IPI4: 8 45 Single function call interrupts
IPI5: 0 0 CPU stop interrupts
IPI6: 1 0 IRQ work interrupts
IPI7: 0 0 completion interrupts
Err: 0

 

 

Thanks Milosoftware for your help.

 

Will

0 Kudos