用的这一款CPU没有i2c host,所以gpio模拟i2c,本来一个设备不用做i2c adapter,直接模拟就是了,但是接了3个i2c设备,ts,radio,touchpad,所以要用i2c总线。driver/i2c/下已经有比较成熟的代码了,所以添加我们这款CPU的adapter,然后做设备driver。
i2c通讯方式中有包含bit方式通讯,driver/i2c/algos/i2c-algo-bit.c
需要添加的是i2c-algo-bit.c里的setsda,setscl,getsda,getscl 4个函数
/* --- setting states on the bus with the right timing: --------------- */
#define setsda(adap,val) adap->setsda(adap->data, val)
#define setscl(adap,val) adap->setscl(adap->data, val)
#define getsda(adap) adap->getsda(adap->data)
#define getscl(adap) adap->getscl(adap->data)
做adapter数据结构
struct t30x_gpio_i2c_pins
{
unsigned int scl_gpio;
unsigned int scl_inout;
unsigned int scl_altfunc;
unsigned int sda_gpio;
unsigned int sda_inout;
unsigned int sda_altfunc;
};
i2c通讯方式中有包含bit方式通讯,driver/i2c/algos/i2c-algo-bit.c
需要添加的是i2c-algo-bit.c里的setsda,setscl,getsda,getscl 4个函数
/* --- setting states on the bus with the right timing: --------------- */
#define setsda(adap,val) adap->setsda(adap->data, val)
#define setscl(adap,val) adap->setscl(adap->data, val)
#define getsda(adap) adap->getsda(adap->data)
#define getscl(adap) adap->getscl(adap->data)
做adapter数据结构
struct t30x_gpio_i2c_pins
{
unsigned int scl_gpio;
unsigned int scl_inout;
unsigned int scl_altfunc;
unsigned int sda_gpio;
unsigned int sda_inout;
unsigned int sda_altfunc;
};