ctrl rk3288 GPIO
使用shell 控制平板GPIO。
1. 查看GPIO number,列出如下 信息: # cat /sys/kernel/debug/gpio 。
GPIOs 0-23, platform/pinctrl, gpio0:
gpio-0 ( |vsel ) out lo
gpio-5 ( |GPIO Key Power ) in hi
gpio-8 ( |rk818_dc_det ) in hi
gpio-12 ( |otg_drv_gpio ) out lo
gpio-14 ( |vcc_host ) out hi
gpio-17 ( |vcc18_dvp ) out lo
GPIOs 24-55, platform/pinctrl, gpio1:
GPIOs 56-87, platform/pinctrl, gpio2:
gpio-71 ( |pwdn ) out lo
GPIOs 88-119, platform/pinctrl, gpio3:
GPIOs 120-151, platform/pinctrl, gpio4:
gpio-139 ( |bt_default_rts ) out hi
gpio-146 ( |bt_default_wake ) out hi
gpio-148 ( |reset ) out hi
gpio-149 ( |bt_default_reset ) out hi
gpio-151 ( |bt_default_wake_host) in hi
GPIOs 152-183, platform/pinctrl, gpio5:
GPIOs 184-215, platform/pinctrl, gpio6:
GPIOs 216-247, platform/pinctrl, gpio7:
gpio-217 ( |enable ) out hi
gpio-218 ( |enable ) out hi
gpio-219 ( |vcc_lcd ) out hi
gpio-220 ( |reset ) out hi
gpio-221 ( |GTP_RST_PORT ) in hi
gpio-222 ( |GTP_INT_IRQ ) in hi
gpio-223 ( |hp det ) in lo
gpio-224 ( |host_drv_gpio ) out hi
gpio-231 ( |? ) out lo
GPIOs 248-263, platform/pinctrl, gpio8:
2. 可以看到gpio8是以nubmer为248开始, 结合PIN列表 那么GPIO8_A4就是 248 + 4 = 252。
PIN={
'A0': 0, 'A1': 1, 'A2': 2, 'A3': 3, 'A4': 4, 'A5': 5, 'A6': 6, 'A7': 7,
'B0': 8, 'B1': 9, 'B2':10, 'B3':11, 'B4':12, 'B5':13, 'B6':14, 'B7':15,
'C0':16, 'C1':17, 'C2':18, 'C3':19, 'C4':20, 'C5':21, 'C6':22, 'C7':23,
'D0':24, 'D1':25, 'D2':26, 'D3':27, 'D4':28, 'D5':29, 'D6':30, 'D7':31,
}
3.示例 GPIO8_A4 设为输出。
# echo 252 > /sys/class/gpio/export //打开GPIO8_A4
# echo out > /sys/class/gpio/gpio252/direction //将GPIO8_A4 修改为输出
# echo 1 >/sys/class/gpio/gpio252/value //GPIO8_A4 设为高电平
# echo 0 >/sys/class/gpio/gpio252/value //GPIO8_A4 设为低电平
4.示例 GPIO8_A4 设为输入。
# echo 252 > /sys/class/gpio/export //打开GPIO8_A4
# echo in > /sys/class/gpio/gpio252/direction //将GPIO8_A4 修改为输入
# cat /sys/class/gpio/gpio252/value // 获取 GPIO8_A4 的值