From patchwork Sat Jun 1 15:30: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: 13682513 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 8C2A11E4AF; Sat, 1 Jun 2024 15:30:25 +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=1717255825; cv=none; b=pFR8UaZHSx9iWCymGkmRRh0XdFUI5U73mUcJSF5Z3zCQLwC8kPk2nW011OjqRLUac8u17IHFBbMAKXpAFkN+a4I9uDf53jHsRq424fqrgLnMzpHn7/J+qKKykyDujoU20tYa5zZrsd3HaKRX9hzojH87nx3BoxBpRGDWwhY6ky8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717255825; c=relaxed/simple; bh=ZBV7j2HnfvAkZTkxfnAC+3ke3f7l/ctdE02xfZ2rec0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aTMh8B9v7w1sZLWi3GjfZqJ4ykcRM+SNQQVLiZ9Dki6Xw9Wq1JC6yjYosz/Kc2EuyKj98/k3T1vh+wCnAfYx2iAxegy1mpYXJ7bMA1Zns2GX87/62EarV2tiorWDDzIgeIZj5NvFPPG0d9YIyptu76QgQSERJFVPrcDG9T8gdFY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gc+WA7JI; 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="gc+WA7JI" Received: by smtp.kernel.org (Postfix) with ESMTPS id 168B2C32789; Sat, 1 Jun 2024 15:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717255825; bh=ZBV7j2HnfvAkZTkxfnAC+3ke3f7l/ctdE02xfZ2rec0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=gc+WA7JIv0ZxCWz9WnKw808SVquDIlv8UvCm5Y9yIYl9i+TPg9UXt9LzejNIJHQTU LzYk54OYtlFvcj0i/as7wEuEcU0sJrxKaY6RkgxwO7ckob7KLEH3S2G5vySdovjtdb H7+34wRgujQEzCZgKnjxGM9XFLT1BZzD+cZ7mh4FQjBHEB3rcg2KWcWY+/cde0MxMD 2B+3995B6hqaXIwr1nHCWfFJPE65ucPhr5ah1utJ/gaJdDCOOWvkzEPE8CHqSyqnEy deQpSrTX7DDTfq3GGi7lBr9QB9WOtU3Nf6a3nyKtM7MKaATvoUR5YCo5Ia63qROvct uRZtH1+ng82tw== 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 F1DB9C25B7E; Sat, 1 Jun 2024 15:30:24 +0000 (UTC) From: Joel Selvaraj via B4 Relay Date: Sat, 01 Jun 2024 10:30:18 -0500 Subject: [PATCH v4 1/3] Input: novatek-nvt-ts: replace generic i2c device id with specific IC variant Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240601-nvt-ts-devicetree-regulator-support-v4-1-e0c0174464c4@gmail.com> References: <20240601-nvt-ts-devicetree-regulator-support-v4-0-e0c0174464c4@gmail.com> In-Reply-To: <20240601-nvt-ts-devicetree-regulator-support-v4-0-e0c0174464c4@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=1717255824; l=1393; i=joelselvaraj.oss@gmail.com; s=20240420; h=from:subject:message-id; bh=JfGOWdU2w8+0k5JiDiNeJehgANFUozza/8JZOnq70YQ=; b=2N+nKpMcTgWMGs8Ob0QX/kRltK4J5K/rzYKY24xqfxDgujMvB8JyQuVXzM4gOJjwmtOA12ZgO NZfn/z8OzhDBgdibMjte+4Qc+nz+YibOf/Imfj1a2WDsnzJ6jMiWFbv 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..9bee3a0c122fb 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..129273df0fdeb 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 Sat Jun 1 15:30: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: 13682515 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 8C3247B3FE; Sat, 1 Jun 2024 15:30:25 +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=1717255825; cv=none; b=rCQJv8rV3fz3EDdn8isXcyYhTNYerZLY2aQU28KIgEhVgpSa4HNqFsnpoP0bdJPtvDwBcc2VIhQK0OdsmAvr8FyfNX982dHfe5Vl1c0pHL/A0nyL/Y5dqfPrl3ClG7xz1EVmf9P3Mm/wdxJ36TlQkmrUSw9uP8JTp//yFZqBvTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717255825; c=relaxed/simple; bh=HaKiHpwKze6xx8hrZ0HkUm95XgsXEh+3lnAI2MmKvj0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=By4gZzLoeWudX99+kkYrxJWxS7DyRnoW7kXD+YHMUFZd3LNgf71wLZ2k4/525snEESPppHsN2xs2geh/FqG3bzSFdKqt50AmCTrnl6W14ELsZ0QhjIoPSHXqO9UpP6ugNd81d7IU2t/5zLycLB37o8EP/7IFbEe84ZN42Cphfhw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Utn68Xel; 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="Utn68Xel" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2541AC32786; Sat, 1 Jun 2024 15:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717255825; bh=HaKiHpwKze6xx8hrZ0HkUm95XgsXEh+3lnAI2MmKvj0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Utn68XelgBT2SXvQcmUUZhDkHj5QwLN5Ho6s1Ot6zaaIpDidBr4KUU5SwXTzqyTxM BWG1BbKc88Seo3kwSb/YZnQxmEC1i4lY8AI+y9M8FCQQfFLaM/377mULFbOdylgQRU uaYohypiBAa8ZO3bxXmfdFTGqP8/rXx5vpxoY92ISD3G8qtuJBFNtt7VH7H21XOeuO huqXstXFkPxYXxTpcV6PMplWAxY/AQrvDVXk6sjx7pLTsyFrIMW+MxW9xJpeGBzFBA HUk41X3+iFKIRvrTN7rfF78U9o5HkerZH8Rwe5hrRfdKSnJ4fX2PVNM87Y5+pMX0WV 9YBWh8WVJYmmg== 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 126D9C27C51; Sat, 1 Jun 2024 15:30:25 +0000 (UTC) From: Joel Selvaraj via B4 Relay Date: Sat, 01 Jun 2024 10:30:19 -0500 Subject: [PATCH v4 2/3] dt-bindings: input: document Novatek NVT touchscreen controller Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240601-nvt-ts-devicetree-regulator-support-v4-2-e0c0174464c4@gmail.com> References: <20240601-nvt-ts-devicetree-regulator-support-v4-0-e0c0174464c4@gmail.com> In-Reply-To: <20240601-nvt-ts-devicetree-regulator-support-v4-0-e0c0174464c4@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 , Krzysztof Kozlowski X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717255824; l=2767; i=joelselvaraj.oss@gmail.com; s=20240420; h=from:subject:message-id; bh=l1XN86Z3ZftRDCgivV8HiV5DOjOZR8yQT8aQnuoq5qg=; b=lRMTx4boW3pUph58nF6j25dK7vblOoujl1WFfyltXJDePDZpDFk43/ildNnxOeFnlQy4Z01Qa Wfhkk8zhygXDiN0fvmyElwrbspBybzQM+6U+e31UY/rhjsfm3PvmvJ8 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 qcom/sdm845-xiaomi-beryllium-tianma.dts. Also, include the devictree binding file in the MAINTAINERS file. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Joel Selvaraj --- .../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..bd6a60486d1f1 --- /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 Sat Jun 1 15:30: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: 13682514 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 8C2E327451; Sat, 1 Jun 2024 15:30:25 +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=1717255825; cv=none; b=RiCWYRItynXcYIc/oCH6w1AxX90Vc+udsVKkm6ZnNUk6RvDbgqzyC65HynxJAVD3u5EUFMM88RzDNHeroRNmdkqvgb7j/289j2bszDi6Vwy9wQgnwNGIVBDCxVa2kpzX+9iXKEExvMPhwBF/TYdy0V4ZxM+0hmitQNN5Ckkq//k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717255825; c=relaxed/simple; bh=YKctU1BgLvYJv1exYVgkH2uz/IJdBVvmQn66+UB144M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OlE0saHZTIThK+uUQsK0Ft0QnZhvYdItm6yPQ6RG5OY8cSPELVlwXRDqXLtYrGbsKFoA1ci8SNFxMASwKfFbJi4lvH7tvvn/E1jOZs20DWLIOrmyWAicvW3n8nT1xdW9Ieemw0rZqnPWsxvUb5qxmjA/ABmWI+23R9dscYIIsdg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XoQVULtx; 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="XoQVULtx" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3BCAFC4AF0A; Sat, 1 Jun 2024 15:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717255825; bh=YKctU1BgLvYJv1exYVgkH2uz/IJdBVvmQn66+UB144M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=XoQVULtxJiG3OwYnKxuBcukpsIbAqATRT9pLRbDHb9K37TVbJ1j5Vjz4nd2wrm4JQ hy6y3DLlOD64xqQn/GfMFucfLgmhI9hJ7U4SnWBpvmR9N0VJ1rzqo3DoW+rkoRwkMe kg6jXXU8U7wkduQLr3W/VhqEtLcv4mXYDRTibNGDkRS3kQyqzDKntJH4OGeZ3LZGdd uVUYYnruOQlYkOhm6/LoxqymP3tFMzPftevdgrjvmYwyvGVQHzafcGMRKTLNDcCxFA Hm1Tawm7z68jy+S0fyle2QhSL4RdsL2yMdInv//zGycHV1mRvfSyy4P7YwCT16p/o/ s99AUwc4NTb7Q== 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 278E6C27C50; Sat, 1 Jun 2024 15:30:25 +0000 (UTC) From: Joel Selvaraj via B4 Relay Date: Sat, 01 Jun 2024 10:30:20 -0500 Subject: [PATCH v4 3/3] Input: novatek-nvt-ts: add support for NT36672A touchscreen Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240601-nvt-ts-devicetree-regulator-support-v4-3-e0c0174464c4@gmail.com> References: <20240601-nvt-ts-devicetree-regulator-support-v4-0-e0c0174464c4@gmail.com> In-Reply-To: <20240601-nvt-ts-devicetree-regulator-support-v4-0-e0c0174464c4@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=1717255824; l=5459; i=joelselvaraj.oss@gmail.com; s=20240420; h=from:subject:message-id; bh=MDx8U1TZt2iAR4PmfpxVEJF0XZQV+kEvz+8qGOsCbAM=; b=KSxgR0L7q1slNer4MRCnteah32lyqCN1Dui7W6UpcwpXX7+2NIBXKj4CtaIZ1i/VSUjTWnnax U9dUl1ZyhxbDWeL1mf3mhRFfdKMwLbfnEXvKQkbKsy8rEuSLAfE2H8l 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 qcom/sdm845-xiaomi-beryllium-tianma.dts. 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. Signed-off-by: Joel Selvaraj --- drivers/input/touchscreen/novatek-nvt-ts.c | 70 +++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/novatek-nvt-ts.c b/drivers/input/touchscreen/novatek-nvt-ts.c index 9bee3a0c122fb..c24c33f609eb8 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]; }; @@ -142,6 +146,13 @@ static irqreturn_t nvt_ts_irq(int irq, void *dev_id) 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 +166,7 @@ static void nvt_ts_stop(struct input_dev *dev) disable_irq(data->client->irq); gpiod_set_value_cansleep(data->reset_gpio, 1); + regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); } static int nvt_ts_suspend(struct device *dev) @@ -199,9 +211,31 @@ 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: %d\n", error); + return error; + } + data->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); error = PTR_ERR_OR_ZERO(data->reset_gpio); if (error) { @@ -216,6 +250,11 @@ static int nvt_ts_probe(struct i2c_client *client) gpiod_set_value_cansleep(data->reset_gpio, 1); /* Put back in reset */ if (error) return error; + error = regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); + if (error) { + dev_err(dev, "failed to disable regulators: %d\n", error); + return error; + } width = get_unaligned_be16(&data->buf[NVT_TS_PARAMS_WIDTH]); height = get_unaligned_be16(&data->buf[NVT_TS_PARAMS_HEIGHT]); @@ -225,8 +264,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 +316,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 +344,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,