1.执行下面的命令,可以显示目前驱动已经申请到的IO状态 :
$ mount -t debugfs debugfs /sys/kernel/debug
$ cat /sys/kernel/debug/gpio
[email protected]:/# cat /sys/kernel/debug/gpio
GPIOs 0-31, gpio:
gpio-2 (volume-up ) in hi
gpio-3 (volume-down ) in hi
gpio-6 (mmc_cd ) in hi
GPIOs 32-63, gpio:
gpio-48 (wlan_en ) out lo
gpio-53 (matrix_kbd_col ) out hi
gpio-54 (matrix_kbd_col ) out hi
gpio-57 (matrix_kbd_row ) in lo
gpio-58 (matrix_kbd_row ) in lo
gpio-59 (matrix_kbd_row ) in lo
GPIOs 64-95, gpio:
GPIOs 96-127, gpio:
gpio-114 (mmc_wp ) in lo
gpio-117 (bt_en
) out lo
2,重新申请一个新IO(118),并且查看有没有申请成功:
[email protected]:/# echo 118 > /sys/class/gpio/export
[email protected]:/# ls /sys/class/gpio
export gpiochip0 gpiochip64 unexport
gpio118 gpiochip32 gpiochip96
[email protected]:/# cat /sys/kernel/debug/gpio
GPIOs 0-31, gpio:
gpio-2 (volume-up ) in hi
gpio-3 (volume-down ) in hi
gpio-6 (mmc_cd ) in hi
GPIOs 32-63, gpio:
gpio-48 (wlan_en ) out lo
gpio-53 (matrix_kbd_col ) out hi
gpio-54 (matrix_kbd_col ) out hi
gpio-57 (matrix_kbd_row ) in lo
gpio-58 (matrix_kbd_row ) in lo
gpio-59 (matrix_kbd_row ) in lo
GPIOs 64-95, gpio:
GPIOs 96-127, gpio:
gpio-114 (mmc_wp ) in lo
gpio-117 (bt_en
) out lo
gpio-118 (sysfs ) in lo
3,改变IO为输出:
[email protected]:/# echo "out" > /sys/class/gpio/gpio118/direction
使IO的输出为高:
[email protected]:/# echo 1 > /sys/class/gpio/gpio118/value
[email protected]:/# cat /sys/kernel/debug/gpio
GPIOs 0-31, gpio:
gpio-2 (volume-up ) in hi
gpio-3 (volume-down ) in hi
gpio-6 (mmc_cd ) in hi
GPIOs 32-63, gpio:
gpio-48 (wlan_en ) out lo
gpio-53 (matrix_kbd_col ) out hi
gpio-54 (matrix_kbd_col ) out hi
gpio-57 (matrix_kbd_row ) in lo
gpio-58 (matrix_kbd_row ) in lo
gpio-59 (matrix_kbd_row ) in lo
GPIOs 64-95, gpio:
GPIOs 96-127, gpio:
gpio-114 (mmc_wp ) in lo
gpio-117 (bt_en
) out lo
gpio-118 (sysfs ) out hi
4,释放IO:
[email protected]:/# echo 118 > /sys/class/gpio/unexport