From patchwork Sun Mar 21 14:10:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair X-Patchwork-Id: 405972 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 EE13CC433E0 for ; Sun, 21 Mar 2021 14:11:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE2126024A for ; Sun, 21 Mar 2021 14:11:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbhCUOLP (ORCPT ); Sun, 21 Mar 2021 10:11:15 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:48109 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbhCUOLH (ORCPT ); Sun, 21 Mar 2021 10:11:07 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6CB925C00FF; Sun, 21 Mar 2021 10:11:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 21 Mar 2021 10:11:07 -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=fm3; bh=0KBDSN+M//14L U3MrMHPCIQQOcg9+lHSbWSqHVh3st8=; b=qoNtAcyNRPweYLi5sQmbqpiUK/ZI+ /HsSd+gJqVkdNHhQWtTCrwi3UGOJ1dNYY+d8ePP/nl3XyfNVgEPw5oWthSP7iSRE M1ZA0HRxQ+4JfsvEQBmZZRfBZMVOBLQX2Qn9aYUJ6mVmoudu4W4RESPeUGqWB8FA 90klhyX8oTiEZw2i4z/khnKufuRc56fxunkmXE1mhEjrFp/pJApIPzhOttRuXJlW oTWya98/Khk1QKh4Ox2vgLUDgdaB8f9rTtvtrK8RahdBni/WHaoklE7Jq87zXTyz xJ395qTWG0dWCkZabDMaEeJyomOyIpxLR0uvhx4z9kZXA5fUB3GwKgOkQ== 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= fm2; bh=0KBDSN+M//14LU3MrMHPCIQQOcg9+lHSbWSqHVh3st8=; b=SMsRnAMZ VudWXUuidvsyli9GCzV3eHKnRBW1eg3po9fqGdlg2fl/qZq9EiFA7VkxX4ObEuhG hzJx9/1ggdwKE8CpFeEBylF5jjQH83Z5/knIOCg6e0t1mcc434Vhc+PI94ZpNlnk Ju3lYsK9DsVBzY75CNUpmmbzwUQC1Vez/9uEN9pgJQuhsYOx4n0MuE4HNH1OKKFI jgHVAxG4JK43KKxNbqtLkB8d7nNU4KIc/jXZE6pN6YQYejO36VO8qwuthIrgkcQT fl8CNoU2HD/rcAQAxZGhFVodOCJ5/BLhPfXPcWIqeLRP8HX9TfPCdEgJWhIeCjsI zBoW/mKw9hHuYA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegvddgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehlihhsthgrihhrucfhrhgrnhgtihhsuceorghlihhsthgr ihhrsegrlhhishhtrghirhdvfedrmhgvqeenucggtffrrghtthgvrhhnpeeggedtteejke eggeeugfehueevudegvdetjeeviedugedvtdekffekhedtteduhfenucfkphepudelfedr vdejrddufedrvdefheenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrih hlfhhrohhmpegrlhhishhtrghirhesrghlihhsthgrihhrvdefrdhmvg X-ME-Proxy: Received: from ThinkpadX1Yoga3.localdomain (unknown [193.27.13.235]) by mail.messagingengine.com (Postfix) with ESMTPA id 7306D2400CC; Sun, 21 Mar 2021 10:11:06 -0400 (EDT) From: Alistair Francis To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de Cc: linux-kernel@vger.kernel.org, alistair23@gmail.com, Alistair Francis Subject: [PATCH v3 3/9] Input: wacom_i2c - Add device tree support to wacom_i2c Date: Sun, 21 Mar 2021 10:10:43 -0400 Message-Id: <20210321141049.148-4-alistair@alistair23.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210321141049.148-1-alistair@alistair23.me> References: <20210321141049.148-1-alistair@alistair23.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Allow the wacom-i2c device to be exposed via device tree. Signed-off-by: Alistair Francis --- drivers/input/touchscreen/wacom_i2c.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c index 1afc6bde2891..fc0bf583d33b 100644 --- a/drivers/input/touchscreen/wacom_i2c.c +++ b/drivers/input/touchscreen/wacom_i2c.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #define WACOM_CMD_QUERY0 0x04 @@ -262,10 +263,17 @@ static const struct i2c_device_id wacom_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, wacom_i2c_id); +static const struct of_device_id wacom_i2c_of_match_table[] __maybe_unused = { + { .compatible = "wacom,generic" }, + {} +}; +MODULE_DEVICE_TABLE(of, wacom_i2c_of_match_table); + static struct i2c_driver wacom_i2c_driver = { .driver = { .name = "wacom_i2c", .pm = &wacom_i2c_pm, + .of_match_table = of_match_ptr(wacom_i2c_of_match_table), }, .probe = wacom_i2c_probe, From patchwork Sun Mar 21 14:10:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair X-Patchwork-Id: 405971 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 3D29DC433E3 for ; Sun, 21 Mar 2021 14:11:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 109CC61946 for ; Sun, 21 Mar 2021 14:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230006AbhCUOLP (ORCPT ); Sun, 21 Mar 2021 10:11:15 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:55833 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbhCUOLJ (ORCPT ); Sun, 21 Mar 2021 10:11:09 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 7077D5C010D; Sun, 21 Mar 2021 10:11:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 21 Mar 2021 10:11:09 -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=fm3; bh=K095MDsa2rzvq +bTQ66D8DiKMgrE+in12AqXZ5ineXk=; b=nkC4TZFtCMuS0Cnbps014mBNRY6B1 YeEwjobF1HkC85esKZ68D3PttjN+fXb24K8aeNAlh+ilJp2mOlr045DTrcQ+75PA X9ZSYujsCnUz4E98QFsRSkeuJ8hfXfNLUFoCqkNr1o2XNWi84tqJwKUDwQ0VO5fi NaqiX7E77S8Rrb+qlP42wA3kJo8sCR9b2mKISQs7spdYt+oB2Vg444RZzI4uh0Nt 7Nn/ewbSaxNZLqSkW7fnLoUz8X2Gi5wRtNs8Oj8tfkZsGA6ZEEQSQYajloxgxSKe IThYbsxyslwkinxNVipJRrBvhCjqwJy2lJ7o5nqpWDT8dHmpvzzkdeVPQ== 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= fm2; bh=K095MDsa2rzvq+bTQ66D8DiKMgrE+in12AqXZ5ineXk=; b=L6q7vKd/ vr2PpeaH1Ndmb4xPgZNXgXFCNQ/BVvMwLkZe8vRPuesJFP/a28kFVEfb/HzhqmFS DeByvGVJxvQNlvoMHG7oxi5oDo0EqNLY4uusI6CIEtdJW+JwaeE5WwGY1htack0L EdNWjmYu0nZoh8Qu4drSTZkwJJWzyC8+U1+Dr0zXBw5uCpE2CVWGnm1jJrApGJ+E sazH3BBDNXsxyb9khilNmM8NcUUy0dhNziZrZalVIU7xrSjZgKtGg7ejvQNBB5rc yrTS8QB/NL66YUwSHs7lDjRnhi0kjfV3JDBpA0XvdlMRD4an5IysWNmBIIbxkdRq LirBsVqk2p34xA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegvddgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehlihhsthgrihhrucfhrhgrnhgtihhsuceorghlihhsthgr ihhrsegrlhhishhtrghirhdvfedrmhgvqeenucggtffrrghtthgvrhhnpeeggedtteejke eggeeugfehueevudegvdetjeeviedugedvtdekffekhedtteduhfenucfkphepudelfedr vdejrddufedrvdefheenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrih hlfhhrohhmpegrlhhishhtrghirhesrghlihhsthgrihhrvdefrdhmvg X-ME-Proxy: Received: from ThinkpadX1Yoga3.localdomain (unknown [193.27.13.235]) by mail.messagingengine.com (Postfix) with ESMTPA id 7EBD2240138; Sun, 21 Mar 2021 10:11:08 -0400 (EDT) From: Alistair Francis To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de Cc: linux-kernel@vger.kernel.org, alistair23@gmail.com, Alistair Francis Subject: [PATCH v3 5/9] Input: wacom_i2c - Add support for distance and tilt x/y Date: Sun, 21 Mar 2021 10:10:45 -0400 Message-Id: <20210321141049.148-6-alistair@alistair23.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210321141049.148-1-alistair@alistair23.me> References: <20210321141049.148-1-alistair@alistair23.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This is based on the out of tree rM2 driver. Signed-off-by: Alistair Francis --- drivers/input/touchscreen/wacom_i2c.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c index 9b2ed0463d09..929680dce9cf 100644 --- a/drivers/input/touchscreen/wacom_i2c.c +++ b/drivers/input/touchscreen/wacom_i2c.c @@ -22,12 +22,16 @@ #define WACOM_CMD_QUERY3 0x02 #define WACOM_CMD_THROW0 0x05 #define WACOM_CMD_THROW1 0x00 -#define WACOM_QUERY_SIZE 19 +#define WACOM_QUERY_SIZE 22 struct wacom_features { int x_max; int y_max; int pressure_max; + int distance_max; + int distance_physical_max; + int tilt_x_max; + int tilt_y_max; char fw_version; }; @@ -79,6 +83,10 @@ static int wacom_query_device(struct i2c_client *client, features->y_max = get_unaligned_le16(&data[5]); features->pressure_max = get_unaligned_le16(&data[11]); features->fw_version = get_unaligned_le16(&data[13]); + features->distance_max = data[15]; + features->distance_physical_max = data[16]; + features->tilt_x_max = get_unaligned_le16(&data[17]); + features->tilt_y_max = get_unaligned_le16(&data[19]); dev_dbg(&client->dev, "x_max:%d, y_max:%d, pressure:%d, fw:%d\n", @@ -95,6 +103,7 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id) u8 *data = wac_i2c->data; unsigned int x, y, pressure; unsigned char tsw, f1, f2, ers; + short tilt_x, tilt_y, distance; int error; error = i2c_master_recv(wac_i2c->client, @@ -109,6 +118,11 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id) x = le16_to_cpup((__le16 *)&data[4]); y = le16_to_cpup((__le16 *)&data[6]); pressure = le16_to_cpup((__le16 *)&data[8]); + distance = data[10]; + + /* Signed */ + tilt_x = le16_to_cpup((__le16 *)&data[11]); + tilt_y = le16_to_cpup((__le16 *)&data[13]); if (!wac_i2c->prox) wac_i2c->tool = (data[3] & 0x0c) ? @@ -123,6 +137,9 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id) input_report_abs(input, ABS_X, x); input_report_abs(input, ABS_Y, y); input_report_abs(input, ABS_PRESSURE, pressure); + input_report_abs(input, ABS_DISTANCE, distance); + input_report_abs(input, ABS_TILT_X, tilt_x); + input_report_abs(input, ABS_TILT_Y, tilt_y); input_sync(input); out: @@ -195,7 +212,11 @@ static int wacom_i2c_probe(struct i2c_client *client, input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0); input_set_abs_params(input, ABS_PRESSURE, 0, features.pressure_max, 0, 0); - + input_set_abs_params(input, ABS_DISTANCE, 0, features.distance_max, 0, 0); + input_set_abs_params(input, ABS_TILT_X, -features.tilt_x_max, + features.tilt_x_max, 0, 0); + input_set_abs_params(input, ABS_TILT_Y, -features.tilt_y_max, + features.tilt_y_max, 0, 0); input_set_drvdata(input, wac_i2c); error = request_threaded_irq(client->irq, NULL, wacom_i2c_irq, From patchwork Sun Mar 21 14:10:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair X-Patchwork-Id: 405970 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 7BC25C433E8 for ; Sun, 21 Mar 2021 14:11:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62CAD61943 for ; Sun, 21 Mar 2021 14:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230022AbhCUOLQ (ORCPT ); Sun, 21 Mar 2021 10:11:16 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:47153 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbhCUOLK (ORCPT ); Sun, 21 Mar 2021 10:11:10 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6B6A85C0116; Sun, 21 Mar 2021 10:11:10 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 21 Mar 2021 10:11: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=fm3; bh=x+Hb78RjpnhpB kIL3qRebVWJuGh/fm1C5mpC8sGyBiU=; b=ionGDJ5KgwcKjEi+yH2c6/i6IEHVZ 3F3T48rR0wj4YIjEi4q6vb6BgrNcXsADsosui5GuFmTMhFoI6Hr+4NDiPXPmkj0h t8NGaIh64C5mFbKqhKAaHExrpljpXfD3uvoUNYpDmUSm0M8+37HXV89bnwvhnCYC WgCgcl6odsv0RzK/LdSMU0hYkfncr+mvgpIHO8IrQSI6wlhQgofTt++ayGRDGs+8 FQscrCO2dOlobJdFPPKqD05s5AOTS7gdn3gJuT/IRL8g3F25M0DA2wJdFNLU7KV1 0P7mzKaomTVcM2TX1q6QG4QdHPSDYa61+pq7t5eovI90Uw3HAZDN1653A== 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= fm2; bh=x+Hb78RjpnhpBkIL3qRebVWJuGh/fm1C5mpC8sGyBiU=; b=rJc9jhRQ oYYVUuXWzLSOf9QloJFqvMXWyucM8BHPJn3ozludbVuEUEPQhoO9j8UCaVjMnHZy zakQ4DI0KBuDlpIn3Lj5Ye7uHxIPxyGtIWvGJwRhjoEu5aKVD93j+V82QoR1Qp46 pwBp64WWPEoqOfqwWgt+55nJZ1BhVE+uDevqDyxZRWltaDNmdOWvRFHFh8JMehtI clsW2fV80LdhOnOlCltWXkfGljAAb24wlyujiLWFHtjpAPr/zPlxLBYUjzdTlhS0 Es2sGuBOQlL94xGg3d74EcGDIdP8QYGHYO6XHB1B+vsh28hX24gIdSaQrFBmyg8g XxoQVlws4ATw6Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegvddgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehlihhsthgrihhrucfhrhgrnhgtihhsuceorghlihhsthgr ihhrsegrlhhishhtrghirhdvfedrmhgvqeenucggtffrrghtthgvrhhnpeeggedtteejke eggeeugfehueevudegvdetjeeviedugedvtdekffekhedtteduhfenucfkphepudelfedr vdejrddufedrvdefheenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrih hlfhhrohhmpegrlhhishhtrghirhesrghlihhsthgrihhrvdefrdhmvg X-ME-Proxy: Received: from ThinkpadX1Yoga3.localdomain (unknown [193.27.13.235]) by mail.messagingengine.com (Postfix) with ESMTPA id 7E6B4240138; Sun, 21 Mar 2021 10:11:09 -0400 (EDT) From: Alistair Francis To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de Cc: linux-kernel@vger.kernel.org, alistair23@gmail.com, Alistair Francis Subject: [PATCH v3 6/9] Input: wacom_i2c - Clean up the query device fields Date: Sun, 21 Mar 2021 10:10:46 -0400 Message-Id: <20210321141049.148-7-alistair@alistair23.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210321141049.148-1-alistair@alistair23.me> References: <20210321141049.148-1-alistair@alistair23.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Improve the query device fields to be more verbose. Signed-off-by: Alistair Francis --- drivers/input/touchscreen/wacom_i2c.c | 71 +++++++++++++++++++-------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c index 929680dce9cf..7aa0d1c3dbc9 100644 --- a/drivers/input/touchscreen/wacom_i2c.c +++ b/drivers/input/touchscreen/wacom_i2c.c @@ -13,15 +13,32 @@ #include #include #include +#include #include #include -#define WACOM_CMD_QUERY0 0x04 -#define WACOM_CMD_QUERY1 0x00 -#define WACOM_CMD_QUERY2 0x33 -#define WACOM_CMD_QUERY3 0x02 -#define WACOM_CMD_THROW0 0x05 -#define WACOM_CMD_THROW1 0x00 +// Registers +#define WACOM_COMMAND_LSB 0x04 +#define WACOM_COMMAND_MSB 0x00 + +#define WACOM_DATA_LSB 0x05 +#define WACOM_DATA_MSB 0x00 + +// Report types +#define REPORT_FEATURE 0x30 + +// Requests / operations +#define OPCODE_GET_REPORT 0x02 + +// Power settings +#define POWER_ON 0x00 +#define POWER_SLEEP 0x01 + +// Input report ids +#define WACOM_PEN_DATA_REPORT 2 +#define WACOM_SHINONOME_REPORT 26 + +#define WACOM_QUERY_REPORT 3 #define WACOM_QUERY_SIZE 22 struct wacom_features { @@ -48,31 +65,41 @@ static int wacom_query_device(struct i2c_client *client, struct wacom_features *features) { int ret; - u8 cmd1[] = { WACOM_CMD_QUERY0, WACOM_CMD_QUERY1, - WACOM_CMD_QUERY2, WACOM_CMD_QUERY3 }; - u8 cmd2[] = { WACOM_CMD_THROW0, WACOM_CMD_THROW1 }; u8 data[WACOM_QUERY_SIZE]; + struct reset_control *rstc; + + u8 get_query_data_cmd[] = { + WACOM_COMMAND_LSB, + WACOM_COMMAND_MSB, + REPORT_FEATURE | WACOM_QUERY_REPORT, + OPCODE_GET_REPORT, + WACOM_DATA_LSB, + WACOM_DATA_MSB, + }; + struct i2c_msg msgs[] = { + // Request reading of feature ReportID: 3 (Pen Query Data) { .addr = client->addr, .flags = 0, - .len = sizeof(cmd1), - .buf = cmd1, - }, - { - .addr = client->addr, - .flags = 0, - .len = sizeof(cmd2), - .buf = cmd2, + .len = sizeof(get_query_data_cmd), + .buf = get_query_data_cmd, }, + // Read 21 bytes { .addr = client->addr, .flags = I2C_M_RD, - .len = sizeof(data), + .len = WACOM_QUERY_SIZE - 1, .buf = data, }, }; + rstc = devm_reset_control_get_optional_exclusive(&client->dev, NULL); + if (IS_ERR(rstc)) + dev_err(&client->dev, "Failed to get reset control before init\n"); + else + reset_control_reset(rstc); + ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); if (ret < 0) return ret; @@ -89,9 +116,13 @@ static int wacom_query_device(struct i2c_client *client, features->tilt_y_max = get_unaligned_le16(&data[19]); dev_dbg(&client->dev, - "x_max:%d, y_max:%d, pressure:%d, fw:%d\n", + "x_max:%d, y_max:%d, pressure:%d, fw:%d, " + "distance: %d, phys distance: %d, " + "tilt_x_max: %d, tilt_y_max: %d\n", features->x_max, features->y_max, - features->pressure_max, features->fw_version); + features->pressure_max, features->fw_version, + features->distance_max, features->distance_physical_max, + features->tilt_x_max, features->tilt_y_max); return 0; } From patchwork Sun Mar 21 14:10:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair X-Patchwork-Id: 405969 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 52A5BC433E6 for ; Sun, 21 Mar 2021 14:11:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3ACA46024A for ; Sun, 21 Mar 2021 14:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230034AbhCUOLQ (ORCPT ); Sun, 21 Mar 2021 10:11:16 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:42859 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbhCUOLM (ORCPT ); Sun, 21 Mar 2021 10:11:12 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6D4D85C00CB; Sun, 21 Mar 2021 10:11:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 21 Mar 2021 10:11:11 -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=fm3; bh=32flhDWiUNY2V sj5ubaE1JFNCRDha2jAWNSmn4As7OM=; b=UQ9+vL0f0OMKIxa5KeLtca8UogsEt Psnoy6ARArYlTXcYAXm0pAVCU3FbsaqHszT95/Uo6h6Li7V4lwhkbhrCDUKvlgDY 6uAMaO0mx1KlmcGnSPy67XZmF+5OtILdbkVEHhVkN7X0FAI9xDhZ46eFPbQwjDrJ 2jhx/brmvEK6W+t2Ljdf7Ay6T6YzbU/0PrZOTjo6c+z/Rjsk9ZjHuB8/U0w0bLyO d3e/+PSztcnIh3+I0RZi3WSZAM4YD2qAORb2xFOgQnezKe5u2QPq7AAQZaubNxfi f5CBZuwX+9D4wAzdn9KKmxGd/t/mUmRW1ES/4qTYKBfCqa6mr7QB+YNRA== 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= fm2; bh=32flhDWiUNY2Vsj5ubaE1JFNCRDha2jAWNSmn4As7OM=; b=JGOyTmud +NGm30J11LpS9tbe0DFVvbZTX8XpB5lax6aNfHJ8a01KxGKtwI9JUZ4aZQqAVj7M ySGMRXJPVUS7RUb6zxPtzlwoJlbUId236WOhQ62hGkPzMm9s47T6WCPxx+Cuk8/y h64wLrc1haRTm6rh2Qwm00PCvztXyVpnSZ/Z6A27o2qIcLcpR25GGVW0nQpBm5R8 zShKK7IFDbG4lqxvA0nAidQW6fwEgUsvGBWcjLozPs7rNdO71DtWWmeVWx7t+H/I F86Ghic1kZDRPw6XthGTJabF5FN1TWD4iuvd/zkTmEzSa6NgdMNnghY/lpgQgOA4 quUh6br5Jxy7Hg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegvddgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehlihhsthgrihhrucfhrhgrnhgtihhsuceorghlihhsthgr ihhrsegrlhhishhtrghirhdvfedrmhgvqeenucggtffrrghtthgvrhhnpeeggedtteejke eggeeugfehueevudegvdetjeeviedugedvtdekffekhedtteduhfenucfkphepudelfedr vdejrddufedrvdefheenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrih hlfhhrohhmpegrlhhishhtrghirhesrghlihhsthgrihhrvdefrdhmvg X-ME-Proxy: Received: from ThinkpadX1Yoga3.localdomain (unknown [193.27.13.235]) by mail.messagingengine.com (Postfix) with ESMTPA id 79FD12400CC; Sun, 21 Mar 2021 10:11:10 -0400 (EDT) From: Alistair Francis To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de Cc: linux-kernel@vger.kernel.org, alistair23@gmail.com, Alistair Francis Subject: [PATCH v3 7/9] Input: wacom_i2c - Add support for vdd regulator Date: Sun, 21 Mar 2021 10:10:47 -0400 Message-Id: <20210321141049.148-8-alistair@alistair23.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210321141049.148-1-alistair@alistair23.me> References: <20210321141049.148-1-alistair@alistair23.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add support for a VDD regulator. This allows the kernel to prove the Wacom-I2C device on the rM2. Signed-off-by: Alistair Francis --- drivers/input/touchscreen/wacom_i2c.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c index 7aa0d1c3dbc9..00db516fa3de 100644 --- a/drivers/input/touchscreen/wacom_i2c.c +++ b/drivers/input/touchscreen/wacom_i2c.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,7 @@ struct wacom_i2c { struct i2c_client *client; struct input_dev *input; struct touchscreen_properties props; + struct regulator *vdd; u8 data[WACOM_QUERY_SIZE]; bool prox; int tool; @@ -203,11 +205,29 @@ static int wacom_i2c_probe(struct i2c_client *client, struct wacom_features features = { 0 }; int error; + wac_i2c = kzalloc(sizeof(*wac_i2c), GFP_KERNEL); + if (!wac_i2c) + return -ENOMEM; + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(&client->dev, "i2c_check_functionality error\n"); return -EIO; } + wac_i2c->vdd = regulator_get(&client->dev, "vdd"); + if (IS_ERR(wac_i2c->vdd)) { + error = PTR_ERR(wac_i2c->vdd); + kfree(wac_i2c); + return error; + } + + error = regulator_enable(wac_i2c->vdd); + if (error) { + regulator_put(wac_i2c->vdd); + kfree(wac_i2c); + return error; + } + error = wacom_query_device(client, &features); if (error) return error; @@ -275,6 +295,8 @@ static int wacom_i2c_probe(struct i2c_client *client, err_free_irq: free_irq(client->irq, wac_i2c); err_free_mem: + regulator_disable(wac_i2c->vdd); + regulator_put(wac_i2c->vdd); input_free_device(input); kfree(wac_i2c);