chipone_tddi_mmi: support ICNL9911C

Cebu 3rd panel bringup
Support Chipone new touch IC ICNL9911C
NO_PROP_NEEDED

Change-Id: I4f8bbed3aac151928bdce009bc3b8a787dacc72f
Signed-off-by: hujing3 <hujing3@lenovo.com>
Reviewed-on: https://gerrit.mot.com/1794746
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
hujing3 2020-11-05 15:25:35 +08:00 • committed by Jing Hu
commit 4cc775bdc5
5 changed files with 122 additions and 9 deletions

View file

@ -1072,6 +1072,48 @@ int cts_hw_reg_readsb_retry(const struct cts_device *cts_dev,
return cts_sram_readsb_retry(cts_dev, reg_addr, dst, len, retry, delay);
}
#define CTS_DEV_HW_REG_DDI_REG_CTRL (0x3002Cu)
static int icnl9911s_set_access_ddi_reg(struct cts_device *cts_dev, bool enable)
{
int ret;
u8 access_flag;
cts_info("ICNL9911S %s access ddi reg", enable ? "enable" : "disable");
ret = cts_hw_reg_readb(cts_dev, CTS_DEV_HW_REG_DDI_REG_CTRL, &access_flag);
if (ret) {
cts_err("Read HW_REG_DDI_REG_CTRL failed %d", ret);
return ret;
}
access_flag = enable ? (access_flag | 0x01) : (access_flag & (~0x01));
ret = cts_hw_reg_writeb(cts_dev, CTS_DEV_HW_REG_DDI_REG_CTRL, access_flag);
if (ret) {
cts_err("Write HW_REG_DDI_REG_CTRL %02x failed %d", access_flag, ret);
return ret;
}
ret = cts_hw_reg_writeb(cts_dev, 0x30074, enable ? 1 : 0);
if (ret) {
cts_err("Write 0x30074 failed %d", ret);
return ret;
}
ret = cts_hw_reg_writew(cts_dev, 0x3DFF0, enable ? 0x595A : 0x5A5A);
if (ret) {
cts_err("Write password to F0 failed %d", ret);
return ret;
}
ret = cts_hw_reg_writew(cts_dev, 0x3DFF4, enable ? 0xA6A5 : 0x5A5A);
if (ret) {
cts_err("Write password to F1 failed %d", ret);
return ret;
}
return 0;
}
const static struct cts_sfctrl icnl9911_sfctrl = {
.reg_base = 0x34000,
.xchg_sram_base = (80 - 1) * 1024,
@ -1129,6 +1171,7 @@ const static struct cts_device_hwdata cts_device_hwdatas[] = {
.program_addr_width = 3,
.sfctrl = &icnl9911c_sfctrl,
.enable_access_ddi_reg = icnl9911s_set_access_ddi_reg,
}
};
@ -1829,10 +1872,32 @@ int cts_suspend_device(struct cts_device *cts_dev)
int cts_resume_device(struct cts_device *cts_dev)
{
int ret = 0;
const struct cts_firmware *firmware = NULL;
int retries = 3;
cts_info("Resume device");
/* Check whether device is in normal mode */
while (--retries >= 0) {
#ifdef CFG_CTS_HAS_RESET_PIN
cts_plat_reset_device(cts_dev->pdata);
#endif
cts_set_normal_addr(cts_dev);
#ifdef CONFIG_CTS_I2C_HOST
if (cts_plat_is_i2c_online
(cts_dev->pdata, CTS_DEV_NORMAL_MODE_I2CADDR))
#else
if (cts_plat_is_normal_mode(cts_dev->pdata))
#endif
{
break;
}
}
if (retries < 0) {
const struct cts_firmware *firmware = NULL;
cts_info("Need update firmware when resume");
#ifdef CFG_CTS_FW_UPDATE_FILE_LOAD
if (cts_dev->config_fw_name[0] != '\0') {
firmware = cts_request_firmware_from_fs(cts_dev,
@ -1856,6 +1921,7 @@ int cts_resume_device(struct cts_device *cts_dev)
"please update manually!!", ret);
goto err_set_program_mode;
}
}
#ifdef CONFIG_CTS_CHARGER_DETECT
if (cts_is_charger_exist(cts_dev)) {

View file

@ -201,7 +201,7 @@ struct cts_device_hwdata {
u8 program_addr_width;
const struct cts_sfctrl *sfctrl;
int (*enable_access_ddi_reg)(struct cts_device *cts_dev, bool enable);
};
/** Chip firmware data */
@ -378,6 +378,18 @@ extern int cts_hw_reg_readsb_retry(const struct cts_device *cts_dev,
u32 reg_addr, void *dst, size_t len,
int retry, int delay);
static inline int cts_hw_reg_readb(const struct cts_device *cts_dev, u32 reg_addr, u8 *b)
{
return cts_hw_reg_readb_retry(cts_dev, reg_addr, b, 1, 0);
}
static inline int cts_hw_reg_writeb(const struct cts_device *cts_dev, u32 reg_addr, u8 b)
{
return cts_hw_reg_writeb_retry(cts_dev, reg_addr, b, 1, 0);
}
static inline int cts_hw_reg_writew(const struct cts_device *cts_dev, u32 reg_addr, u16 w)
{
return cts_hw_reg_writew_retry(cts_dev, reg_addr, w, 1, 0);
}
static inline int cts_fw_reg_writeb(const struct cts_device *cts_dev,
u32 reg_addr, u8 b)
{

View file

@ -231,6 +231,7 @@ static int check_dt(struct device_node *np)
panel = of_drm_find_panel(node);
of_node_put(node);
if (!IS_ERR(panel)) {
cts_info("check active_panel");
active_panel = panel;
return 0;
}
@ -240,6 +241,35 @@ static int check_dt(struct device_node *np)
return -ENODEV;
}
static int check_default_tp(struct device_node *dt, const char *prop)
{
const char *active_tp;
const char *compatible;
char *start;
int ret;
ret = of_property_read_string(dt->parent, prop, &active_tp);
if (ret) {
cts_err(" %s:fail to read %s %d\n", __func__, prop, ret);
return -ENODEV;
}
ret = of_property_read_string(dt, "compatible", &compatible);
if (ret < 0) {
cts_err(" %s:fail to read %s %d\n", __func__, "compatible", ret);
return -ENODEV;
}
start = strnstr(active_tp, compatible, strlen(active_tp));
if (start == NULL) {
cts_err(" %s:no match compatible, %s, %s\n",
__func__, compatible, active_tp);
ret = -ENODEV;
}
return ret;
}
#ifdef CONFIG_CTS_I2C_HOST
static int cts_driver_probe(struct i2c_client *client,
const struct i2c_device_id *id)
@ -253,8 +283,13 @@ static int cts_driver_probe(struct spi_device *client)
{
struct device_node *dp = client->dev.of_node;
if (check_dt(dp)) {
if (!check_default_tp(dp, "qcom,i2c-touch-active"))
ret = -EPROBE_DEFER;
else
ret = -ENODEV;
cts_err("%s: %s not actived\n", __func__, dp->name);
return -ENODEV;
return ret;
}
}
#ifdef CONFIG_CTS_I2C_HOST
@ -831,7 +866,7 @@ static int __init cts_driver_init(void)
#ifdef CONFIG_CTS_I2C_HOST
return i2c_add_driver(&cts_i2c_driver);
#else
pr_err("wj---spi");
pr_err("cts_driver_init spi");
return spi_register_driver(&cts_spi_driver);
#endif
}
@ -847,8 +882,8 @@ static void __exit cts_driver_exit(void)
#endif
}
//module_init(cts_driver_init);
late_initcall(cts_driver_init);
module_init(cts_driver_init);
//late_initcall(cts_driver_init);
module_exit(cts_driver_exit);
#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE

View file

@ -583,7 +583,7 @@ int cts_init_platform_data(struct cts_platform_data *pdata,
struct input_dev *input_dev;
int ret = 0;
cts_info("Init");
cts_info("cts_init_platform_data Init");
#ifdef CONFIG_CTS_OF
{

View file

@ -30,7 +30,7 @@ char *argv[MAX_ARG_NUM];
static int jitter_test_frame = 10;
static s16 *manualdiff_base;
u16 speed = 6000;
u16 speed = 9600;
int parse_arg(const char *buf, size_t count)
{
@ -2053,7 +2053,7 @@ static ssize_t jitter_store(struct device *dev,
ret = kstrtou16(argv[0], 0, &cnt);
if (ret == 0) {
if (cnt < 2 || cnt > 10000) {
if (cnt > 2 || cnt < 10000) {
jitter_test_frame = cnt;
}
}