20240629在飞凌开发板OK3588-C上使用Rockchip原厂的SDK跑通I2C扩展GPIO芯片TCA6424ARGJRR

20240629在飞凌开发板OK3588-C上使用Rockchip原厂的SDK跑通I2C扩展GPIO芯片TCA6424ARGJRR

2024/6/29 18:02

1、替换DTS了:

Z:\repo_RK3588_Buildroot20240508\kernel\arch\arm64\boot\dts\rockchip

viewpro@viewpro-ThinkBook-16-G5-IRH:~/repo_RK3588_Buildroot20240508/kernel/arch/arm64/boot/dts/rockchip$ ll

total 1244

drwx------ 2 viewpro viewpro 4096 6月 29 18:12 ./

drwxrwxr-x 34 viewpro viewpro 4096 6月 29 17:15 ../
-rw-rw-r-- 1 viewpro viewpro 3917 12月 21 2023 FET3588-C.dtsi
-rw-rw-r-- 1 viewpro viewpro 7758 12月 21 2023 Makefile
-rw-rw-r-- 1 viewpro viewpro 14850 12月 21 2023 OK3588-C-Camera.dtsi
-rw-rw-r-- 1 viewpro viewpro 32947 12月 21 2023 OK3588-C-common.dtsi
-rw-rw-r-- 1 viewpro viewpro 2363 12月 21 2023 OK3588-C-Linux.dts
-rw-rw-r-- 1 viewpro viewpro 246717 5月 24 17:56 OK3588-C-Linux.dump.dts
-rw-rw-r-- 1 viewpro viewpro 27858 12月 21 2023 rk3588.dtsi
-rw-rw-r-- 1 viewpro viewpro 280681 6月 29 18:12 rk3588-evb7-v11-linux.dtb
-rw-rw-r-- 1 viewpro viewpro 3061 6月 29 18:12 .rk3588-evb7-v11-linux.dtb.cmd
-rw-rw-r-- 1 viewpro viewpro 120 6月 29 18:12 .rk3588-evb7-v11-linux.dtb.d.dtc.tmp
-rw-rw-r-- 1 viewpro viewpro 1693 6月 29 18:12 .rk3588-evb7-v11-linux.dtb.d.pre.tmp
-rw-rw-r-- 1 viewpro viewpro 326518 6月 29 18:12 .rk3588-evb7-v11-linux.dtb.dts.tmp
-rwx------ 1 viewpro viewpro 2363 6月 21 11:40 rk3588-evb7-v11-linux.dts*
-rw-rw-r-- 1 viewpro viewpro 9573 12月 21 2023 rk3588-rk806-single.dtsi
-rw-rw-r-- 1 viewpro viewpro 185703 12月 21 2023 rk3588s.dtsi
-rw-rw-r-- 1 viewpro viewpro 67505 12月 21 2023 rk3588s-pinctrl.dtsi
-rw-rw-r-- 1 viewpro viewpro 9865 12月 21 2023 rk3588-vccio3-pinctrl.dtsi
-rw-rw-r-- 1 viewpro viewpro 7448 12月 21 2023 rockchip-pinconf.dtsi

viewpro@viewpro-ThinkBook-16-G5-IRH:~/repo_RK3588_Buildroot20240508/kernel/arch/arm64/boot/dts/rockchip$

确认驱动没有加载好:没有找到gpiochip485!

root@rk3588-buildroot:/#

root@rk3588-buildroot:/#

root@rk3588-buildroot:/#

Display all 910 possibilities? (y or n)^C

root@rk3588-buildroot:/#

root@rk3588-buildroot:/# cd /sys/class/gpio/

root@rk3588-buildroot:/sys/class/gpio#

root@rk3588-buildroot:/sys/class/gpio# ls -l

total 0

--w------- 1 root root 4096 Jan 1 00:00 export

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip0 -> ../../devices/platform/pinctrl/fd8a0000.gpio/gpio/gpiochip0

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip128 -> ../../devices/platform/pinctrl/fec50000.gpio/gpio/gpiochip128

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip32 -> ../../devices/platform/pinctrl/fec20000.gpio/gpio/gpiochip32
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip509 -> ../../devices/platform/feb20000.spi/spi_master/spi2/spi2.0/rk806-pinctrl.0.auto/gpio/gpiochip509

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip64 -> ../../devices/platform/pinctrl/fec30000.gpio/gpio/gpiochip64

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip96 -> ../../devices/platform/pinctrl/fec40000.gpio/gpio/gpiochip96

