我想连接 TCA6408 IO 扩展器并将按键输入到我的嵌入式系统。 我正在尝试使用 SABRELite (iMX6Q) Boad,我的开发环境是 LTIB (L3.0.35_4.1.0_130816_source.tar.gz)
我做了以下修改
1.) 在“board-mx6q_sabrelite.c”中添加一个条目
static struct i2c_board_info mxc_i2c2_board_info[] __initdata = {
{
I2C_BOARD_INFO("pca953x", 0x21),
.irq = gpio_to_irq(MX6Q_SABRELITE_CAP_TCH_INT1),
},
};
2.) 从 menuconfig 启用驱动程序
--- GPIO Support
< * > PCA953x, PCA955x, TCA64xx, and MAX7310 I/O ports
[ * ] Interrupt controller support for PCA953x
当我启动系统时,驱动程序注册就可以了。 但是在 Probe() 函数中出现错误(pca953x:2-0020 的探测失败,错误为 -22)。
#控制台日志
Freescale USB OTG Driver loaded, $Revision: 1.55 $
pca953x: probe of 2-0020 failed with error -22
imx-ipuv3 imx-ipuv3.0: IPU DMFC NORMAL mode: 1(0~1), 5B(4,5), 5F(6,7)
imx-ipuv3 imx-ipuv3.1: IPU DMFC NORMAL mode: 1(0~1), 5B(4,5), 5F(6,7)
mxc_mipi_csi2 mxc_mipi_csi2: i.MX MIPI CSI2 driver probed
mxc_mipi_csi2 mxc_mipi_csi2: i.MX MIPI CSI2 dphy version is 0x3130302a
MIPI CSI2 driver module loaded
Advanced Linux Sound Architecture Driver Version 1.0.24.
这个错误是因为 (pdata == NULL)
linux-3.0.35/drivers/gpio/pca953x.c
static int __devinit pca953x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct pca953x_platform_data *pdata;
struct pca953x_chip *chip;
int ret = 0;
chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
if (chip == NULL)
return -ENOMEM;
pdata = client->dev.platform_data;
if (pdata == NULL) {
pdata = pca953x_get_alt_pdata(client);
/*
* Unlike normal platform_data, this is allocated
* dynamically and must be freed in the driver
*/
chip->dyn_pdata = pdata;
}
if (pdata == NULL) {
dev_dbg(&client->dev, "no platform data\n");
ret = -EINVAL;
goto out_failed;
}
我无法理解这个问题。 “platform_data”需要做什么样的修改?
请大家多多支持
最佳答案
您需要在 i2c_board_info 结构中提供一些平台数据。
根据您提供的代码,该结构应该是 struct pca953x_platform_data 类型并且 在 platform_data 字段中引用。
即(SABRE 精简板)
static struct pca953x_platform_data my_pca953x_pdata = {
.gpio_base = MX6Q_PAD_GPIO_5__I2C3_SCL,
};
static struct i2c_board_info mxc_i2c2_board_info[] __initdata = {
{
I2C_BOARD_INFO("pca953x", 0x21),
.irq = gpio_to_irq(MX6Q_SABRELITE_CAP_TCH_INT1),
.platform_data = &my_pca953x_pdata
},
};
关于linux - I2C 设备驱动程序错误 [TCA6408 I/O 扩展器],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20698877/