Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp354254pxu; Fri, 11 Dec 2020 04:05:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcvEQZm26HcRfA/+MeLtWB9Pkvp7NNNF6W41ruSowT2kEAlm/Ip/A7bI23f8ZkjA51/iYA X-Received: by 2002:a17:906:179a:: with SMTP id t26mr11023368eje.49.1607688358364; Fri, 11 Dec 2020 04:05:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607688358; cv=none; d=google.com; s=arc-20160816; b=p1yphnRe+UcuQAEWTMPfenJRd5OcXiItg8g/w5hkFxeLqb8mmkEPp056PCY7aO+lPB GM8HCVWv99RyWytdCo6v0sVgxmM3i07qIjF70GD03T94bO+MLEKZqOmfmnUco2o4KFR+ hTl/Cp22KpnKY8Au+9YXpKWxQ6/qqxbVlKfbhuSgCPntDDTcA3y3fPusWAqfE2ebc4Av jOFqpSi+vbq5EQgyB4rAJZp3gKDmufrePZHqk6jR9/drsAcugcEyOq0oCxuLVDqpznM0 nHEUcj6LEGtbvO0SD710Dd2aAJbCoJhCw37rSMvvGza/80Obds9ansHyTZ+IEVDtkTr0 5Fjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :subject:from:references:in-reply-to:message-id:date:dkim-signature; bh=SPwdtJNfCi13XI+eQCir3ZIu13dtAN84AxR2GeGdrh8=; b=YtwcgLR1c0uibnbkfPeZWAdBaCQ2/k9Ose4CIPB+ajyXt1RVHrReRjdShagbWbV+fv i6WPZXQ3YewlxE7Ha+FuBcLVsoeNxy1lQAIf+ElvhfyUAex5Zoa6SKfwJWCDYOMSuQ5E P1+pzFSrVk9e0DKB1VxUHYEThSnGLnFTgt0MHwqwNOgyUXivncC5Oc0ntcvlLmwiuoUn SDXCZfoc32GJNjceSHohJ+SlOLj41juFgOPj2UuE9WLoy4aCxZXugUfPHP/Ab8Gzcap4 EmOiIbIVjor3eRu8QGSuWZSwQy/VAX0mJikdkjUrigmdw6rWYZxWh3oMuLeWIWEoO04i oSsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=AzWbct9B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga34si4320840ejc.171.2020.12.11.04.05.34; Fri, 11 Dec 2020 04:05:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=AzWbct9B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436576AbgLKGym (ORCPT + 99 others); Fri, 11 Dec 2020 01:54:42 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:56153 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436527AbgLKGyf (ORCPT ); Fri, 11 Dec 2020 01:54:35 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4CshMj4YPjz5Y; Fri, 11 Dec 2020 07:53:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1607669633; bh=sjHesEuhUQBPTBR5PKdh6Su6/OO5b6xTTe6dLO4s9HI=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=AzWbct9BSww5p9/vQA59TqbXfDDU/xSq/1rqGmRkQNIWkfOUj9iDC27JVWx9yzh/w xJ6+7q5L3wbk8Ah15e6WpjN7NT/jsdqOMCX2bdt6l3sjMEPydaw1EHKp8y+R/BBhvZ l19o8XW9KU3lMbpo5nwNj2Gu8bzqh628NPSJ7aX6iTh1S3rirZXZ+gmgLlUAyAqZIk UvT3F+u+o2rNUz56glgYRhRxCQd/B2NfzcpX/iRKjuIUFp4NVDLO5SvQbQkEgULvfM CJjR2tjqK2JYvxEq+G0TwmiMSwqUJ1fbXreAJRT2Q20AY5y9MtQuUiq7EKjCq8G8jw xt3nU2QJEJcwA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.4 at mail Date: Fri, 11 Dec 2020 07:53:56 +0100 Message-Id: In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH RESEND v8 3/4] input: elants: read touchscreen size for EKTF3624 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Dmitry Torokhov Cc: Dmitry Osipenko , Johnny Chuang , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org EKTF3624 as present in Asus TF300T tablet has touchscreen size encoded in different registers. Signed-off-by: Michał Mirosław Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko --- drivers/input/touchscreen/elants_i2c.c | 84 ++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index f1bf3e000e96..c24d8cdc4251 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -43,6 +43,10 @@ /* Device, Driver information */ #define DEVICE_NAME "elants_i2c" +/* Device IDs */ +#define EKTH3500 0 +#define EKTF3624 1 + /* Convert from rows or columns into resolution */ #define ELAN_TS_RESOLUTION(n, m) (((n) - 1) * (m)) @@ -94,6 +98,8 @@ #define E_ELAN_INFO_REK 0xD0 #define E_ELAN_INFO_TEST_VER 0xE0 #define E_ELAN_INFO_FW_ID 0xF0 +#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 @@ -157,6 +163,7 @@ struct elants_data { bool wake_irq_enabled; bool keep_power_in_suspend; + u8 chip_id; /* Must be last to be used for DMA operations */ u8 buf[MAX_PACKET_SIZE] ____cacheline_aligned; @@ -434,7 +441,58 @@ static int elants_i2c_query_bc_version(struct elants_data *ts) return 0; } -static int elants_i2c_query_ts_info(struct elants_data *ts) +static int elants_i2c_query_ts_info_ektf(struct elants_data *ts) +{ + struct i2c_client *client = ts->client; + int error; + u8 resp[4]; + u16 phy_x, phy_y; + const u8 get_xres_cmd[] = { + CMD_HEADER_READ, E_INFO_X_RES, 0x00, 0x00 + }; + const u8 get_yres_cmd[] = { + CMD_HEADER_READ, E_INFO_Y_RES, 0x00, 0x00 + }; + + /* Get X/Y size in mm */ + error = elants_i2c_execute_command(client, get_xres_cmd, + sizeof(get_xres_cmd), + resp, sizeof(resp), 1, + "get X size"); + if (error) + return error; + + phy_x = resp[2] | ((resp[3] & 0xF0) << 4); + + error = elants_i2c_execute_command(client, get_yres_cmd, + sizeof(get_yres_cmd), + resp, sizeof(resp), 1, + "get Y size"); + if (error) + return error; + + phy_y = resp[2] | ((resp[3] & 0xF0) << 4); + + if (!phy_x || !phy_y) { + dev_warn(&client->dev, + "invalid size data: %d x %d mm\n", + phy_x, phy_y); + return 0; + } + + dev_dbg(&client->dev, "phy_x=%d, phy_y=%d\n", phy_x, phy_y); + + /* calculate resolution from size */ + ts->x_max = 2240-1; + ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, phy_x); + + ts->y_max = 1408-1; + ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, phy_y); + + return 0; +} + +static int elants_i2c_query_ts_info_ekth(struct elants_data *ts) { struct i2c_client *client = ts->client; int error; @@ -588,8 +646,20 @@ static int elants_i2c_initialize(struct elants_data *ts) error = elants_i2c_query_fw_version(ts); if (!error) error = elants_i2c_query_test_version(ts); - if (!error) - error = elants_i2c_query_ts_info(ts); + + switch (ts->chip_id) { + case EKTH3500: + if (!error) + error = elants_i2c_query_ts_info_ekth(ts); + break; + case EKTF3624: + if (!error) + error = elants_i2c_query_ts_info_ektf(ts); + break; + default: + unreachable(); + break; + } if (error) ts->iap_mode = ELAN_IAP_RECOVERY; @@ -1266,6 +1336,9 @@ static int elants_i2c_probe(struct i2c_client *client, ts->client = client; i2c_set_clientdata(client, ts); + if (client->dev.of_node) + ts->chip_id = (uintptr_t)of_device_get_match_data(&client->dev); + ts->vcc33 = devm_regulator_get(&client->dev, "vcc33"); if (IS_ERR(ts->vcc33)) { error = PTR_ERR(ts->vcc33); @@ -1495,7 +1568,8 @@ MODULE_DEVICE_TABLE(acpi, elants_acpi_id); #ifdef CONFIG_OF static const struct of_device_id elants_of_match[] = { - { .compatible = "elan,ekth3500" }, + { .compatible = "elan,ekth3500", .data = (void *)EKTH3500 }, + { .compatible = "elan,ektf3624", .data = (void *)EKTF3624 }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, elants_of_match); -- 2.20.1