--w------- 1 root root 4096 Jan 1 00:00 unexport

root@rk3588-buildroot:/sys/class/gpio#
root@rk3588-buildroot:/sys/class/gpio#
root@rk3588-buildroot:/sys/class/gpio# echo 508 > export
[ 297.960946] export_store: invalid GPIO 508
sh: echo: write error: Invalid argument
root@rk3588-buildroot:/sys/class/gpio#

root@rk3588-buildroot:/sys/class/gpio#

Z:\repo_RK3588_Buildroot20240508\kernel\include\dt-bindings\pinctrl\rockchip.h

/* SPDX-License-Identifier: GPL-2.0-or-later */

/*

* Header providing constants for Rockchip pinctrl bindings.

*

* Copyright (c) 2013 MundoReader S.L.

* Author: Heiko Stuebner <heiko@sntech.de>

*/

#ifndef DT_BINDINGS_ROCKCHIP_PINCTRL_H

#define DT_BINDINGS_ROCKCHIP_PINCTRL_H

#define RK_PA0 0

#define RK_PA1 1

#define RK_PA2 2

#define RK_PA3 3

#define RK_PA4 4

#define RK_PA5 5

#define RK_PA6 6

#define RK_PA7 7

#define RK_PB0 8

#define RK_PB1 9

#define RK_PB2 10

#define RK_PB3 11

#define RK_PB4 12

#define RK_PB5 13

#define RK_PB6 14

#define RK_PB7 15

#define RK_PC0 16

#define RK_PC1 17

#define RK_PC2 18

#define RK_PC3 19

#define RK_PC4 20

#define RK_PC5 21

#define RK_PC6 22

#define RK_PC7 23

#define RK_PD0 24

#define RK_PD1 25

#define RK_PD2 26

#define RK_PD3 27

#define RK_PD4 28

#define RK_PD5 29

#define RK_PD6 30

#define RK_PD7 31

#define RK_FUNC_GPIO 0

#define EXTIO_GPIO_P00 0
#define EXTIO_GPIO_P01 1
#define EXTIO_GPIO_P02 2
#define EXTIO_GPIO_P03 3
#define EXTIO_GPIO_P04 4
#define EXTIO_GPIO_P05 5
#define EXTIO_GPIO_P06 6
#define EXTIO_GPIO_P07 7
#define EXTIO_GPIO_P10 8
#define EXTIO_GPIO_P11 9
#define EXTIO_GPIO_P12 10
#define EXTIO_GPIO_P13 11
#define EXTIO_GPIO_P14 12
#define EXTIO_GPIO_P15 13
#define EXTIO_GPIO_P16 14
#define EXTIO_GPIO_P17 15
#define EXTIO_GPIO_P20 16
#define EXTIO_GPIO_P21 17
#define EXTIO_GPIO_P22 18
#define EXTIO_GPIO_P23 19
#define EXTIO_GPIO_P24 20
#define EXTIO_GPIO_P25 21
#define EXTIO_GPIO_P26 22
#define EXTIO_GPIO_P27 23

#endif

2、更新驱动的部分:

Z:\repo_RK3588_Buildroot20240508\kernel\.config

I2C GPIO expanders

CONFIG_GPIO_ADP5588 is not set

CONFIG_GPIO_ADNP is not set

CONFIG_GPIO_AW9110 is not set

CONFIG_GPIO_GW_PLD is not set

CONFIG_GPIO_MAX7300 is not set

CONFIG_GPIO_MAX732X is not set

CONFIG_GPIO_NCA9539 is not set

CONFIG_GPIO_PCA953X=y

CONFIG_GPIO_PCA953X_IRQ is not set

CONFIG_GPIO_PCA9570 is not set

CONFIG_GPIO_PCF857X is not set

CONFIG_GPIO_TPIC2810 is not set

end of I2C GPIO expanders

CONFIG_GPIO_ROCKCHIP=y

CONFIG_GPIO_SAMA5D2_PIOBU is not set

CONFIG_GPIO_SIFIVE is not set

CONFIG_GPIO_SYSCON=y

CONFIG_GPIO_XGENE is not set

CONFIG_GPIO_XILINX is not set

CONFIG_GPIO_AMD_FCH is not set

