在使用GPIO的时候,有时候不知道GPIO的状态,也不知道在内核中GPIO是否申请成功。
可以通过/sys/kernel/debug/gpio这个文件来查看。这个文件显示了申请成功的GPIO的输入输出状态和电平。
参考
GPIO Signals | GPIO Support | RidgeRun Developer
配置
- 内核打开debugfs支持
Symbol: DEBUG_FS [=y]
Prompt: Debug Filesystem
Defined at lib/Kconfig.debug:77
Depends on: SYSFS
Location:
-> Kernel configuration
-> Kernel hacking
- 挂载debugfs
mount -t debugfs none /sys/kernel/debug
测试:
# pwd
/sys/kernel/debug
# ls
bdi extfrag mmc0 suspend_time
binder gpio pinctrl sync
ccudbg hid regulator tracing
clk ieee80211 shrinker usb
cpufreq ion sram wakeup_sources
dma_buf kprobes sunxi_pinctrl
dramfreq memblock suspend_stats
#
# cat gpio
GPIOs 0-287, platform/1c20800.pinctrl, 1c20800.pinctrl:
gpio-0 (phy-rst ) in lo
gpio-17 (phy-rst ) out hi
gpio-35 (up_key ) in hi
gpio-40 (wdt_en ) out lo
gpio-46 (lcd_cs ) out hi
gpio-109 (wdt_ctl ) out hi
gpio-227 (lcd_dc ) out lo
gpio-230 (lcd_blk ) out lo
gpio-231 (lcd_rst ) out hi
gpio-236 (down_key ) in lo
gpio-251 (phy-rst ) out hi
gpio-258 (reset_gpio ) out hi
GPIOs 1024-1025, platform/axp22-gpio, axp-pinctrl:
#