作者:付汉杰,<a href="mailto:hankf@xilinx.com">hankf@xilinx.com</a>,文章转载自:<a id="link_3" href="https://forums.xilinx.com/t5/%E5%B5%8C%E5%85%A5%E5%BC%8F-%E5%B7%A5%E5%8…;
Zynq-7000和MPSoC有很多MIO管脚。如果外设有中断,也可以通过MIO驱动。
<strong>GPIO中断控制器</strong>
按下列模式,在GPIO的设备树里声明为中断控制器
<pre>&gpio0 {
#interrupt-cells = <2>;
interrupt-controller;
};</pre>
<strong>外设使用GPIO中断控制器</strong>
外设的设备树里,添加下列行,声明gpio0为自己的中断控制器,并声明对应的MIO引脚和中断内心。
<pre>touchscreen@0 {
interrupt-parent = <&gpio0>;
interrupts = <52 2>; /* MIO 52, falling edge */
};</pre>
<strong>检查结果</strong>
单板启动后,可以检查启动信息和中断信息。
<pre># dmesg | grep ads
ads7846 spi32766.0: touchscreen, irq 148
# cat /proc/interrupts
CPU0 CPU1
148: 21 1 zynq-gpio 52 ads7846</pre>
<strong>文档</strong>
GPIO的中断说明,在Linux的文件Documentation/devicetree/bindings/gpio/gpio-zynq.txt里。
中断的相关信息如下:
<pre>- interrupt-controller : Marks the device node as an interrupt controller.
- #interrupt-cells : Should be 2. The first cell is the GPIO number.
The second cell bits[3:0] is used to specify trigger type and level flags:
1 = low-to-high edge triggered.
2 = high-to-low edge triggered.
4 = active high level-sensitive.
8 = active low level-sensitive.</pre>
参考文档:https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842482/Device+T…