From patchwork Sun Apr 26 17:47:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 207908 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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 E11A0C54FCB for ; Sun, 26 Apr 2020 17:48:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDA3B206DD for ; Sun, 26 Apr 2020 17:48:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="KseRlAyn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726179AbgDZRrw (ORCPT ); Sun, 26 Apr 2020 13:47:52 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:63108 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgDZRrv (ORCPT ); Sun, 26 Apr 2020 13:47:51 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 499Fjx43zdzHm; Sun, 26 Apr 2020 19:47:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1587923269; bh=4J9FdJziB6dpG5MrCPguNFbJpePYCA2dEx3hDaxmX6E=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=KseRlAyn9rRzKhZYX2lWjzHPvqKrrMQor/sfpt0TVh5V5BwfbMCfnpUhzTXvLSuDf 57E6AMcoAK6DFNsXwJDZXxA9pl1VaE/QrxoO45fG78M/NRtLuK3SmmLgVmEpWxb50u MiIVD+1HSMbNNcAUYNHObVq8JkSvptx9tVgGdnM+31vnebOC6BdiFw5UEPrfNKHCFZ vk/44NnxES8WGTmhfsAXsU+Q7/YsnDdmkJxHBp3PET0YVXdpFSb3eeCwbA7MdVnMAU y5NJ3YlFEC+rIGNn5uIiq42Q+x18PqOQ7N95U/oH6hYj0NWRyCwZCEx8ltr3QrMsx+ 7qFdBGl963W+g== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Sun, 26 Apr 2020 19:47:49 +0200 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v5 01/10] input: elants: document some registers and values MIME-Version: 1.0 To: David Heidelberg , Dmitry Osipenko , Dmitry Torokhov , Henrik Rydberg , James Chen , Johnny Chuang , Rob Herring , Scott Liu Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add information found in downstream kernels, to make the code less magic. Signed-off-by: Michał Mirosław Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko --- drivers/input/touchscreen/elants_i2c.c | 29 +++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 2289f9638116..d2175fb6209a 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -81,7 +81,11 @@ #define HEADER_REPORT_10_FINGER 0x62 -/* Header (4 bytes) plus 3 fill 10-finger packets */ +/* Power state */ +#define PWR_STATE_DEEP_SLEEP 0 +#define PWR_STATE_NORMAL 1 + +/* Header (4 bytes) plus 3 full 10-finger packets */ #define MAX_PACKET_SIZE 169 #define BOOT_TIME_DELAY_MS 50 @@ -91,10 +95,21 @@ #define E_ELAN_INFO_BC_VER 0x10 #define E_ELAN_INFO_TEST_VER 0xE0 #define E_ELAN_INFO_FW_ID 0xF0 +#define E_POWER_MODE 0x40 +#define E_POWER_STATE 0x50 +#define E_INFO_X_RES 0x60 +#define E_INFO_Y_RES 0x63 #define E_INFO_OSR 0xD6 #define E_INFO_PHY_SCAN 0xD7 #define E_INFO_PHY_DRIVER 0xD8 +/* FW write command, 0x54 0x?? 0x0, 0x01 */ +#define E_POWER_MODE_BATTERY 0x40 +#define E_POWER_MODE_AC 0x41 +#define E_POWER_MODE_USB 0x42 +#define E_POWER_STATE_SLEEP 0x50 +#define E_POWER_STATE_RESUME 0x58 + #define MAX_RETRIES 3 #define MAX_FW_UPDATE_RETRIES 30 @@ -239,8 +254,8 @@ static int elants_i2c_calibrate(struct elants_data *ts) { struct i2c_client *client = ts->client; int ret, error; - static const u8 w_flashkey[] = { 0x54, 0xC0, 0xE1, 0x5A }; - static const u8 rek[] = { 0x54, 0x29, 0x00, 0x01 }; + static const u8 w_flashkey[] = { CMD_HEADER_WRITE, 0xC0, 0xE1, 0x5A }; + static const u8 rek[] = { CMD_HEADER_WRITE, 0x29, 0x00, 0x01 }; static const u8 rek_resp[] = { CMD_HEADER_REK, 0x66, 0x66, 0x66 }; disable_irq(client->irq); @@ -1366,7 +1381,9 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct elants_data *ts = i2c_get_clientdata(client); - const u8 set_sleep_cmd[] = { 0x54, 0x50, 0x00, 0x01 }; + const u8 set_sleep_cmd[] = { + CMD_HEADER_WRITE, E_POWER_STATE_SLEEP, 0x00, 0x01 + }; int retry_cnt; int error; @@ -1403,7 +1420,9 @@ static int __maybe_unused elants_i2c_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct elants_data *ts = i2c_get_clientdata(client); - const u8 set_active_cmd[] = { 0x54, 0x58, 0x00, 0x01 }; + const u8 set_active_cmd[] = { + CMD_HEADER_WRITE, E_POWER_STATE_RESUME, 0x00, 0x01 + }; int retry_cnt; int error;