[ARM开发] 【小梅哥SoC】如何查看SoC FPGA的系统中FPGA侧添加的GPIO的编号并使用中断

小梅哥   2019-1-29 11:38 楼主
将Intel SoC FPGA的开发方法详细系统的整理出来,小梅哥一直在努力。(YY自嗨一把)。

问题描述
        之前因为中断号的问题,卡了几年。对于ARM侧自己的GPIO,都有一个计算公式可以算出每个pin 对应的GPIO号,而对于在FPGA侧为ARM添加的PIO,添加之后该PIO的编号是多少,一直是一个困扰着我的难题,因为自己Linux方面很菜,很菜很菜,所以一直不知道如何去解决,今天终于在官网上找到了解答。以下为原文内容,我就不翻译了。最后附上能够在我们的AC501-SoC的系统中直接实验的按键中断的源码。

纯英文的,翻译过来就懂了,是的,你没猜错,这是我官网复制粘贴的,不是我写的,
Application to register interrupt and write simple interrupt service routine

----------------------------------------------------------------------------
Detect user input from push button / DIP switch:
        modprobe gpio_interrupt gpio_number=

When user presses the button or flips the dip switch, a message will be printed
to kernel console.
1. If the user connects to the console on board using serial connection,
the message "Interrupt happened at gpio:" will be printed on the
console.
2. If the user connects to the console on board using ssh, the message can be
viewed from kernel log via "dmesg" command.

Note: User will need to do "rmmod gpio_interrupt" prior in order to change
gpio_number by calling "modprobe gpio_interrupt gpio_number=" again

User will need to get the GPIO number from /sys/class/gpio/ by using
command 'ls'. E.g.

        root@socfpga~:# ls /sys/class/gpio/
        gpiochip150        gpiochip152        gpiochip156        gpiochip160
        gpiochip192        gpiochip224

From the listing, n can be obtained. The GPIO number may vary for different
design with different device tree entries; this is due to the GPIO numbers are
auto-assign by the kernel.

To confirm the n is associated to which peripheral, user needs to match the
label of the GPIO chip to the address of push button and DIP switch in device
tree.
e.g.
        root@socfpga~:# cat /sys/class/gpio/gpiochip150/label
        /sopc@0/bridge@0xc0000000/gpio@0x1000100C0

In this reference design, DIP switch is at address 0x10080 while the push button
is at address 0x100c0. So in this case GPIO number 150 - 151 are allocated to
push button 0 - 1.

pio-interrupt.rar (19.47 KB)
(下载次数: 30, 2019-1-29 11:37 上传)

至于如何编译该驱动和使用,请参考小梅哥《基于SoC FPGA的嵌入式设计和开发教程》一书中对应内容。

回复评论 (2)

感谢分享!
IIS7站群大全
点赞  2019-1-29 12:40
基于SoC FPGA的嵌入式设计和开发教程

这本书, 搜不到
点赞  2019-2-1 14:02
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复