fogos: dlkm: Skip load chipone touch modules when charger

- When bootmode is charger, skip insmod touch drivers because in this case
touch is not necessary and there is a conflict between firmware upgrade and
stopping device.

Change-Id: I8afc846361df5868d99d3b8f7a80f20c2da85db6
Signed-off-by: Jun Weng <wengjun1@motorola.com>
Reviewed-on: https://gerrit.mot.com/2755532
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Zhihong Kang <kangzh@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Jun Weng 2023-09-21 17:15:51 +08:00
commit d87f1944e8
3 changed files with 50 additions and 0 deletions

View file

@ -49,6 +49,10 @@ ifeq ($(TOUCHSCREEN_PM_BRL_SPI),true)
KERNEL_CFLAGS += TOUCHSCREEN_PM_BRL_SPI=y
endif
ifeq ($(CONFIG_INPUT_CHECK_DEVICE_BOOTMODE),true)
KERNEL_CFLAGS += CONFIG_CHIPONE_CHECK_DEVICE_BOOTMODE=y
endif
include $(CLEAR_VARS)
ifneq ($(BOARD_USES_DOUBLE_TAP),)
LOCAL_ADDITIONAL_DEPENDENCIES += $(KERNEL_MODULES_OUT)/sensors_class.ko

View file

@ -45,6 +45,10 @@ ifneq ($(filter m y,$(TOUCHSCREEN_PM_BRL_SPI)),)
EXTRA_CFLAGS += -DTOUCHSCREEN_PM_BRL_SPI
endif
ifneq ($(filter m y,$(CONFIG_CHIPONE_CHECK_DEVICE_BOOTMODE)),)
EXTRA_CFLAGS += -DCTS_CHECK_DEVICE_BOOTMODE
endif
#obj-$(CONFIG_TOUCHSCREEN_CHIPONE) += chipone-tddi.o
obj-m += chipone_tddi_v2_mmi.o

View file

@ -609,6 +609,41 @@ int chipone_sensor_remove(struct chipone_ts_data *data)
}
#endif
#ifdef CTS_CHECK_DEVICE_BOOTMODE
static bool cts_is_charger_mode(void)
{
struct device_node *np = of_find_node_by_path("/chosen");
bool charger_mode = false;
const char *bootargs = NULL;
char *bootmode = NULL;
char *end = NULL;
if (!np)
return charger_mode;
#ifdef CONFIG_BOOT_CONFIG
if (!of_property_read_string(np, "mmi,bootconfig", &bootargs)) {
#else
if (!of_property_read_string(np, "bootargs", &bootargs)) {
#endif
bootmode = strstr(bootargs, "androidboot.mode=");
if (bootmode) {
end = strpbrk(bootmode, " ");
bootmode = strpbrk(bootmode, "=");
}
if (bootmode &&
end > bootmode &&
strnstr(bootmode, "charger", end - bootmode)) {
charger_mode = true;
}
}
of_node_put(np);
cts_info("Charger mode = %d", charger_mode);
return charger_mode;
}
#endif
#ifdef CONFIG_CTS_I2C_HOST
static int cts_driver_probe(struct i2c_client *client,
const struct i2c_device_id *id)
@ -654,6 +689,13 @@ static int cts_driver_probe(struct spi_device *client)
#endif
#endif
#ifdef CTS_CHECK_DEVICE_BOOTMODE
if (cts_is_charger_mode()) {
cts_info("Charger mode, ignore insmod chipone modules.\n");
return -ENODEV;
}
#endif
#ifdef CONFIG_CTS_I2C_HOST
cts_info("Probe i2c client: name='%s' addr=0x%02x flags=0x%02x irq=%d",
client->name, client->addr, client->flags, client->irq);