input: touchscreen: goodix_berlin_driver: Get IC type from matched compatible

Change-Id: I45123063402b3bbeac99288ccdb4ae2c3280698c
Signed-off-by: Jens Reidel <adrian@travitia.xyz>
This commit is contained in:
Jens Reidel 2024-09-06 23:46:22 +02:00
parent 73c3523557
commit a426129cba
No known key found for this signature in database
GPG Key ID: 23C1E5F512C12303
4 changed files with 33 additions and 32 deletions

View File

@ -161,6 +161,16 @@ static void goodix_pdev_release(struct device *dev)
kfree(goodix_pdev);
}
#ifdef CONFIG_OF
static const struct of_device_id i2c_matchs[] = {
{.compatible = "goodix,gt9897",},
{.compatible = "goodix,gt9966",},
{.compatible = "goodix,gt9916",},
{},
};
MODULE_DEVICE_TABLE(of, i2c_matchs);
#endif
static int goodix_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *dev_id)
{
@ -172,7 +182,7 @@ static int goodix_i2c_probe(struct i2c_client *client,
return -EIO;
/* get ic type */
ret = goodix_get_ic_type(client->dev.of_node);
ret = goodix_get_ic_type(client->dev.of_node, i2c_matchs);
if (ret < 0)
return ret;
@ -221,16 +231,6 @@ static int goodix_i2c_remove(struct i2c_client *client)
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id i2c_matchs[] = {
{.compatible = "goodix,gt9897",},
{.compatible = "goodix,gt9966",},
{.compatible = "goodix,gt9916",},
{},
};
MODULE_DEVICE_TABLE(of, i2c_matchs);
#endif
static const struct i2c_device_id i2c_id_table[] = {
{TS_DRIVER_NAME, 0},
{},

View File

@ -189,6 +189,16 @@ static void goodix_pdev_release(struct device *dev)
kfree(goodix_pdev);
}
#ifdef CONFIG_OF
static const struct of_device_id spi_matchs[] = {
{.compatible = "goodix,gt9897S",},
{.compatible = "goodix,gt9897T",},
{.compatible = "goodix,gt9966S",},
{.compatible = "goodix,gt9916S",},
{},
};
#endif
static int goodix_spi_probe(struct spi_device *spi)
{
int ret = 0;
@ -206,7 +216,7 @@ static int goodix_spi_probe(struct spi_device *spi)
}
/* get ic type */
ret = goodix_get_ic_type(spi->dev.of_node);
ret = goodix_get_ic_type(spi->dev.of_node, spi_matchs);
if (ret < 0)
return ret;
@ -259,16 +269,6 @@ static int goodix_spi_remove(struct spi_device *spi)
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id spi_matchs[] = {
{.compatible = "goodix,gt9897S",},
{.compatible = "goodix,gt9897T",},
{.compatible = "goodix,gt9966S",},
{.compatible = "goodix,gt9916S",},
{},
};
#endif
static const struct spi_device_id spi_id_table[] = {
{TS_DRIVER_NAME, 0},
{},

View File

@ -694,7 +694,7 @@ int goodix_fw_update_init(struct goodix_ts_core *core_data);
void goodix_fw_update_uninit(void);
int goodix_do_fw_update(struct goodix_ic_config *ic_config, int mode);
int goodix_get_ic_type(struct device_node *node);
int goodix_get_ic_type(struct device_node *node, const struct of_device_id *goodix_dt_ids);
int gesture_module_init(void);
void gesture_module_exit(void);
int inspect_module_init(void);

View File

@ -150,24 +150,25 @@ void goodix_rotate_abcd2cbad(int tx, int rx, s16 *data)
}
/* get ic type */
int goodix_get_ic_type(struct device_node *node)
int goodix_get_ic_type(struct device_node *node, const struct of_device_id *goodix_dt_ids)
{
const char *name_tmp;
const struct of_device_id *match;
int ret;
ret = of_property_read_string(node, "compatible", &name_tmp);
if (ret < 0) {
ts_err("get compatible failed");
return ret;
match = of_match_node(of_match_ptr(goodix_dt_ids), node);
if (!match) {
ts_err("failed to match device tree node");
return -EINVAL;
}
ts_info("ic type is %s", match->compatible);
if (strstr(name_tmp, "9897")) {
if (strstr(match->compatible, "9897")) {
ts_info("ic type is BerlinA");
ret = IC_TYPE_BERLIN_A;
} else if (strstr(name_tmp, "9966") || strstr(name_tmp, "7986")) {
} else if (strstr(match->compatible, "9966") || strstr(match->compatible, "7986")) {
ts_info("ic type is BerlinB");
ret = IC_TYPE_BERLIN_B;
} else if (strstr(name_tmp, "9916")) {
} else if (strstr(match->compatible, "9916")) {
ts_info("ic type is BerlinD");
ret = IC_TYPE_BERLIN_D;
} else {