XL9555调试
说明
XL9555是一个i2c接口扩展GPIO的芯片。
适配驱动
内核选项选上 CONFIG_GPIO_PCA953X 即可。
原理图

设备树
RK3588的设备树:
&i2c2{
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&i2c2m4_xfer>;
xl9555_ext_gpio: xl9555-ext-gpio@20{
compatible = "nxp,pca9555";
reg = <0x20>;
pinctrl-names = "default";
pinctrl-0=<&pinctrl_xl9555>;
interrupt-parent = <&gpio1>;
interrupts = <RK_PC4 IRQ_TYPE_LEVEL_LOW>;
gpio-controller;
#gpio-cells =<2>;
status = "okay";
};
};
其他节点调用扩展的GPIO。
vcc3v3_pcie30: vcc3v3-pcie30 {
compatible = "regulator-fixed";
regulator-name = "vcc3v3_pcie30";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
enable-active-high;
gpios = <&xl9555_ext_gpio 7 GPIO_ACTIVE_HIGH>;
startup-delay-us = <5000>;
vin-supply = <&vcc12v_dcin>;
};
设置GPIO默认拉低
修改驱动 drivers/gpio/gpio-pca953x.c :
patch
From 5a9863f30c551546709f0f62bbd352641fb5e12a Mon Sep 17 00:00:00 2001
From: yangx <yangx@qiyangtech.com>
Date: Mon, 21 Apr 2025 22:10:20 +0800
Subject: [PATCH] =?UTF-8?q?QY:=20=E4=BF=AE=E5=A4=8D=E8=AE=BE=E7=BD=AEXL955?=
=?UTF-8?q?5=20IO=E6=89=A9=E5=B1=95=E8=8A=AF=E7=89=87=E7=9A=84=208,9,10,11?=
=?UTF-8?q?,12,13=E8=84=9A=E9=85=8D=E7=BD=AE=E8=BE=93=E5=87=BAout=E6=97=B6?=
=?UTF-8?q?=E8=A6=81=E9=BB=98=E8=AE=A4=E4=B8=BA1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
drivers/gpio/gpio-pca953x.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index c21e858952f4..71ebe277fda0 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -549,10 +549,11 @@ static int pca953x_gpio_direction_output(struct gpio_chip *gc,
/* set output level */
if (chip->client->addr == 0x21 && (off == 8 || off ==9 || off == 10 || off == 11 || off == 12 || off == 13 )) {
// printk("yx ---- got it \n");
- ret = regmap_write_bits(chip->regmap, outreg, bit, 1);
+ ret = regmap_write_bits(chip->regmap, outreg, bit, bit);
} else {
- ret = regmap_write_bits(chip->regmap, outreg, bit, val ? bit : 0);
+ ret = regmap_write_bits(chip->regmap, outreg, bit, val ? bit : 0);
}
+
if (ret)
goto exit;
--
2.25.1
固定扩展GPIO的起始号
因为是两个扩展芯片,会导致加载顺序不确定,起始GPIO号不确定,这样设置下就可以了。
patch:
From: Yangx <1046436450@qq.com>
Date: Fri, 23 May 2025 11:33:36 +0800
Subject: [PATCH] =?UTF-8?q?QY:=20=E5=9B=BA=E5=AE=9A=20=E6=89=A9=E5=B1=95gp?=
=?UTF-8?q?io=20=E7=9A=84gpio=E8=B5=B7=E5=A7=8B=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
drivers/gpio/gpio-pca953x.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 71ebe277fda0..06649b224345 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -1120,7 +1120,15 @@ static int pca953x_probe(struct i2c_client *client)
chip->regulator = reg;
i2c_set_clientdata(client, chip);
-
+ // printk("yx ------- device_pca95xx_init addr:0x%02x\n", chip->client->addr);
+ if (chip->client->addr == 0x20) {
+ chip->gpio_start = 640;
+ printk("ex in io set 640\n");
+ }
+ if (chip->client->addr == 0x21) {
+ chip->gpio_start = 656;
+ printk("ex out io set 656\n");
+ }
pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK);
if (NBANK(chip) > 2 || PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE) {
--
2.25.1
调试驱动
还是根据芯片手册使用i2c工具进行读写寄存器调试。
注意
引脚上电是默认上拉的。
在芯片手册搜索:pull up

本文来自博客园,作者:杨旭0324,转载请注明原文链接:https://www.cnblogs.com/allalonewithyou/p/19131687,个人邮箱:yaonie4444@foxmail.com

浙公网安备 33010602011771号