标签:style color os io strong ar cti sp line
1.执行下面的命令,可以显示目前驱动已经申请到的IO状态 :
$ mount -t debugfs debugfs /sys/kernel/debug
$ cat /sys/kernel/debug/gpio
root@am335x-evm:/# 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),并且查看有没有申请成功:
root@am335x-evm:/# echo 118 > /sys/class/gpio/export
root@am335x-evm:/# ls /sys/class/gpio
export gpiochip0 gpiochip64 unexport
gpio118 gpiochip32 gpiochip96
root@am335x-evm:/# 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为输出:
root@am335x-evm:/# echo "out" > /sys/class/gpio/gpio118/direction
使IO的输出为高:
root@am335x-evm:/# echo 1 > /sys/class/gpio/gpio118/value
root@am335x-evm:/# 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:
root@am335x-evm:/# echo 118 > /sys/class/gpio/unexport
标签:style color os io strong ar cti sp line
原文地址:http://www.cnblogs.com/zym0805/p/3944127.html