From nobody Fri Jun 19 07:47:23 2026 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40D3136EAAE for ; Fri, 24 Apr 2026 07:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777014821; cv=none; b=CYsRC7CTS+WRz5ltTWpT12DkTG+SXtZLbH3bkwCH1QJ34I5cSqPVEuu0I98JYQmn34RrG1hRL0VoVfUM3DFQ9l07pbp1ZFoiNYGKOzufE/1ruBx9XcWMqf4TQwkGCCXtrGvUtnNDEbQDFouX+MhC5fXIOZOpFLuyLXPOQjZvjk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777014821; c=relaxed/simple; bh=tnLPRL9A9azacxq4NLt+IId8izuY1ScptZDT7gzu40c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F1ol2YvJrVQC+QQyMtyfpdp61uVWuNDfv5y4yyS5OqJLZcYFx5OEHjZ9cCVioNqc8ObavM50H17+nThjIuq+MsfZ4CZNM65N4EhFGn17rkv3Xttt+abf2eKI/ofvcWOaWlrTm4ijSL8zJxWEx5sWIOot+mm7XdmHMF9xn4nXQ4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JY4AFANb; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JY4AFANb" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5a2b636b944so9791049e87.1 for ; Fri, 24 Apr 2026 00:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777014814; x=1777619614; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RBE1o78vN0SIWnrb8j+CXJa2K5r2M8CfhkLvD2G7oEc=; b=JY4AFANbEnAu7Sm0MHnDuPYu5DcBcphUo8zr8wbxxIxCIMX1QWhV37CB2N3tJcHl31 MGJ7Oqaq/fvZCBtCFoJX0WK4vwNaCXoy5AY39WxlAyft8e9I8sDSAHUl9jB4+lMbBAgx hh4+eZoBk6eZVJ//ykx+gKR51D5rx5mNTo4cXUrBHZvfZe7otyL7obuzYUXqztsmKH0I 9qpm8OJHq+KyKz9WBYvDUbF2yMG431YAM6MCWl8njp7LD2we2A/CdTw8ZkXNx5Ji3txM nhZCGagNS/UoxBCFjNB9mIWNL16X9XOtCA8xXiNRH4HDSaO738FF4+SiMkkoGGa/I4JB iTYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777014814; x=1777619614; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RBE1o78vN0SIWnrb8j+CXJa2K5r2M8CfhkLvD2G7oEc=; b=pvqKGEkbkw8tf6ZYFY3Ig1HKQX2pDBNQ3v0oQABS3LAVQnpIZM0HvftlWr+CICkHXF TNqdvC1DpwKqqfkyyk6/n25gCWgWPcCRxTAfdX7DXy4GUtVkvdxxkgz9vJ1EQAz5TmWf lcSnddOG44vsrULeM9f/txQRTiOBwfXxP9ueU2oKknrhp1ZTFs3cSerdpU58Ee/W4TX9 gRLYdGlhZrTjNFEuRKbGv1ZM9+6aAWy8cowZrQyesd25aGr7HJ2+wdDykNGZhRoGL9Is cUXWIxVY8z/9963/mxkIf2wsvMR4nWGVTxIObuqmnNzm7Z9t0iN7Q7kXMTawv0TrpVv5 4cVw== X-Forwarded-Encrypted: i=1; AFNElJ9ypLOHQuXvoQEwKQI3JF94GM2VDA39Q5yrphXYVQXcCbERTgRJMwERBtm6eo7Wj4fTGU1spDuVLzL1wI8=@vger.kernel.org X-Gm-Message-State: AOJu0YzJ8brwdUmNfvyWx6aI7y1vfGwloXrAe9qUqGJcGispNgYW/lND ImlXNX6vKK8Ozr2wcnLmhPb8b1Yb05HpcUsU79+fk0uVHRGCDZrcSTN4 X-Gm-Gg: AeBDieujV4uplJ9dchWHYTIKP7ougut4JIMa2aLmo9wyeIigIggBo8m0YjZ9xHcZvbI XZDcTvP7fvBZ13JgviP0wMnwJWN5+Nj4A0+h9n3co7j+GMrT95G1NkRjRKRse1Cs/wnxkrVEdDv PZC2aoTlD1N+rJMm+7mIgi73+0Rplgh7rLnNFr1jQ0eH3y0JwKQUCMliEhOVv/GZ7QY2RklOInS b2ae35EhjUX7hPdxSMTsN3ak//6poSHhT6oR4KEztjSfT34KhW9NZDufSLWhBkYD+fM3FckquR6 Owk5vnnckSuc0SWzAZvcD+6K3GERClFjnOBox/r1reK+Y3fNBBe6peo1/T9s/pSEMaW7hy2IeAl K47lexgxmjA184wBTB1Xo5yoFr/dR6yi19yayIiJVczplMISGNylYfwVVzG5tuuTLA/nM/hMQcZ Niu1Q4pqBtjh6E0kjhr4Xc5n8= X-Received: by 2002:a05:6512:3b14:b0:5a3:d381:2a7c with SMTP id 2adb3069b0e04-5a4172e2d60mr12562766e87.31.1777014814198; Fri, 24 Apr 2026 00:13:34 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb290095sm43760131fa.0.2026.04.24.00.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 00:13:33 -0700 (PDT) From: Svyatoslav Ryhel To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Svyatoslav Ryhel Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/2] dt-bindings: input: Document Imagis ISA1200 haptic motor driver Date: Fri, 24 Apr 2026 10:13:04 +0300 Message-ID: <20260424071305.89503-2-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260424071305.89503-1-clamor95@gmail.com> References: <20260424071305.89503-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the Imagis ISA1200 haptic motor driver, used primarily in mobile handheld devices and capable of supporting up to two motors. The exact datasheet for the ISA1200 is not available; all data was modeled based on available downstream kernel sources for various devices and fragments of information scattered across the internet. Signed-off-by: Svyatoslav Ryhel --- .../bindings/input/imagis,isa1200.yaml | 145 ++++++++++++++++++ include/dt-bindings/input/isa1200.h | 16 ++ 2 files changed, 161 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/imagis,isa1200.= yaml create mode 100644 include/dt-bindings/input/isa1200.h diff --git a/Documentation/devicetree/bindings/input/imagis,isa1200.yaml b/= Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file mode 100644 index 000000000000..51767fd8189d --- /dev/null +++ b/Documentation/devicetree/bindings/input/imagis,isa1200.yaml @@ -0,0 +1,145 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/imagis,isa1200.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Imagis ISA1200 haptic motor driver + +maintainers: + - Svyatoslav Ryhel + - Linus Walleij + +description: + The ISA1200 is a high-performance enhanced haptic motor driver designed + for mobile hand-held devices. It supports various voltages for both ERM + (Eccentric Rotating Mass) and LRA (Linear Resonant Actuator) type + actuators. Thanks to an embedded LDO, battery power can be used directly + in handheld applications. + +properties: + compatible: + const: imagis,isa1200 + + reg: + maxItems: 1 + + enable-gpios: + description: + One or two GPIOs flagged as active high linked to HEN and LEN pins + maxItems: 2 + + clocks: + maxItems: 1 + + pwms: + maxItems: 1 + + vdd-supply: + description: + Regulator for 2.4V - 5.5V power supply + + vddp-supply: + description: + Regulator for 2.4V - 3.6V IO power supply + + imagis,clk-div: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Divider for the external input clock/PWM + 0 - 128 + 1 - 256 + 2 - 512 + 3 - 1024 + enum: [0, 1, 2, 3] + default: 0 + + imagis,pll-div: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Divider for the internal PLL clock + minimum: 1 + maximum: 15 + default: 1 + + imagis,mode: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Defines the motor type isa1200 drives + 0 - LRA (Linear Resonant Actuator) + 1 - ERM (Eccentric Rotating Mass) + enum: [0, 1] + default: 0 + + imagis,period-ns: + description: + Period of the internal PWM channel in nanoseconds. + minimum: 128 + maximum: 254 + + imagis,duty-cycle-ns: + description: + Duty cycle of the external/internal PWM channel in nanoseconds, + defaults to 50% of the channel's period + + ldo: + $ref: /schemas/regulator/regulator.yaml# + type: object + description: + Embedded LDO regulator with voltage range 2.3V - 3.8V + unevaluatedProperties: false + + required: + - regulator-min-microvolt + - regulator-max-microvolt + +required: + - compatible + - reg + - ldo + +anyOf: + - required: + - clocks + - imagis,period-ns + - required: + - pwms + +additionalProperties: false + +examples: + - | + #include + #include + + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + haptic-engine@49 { + compatible =3D "imagis,isa1200"; + reg =3D <0x49>; + + clocks =3D <&isa1200_refclk>; + + enable-gpios =3D <&gpio 22 GPIO_ACTIVE_HIGH>, + <&gpio 23 GPIO_ACTIVE_HIGH>; + + vdd-supply =3D <&vdd_3v3_vbat>; + vddp-supply =3D <&vdd_2v8_vvib>; + + imagis,clk-div =3D ; + imagis,pll-div =3D <2>; + + imagis,mode =3D ; + + imagis,period-ns =3D <134>; + imagis,duty-cycle-ns =3D <100>; + + ldo { + regulator-name =3D "vdd_vib"; + regulator-min-microvolt =3D <2300000>; + regulator-max-microvolt =3D <2300000>; + }; + }; + }; diff --git a/include/dt-bindings/input/isa1200.h b/include/dt-bindings/inpu= t/isa1200.h new file mode 100644 index 000000000000..cbae47ccf99b --- /dev/null +++ b/include/dt-bindings/input/isa1200.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */ + +#ifndef _DT_BINDINGS_ISA1200_H +#define _DT_BINDINGS_ISA1200_H + +/* Linked actuator type */ +#define ISA1200_LRA_MODE 0 +#define ISA1200_ERM_MODE 1 + +/* External clock divider */ +#define ISA1200_CKLDIV_128 0 +#define ISA1200_CKLDIV_256 1 +#define ISA1200_CKLDIV_512 2 +#define ISA1200_CKLDIV_1024 3 + +#endif --=20 2.51.0 From nobody Fri Jun 19 07:47:23 2026 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4120437186E for ; Fri, 24 Apr 2026 07:13:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777014824; cv=none; b=o9yMrWdFqempIHWxxSt1OWGhvF03O7UAy+ig+Akclns1uNW/8y7UK6NY/4LtTlZdXHRtQPhf4nKJXms1zIhAibsLxGkczw0VFrY6I+lugtfz0F7A/FA5w8/Uu1fMxESIu/AP6xXN8ygNYU1NKrd7feelUQ5tndH1SrgLGaXrG9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777014824; c=relaxed/simple; bh=oLwFMf+RYFTSQZ3/bafrCThO17KZdvqy0PClqzetDio=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tVtEXCDC3Ha+PTSKsCJpyO9+HaOv3aPQsByYIHFN0ck0o61efdM7tInGPvuK2SGtxseXhZTMrOLskGuzZNHwmWc9W91CrqrEMp6eorCzWbv4BKB9j6LLoyECjMALkM9QGIBfojMDUZRDMNEJtRjW0ckr3uvc7lmJNeMkkCoCQRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZyTm6Rru; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZyTm6Rru" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-386b553c70eso61088031fa.0 for ; Fri, 24 Apr 2026 00:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777014815; x=1777619615; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I/sixd4NaU0xSnVcxqGNpLA0xHbCyBHrYwxOHqjgPeI=; b=ZyTm6RruNSK4WkXyLD5GWxMDgz47TBazD78jo6Gtqd+XuvmynxGBEaRLBsF+xaT5Ub psyB3exuhfL2PkgooE6BMYG2GFWnUxDBPh0l/T1+AINcVenlUbALanjOltj4mRyfy+1b p2zV8SgNT6wMHbQufpC0+HNgTzbqCD21+g9MraTRC4zvVd8kvz6jEUnI6GwhkdOBnRui +CVT9uZliWjEXfzsNVZiHbMcEw9KSxpykyGjokEYPWBM5lwGBrUQCEUidV7WWH/9Gc25 XGTWKH4/UoKTPUf3SFa3exuM5+USsrd+RwrbsGSBJHqbBgB1BfKjNop4faduYErc4o3r CMbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777014815; x=1777619615; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=I/sixd4NaU0xSnVcxqGNpLA0xHbCyBHrYwxOHqjgPeI=; b=JrYfaDCXyd1oN8qbR/Mk2bOCkoKerRDca2lBQf06laDLiKL+erlOs1Y1+qKkQxM9xM OLeFSIdPG5mO3QzME3GGZBLQ2ylUWYZSKijF+56bIRkkCWmKYYAY3zqnfVk32AO1h9YF E/g46BoGuxzcpHUMm4321yGAqpS9VdNZxHtKe+gbQQgEU/OtvBKvQNQ861Pc/KQjiOTK ktE9wKL5v7x15amCwOd2E5/4/D3Td+i1iikabC4+3mXAh9Ej2ADgyk+qaI7JCLjqShBr pirNmWgRXXEe/O7bFNRe252skH8pgjK7erzYS6NJgo9cym9/PuJiBYJWVy5yCTSq8ikn AGmQ== X-Forwarded-Encrypted: i=1; AFNElJ9UlzQoEmp/eNO3bz0bJwS2TTPuwmfXJtjOG8uEahe2t1khmJfwLv70PbxfAYXXeZ9W4OaukE0XecJ+JKU=@vger.kernel.org X-Gm-Message-State: AOJu0Ywlu0azaBkCps+vldqPyDF3Wsj9ABo9TbKempxWXVoONlzZcqdC o00II7DSRpmODuXwLudbu4i0dEXa1RysGHPtpqoeHtQEEGtN5whCRY9x X-Gm-Gg: AeBDiesqySckNKYn54EJnGx9FryLrF0g/vhc9X3OvNSsH6v59/dClvadofBGmjYRgx5 85/Kw/cS+Uld/qgLCZ2Yyi8IfoF37wvdmHb7pvuTgluWyz7YsqtG//+31n6j2f1FsqCCK7++9lL sqjnoJTFfxrBsyLWzWLFfIa0lgksPeREF+xtYCtyvxZJ3A4Wf1eTyrSXmZCpQNKubh6tBD5LHEf kX2MHSKErlWtvShlg21012f6SU7Li0fB+jbM3H9tJABjx5P7/qtXq8MlqjjoFaOqmO0klGuy6wD HeTzbtzJlbLd4bZZNK1sNqfrpq4U6K359RB+ZyxAzvp6S3qGNR7MxLyAD4g89Gzcl10iISXeZaB TQn5VOy+MizDG0VsoNQ7YAiKJ1liCUvN58qxOMzjiSBWwfxHuTu40CiEIcfIt0SiTHUxQa7Uvf3 yUkumOk3JmA1TG/C/3hXSEsow= X-Received: by 2002:a2e:be90:0:b0:38f:e351:1e7b with SMTP id 38308e7fff4ca-38fe35120e9mr78441581fa.17.1777014815125; Fri, 24 Apr 2026 00:13:35 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb290095sm43760131fa.0.2026.04.24.00.13.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 00:13:34 -0700 (PDT) From: Svyatoslav Ryhel To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Svyatoslav Ryhel Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/2] Input: isa1200 - new driver for Imagis ISA1200 Date: Fri, 24 Apr 2026 10:13:05 +0300 Message-ID: <20260424071305.89503-3-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260424071305.89503-1-clamor95@gmail.com> References: <20260424071305.89503-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Linus Walleij The ISA1200 is a haptic feedback unit from Imagis Technology using two motors for haptic feedback in mobile phones. Used in many mobile devices c. 2012 including Samsung Galxy S Advance GT-I9070 (Janice), Samsung Beam GT-I8350 (Gavini), LG Optimus 4X P880 and LG Optimus Vu P895. The exact datasheet for the ISA1200 is not available; all data was modeled based on available downstream kernel sources for various devices and fragments of information scattered across the internet. Signed-off-by: Linus Walleij Co-developed-by: Svyatoslav Ryhel Signed-off-by: Svyatoslav Ryhel --- drivers/input/misc/Kconfig | 11 + drivers/input/misc/Makefile | 1 + drivers/input/misc/isa1200.c | 459 +++++++++++++++++++++++++++++++++++ 3 files changed, 471 insertions(+) create mode 100644 drivers/input/misc/isa1200.c diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 94a753fcb64f..5e5d46f44b91 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -852,6 +852,17 @@ config INPUT_IQS7222 To compile this driver as a module, choose M here: the module will be called iqs7222. =20 +config INPUT_ISA1200_HAPTIC + tristate "Imagis ISA1200 haptic feedback unit" + depends on I2C + select REGMAP_I2C + help + Say Y to enable support for the Imagis ISA1200 haptic + feedback unit. + + To compile this driver as a module, choose M here: the + module will be called isa1200. + config INPUT_CMA3000 tristate "VTI CMA3000 Tri-axis accelerometer" help diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 415fc4e2918b..d62bf2e9d85f 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -49,6 +49,7 @@ obj-$(CONFIG_INPUT_IMS_PCU) +=3D ims-pcu.o obj-$(CONFIG_INPUT_IQS269A) +=3D iqs269a.o obj-$(CONFIG_INPUT_IQS626A) +=3D iqs626a.o obj-$(CONFIG_INPUT_IQS7222) +=3D iqs7222.o +obj-$(CONFIG_INPUT_ISA1200_HAPTIC) +=3D isa1200.o obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) +=3D keyspan_remote.o obj-$(CONFIG_INPUT_KXTJ9) +=3D kxtj9.o obj-$(CONFIG_INPUT_M68K_BEEP) +=3D m68kspkr.o diff --git a/drivers/input/misc/isa1200.c b/drivers/input/misc/isa1200.c new file mode 100644 index 000000000000..965883e29c37 --- /dev/null +++ b/drivers/input/misc/isa1200.c @@ -0,0 +1,459 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* + * System control (LDO regulator) + * + * LDO voltage to register mapping is linear, but it is split in two parts: + * 2.3V - 3.0V map to 0x08 - 0x0f; 3.1V - 3.8V map to 0x00 - 0x7 + */ + +#define ISA1200_SCTRL 0x00 +#define ISA1200_LDO_VOLTAGE_BASE 0x08 +#define ISA1200_LDO_VOLTAGE_STEP 100000 +#define ISA1200_LDO_VOLTAGE_2V3 23 +#define ISA1200_LDO_VOLTAGE_3V1 31 + +/* + * The output frequency is calculated with this formula: + * + * base clock frequency + * fout =3D ----------------------------------------- + * (128 - PWM_FREQ) * 2 * PLLDIV * PWM_PERIOD + * + * The base clock frequency is the clock frequency provided on the + * clock input to the chip, divided by the value in HCTRL0 + * + * PWM_FREQ is configured in register HCTRL4, it is common to set this + * to 0 to get only two variables to calculate. + * + * PLLDIV is configured in register HCTRL3 (bits 7..4, so 0..15) + * PWM_PERIOD is configured in register HCTRL6 + * Further the duty cycle can be configured in HCTRL5 + */ + +/* + * HCTRL0 configures clock or PWM input and selects the divider for + * the clock input. + */ +#define ISA1200_HCTRL0 0x30 +#define ISA1200_HCTRL0_HAP_ENABLE BIT(7) +#define ISA1200_HCTRL0_PWM_GEN_MODE BIT(4) +#define ISA1200_HCTRL0_PWM_INPUT_MODE BIT(3) +#define ISA1200_HCTRL0_TO_CLKDIV(n) (128 << (n)) + +/* + * HCTRL1 configures the motor type and clock sourse + */ +#define ISA1200_HCTRL1 0x31 +#define ISA1200_HCTRL1_EXT_CLOCK BIT(7) +#define ISA1200_HCTRL1_DAC_INVERT BIT(6) +#define ISA1200_HCTRL1_MODE(n) ((n) << 5) + +/* HCTRL2 controls software reset of the chip */ +#define ISA1200_HCTRL2 0x32 +#define ISA1200_HCTRL2_SW_RESET BIT(0) + +/* + * HCTRL3 controls the PLL divisor + * + * Bits [0,1] are always set to 1 (we don't know what they are + * used for) and bit 4 and upward control the PLL divisor. + */ +#define ISA1200_HCTRL3 0x33 +#define ISA1200_HCTRL3_DEFAULT 0x03 +#define ISA1200_HCTRL3_PLLDIV(n) (((n) & 0xf) << 4) + +/* HCTRL4 controls the PWM frequency of external channel */ +#define ISA1200_HCTRL4 0x34 + +/* HCTRL5 controls the PWM high duty cycle of internal channel */ +#define ISA1200_HCTRL5 0x35 + +/* HCTRL6 controls the PWM period of internal channel */ +#define ISA1200_HCTRL6 0x36 + +#define ISA1200_EN_PINS_MAX 2 + +struct isa1200_config { + u32 ldo_voltage; + u32 mode; + u32 clkdiv; + u32 plldiv; + u32 freq; + u32 period; + u32 duty; +}; + +struct isa1200 { + struct input_dev *input; + struct regmap *map; + + struct clk *clk; + struct pwm_device *pwm; + struct gpio_descs *enable_gpios; + + struct work_struct play_work; + struct isa1200_config config; + + int level; +}; + +static const struct regmap_config isa1200_regmap_config =3D { + .reg_bits =3D 8, + .val_bits =3D 8, + .max_register =3D 0x3d, +}; + +static void isa1200_start(struct isa1200 *isa) +{ + struct isa1200_config *config =3D &isa->config; + struct pwm_state state; + u8 hctrl0, hctrl1; + DECLARE_BITMAP(values, ISA1200_EN_PINS_MAX); + + clk_prepare_enable(isa->clk); + + bitmap_fill(values, ISA1200_EN_PINS_MAX); + gpiod_multi_set_value_cansleep(isa->enable_gpios, values); + + usleep_range(200, 300); + + regmap_write(isa->map, ISA1200_SCTRL, config->ldo_voltage); + + if (isa->clk) { + hctrl0 =3D ISA1200_HCTRL0_PWM_GEN_MODE; + hctrl1 =3D ISA1200_HCTRL1_EXT_CLOCK; + } + + if (isa->pwm) { + hctrl0 =3D ISA1200_HCTRL0_PWM_INPUT_MODE; + hctrl1 =3D 0; + } + + hctrl0 |=3D config->clkdiv; + hctrl1 |=3D ISA1200_HCTRL1_DAC_INVERT; + hctrl1 |=3D ISA1200_HCTRL1_MODE(config->mode); + + regmap_write(isa->map, ISA1200_HCTRL0, hctrl0); + regmap_write(isa->map, ISA1200_HCTRL1, hctrl1); + + /* Make sure to de-assert software reset */ + regmap_write(isa->map, ISA1200_HCTRL2, 0x00); + + /* PLL divisor */ + regmap_write(isa->map, ISA1200_HCTRL3, + ISA1200_HCTRL3_PLLDIV(config->plldiv) | + ISA1200_HCTRL3_DEFAULT); + + /* Frequency */ + regmap_write(isa->map, ISA1200_HCTRL4, config->freq); + /* Duty cycle */ + regmap_write(isa->map, ISA1200_HCTRL5, config->period >> 1); + /* Period */ + regmap_write(isa->map, ISA1200_HCTRL6, config->period); + + hctrl0 |=3D ISA1200_HCTRL0_HAP_ENABLE; + regmap_write(isa->map, ISA1200_HCTRL0, hctrl0); + + if (isa->clk) + regmap_write(isa->map, ISA1200_HCTRL5, config->duty); + + if (isa->pwm) { + pwm_get_state(isa->pwm, &state); + state.duty_cycle =3D config->duty; + state.enabled =3D true; + pwm_apply_might_sleep(isa->pwm, &state); + } +} + +static void isa1200_stop(struct isa1200 *isa) +{ + struct pwm_state state; + DECLARE_BITMAP(values, ISA1200_EN_PINS_MAX); + + if (isa->pwm) { + pwm_get_state(isa->pwm, &state); + state.duty_cycle =3D 0; + state.enabled =3D false; + pwm_apply_might_sleep(isa->pwm, &state); + } + + regmap_write(isa->map, ISA1200_HCTRL0, 0x00); + + bitmap_zero(values, ISA1200_EN_PINS_MAX); + gpiod_multi_set_value_cansleep(isa->enable_gpios, values); + + clk_disable_unprepare(isa->clk); +} + +static void isa1200_play_work(struct work_struct *work) +{ + struct isa1200 *isa =3D + container_of(work, struct isa1200, play_work); + + if (isa->level) + isa1200_start(isa); + else + isa1200_stop(isa); +} + +static int isa1200_vibrator_play_effect(struct input_dev *input, void *dat= a, + struct ff_effect *effect) +{ + struct isa1200 *isa =3D input_get_drvdata(input); + int level; + + /* + * TODO: we currently only support rumble. + * The ISA1200 can control two motors and some devices + * also have two motors mounted. + */ + level =3D effect->u.rumble.strong_magnitude; + if (!level) + level =3D effect->u.rumble.weak_magnitude; + + dev_dbg(&input->dev, "FF effect type %d level %d\n", + effect->type, level); + + if (isa->level !=3D level) { + isa->level =3D level; + schedule_work(&isa->play_work); + } + + return 0; +} + +static void isa1200_vibrator_close(struct input_dev *input) +{ + struct isa1200 *isa =3D input_get_drvdata(input); + + cancel_work_sync(&isa->play_work); + + if (isa->level) + isa1200_stop(isa); + + isa->level =3D 0; +} + +static int isa1200_of_probe(struct i2c_client *client) +{ + static const char * const isa1200_supplies[] =3D { "vdd", "vddp" }; + struct isa1200 *isa =3D i2c_get_clientdata(client); + struct isa1200_config *config =3D &isa->config; + struct device *dev =3D &client->dev; + struct fwnode_handle *ldo_node; + int ret; + + isa->clk =3D devm_clk_get_optional(dev, NULL); + if (IS_ERR(isa->clk)) + return dev_err_probe(dev, PTR_ERR(isa->clk), + "failed to get clock\n"); + + isa->pwm =3D devm_pwm_get(dev, NULL); + if (IS_ERR(isa->pwm)) + isa->pwm =3D NULL; + + ret =3D devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(isa1200_supplies), + isa1200_supplies); + if (ret) + return dev_err_probe(dev, ret, "failed to set up supplies\n"); + + isa->enable_gpios =3D devm_gpiod_get_array_optional(dev, "enable", + GPIOD_OUT_LOW); + if (IS_ERR(isa->enable_gpios)) + return dev_err_probe(dev, PTR_ERR(isa->enable_gpios), + "failed to get enable gpios\n"); + + ldo_node =3D device_get_named_child_node(dev, "ldo"); + if (!ldo_node) + return dev_err_probe(dev, -ENODEV, + "failed to get embedded LDO node\n"); + + config->ldo_voltage =3D 2300000; + ret =3D fwnode_property_read_u32(ldo_node, "regulator-min-microvolt", + &config->ldo_voltage); + fwnode_handle_put(ldo_node); + if (ret) + return dev_err_probe(dev, ret, + "failed to get ldo voltage\n"); + + /* Device supports only 2.3V - 3.8V range */ + if (config->ldo_voltage < 2300000 || config->ldo_voltage > 38000000) + return dev_err_probe(dev, -EINVAL, + "voltage is out of 2.3V - 3.8V range\n"); + + config->ldo_voltage /=3D ISA1200_LDO_VOLTAGE_STEP; + if (config->ldo_voltage < ISA1200_LDO_VOLTAGE_3V1) + config->ldo_voltage =3D config->ldo_voltage - + ISA1200_LDO_VOLTAGE_2V3 + + ISA1200_LDO_VOLTAGE_BASE; + else + config->ldo_voltage -=3D ISA1200_LDO_VOLTAGE_3V1; + + config->mode =3D ISA1200_LRA_MODE; + device_property_read_u32(dev, "imagis,mode", &config->mode); + + config->clkdiv =3D ISA1200_CKLDIV_128; + device_property_read_u32(dev, "imagis,clk-div", &config->clkdiv); + + config->plldiv =3D 1; + device_property_read_u32(dev, "imagis,pll-div", &config->plldiv); + + config->period =3D 0; + config->freq =3D 0; + config->duty =3D 0; + + if (isa->clk) { + ret =3D device_property_read_u32(dev, "imagis,period-ns", + &config->period); + if (ret) + return dev_err_probe(dev, ret, + "failed to get period\n"); + + config->duty =3D config->period >> 1; + } + + if (isa->pwm) { + struct pwm_state state; + + pwm_init_state(isa->pwm, &state); + + config->freq =3D div64_u64(NANO, state.period * + ISA1200_HCTRL0_TO_CLKDIV(config->clkdiv)); + config->duty =3D state.period >> 1; + + ret =3D pwm_apply_might_sleep(isa->pwm, &state); + if (ret) + return dev_err_probe(dev, ret, + "failed to apply initial PWM state\n"); + } + + device_property_read_u32(dev, "imagis,duty-cycle-ns", &config->duty); + + return 0; +} + +static int isa1200_probe(struct i2c_client *client) +{ + struct isa1200 *isa; + struct device *dev =3D &client->dev; + DECLARE_BITMAP(values, ISA1200_EN_PINS_MAX); + u32 val; + int ret; + + isa =3D devm_kzalloc(dev, sizeof(*isa), GFP_KERNEL); + if (!isa) + return -ENOMEM; + + isa->input =3D devm_input_allocate_device(dev); + if (!isa->input) + return -ENOMEM; + + i2c_set_clientdata(client, isa); + + ret =3D isa1200_of_probe(client); + if (ret) + return ret; + + isa->map =3D devm_regmap_init_i2c(client, &isa1200_regmap_config); + if (IS_ERR(isa->map)) + return dev_err_probe(dev, PTR_ERR(isa->map), + "failed to initialize register map\n"); + + clk_prepare_enable(isa->clk); + + bitmap_fill(values, ISA1200_EN_PINS_MAX); + gpiod_multi_set_value_cansleep(isa->enable_gpios, values); + + usleep_range(200, 300); + + /* Read a register so we know that regmap and I2C transport works */ + ret =3D regmap_read(isa->map, ISA1200_SCTRL, &val); + if (ret) + return dev_err_probe(dev, ret, "failed to read SCTRL\n"); + + INIT_WORK(&isa->play_work, isa1200_play_work); + + isa->input->name =3D "isa1200-haptic"; + isa->input->id.bustype =3D BUS_HOST; + isa->input->dev.parent =3D dev; + isa->input->close =3D isa1200_vibrator_close; + + input_set_drvdata(isa->input, isa); + + /* TODO: this hardware can likely support more than rumble */ + input_set_capability(isa->input, EV_FF, FF_RUMBLE); + + ret =3D input_ff_create_memless(isa->input, NULL, + isa1200_vibrator_play_effect); + if (ret) + return dev_err_probe(dev, ret, "couldn't create FF dev\n"); + + ret =3D input_register_device(isa->input); + if (ret) + return dev_err_probe(dev, ret, "couldn't register input dev\n"); + + return ret; +} + +static int isa1200_suspend(struct device *dev) +{ + struct isa1200 *isa =3D dev_get_drvdata(dev); + + if (isa->level) + isa1200_stop(isa); + + return 0; +} + +static int isa1200_resume(struct device *dev) +{ + struct isa1200 *isa =3D dev_get_drvdata(dev); + + if (isa->level) + isa1200_start(isa); + + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(isa1200_pm_ops, isa1200_suspend, isa1200_r= esume); + +static const struct of_device_id isa1200_of_match[] =3D { + { .compatible =3D "imagis,isa1200" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, isa1200_of_match); + +static struct i2c_driver isa1200_i2c_driver =3D { + .driver =3D { + .name =3D "isa1200", + .of_match_table =3D isa1200_of_match, + .pm =3D pm_sleep_ptr(&isa1200_pm_ops), + }, + .probe =3D isa1200_probe, +}; +module_i2c_driver(isa1200_i2c_driver); + +MODULE_AUTHOR("Linus Walleij "); +MODULE_AUTHOR("Svyatoslav Ryhel "); +MODULE_DESCRIPTION("Imagis ISA1200 haptic feedback unit"); +MODULE_LICENSE("GPL"); --=20 2.51.0