目录
1、理解GPIO的开漏(OD)和开集(OC)
2、查询io寄存器地址及定义
3、配置可调寄存器接口dev/mem
author | daisy.skye的博客_CSDN博客-嵌入式,Qt,Linux领域博主 daisy.skye_嵌入式,Linux,Qt-CSDN博客daisy.skye擅长嵌入式,Linux,Qt,等方面的知识https://blog.csdn.net/qq_40715266?type=blog |
1、理解GPIO的开漏(OD)和开集(OC)
参考链接:GPIO口有关上拉电阻和下拉电阻&推挽输出&开漏(OD)和开集(OC)
实测中遇到的是i2c问题,但是uart或者电平转换芯片都会遇到,首先保证外部是否有1k电阻的上拉,当然具体的电阻可以自行进行调节,其次需要满足开漏模式的输出(OD)。
2、查询io寄存器地址及定义
根据原理图的地址,查询rk3568的手册得到gpio的OD配置及地址,
主要是为了后续能够进行io操作指令对具体gpio的寄存器值进行改写测试,
31:16位电平要求与15:0一致才能写使能生效
GRF_GPIO4B_OPD
Address: Operational Base + offset (0x0134)
根据当前参数的章节找到隶属于3.7SYS_GRF 后就找到了基地址
3.7 SYS_GRF Register Description
3.7.1 Registers Summary
基地址SYS_GRF 0xFDC60000
0xFDC60000 + 0x0134 = 0xFDC60134
3、配置可调寄存器接口dev/mem
makefile | kernel/drivers/char/Makefile obj-$(CONFIG_DEVMEM) += mem.o |
config | kernel/arch/arm64/configs/rockchip_defconfig CONFIG_DEVMEM=y CONFIG_STRICT_DEVMEM=n CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=n |
mem.c 驱动 | drivers/char/mem.c // #ifdef CONFIG_DEVMEM // [1] = { "mem", 0, &mem_fops, FMODE_UNSIGNED_OFFSET }, // #endif |
单独编译boot.img |
$ cd u-boot $ ./make.sh rk3568
$ cd .. $ cd kernel $ make ARCH=arm64 rockchip_evb3568_v2b_defconfig $ ./mk_kernel.sh ido-evb3568-v2b-dsi0-mipi.img |
1|rk3568_r:/ # ls -l /dev/mem
crw------- 1 media media 1, 1 2023-12-01 21:13 /dev/mem
1|rk3568_r:/ # io
Raw memory i/o utility - $Revision: 1.5 $io -v -1|2|4 -r|w [-l <len>] [-f <file>] <addr> [<value>] -v Verbose, asks for confirmation
-1|2|4 Sets memory access size in bytes (default byte)
-l <len> Length in bytes of area to access (defaults to
one access, or whole file length)
-r|w Read from or Write to memory (default read)
-f <file> File to write on memory read, or
to read on memory write<addr> The memory address to access<val> The value to write (implies -w)Examples:
io 0x1000 Reads one byte from 0x1000
io 0x1000 0x12 Writes 0x12 to location 0x1000
io -2 -l 8 0x1000 Reads 8 words from 0x1000
io -r -f dmp -l 100 200 Reads 100 bytes from addr 200 to file
io -w -f img 0x10000 Writes the whole of file to memoryNote access size (-1|2|4) does not apply to file based accesses.1|rk3568_r:/ # io -4 -l 0x30 0xFDC60000
open /dev/mem: No such file or directory
rk3568_r:/ # io -4 -w 0xFDC60134 0x040004
rk3568_r:/ # io -4 -r 0xFDC60134#0x040004