Skip to content

Commit

Permalink
input: touchscreen: gt1x: support to keep otp config
Browse files Browse the repository at this point in the history
  • Loading branch information
efectn committed Oct 6, 2024
1 parent 5b2189d commit 73a94e5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
6 changes: 6 additions & 0 deletions drivers/input/touchscreen/gt1x/gt1x.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ static int gt1x_parse_dt(struct device *dev)
}
#endif

#if GTP_DRIVER_SEND_CFG
gt1x_keep_otp_config = of_property_read_bool(dev->of_node, "keep-otp-config");
#else
gt1x_keep_otp_config = true;
#endif

return 0;
}

Expand Down
29 changes: 22 additions & 7 deletions drivers/input/touchscreen/gt1x/gt1x_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ u32 gt1x_abs_x_max;
u32 gt1x_abs_y_max;
int gt1x_halt;
bool gt1x_ics_slot_report;
bool gt1x_keep_otp_config;

#if GTP_DEBUG_NODE
static ssize_t gt1x_debug_read_proc(struct file *, char __user *, size_t, loff_t *);
Expand Down Expand Up @@ -629,14 +630,26 @@ s32 gt1x_init_panel(void)
}
set_reg_bit(gt1x_config[MODULE_SWITCH3_LOC], 5, !gt1x_wakeup_level);
#endif /* END GTP_CUSTOM_CFG */
#endif /* END GTP_DRIVER_SEND_CFG */

#else /* DRIVER NOT SEND CONFIG */
cfg_len = GTP_CONFIG_MAX_LENGTH;
ret = gt1x_i2c_read(GTP_REG_CONFIG_DATA, gt1x_config, cfg_len);
if (ret < 0) {
return ret;
if (gt1x_keep_otp_config) {
cfg_len = GTP_CONFIG_MAX_LENGTH;
ret = gt1x_i2c_read(GTP_REG_CONFIG_DATA, gt1x_config, cfg_len);
if (ret < 0) {
GTP_ERROR("Failed to read CONFIG data, sensor_id %d", gt1x_version.sensor_id);
return ret;
} else {
int i;
u16 checksum = 0;
for (i = 0; i < cfg_len - 4; i += 2) {
checksum += (gt1x_config[i] << 8) + gt1x_config[i + 1];
}
checksum = 0 - checksum;
if (!checksum || checksum != ((gt1x_config[i] << 8) + gt1x_config[i + 1])) {
GTP_ERROR("Invalid config data, checksum %04x", checksum);
}
}
}
#endif /* END GTP_DRIVER_SEND_CFG */

GTP_DEBUG_FUNC();
/* match resolution when gt1x_abs_x_max & gt1x_abs_y_max have been set already */
Expand All @@ -657,7 +670,9 @@ s32 gt1x_init_panel(void)
GTP_INFO("X_MAX=%d,Y_MAX=%d,TRIGGER=0x%02x,WAKEUP_LEVEL=%d", gt1x_abs_x_max, gt1x_abs_y_max, gt1x_int_type, gt1x_wakeup_level);

gt1x_cfg_length = cfg_len;
ret = gt1x_send_cfg(gt1x_config, gt1x_cfg_length);
if (!gt1x_keep_otp_config) {
ret = gt1x_send_cfg(gt1x_config, gt1x_cfg_length);
}
return ret;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/input/touchscreen/gt1x/gt1x_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ extern s32 gt1x_i2c_read(u16 addr, u8 *buffer, s32 len);
extern s32 gt1x_i2c_read_dbl_check(u16 addr, u8 *buffer, s32 len);

extern bool gt1x_ics_slot_report;
extern bool gt1x_keep_otp_config;
extern u8 gt1x_config[];
extern u32 gt1x_cfg_length;
extern u8 gt1x_int_type;
Expand Down

0 comments on commit 73a94e5

Please sign in to comment.