全志下 移植TP 设备没有注册到内核中问题

枫叶会再红吗 2017-06-13 05:22:32
小弟最近在全志a64上面移植TP,之前没有碰过全志的平台,这套TP代码写的人也不是按照全志下面来写的,移植过程中I2C_dirver有注册成功,i2c_devices没有注册上,probe没有被调用,我在sys_config.fex中有配置相关选项

[ctp]
compatible = "allwinner,sun50i-ctp-para"
ctp_used = 1
ctp_name = "msg2xxx"
ctp_twi_id = 1
ctp_twi_addr = 0x26
ctp_screen_max_x = 1080
ctp_screen_max_y = 1920
ctp_revert_x_flag = 0
ctp_revert_y_flag = 0
ctp_exchange_x_y_flag = 0

ctp_int_port = port:PH06<6><default><default><default>
ctp_wakeup = port:PH07<1><default><default><1>
ctp_power_ldo = "vcc-ctp"
ctp_power_ldo_vol = 3300
ctp_power_io =

;--------------------------------------------------------------------------------
; CTP automatic detection configuration
;ctp_detect_used --- Whether startup automatic inspection function. 1:used,0:unused
;Module name postposition 1 said detection, 0 means no detection.
;--------------------------------------------------------------------------------
[ctp_list]
compatible = "allwinner,sun50i-ctp-list"
ctp_list_used = 1
gslX680new = 0
gt9xx_ts = 0
gt9xxnew_ts = 0
gt82x = 0
zet622x = 0
aw5306_ts = 0
ft5x = 0
Ilitek_drv_qcom = 1

;i2c configuration
;----------------------------------------------------------------------------------
[twi0]
twi0_used = 0
twi0_scl = port:PH0<2><default><default><default>
twi0_sda = port:PH1<2><default><default><default>

[twi1]
twi1_used = 1
twi1_scl = port:PH2<2><default><default><default>
twi1_sda = port:PH3<2><default><default><default>

[twi2]
twi2_used = 0
twi2_scl = port:PE14<3><default><default><default>
twi2_sda = port:PE15<3><default><default><default>

bus num 0,1,2都试过,名字地址都正确,请问还有其他什么有漏掉的吗,我有点怀疑是代码初始化部分有点问题,我自己写了点全志差异话的代码,代码我贴在下面,有做过全志的大神麻烦帮忙看下。

#define MSG_TP_IC_NAME "msg2xxx" //"msg22xx" or "msg28xx" /* Please define the mstar touch ic name based on the mutual-capacitive ic or self capacitive ic that you are using */

/*=============================================================*/
// VARIABLE DEFINITION
/*=============================================================*/

struct i2c_client *g_I2cClient = NULL;

#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
struct regulator *g_ReguVdd = NULL;
struct regulator *g_ReguVcc_i2c = NULL;
#endif //CONFIG_ENABLE_REGULATOR_POWER_ON

#ifdef CONFIG_TOUCH_DRIVER_RUN_ON_ALLWINER_PLATFORM

static const unsigned short normal_i2c[2] = {0x26,I2C_CLIENT_END};

struct ctp_config_info config_info = {
.input_type = CTP_TYPE,
.name = NULL,
.int_number = 0,
};

static int twi_id = 0;
static int screen_max_x = 0;
static int screen_max_y = 0;
static int revert_x_flag = 0;
static int revert_y_flag = 0;
static int exchange_x_y_flag = 0;

static int ctp_get_system_config(void)
{

twi_id = config_info.twi_id;
//screen_max_x = 1080;//config_info.screen_max_x;
//screen_max_y = 1920;//config_info.screen_max_y;
screen_max_x = config_info.screen_max_x;
screen_max_y = config_info.screen_max_y;
printk("Ilitek: screen_max_x = %d\n",screen_max_x);
revert_x_flag = config_info.revert_x_flag;
revert_y_flag = config_info.revert_y_flag;
exchange_x_y_flag = config_info.exchange_x_y_flag;
if( (screen_max_x == 0) || (screen_max_y == 0)){
printk("%s:read config error!\n",__func__);
return 0;
}
return 1;
}

int ctp_ts_detect(struct i2c_client *client, struct i2c_board_info *info)
{
struct i2c_adapter *adapter = client->adapter;

if(twi_id == adapter->nr)
{
//pr_info("%s: Detected chip %s at adapter %d, address 0x%02x\n",__func__, ILITEK_I2C_DRIVER_NAME, i2c_adapter_id(adapter), client->addr);
strlcpy(info->type, MSG_TP_IC_NAME, I2C_NAME_SIZE);
return 0;
}
else
{
return -ENODEV;
}
}
/*
static struct i2c_board_info i2c_info_dev = {
I2C_BOARD_INFO("msg2xxx", 0x26),
.platform_data = NULL,
};

static int add_ctp_device(void) {
//char name[I2C_NAME_SIZE];
struct i2c_adapter *adap;

//script_parser_fetch("ctp_para", "ctp_twi_id", &twi_id, 1);

adap = i2c_get_adapter(twi_id);
g_I2cClient = i2c_new_device(adap, &i2c_info_dev);

return 0;
}
*/
#endif