end of Memory mapped GPIO drivers

I2C GPIO expanders

CONFIG_GPIO_ADP5588 is not set

CONFIG_GPIO_ADNP is not set

CONFIG_GPIO_AW9110 is not set

CONFIG_GPIO_GW_PLD is not set

CONFIG_GPIO_MAX7300 is not set

CONFIG_GPIO_MAX732X is not set

CONFIG_GPIO_NCA9539 is not set

CONFIG_GPIO_PCA953X is not set

CONFIG_GPIO_PCA9570 is not set

CONFIG_GPIO_PCF857X is not set

CONFIG_GPIO_TPIC2810 is not set

end of I2C GPIO expanders

MFD GPIO expanders

CONFIG_GPIO_TPS6586X is not set

end of MFD GPIO expanders

【相关的驱动部分:】

viewpro@viewpro-ThinkBook-16-G5-IRH:~/repo_RK3588_Buildroot20240508/kernel/arch/arm64/configs$ grep CONFIG_GPIO_SYSCON . -R

./rockchip_defconfig:CONFIG_GPIO_SYSCON=y

./rockchip_linux_defconfig:CONFIG_GPIO_SYSCON=y

viewpro@viewpro-ThinkBook-16-G5-IRH:~/repo_RK3588_Buildroot20240508/kernel/arch/arm64/configs$

Z:\repo_RK3588_Buildroot20240508\kernel\arch\arm64\configs\rk3588_linux.config

CONFIG_BCMDHD_SDIO=y is not set

CONFIG_BCMDHD_PCIE=y
CONFIG_MALI_CSF_SUPPORT=y
CONFIG_GPIO_PCA953X=y

Z:\repo_RK3588_Buildroot20240508\kernel\drivers\gpio\gpio-pca953x.c

【这里不要动了,强制修改的!】

Z:\repo_RK3588_Buildroot20240508\kernel\drivers\gpio\Makefile

obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o

obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o

obj-$(CONFIG_GPIO_NCA9539) += gpio-nca9539.o

obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o

obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o

obj-(CONFIG_GPIO_PALMAS) += gpio-palmas.o #obj-(CONFIG_GPIO_PCA953X) += gpio-pca953x.o
obj-y += gpio-pca953x.o

obj-$(CONFIG_GPIO_PCA9570) += gpio-pca9570.o

obj-$(CONFIG_GPIO_PCF857X) += gpio-pcf857x.o

obj-$(CONFIG_GPIO_PCH) += gpio-pch.o

确认的LOG:

高:3.299V

低:0.001V

root@rk3588-buildroot:/#

root@rk3588-buildroot:/#

root@rk3588-buildroot:/#

root@rk3588-buildroot:/# cd /sys/class/gpio/

root@rk3588-buildroot:/sys/class/gpio# ls -l

total 0

--w------- 1 root root 4096 Jan 1 00:00 export

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip0 -> ../../devices/platform/pinctrl/fd8a0000.gpio/gpio/gpiochip0

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip128 -> ../../devices/platform/pinctrl/fec50000.gpio/gpio/gpiochip128

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip32 -> ../../devices/platform/pinctrl/fec20000.gpio/gpio/gpiochip32

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip485 -> ../../devices/platform/feaa0000.i2c/i2c-2/2-0023/gpio/gpiochip485

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip509 -> ../../devices/platform/feb20000.spi/spi_master/spi2/spi2.0/rk806-pinctrl.0.auto/gpio/gpiochip509

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip64 -> ../../devices/platform/pinctrl/fec30000.gpio/gpio/gpiochip64

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip96 -> ../../devices/platform/pinctrl/fec40000.gpio/gpio/gpiochip96

--w------- 1 root root 4096 Jan 1 00:00 unexport

root@rk3588-buildroot:/sys/class/gpio#

root@rk3588-buildroot:/sys/class/gpio# echo 508 > export

root@rk3588-buildroot:/sys/class/gpio#

root@rk3588-buildroot:/sys/class/gpio# ls -l

total 0

--w------- 1 root root 4096 Jan 1 00:01 export

