|
发表于 2022-9-22 15:11:09
只看该作者
板凳
我要用的i2c1, 目前遇到了些问题。配置如下
/*
* zcp 2022.9.21 add it8602
*/
#include <linux/kernel.h>
#include <linux/hrtimer.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/of_gpio.h>
#include <linux/gpio.h>
#include <linux/slab.h>
#define IT6802_I2C_NAME "it6802"
struct it6802_priv{
struct it6802_devce *it6802;
unsigned int initb;
struct i2c_driver drvier;
struct i2c_adapter *pI2cAdapter;
struct i2c_client *pI2cClient;
struct device *dev;
};
struct it6802_priv *it6802_info = NULL;
static int it6802_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
//printk("###zcp enter1\n");
struct it6802_priv *priv;
int ret = 0;
printk("###zcp enter2=====%s====\n",__func__);
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if(!priv)
return -ENOMEM;
priv->dev = &client ->dev;
if(!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
priv->pI2cAdapter = client->adapter;
if(priv->pI2cAdapter == NULL){
printk("[%s(), %d],###zcp failed to get i2c adapter.\n", __func__, __LINE__);
goto out;
}
it6802_info = priv;
printk("[%s(), %d],###zcp over.\n", __func__, __LINE__);
return 0;
out:
kfree(priv);
return ret;
}
static int it6802_remove(struct i2c_client *client)
{
printk("###zcp=====%s====\n",__func__);
return 0;
}
static const struct i2c_device_id it6802_id[] = {
{ IT6802_I2C_NAME, 0 },
{ }
};
static struct of_device_id it6802_dt_ids[] = {
{ .compatible = "rk3566,it6802" },
{ }
};
static struct i2c_driver it6802_driver = {
.probe = it6802_probe,
.remove = it6802_remove,
.id_table = it6802_id,
.driver = {
.name = IT6802_I2C_NAME,
.of_match_table = of_match_ptr(it6802_dt_ids),
},
};
static int it6802_init(void)
{
int ret;
printk("###zcp=====%s====\n",__func__);
ret = i2c_add_driver(&it6802_driver);
if(ret!=0){
printk("###zcp it6802 init error,ret =%d\n",ret);
}
printk("###zcp ret =%d\n",ret);
return ret;
}
static void it6802_exit(void){
printk("###zcp=====%s====\n",__func__);
i2c_del_driver(&it6802_driver);
}
module_init(it6802_init);
module_exit(it6802_exit);
MODULE_DESCRIPTION("It6802 Driver");
MODULE_AUTHOR("caigong");
MODULE_LICENSE("GPL");
rk3566-firefly-aiojd4.dtsi 的中配置如下
&pinctrl {
it6802 {
it6802_gpio: it6802-gpio{
rockchip,pins = <0 6 RK_FUNC_GPIO &pcfg_pull_up>;
};
};
};
&i2c1 {
status = "okay";
i2c-scl-rising-time-ns = <300>;
i2c-scl-falling-time-ns = <15>;
it6802: it6802@92 {
compatible = "rk3566,it6802";
reg = <0x92>;
reset_gpio = <&gpio0 6 GPIO_ACTIVE_HIGH>; //GPIO0_A6
pinctrl-names = "default";
pinctrl-0 = <&it6802_gpio>;
status = "okay";
};
};
rk3566-firefly-aiojd4-mipi101_JDM101014_BC45_A1.dts 中配置
&i2c1 {
status = "disabled";
}
内核打印进入
[ 0.200059] ###zcp=====it6802_init====
[ 0.200095] ###zcp ret =0
但是没进入prob函数。
且开机日志中有报错i2c1地址不对,请问正确地址是多少
[ 0.612407] i2c i2c-1: Invalid 7-bit I2C address 0x92
[ 0.612430] i2c i2c-1: of_i2c: Failure registering /i2c@fe5a0000/it6802@92
[ 0.612439] i2c i2c-1: Failed to create I2C device for /i2c@fe5a0000/it6802@92
|
|