/*=============================================================*/
// FUNCTION DEFINITION
/*=============================================================*/

/* probe function is used for matching and initializing input device */
static int /*__devinit*/ touch_driver_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
int ret = 0;
const char *vdd_name = "vdd";
const char *vcc_i2c_name = "vcc_i2c";
#endif //CONFIG_ENABLE_REGULATOR_POWER_ON

printk("*** %s ***\n", __func__);

if (client == NULL)
{
printk("i2c client is NULL\n");
return -1;
}
g_I2cClient = client;

#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
g_ReguVdd = regulator_get(&g_I2cClient->dev, vdd_name);
if (IS_ERR(g_ReguVdd)) {
printk("regulator_get vdd fail\n");
//return -EINVAL;
}
else {
ret = regulator_set_voltage(g_ReguVdd, 2600000, 3300000);
if (ret)
{
printk("Could not set to 2800mv.\n");
}
}
g_ReguVcc_i2c = regulator_get(&g_I2cClient->dev, vcc_i2c_name);
if (IS_ERR(g_ReguVcc_i2c)) {
printk("regulator_get vcc fail\n");
//return -EINVAL;
}
else {
ret = regulator_set_voltage(g_ReguVcc_i2c, 1800000, 1800000);
if (ret)
{
printk("Could not set to 1800mv.\n");
}
}
#endif //CONFIG_ENABLE_REGULATOR_POWER_ON

#ifdef CONFIG_TOUCH_DRIVER_RUN_ON_ALLWINER_PLATFORM

if(!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
printk("Ilitek: %s, I2C_FUNC_I2C not support\n", __func__);
return -1;
}

#endif
return MsDrvInterfaceTouchDeviceProbe(g_I2cClient, id);
}

/* remove function is triggered when the input device is removed from input sub-system */
static int touch_driver_remove(struct i2c_client *client)
{
printk("*** %s ***\n", __func__);

return MsDrvInterfaceTouchDeviceRemove(client);
}

/* The I2C device list is used for matching I2C device and I2C device driver. */
static const struct i2c_device_id touch_device_id[] =
{
{MSG_TP_IC_NAME, 0},
{}, /* should not omitted */
};

MODULE_DEVICE_TABLE(i2c, touch_device_id);

static struct of_device_id touch_match_table[] = {
{ .compatible = "mstar,msg2xxx",},
{ .compatible = "tchip,ilitek",},
{ .compatible = "ilitek,2120",},
{},
};

static struct i2c_driver touch_device_driver =
{
//.class = I2C_CLASS_HWMON,

.driver = {
.name = MSG_TP_IC_NAME,
.owner = THIS_MODULE,
.of_match_table = touch_match_table,
},
.probe = touch_driver_probe,
.remove = touch_driver_remove,
.id_table = touch_device_id,
#ifdef CONFIG_TOUCH_DRIVER_RUN_ON_ALLWINER_PLATFORM
.address_list = normal_i2c,
#endif
};

static int __init touch_driver_init(void)
{
s32 ret = -1;

#ifdef CONFIG_TOUCH_DRIVER_RUN_ON_ALLWINER_PLATFORM
if (input_fetch_sysconfig_para(&(config_info.input_type))) {
printk("Ilitek: %s: ctp_fetch_sysconfig_para err.\n", __func__);
return 0;
} else {
ret = input_init_platform_resource(&(config_info.input_type));
if (0 != ret) {
printk("Ilitek: %s:ctp_ops.init_platform_resource err. \n", __func__);
}
}

if(config_info.ctp_used == 0) {
printk("Ilitek: *** ctp_used set to 0 !\n");
printk("Ilitek: *** if use ctp,please put the sys_config.fex ctp_used set to 1. \n");
return 0;
}

if(!ctp_get_system_config()) {
printk("Ilitek: %s:read config fail!\n",__func__);
return ret;
}

//add_ctp_device();

touch_device_driver.detect = ctp_ts_detect;

#endif



/* register driver */

ret = i2c_add_driver(&touch_device_driver);
if (ret < 0)
{
printk("add ILITEK/MStar touch device driver i2c driver failed.\n");
return -ENODEV;
}
printk("add ILITEK/MStar touch device driver i2c driver.\n");

return ret;

}

static void __exit touch_driver_exit(void)
{
printk("remove ILITEK/MStar touch device driver i2c driver.\n");

i2c_del_driver(&touch_device_driver);
}

module_init(touch_driver_init);
module_exit(touch_driver_exit);
MODULE_LICENSE("GPL");
...全文
486 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

21,600

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 驱动开发/核心开发
社区管理员
  • 驱动开发/核心开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