lrwxrwxrwx 1 root root 0 Jan 1 00:01 gpio508 -> ../../devices/platform/feaa0000.i2c/i2c-2/2-0023/gpiochip6/gpio/gpio508

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip0 -> ../../devices/platform/pinctrl/fd8a0000.gpio/gpio/gpiochip0

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip128 -> ../../devices/platform/pinctrl/fec50000.gpio/gpio/gpiochip128

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip32 -> ../../devices/platform/pinctrl/fec20000.gpio/gpio/gpiochip32
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip485 -> ../../devices/platform/feaa0000.i2c/i2c-2/2-0023/gpio/gpiochip485
lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip509 -> ../../devices/platform/feb20000.spi/spi_master/spi2/spi2.0/rk806-pinctrl.0.auto/gpio/gpiochip509

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip64 -> ../../devices/platform/pinctrl/fec30000.gpio/gpio/gpiochip64

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip96 -> ../../devices/platform/pinctrl/fec40000.gpio/gpio/gpiochip96

--w------- 1 root root 4096 Jan 1 00:00 unexport

root@rk3588-buildroot:/sys/class/gpio#

root@rk3588-buildroot:/sys/class/gpio# cd gpio508

root@rk3588-buildroot:/sys/class/gpio/gpio508#

root@rk3588-buildroot:/sys/class/gpio/gpio508# ls -l

total 0

-rw-r--r-- 1 root root 4096 Jan 1 00:01 active_low

lrwxrwxrwx 1 root root 0 Jan 1 00:01 device -> ../../../gpiochip6

-rw-r--r-- 1 root root 4096 Jan 1 00:01 direction

drwxr-xr-x 2 root root 0 Jan 1 00:01 power

lrwxrwxrwx 1 root root 0 Jan 1 00:01 subsystem -> ../../../../../../../../class/gpio

-rw-r--r-- 1 root root 4096 Jan 1 00:01 uevent

-rw-r--r-- 1 root root 4096 Jan 1 00:01 value

root@rk3588-buildroot:/sys/class/gpio/gpio508#

root@rk3588-buildroot:/sys/class/gpio/gpio508# cat direction

in

root@rk3588-buildroot:/sys/class/gpio/gpio508# cat value

0

root@rk3588-buildroot:/sys/class/gpio/gpio508#

root@rk3588-buildroot:/sys/class/gpio/gpio508# echo out > direction

root@rk3588-buildroot:/sys/class/gpio/gpio508# echo 1 > value

root@rk3588-buildroot:/sys/class/gpio/gpio508#

root@rk3588-buildroot:/sys/class/gpio/gpio508# cat direction

out

root@rk3588-buildroot:/sys/class/gpio/gpio508# cat value

1

root@rk3588-buildroot:/sys/class/gpio/gpio508# ^C

root@rk3588-buildroot:/sys/class/gpio/gpio508#

root@rk3588-buildroot:/sys/class/gpio/gpio508#

root@rk3588-buildroot:/sys/class/gpio/gpio508# cd ..

root@rk3588-buildroot:/sys/class/gpio#

root@rk3588-buildroot:/sys/class/gpio#

root@rk3588-buildroot:/sys/class/gpio# ls -l

total 0

--w------- 1 root root 4096 Jan 1 00:01 export

lrwxrwxrwx 1 root root 0 Jan 1 00:01 gpio508 -> ../../devices/platform/feaa0000.i2c/i2c-2/2-0023/gpiochip6/gpio/gpio508

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip0 -> ../../devices/platform/pinctrl/fd8a0000.gpio/gpio/gpiochip0

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip128 -> ../../devices/platform/pinctrl/fec50000.gpio/gpio/gpiochip128

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip32 -> ../../devices/platform/pinctrl/fec20000.gpio/gpio/gpiochip32

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip485 -> ../../devices/platform/feaa0000.i2c/i2c-2/2-0023/gpio/gpiochip485

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip509 -> ../../devices/platform/feb20000.spi/spi_master/spi2/spi2.0/rk806-pinctrl.0.auto/gpio/gpiochip509

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip64 -> ../../devices/platform/pinctrl/fec30000.gpio/gpio/gpiochip64

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip96 -> ../../devices/platform/pinctrl/fec40000.gpio/gpio/gpiochip96

--w------- 1 root root 4096 Jan 1 00:00 unexport

root@rk3588-buildroot:/sys/class/gpio#

root@rk3588-buildroot:/sys/class/gpio#

root@rk3588-buildroot:/sys/class/gpio# echo 507 > export

root@rk3588-buildroot:/sys/class/gpio# ls -l

