From patchwork Fri May 24 14:39:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Selvaraj via B4 Relay X-Patchwork-Id: 798786 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1D3286643; Fri, 24 May 2024 14:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716561589; cv=none; b=kpuZ2efmZtZlpdfGTtYTKgOgnuE+hxU3KhlQSdOfIEOcjpfAOdKy+QZLvmoU4ht2FE8enG8jQkYNX59XVkIvtJXPULkeV0zHlQQ9kDgFglMx2CW+uvDqq1mb8fJYVZd2ukfC+Dv/hCDfza/vajfCMG+fIoJaDlPUwgB1QeLFclk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716561589; c=relaxed/simple; bh=M9oEkYlMCsLV8xMj4+wTERAWbk6x/3fQFKuCW2n0YG8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VdgxfN8qY4GZlOFEGV7pt1R5OmbYh6oZStXweiU12gMkSR5PoMbsPgXTwzxIT/uSR3Rbi8eDCNoJDN4RVIFnNNyh2ePO/KZbTOSAJwh4fDVg+syg/AOMVc1G5zUay10Il0v0CfuC9phqIFkF0ceaY4mITZhQRoE1A3Pdejh6LtM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bt2WlCCG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bt2WlCCG" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7A61CC32782; Fri, 24 May 2024 14:39:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716561589; bh=M9oEkYlMCsLV8xMj4+wTERAWbk6x/3fQFKuCW2n0YG8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Bt2WlCCGVn3Nt81R3yCa8GpCrYR4fOUV/UdO0/yyIWOtRzvm+vO/8J2RXbzAmuXwo uL0ZhJTyx8BLSagQLCng+6mubnw1I2W+lzLh1IPAYq7kN6sA4h9B3yAKVLt2jH2Rs5 AXrAJrpDkd17NTir6HZ0jdZc7jFle3FRZ+vK4tKMVlz3xKG48cdRm+Gepc3rOd0hha ivMAUuDwBdST34b8LdZL1BPaNauNMF7Xne+TeShr3l7r4iDYetPtEUe5x3xxKC3U7Q kEeUTdt4WrbeqiLggBJQVTiFtBOgRgirtlbzuue49W7zT96y5tx6J9r2LU5o2XTi+l rmqLzBuox9HlA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B367C25B7C; Fri, 24 May 2024 14:39:49 +0000 (UTC) From: Joel Selvaraj via B4 Relay Date: Fri, 24 May 2024 09:39:18 -0500 Subject: [PATCH v2 1/3] Input: novatek-nvt-ts: replace generic i2c device id with specific IC variant Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240524-nvt-ts-devicetree-regulator-support-v2-1-b74947038c44@gmail.com> References: <20240524-nvt-ts-devicetree-regulator-support-v2-0-b74947038c44@gmail.com> In-Reply-To: <20240524-nvt-ts-devicetree-regulator-support-v2-0-b74947038c44@gmail.com> To: Hans de Goede , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, Joel Selvaraj X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1716561588; l=1393; i=joelselvaraj.oss@gmail.com; s=20240420; h=from:subject:message-id; bh=o9JSDCGAeFyywH+QabP9V+yumWYX1UdF0t0fi0getJU=; b=+OHGaB9WLCWxuEeAT06cejRG59IV/cz0Vfn5cBW7XM9N5BLLtADdbu3SlSTg8/7LJHtJssDAJ lujx96/TNl1ApdmyOspcU4XlxT0qo/HB70ckz2PcY1BzGCLk9SlfNlK X-Developer-Key: i=joelselvaraj.oss@gmail.com; a=ed25519; pk=qT4gsuVtlPE0Dpr+tQA/Fumm7wzVP6qfeVaY+6pX04s= X-Endpoint-Received: by B4 Relay for joelselvaraj.oss@gmail.com/20240420 with auth_id=165 X-Original-From: Joel Selvaraj Reply-To: joelselvaraj.oss@gmail.com From: Joel Selvaraj This is done in preparation to introduce other variants of the Novatek NVT touchscreen controller that can be supported by the driver. Signed-off-by: Joel Selvaraj --- drivers/input/touchscreen/novatek-nvt-ts.c | 2 +- drivers/platform/x86/x86-android-tablets/other.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/novatek-nvt-ts.c b/drivers/input/touchscreen/novatek-nvt-ts.c index 1a797e410a3fa..224fd112b25a9 100644 --- a/drivers/input/touchscreen/novatek-nvt-ts.c +++ b/drivers/input/touchscreen/novatek-nvt-ts.c @@ -278,7 +278,7 @@ static int nvt_ts_probe(struct i2c_client *client) } static const struct i2c_device_id nvt_ts_i2c_id[] = { - { "NVT-ts" }, + { "NT11205-ts" }, { } }; MODULE_DEVICE_TABLE(i2c, nvt_ts_i2c_id); diff --git a/drivers/platform/x86/x86-android-tablets/other.c b/drivers/platform/x86/x86-android-tablets/other.c index eb0e55c69dfed..5ecee6e66fb4d 100644 --- a/drivers/platform/x86/x86-android-tablets/other.c +++ b/drivers/platform/x86/x86-android-tablets/other.c @@ -40,7 +40,7 @@ static const struct x86_i2c_client_info acer_b1_750_i2c_clients[] __initconst = { /* Novatek NVT-ts touchscreen */ .board_info = { - .type = "NVT-ts", + .type = "NT11205-ts", .addr = 0x34, .dev_name = "NVT-ts", }, From patchwork Fri May 24 14:39:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Selvaraj via B4 Relay X-Patchwork-Id: 798787 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1CC117C9; Fri, 24 May 2024 14:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716561589; cv=none; b=mhSZozOCHHwLC7QBTi9Llbcv9sXgk0e9kLoTbzMDhl6ODod6YAhYvjF6SbMvPxfpNKTeBDL52hNgmOt9W/8RcM3P9bx3pIEpsLRgwH2O73GssuadzfozrOW7Ed51hYGVBCiqpPo6K9xIhvSoZkGdIhmyS3wUbh/3SXNDfjiXPts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716561589; c=relaxed/simple; bh=qPagS3nf7JxLDEBoJP6Rlhnx9zPxEQqI9AG4+8sd/Oo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SXrlhEh/wTJKWQ16zw324XF0Jbfs3tL3AdgAVzpin9wJrtykg2Yyn8pO1p6Dg95dPxl0LKyjNrOkUKqDGxFPSiCme/hkVfA19m1AtkZZJwxkcMnGywWvTchgBdhE92KIoYD7TcxfT/YvQd/q+wNllnTrxuTks6xwmHHB7eWsiOQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a5U1d6lj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="a5U1d6lj" Received: by smtp.kernel.org (Postfix) with ESMTPS id 81378C2BD11; Fri, 24 May 2024 14:39:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716561589; bh=qPagS3nf7JxLDEBoJP6Rlhnx9zPxEQqI9AG4+8sd/Oo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=a5U1d6lj5avUgnLbwhLnasDun9VuLD6Pq/mjpi/7jv7N7IGzpIngjgD4vilY1n6QZ zOfbqsOmWG1fxUABq3uBdE2Pf67RCpya3JZRtbrU8EAjEq5oRHJqxRiZAUazcw2ekT iLj+dG3T5C1aKQCpib/8bKODh+xQnpzheOniz3SHbA7sjxl4Poqg8XVMuhkbHIe4rW Uzz6GyNwE2K2WuFK4FzA3QLbDUrQPvoMsNdIoiXBqDbAGh5GTUq9jaU7hr5vPGh0AZ JPncP6XxhC+5r8zyDInFjaaLJvEc3mr2h5MQRA377B2DbzViyLaCLvura7nl6j0sIm 4jhX8OEwoRf5A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6912FC25B7D; Fri, 24 May 2024 14:39:49 +0000 (UTC) From: Joel Selvaraj via B4 Relay Date: Fri, 24 May 2024 09:39:19 -0500 Subject: [PATCH v2 2/3] dt-bindings: input: document Novatek NVT touchscreen controller Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240524-nvt-ts-devicetree-regulator-support-v2-2-b74947038c44@gmail.com> References: <20240524-nvt-ts-devicetree-regulator-support-v2-0-b74947038c44@gmail.com> In-Reply-To: <20240524-nvt-ts-devicetree-regulator-support-v2-0-b74947038c44@gmail.com> To: Hans de Goede , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, Joel Selvaraj X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1716561588; l=2807; i=joelselvaraj.oss@gmail.com; s=20240420; h=from:subject:message-id; bh=Y6dkGY1AKwCQh1ciYwF2DiXPtYGhHE52a60bkhbIlpc=; b=YJD1TuFL0D65mNKAyem1JMSxF062NJeL2lFevzqLNvapmkGwEpGn6W+EksRgr26odzQCIas0Z ARnVuVCHoCHAQSjHxcO1EKB+XS9z9dysNdHYAWfB8a2InIhr0Ja1/na X-Developer-Key: i=joelselvaraj.oss@gmail.com; a=ed25519; pk=qT4gsuVtlPE0Dpr+tQA/Fumm7wzVP6qfeVaY+6pX04s= X-Endpoint-Received: by B4 Relay for joelselvaraj.oss@gmail.com/20240420 with auth_id=165 X-Original-From: Joel Selvaraj Reply-To: joelselvaraj.oss@gmail.com From: Joel Selvaraj Document the Novatek NVT touchscreen controller present in devices like the Xiaomi Poco F1 [1]. Also, include the devictree binding file in the MAINTAINERS file. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium-tianma.dts?h=v6.9 Signed-off-by: Joel Selvaraj Reviewed-by: Krzysztof Kozlowski --- .../bindings/input/touchscreen/novatek,nvt-ts.yaml | 62 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 63 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/novatek,nvt-ts.yaml b/Documentation/devicetree/bindings/input/touchscreen/novatek,nvt-ts.yaml new file mode 100644 index 0000000000000..c47b4de9d58e7 --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/novatek,nvt-ts.yaml @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/novatek,nvt-ts.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Novatek NVT Touchscreen Controller + +maintainers: + - Hans de Goede + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + enum: + - novatek,nt11205-ts + - novatek,nt36672a-ts + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vcc-supply: true + iovcc-supply: true + +required: + - compatible + - reg + - interrupts + +unevaluatedProperties: false + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + touchscreen@1 { + compatible = "novatek,nt36672a-ts"; + reg = <0x01>; + interrupts-extended = <&tlmm 31 IRQ_TYPE_EDGE_RISING>; + reset-gpios = <&tlmm 32 GPIO_ACTIVE_LOW>; + vcc-supply = <&vreg_l22a_2p85>; + iovcc-supply = <&vreg_l14a_1p8>; + pinctrl-0 = <&ts_int_default &ts_reset_default>; + pinctrl-1 = <&ts_int_sleep &ts_reset_sleep>; + pinctrl-names = "default", "sleep"; + touchscreen-size-x = <1080>; + touchscreen-size-y = <2246>; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 90754a451bcfc..e1f744992b15f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15942,6 +15942,7 @@ NOVATEK NVT-TS I2C TOUCHSCREEN DRIVER M: Hans de Goede L: linux-input@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/novatek,nvt-ts.yaml F: drivers/input/touchscreen/novatek-nvt-ts.c NSDEPS From patchwork Fri May 24 14:39:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Selvaraj via B4 Relay X-Patchwork-Id: 799029 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1CF642AB7; Fri, 24 May 2024 14:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716561589; cv=none; b=MaBnu4l7RmTMK+Y9C+JDKVyn+f4CMKYN+yz4BUI7sBq9IHhTjZtOsSItjqP/3iEU02MinMzDXfcEfef1utp/LR496Vk9PNUGRLigu2GbmZ6W7XS4w2zEnBajdM3J7Zt9haaGYMgVFxOl/I3nm5y/JsrBV/2bYh+hhFMEYiZM72w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716561589; c=relaxed/simple; bh=azd/+Jtb3PR7LZMaQHlxqyMQJmkcRTdfxSuAuKzYoWs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KS/tOozzFreOpkQv83qtsQl/U8FtCsgKKTfiPJl1o0f3bTTino662ugKHz+4nqKhiz70hEaudSive2cFz24Q6Tdk/y6OvgsrkNL75T0lkMo0BSoFb8wjzwjMT63IfVGR1mQVgOelYu4N3437tXlG3DFydpbG9v1a4oyFhURompw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M2aQRmyy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M2aQRmyy" Received: by smtp.kernel.org (Postfix) with ESMTPS id 89298C32789; Fri, 24 May 2024 14:39:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716561589; bh=azd/+Jtb3PR7LZMaQHlxqyMQJmkcRTdfxSuAuKzYoWs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=M2aQRmyyaZQfqtPWnQ/9RXPSHv41T39imxCCf/golpT5NtAVqcl3A+QZlyZR467nd IdxVWUgM986bNzwEv1VzF5YxjEgRgsxKRP6CinpHIW7e1M+q7yK8TWl+VfTde6jM9l ibIcRIMVTCg3fP/3mu8RwKsJojGqfQB7FDlqHoJPsdPhHg6qZA+M4PQKB/fAtuheae fhxJvjC0BvOn8eJX8idOx+GE5NTjP8qY7vf/JB9046yDTyDKz53hwifS7uOA9sKEKj yMkM8GAItvk1WhdT4tKc0wGr1B66mdAXffC86gtUIwtWh1QNJDNNXpDZLZhgIVPsKu QASO57CziNszQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77786C25B7A; Fri, 24 May 2024 14:39:49 +0000 (UTC) From: Joel Selvaraj via B4 Relay Date: Fri, 24 May 2024 09:39:20 -0500 Subject: [PATCH v2 3/3] Input: novatek-nvt-ts: add support for NT36672A touchscreen Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240524-nvt-ts-devicetree-regulator-support-v2-3-b74947038c44@gmail.com> References: <20240524-nvt-ts-devicetree-regulator-support-v2-0-b74947038c44@gmail.com> In-Reply-To: <20240524-nvt-ts-devicetree-regulator-support-v2-0-b74947038c44@gmail.com> To: Hans de Goede , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, Joel Selvaraj X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1716561588; l=5429; i=joelselvaraj.oss@gmail.com; s=20240420; h=from:subject:message-id; bh=iS/qydC+3ZyOwj/BFn5ZeWXmsLtQZbVeeksPZgAo5MU=; b=it6bM7idQMfK/9zprRb/BDnQ0I6+EMIqT/GWcPoiI4aCre6zWER6hYdZarF2jpU0n3F47QCl3 6SnhCHRKA8KCQoBPzdUHXALe+CrZUeBtTpOZgvHZpkQw7yIj73yDMYN X-Developer-Key: i=joelselvaraj.oss@gmail.com; a=ed25519; pk=qT4gsuVtlPE0Dpr+tQA/Fumm7wzVP6qfeVaY+6pX04s= X-Endpoint-Received: by B4 Relay for joelselvaraj.oss@gmail.com/20240420 with auth_id=165 X-Original-From: Joel Selvaraj Reply-To: joelselvaraj.oss@gmail.com From: Joel Selvaraj Extend the novatek touchscreen driver to support NT36672A chip which is found in phones like Xiaomi Poco F1 [1]. Added devicetree support for the driver and used i2c chip data to handle the variation in chip id and wake type. Also added vcc and iovcc regulators which are used to power the touchscreen hardware. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium-tianma.dts?h=v6.9 Signed-off-by: Joel Selvaraj --- drivers/input/touchscreen/novatek-nvt-ts.c | 78 +++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/novatek-nvt-ts.c b/drivers/input/touchscreen/novatek-nvt-ts.c index 224fd112b25a9..7a82a1b09f9d5 100644 --- a/drivers/input/touchscreen/novatek-nvt-ts.c +++ b/drivers/input/touchscreen/novatek-nvt-ts.c @@ -31,9 +31,6 @@ #define NVT_TS_PARAMS_CHIP_ID 0x0e #define NVT_TS_PARAMS_SIZE 0x0f -#define NVT_TS_SUPPORTED_WAKE_TYPE 0x05 -#define NVT_TS_SUPPORTED_CHIP_ID 0x05 - #define NVT_TS_MAX_TOUCHES 10 #define NVT_TS_MAX_SIZE 4096 @@ -51,11 +48,18 @@ static const int nvt_ts_irq_type[4] = { IRQF_TRIGGER_HIGH }; +struct nvt_ts_i2c_chip_data { + u8 wake_type; + u8 chip_id; +}; + struct nvt_ts_data { struct i2c_client *client; struct input_dev *input; struct gpio_desc *reset_gpio; + struct regulator_bulk_data regulators[2]; struct touchscreen_properties prop; + const struct nvt_ts_i2c_chip_data *chip; int max_touches; u8 buf[NVT_TS_TOUCH_SIZE * NVT_TS_MAX_TOUCHES]; }; @@ -139,9 +143,23 @@ static irqreturn_t nvt_ts_irq(int irq, void *dev_id) return IRQ_HANDLED; } +static void nvt_ts_disable_regulators(void *_data) +{ + struct nvt_ts_data *data = _data; + + regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); +} + static int nvt_ts_start(struct input_dev *dev) { struct nvt_ts_data *data = input_get_drvdata(dev); + int error; + + error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), data->regulators); + if (error) { + dev_err(&data->client->dev, "failed to enable regulators\n"); + return error; + } enable_irq(data->client->irq); gpiod_set_value_cansleep(data->reset_gpio, 0); @@ -155,6 +173,7 @@ static void nvt_ts_stop(struct input_dev *dev) disable_irq(data->client->irq); gpiod_set_value_cansleep(data->reset_gpio, 1); + nvt_ts_disable_regulators(data); } static int nvt_ts_suspend(struct device *dev) @@ -199,9 +218,37 @@ static int nvt_ts_probe(struct i2c_client *client) if (!data) return -ENOMEM; + data->chip = device_get_match_data(&client->dev); + if (!data->chip) + return -EINVAL; + data->client = client; i2c_set_clientdata(client, data); + /* + * VCC is the analog voltage supply + * IOVCC is the digital voltage supply + */ + data->regulators[0].supply = "vcc"; + data->regulators[1].supply = "iovcc"; + error = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators), data->regulators); + if (error) { + dev_err(dev, "cannot get regulators: %d\n", error); + return error; + } + + error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), data->regulators); + if (error) { + dev_err(dev, "failed to enable regulators\n"); + return error; + } + + error = devm_add_action_or_reset(dev, nvt_ts_disable_regulators, data); + if (error) { + dev_err(dev, "failed to install regulator disable handler\n"); + return error; + } + data->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); error = PTR_ERR_OR_ZERO(data->reset_gpio); if (error) { @@ -225,8 +272,8 @@ static int nvt_ts_probe(struct i2c_client *client) if (width > NVT_TS_MAX_SIZE || height >= NVT_TS_MAX_SIZE || data->max_touches > NVT_TS_MAX_TOUCHES || irq_type >= ARRAY_SIZE(nvt_ts_irq_type) || - data->buf[NVT_TS_PARAMS_WAKE_TYPE] != NVT_TS_SUPPORTED_WAKE_TYPE || - data->buf[NVT_TS_PARAMS_CHIP_ID] != NVT_TS_SUPPORTED_CHIP_ID) { + data->buf[NVT_TS_PARAMS_WAKE_TYPE] != data->chip->wake_type || + data->buf[NVT_TS_PARAMS_CHIP_ID] != data->chip->chip_id) { dev_err(dev, "Unsupported touchscreen parameters: %*ph\n", NVT_TS_PARAMS_SIZE, data->buf); return -EIO; @@ -277,8 +324,26 @@ static int nvt_ts_probe(struct i2c_client *client) return 0; } +static const struct nvt_ts_i2c_chip_data nvt_nt11205_ts_data = { + .wake_type = 0x05, + .chip_id = 0x05, +}; + +static const struct nvt_ts_i2c_chip_data nvt_nt36672a_ts_data = { + .wake_type = 0x01, + .chip_id = 0x08, +}; + +static const struct of_device_id nvt_ts_of_match[] = { + { .compatible = "novatek,nt11205-ts", .data = &nvt_nt11205_ts_data }, + { .compatible = "novatek,nt36672a-ts", .data = &nvt_nt36672a_ts_data }, + { } +}; +MODULE_DEVICE_TABLE(of, nvt_ts_of_match); + static const struct i2c_device_id nvt_ts_i2c_id[] = { - { "NT11205-ts" }, + { "NT11205-ts", (unsigned long) &nvt_nt11205_ts_data }, + { "NT36672A-ts", (unsigned long) &nvt_nt36672a_ts_data }, { } }; MODULE_DEVICE_TABLE(i2c, nvt_ts_i2c_id); @@ -287,6 +352,7 @@ static struct i2c_driver nvt_ts_driver = { .driver = { .name = "novatek-nvt-ts", .pm = pm_sleep_ptr(&nvt_ts_pm_ops), + .of_match_table = nvt_ts_of_match, }, .probe = nvt_ts_probe, .id_table = nvt_ts_i2c_id,