From patchwork Fri May 8 05:56:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89BB7C47247 for ; Fri, 8 May 2020 06:01:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F79320736 for ; Fri, 8 May 2020 06:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726099AbgEHF5U (ORCPT ); Fri, 8 May 2020 01:57:20 -0400 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:21951 "EHLO esa3.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725875AbgEHF5T (ORCPT ); Fri, 8 May 2020 01:57:19 -0400 IronPort-SDR: P2Qo1MpdLxqWs7ICMXluIFp6QtcRLCjGnUct7SA1p6Im8bVduiTI1fzuxukv4xW+IivT6T+nFG Dfu2EBaxlWWJ7o2j/ziMtZugl/ZXSH8U7kFLs8yJfyec4ggfHGrnSBBS8hYJ8SkNvShBQpHXmJ +hCyOzbz0v2oFj167uBBi2oXh5zodcBP5ItA3OqGhnwFPQVZ1J3NC2wbfCtNTwX0TfzsEND+7w gERKQyxD+V5aaEm90swSAElhnT5aEDs9gpvyx7WpGoF5fOKqkBlHoZ6A59w1aW+fxO8Q5qm/Sz GNs= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48651890" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 07 May 2020 21:57:06 -0800 IronPort-SDR: OpKNHbLPxedSfEsjC+awblXLTff3ppW/B+Bb3rRvYNBvt6Ozsq9x2JgwXiIcJpZxn32XobGwnP PjUxsS7rSfGYz5gVl02wZeOkNpr5tINxRGV3uzkFxSxUNgSi+22Ob6NK15J7Nc2+Zb66SIMYNh bOWU0olE7VKGDv+MD99LxUwjneBzQgKTF2uh4U6G42BHrZSuYEU3dk6uWBFtAUHtnpyxNBmUMF H89bV6/w1NL5FC9fDdUM8phHEhYZXm6ciwzh9nSrVHC0Qou2DJYf0pJKZhgICVtOuiyBTY8Y5W gIE= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 01/56] Input: introduce input_mt_report_slot_inactive Date: Thu, 7 May 2020 22:56:01 -0700 Message-ID: <20200508055656.96389-2-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org input_mt_report_slot_state() ignores the tool when the slot is closed. which has caused a bit of confusion. This patch introduces input_mt_report_slot_inactive() to report slot inactive state. replaces all input_mt_report_slot_state() with input_mt_report_slot_inactive() in case of close of slot. Suggested-by: Dmitry Torokhov Reported-by: kernel test robot Signed-off-by: Jiada Wang --- drivers/hid/hid-alps.c | 3 +-- drivers/hid/hid-multitouch.c | 6 ++---- drivers/input/misc/xen-kbdfront.c | 2 +- drivers/input/mouse/elan_i2c_core.c | 2 +- drivers/input/touchscreen/atmel_mxt_ts.c | 7 +++---- drivers/input/touchscreen/cyttsp4_core.c | 5 ++--- drivers/input/touchscreen/cyttsp_core.c | 2 +- drivers/input/touchscreen/melfas_mip4.c | 4 ++-- drivers/input/touchscreen/mms114.c | 2 +- drivers/input/touchscreen/raspberrypi-ts.c | 2 +- drivers/input/touchscreen/stmfts.c | 2 +- include/linux/input/mt.h | 5 +++++ 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c index ae79a7c66737..36ca1d815d53 100644 --- a/drivers/hid/hid-alps.c +++ b/drivers/hid/hid-alps.c @@ -387,8 +387,7 @@ static int u1_raw_event(struct alps_dev *hdata, u8 *data, int size) input_report_abs(hdata->input, ABS_MT_PRESSURE, z); } else { - input_mt_report_slot_state(hdata->input, - MT_TOOL_FINGER, 0); + input_mt_report_slot_inactive(hdata->input); } } diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 362805ddf377..e2ce790ff4a4 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -896,7 +896,7 @@ static void mt_release_pending_palms(struct mt_device *td, clear_bit(slotnum, app->pending_palm_slots); input_mt_slot(input, slotnum); - input_mt_report_slot_state(input, MT_TOOL_PALM, false); + input_mt_report_slot_inactive(input); need_sync = true; } @@ -1640,9 +1640,7 @@ static void mt_release_contacts(struct hid_device *hid) if (mt) { for (i = 0; i < mt->num_slots; i++) { input_mt_slot(input_dev, i); - input_mt_report_slot_state(input_dev, - MT_TOOL_FINGER, - false); + input_mt_report_slot_inactive(input_dev); } input_mt_sync_frame(input_dev); input_sync(input_dev); diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c index 24bc5c5d876f..a1bba722b234 100644 --- a/drivers/input/misc/xen-kbdfront.c +++ b/drivers/input/misc/xen-kbdfront.c @@ -146,7 +146,7 @@ static void xenkbd_handle_mt_event(struct xenkbd_info *info, break; case XENKBD_MT_EV_UP: - input_mt_report_slot_state(info->mtouch, MT_TOOL_FINGER, false); + input_mt_report_slot_inactive(info->mtouch); break; case XENKBD_MT_EV_SYN: diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 8719da540383..3f9354baac4b 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -938,7 +938,7 @@ static void elan_report_contact(struct elan_tp_data *data, input_report_abs(input, ABS_MT_TOUCH_MINOR, minor); } else { input_mt_slot(input, contact_num); - input_mt_report_slot_state(input, MT_TOOL_FINGER, false); + input_mt_report_slot_inactive(input); } } diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index ae60442efda0..a2189739e30f 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -822,8 +822,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message) * have happened. */ if (status & MXT_T9_RELEASE) { - input_mt_report_slot_state(input_dev, - MT_TOOL_FINGER, 0); + input_mt_report_slot_inactive(input_dev); mxt_input_sync(data); } @@ -839,7 +838,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message) input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, area); } else { /* Touch no longer active, close out slot */ - input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 0); + input_mt_report_slot_inactive(input_dev); } data->update_input = true; @@ -947,7 +946,7 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message) dev_dbg(dev, "[%u] release\n", id); /* close out slot */ - input_mt_report_slot_state(input_dev, 0, 0); + input_mt_report_slot_inactive(input_dev); } data->update_input = true; diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 6bcffc930384..02a73d9a4def 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -744,8 +744,7 @@ static void cyttsp4_report_slot_liftoff(struct cyttsp4_mt_data *md, for (t = 0; t < max_slots; t++) { input_mt_slot(md->input, t); - input_mt_report_slot_state(md->input, - MT_TOOL_FINGER, false); + input_mt_report_slot_inactive(md->input); } } @@ -845,7 +844,7 @@ static void cyttsp4_final_sync(struct input_dev *input, int max_slots, int *ids) if (ids[t]) continue; input_mt_slot(input, t); - input_mt_report_slot_state(input, MT_TOOL_FINGER, false); + input_mt_report_slot_inactive(input); } input_sync(input); diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c index 3f5d463dbeed..697aa2c158f7 100644 --- a/drivers/input/touchscreen/cyttsp_core.c +++ b/drivers/input/touchscreen/cyttsp_core.c @@ -340,7 +340,7 @@ static void cyttsp_report_tchdata(struct cyttsp *ts) continue; input_mt_slot(input, i); - input_mt_report_slot_state(input, MT_TOOL_FINGER, false); + input_mt_report_slot_inactive(input); } input_sync(input); diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c index 247c3aaba2d8..f67efdd040b2 100644 --- a/drivers/input/touchscreen/melfas_mip4.c +++ b/drivers/input/touchscreen/melfas_mip4.c @@ -391,7 +391,7 @@ static void mip4_clear_input(struct mip4_ts *ts) /* Screen */ for (i = 0; i < MIP4_MAX_FINGERS; i++) { input_mt_slot(ts->input, i); - input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, 0); + input_mt_report_slot_inactive(ts->input); } /* Keys */ @@ -534,7 +534,7 @@ static void mip4_report_touch(struct mip4_ts *ts, u8 *packet) } else { /* Release event */ input_mt_slot(ts->input, id); - input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, 0); + input_mt_report_slot_inactive(ts->input); } input_mt_sync_frame(ts->input); diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index 69c6d559eeb0..776ed9e4629d 100644 --- a/drivers/input/touchscreen/mms114.c +++ b/drivers/input/touchscreen/mms114.c @@ -549,7 +549,7 @@ static int __maybe_unused mms114_suspend(struct device *dev) /* Release all touch */ for (id = 0; id < MMS114_MAX_TOUCH; id++) { input_mt_slot(input_dev, id); - input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, false); + input_mt_report_slot_inactive(input_dev); } input_mt_report_pointer_emulation(input_dev, true); diff --git a/drivers/input/touchscreen/raspberrypi-ts.c b/drivers/input/touchscreen/raspberrypi-ts.c index 0e2e08f3f433..ef6aaed217cf 100644 --- a/drivers/input/touchscreen/raspberrypi-ts.c +++ b/drivers/input/touchscreen/raspberrypi-ts.c @@ -100,7 +100,7 @@ static void rpi_ts_poll(struct input_dev *input) released_ids = ts->known_ids & ~modified_ids; for_each_set_bit(i, &released_ids, RPI_TS_MAX_SUPPORTED_POINTS) { input_mt_slot(input, i); - input_mt_report_slot_state(input, MT_TOOL_FINGER, 0); + input_mt_report_slot_inactive(input); modified_ids &= ~(BIT(i)); } ts->known_ids = modified_ids; diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c index b6f95f20f924..b54cc64e4ea6 100644 --- a/drivers/input/touchscreen/stmfts.c +++ b/drivers/input/touchscreen/stmfts.c @@ -198,7 +198,7 @@ static void stmfts_report_contact_release(struct stmfts_data *sdata, u8 slot_id = (event[0] & STMFTS_MASK_TOUCH_ID) >> 4; input_mt_slot(sdata->input, slot_id); - input_mt_report_slot_state(sdata->input, MT_TOOL_FINGER, false); + input_mt_report_slot_inactive(sdata->input); input_sync(sdata->input); } diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h index 9e409bb13642..3b8580bd33c1 100644 --- a/include/linux/input/mt.h +++ b/include/linux/input/mt.h @@ -100,6 +100,11 @@ static inline bool input_is_mt_axis(int axis) bool input_mt_report_slot_state(struct input_dev *dev, unsigned int tool_type, bool active); +static inline void input_mt_report_slot_inactive(struct input_dev *dev) +{ + input_mt_report_slot_state(dev, 0, false); +} + void input_mt_report_finger_count(struct input_dev *dev, int count); void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count); void input_mt_drop_unused(struct input_dev *dev); From patchwork Fri May 8 05:56:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5812C4724C for ; Fri, 8 May 2020 06:00:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 905F920736 for ; Fri, 8 May 2020 06:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727787AbgEHGAu (ORCPT ); Fri, 8 May 2020 02:00:50 -0400 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:21951 "EHLO esa3.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbgEHF5V (ORCPT ); Fri, 8 May 2020 01:57:21 -0400 IronPort-SDR: MSE6KzYgSYJAkeEQCY/spftiKESCOL63BL1dG5/Ul9XRs0NG1yJhX07tFY8pdcrT2CzotC6Cjm e+kqrsw8TRS+PUTqia9eN7bbGYR6xU+A9KNcgErbWBlr7fQ2i6QUr0ALaOteCRNmntybck7mco AMNSLngfms1OsHBCEL/pcW5fXrgDkxLwjV4tuTGrXQU2PphKf1jYUk1m564sKnMvxk3vvp8zfa BCSG01Q+XmFkFmGLZlLucv3DA1aYEaos/w2zFEa30spHycPGIPqRx/BvGz1v5F90E0Ob5FJ14d 5EA= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48651898" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 07 May 2020 21:57:14 -0800 IronPort-SDR: OpQ92qvWaEhSSvQzJ3CBM/8T0x/w/HyRUi3W1/ReH/AR5N/NhPhFY28zQMP2IawwUeX3XELpHC LI3saavJGEkFWFHpqRPgw7wAeJqJN252FCVcyBklfutUkLsj6o4/4s7rViQWqjZFP8WJINSuo6 N9DMmOV54O0oqeGU9Txw9SZkeiTBFdTc3+xApO/PbymFGXuPZ68bFlfoxtO5yD4DsTRGo5oDdd c/961w5ZfvxWLSHxFPWzgAicMWzx9hUXggBq2SJ1bfYLlTs4xT+AEsb1sS9tCkCj/z/Q3zCWSf 7uk= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 03/56] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary Date: Thu, 7 May 2020 22:56:03 -0700 Message-ID: <20200508055656.96389-4-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer The workaround of reading all messages until an invalid is received is a way of forcing the CHG line high, which means that when using edge-triggered interrupts the interrupt can be acquired. With level-triggered interrupts the workaround is unnecessary. Also, most recent maXTouch chips have a feature called RETRIGEN which, when enabled, reasserts the interrupt line every cycle if there are messages waiting. This also makes the workaround unnecessary. Note: the RETRIGEN feature is only in some firmware versions/chips, it's not valid simply to enable the bit. Signed-off-by: Nick Dyer Acked-by: Benson Leung Acked-by: Yufeng Shen (cherry picked from ndyer/linux/for-upstream commit 1ae4e8281e491b22442cd5acdfca1862555f8ecb) [gdavis: Fix conflicts due to v4.6-rc7 commit eb43335c4095 ("Input: atmel_mxt_ts - use mxt_acquire_irq in mxt_soft_reset").] Signed-off-by: George G. Davis [jiada: reset use_retrigen_workaround at beginning of mxt_check_retrigen() call mxt_check_retrigen() after mxt_acquire_irq() in mxt_initialize() replace white-spaces with tab for MXT_COMMS_RETRIGEN] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 51 ++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 49bdf5cf3a0d..3f1ebe14802f 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +130,7 @@ struct t9_range { /* MXT_SPT_COMMSCONFIG_T18 */ #define MXT_COMMS_CTRL 0 #define MXT_COMMS_CMD 1 +#define MXT_COMMS_RETRIGEN BIT(6) /* MXT_DEBUG_DIAGNOSTIC_T37 */ #define MXT_DIAGNOSTIC_PAGEUP 0x01 @@ -308,6 +310,7 @@ struct mxt_data { struct t7_config t7_cfg; struct mxt_dbg dbg; struct gpio_desc *reset_gpio; + bool use_retrigen_workaround; /* Cached parameters from object table */ u16 T5_address; @@ -318,6 +321,7 @@ struct mxt_data { u16 T71_address; u8 T9_reportid_min; u8 T9_reportid_max; + u16 T18_address; u8 T19_reportid; u16 T44_address; u8 T100_reportid_min; @@ -1190,9 +1194,11 @@ static int mxt_acquire_irq(struct mxt_data *data) enable_irq(data->irq); - error = mxt_process_messages_until_invalid(data); - if (error) - return error; + if (data->use_retrigen_workaround) { + error = mxt_process_messages_until_invalid(data); + if (error) + return error; + } return 0; } @@ -1282,6 +1288,33 @@ static u32 mxt_calculate_crc(u8 *base, off_t start_off, off_t end_off) return crc; } +static int mxt_check_retrigen(struct mxt_data *data) +{ + struct i2c_client *client = data->client; + int error; + int val; + + data->use_retrigen_workaround = false; + + if (irq_get_trigger_type(data->irq) & IRQF_TRIGGER_LOW) + return 0; + + if (data->T18_address) { + error = __mxt_read_reg(client, + data->T18_address + MXT_COMMS_CTRL, + 1, &val); + if (error) + return error; + + if (val & MXT_COMMS_RETRIGEN) + return 0; + } + + dev_warn(&client->dev, "Enabling RETRIGEN workaround\n"); + data->use_retrigen_workaround = true; + return 0; +} + static int mxt_prepare_cfg_mem(struct mxt_data *data, struct mxt_cfg *cfg) { struct device *dev = &data->client->dev; @@ -1561,6 +1594,10 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw) mxt_update_crc(data, MXT_COMMAND_BACKUPNV, MXT_BACKUP_VALUE); + ret = mxt_check_retrigen(data); + if (ret) + goto release_mem; + ret = mxt_soft_reset(data); if (ret) goto release_mem; @@ -1604,6 +1641,7 @@ static void mxt_free_object_table(struct mxt_data *data) data->T71_address = 0; data->T9_reportid_min = 0; data->T9_reportid_max = 0; + data->T18_address = 0; data->T19_reportid = 0; data->T44_address = 0; data->T100_reportid_min = 0; @@ -1678,6 +1716,9 @@ static int mxt_parse_object_table(struct mxt_data *data, object->num_report_ids - 1; data->num_touchids = object->num_report_ids; break; + case MXT_SPT_COMMSCONFIG_T18: + data->T18_address = object->start_address; + break; case MXT_SPT_MESSAGECOUNT_T44: data->T44_address = object->start_address; break; @@ -2145,6 +2186,10 @@ static int mxt_initialize(struct mxt_data *data) if (error) return error; + error = mxt_check_retrigen(data); + if (error) + return error; + error = mxt_sysfs_init(data); if (error) return error; From patchwork Fri May 8 05:56:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207870 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1280C4724C for ; Fri, 8 May 2020 05:57:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 887F620870 for ; Fri, 8 May 2020 05:57:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726877AbgEHF50 (ORCPT ); Fri, 8 May 2020 01:57:26 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38659 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbgEHF50 (ORCPT ); Fri, 8 May 2020 01:57:26 -0400 IronPort-SDR: 2da9ZufG6x6cSHPWxOkyQUMM4gqMot08r5lkfrV0eJEvQnQUXcaGUkX6MbOYHhSSk4YHoQ0nEx c3ZsC/wPygCfLvZLyEnXESsXdEx8LiaKihDkxtc3FKFzCbz4V4teTFgAJXw/Z32iZGTndPOOYj aIFP1b2lEdGKj+WiIFEXbnEJSDG1qsBFGOZ4ZYlR04M5tjPCmJmRjOLsmGj/YNTYZ13FYGKGBY SwNN3nzUeDUr6Vj/YJzu58Q0x79rBnp2J+JZb+uK+mPb8TUYXsrVZ9fU/nImLhvJBP0DdnVfNI Iv0= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670046" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 21:57:24 -0800 IronPort-SDR: jOqvN7yEMsw/9CRkF+DqvM1oXhbwYkxrjI7AJVGNOf3xrGIcTvRjhx5N6sg4cXRYo8ROvcyeTT +mE4c/8JzH+r3GPo95PSo08hqQg3FmOtpFBLHXqWBf65wc4tl4oEMTN9btgw6DZfjOuTQu2Eky D8e9fP9dLzauqc7HT75gsrlwPoaI9ip3ZZEYQIz0V8XGSPskmDcU1yM5CxaE02CrVcXGvWCWjv Gn5qTBZ++oMBzKO6g5b3tcekz+0Ect0MR8IHQs2G5fUzx3gztWlTyGLOhn4PY1dkgURDXbelxL fgA= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 06/56] Input: atmel_mxt_ts - output status from T42 Touch Suppression Date: Thu, 7 May 2020 22:56:06 -0700 Message-ID: <20200508055656.96389-7-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer This patch outputs status from T42 touch suppression Signed-off-by: Nick Dyer Acked-by: Benson Leung Acked-by: Yufeng Shen (cherry picked from ndyer/linux/for-upstream commit ab95b5a309999d2c098daaa9f88d9fcfae7eb516) Signed-off-by: George G. Davis [jiada: Replace dev_info() with dev_dbg()] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index a53985a7736f..f6465edaa57e 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -155,6 +155,9 @@ struct t37_debug { #define MXT_RESET_VALUE 0x01 #define MXT_BACKUP_VALUE 0x55 +/* Define for MXT_PROCI_TOUCHSUPPRESSION_T42 */ +#define MXT_T42_MSG_TCHSUP BIT(0) + /* T100 Multiple Touch Touchscreen */ #define MXT_T100_CTRL 0 #define MXT_T100_CFG1 1 @@ -323,6 +326,8 @@ struct mxt_data { u8 T9_reportid_max; u16 T18_address; u8 T19_reportid; + u8 T42_reportid_min; + u8 T42_reportid_max; u16 T44_address; u8 T48_reportid; u8 T100_reportid_min; @@ -979,6 +984,17 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message) data->update_input = true; } +static void mxt_proc_t42_messages(struct mxt_data *data, u8 *msg) +{ + struct device *dev = &data->client->dev; + u8 status = msg[1]; + + if (status & MXT_T42_MSG_TCHSUP) + dev_dbg(dev, "T42 suppress\n"); + else + dev_dbg(dev, "T42 normal\n"); +} + static int mxt_proc_t48_messages(struct mxt_data *data, u8 *msg) { struct device *dev = &data->client->dev; @@ -1006,6 +1022,9 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message) if (report_id == data->T6_reportid) { mxt_proc_t6_messages(data, message); + } else if (report_id >= data->T42_reportid_min + && report_id <= data->T42_reportid_max) { + mxt_proc_t42_messages(data, message); } else if (report_id == data->T48_reportid) { mxt_proc_t48_messages(data, message); } else if (!data->input_dev) { @@ -1686,6 +1705,8 @@ static void mxt_free_object_table(struct mxt_data *data) data->T9_reportid_max = 0; data->T18_address = 0; data->T19_reportid = 0; + data->T42_reportid_min = 0; + data->T42_reportid_max = 0; data->T44_address = 0; data->T48_reportid = 0; data->T100_reportid_min = 0; @@ -1763,6 +1784,10 @@ static int mxt_parse_object_table(struct mxt_data *data, case MXT_SPT_COMMSCONFIG_T18: data->T18_address = object->start_address; break; + case MXT_PROCI_TOUCHSUPPRESSION_T42: + data->T42_reportid_min = min_id; + data->T42_reportid_max = max_id; + break; case MXT_SPT_MESSAGECOUNT_T44: data->T44_address = object->start_address; break; From patchwork Fri May 8 05:56:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4DA3C47247 for ; Fri, 8 May 2020 05:57:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD02520CC7 for ; Fri, 8 May 2020 05:57:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727092AbgEHF5d (ORCPT ); Fri, 8 May 2020 01:57:33 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:45858 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726701AbgEHF5c (ORCPT ); Fri, 8 May 2020 01:57:32 -0400 IronPort-SDR: nOVsoYWfBGgfOnXTTd9YlLU1hkpZVQrg4ZQS0uRLajEcCPyLTkNOIGa0hSVMiwO8DSlpeh33pz Jm0oW6FSeE72yKmtZyE7pRQ3VBIdy8HHfBdHZ+8t2Vq118n7iSWCH7aMC9M2gzTRTYbw4oFfBZ ab/NJMXLxA2r28JlhCr18SoL1VoZM3r+ca91Lv44KPI/AL7sk4Wt9kN1yJ1dAcnp9vjpLqpDDA j17d2bIEE3Xq0vvDb2J7oOHMRkgYfbrI7e6vd1o5J2ulih+LbKcX3Ck8QlryuplY1JghYVs7Ei LPQ= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48710560" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 07 May 2020 21:57:29 -0800 IronPort-SDR: /1c6/32l0lRKDPvHVXozzktU2zipPl9jaIDsxFCqC5cXqEneB526law/WPyFoVUBckwt5ubvgd GT9gDmeESXe/qERNrmA2R+yq3miF8llHvFJeDnQW1bXrP9Hef6yLWlb0g9B4VKWc6qdPNgllyO altkADSa03lv/RzVs+8JRhGdjiY05BN4cFhqhCny/iq2O9FJ/oA730lPeI3OElQHjFRXPgzNhE oTy0K6jBBl/HuQYqT+lP7oJyKeVe251RJCIaw85WOewVVUamVCUDmQ0FPQBPEq00rROSw0FGnv Q48= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 07/56] Input: atmel_mxt_ts - implement T9 vector/orientation support Date: Thu, 7 May 2020 22:56:07 -0700 Message-ID: <20200508055656.96389-8-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer The atmel touch messages contain orientation information as a byte in a packed format which can be passed straight on to Android if the input device configuration is correct. This requires vector reports to be enabled in maXTouch config (zero DISVECT bit 3 in T9 CTRL field) Android converts the format in InputReader.cpp, search for ORIENTATION_CALIBRATION_VECTOR. Signed-off-by: Nick Dyer Acked-by: Benson Leung Acked-by: Yufeng Shen (cherry picked from ndyer/linux/for-upstream commit a6f0ee919d2631678169b23fb18f55b6dbabcd4c) Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index f6465edaa57e..df2e0ba76e63 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -817,6 +817,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message) int y; int area; int amplitude; + u8 vector; id = message[0] - data->T9_reportid_min; status = message[1]; @@ -831,9 +832,10 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message) area = message[5]; amplitude = message[6]; + vector = message[7]; dev_dbg(dev, - "[%u] %c%c%c%c%c%c%c%c x: %5u y: %5u area: %3u amp: %3u\n", + "[%u] %c%c%c%c%c%c%c%c x: %5u y: %5u area: %3u amp: %3u vector: %02X\n", id, (status & MXT_T9_DETECT) ? 'D' : '.', (status & MXT_T9_PRESS) ? 'P' : '.', @@ -843,7 +845,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message) (status & MXT_T9_AMP) ? 'A' : '.', (status & MXT_T9_SUPPRESS) ? 'S' : '.', (status & MXT_T9_UNGRIP) ? 'U' : '.', - x, y, area, amplitude); + x, y, area, amplitude, vector); input_mt_slot(input_dev, id); @@ -868,6 +870,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message) input_report_abs(input_dev, ABS_MT_POSITION_Y, y); input_report_abs(input_dev, ABS_MT_PRESSURE, amplitude); input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, area); + input_report_abs(input_dev, ABS_MT_ORIENTATION, vector); } else { /* Touch no longer active, close out slot */ input_mt_report_slot_inactive(input_dev); @@ -2180,8 +2183,9 @@ static int mxt_initialize_input_device(struct mxt_data *data) 0, 255, 0, 0); } - if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 && - data->t100_aux_vect) { + if (data->multitouch == MXT_TOUCH_MULTI_T9 || + (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 && + data->t100_aux_vect)) { input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 255, 0, 0); } From patchwork Fri May 8 05:56:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2670C47247 for ; Fri, 8 May 2020 05:58:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A61B120CC7 for ; Fri, 8 May 2020 05:58:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgEHF5k (ORCPT ); Fri, 8 May 2020 01:57:40 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38668 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbgEHF5h (ORCPT ); Fri, 8 May 2020 01:57:37 -0400 IronPort-SDR: iq+Xz+pkTfcg99ODonemdncCofNRYnrtv6cBmTTnoBNSNcgbXQnUBaMUWx3A5vz169+n1pSHQK yqdlboIhuX63FzBW5RPfEJY05+A4uTw65hPiooqj4Zn9AsWpLpi9mJ5PtyfigdNwA67x3ZdeXJ XId3Kn82osJvcl2j+LaIjr7FZ3BY448cYlvWEsAq4zPXmDDfF0p5MUScTxt9QN4RuZ1eW9qfQT B26y83fE92Bobwa+qHtzbhrZGT4NLfrJ56oVxcDYhFmjGQtshcdZguNwpJuBiWy3S+59SYpU4Z LY4= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670052" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 21:57:35 -0800 IronPort-SDR: Jht1gashke8s99GRPq4ALeztPIodd5iUctQdzP1M7u4hRj/ISCzP8cOu5+8l2cBk7WqSdKPPb1 yxsUkfZAX2efAhS59sSe/IqZH5/zK4P3sAewCvmX1ZnQ5gQL2Gnrbr9nXgD319DUn2TtXEV/FK jIuAnbXEndG32vS9Ggsq2RzfcnOy+X2pyY23rh36DbrIvPcVVHgp6bLp1lclb/0ml2S0IzbEtR WCNYtTz0g/iC5FNdP0v+llCuFtIhCyKpKPuouzHIIQPxkibmfxzvcPQZ1blSco/Cuqh8ufS2Vw cgg= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 09/56] Input: atmel_mxt_ts - handle reports from T47 Stylus object Date: Thu, 7 May 2020 22:56:09 -0700 Message-ID: <20200508055656.96389-10-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer This patch handles reports from T47 Stylus object Signed-off-by: Nick Dyer Acked-by: Benson Leung Acked-by: Yufeng Shen (cherry picked from ndyer/linux/for-upstream commit 56405a5ea08eb34cfe83f3121867c9de0a5c48c1) Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index d05249b02781..ba58cdd5b76d 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -823,6 +823,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message) int area; int amplitude; u8 vector; + int tool; id = message[0] - data->T9_reportid_min; status = message[1]; @@ -836,6 +837,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message) y >>= 2; area = message[5]; + amplitude = message[6]; vector = message[7]; @@ -865,12 +867,20 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message) mxt_input_sync(data); } + /* A size of zero indicates touch is from a linked T47 Stylus */ + if (area == 0) { + area = MXT_TOUCH_MAJOR_DEFAULT; + tool = MT_TOOL_PEN; + } else { + tool = MT_TOOL_FINGER; + } + /* if active, pressure must be non-zero */ if (!amplitude) amplitude = MXT_PRESSURE_DEFAULT; /* Touch active */ - input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 1); + input_mt_report_slot_state(input_dev, tool, 1); input_report_abs(input_dev, ABS_MT_POSITION_X, x); input_report_abs(input_dev, ABS_MT_POSITION_Y, y); input_report_abs(input_dev, ABS_MT_PRESSURE, amplitude); From patchwork Fri May 8 05:56:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD051C47247 for ; Fri, 8 May 2020 05:57:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B82DA20CC7 for ; Fri, 8 May 2020 05:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727785AbgEHF5p (ORCPT ); Fri, 8 May 2020 01:57:45 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38668 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727778AbgEHF5o (ORCPT ); Fri, 8 May 2020 01:57:44 -0400 IronPort-SDR: FhaTmXxFBQFflkwhsPHp6bNpM2nqng0ezLThyFgFSN1JBK1dTEMAtjLyz91P63ipkjbAj1Rqzs ruVH0kPS9iURyINdF2tee70V3BcK7zyC3rrgjEesupMVXJ45lPT3V0q/iH8RZIssiQyP1T3AJo s6U/wyysnvFRo/u+HVMB0azBlz7DEXDAF2LLdagTdcRFFLbQwnJFuXZzeaEccsej5xW7rot05E C/NSKiqSfmKvBIUqMVzS3K6HgtiXtJ59A9bneE7vI+CsriMRKJ57sR41k42csokf4HcW19lJyX /Vc= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670063" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 21:57:43 -0800 IronPort-SDR: TmXZ0tivA8Gceq1YeDeZ03sHiq8QqHiuj8NIa1BU944p9m3vfoVraf5Smr4kQnPjILez0ntZlq 69xvfRriP/Cp3dujNkx4ge2iUQAyp97hpHj3PFNg7nk9zjVKXWOPmKs2re84PdfuWNuLeiheez nRq+0olhpPxDziZKZUzzhnx/mINZkMOIJN28aVXJ4+0pjsKa38OelABh6J+ieTlww6j+3NiwLV LAw1QNUUIL2mlcg06mW2cjPM3hWmYpURDD7Oodv1XYO/67Zh50ZG+G/8ZI8SKkUl+yb2Om1J3y BmA= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 11/56] Input: atmel_mxt_ts - add debug for T92 gesture and T93 touch seq msgs Date: Thu, 7 May 2020 22:56:11 -0700 Message-ID: <20200508055656.96389-12-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Karl Tsou output T92 gesture and T93 touch sequence messages. Signed-off-by: Karl Tsou Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit cb98986f8342107bf4a536aed4160b20839e97c1) Signed-off-by: George G. Davis Reported-by: kbuild test robot [jiada: changed dev_debug() to dev_info()] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 63db8b66eb67..6126bb8a7acc 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -71,6 +71,8 @@ #define MXT_SPT_MESSAGECOUNT_T44 44 #define MXT_SPT_CTECONFIG_T46 46 #define MXT_SPT_DYNAMICCONFIGURATIONCONTAINER_T71 71 +#define MXT_PROCI_SYMBOLGESTUREPROCESSOR 92 +#define MXT_PROCI_TOUCHSEQUENCELOGGER 93 #define MXT_TOUCH_MULTITOUCHSCREEN_T100 100 #define MXT_PROCI_ACTIVESTYLUS_T107 107 @@ -349,6 +351,10 @@ struct mxt_data { u8 T42_reportid_max; u16 T44_address; u8 T48_reportid; + u16 T92_address; + u8 T92_reportid; + u16 T93_address; + u8 T93_reportid; u8 T100_reportid_min; u8 T100_reportid_max; u16 T107_address; @@ -1113,6 +1119,24 @@ static int mxt_proc_t48_messages(struct mxt_data *data, u8 *msg) return 0; } +static void mxt_proc_t92_messages(struct mxt_data *data, u8 *msg) +{ + struct device *dev = &data->client->dev; + u8 status = msg[1]; + + dev_info(dev, "T92 long stroke LSTR=%d %d\n", + (status & 0x80) ? 1 : 0, + status & 0x0F); +} + +static void mxt_proc_t93_messages(struct mxt_data *data, u8 *msg) +{ + struct device *dev = &data->client->dev; + u8 status = msg[1]; + + dev_info(dev, "T93 report double tap %d\n", status); +} + static int mxt_proc_message(struct mxt_data *data, u8 *message) { u8 report_id = message[0]; @@ -1145,6 +1169,10 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message) } else if (report_id >= data->T15_reportid_min && report_id <= data->T15_reportid_max) { mxt_proc_t15_messages(data, message); + } else if (report_id == data->T92_reportid) { + mxt_proc_t92_messages(data, message); + } else if (report_id == data->T93_reportid) { + mxt_proc_t93_messages(data, message); } else { mxt_dump_message(data, message); } @@ -1814,6 +1842,10 @@ static void mxt_free_object_table(struct mxt_data *data) data->T42_reportid_max = 0; data->T44_address = 0; data->T48_reportid = 0; + data->T92_reportid = 0; + data->T92_address = 0; + data->T93_reportid = 0; + data->T93_address = 0; data->T100_reportid_min = 0; data->T100_reportid_max = 0; data->max_reportid = 0; @@ -1906,6 +1938,14 @@ static int mxt_parse_object_table(struct mxt_data *data, case MXT_PROCG_NOISESUPPRESSION_T48: data->T48_reportid = min_id; break; + case MXT_PROCI_SYMBOLGESTUREPROCESSOR: + data->T92_reportid = min_id; + data->T92_address = object->start_address; + break; + case MXT_PROCI_TOUCHSEQUENCELOGGER: + data->T93_reportid = min_id; + data->T93_address = object->start_address; + break; case MXT_TOUCH_MULTITOUCHSCREEN_T100: data->multitouch = MXT_TOUCH_MULTITOUCHSCREEN_T100; data->T100_reportid_min = min_id; From patchwork Fri May 8 05:56:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE30FC4724C for ; Fri, 8 May 2020 05:57:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDDD220870 for ; Fri, 8 May 2020 05:57:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727799AbgEHF5u (ORCPT ); Fri, 8 May 2020 01:57:50 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:45878 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727778AbgEHF5t (ORCPT ); Fri, 8 May 2020 01:57:49 -0400 IronPort-SDR: kX6JCWvDVW0VN1nCTsUudgKqQQZ0jAVhrVz/crWGm4YPGd2uExirw3jpMgydyAa4r0Czv4A/Pz BB6N1Ng/KwIrP1p/MBh7AyyuUu8gkuGLJ431M9jaJW+855Ypy9svXe3/unb+VvrgfDJ1IFOEPH mj9t/q0bzzjl4tQgVj4ypR5bqMzPTGrkDEKqRWk40jF3Kedd3wJo4l9Ergb2DzWZwy2rIxxbl/ fadqPSRKTJwOUXsIgkWkuW2e0xQDdM6T91ojP+OTgaVKZ0SAeUbDv1pqF2l7hryrXZNvdDJaYs LDg= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48710574" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 07 May 2020 21:57:48 -0800 IronPort-SDR: ZW2wFzsxEUQnQNnXPaEOTT6B1gWmvefbhow17aKRHW//13MXJH24cUbBSCZ24WsZpz1m+owZ/8 DjKtL1fqbS0f1b3sSD5ln6mRFgJt5QqS4CCuKoEcUMMVh5Qj1PA209/W+TtpFferxMIWMtfYBr SLUG1QuIg9dSL7hHns6owsaNfV112SLRJdwurj0kzDf9vmR6k0XkGNPEutpymPNxw9ID8y/abP LkouvykyaU/2MS5WcW6wKqQAWZuVYVUisoyjg4dfXtgCv7MDMnAdty2wLkfaCXqVVQhSw6FF/n hX0= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 12/56] Input: atmel_mxt_ts - release touch state during suspend Date: Thu, 7 May 2020 22:56:12 -0700 Message-ID: <20200508055656.96389-13-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer If fingers are down as the MXT chip goes into suspend it does not send a lift message. In addition, it may not complete its final measurement cycle immediately, which means touch messages may be received by the interrupt handler after mxt_stop() has completed. So: - disable irq during suspend - flush any messages created after suspend - tell app layer that slots were released at suspend Signed-off-by: Nick Dyer Acked-by: Benson Leung Acked-by: Yufeng Shen (cherry picked from ndyer/linux/for-upstream commit 26794433086dbc7dea18d2f6a1c8d61ab25bcfda) [gdavis: Resolve forward port conflicts due to applying upstream commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform data support").] Signed-off-by: George G. Davis [gdavis: Squash fix from Dirk Behme: - Input: atmel_mxt_ts - remove superfluous data->suspended] Signed-off-by: Dirk Behme --- drivers/input/touchscreen/atmel_mxt_ts.c | 52 ++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 6126bb8a7acc..9aafed92db9c 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -372,6 +372,9 @@ struct mxt_data { unsigned int t19_num_keys; enum mxt_suspend_mode suspend_mode; + + /* Indicates whether device is in suspend */ + bool suspended; }; struct mxt_vb2_buffer { @@ -1151,10 +1154,10 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message) mxt_proc_t42_messages(data, message); } else if (report_id == data->T48_reportid) { mxt_proc_t48_messages(data, message); - } else if (!data->input_dev) { + } else if (!data->input_dev || data->suspended) { /* - * Do not report events if input device - * is not yet registered. + * Do not report events if input device is not + * yet registered or returning from suspend */ mxt_dump_message(data, message); } else if (report_id >= data->T9_reportid_min && @@ -3135,6 +3138,11 @@ static int mxt_load_fw(struct device *dev, const char *fn) if (ret) goto release_firmware; + if (data->suspended) { + enable_irq(data->irq); + data->suspended = false; + } + if (!data->in_bootloader) { /* Change to the bootloader mode */ data->in_bootloader = true; @@ -3306,8 +3314,27 @@ static void mxt_sysfs_remove(struct mxt_data *data) sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); } +static void mxt_reset_slots(struct mxt_data *data) +{ + struct input_dev *input_dev = data->input_dev; + int id; + + if (!input_dev) + return; + + for (id = 0; id < data->num_touchids; id++) { + input_mt_slot(input_dev, id); + input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 0); + } + + mxt_input_sync(data); +} + static void mxt_start(struct mxt_data *data) { + if (!data->suspended || data->in_bootloader) + return; + switch (data->suspend_mode) { case MXT_SUSPEND_T9_CTRL: mxt_soft_reset(data); @@ -3320,16 +3347,29 @@ static void mxt_start(struct mxt_data *data) case MXT_SUSPEND_DEEP_SLEEP: default: + /* + * Discard any touch messages still in message buffer + * from before chip went to sleep + */ + mxt_process_messages_until_invalid(data); + mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN); /* Recalibrate since chip has been in deep sleep */ mxt_t6_command(data, MXT_COMMAND_CALIBRATE, 1, false); + + mxt_acquire_irq(data); break; } + + data->suspended = false; } static void mxt_stop(struct mxt_data *data) { + if (data->suspended || data->in_bootloader) + return; + switch (data->suspend_mode) { case MXT_SUSPEND_T9_CTRL: /* Touch disable */ @@ -3339,9 +3379,15 @@ static void mxt_stop(struct mxt_data *data) case MXT_SUSPEND_DEEP_SLEEP: default: + disable_irq(data->irq); + mxt_set_t7_power_cfg(data, MXT_POWER_CFG_DEEPSLEEP); + + mxt_reset_slots(data); break; } + + data->suspended = true; } static int mxt_input_open(struct input_dev *dev) From patchwork Fri May 8 05:56:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207866 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB521C38A2A for ; Fri, 8 May 2020 05:57:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA01F208D6 for ; Fri, 8 May 2020 05:57:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727811AbgEHF56 (ORCPT ); Fri, 8 May 2020 01:57:58 -0400 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:21990 "EHLO esa3.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727827AbgEHF55 (ORCPT ); Fri, 8 May 2020 01:57:57 -0400 IronPort-SDR: irrm295E0c9Xcdard16jgQaP8LPdUNsHDpT21YYQpV8pChKX4ms0YwGfqkwpruoouVPeicLUME R75W4fWFMfwO2DaXHuyboW+aem+kJR484U/HsYNbeQHwupegYkJTK785thc9o4y2jq70bCg6Mh O1hgCTCcSMW+1OUjAFWQVhTIJuzRKJZgQljPcRUuOaB29X4YNJQEijrznOqedFY2u8eIdOD6rs vPNLoZYaB1SMeWI3znH8uTU0pPqQutHU0RqBGBGQ8d3EzN1b0QrfrOCqkKkRoLd7xMsiu8r//+ NmQ= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48651927" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 07 May 2020 21:57:55 -0800 IronPort-SDR: WGe2HocbVhSizWETEQCGM7uqV2yzESxFmmzY/FmLF4QETENikahxeDzGIx3t448LMw00YB/1EN wMAs0n9Rgi2CvNMriTT9KR4yLmdjxFI/8i4JjroVNMIimy48RCv+tuNE4BR/PUWw7JbI8oST+/ sfj5FLs+C+VXA/61nVXF25MrEC/u3mtyC0PCuq3EhX073tVFg+4wwrGVMVFsDcjyVLA/LUeLFe 7/bQmJTwZ4Deq+F+ur4B5KZCO4UcnxrXFqldivGPW8JlEHa/cGENZ5HSqoCgTdwUemuAG+YV6t lco= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 14/56] Input: atmel_mxt_ts - add regulator control support Date: Thu, 7 May 2020 22:56:14 -0700 Message-ID: <20200508055656.96389-15-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer Allow the driver to optionally manage enabling/disable power to the touch controller itself. If the regulators are not present then use the deep sleep power mode instead. For a correct power on sequence, it is required that we have control over the RESET line. Signed-off-by: Nick Dyer Acked-by: Benson Leung Acked-by: Yufeng Shen (cherry picked from ndyer/linux/for-upstream commit 14052b61bb66c2f2283c00e733e131be7a9b8bfc) [gdavis: Resolve forward port conflicts due to v4.14-rc1 commmit f657b00df22e ("Input: atmel_mxt_ts - add support for reset line") and applying upstream commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform data support").] Signed-off-by: George G. Davis [gdavis: Squash fixes from Dirk Behme: - Input: atmel_mxt_ts - in failure case disable the regulator - Input: atmel_mxt_ts - disable only enabled regulators - Input: atmel_mxt_ts - use devm_regulator_get()] Signed-off-by: Dirk Behme [jiada: Replace white-spaces with tab for MXT_CHG_DELAY separate Documentation/ and include/dt-bindings/ portion change to another commit] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 130 +++++++++++++++++++++-- 1 file changed, 121 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 9aafed92db9c..ef8baf64659e 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -26,10 +26,12 @@ #include #include #include +#include #include #include #include #include +#include /* Firmware files */ #define MXT_FW_NAME "maxtouch.fw" @@ -215,6 +217,9 @@ enum t100_type { #define MXT_CRC_TIMEOUT 1000 /* msec */ #define MXT_FW_RESET_TIME 3000 /* msec */ #define MXT_FW_CHG_TIMEOUT 300 /* msec */ +#define MXT_REGULATOR_DELAY 150 /* msec */ +#define MXT_CHG_DELAY 100 /* msec */ +#define MXT_POWERON_DELAY 150 /* msec */ /* Command to unlock bootloader */ #define MXT_UNLOCK_CMD_MSB 0xaa @@ -275,11 +280,6 @@ enum v4l_dbg_inputs { MXT_V4L_INPUT_MAX, }; -enum mxt_suspend_mode { - MXT_SUSPEND_DEEP_SLEEP = 0, - MXT_SUSPEND_T9_CTRL = 1, -}; - /* Config update context */ struct mxt_cfg { u8 *raw; @@ -333,6 +333,8 @@ struct mxt_data { u8 stylus_aux_pressure; u8 stylus_aux_peak; bool use_retrigen_workaround; + struct regulator *reg_vdd; + struct regulator *reg_avdd; /* Cached parameters from object table */ u16 T5_address; @@ -2073,6 +2075,94 @@ static int mxt_read_info_block(struct mxt_data *data) return error; } +static void mxt_regulator_enable(struct mxt_data *data) +{ + int error; + + if (!data->reg_vdd || !data->reg_avdd) + return; + + gpiod_set_value(data->reset_gpio, 0); + + error = regulator_enable(data->reg_vdd); + if (error) + return; + + error = regulator_enable(data->reg_avdd); + if (error) { + regulator_disable(data->reg_vdd); + return; + } + + /* + * According to maXTouch power sequencing specification, RESET line + * must be kept low until some time after regulators come up to + * voltage + */ + msleep(MXT_REGULATOR_DELAY); + gpiod_set_value(data->reset_gpio, 1); + msleep(MXT_CHG_DELAY); + +retry_wait: + reinit_completion(&data->bl_completion); + data->in_bootloader = true; + error = mxt_wait_for_completion(data, &data->bl_completion, + MXT_POWERON_DELAY); + if (error == -EINTR) + goto retry_wait; + + data->in_bootloader = false; +} + +static void mxt_regulator_disable(struct mxt_data *data) +{ + if (!data->reg_vdd || !data->reg_avdd) + return; + + if (regulator_is_enabled(data->reg_vdd)) + regulator_disable(data->reg_vdd); + if (regulator_is_enabled(data->reg_avdd)) + regulator_disable(data->reg_avdd); +} + +static int mxt_probe_regulators(struct mxt_data *data) +{ + struct device *dev = &data->client->dev; + int error; + + /* Must have reset GPIO to use regulator support */ + if (!data->reset_gpio) { + error = -EINVAL; + goto fail; + } + + data->reg_vdd = devm_regulator_get(dev, "vdd"); + if (IS_ERR(data->reg_vdd)) { + error = PTR_ERR(data->reg_vdd); + dev_err(dev, "Error %d getting vdd regulator\n", error); + goto fail; + } + + data->reg_avdd = devm_regulator_get(dev, "avdd"); + if (IS_ERR(data->reg_avdd)) { + error = PTR_ERR(data->reg_avdd); + dev_err(dev, "Error %d getting avdd regulator\n", error); + goto fail_release; + } + + mxt_regulator_enable(data); + + dev_dbg(dev, "Initialised regulators\n"); + return 0; + +fail_release: + regulator_put(data->reg_vdd); +fail: + data->reg_vdd = NULL; + data->reg_avdd = NULL; + return error; +} + static int mxt_read_t9_resolution(struct mxt_data *data) { struct i2c_client *client = data->client; @@ -3139,7 +3229,12 @@ static int mxt_load_fw(struct device *dev, const char *fn) goto release_firmware; if (data->suspended) { - enable_irq(data->irq); + if (data->suspend_mode == MXT_SUSPEND_REGULATOR) + mxt_regulator_enable(data); + + if (data->suspend_mode == MXT_SUSPEND_DEEP_SLEEP) + enable_irq(data->irq); + data->suspended = false; } @@ -3345,6 +3440,11 @@ static void mxt_start(struct mxt_data *data) MXT_TOUCH_MULTI_T9, MXT_T9_CTRL, 0x83); break; + case MXT_SUSPEND_REGULATOR: + enable_irq(data->irq); + mxt_regulator_enable(data); + break; + case MXT_SUSPEND_DEEP_SLEEP: default: /* @@ -3377,6 +3477,12 @@ static void mxt_stop(struct mxt_data *data) MXT_TOUCH_MULTI_T9, MXT_T9_CTRL, 0); break; + case MXT_SUSPEND_REGULATOR: + disable_irq(data->irq); + mxt_regulator_disable(data); + mxt_reset_slots(data); + break; + case MXT_SUSPEND_DEEP_SLEEP: default: disable_irq(data->irq); @@ -3469,6 +3575,8 @@ static int mxt_parse_device_properties(struct mxt_data *data) data->t15_num_keys = n_keys; } + device_property_read_u32(dev, "atmel,suspend-mode", + &data->suspend_mode); return 0; } @@ -3555,14 +3663,18 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) return error; } - disable_irq(client->irq); - - if (data->reset_gpio) { + if (data->suspend_mode == MXT_SUSPEND_REGULATOR) { + error = mxt_probe_regulators(data); + if (error) + return error; + } else if (data->reset_gpio) { msleep(MXT_RESET_GPIO_TIME); gpiod_set_value(data->reset_gpio, 1); msleep(MXT_RESET_INVALID_CHG); } + disable_irq(data->irq); + error = mxt_initialize(data); if (error) return error; From patchwork Fri May 8 05:56:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207864 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 427B0C4724C for ; Fri, 8 May 2020 05:58:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 273E320CC7 for ; Fri, 8 May 2020 05:58:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727845AbgEHF6N (ORCPT ); Fri, 8 May 2020 01:58:13 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:2686 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727839AbgEHF6I (ORCPT ); Fri, 8 May 2020 01:58:08 -0400 IronPort-SDR: SHi+DY//0g+rfhPMbYviJCg6GCX9IXkEoKyG9V97MTnOae+Faq4R6ef5WfHtuiD+J65pNRmxXP XHem2Vd4lXwHM89nF8XIq8crska4ZtoZSe2V3NnFehFpZtgFk8MOP2zQqg97HRtEYAGCHiET5i ghtdGRGC23NPVlsnvXM5lKukyjV9cK6n6DGjIxVrWRfReXg74c/SIsjGlSTW2tGknlrQpntzXu cvQ3NMId+MlFMCfufv4oaqQr34Y5ybhLbwZR/UX74DqXG+2PwuzW6yxoa81Fw0zL0McJh15TIv THA= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48589076" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 07 May 2020 21:58:06 -0800 IronPort-SDR: O3oGVhCAJWCST6rYedjqaU7hRNEMHGFbZGrKrueSnFTg/nU/DW6e+cGs+k8ec3TjLJ43NWkpS1 u33M5gmqlL5cxzrOUqprt/35lwFCnOLBGLmGWuAK9yJmsFkMvYiYKNU6g0bRqrVtTYy+qoyp5z Y0ET+TPOM+orWHxH+3c7U3foaPouiMaWCsEkJ1Tb3ePbG18cfbxkpaoja9FoJlSwNzfyTpg01Q d7jz4GwplT5fI2N+Pb/HWdZwsdPUuHkm87KOaVrC1+ct+sO/jgQ6rM1LgLeDWAkgbyi0zwqhVv U3s= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 17/56] Input: atmel_mxt_ts: Rename mxt_fw_version_show to fw_version_show Date: Thu, 7 May 2020 22:56:17 -0700 Message-ID: <20200508055656.96389-18-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Rename mxt_fw_version_show to fw_version_show to address checkpatch warning Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 0e30ff372a43..b2a37a9597f3 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3104,8 +3104,8 @@ static int mxt_configure_objects(struct mxt_data *data, } /* Firmware Version is returned as Major.Minor.Build */ -static ssize_t mxt_fw_version_show(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t fw_version_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct mxt_data *data = dev_get_drvdata(dev); struct mxt_info *info = data->info; @@ -3403,7 +3403,7 @@ static const struct attribute_group mxt_fw_attr_group = { .attrs = mxt_fw_attrs, }; -static DEVICE_ATTR(fw_version, S_IRUGO, mxt_fw_version_show, NULL); +static DEVICE_ATTR_RO(fw_version); static DEVICE_ATTR(hw_version, S_IRUGO, mxt_hw_version_show, NULL); static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL); From patchwork Fri May 8 05:56:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2ED4C47247 for ; Fri, 8 May 2020 05:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A4F421582 for ; Fri, 8 May 2020 05:58:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727935AbgEHF6X (ORCPT ); Fri, 8 May 2020 01:58:23 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:2693 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727917AbgEHF6W (ORCPT ); Fri, 8 May 2020 01:58:22 -0400 IronPort-SDR: ZpqTchIRYgUBl24PfM/5caqAn/X2791qnf2VUApgTU50eTBH4r8OWu3RhKsakgUr6ePfx1BZej ywY0fI2hJ852mbQr0eSi3kHFMSV1kNR6ItaO9EY4McbyhNwEv/F7NJe/J7mhPmxuphL2UYisR0 IEVVrlWNfbRrVl+eXli+fVeQFCQsuRBqmvpWomsmv4joIrG3Axn/yZl6v/Wg4UBO7mgrgC/str /GOSDIBUVdSW1vwsI4EpH4uEW88GhE+Pf0lXTzGjdeM/LIBBEKHv0a+Bq2IjVpC+BzDNpiPoy7 Mvg= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48589089" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 07 May 2020 21:58:21 -0800 IronPort-SDR: QpgF3jsE9EDTAHw+EahVPXT5luom99XRRZBfLm//vN7NVQZqBHalhffWiYMHcUNGm7ft1ykpCH nje7qvn0m9ZtM0XdIAABou4y0tWtFViaLzDZjHC33qJzLee7TdlwMJMnmYMEQppclaT+/5evrk OGe5iLBp+cvNVuEvdtXkVMNTZJmsrOyRxcnhExY44qZOBIwtsEUttG7j2pys+uWfUiXEJyRgdx oNK75w5nsX3qvoig9e9WwHnVHsQb39ZySqDWrWKcSwLKInk+ZLHs5NXWV7difoIu5h14Srr/Q9 A9w= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 21/56] Input: atmel_mxt_ts - check data->input_dev is not null in mxt_input_sync() Date: Thu, 7 May 2020 22:56:21 -0700 Message-ID: <20200508055656.96389-22-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Janus Cheng * Symptom: if update_fw and update_cfg, kernel panic occurs. * Reproducibility: 10% * Root Cause: - If update_fw, the T6 will send a CFG_ERR message periodically. - After that, update_cfg process begin, the mxt_update_cfg_store() will invoke mxt_free_input_device() and nullify data->input_dev. - The CFG_ERR message will trigger mxt_interrupt(), and mxt_input_sync() will be invoked by mxt_process_messages_t44(). And mxt_input_sync() references a NULL data->input_dev and kernel panic occurs. TrackerRMS TKT-004235 Signed-off-by: Janus Cheng Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit c909ada856861f305653b127db3ea0fa60264331) [gdavis: Resolve forward port conflicts due to applying upstream commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform data support").] Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 503e70603a67..85b903b8d5c9 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -838,9 +838,11 @@ static void mxt_input_button(struct mxt_data *data, u8 *message) static void mxt_input_sync(struct mxt_data *data) { - input_mt_report_pointer_emulation(data->input_dev, - data->t19_num_keys); - input_sync(data->input_dev); + if (data->input_dev) { + input_mt_report_pointer_emulation(data->input_dev, + data->t19_num_keys); + input_sync(data->input_dev); + } } static void mxt_proc_t9_message(struct mxt_data *data, u8 *message) From patchwork Fri May 8 05:56:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9FA8C38A2A for ; Fri, 8 May 2020 05:58:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD4412070B for ; Fri, 8 May 2020 05:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727917AbgEHF6h (ORCPT ); Fri, 8 May 2020 01:58:37 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38715 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727964AbgEHF6d (ORCPT ); Fri, 8 May 2020 01:58:33 -0400 IronPort-SDR: KgNruznJZ/0w0iVfdO7ogZzeAS2cIw1TzSLnFA1oREOHYxb9xQgkpg/Oe0T7+clGDM+Zudh/Q2 p7myzX03cDBG8B9mg+Q8mWEioR+ylzMiwXRObiDm7BxQgjobPUSae4VyTJFOlLPctzS2bJ5sBV EkrBcshiQDMZCRT/BxyLMaXJRmKGW5mmmhuhCAgVe6hZdGHng9+wejIsmsP+h/RI3mxRZdAa3m IRwBMc7HrIcvBPVIvtZQEzsBkYGUU8L0mj81+ZtWDfKw8Edc6NWGiI+fFCPkfu8do2BMFCohbg 0eQ= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670091" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 21:58:31 -0800 IronPort-SDR: aYayti0Wg97Eu5aBqHeYbAMonggtq/Qbg5AkRD9aq/IKmgX1BZVhEJlk4x6NuqkqN3HpcbgBQM yoRDpphgUgTmxUJoWByuqssjn+lNtSZhZwDGIU9E5d4oo+K7VKSxuHgHLwmE2PcPvQUvYpb762 lqhKpOis3XnvLVoXumNdwlDz6ZRXJMQicjl+kIws6KWGTskj06je8VWdltM9AIcw6upNigVECM Oz22NTcAq8k5TxnE13BTPfieh3GpC2n0dJc1pHJhD70ZPFuN4xVO58Z/A7lvXzJ8GxUwwtnVxu OwI= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 24/56] dt-bindings: input: atmel: support to specify input name Date: Thu, 7 May 2020 22:56:24 -0700 Message-ID: <20200508055656.96389-25-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Support to specify input name Signed-off-by: Jiada Wang --- Documentation/devicetree/bindings/input/atmel,maxtouch.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt index 4705d7753c54..f084afa1660e 100644 --- a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt +++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt @@ -43,6 +43,8 @@ Optional properties for main touchpad device: - atmel,cfg_name: Provide name of configuration file in OBP_RAW format. This will be downloaded from the firmware loader on probe to the device. +- atmel,input_name: Override name of input device from the default. + Example: touch@4b { From patchwork Fri May 8 05:56:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C1CBC4724C for ; Fri, 8 May 2020 05:58:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1697B2070B for ; Fri, 8 May 2020 05:58:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727964AbgEHF6j (ORCPT ); Fri, 8 May 2020 01:58:39 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38715 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbgEHF6h (ORCPT ); Fri, 8 May 2020 01:58:37 -0400 IronPort-SDR: k4w5bE0IfG/9q0oozAj0dg7WD4gOnWpnkfigWXICqFYbIxaUxLAZwRkbIRFGIG1hFU3re9zq2F tePF+0Ja51GQ/kthVrxNif6soi66qPSe8QNmQn4CkOim2PsFJ//TUhW2x4xfksoqMKIUSJulyz JJQGsS+01X58W6oe/mpidjFm2YRUxTeFNruzvxcpMrTqCgw07OPokIV9T5oDiHyOoc8HoOtmT4 TlZ2xRxHzDBBodGUMYcMWbj7fABPWn6nxSmusOQduUyLK/ZXVICo7F/qZw3ucwoA8uzXeb4myw v3A= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670094" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 21:58:35 -0800 IronPort-SDR: gaOKQOPg0wMl4YVGAFmvieHGkAxL/K4e31nEbZnhxMELlNVcA/PHCoQw3xnAxpVQ33+mOFNxOl qwOZFb6PMFRiUo3ZruP/yovJ4lbaJMF5bU3tFPIRE9f+yR3dZ5RWj6r+Nl9uT1ZvOGtxza+sVY ebRIZGGoGcszokmqRxuSsVi+qpwsPfK89OkNHpNCsVgLv6tz/FmieTo/WZRcygmcpHJZF2y63K 7TJdTElbWaoN0gDe0UwZgTpQuTgprnZcO9ZOaEMcxbQlKFMFjPQTgX8ZFDEqcwCxRxhVI9a80X A9g= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 25/56] Input: atmel_mxt_ts - add config checksum attribute to sysfs Date: Thu, 7 May 2020 22:56:25 -0700 Message-ID: <20200508055656.96389-26-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: karl tsou Add config checksum attribute to sysfs Signed-off-by: karl tsou Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 03477477ddbe5dcad42853ab3f84166a8f807acf) [gdavis: Forward port and fix conflicts.] Signed-off-by: George G. Davis [jiada: Add commit description Rename mxt_config_crc_show to config_crc_show Replace DEVICE_ATTR with DEVICE_ATTR_RO] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index affd2bf32969..780850343089 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3124,6 +3124,15 @@ static int mxt_configure_objects(struct mxt_data *data, return error; } +/* Configuration crc check sum is returned as hex xxxxxx */ +static ssize_t config_crc_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mxt_data *data = dev_get_drvdata(dev); + + return scnprintf(buf, PAGE_SIZE, "%06x\n", data->config_crc); +} + /* Firmware Version is returned as Major.Minor.Build */ static ssize_t fw_version_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -3477,12 +3486,14 @@ static DEVICE_ATTR_RO(fw_version); static DEVICE_ATTR_RO(hw_version); static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL); static DEVICE_ATTR_WO(update_cfg); +static DEVICE_ATTR_RO(config_crc); static struct attribute *mxt_attrs[] = { &dev_attr_fw_version.attr, &dev_attr_hw_version.attr, &dev_attr_object.attr, &dev_attr_update_cfg.attr, + &dev_attr_config_crc.attr, NULL }; From patchwork Fri May 8 05:56:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4486FC38A2A for ; Fri, 8 May 2020 05:58:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FE2620870 for ; Fri, 8 May 2020 05:58:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727995AbgEHF6q (ORCPT ); Fri, 8 May 2020 01:58:46 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38715 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728025AbgEHF6p (ORCPT ); Fri, 8 May 2020 01:58:45 -0400 IronPort-SDR: HmIP7Nv1cFb6mB1nPz9E2pcK+TFTaEyROys2FWtAHsbogEKM/e7nzPw6j8OyZ3BZ2/ddfkYefw GYtAJ1tMqRKEp6YQTWhmhANrssJVpuUywsNESr9XjPMmziir0bL/We3ZHUqhXXm8eCxL37bjHB 7FL/pNJ6z7w8myfC8VLHwsExGGln0N5gazf96+W1T/khn3KnHF+1HuA+M8S4CYzbWpuwFDvFwo wQj6/2+58GxLD5Od5Ik1vyYTcSMMwOYBX65FX6nAmkTe+ov4vUhG1hrGRoCB1Dh+s159X2cC2/ oBE= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670102" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 21:58:42 -0800 IronPort-SDR: Dovf0Zltps35i24+B4fT2Hb0aNvonZO0OQFkaUR1Pf8vexF/yHxpJHvOaVvfsDA3L5rSjBhFdx Q1NdD3PVi3gHWL2DqIpCHlDMuj8FT+ZI5cHLz6tieNhbyOVEEaGoYWh5MDW8n7gsJSpLLZwJm5 TrGvmw0nd5UoeZTOqvSm2VfaSCKsCc2JKwBt5rOJ9H6niPIkxgBTm/tm8b7psZEtplXY2GCURv Rwy6H2NO2wb+GJbpzYIV1XE/UbvbO/ikTkg2MKbVmHHsV4bPLYDSvGLl20hL1FBUP8Bq84sg2Y IiQ= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 27/56] Input: atmel_mxt_ts - refactor firmware flash to extract context into struct Date: Thu, 7 May 2020 22:56:27 -0700 Message-ID: <20200508055656.96389-28-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer Refactor firmware flash to extract context into struct Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 1bbe20ff3dcd6612e7942c495929eae5c138ece2) Signed-off-by: George G. Davis [jiada: Add commit description] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 59 +++++++++++++++--------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index c3dd6c486c12..bb4fc13defea 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -292,6 +292,22 @@ struct mxt_cfg { struct mxt_info info; }; +/* Firmware frame structure */ +struct mxt_fw_frame { + __be16 size; + u8 data[]; +}; + +/* Firmware update context */ +struct mxt_flash { + const struct firmware *fw; + struct mxt_fw_frame *frame; + loff_t pos; + size_t frame_size; + unsigned int count; + unsigned int retry; +}; + /* Each client has this additional data */ struct mxt_data { struct i2c_client *client; @@ -3240,21 +3256,17 @@ static int mxt_check_firmware_format(struct device *dev, static int mxt_load_fw(struct device *dev) { struct mxt_data *data = dev_get_drvdata(dev); - const struct firmware *fw = NULL; - unsigned int frame_size; - unsigned int pos = 0; - unsigned int retry = 0; - unsigned int frame = 0; + struct mxt_flash f = { 0, }; int ret; - ret = request_firmware(&fw, data->fw_name, dev); + ret = request_firmware(&f.fw, data->fw_name, dev); if (ret) { dev_err(dev, "Unable to open firmware %s\n", data->fw_name); return ret; } /* Check for incorrect enc file */ - ret = mxt_check_firmware_format(dev, fw); + ret = mxt_check_firmware_format(dev, f.fw); if (ret) goto release_firmware; @@ -3308,41 +3320,42 @@ static int mxt_load_fw(struct device *dev) goto disable_irq; } - while (pos < fw->size) { + while (f.pos < f.fw->size) { + f.frame = (struct mxt_fw_frame *)(f.fw->data + f.pos); + ret = mxt_check_bootloader(data, MXT_WAITING_FRAME_DATA, true); if (ret) goto disable_irq; - frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1)); - /* Take account of CRC bytes */ - frame_size += 2; + f.frame_size = __be16_to_cpu(f.frame->size) + 2U; /* Write one frame to device */ - ret = mxt_bootloader_write(data, fw->data + pos, frame_size); + ret = mxt_bootloader_write(data, f.fw->data + f.pos, + f.frame_size); if (ret) goto disable_irq; ret = mxt_check_bootloader(data, MXT_FRAME_CRC_PASS, true); if (ret) { - retry++; + f.retry++; /* Back off by 20ms per retry */ - msleep(retry * 20); + msleep(f.retry * 20); - if (retry > 20) { + if (f.retry > 20) { dev_err(dev, "Retry count exceeded\n"); goto disable_irq; } } else { - retry = 0; - pos += frame_size; - frame++; + f.retry = 0; + f.pos += f.frame_size; + f.count++; } - if (frame % 50 == 0) - dev_dbg(dev, "Sent %d frames, %d/%zd bytes\n", - frame, pos, fw->size); + if (f.count % 50 == 0) + dev_dbg(dev, "Sent %u frames, %lld/%zu bytes\n", + f.count, f.pos, f.fw->size); } /* Wait for flash. */ @@ -3351,7 +3364,7 @@ static int mxt_load_fw(struct device *dev) if (ret) goto disable_irq; - dev_dbg(dev, "Sent %d frames, %d bytes\n", frame, pos); + dev_dbg(dev, "Sent %u frames, %lld bytes\n", f.count, f.pos); /* * Wait for device to reset. Some bootloader versions do not assert @@ -3365,7 +3378,7 @@ static int mxt_load_fw(struct device *dev) disable_irq: disable_irq(data->irq); release_firmware: - release_firmware(fw); + release_firmware(f.fw); return ret; } From patchwork Fri May 8 05:56:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B95AC47257 for ; Fri, 8 May 2020 05:59:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36E4A21841 for ; Fri, 8 May 2020 05:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728055AbgEHF6w (ORCPT ); Fri, 8 May 2020 01:58:52 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:45906 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728047AbgEHF6w (ORCPT ); Fri, 8 May 2020 01:58:52 -0400 IronPort-SDR: JHsLNhFGi8MNXYsrMJd73Wy/XwoktPaR/vaB7zBQfSZm0haCNSOp2cUGLwhalESKNy7L0/ujx7 MA/8L6i/G6Js0K3R5WzxwsUN1+yC35XgtQeh1xV1BXjC6FvVIXInsU6Ak+2zQQFSlea7rSSZ3q 2P9PutKDLQ4noKr0OWMofFeShvGQX/Yy6KWP8/1in+Ar1+FuCtpczrSa5fGbzuTRXZCt8RZMMi j8j3uQjxsIxaKSDUxv0/IqXuj5GIfNBR7nKc/6q9sMEquxdi9pMfxH1ZxC0NMWiwF03I/8s0Rr dIA= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48710628" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 07 May 2020 21:58:51 -0800 IronPort-SDR: Ykvrv/U4JQnt7VN16jBlVZVrYcobX2V/+g1n8xKJOq/jcicayp3vrUM9eRfVdMdg3n6t/eL5Ed zEnV6C4vsEulq4NdOAmfoJbEYCGE72aS0Aa1rNayWNdQOta+RAn8GxGDlhc5xy2kxSKb7C5qjG WeV4KEOMoo/l6St1GsS0DbRrw5ong1hsBHMyWZ0dK93XL3zVqlYI7TPe+pN/nlU3ECa2zVX354 uor4A6uXPPIqf7yI+Tc2o13wcyCqmiUdGIMtCi3JEDr2rpwmX/FlHqh0w95jhp8J577YwSLYVG AFg= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 29/56] Input: atmel_mxt_ts - combine bootloader version query with probe Date: Thu, 7 May 2020 22:56:29 -0700 Message-ID: <20200508055656.96389-30-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer This removes some complexity from the bootloader state machine, and means that we always output some debug about the version as soon as we start talking to the bootloader. Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit a2d141f170c80fea6663af98aab0be32abc0ddb0) Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 45 +++++++----------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 674763dddcd3..e2538c2dd3f7 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -559,47 +559,31 @@ static int mxt_probe_bootloader(struct mxt_data *data, bool alt_address) { struct device *dev = &data->client->dev; int error; - u8 val; - bool crc_failure; + u8 buf[3]; + bool crc_failure, extended_id; error = mxt_lookup_bootloader_address(data, alt_address); if (error) return error; - error = mxt_bootloader_read(data, &val, 1); + /* Check bootloader status and version information */ + error = mxt_bootloader_read(data, buf, sizeof(buf)); if (error) return error; - /* Check app crc fail mode */ - crc_failure = (val & ~MXT_BOOT_STATUS_MASK) == MXT_APP_CRC_FAIL; + crc_failure = (buf[0] & ~MXT_BOOT_STATUS_MASK) == MXT_APP_CRC_FAIL; + extended_id = buf[0] & MXT_BOOT_EXTENDED_ID; - dev_err(dev, "Detected bootloader, status:%02X%s\n", - val, crc_failure ? ", APP_CRC_FAIL" : ""); + dev_info(dev, "Found bootloader addr:%02x ID:%u%s%u%s\n", + data->bootloader_addr, + extended_id ? (buf[1] & MXT_BOOT_ID_MASK) : buf[0], + extended_id ? " version:" : "", + extended_id ? buf[2] : 0, + crc_failure ? ", APP_CRC_FAIL" : ""); return 0; } -static u8 mxt_get_bootloader_version(struct mxt_data *data, u8 val) -{ - struct device *dev = &data->client->dev; - u8 buf[3]; - - if (val & MXT_BOOT_EXTENDED_ID) { - if (mxt_bootloader_read(data, &buf[0], 3) != 0) { - dev_err(dev, "%s: i2c failure\n", __func__); - return val; - } - - dev_dbg(dev, "Bootloader ID:%d Version:%d\n", buf[1], buf[2]); - - return buf[0]; - } else { - dev_dbg(dev, "Bootloader ID:%d\n", val & MXT_BOOT_ID_MASK); - - return val; - } -} - static int mxt_check_bootloader(struct mxt_data *data, unsigned int state, bool wait) { @@ -633,9 +617,6 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state, if (ret) return ret; - if (state == MXT_WAITING_BOOTLOAD_CMD) - val = mxt_get_bootloader_version(data, val); - switch (state) { case MXT_WAITING_BOOTLOAD_CMD: case MXT_WAITING_FRAME_DATA: @@ -3279,7 +3260,7 @@ static int mxt_enter_bootloader(struct mxt_data *data) msleep(MXT_RESET_TIME); /* Do not need to scan since we know family ID */ - ret = mxt_lookup_bootloader_address(data, 0); + ret = mxt_probe_bootloader(data, 0); if (ret) return ret; From patchwork Fri May 8 05:56:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB115C47247 for ; Fri, 8 May 2020 05:59:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6C8C2192A for ; Fri, 8 May 2020 05:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbgEHF65 (ORCPT ); Fri, 8 May 2020 01:58:57 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:45906 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728047AbgEHF6z (ORCPT ); Fri, 8 May 2020 01:58:55 -0400 IronPort-SDR: UNNq79+blQ0AAtKeWP/nQ7Tnimlen0ZUV0EeCcUe9Oa8OYrFCl8dIbNLXzaqTrFUq91CQvbhdy WfDGchaAeX5wW/xaiNdoO73JHC5iGksT2A7g53dCaqsDJEfnsexCbhxREeVrAZa/EaXzz/0El0 ASifvC71GIEGg6n5Gu3KCIjwCkz7yE8fX03YLfP89RaHU/13ktw0vUUmXfu2S+72srYYtuzprT hoR+l1xPa2XMiji2HgDu4BBkpQPTYNvuiCs/mjc1NC36BKoF65D3d+peKz3a+oT5plWuUCFd96 diU= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48710631" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 07 May 2020 21:58:55 -0800 IronPort-SDR: bcUY2uKbfHTvVaHX1DMtf3OunCmCkdN8LHYZ6/fcBxArBA5McAee7CAj3wkduo22Bz4CwfsVLF 6cS3HpVvb2qWCi2naDXAJR8tZtQb5BEwFP2Azv2t6IPEi0sRmxxQQHe4CFdVcbFgEkElYw4S0e BVrsb/Y4sb2ugMMdyseXlrf1i6CG6Idd7LWLAiVVh1gcHNWXHovzTJ08LgJwrbZkdIgUYGRVSo vZk9S0EfpseWIB374AHqq5L7/wkKCqq9VGssH778SiYtsfLMT8Bdff/R1px02YZp/5TxOBiXhY sLA= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 30/56] Input: atmel_mxt_ts - improve bootloader state machine handling Date: Thu, 7 May 2020 22:56:30 -0700 Message-ID: <20200508055656.96389-31-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer The code is much clearer if we switch on the actual state the bootloader is in, rather than the state we want it to be in, and allows the removal of a goto retry tangle. Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 463e15ee95ee6e6274017ff645839dbe34d75c99) [gdavis: Squash fix from George G. Davis: - input: atmel_mxt_ts - Fix 'mxt_send_bootloader_cmd' was not declared warning] Signed-off-by: George G. Davis [jiada: only wait on some status change, cleanup code style] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 165 +++++++++++++---------- 1 file changed, 95 insertions(+), 70 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index e2538c2dd3f7..4d2240971387 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -306,6 +306,9 @@ struct mxt_flash { size_t frame_size; unsigned int count; unsigned int retry; + u8 previous; + bool complete; + bool wait; }; /* Each client has this additional data */ @@ -584,15 +587,27 @@ static int mxt_probe_bootloader(struct mxt_data *data, bool alt_address) return 0; } -static int mxt_check_bootloader(struct mxt_data *data, unsigned int state, - bool wait) +static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock); + +static int mxt_write_firmware_frame(struct mxt_data *data, struct mxt_flash *f) +{ + f->frame = (struct mxt_fw_frame *)(f->fw->data + f->pos); + + /* Take account of CRC bytes */ + f->frame_size = __be16_to_cpu(f->frame->size) + 2U; + + /* Write one frame to device */ + return mxt_bootloader_write(data, f->fw->data + f->pos, + f->frame_size); +} + +static int mxt_check_bootloader(struct mxt_data *data, struct mxt_flash *f) { struct device *dev = &data->client->dev; - u8 val; + u8 state; int ret; -recheck: - if (wait) { + if (f->wait) { /* * In application update mode, the interrupt * line signals state transitions. We must wait for the @@ -608,40 +623,96 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state, * by writing length 0x000 to device (iff we are in * WAITING_FRAME_DATA state). */ - dev_err(dev, "Update wait error %d\n", ret); + dev_warn(dev, "Update wait error %d\n", ret); return ret; } } - ret = mxt_bootloader_read(data, &val, 1); + f->wait = false; + + ret = mxt_bootloader_read(data, &state, 1); if (ret) return ret; + /* Remove don't care bits */ + if (state & ~MXT_BOOT_STATUS_MASK) + state &= ~MXT_BOOT_STATUS_MASK; + switch (state) { case MXT_WAITING_BOOTLOAD_CMD: + dev_info(dev, "Unlocking bootloader\n"); + ret = mxt_send_bootloader_cmd(data, true); + if (ret) + return ret; + f->wait = true; + + break; + case MXT_WAITING_FRAME_DATA: - case MXT_APP_CRC_FAIL: - val &= ~MXT_BOOT_STATUS_MASK; + if (f->previous != MXT_WAITING_BOOTLOAD_CMD && + f->previous != MXT_FRAME_CRC_PASS && + f->previous != MXT_FRAME_CRC_FAIL) + goto unexpected; + + ret = mxt_write_firmware_frame(data, f); + if (ret) + return ret; + + f->wait = true; + + break; + + case MXT_FRAME_CRC_CHECK: + if (f->previous != MXT_WAITING_FRAME_DATA) + goto unexpected; + f->wait = true; break; + case MXT_FRAME_CRC_PASS: - if (val == MXT_FRAME_CRC_CHECK) { - goto recheck; - } else if (val == MXT_FRAME_CRC_FAIL) { - dev_err(dev, "Bootloader CRC fail\n"); - return -EINVAL; + if (f->previous != MXT_FRAME_CRC_CHECK) + goto unexpected; + + /* Next frame */ + f->retry = 0; + f->pos += f->frame_size; + f->count++; + f->wait = true; + + if (f->pos >= f->fw->size) { + f->complete = true; + dev_info(dev, "Sent %u frames, %zu bytes\n", + f->count, f->fw->size); + } else if (f->count % 50 == 0) { + dev_dbg(dev, "Sent %u frames, %lld/%zu bytes\n", + f->count, f->pos, f->fw->size); + } + + break; + + case MXT_FRAME_CRC_FAIL: + if (f->retry > 20) { + dev_err(dev, "Retry count exceeded\n"); + return -EIO; } + + /* Back off by 20ms per retry */ + dev_dbg(dev, "Bootloader frame CRC failure\n"); + f->retry++; + f->wait = true; + msleep(f->retry * 20); break; + default: return -EINVAL; } - if (val != state) { - dev_err(dev, "Invalid bootloader state %02X != %02X\n", - val, state); - return -EINVAL; - } + f->previous = state; return 0; + +unexpected: + dev_err(dev, "Unexpected state transition\n"); + return -EINVAL; } static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock) @@ -3297,57 +3368,13 @@ static int mxt_load_fw(struct device *dev) if (ret) goto release_firmware; - ret = mxt_check_bootloader(data, MXT_WAITING_BOOTLOAD_CMD, false); - if (ret) { - /* Bootloader may still be unlocked from previous attempt */ - ret = mxt_check_bootloader(data, MXT_WAITING_FRAME_DATA, false); - if (ret) - goto disable_irq; - } else { - dev_info(dev, "Unlocking bootloader\n"); - - /* Unlock bootloader */ - ret = mxt_send_bootloader_cmd(data, true); + while (true) { + ret = mxt_check_bootloader(data, &f); if (ret) - goto disable_irq; - } - - while (f.pos < f.fw->size) { - f.frame = (struct mxt_fw_frame *)(f.fw->data + f.pos); - - ret = mxt_check_bootloader(data, MXT_WAITING_FRAME_DATA, true); - if (ret) - goto disable_irq; - - /* Take account of CRC bytes */ - f.frame_size = __be16_to_cpu(f.frame->size) + 2U; - - /* Write one frame to device */ - ret = mxt_bootloader_write(data, f.fw->data + f.pos, - f.frame_size); - if (ret) - goto disable_irq; - - ret = mxt_check_bootloader(data, MXT_FRAME_CRC_PASS, true); - if (ret) { - f.retry++; - - /* Back off by 20ms per retry */ - msleep(f.retry * 20); - - if (f.retry > 20) { - dev_err(dev, "Retry count exceeded\n"); - goto disable_irq; - } - } else { - f.retry = 0; - f.pos += f.frame_size; - f.count++; - } + return ret; - if (f.count % 50 == 0) - dev_dbg(dev, "Sent %u frames, %lld/%zu bytes\n", - f.count, f.pos, f.fw->size); + if (f.complete) + break; } /* Wait for flash. */ @@ -3356,7 +3383,6 @@ static int mxt_load_fw(struct device *dev) if (ret) goto disable_irq; - dev_dbg(dev, "Sent %u frames, %lld bytes\n", f.count, f.pos); /* * Wait for device to reset. Some bootloader versions do not assert @@ -3366,7 +3392,6 @@ static int mxt_load_fw(struct device *dev) mxt_wait_for_completion(data, &data->bl_completion, MXT_FW_RESET_TIME); data->in_bootloader = false; - disable_irq: disable_irq(data->irq); release_firmware: From patchwork Fri May 8 05:56:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0ADAC4724C for ; Fri, 8 May 2020 05:59:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC18E20870 for ; Fri, 8 May 2020 05:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728095AbgEHF7A (ORCPT ); Fri, 8 May 2020 01:59:00 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:45906 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728093AbgEHF67 (ORCPT ); Fri, 8 May 2020 01:58:59 -0400 IronPort-SDR: lABfUEMR4TV7l0NKrzIn20Oxz3YEIiuANMpW248NExKkzkOxGOMFnUCYPwZ8fqpj/TvKp9Nd7q 4yJlIQ9x7nXRrZu9auCTVgK8qGKCt8CkXq8DvyvJtXg/cFT5NXjxMXgto0IauZS7rY9KcFPJ0l uFIv6PtoXe6DQdGgdz3mFJgCRfpBtNvwTs+TQ8vC+CfVJCMgSrP+WjSVDdaLlSJJExJ6eynF29 BSZSeiaHlDf5lJYlsnYPM3jcXOQHK5AVqZ88ABSKaTYZ14uUuBjN1cBt41b7PcM4l2S9MAEstL 0Xc= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48710634" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 07 May 2020 21:58:58 -0800 IronPort-SDR: x1GkO14UZkQ0XJlLfiIbtztHs9EeHS+2nOwpqLSKR4UTqu5zJCfYSqGbXc67mDMrmdJmGnzUd4 ZOGZGMMD8TeQrfPMIsAGYckis/nrCav5caN91Sn157lPAqQMRnGFY9Okn7C16AhbFHJTaX3Th8 uxlnooT9uX8eVnbdROmXkXGi1MkzaIoOB1jy/tf9U2E1+3b4J2YzIWXr+DcjEIdvzXJU4Q9moV hy2ZcsW6sdFMxB70bGwu1e00kEr2A/VkzBO41L0sm2/8JEcP1VdZKwHlaxj0f/NPorvT4f0S/W r0U= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 31/56] Input: atmel_mxt_ts - rename bl_completion to chg_completion Date: Thu, 7 May 2020 22:56:31 -0700 Message-ID: <20200508055656.96389-32-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer Rename bl_completion to chg_completion Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit dda8453bfb44216645ede798918a314d4fca2481) [gdavis: Resolve forward port conflicts due to applying upstream commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform data support").] Signed-off-by: George G. Davis [jiada: call complete(&data->chg_completion) only when in_bootloader is TRUE Add commit description] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 4d2240971387..0d77ae455fde 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -383,9 +383,6 @@ struct mxt_data { u8 T100_reportid_max; u16 T107_address; - /* for fw update in bootloader */ - struct completion bl_completion; - /* for reset handling */ struct completion reset_completion; @@ -397,6 +394,9 @@ struct mxt_data { enum mxt_suspend_mode suspend_mode; + /* for power up handling */ + struct completion chg_completion; + /* Indicates whether device is in suspend */ bool suspended; @@ -614,7 +614,7 @@ static int mxt_check_bootloader(struct mxt_data *data, struct mxt_flash *f) * CHG assertion before reading the status byte. * Once the status byte has been read, the line is deasserted. */ - ret = mxt_wait_for_completion(data, &data->bl_completion, + ret = mxt_wait_for_completion(data, &data->chg_completion, MXT_FW_CHG_TIMEOUT); if (ret) { /* @@ -1415,8 +1415,7 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id) struct mxt_data *data = dev_id; if (data->in_bootloader) { - /* bootloader state transition completion */ - complete(&data->bl_completion); + complete(&data->chg_completion); return IRQ_HANDLED; } @@ -2180,9 +2179,9 @@ static void mxt_regulator_enable(struct mxt_data *data) msleep(MXT_CHG_DELAY); retry_wait: - reinit_completion(&data->bl_completion); + reinit_completion(&data->chg_completion); data->in_bootloader = true; - error = mxt_wait_for_completion(data, &data->bl_completion, + error = mxt_wait_for_completion(data, &data->chg_completion, MXT_POWERON_DELAY); if (error == -EINTR) goto retry_wait; @@ -3342,7 +3341,7 @@ static int mxt_enter_bootloader(struct mxt_data *data) enable_irq(data->irq); } - reinit_completion(&data->bl_completion); + reinit_completion(&data->chg_completion); return 0; } @@ -3378,7 +3377,7 @@ static int mxt_load_fw(struct device *dev) } /* Wait for flash. */ - ret = mxt_wait_for_completion(data, &data->bl_completion, + ret = mxt_wait_for_completion(data, &data->chg_completion, MXT_FW_RESET_TIME); if (ret) goto disable_irq; @@ -3389,7 +3388,7 @@ static int mxt_load_fw(struct device *dev) * the CHG line after bootloading has finished, so ignore potential * errors. */ - mxt_wait_for_completion(data, &data->bl_completion, MXT_FW_RESET_TIME); + mxt_wait_for_completion(data, &data->chg_completion, MXT_FW_RESET_TIME); data->in_bootloader = false; disable_irq: @@ -3811,7 +3810,7 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) data->irq = client->irq; i2c_set_clientdata(client, data); - init_completion(&data->bl_completion); + init_completion(&data->chg_completion); init_completion(&data->reset_completion); init_completion(&data->crc_completion); From patchwork Fri May 8 05:56:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC8C9C38A2A for ; Fri, 8 May 2020 05:59:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C883221841 for ; Fri, 8 May 2020 05:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728152AbgEHF7S (ORCPT ); Fri, 8 May 2020 01:59:18 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:45906 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728139AbgEHF7O (ORCPT ); Fri, 8 May 2020 01:59:14 -0400 IronPort-SDR: 5VkTlkxivbDZ5yPUL4Dm+uz450kupOsdfsJd3bmVfZQgegmZfGbyT3QLv4cJUlPb+2OuL8LG1w X4jKyTjdRKskx/32ne7kHebmazd6ghdNeGiWjoghm2xifSn/L/sLaRyed+bLXmOngzuC50Tu0b lEX6itCiO0O3cLZoYAcaolAHyhhpL427qPuvPYjCwf7D4dnECe5DPCHlgeLOkNKbRNN9voPmec v6PzE9Q7LNi4G9dIoCtwAVtRIXs8wPp+nakDMHNALa7G4aZGhnuLdpHwE9A382BG8EvAYxTSAn xRo= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48710644" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 07 May 2020 21:59:14 -0800 IronPort-SDR: wm3fgo17k7SSJ/DnkYOOLsJxwrH7ObDSgby8pR5xdd4ArR7Qoswk9Egeo2EV/CNxwVXzUi4iiI la+krsiNlg8yr0cdy/8rEK7ZHNInxKdqPi2ykcBzKVPNAgHX9OeTrGDUTUmmTDTtj28Ybllwqz S4tFAZla9JOu2Gs2y0j1gyOPiT/nMjT5vkaFblsFcHUMRcfgmGlPZYPF3N7fkPslV1yZQSnRx7 iu2X/IoiyxFf3GKxevW8vSp5X1VpZ4/oqrFGmEPJEVcSGgLADZ/6V5m2P76tz+TBjqd6K6o3fQ mto= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 35/56] Input: atmel_mxt_ts - orientation is not present in hover Date: Thu, 7 May 2020 22:56:35 -0700 Message-ID: <20200508055656.96389-36-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer When in hover, the orientation information is not sent Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 0c885d5bd276bd9240c43aa046fc407cbe2ae864) Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 152069c3e15d..1027ebbc3978 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -1027,10 +1027,6 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message) distance = MXT_DISTANCE_HOVERING; hover = true; active = true; - - if (data->t100_aux_vect) - orientation = message[data->t100_aux_vect]; - break; case MXT_T100_TYPE_FINGER: From patchwork Fri May 8 05:56:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EE2FC38A2A for ; Fri, 8 May 2020 05:59:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A2E820736 for ; Fri, 8 May 2020 05:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727107AbgEHF76 (ORCPT ); Fri, 8 May 2020 01:59:58 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:22062 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727104AbgEHF7S (ORCPT ); Fri, 8 May 2020 01:59:18 -0400 IronPort-SDR: Ef7ooS/g+dUBxga/7WSmWDbeAMsS/BZITWmQnYCoEU8Tu5FqQMogSADT9IrufU0VHPhoACSnic JcySAcnNnmhHsp85ER/xqzUhbaf5I7fUx/D7Wkjs+xRRIF2P6Rifcl/dSapiz21CmbRCiGmmwF BiCzQn5SejSRnxW8asn9POa5d0cY1cL2muKJ0YgFDAu+wcvr10tCh3/CPWJCu2ONQzH1H/Q2IX OtKkvHDB1v1CtSWblsA/tBuEfgquHdEfFmLl5liXbTZuLlK8FqhXDl5RsuAHMJK72WTAc+EBzf Peo= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48589120" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 07 May 2020 21:59:17 -0800 IronPort-SDR: /151iejCQ14UkWcq1PC2SpC2EGv6MEZlEhO+H4MrdNPMSdiDiKHosyb/L1NP2kFFslHfnf5NzY o4K28EdsRSpuIXVJLXmCxVt6X+kJ7hmO8FBlUrNX/HQ+8YLIlyJlFJbX13qknUJwkyNiWgrxql PS0rGM/trQPStR7NQ5VZCGGh+4a3tBeYjOsskeTzu00Yoajxak3tCyPGvDkBVYPGlUE8OYIDEj yJJWCb8jgY5bA9C3EGQsacxuAH+9CDRE++UkZJkVft7gEnNSDoJbW0iF4784neiZxj2LRvSue4 ak4= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 36/56] Input: atmel_mxt_ts - implement debug output for messages Date: Thu, 7 May 2020 22:56:36 -0700 Message-ID: <20200508055656.96389-37-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer Add a debug switch which causes all messages from the touch controller to be dumped to the dmesg log with a set prefix "MXT MSG:". This is used by Atmel user-space utilities to debug touch operation. Enabling this output does impact touch performance. Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 3c3fcfdd4889dfeb1c80ae8cd94a622c6342b06a) [gdavis: Forward port and fix conflicts.] Signed-off-by: George G. Davis [jiada: Rename mxt_debug_enable_store to debug_enable_store Rename mxt_debug_enable_show to debug_enable_show Replace DEVICE_ATTR with DEVICE_ATTR_RW] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 46 ++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 1027ebbc3978..7d48c4d1f57d 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -336,6 +336,7 @@ struct mxt_data { u8 t100_aux_ampl; u8 t100_aux_area; u8 t100_aux_vect; + bool debug_enabled; u8 max_reportid; u32 config_crc; u32 info_crc; @@ -461,8 +462,11 @@ static bool mxt_object_readable(unsigned int type) static void mxt_dump_message(struct mxt_data *data, u8 *message) { - dev_dbg(&data->client->dev, "message: %*ph\n", - data->T5_msg_size, message); + /* debug message with prefix 'MXT MSG:' used by + * Atmel user-space utilities to debug touch operation + */ + dev_dbg(&data->client->dev, "MXT MSG: %*ph\n", + data->T5_msg_size, message); } static int mxt_wait_for_completion(struct mxt_data *data, @@ -1212,6 +1216,7 @@ static void mxt_proc_t93_messages(struct mxt_data *data, u8 *msg) static int mxt_proc_message(struct mxt_data *data, u8 *message) { u8 report_id = message[0]; + bool dump = data->debug_enabled; if (report_id == MXT_RPTID_NOMSG) return 0; @@ -1246,9 +1251,12 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message) } else if (report_id == data->T93_reportid) { mxt_proc_t93_messages(data, message); } else { - mxt_dump_message(data, message); + dump = true; } + if (dump) + mxt_dump_message(data, message); + return 1; } @@ -3498,6 +3506,36 @@ static ssize_t update_cfg_store(struct device *dev, return ret; } +static ssize_t debug_enable_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mxt_data *data = dev_get_drvdata(dev); + char c; + + c = data->debug_enabled ? '1' : '0'; + return scnprintf(buf, PAGE_SIZE, "%c\n", c); +} + +static ssize_t debug_enable_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct mxt_data *data = dev_get_drvdata(dev); + u8 i; + ssize_t ret; + + if (kstrtou8(buf, 0, &i) == 0 && i < 2) { + data->debug_enabled = (i == 1); + + dev_dbg(dev, "%s\n", i ? "debug enabled" : "debug disabled"); + ret = count; + } else { + dev_dbg(dev, "debug_enabled write error\n"); + ret = -EINVAL; + } + + return ret; +} + static DEVICE_ATTR_WO(update_fw); static struct attribute *mxt_fw_attrs[] = { @@ -3514,6 +3552,7 @@ static DEVICE_ATTR_RO(hw_version); static DEVICE_ATTR_RO(object); static DEVICE_ATTR_WO(update_cfg); static DEVICE_ATTR_RO(config_crc); +static DEVICE_ATTR_RW(debug_enable); static struct attribute *mxt_attrs[] = { &dev_attr_fw_version.attr, @@ -3521,6 +3560,7 @@ static struct attribute *mxt_attrs[] = { &dev_attr_object.attr, &dev_attr_update_cfg.attr, &dev_attr_config_crc.attr, + &dev_attr_debug_enable.attr, NULL }; From patchwork Fri May 8 05:56:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D066C47247 for ; Fri, 8 May 2020 05:59:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EAAC2070B for ; Fri, 8 May 2020 05:59:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728183AbgEHF71 (ORCPT ); Fri, 8 May 2020 01:59:27 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:22062 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726807AbgEHF70 (ORCPT ); Fri, 8 May 2020 01:59:26 -0400 IronPort-SDR: jfVFPUQOF/0KVTqimvcqRSg3Ipr5j7ROEDr5w5XAO8n3vjFBZ/CPWi+Y2AFz4z4wS3Vu3MLV90 C9DZO7zuyu1qcLF1of4GblJui2hvwFj7TyHz11Ny8BwltI6mlTq07aHD+b0fBq2c8R09Py/nEg WXhWrJF5cpsKqI7zHFmRqEhR6qI2V71/CC6ky73CZn+td6LbEmzJ9FnSMRDciaGBv5rG+xg4lF WZ6UaBAmnH+WQqAUss/nJZlIGSoQap3sUZX3ejwI096L2zCLFvyudyuLmu53jakozxwIYf8brR uvI= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48589126" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 07 May 2020 21:59:25 -0800 IronPort-SDR: L3NrtHh3nnZ6Sw1G2JDvUzOhqhU6HO2PJGQe51mZTeWccV8WdD2EOxp5hpXykDPc9s6/o3GOUn E9qaBdRtW5x38c5kjZKFUbn6OqkB69946fkXCmL9a+Lrm2kBG9AdaDV7s3kYJqQLumW/TWZaV8 xDWxhwnzZs/JFRtb9W31LM6broVp+e7dH1nfm5tzwcnKw59KuwOAhlC+rbMXudcdMJfRLQzXl1 An3u/EgLjUh5CsI0AkzJ71ZZdQwGgNkIk/1XNAeParC29Gc+4JH93AxzTLdS4vwyWE61xGMbrr Rkk= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 38/56] Input: atmel_mxt_ts - eliminate data->raw_info_block Date: Thu, 7 May 2020 22:56:38 -0700 Message-ID: <20200508055656.96389-39-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Dynamically allocated in mxt_read_info_block() buffer buf is assigned both to data->info and data->raw_info_block, having both data->info and data->raw_info_block is redundant and confusing. This patch eliminates data->raw_info_block. Signed-off-by: Jiada Wang Signed-off-by: George G. Davis Signed-off-by: Vladimir Zapolskiy --- drivers/input/touchscreen/atmel_mxt_ts.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 92c883087a4f..a92ad9a103a1 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -324,7 +324,6 @@ struct mxt_data { char phys[64]; /* device physical location */ struct mxt_object *object_table; struct mxt_info *info; - void *raw_info_block; unsigned int irq; unsigned int max_x; unsigned int max_y; @@ -2053,9 +2052,8 @@ static void mxt_free_object_table(struct mxt_data *data) v4l2_device_unregister(&data->dbg.v4l2); #endif data->object_table = NULL; + kfree(data->info); data->info = NULL; - kfree(data->raw_info_block); - data->raw_info_block = NULL; kfree(data->msg_buf); data->msg_buf = NULL; data->T5_address = 0; @@ -2224,7 +2222,7 @@ static int mxt_read_info_block(struct mxt_data *data) u8 *crc_ptr; /* If info block already allocated, free it */ - if (data->raw_info_block) + if (data->info) mxt_free_object_table(data); /* Read 7-byte ID information block starting at address 0 */ @@ -2275,7 +2273,6 @@ static int mxt_read_info_block(struct mxt_data *data) goto err_free_mem; } - data->raw_info_block = id_buf; data->info = (struct mxt_info *)id_buf; dev_info(&client->dev, From patchwork Fri May 8 05:56:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207854 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61610C4724C for ; Fri, 8 May 2020 05:59:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49B2720736 for ; Fri, 8 May 2020 05:59:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726689AbgEHF7e (ORCPT ); Fri, 8 May 2020 01:59:34 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:22062 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728204AbgEHF7d (ORCPT ); Fri, 8 May 2020 01:59:33 -0400 IronPort-SDR: 9FXnISG8iVIz06Ci1hq+aym5kY0bW4FQxxKZ1sbZKttlRFNDRSmOkrGPSdwh/33vrV8huYS+9N CWwkXkmL6e45m0k7m6KObnfNDo9hMY+mqvKz2hHcCeY8Y9Tu/sGOKBWUqqaC+5RS/hwxZkcBBz e8ZVvvMO06XDVsDcA9TSsQqoOTfOG3jlQeJ46ZghatoiEaBWqooN8H5NEBTmTMuo5td2MCtgSF +piphqFwWmO5oKKniN5L2J9NkOraVfh4F2rL7UiTibKg9ESRl/EBgRiBZQT6BI94YcF3uPy0da lmM= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48589131" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 07 May 2020 21:59:32 -0800 IronPort-SDR: 8NF/PDMjkJXD1+qb8TXq/zbB285WiIfPmyl29LuEh94wRHstxvWjbeaH+qRHY3APDZAGVlLWTE WXk/jmvVaA/XhayR3t9KjiwMNOP5+J3u48vzQF6IUXKuLFyHexI64AsD1WWVF0xtFYWtu8D/xu Qb8t7epXFvFLhkIo6fCz+6mr/CjHSNVZCSF01aUurD3PJvtXckPrwBnIAT1U4JkxzbT6SwpwRM vZWS/Ko6DFzFsueW2madt+EmuZPVJE6XWfFylEHcGiTBwSeEeDTTIMj/IWBn800H3KWUgjTgMM HLg= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 40/56] Input: atmel_mxt_ts - rely on calculated_crc rather than file config_crc Date: Thu, 7 May 2020 22:56:40 -0700 Message-ID: <20200508055656.96389-41-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Kautuk Consul We now prefer to rely on the calculated CRC and not on the CRC stored in the file. The new logic is as follows: 1) stored CRC of file != calculated CRC of file, then refuse the possible corrupted file 2) calculated CRC of file != CRC of configuration in controller, then update configuration in controller 3) calculated CRC of file == CRC of configuration in controller, then ignore configuration file Signed-off-by: Kautuk Consul Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 65 +++++++++++++----------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 9281a574ca80..75329f87927b 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -1891,7 +1891,7 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw) int ret; int offset; int i; - u32 info_crc, config_crc, calculated_crc; + u32 info_crc, config_crc, calculated_crc = 0; u16 crc_start = 0; /* Make zero terminated copy of the OBP_RAW file */ @@ -1954,30 +1954,6 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw) } cfg.raw_pos += offset; - /* - * The Info Block CRC is calculated over mxt_info and the object - * table. If it does not match then we are trying to load the - * configuration from a different chip or firmware version, so - * the configuration CRC is invalid anyway. - */ - if (info_crc == data->info_crc) { - if (config_crc == 0 || data->config_crc == 0) { - dev_info(dev, "CRC zero, attempting to apply config\n"); - } else if (config_crc == data->config_crc) { - dev_dbg(dev, "Config CRC 0x%06X: OK\n", - data->config_crc); - ret = 0; - goto release_raw; - } else { - dev_info(dev, "Config CRC 0x%06X: does not match file 0x%06X\n", - data->config_crc, config_crc); - } - } else { - dev_warn(dev, - "Warning: Info CRC error - device=0x%06X file=0x%06X\n", - data->info_crc, info_crc); - } - /* Malloc memory to store configuration */ cfg.start_ofs = MXT_OBJECT_START + data->info->object_num * sizeof(struct mxt_object) + @@ -2001,14 +1977,45 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw) else dev_warn(dev, "Could not find CRC start\n"); - if (crc_start > cfg.start_ofs) { + if (crc_start > cfg.start_ofs) calculated_crc = mxt_calculate_crc(cfg.mem, crc_start - cfg.start_ofs, cfg.mem_size); - if (config_crc > 0 && config_crc != calculated_crc) - dev_warn(dev, "Config CRC in file inconsistent, calculated=%06X, file=%06X\n", - calculated_crc, config_crc); + /* If the CRC stored in the file is not the same as what + * was calculated by mxt_calculate_crc, this means we + * have to refuse the config file and abort download. + */ + if (config_crc != calculated_crc) { + dev_warn(dev, + "Config CRC in file inconsistent, calculated=%06X, file=%06X\n", + calculated_crc, config_crc); + ret = 0; + goto release_mem; + } + + /* + * The Info Block CRC is calculated over mxt_info and the object + * table. If it does not match then we are trying to load the + * configuration from a different chip or firmware version, so + * the configuration CRC is invalid anyway. + */ + if (info_crc == data->info_crc) { + if (config_crc == 0 || data->config_crc == 0) { + dev_info(dev, "CRC zero, attempting to apply config\n"); + } else if (config_crc == data->config_crc) { + dev_dbg(dev, "Config CRC 0x%06X: OK\n", + data->config_crc); + ret = 0; + goto release_mem; + } else { + dev_info(dev, "Config CRC 0x%06X: does not match file 0x%06X\n", + data->config_crc, config_crc); + } + } else { + dev_warn(dev, + "Warning: Info CRC error - device=0x%06X file=0x%06X\n", + data->info_crc, info_crc); } ret = mxt_upload_cfg_mem(data, &cfg); From patchwork Fri May 8 05:56:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF85AC4724C for ; Fri, 8 May 2020 05:59:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3E26208D6 for ; Fri, 8 May 2020 05:59:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727082AbgEHF7m (ORCPT ); Fri, 8 May 2020 01:59:42 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38765 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728219AbgEHF7l (ORCPT ); Fri, 8 May 2020 01:59:41 -0400 IronPort-SDR: KdiCdzezZaBxyLhG/IRkyp8tax5lEXC0jm1F/wlimpaznFifHV8LlyENWgXNnhzjdhqTdZuGG0 3/21U82N95o2E/Bq9DDBSw7kbDUKF+vy+/SFts5sxJ3yokTPVsHLVGPe1WjNJXfWWWaoII+Fx6 a7f37fIsT+jHtWvnR44CC2lcwLqhdX16mANSDfb2Fs/Us+OrdJfakdyzO0UlvcI5NMfvxOu9Xr OyBsmq0HFJF6w/wE77SKiOzyrw0DbnAH7rQSiWQvee3jZRAYtEbEJI1s+aeeceft9jCnPU1BpJ vLY= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670133" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 21:59:38 -0800 IronPort-SDR: r/Rv/h0cRyyuPc29rcGtKYaaxVbI8fjHmNLO3O0xcDBznkKIV4SszxtVpm1089kNZ9o+7sjPcn CV/9/0w7MTJuWRNuOpjULMI0Pxy8hzps20cSoSHEOSCy3yQawoN9EwOMKD+UyN7u1TqlT5kcbP EFv5J+u+t0pl64ppMB5HbY8xfDbc0ZM+zudrW4UWjcvb1XXELstpdkqDbFU3UJPSF/s3018NMP VSphJ7hbndwrLpONmjm5HDcRu1ypKym4ky1sCtTtkqtW2U+OlnNypEknJ5R2dfRWw1C3hIEIAv 3GM= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 42/56] input: atmel_mxt_ts: Add Missing Delay for reset handling of Atmel touch panel controller in detachable displays. Date: Thu, 7 May 2020 22:56:42 -0700 Message-ID: <20200508055656.96389-43-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: keerthikumarp In case of attached display, the touchpanel reset is controlled via imx gpio's from atmel driver and the delay between touchpanel reset and the time at which the chip becomes capable to communicate with the host processor, has be taken care. However in case of detachable displays, the touchpanel reset is controlled via a deserializer gpio which is triggered just before the atmel driver is probed.The delay between touchpanel reset and the time at which the chip becomes capable to communicate (as specified in datasheet) was not being accounted for. This patch introduces that delay. Signed-off-by: keerthikumarp Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index ceb14b4a8d4d..3ffd49b383f4 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -4105,6 +4105,10 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) msleep(MXT_RESET_GPIO_TIME); gpiod_set_value(data->reset_gpio, 1); msleep(MXT_RESET_INVALID_CHG); + } else { + dev_dbg(&client->dev, + "atmel reset pin not found in device tree"); + msleep(MXT_RESET_TIME); } error = mxt_initialize(data); From patchwork Fri May 8 05:56:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74A1EC47247 for ; Fri, 8 May 2020 05:59:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FEBD20736 for ; Fri, 8 May 2020 05:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728279AbgEHF7x (ORCPT ); Fri, 8 May 2020 01:59:53 -0400 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:25985 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728267AbgEHF7w (ORCPT ); Fri, 8 May 2020 01:59:52 -0400 IronPort-SDR: STiOOJXeWZKXeRzXPYQLsywoYdlfshIlr1iJMcyYB1B32YPES7Lot90E4DgGR7CtX99hHga401 uoWbFS/m+IpC5ZLCbnS2an+TLQmBOyU5D7KoKXYMsd8e4GOjfMMbzKRmHQZkKJy8WezaaV3iZ3 v+wA2N5T3OtmpWeAoVK1oHXgBHtHp1rP5w44dWEo7Hu1CZuCfgBmHUwCIZHUYjy9sAKPVnwl7s STiC5UXCs4lpH/JVHX4eIKRVZBzYQIMvkYDT0CcAeXjtjKziw+rK1twu2z05C3w+YffJ94/IZE Gjs= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48589144" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 07 May 2020 21:59:51 -0800 IronPort-SDR: rqzIu02eyh5EBRONiywVoH9QD3pw6+rrncbQ77fDMee993IcW/9etuc0XbM11HNwfEUGT018zf 0/fQ58a5RcE/GSIzFyjQsizKubCJe5TB0WsX1KndUOqbf/7suSOevUD1rHNznNYdjepBzWQrpi dnrB7T5vsq+ioh14YfywFJBMqtdSPuNG9IYYYPWL28/UDKE5fRo4Sr3XvPlE7OU+k5NJtftPpc Q8Wenp/TtPDFuCyGDpx0ImKdEsu+g9W4wWF6MHFaWY6Y9GJAuFUz1FYbi131GCQUY6uyCSDHzr RTE= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 45/56] Input: atmel_mxt_ts: return error from mxt_process_messages_until_invalid() Date: Thu, 7 May 2020 22:56:45 -0700 Message-ID: <20200508055656.96389-46-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Dean Jenkins mxt_process_messages_until_invalid() failed to propagate the error code from mxt_read_and_process_messages() so return the error code. Signed-off-by: Dean Jenkins Signed-off-by: Deepak Das Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index ed850a0bae69..7c530ffac1ba 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -1563,6 +1563,8 @@ static int mxt_process_messages_until_invalid(struct mxt_data *data) /* Read messages until we force an invalid */ do { read = mxt_read_and_process_messages(data, count); + if (read < 0) + return read; if (read < count) return 0; } while (--tries); From patchwork Fri May 8 05:56:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BF20C47257 for ; Fri, 8 May 2020 06:00:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5848E20736 for ; Fri, 8 May 2020 06:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727094AbgEHGAn (ORCPT ); Fri, 8 May 2020 02:00:43 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:47211 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728267AbgEHF74 (ORCPT ); Fri, 8 May 2020 01:59:56 -0400 IronPort-SDR: 8IuJZ72TIJkLVef6RgI8jWHKClON2hKO4lB/nME31KXuA12W6+SIqT/I16ybOKEEDxMZe4GfY9 U3GF/eV4v95cR7a703WPpQgc04iibko/MIJJlawKvMIK1BSBVsMht0+S9peUpK2oGjO4RkyTYZ EhrTv0PBUCfpnA3v+yRjn9Q2052XSoNHHkRulyDNzu8/2ljBP0j6yuH9yZkKgHBIguXs8KeJ6X ofQ4CwDVmZnpnM/6wrRp9l5HHCtxywXiCrdsHCK+jM7Ps1xOE0vnrvBD1dTgp95bqBfpa0mO1M Mmo= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48710673" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 07 May 2020 21:59:55 -0800 IronPort-SDR: 5n5LpbM3gAISoEMlV7TIuHjP7CMnuN2RfLE/uJYYimVpDrMAzZP6G+BUPZYTf3t4Wt5eihcQE4 4/waqlYmYdpzuIxjZGM/uqr1J9yrfmR8AmaZTwJ/ZFwouNQ3PQx1ZCgNvXSZ8DHBCUPxoPGuCp Ql/eZo5nxkhN7v38m2/lXitBVwp5dl4ywJnrYUfWTCAT/4PB7i+lfW6OJMp1nX6LEXUFVCn8kj l5Kc0wkUBPnVR6h6mwXS6YNOulL3Iy7pUg5v9YWn7FUF0YLW9+1OafhClnIgk8dpd2LrSmCyrt hLc= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 46/56] Input: Atmel: improve error handling in mxt_start() Date: Thu, 7 May 2020 22:56:46 -0700 Message-ID: <20200508055656.96389-47-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Deepak Das mxt_start() does not return error in any of the failure cases which will allow input_dev->open() to return success even in case of any failure. This commit modifies mxt_start() to return error in failure cases. Signed-off-by: Deepak Das Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 31 ++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 7c530ffac1ba..906da438d5e8 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3961,12 +3961,13 @@ static int mxt_start(struct mxt_data *data) switch (data->suspend_mode) { case MXT_SUSPEND_T9_CTRL: - mxt_soft_reset(data); - + ret = mxt_soft_reset(data); + if (ret) + break; /* Touch enable */ /* 0x83 = SCANEN | RPTEN | ENABLE */ - mxt_write_object(data, - MXT_TOUCH_MULTI_T9, MXT_T9_CTRL, 0x83); + ret = mxt_write_object(data, + MXT_TOUCH_MULTI_T9, MXT_T9_CTRL, 0x83); break; case MXT_SUSPEND_REGULATOR: @@ -3980,27 +3981,26 @@ static int mxt_start(struct mxt_data *data) * Discard any touch messages still in message buffer * from before chip went to sleep */ - mxt_process_messages_until_invalid(data); + ret = mxt_process_messages_until_invalid(data); + if (ret) + break; ret = mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN); if (ret) - return ret; + break; /* Recalibrate since chip has been in deep sleep */ ret = mxt_t6_command(data, MXT_COMMAND_CALIBRATE, 1, false); if (ret) - return ret; + break; ret = mxt_acquire_irq(data); - if (ret) - return ret; - - break; } - data->suspended = false; + if (!ret) + data->suspended = false; - return 0; + return ret; } static int mxt_stop(struct mxt_data *data) @@ -4327,6 +4327,7 @@ static int __maybe_unused mxt_resume(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct mxt_data *data = i2c_get_clientdata(client); struct input_dev *input_dev = data->input_dev; + int ret = 0; if (!input_dev) return 0; @@ -4336,11 +4337,11 @@ static int __maybe_unused mxt_resume(struct device *dev) mutex_lock(&input_dev->mutex); if (input_dev->users) - mxt_start(data); + ret = mxt_start(data); mutex_unlock(&input_dev->mutex); - return 0; + return ret; } static SIMPLE_DEV_PM_OPS(mxt_pm_ops, mxt_suspend, mxt_resume); From patchwork Fri May 8 05:56:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207850 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF072C47247 for ; Fri, 8 May 2020 06:00:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6ADB20736 for ; Fri, 8 May 2020 06:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728307AbgEHGAE (ORCPT ); Fri, 8 May 2020 02:00:04 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38783 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728301AbgEHGAD (ORCPT ); Fri, 8 May 2020 02:00:03 -0400 IronPort-SDR: 9I7VdDF1VzIfm6kdWbjaIG4FKAKqM7nT+8b9o8e8V9RXG91aJ01fybEXHTZhIYsxagZBwzmH/T Tm42fDRa81Ed4qH/lZel3MM971cGVe2fRn03WqAznw+9wUu48UCnQmowzhs/qTtwlIAtdo5hzC kXPcxupwlBJj2YSX0XWKbsOyQP3g8X8F1kq1vNdnY4/NC5RkBDTSOhBooqlBV9hatrwwoAhlrB TGzqWXdHR//Ox8juQyJkW5puMHZRWDzHR/FLD5B2kk76bEH60S7gF9qYOGCnu1BwB+nGrTayD4 yIo= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670152" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 22:00:01 -0800 IronPort-SDR: Gisp1ek7G0L716U9x5yQZge7TL6zYKgwRZq31Ly7lUh7nBbgfYulJgo32tc3aNoPkJM1V5pgtZ 6SA8cr0McrI93vhnAaAFyoOQ3wMWqGXi2D2szPvgmJ4nLjuF1smwp+pdXUVjpbz0mP26/h9k/w 7SL1OtAicfbxg/IxNlvJkF3XAfS1Dx6Lk8qDEiog/ywdXJp9ajuPboes+jgE4zu9/trRJkO9Fk SA0n0PDn2iMbGwF3NpfFjNTd3maGEDqmkGgqfNtNLuqSdfZOXNGVOW1mSqKwS+8S855aavBEGy UC0= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 48/56] Input: Atmel: improve error handling in mxt_update_cfg() Date: Thu, 7 May 2020 22:56:48 -0700 Message-ID: <20200508055656.96389-49-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Deepak Das mxt_update_cfg() failed to propagate the error code from mxt_init_t7_power_cfg() so return the error code. Signed-off-by: Deepak Das Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index c779cac565a8..83fa2caddeab 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -2172,7 +2172,9 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw) dev_info(dev, "Config successfully updated\n"); /* T7 config may have changed */ - mxt_init_t7_power_cfg(data); + ret = mxt_init_t7_power_cfg(data); + if (ret) + dev_warn(dev, "Power Config failed to update\n"); release_mem: kfree(cfg.mem); From patchwork Fri May 8 05:56:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F342C38A2A for ; Fri, 8 May 2020 06:00:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AE9820736 for ; Fri, 8 May 2020 06:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727121AbgEHGAO (ORCPT ); Fri, 8 May 2020 02:00:14 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38783 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728323AbgEHGAL (ORCPT ); Fri, 8 May 2020 02:00:11 -0400 IronPort-SDR: sUl9fRF2fVoZs0RHja5c5kJMC8LDMYOJl/CeEYxHwLN6vljmpaZpZucAb+jLstHuGgSLtX9Z0V tF4S6SoW/w8wxPUSQroK4np71250S/wrBLz/tCbxj8dTu1k8pIUz/bPqCnC4Mb6KFy/KCCbzOu I+MJ10XLk36/90If1ZGCSSLmMmS+JyKd4RAvJI5Sb8H1ZyCvK9WSJJdi9jcPLOtyF9Spq1gqpB c1Ysl9KRmVEFwYZlHQhG5fdtPaWELaC1SHe1+Ho5Q+rQyoCIRXpitVGQgyCly2OUyQ2rzTHJb8 P3Q= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670168" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 22:00:08 -0800 IronPort-SDR: oZx0j2xcqYbijImYJojoAtAzZ+qTicxtGtQPPUvKpBLdY5tutC7BIXRd0PCT6o7dF8W0pt+7rU qSfQNzkTnOQEc3JxnFdIR4y2MxaXb836jgvB8p7QVfcwzL3exlwL38KMfYOSdJXlYWTMhF5POW +yGDpxvUu6qYoV9bLxSEf3wsKVLRw131aGPyxvo0nGqHXNOevCfdFRlADp3vPoelqfLmfjAOkQ g+DjWvEczzLHuxKTX2RihxjFeDm3voFRamh79qdstkWQjGXQnhZ8/lU1dDJqORXQEWjLH81Hr2 4GM= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 50/56] Input: Atmel: handle ReportID "0x00" while processing T5 messages Date: Thu, 7 May 2020 22:56:50 -0700 Message-ID: <20200508055656.96389-51-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Deepak Das ReportID "0x00" is reserved by Atmel and should not be used by any Atmel touch controller. reportID is the first byte retrieved from T5 message payload. Currently Atmel driver continues to process the T5 messages even if the reportID "0x00" is returned by Touch Controller. This commit modifies Atmel touch driver to return -EINVAL if ReportID "0x00" is received while processing T5 messages. Signed-off-by: Deepak Das Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 92701bf5291f..103881911acc 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -77,6 +77,7 @@ #define MXT_PROCI_TOUCHSEQUENCELOGGER 93 #define MXT_TOUCH_MULTITOUCHSCREEN_T100 100 #define MXT_PROCI_ACTIVESTYLUS_T107 107 +#define MXT_RPTID_RESERVED 0 /* MXT_GEN_MESSAGE_T5 object */ #define MXT_RPTID_NOMSG 0xff @@ -1381,6 +1382,11 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message) u8 report_id = message[0]; bool dump = data->debug_enabled; + if (report_id == MXT_RPTID_RESERVED) { + dev_err(&data->client->dev, + "Received Reserved ReportID 0x00\n"); + return -EINVAL; + } if (report_id == MXT_RPTID_NOMSG) return 0; @@ -1451,6 +1457,8 @@ static int mxt_read_and_process_messages(struct mxt_data *data, u8 count) ret = mxt_proc_message(data, data->msg_buf + data->T5_msg_size * i); + if (ret < 0) + return ret; if (ret == 1) num_valid++; } From patchwork Fri May 8 05:56:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207846 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B155BC38A2A for ; Fri, 8 May 2020 06:00:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CC7020870 for ; Fri, 8 May 2020 06:00:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728333AbgEHGAR (ORCPT ); Fri, 8 May 2020 02:00:17 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38783 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727786AbgEHGAQ (ORCPT ); Fri, 8 May 2020 02:00:16 -0400 IronPort-SDR: XWYePAJHoDBAU1HrbGwMduG8iI6YNxo5qL66LqxM26QiO0vNmltpKeZcra0FD2MwA2EAC7t9o3 6FARs+bspBJNiYyXz4SHZFa728+6Za+wuJVUeK8rhaNNcUh4E3wW/0zBvI57bF7LoG4XcfUDWW f/i85ZeIUzovroguxNS/xj8yDayP3Vv9s5C8QFGA2sClDGSIwqfHR19bN1bT0is+myhVKiLAKZ WkihBdDbp4qhZnc5xOEdlNay/Xu9JsA1TO0agjp6MFeblQFY90bJNyp7piDhDL13+Iq/iRo2Uk K50= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670175" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 22:00:12 -0800 IronPort-SDR: 0dvSsT56dEgWubpsFxTpFLoyMGtLjsxbbv1g7k4/rKaNGvz65EfhHVs8JnUiEFcK2bcnwR8jjo TdtfAJN+K8GeUnVcxBgx9whRMifRwbL2xJAWUQC/mRW0Jz2dfTlUV30jTZKJ1lpJJJ9iHqoHL5 iqfg8ayts1mvI6vN6n4LdJmGEdWvLJFO7YZFU+AEaonrhdCE54y//zRjZLSPZkjI86Z+Aek4qA QcMcngS+nogxhci+giUqv9TuTGpTtPM/dHP4yudm+E8uX7qpVqZ63bt9c1Bu1Y3q0/Ej0tajdM ON8= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 51/56] Input: Atmel: use T44 object to process T5 messages Date: Thu, 7 May 2020 22:56:51 -0700 Message-ID: <20200508055656.96389-52-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Deepak Das T44 object returns the count of valid T5 messages in the buffer. According to atmel, this count should be the main criteria to read the number of T5 messages. Following is the statement from atmel confirming the same :- "For the readout of messages we recommend to stop after the last message is read out from the buffer. One way to identify the amount of new messages is to read T44. The other way is to monitor the /CHG line which indicates independent of mode 0 or mode 1 if there are still data in the buffer. 0xFF indicates that there is no message pending anymore, but it is not recommended to use this as the main criteria to control the data transfer." This commit modifies the logic to readout the T5 messages on the basis of T44 object. Signed-off-by: Deepak Das Signed-off-by: Sanjeev Chugh Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 55 +++++++++++++++--------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 103881911acc..d134a8b9b3ca 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -1488,7 +1488,7 @@ static u8 mxt_max_msg_read_count(struct mxt_data *data, u8 max_T5_msg_count) return min(T5_msg_count_limit, max_T5_msg_count); } -static irqreturn_t mxt_process_messages_t44(struct mxt_data *data) +static int mxt_process_messages_t44(struct mxt_data *data) { struct device *dev = &data->client->dev; int ret; @@ -1501,7 +1501,7 @@ static irqreturn_t mxt_process_messages_t44(struct mxt_data *data) data->T5_msg_size + 1, data->msg_buf); if (ret) { dev_err(dev, "Failed to read T44 and T5 (%d)\n", ret); - return IRQ_NONE; + return ret; } T5_msg_count = data->msg_buf[0]; @@ -1511,7 +1511,7 @@ static irqreturn_t mxt_process_messages_t44(struct mxt_data *data) * Mode 0. It results in unnecessary I2C operations but it is benign. */ if (!T5_msg_count) - return IRQ_NONE; + return processed_valid; if (T5_msg_count > data->max_reportid) { dev_warn(dev, "T44 count %d exceeded max report id\n", @@ -1523,12 +1523,14 @@ static irqreturn_t mxt_process_messages_t44(struct mxt_data *data) ret = mxt_proc_message(data, data->msg_buf + 1); if (ret < 0) { dev_warn(dev, "Unexpected invalid message\n"); - return IRQ_NONE; + return ret; } total_pending = T5_msg_count - 1; - if (!total_pending) + if (!total_pending) { + processed_valid = 1; goto end; + } /* Process remaining messages if necessary */ T5_msg_count = mxt_max_msg_read_count(data, total_pending); @@ -1552,7 +1554,7 @@ static irqreturn_t mxt_process_messages_t44(struct mxt_data *data) data->update_input = false; } - return IRQ_HANDLED; + return processed_valid; } static int mxt_process_messages_until_invalid(struct mxt_data *data) @@ -1582,7 +1584,7 @@ static int mxt_process_messages_until_invalid(struct mxt_data *data) return -EBUSY; } -static irqreturn_t mxt_process_messages(struct mxt_data *data) +static int mxt_process_messages(struct mxt_data *data) { int total_handled, num_handled; u8 count = data->last_message_count; @@ -1593,7 +1595,7 @@ static irqreturn_t mxt_process_messages(struct mxt_data *data) /* include final invalid message */ total_handled = mxt_read_and_process_messages(data, count + 1); if (total_handled < 0) - return IRQ_NONE; + return total_handled; /* if there were invalid messages, then we are done */ else if (total_handled <= count) goto update_count; @@ -1602,7 +1604,7 @@ static irqreturn_t mxt_process_messages(struct mxt_data *data) do { num_handled = mxt_read_and_process_messages(data, 2); if (num_handled < 0) - return IRQ_NONE; + return num_handled; total_handled += num_handled; @@ -1618,12 +1620,13 @@ static irqreturn_t mxt_process_messages(struct mxt_data *data) data->update_input = false; } - return IRQ_HANDLED; + return total_handled; } static irqreturn_t mxt_interrupt(int irq, void *dev_id) { struct mxt_data *data = dev_id; + int ret; if (data->in_bootloader) { complete(&data->chg_completion); @@ -1631,17 +1634,22 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id) if (data->flash) cancel_delayed_work_sync(&data->flash->work); - return IRQ_RETVAL(mxt_check_bootloader(data)); + ret = mxt_check_bootloader(data); + return IRQ_RETVAL(ret); } if (!data->object_table) return IRQ_HANDLED; - if (data->T44_address) { - return mxt_process_messages_t44(data); - } else { - return mxt_process_messages(data); - } + if (data->T44_address) + ret = mxt_process_messages_t44(data); + else + ret = mxt_process_messages(data); + + if (ret <= 0) + return IRQ_NONE; + else + return IRQ_HANDLED; } static int mxt_t6_command(struct mxt_data *data, u16 cmd_offset, @@ -1763,8 +1771,11 @@ static int mxt_acquire_irq(struct mxt_data *data) enable_irq(data->irq); if (data->use_retrigen_workaround) { - error = mxt_process_messages_until_invalid(data); - if (error) + if (data->T44_address) + error = mxt_process_messages_t44(data); + else + error = mxt_process_messages_until_invalid(data); + if (error < 0) return error; } @@ -4019,8 +4030,12 @@ static int mxt_start(struct mxt_data *data) * Discard any touch messages still in message buffer * from before chip went to sleep */ - ret = mxt_process_messages_until_invalid(data); - if (ret) + + if (data->T44_address) + ret = mxt_process_messages_t44(data); + else + ret = mxt_process_messages_until_invalid(data); + if (ret < 0) break; ret = mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN); From patchwork Fri May 8 05:56:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207848 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5065FC38A2A for ; Fri, 8 May 2020 06:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39B6220736 for ; Fri, 8 May 2020 06:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728368AbgEHGA1 (ORCPT ); Fri, 8 May 2020 02:00:27 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38783 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727821AbgEHGA0 (ORCPT ); Fri, 8 May 2020 02:00:26 -0400 IronPort-SDR: IkpAWn62KR0fw969MitX4+q9TPB3s0wpBcR9mtMWtIDt2evr7ebiLUxRekajz9EILO5LE+f87g E+RW/OxGHAcG1bDUHFSZ+hzBPjKcqXf3VsFbmpIQKz/Wq9k4bJYzbyy6dpaGnlqwJzXi5iOuVE l12BRH9RvxbxNJxhtNqKa5cXtY05w7ReqVnw+oStyihJa87HNGbTh1+ogpXVWcV2oIUjK7a68Y JqZrAcwVGPtfUy3TU5vPDRLn4UN+nJ3p6JdzLTfIYfbuROIndTdG60X6eBa3f1zt+aGZORu/pE fQ4= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670188" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 22:00:24 -0800 IronPort-SDR: cjYdFAztbFgCCa3SWi5XjmoVuAYgIv+Xc3HCMYzITM6BSyVg5bweOt00QXwyQW2ee5ILH5VrJf 5tO584Lk4Bq2iWsIZgYeh5JyULK1TY0n7oTaXuXvDzvOinhTACA0ddMNMn7IEJd9Nl8XBnG1Ag JP5kByLmmyaA06F7tKfBqTzaYW/IgLImvSHqwqGlEFXdDSw7wsE3KDuI2/PNOBRRLzZim1YWsE RIUfN79DhXpkOt1sw641NEp8q/rjNxzs+FrpgiJ+09k1ojlcn5WIehXX98ItUYTRTU+wSZzrrB ncM= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 54/56] input: atmel_mxt_ts: added sysfs interface to update atmel T38 data Date: Thu, 7 May 2020 22:56:54 -0700 Message-ID: <20200508055656.96389-55-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Naveen Chakka Atmel touch controller contains T38 object where a user can store its own data of length 64 bytes. T38 data will not be part of checksum calculation on executing T6 BACKUP command. format used to update the T38 data is given below: offset: offset address of the data to be written in the t38 object (in decimal) length: length of the data to be written into the t38 object(in decimal) data: actual data bytes to be written into the t38 object (values should be in hex) Ex: 1. 0 2 10 20 updates first two bytes of the t38 data with values 10 and 20 2. 19 6 10 2f 30 4a 50 60 updates 6 bytes of t38 data from the index 19-24 with hex values Signed-off-by: Naveen Chakka Signed-off-by: Sanjeev Chugh Signed-off-by: George G. Davis [jiada: Rename mxt_t38_data_show to t38_data_show Rename mxt_t38_data_store to t38_data_store Replace DEVICE_ATTR with DEVICE_ATTR_RW] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 102 +++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 5c2f4ea1a362..e75a7e5b0c59 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3989,6 +3989,106 @@ static ssize_t touch_dev_stat_show(struct device *dev, struct return ret; } +static ssize_t t38_data_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mxt_data *data = dev_get_drvdata(dev); + struct mxt_object *object; + size_t count = 0, size; + u8 i, *t38_buf; + + if (!data->object_table) + return -ENXIO; + + object = mxt_get_object(data, MXT_SPT_USERDATA_T38); + size = mxt_obj_size(object); + + /* Pre-allocate buffer large enough to hold max size of t38 object.*/ + t38_buf = kmalloc(size, GFP_KERNEL); + if (!t38_buf) + return -ENOMEM; + + count = __mxt_read_reg(data->client, object->start_address, + size, t38_buf); + if (count) + goto end; + + for (i = 0; i < size; i++) + count += scnprintf(buf + count, PAGE_SIZE - count, + "[%2u]: %02x\n", i, t38_buf[i]); + count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); +end: + kfree(t38_buf); + return count; +} + +static ssize_t t38_data_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct mxt_data *data = dev_get_drvdata(dev); + struct mxt_object *object; + ssize_t ret = 0, pos, offset; + unsigned int i, len, index; + u8 *t38_buf; + + if (!data->object_table) + return -ENXIO; + + object = mxt_get_object(data, MXT_SPT_USERDATA_T38); + + /* Pre-allocate buffer large enough to hold max size of t38 object.*/ + t38_buf = kmalloc(mxt_obj_size(object), GFP_KERNEL); + if (!t38_buf) + return -ENOMEM; + + ret = sscanf(buf, "%zd %d%zd", &offset, &len, &pos); + if (ret != 2) { + dev_err(dev, "Bad format: Invalid parameter to update t38\n"); + ret = -EINVAL; + goto end; + } + + if (len == 0) { + dev_err(dev, + "Bad format: Data length should not be equal to 0\n"); + ret = -EINVAL; + goto end; + } + + if (offset < 0 || ((offset + len) > 64)) { + dev_err(dev, "Invalid offset value to update t38\n"); + ret = -EINVAL; + goto end; + } + + index = pos; + for (i = 0; i < len; i++) { + ret = sscanf(buf + index, "%hhx%zd", t38_buf + i, &pos); + if (ret != 1) { + dev_err(dev, "Bad format: Invalid Data\n"); + ret = -EINVAL; + goto end; + } + index += pos; + } + + ret = __mxt_write_reg(data->client, object->start_address + offset, + len, t38_buf); + if (ret) + goto end; + + ret = mxt_t6_command(data, MXT_COMMAND_BACKUPNV, MXT_BACKUP_VALUE, + true); + if (ret) + dev_err(dev, "backup command failed\n"); + else + ret = count; +end: + kfree(t38_buf); + return ret; +} + static DEVICE_ATTR_RO(fw_version); static DEVICE_ATTR_RO(hw_version); static DEVICE_ATTR_RO(object); @@ -3999,6 +4099,7 @@ static DEVICE_ATTR_RW(debug_v2_enable); static DEVICE_ATTR_RO(debug_notify); static DEVICE_ATTR_RW(t25_selftest); static DEVICE_ATTR_RO(touch_dev_stat); +static DEVICE_ATTR_RW(t38_data); static struct attribute *mxt_attrs[] = { &dev_attr_fw_version.attr, @@ -4011,6 +4112,7 @@ static struct attribute *mxt_attrs[] = { &dev_attr_debug_notify.attr, &dev_attr_t25_selftest.attr, &dev_attr_touch_dev_stat.attr, + &dev_attr_t38_data.attr, NULL }; From patchwork Fri May 8 05:56:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 207847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83488C38A2A for ; Fri, 8 May 2020 06:00:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69EF920736 for ; Fri, 8 May 2020 06:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727821AbgEHGAa (ORCPT ); Fri, 8 May 2020 02:00:30 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38783 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728370AbgEHGA3 (ORCPT ); Fri, 8 May 2020 02:00:29 -0400 IronPort-SDR: I9emyzfXPy7l4IFiaDjwNNCJKZ9l9uX2Vr7sh9TziL2OYY4Cef9+chBqelS3oVl0SuO/hWNT+m 59ieNsYrztuE6WPB2kBsssYedYaw7ym6Oe5cKK7TFEmlnsxgegypw5QERdLBmJM50Tyump1LAO kCHkxTw4leD0oHxVYb5TTQ5ZeDx81Jp9cU4+GVDjkC0DH8F4ytguCpoLHGBKJbbQg9paVO0gcv Y+N9i7XHqLVTKp69tEIaMCtGd+fV1FK60V45jrTchnB12VuZju4m5Lu89jnhV6/gBb83tViYwo UKk= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670190" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 22:00:27 -0800 IronPort-SDR: +yaNTrnZLMEk0EKHupJzgNyBN8O8vrAQCH2LeoUEj/NhFFbYFuPGqWcUXfvWz047zp48nNGOcd ZtkRXtT5/eEH8Tc1HbqG4g6NQxblzlUVeqDfFL24W3d/48O5qedFZIWUu58pmd3NbqXmVPu6gO l/RU+Bdw1wyiVqk8KMTliJ7VDWcBCUhWIODN8ITXuM/O/t1qFHtjw/wb1MeR8QHHNLWhGr+Q5x 1vwMo/ublQYaOjXEz6DrjV1abGlfpwJQbNmWi9lNCfFk6TX25J0q9c/zRTch4ZqMzAb1VukRoK 5Mw= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 55/56] input: atmel_mxt_ts: don't disable IRQ before remove of mxt_fw_attr_group Date: Thu, 7 May 2020 22:56:55 -0700 Message-ID: <20200508055656.96389-56-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org There is issue when firmware is being updated, but mxt_remove() is called to remove driver, because at very beginning IRQ is disabled so that firmware can't proceed, thus cause driver to hang. This patch by move disable_irq() after remove of mxt_fw_attr_group in mxt_remove() to address this issue. Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index e75a7e5b0c59..b518c316757d 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -4514,8 +4514,8 @@ static int mxt_remove(struct i2c_client *client) { struct mxt_data *data = i2c_get_clientdata(client); - disable_irq(data->irq); sysfs_remove_group(&client->dev.kobj, &mxt_fw_attr_group); + disable_irq(data->irq); if (data->reset_gpio) { sysfs_remove_link(&client->dev.kobj, "reset"); gpiod_unexport(data->reset_gpio);