From patchwork Sun Aug 29 09:19:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair X-Patchwork-Id: 504141 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 E8944C4320E for ; Sun, 29 Aug 2021 09:20:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4AF6603E7 for ; Sun, 29 Aug 2021 09:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234947AbhH2JVD (ORCPT ); Sun, 29 Aug 2021 05:21:03 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:45459 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234990AbhH2JVC (ORCPT ); Sun, 29 Aug 2021 05:21:02 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 5FAAC580B11; Sun, 29 Aug 2021 05:20:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 29 Aug 2021 05:20:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alistair23.me; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=00k/cE/VEfTz/ +dQ9yaE8zGdsiZBwAiNjh1K23Pi1yc=; b=1dSzrr5YQgzRyafCzkmNdpZkQJ8wD Pn0Z7M8IFhl5/higyORImVky4GaHqrhYsFOVVXpG/J9aB8K9k2cR4AC3VzIHbuWE dTvLAsD0mFnJL+Wi2wBdfFZBl8lU3DTUak2HOw3Jfn7XFPnQPzo4HekHojXLfjYI r4sQfCmsG/xKzxUOIOtIbs+C7RXzjua1z5xYcnphZfes3G5eNp67o+XSxD6Bd/Rc fvksOTrDdOfaVzk3y7XjKxmOvGykiVLjSgwA4Maiquee+3/tfB1m8EKIZ0Cd7Ero 13XDGzag+rRDrQC+uIzvg5rSBgVO5r+VmkmlJeH8orMBHIx73G4mff6Sw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=00k/cE/VEfTz/+dQ9yaE8zGdsiZBwAiNjh1K23Pi1yc=; b=lAcBFIi+ tEugxtw5tamyDhgH/0BOd5n76H+CYWiG8BKzYJXuvvO1vi00WiICoozEKedniPPc D2Id11EX/xdtik+CfiPrfO/+++C+xKYSAe4NvyrmkrXRXr3IARLrn8ud75/kxcyl QgIgcM19b86jZIG6n0P0cSAP+9SL82tkVYtSvqjjnUEZ8L7xFOrbsyyQEM5vmNUZ xrSHClGmXMcT1h1xtNtD+1AW/Sto/m7KIcVHPcEVMfaZy5vHpQBV85ks5YIii8fy G9erClRG6fi3DFhiJhPlxC9GQlm8WDQiaSVisNPk5/QsIh1gEKYhjde1+z1j7YdH O9VvznakMq4SDQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddujedgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehlihhsthgrihhrucfhrhgrnhgtihhsuceorghlihhsthgr ihhrsegrlhhishhtrghirhdvfedrmhgvqeenucggtffrrghtthgvrhhnpeeggedtteejke eggeeugfehueevudegvdetjeeviedugedvtdekffekhedtteduhfenucevlhhushhtvghr ufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhishhtrghirhesrghlih hsthgrihhrvdefrdhmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 29 Aug 2021 05:20:05 -0400 (EDT) From: Alistair Francis To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, pinglinux@gmail.com, tatsunosuke.tobita@wacom.com, junkpainting@gmail.com, ping.cheng@wacom.com Cc: linux-kernel@vger.kernel.org, alistair23@gmail.com, robh+dt@kernel.org, devicetree@vger.kernel.org, Alistair Francis Subject: [PATCH v10 05/12] Input: wacom_i2c - Read the descriptor values Date: Sun, 29 Aug 2021 19:19:18 +1000 Message-Id: <20210829091925.190-7-alistair@alistair23.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210829091925.190-1-alistair@alistair23.me> References: <20210829091925.190-1-alistair@alistair23.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org When we query the device let's also read the descriptor from the device. This tells us useful information, including the version, which we use to determine a generation. This is based on the driver from Wacom. Signed-off-by: Alistair Francis --- drivers/input/touchscreen/wacom_i2c.c | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c index 28255c77d426..72ba4a36459b 100644 --- a/drivers/input/touchscreen/wacom_i2c.c +++ b/drivers/input/touchscreen/wacom_i2c.c @@ -16,6 +16,7 @@ #include #include +#define WACOM_DESC_REG 0x01 #define WACOM_CMD_QUERY0 0x04 #define WACOM_CMD_QUERY1 0x00 #define WACOM_CMD_QUERY2 0x33 @@ -24,11 +25,46 @@ #define WACOM_CMD_THROW1 0x00 #define WACOM_QUERY_SIZE 19 +#define WACOM_MAX_DATA_SIZE_BG9 10 +#define WACOM_MAX_DATA_SIZE_G12 15 +#define WACOM_MAX_DATA_SIZE_AG14 17 +#define WACOM_MAX_DATA_SIZE 22 + +/* Generation selction */ +/* Before and at G9 generation */ +#define WACOM_BG9 0 +/* G12 generation the IC supports "height"*/ +#define WACOM_G12 1 +/* After and at G14 generation the IC supports "height" and + * it is defined as "Z" axis + */ +#define WACOM_AG14 2 + +struct wacom_desc { + u16 descLen; + u16 version; + u16 reportLen; + u16 reportReg; + u16 inputReg; + u16 maxInputLen; + u16 outputReg; + u16 maxOutputLen; + u16 commReg; + u16 dataReg; + u16 vendorID; + u16 productID; + u16 fwVersion; + u16 misc_high; + u16 misc_low; +}; + struct wacom_features { + struct wacom_desc desc; int x_max; int y_max; int pressure_max; char fw_version; + unsigned char generation; }; struct wacom_i2c { @@ -45,6 +81,7 @@ static int wacom_query_device(struct i2c_client *client, struct wacom_features *features) { int ret; + u8 cmd_wac_desc[] = {WACOM_DESC_REG, 0x00}; u8 cmd1[] = { WACOM_CMD_QUERY0, WACOM_CMD_QUERY1, WACOM_CMD_QUERY2, WACOM_CMD_QUERY3 }; u8 cmd2[] = { WACOM_CMD_THROW0, WACOM_CMD_THROW1 }; @@ -70,6 +107,33 @@ static int wacom_query_device(struct i2c_client *client, }, }; + /* Read the description register */ + ret = i2c_master_send(client, cmd_wac_desc, sizeof(cmd_wac_desc)); + if (ret < 0) + return ret; + ret = i2c_master_recv(client, (char *)&features->desc, sizeof(features->desc)); + if (ret < 0) + return ret; + + switch (features->desc.maxInputLen) { + case WACOM_MAX_DATA_SIZE_BG9: + features->generation = WACOM_BG9; + break; + + case WACOM_MAX_DATA_SIZE_G12: + features->generation = WACOM_G12; + break; + + case WACOM_MAX_DATA_SIZE_AG14: + features->generation = WACOM_AG14; + break; + + default: + /* Cover all generations possible */ + features->generation = WACOM_AG14; + break; + } + ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); if (ret < 0) return ret;