一,硬件IO复用配置
配置复用
GPIO3 :FF790~ FF788;
GPIO3_B7: GPIO
io -4 -r 0xff79e014
GPIO3 FF79e054
iomux
FF79e014RK3399的iO控制
echo 227 > /sys/class/gpio/export
GPIO7A3: 7X32 +3 = 227
gpio0B5 : 0X32+13 = 13gpio3_B7: 3X32 + 15 = 111
echo 111 > /sys/class/gpio/export
配置GRF
io -4 -r 0xff78800
[root@rk3399:/]# io -4 -r 0xff788000
ff788000: 00008000
[root@rk3399:/]#
GRF基地址为:FF77_0000
GRF_GPIO3B_IOMUX 0x0e014
io 0xff77e015 > 0x15
cat /sys/kernel/debug/gpio
GPIO控制
测试GPIO2_B2
写入GPIO2_B2位低电平
io -4 -w 0xff780000 0x7f0
红灯亮,设置生效
测试GPIO2_B3
写入GPIO2_B3为输出
io -4 -w 0xff780004 0x80ff1
GPIO2_B3输出为低
io -4 -w 0xff780000 0xff0
发现不生效,查询IOMUX寄存器
io -4 -r 0xff77e004
返回
0x00c0
查询寄存器文档可知bit7:6为11, gpio2_b3没有设为gpio
设置iomux为gpio
io -4 -w 0xff7e004 0x0000
设置无效,可能是被驱动限制了
测试GPIO2_B1
bit位为(B-A)*8 + 1 = 9
由前面可知,DDR应该已经是输出
直接设置DR
io -4 -w 0xff780000 0x5f0二,另外一种用GPIO Debug接口控制的方法
以GPIO2_B2为例
查看GPIO2_B2的gpio numberrk3399:/sys/kernel/debug # cat gpio
GPIOs 0-31, platform/pinctrl, gpio0:
gpio-1 ( |vcc_sd ) out lo
gpio-4 ( |bt_default_wake_host) in lo
gpio-5 ( |power ) in hi
gpio-9 ( |bt_default_reset ) out lo
gpio-10 ( |reset ) out hiGPIOs 32-63, platform/pinctrl, gpio1:
gpio-34 ( |int-n ) in hi
gpio-35 ( |camsys_gpio ) out hi
gpio-45 ( |enable ) out hi
gpio-46 ( |vsel ) out lo
gpio-49 ( |vsel ) out lo
gpio-54 ( |mpu6500 ) in loGPIOs 64-95, platform/pinctrl, gpio2:
gpio-64 ( |vbus-5v ) out lo
gpio-69 ( |power33 ) out hi
gpio-70 ( |power ) out hi
gpio-71 ( |reset ) out hi
gpio-72 ( |stanby ) out hi
gpio-73 ( |power18 ) out hi
gpio-74 ( |sysfs ) out lo
gpio-76 ( |int ) in hi
gpio-83 ( |bt_default_rts ) in hi
gpio-90 ( |bt_default_wake ) in lo
可知GPIO2_B2的number 为GPIO74
32*2 + 8+2rk3399:/sys/class/gpio # echo 74 > export
1|rk3399:/sys/class/gpio # ls
export gpiochip0 gpiochip32 gpiochip96
gpio74 gpiochip128 gpiochip64 unexport
rk3399:/sys/class/gpio #rk3399:/sys/class/gpio/gpio74 # ls
active_low device direction edge power subsystem uevent value
rk3399:/sys/class/gpio/gpio74 # echo 1 > value
rk3399:/sys/class/gpio/gpio74 # echo 0 > value
rk3399:/sys/class/gpio/gpio74 #免责声明:文章内容来自互联网,本站不对其真实性负责,也不承担任何法律责任,如有侵权等情况,请与本站联系删除。
转载请注明出处:RK平台,RK3399,RK3288,IO控制。 https://www.yhzz.com.cn/a/17483.html