LS1028 GPIO初始化为高电平
1. 修改RCW
以将GPIO3_DAT14初始化为高电平为例,默认是将用作SPI3_SCK,需要将其先复用为GPIO
修改RCW:firmware/rcw/ls1028ardb/R_SQPP_0x85bb/rcw_1500_gpu600.rcw
SPI3_PMUX=1
2. uboot初始化
在uboot源码中进行初始化
修改位置:packages/firmware/OK1028-linux-uboot/board/freescale/ls1028a/ls1028a.c
定义一个常量
给其赋值,含义:将GPIO3_DAT14设置为输出,值设置为1(高电平)
单独编译firmware固件烧写,一上电用万用表进行测量,可以看到该引脚为高电平(1.8V)
其他
将GPIO3_DAT14进行初始化为高电平,一共32位将第十四位置为1
添加gpio按键
1.复用GPIO
首先要找到按键使用的GPIO,然后再设备树里面进行设备节点的注册这里以GPIO3_13、GPIO3_16为例,板子上默认是将其用作SPI_SIN、SPI_SOUT。
2.修改RCW
RCW路径:firmware/rcw/ls1028ardb/R_SQPP_0x85bb/rcw_1500_gpu600.rcw
--- a/packages/firmware/rcw/ls1028ardb/R_SQPP_0x85bb/rcw_1500_gpu600.rcw
+++ b/packages/firmware/rcw/ls1028ardb/R_SQPP_0x85bb/rcw_1500_gpu600.rcw
@@ -28,7 +28,7 @@ IIC3_PMUX=2
IIC4_PMUX=2
IIC5_PMUX=1
IIC6_PMUX=0
-SPI3_PMUX=0
+SPI3_PMUX=1
CLK_OUT_PMUX=2
EC1_SAI4_5_PMUX=2
EC1_SAI3_6_PMUX=1
3.修改设备树
设备树路径:OK1028-linux-fs/packages/linux/linux/arch/arm64/boot/dts/freescale/OK1028A-C.dts
修改设备树
--- a/packages/linux/OK1028-linux-kernel/arch/arm64/boot/dts/freescale/OK1028A-C.dts
+++ b/packages/linux/OK1028-linux-kernel/arch/arm64/boot/dts/freescale/OK1028A-C.dts
@@ -131,7 +131,23 @@
default-brightness-level = <200>;
status = "okay";
};
-
+
+ gpio-keys {
+ compatible = "gpio-keys";
+ autorepeat;
+
+ down {
+ label = "GPIO Key DOWN";
+ linux,code = <108>;
+ gpios = <&gpio3 13 0>;
+ };
+ /*up{
+ label = "GPIO Key UP";
+ linux,code = <103>;
+ gpios = <&gpio3 16 1>;
+ };*/
+
+ };
};
4.验证
修改完成后全编译生成镜像,烧写完成后,进行验证
root@forlinx:~# cat /sys/kernel/debug/gpio
gpiochip2: GPIOs 416-447, parent: platform/2320000.gpio, 2320000.gpio:
gpio-429 ( |GPIO Key DOWN ) in hi ACTIVE LOW
gpiochip1: GPIOs 448-479, parent: platform/2310000.gpio, 2310000.gpio:
gpio-454 ( |? ) out lo
gpiochip0: GPIOs 480-511, parent: platform/2300000.gpio, 2300000.gpio:
其他
关于gpio-keys设备节点的注册可以参考:OK1028-linux-fs/packages/linux/linux/Documentation/devicetree/bindings/input/gpio-keys.txt
参数说明
ompatible = "gpio-keys" <-------------------------匹配驱动
Label = "GPIO Key UP"; <-------------------------按键标签
linux,code = <103>; <-------------------------键值
gpios = <&gpio3 13 0>; <-------------------------使用gpio3_13,低电平有效
按键驱动路径:OK1028-linux-kernel/drivers/input/keyboard/gpio_keys.c
按键键值定义:OK1028-linux-kernel/include/uapi/linux/input-event-codes.h