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#

相关推荐
&岁月不待人&18 分钟前
Kotlin by lazy和lateinit的使用及区别
android·开发语言·kotlin
StayInLove21 分钟前
G1垃圾回收器日志详解
java·开发语言
TeYiToKu23 分钟前
笔记整理—linux驱动开发部分(9)framebuffer驱动框架
linux·c语言·arm开发·驱动开发·笔记·嵌入式硬件·arm
无尽的大道29 分钟前
Java字符串深度解析:String的实现、常量池与性能优化
java·开发语言·性能优化
互联网打工人no130 分钟前
每日一题——第一百二十四题
c语言
爱吃生蚝的于勒33 分钟前
深入学习指针(5)!!!!!!!!!!!!!!!
c语言·开发语言·数据结构·学习·计算机网络·算法
羊小猪~~36 分钟前
数据结构C语言描述2(图文结合)--有头单链表,无头单链表(两种方法),链表反转、有序链表构建、排序等操作,考研可看
c语言·数据结构·c++·考研·算法·链表·visual studio
binishuaio42 分钟前
Java 第11天 (git版本控制器基础用法)
java·开发语言·git
zz.YE44 分钟前
【Java SE】StringBuffer
java·开发语言
就是有点傻1 小时前
WPF中的依赖属性
开发语言·wpf