From c090df6a23e68fb35d667dab96eb8d97fe244a09 Mon Sep 17 00:00:00 2001 From: Ryan Lattrel Date: Fri, 15 Dec 2017 10:12:15 -0600 Subject: [PATCH] cypress: cyttsp_sar_mmi: fix interrupt problems -Prevent the reset line from going into HiZ mode. HiZ mode results in the chip getting stuck in reset on this chipset. -Disable interrupts when a device tries to flash. -Fix system crash on removal of the module due to the wrong IRQ getting freed. Change-Id: I1a0bcd32b570507703d6847a7372251ec0272b5f Signed-off-by: Ryan Lattrel Reviewed-on: https://gerrit.mot.com/1104822 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Konstantin Makariev Submit-Approved: Jira Key --- drivers/misc/cypress/ProgrammingSteps.c | 9 +++------ drivers/misc/cypress/cyttsp_sar_mmi.c | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/misc/cypress/ProgrammingSteps.c b/drivers/misc/cypress/ProgrammingSteps.c index c4a04d2e1575..2a85f0333b61 100644 --- a/drivers/misc/cypress/ProgrammingSteps.c +++ b/drivers/misc/cypress/ProgrammingSteps.c @@ -1098,7 +1098,7 @@ unsigned char VerifyFlash(struct hssp_data *d) rowAddress = FLASH_ROW_BYTE_SIZE_HEX_FILE * rowCount; /* Extract 128-byte row from the hex-file from address: - “rowCount” into buffer - “rowData”. */ + "rowCount" into buffer - "rowData". */ HEX_ReadRowData(&d->inf, rowCount, &rowData[0]); /* Read row from chip */ @@ -1258,7 +1258,7 @@ unsigned char VerifyProtectionSettings(struct hssp_data *d) rowProtectionFlashData[i + 3] = (protectionData >> 24) & 0xFF; } - /* Compare hex and silicon’s data */ + /* Compare hex and silicon's data */ for (i = 0; i < rowProtectionByteSize; i++) { if (rowProtectionData[i] != rowProtectionFlashData[i]) { @@ -1283,7 +1283,7 @@ unsigned char VerifyProtectionSettings(struct hssp_data *d) else if (chipProtectionData_Chip == CHIP_PROT_OPEN) chipProtectionData_Chip = CHIP_PROT_VIRGIN; - /* Compare hex’s and silicon’s chip protection data */ + /* Compare hex's and silicon's chip protection data */ if (chipProtectionData_Chip != chipProtectionData_Hex) { /* Set the verification error bit for Flash protection data mismatch and return failure */ @@ -1397,9 +1397,6 @@ void ExitProgrammingMode(void) SetXresLow(); DelayHundredUs(); SetXresHigh(); - - /* Make XRES High-Z after generating the reset pulse */ - SetXresHizInput(); } /* [] END OF FILE */ diff --git a/drivers/misc/cypress/cyttsp_sar_mmi.c b/drivers/misc/cypress/cyttsp_sar_mmi.c index 6a95d8bf0247..4417db02fbe6 100644 --- a/drivers/misc/cypress/cyttsp_sar_mmi.c +++ b/drivers/misc/cypress/cyttsp_sar_mmi.c @@ -851,6 +851,12 @@ static void capsense_update_work(struct work_struct *w) { struct cycapsense_ctrl_data *data = container_of(w, struct cycapsense_ctrl_data, work); + struct i2c_client *client = to_i2c_client(data->dev); + + if(data->cmd == HSSP_CMD_NONE) + return; + + disable_irq(client->irq); switch (data->cmd) { case HSSP_CMD_RESET: @@ -864,6 +870,8 @@ static void capsense_update_work(struct work_struct *w) break; } data->cmd = HSSP_CMD_NONE; + + enable_irq(client->irq); } int cycapsense_reset(void) @@ -1152,7 +1160,7 @@ static int cyttsp_sar_probe(struct i2c_client *client, error = cyttsp_sar_parse_dt(&client->dev, pdata); if (error) return error; - client->irq = pdata->irq_gpio; + client->irq = gpio_to_irq(pdata->irq_gpio); cyttsp_reg_setup_init(client); @@ -1220,13 +1228,13 @@ static int cyttsp_sar_probe(struct i2c_client *client, } - error = request_threaded_irq(gpio_to_irq(client->irq), NULL, cyttsp_sar_interrupt, + error = request_threaded_irq(client->irq, NULL, cyttsp_sar_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, client->dev.driver->name, data); - dev_err(&client->dev, "registering irq %d\n", gpio_to_irq(client->irq)); + dev_err(&client->dev, "registering irq %d\n", client->irq); if (error) { - dev_err(&client->dev, "Error %d registering irq %d\n", error, gpio_to_irq(client->irq)); + dev_err(&client->dev, "Error %d registering irq %d\n", error, client->irq); goto err_unreg_input; } @@ -1315,6 +1323,7 @@ static int cyttsp_sar_remove(struct i2c_client *client) free_irq(client->irq, data); for (i = 0; i < 4; i++) { input_unregister_device(data->input_dev[i]); + sensors_classdev_unregister(&sensors_capsensor_cdev[i]); } if (gpio_is_valid(pdata->irq_gpio)) gpio_free(pdata->irq_gpio); @@ -1325,6 +1334,8 @@ static int cyttsp_sar_remove(struct i2c_client *client) if (data->regulator_vddio) regulator_disable(data->regulator_vddio); + class_unregister(&capsense_class); + kfree(data); data = NULL;