total 0

--w------- 1 root root 4096 Jan 1 00:09 export

lrwxrwxrwx 1 root root 0 Jan 1 00:09 gpio507 -> ../../devices/platform/feaa0000.i2c/i2c-2/2-0023/gpiochip6/gpio/gpio507

lrwxrwxrwx 1 root root 0 Jan 1 00:01 gpio508 -> ../../devices/platform/feaa0000.i2c/i2c-2/2-0023/gpiochip6/gpio/gpio508

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip0 -> ../../devices/platform/pinctrl/fd8a0000.gpio/gpio/gpiochip0

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip128 -> ../../devices/platform/pinctrl/fec50000.gpio/gpio/gpiochip128

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip32 -> ../../devices/platform/pinctrl/fec20000.gpio/gpio/gpiochip32

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip485 -> ../../devices/platform/feaa0000.i2c/i2c-2/2-0023/gpio/gpiochip485

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip509 -> ../../devices/platform/feb20000.spi/spi_master/spi2/spi2.0/rk806-pinctrl.0.auto/gpio/gpiochip509

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip64 -> ../../devices/platform/pinctrl/fec30000.gpio/gpio/gpiochip64

lrwxrwxrwx 1 root root 0 Jan 1 00:00 gpiochip96 -> ../../devices/platform/pinctrl/fec40000.gpio/gpio/gpiochip96

--w------- 1 root root 4096 Jan 1 00:00 unexport

root@rk3588-buildroot:/sys/class/gpio# cd gpio507/

root@rk3588-buildroot:/sys/class/gpio/gpio507# ll

sh: ll: command not found

root@rk3588-buildroot:/sys/class/gpio/gpio507# ls -l

total 0

-rw-r--r-- 1 root root 4096 Jan 1 00:09 active_low

lrwxrwxrwx 1 root root 0 Jan 1 00:09 device -> ../../../gpiochip6

-rw-r--r-- 1 root root 4096 Jan 1 00:09 direction

drwxr-xr-x 2 root root 0 Jan 1 00:09 power

lrwxrwxrwx 1 root root 0 Jan 1 00:09 subsystem -> ../../../../../../../../class/gpio

-rw-r--r-- 1 root root 4096 Jan 1 00:09 uevent

-rw-r--r-- 1 root root 4096 Jan 1 00:09 value

root@rk3588-buildroot:/sys/class/gpio/gpio507#

root@rk3588-buildroot:/sys/class/gpio/gpio507#

root@rk3588-buildroot:/sys/class/gpio/gpio507# echo out > direction

root@rk3588-buildroot:/sys/class/gpio/gpio507# echo 1 > value

root@rk3588-buildroot:/sys/class/gpio/gpio507# cat direction

out

root@rk3588-buildroot:/sys/class/gpio/gpio507# cat value

1

root@rk3588-buildroot:/sys/class/gpio/gpio507#

root@rk3588-buildroot:/sys/class/gpio/gpio507# echo 0 > value

root@rk3588-buildroot:/sys/class/gpio/gpio507#

相关推荐
qq_433554547 分钟前
C++ 面向对象编程:+号运算符重载,左移运算符重载
开发语言·c++
数据小爬虫@26 分钟前
如何高效利用Python爬虫按关键字搜索苏宁商品
开发语言·爬虫·python
ZJ_.28 分钟前
WPSJS:让 WPS 办公与 JavaScript 完美联动
开发语言·前端·javascript·vscode·ecmascript·wps
Narutolxy33 分钟前
深入探讨 Go 中的高级表单验证与翻译:Gin 与 Validator 的实践之道20241223
开发语言·golang·gin
Hello.Reader41 分钟前
全面解析 Golang Gin 框架
开发语言·golang·gin
禁默1 小时前
深入浅出:AWT的基本组件及其应用
java·开发语言·界面编程
Code哈哈笑1 小时前
【Java 学习】深度剖析Java多态:从向上转型到向下转型,解锁动态绑定的奥秘,让代码更优雅灵活
java·开发语言·学习
程序猿进阶1 小时前
深入解析 Spring WebFlux:原理与应用
java·开发语言·后端·spring·面试·架构·springboot
qq_433618441 小时前
shell 编程(二)
开发语言·bash·shell
charlie1145141911 小时前
C++ STL CookBook
开发语言·c++·stl·c++20