主题:LP5815 中讨论的其他器件
工具/软件:
您好、
目前、我正在 Linux 环境中将 LP5815 LED 控制器驱动器与基于 AM62Lx 的定制电路板集成在一起。 我参考了[TIThread ]上提供的驱动程序文档。 我遵循了驱动程序随附的参考 DTS(器件树源代码)文件、需要在 LP5815 器件的 I2C 节点上添加 SCL 引脚配置。
器件的 DTS 节点: 
在驱动器代码中、请求了 GPIO 引脚来控制 LED 输出。 我已经修改了 DTS 绑定、以匹配我们电路板的 pinmux 和 GPIO 分配。 我在探测函数中添加了一些打印件。 我在此处共享它以进行调试:
static int lp5815_probe(struct i2c_client *client)
{
struct lp5815_chip *chip;
int ret;
printk("Hello from lp5815 kernel module!\n");
chip = devm_kzalloc(&client->dev, sizeof(struct lp5815_chip),
GFP_KERNEL);
if (!chip) {
return -ENOMEM;
}
mutex_init(&chip->lock);
chip->i2c_cl = client;
chip->dev = &client->dev;
chip->regs = ®s;
chip->command = NONE;
chip->total_leds = MAX_LEDS;
chip->attr_group.name = "lp5815_chip_setup";
chip->attr_group.attrs = lp5815_chip_attributes;
i2c_set_clientdata(client, chip);
printk("lp5815: Kernel default values are written\n");
ret = sysfs_create_group(&chip->dev->kobj, &chip->attr_group);
if (ret) {
printk("lp5815 --> [DEBUG]: sysfs_create_group failed\n");
pr_info("[DEBUG]: sysfs_create_group failed\n");
return ret;
}
printk("lp5815 --> [DEBUG]: sysfs_create_group Done\n");
ret = lp5815_led_init(chip);
if (ret) {
return ret;
}
/* Request 2 more gpio pins for scl sda */
ret = of_property_read_u32(client->dev.of_node, "scl-pin",
&chip->scl_pin);
if (ret) {
printk("lp5815 --> [DEBUG]: Failed to read scl-pin from device tree\n");
pr_info("[DEBUG]: Failed to read scl-pin from device tree\n");
return ret;
}
printk("lp5815: [DEBUG]: Successfully read scl-pin from device tree\n");
ret = devm_gpio_request_one(&client->dev, chip->scl_pin,
GPIOF_IN, "scl-pin");
if (ret) {
printk("lp5815: [DEBUG]: Failed to request SCL GPIO: %d\n", ret);
pr_err("[DEBUG]: Failed to request SCL GPIO: %d\n", ret);
return ret;
}
printk("lp5815: [DEBUG]: Successfully to request SCL GPIO: %d\n", ret);
ret = of_property_read_u32(client->dev.of_node, "sda-pin",
&chip->sda_pin);
if (ret) {
printk("lp5815: [DEBUG]: Failed to read sda_pin from device tree\n");
pr_info("[DEBUG]: Failed to read sda_pin from device tree\n");
return ret;
}
printk("lp5815: [DEBUG]: Successfully to read sda_pin from device tree\n");
ret = devm_gpio_request_one(&client->dev, chip->sda_pin,
GPIOF_IN, "sda-pin");
if (ret) {
printk("lp5815 --> [DEBUG]: Failed to request SDA GPIO: %d\n", ret);
pr_err("[DEBUG]: Failed to request SDA GPIO: %d\n", ret);
return ret;
}
printk("lp5815 --> [DEBUG]: Successfully to request SDA GPIO: %d\n", ret);
/* disable charging and enable device as default */
lp5815_write(chip, CHIP_EN_REG, 0x03);
return 0;
}根据 GPIO 引脚更新了 dts:
ledController: lp5815@2D {
compatible = "ti,lp5815";
reg = <0x2D>;
scl-pin = <&main_gpio0 98 GPIO_ACTIVE_HIGH>;
sda-pin = <&main_gpio0 99 GPIO_ACTIVE_HIGH>;
// scl-pin = <22>; //corresponding pin 26 in rk3568 board
// sda-pin = <16>; //corresponding pin 25 in rk3568 board
};
但是、在启动期间、LP5815 驱动程序无法进行探测。 内核日志显示一条错误消息、指示尝试请求 GPIO 时“Canto access GPIO“。 相关的 dmesg 输出如下所示: 
此致、
参数