Skip to contentSkip to conversation

input: misc: add support for Imagis ISA1200 haptic motor driver

PATCH Superseded Svyatoslav Ryhel 4 participants 14 messages May 12 – Jun 17

Subsystems (3)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover input: misc: add support for Imagis ISA1200 haptic motor driver

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.

---
Changes in v5:
- added supplies to private structure
- clk_on dropped
- ret > err
- added active flag to track status
- all hardware manipulations consolidated in start/stop
- dropped mutex from work
- dropped active check from isa1200_vibrator_close it was moved to stop directly
- dropped hw maniplations from probe
- bustype set to BUS_I2C
- adjusted error strings
- fixed cancel_work_sync in isa1200_suspend

Changes in v4:
- added INPUT_FF_MEMLESS option selection
- fixed missing clock status set
- guard start/stop calls in isa1200_play_work with lock
- clamp ldo voltages to allowed range
- fixed imagis,pll-div parsing
- dropped Tested-by from schema adding commit

Changes in v3:
- added clock state tracking
- dropped level check in vibrator close
- added clkdiv clamping
- added comments regarding registers 5 and 6

Changes in v2:
- imagis,clk-div switched to accept actual divider value
- dropped DT header
- adjusted imagis,period-ns range
- initiated hctrl0 and hctrl1 values in isa1200_start
- fixed situation when PWM might return -EPROBE_DEFER to be treated properly
- added chech a clock or PWM is available
- fixed regulator voltages check being off by 10
- added chech if state.period is not zero
- added action call to disable clock and gpios on error
- used managed version of work init
- added work cancel on suspend
- PW calls are done under mutex lock
---

Linus Walleij (1):
Input: isa1200 - new driver for Imagis ISA1200

Svyatoslav Ryhel (1):
dt-bindings: input: Document Imagis ISA1200 haptic motor driver

 .../bindings/input/imagis,isa1200.yaml        | 140 +++++
 drivers/input/misc/Kconfig                    |  12 +
 drivers/input/misc/Makefile                   |   1 +
 drivers/input/misc/isa1200.c                  | 524 ++++++++++++++++++
 4 files changed, 677 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/imagis,isa1200.yaml
 create mode 100644 drivers/input/misc/isa1200.c
Signature · 1 line
2.51.0
#1 lore raw

PATCH v5 1/2 dt-bindings: input: Document Imagis ISA1200 haptic motor driver

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.

---
 .../bindings/input/imagis,isa1200.yaml        | 140 ++++++++++++++++++
 1 file changed, 140 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/imagis,isa1200.yaml
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +140 -0
new file mode 100644
index 000000000000..bbe6f99d39c1
@@ -0,0 +1,140 @@
+# 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 <[email protected]>
+  - Linus Walleij <[email protected]>
+
+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
+
+  control-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
+    enum: [128, 256, 512, 1024]
+    default: 128
+
+  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: 10000
+    maximum: 30000
+
+  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 <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        haptic-engine@49 {
+            compatible = "imagis,isa1200";
+            reg = <0x49>;
+
+            clocks = <&isa1200_refclk>;
+
+            control-gpios = <&gpio 22 GPIO_ACTIVE_HIGH>,
+                            <&gpio 23 GPIO_ACTIVE_HIGH>;
+
+            vdd-supply = <&vdd_3v3_vbat>;
+            vddp-supply = <&vdd_2v8_vvib>;
+
+            imagis,clk-div = <256>;
+            imagis,pll-div = <2>;
+
+            imagis,mode = <0>; /* LRA_MODE */
+
+            imagis,period-ns = <13400>;
+            imagis,duty-cycle-ns = <100>;
+
+            ldo {
+                regulator-name = "vdd_vib";
+                regulator-min-microvolt = <2300000>;
+                regulator-max-microvolt = <2300000>;
+            };
+        };
+    };
Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH v5 1/2] dt-bindings: input: Document Imagis ISA1200 haptic motor driver

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Missing scalar type definitions for `imagis,period-ns` and `imagis,duty-cycle-ns` cause schema…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing scalar type definitions for imagis,period-ns and imagis,duty-cycle-ns cause schema bounds validation to be silently bypassed. --

commit c2a7ef2ca3d62317c69bc5b6a450107172eeeac7
Author: Svyatoslav Ryhel <[email protected]>

dt-bindings: input: Document Imagis ISA1200 haptic motor driver

This commit documents the Imagis ISA1200 haptic motor driver. It introduces a new YAML binding schema for the driver, specifying properties like control-gpios, clocks, and internal PWM configurations.

Quoted 5 lines
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +0 -0
new file mode 100644
index 0000000000000..bbe6f99d39c19

[ ... ]

Quoted 1 line
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +0 -0
@@ -0,0 +1,140 @@

[ ... ]

Quoted 9 lines
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +9 -0
+  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
+

Documentation/devicetree/bindings/input/imagis,isa1200.yaml line 79

Quoted 10 lines
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +10 -0
+  imagis,period-ns:
+    description:
+      Period of the internal PWM channel in nanoseconds.
+    minimum: 10000
+    maximum: 30000
+
+  imagis,duty-cycle-ns:
+    description:
+      Duty cycle of the external/internal PWM channel in nanoseconds,
+      defaults to 50% of the channel's period

Will the minimum and maximum bounds on imagis,period-ns be silently ignored during validation?

The core property-units.yaml schema automatically assigns an array type to properties ending in -ns. Without an explicit reference to /schemas/types.yaml#/definitions/uint32, these properties are evaluated as arrays rather than scalar integers.

In standard JSON Schema, numeric constraints like minimum and maximum are ignored when applied to an array instance. Adding the uint32 type reference for both imagis,period-ns and imagis,duty-cycle-ns would ensure the constraints are properly enforced on a single scalar value.

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#3 lore raw

Re: [PATCH v5 1/2] dt-bindings: input: Document Imagis ISA1200 haptic motor driver

Quoted 49 lines · On Wed, May 13, 2026 at 08:15:57PM +0000, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing scalar type definitions for imagis,period-ns and imagis,duty-cycle-ns cause schema bounds validation to be silently bypassed. --

commit c2a7ef2ca3d62317c69bc5b6a450107172eeeac7
Author: Svyatoslav Ryhel <[email protected]>

dt-bindings: input: Document Imagis ISA1200 haptic motor driver

This commit documents the Imagis ISA1200 haptic motor driver. It introduces a new YAML binding schema for the driver, specifying properties like control-gpios, clocks, and internal PWM configurations.

Quoted 5 lines
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +0 -0
new file mode 100644
index 0000000000000..bbe6f99d39c19

[ ... ]

Quoted 1 line
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +0 -0
@@ -0,0 +1,140 @@

[ ... ]

Quoted 9 lines
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +9 -0
+  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
+

Documentation/devicetree/bindings/input/imagis,isa1200.yaml line 79

Quoted 10 lines
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +10 -0
+  imagis,period-ns:
+    description:
+      Period of the internal PWM channel in nanoseconds.
+    minimum: 10000
+    maximum: 30000
+
+  imagis,duty-cycle-ns:
+    description:
+      Duty cycle of the external/internal PWM channel in nanoseconds,
+      defaults to 50% of the channel's period

Will the minimum and maximum bounds on imagis,period-ns be silently ignored during validation?

The core property-units.yaml schema automatically assigns an array type to properties ending in -ns. Without an explicit reference to /schemas/types.yaml#/definitions/uint32, these properties are evaluated as arrays rather than scalar integers.

Quoted 4 lines

In standard JSON Schema, numeric constraints like minimum and maximum are ignored when applied to an array instance. Adding the uint32 type reference for both imagis,period-ns and imagis,duty-cycle-ns would ensure the constraints are properly enforced on a single scalar value.

Wrong.

While that's true for json-schema, the standard unit properties schemas will be fixed up to the right type.

Rob

maintainer Reviewed-by on v5 1/2
#4 lore raw

Re: [PATCH v5 1/2] dt-bindings: input: Document Imagis ISA1200 haptic motor driver

In reply to Svyatoslav Ryhel
Quoted 38 lines · Svyatoslav Ryhel

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.

---
 .../bindings/input/imagis,isa1200.yaml        | 140 ++++++++++++++++++
 1 file changed, 140 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/imagis,isa1200.yaml
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +19 -0
new file mode 100644
index 000000000000..bbe6f99d39c1
@@ -0,0 +1,140 @@
+# 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 <[email protected]>
+  - Linus Walleij <[email protected]>
+
+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.
+

Documentation/devicetree/bindings/input/imagis,isa1200.yaml line 29

Quoted 10 lines
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +10 -0
+properties:
+  compatible:
+    const: imagis,isa1200
+
+  reg:
+    maxItems: 1
+
+  control-gpios:
+    description:
+      One or two GPIOs flagged as active high linked to HEN and LEN pins

minItems: 1

With that,

Quoted 1 line
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +1 -0
+    maxItems: 2
#5 lore raw

Re: [PATCH v5 1/2] dt-bindings: input: Document Imagis ISA1200 haptic motor driver

чт, 14 трав. 2026 р. о 17:55 Rob Herring <[email protected]> пише:

Quoted 44 lines · Svyatoslav Ryhel
Quoted 42 lines

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.

---
 .../bindings/input/imagis,isa1200.yaml        | 140 ++++++++++++++++++
 1 file changed, 140 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/imagis,isa1200.yaml
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +23 -0
new file mode 100644
index 000000000000..bbe6f99d39c1
@@ -0,0 +1,140 @@
+# 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 <[email protected]>
+  - Linus Walleij <[email protected]>
+
+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
+
Quoted 9 lines

Documentation/devicetree/bindings/input/imagis,isa1200.yaml line 29

Quoted 6 lines
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +6 -0
+  reg:
+    maxItems: 1
+
+  control-gpios:
+    description:
+      One or two GPIOs flagged as active high linked to HEN and LEN pins

minItems: 1

In theory there may be no GPIOs and both pins can be hooked to power. This is unlikely scenario but since it is possible I did not set minItems and did not make control-gpios a required property.

Quoted 5 lines

With that,

Quoted 1 line
Documentation/devicetree/bindings/input/imagis,isa1200.yaml new file +1 -0
+    maxItems: 2
#6 lore raw

PATCH v5 2/2 Input: isa1200 - new driver for Imagis ISA1200

In reply to Svyatoslav Ryhel

From: Linus Walleij <[email protected]>

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.

---
 drivers/input/misc/Kconfig   |  12 +
 drivers/input/misc/Makefile  |   1 +
 drivers/input/misc/isa1200.c | 524 +++++++++++++++++++++++++++++++++++
 3 files changed, 537 insertions(+)
 create mode 100644 drivers/input/misc/isa1200.c
drivers/input/misc/Kconfig +12 -0
index 94a753fcb64f..52f192104ee2 100644
@@ -852,6 +852,18 @@ config INPUT_IQS7222
 	  To compile this driver as a module, choose M here: the
 	  module will be called iqs7222.
 
+config INPUT_ISA1200_HAPTIC
+	tristate "Imagis ISA1200 haptic feedback unit"
+	depends on I2C
+	select INPUT_FF_MEMLESS
+	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
drivers/input/misc/Makefile +1 -0
index 415fc4e2918b..d62bf2e9d85f 100644
@@ -49,6 +49,7 @@ obj-$(CONFIG_INPUT_IMS_PCU)		+= ims-pcu.o
 obj-$(CONFIG_INPUT_IQS269A)		+= iqs269a.o
 obj-$(CONFIG_INPUT_IQS626A)		+= iqs626a.o
 obj-$(CONFIG_INPUT_IQS7222)		+= iqs7222.o
+obj-$(CONFIG_INPUT_ISA1200_HAPTIC)	+= isa1200.o
 obj-$(CONFIG_INPUT_KEYSPAN_REMOTE)	+= keyspan_remote.o
 obj-$(CONFIG_INPUT_KXTJ9)		+= kxtj9.o
 obj-$(CONFIG_INPUT_M68K_BEEP)		+= m68kspkr.o
drivers/input/misc/isa1200.c new file +524 -0

524 lines not on this page · raw message

Signature · 1 line
2.51.0
#7 lore raw

Re: [PATCH v5 2/2] Input: isa1200 - new driver for Imagis ISA1200

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] Flawed interaction between isa1200_stop, suspend, and isa->level leads to lost haptic state on…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Flawed interaction between isa1200_stop, suspend, and isa->level leads to lost haptic state on resume and power leaks.
- [High] Missing workqueue cancellation and timer cleanup on driver unbind causes Use-After-Free.
- [High] Data races around hardware state transitions lead to resource leaks and I2C corruption.
- [Medium] Stack out-of-bounds read due to unvalidated GPIO descriptor count.
--

commit 87a2f648deb0c974007e802b082c1ec62d4fb097
Author: Linus Walleij <[email protected]>

Input: isa1200 - new driver for Imagis ISA1200

This commit introduces a new input driver for the Imagis ISA1200 haptic feedback unit, adding support for controlling its motors over I2C and PWM interfaces.

Quoted 5 lines
drivers/input/misc/isa1200.c new file +0 -0
new file mode 100644
index 0000000000000..ff82252a08e1b

[ ... ]

drivers/input/misc/isa1200.c line 155

Quoted 12 lines
drivers/input/misc/isa1200.c new file +12 -0
+static void isa1200_start(struct isa1200 *isa)
+{
+	struct isa1200_config *config = &isa->config;
+	struct device *dev = &isa->input->dev;
+	struct pwm_state state;
+	u8 hctrl0 = 0, hctrl1 = 0;
+	DECLARE_BITMAP(values, ISA1200_EN_PINS_MAX);
+	int err;
+
+	if (!isa->active) {
+		err = regulator_bulk_enable(ARRAY_SIZE(isa1200_supplies),
+					    isa->supplies);

Are isa1200_start() and isa1200_stop() vulnerable to data races on the isa->active state?

The active flag is read and modified here without holding any locks. If the workqueue and PM resume callbacks execute concurrently, could both threads observe isa->active as false? This might lead to double initialization of the clocks and regulators, leaking their reference counts when isa1200_stop() only disables them once.

[ ... ]

Quoted 2 lines
drivers/input/misc/isa1200.c new file +2 -0
+static void isa1200_stop(struct isa1200 *isa)
+{

[ ... ]

Quoted 3 lines
drivers/input/misc/isa1200.c new file +3 -0
+	isa->active = false;
+	isa->level = 0;
+}

[ ... ]

Quoted 2 lines
drivers/input/misc/isa1200.c new file +2 -0
+static int isa1200_of_probe(struct i2c_client *client)
+{

[ ... ]

drivers/input/misc/isa1200.c line 329

Quoted 2 lines
drivers/input/misc/isa1200.c new file +2 -0
+	isa->enable_gpios = devm_gpiod_get_array_optional(dev, "control",
+							  GPIOD_OUT_LOW);

Should this validate the number of returned GPIO descriptors against ISA1200_EN_PINS_MAX?

In isa1200_start() and isa1200_stop(), a local bitmap is declared on the stack with DECLARE_BITMAP(values, ISA1200_EN_PINS_MAX). If a malformed device tree provides more GPIOs than expected, could gpiod_multi_set_value_cansleep() read past the stack bounds of the values bitmap?

[ ... ]

Quoted 2 lines
drivers/input/misc/isa1200.c new file +2 -0
+static int isa1200_probe(struct i2c_client *client)
+{

[ ... ]

drivers/input/misc/isa1200.c line 450

Quoted 1 line
drivers/input/misc/isa1200.c new file +1 -0
+	INIT_WORK(&isa->play_work, isa1200_play_work);

The isa structure is allocated via devm_kzalloc() and will be freed automatically when the device is unbound. Because there is no remove callback or devm action to cancel isa->play_work, could the workqueue execute after unbind and cause a use-after-free if an effect is playing during unbind?

Similarly, the ff_memless timer is tied to the input_dev, which can outlive the I2C device if userspace holds an open file descriptor. Does the timer also need to be cleaned up on driver unbind to prevent it from accessing freed memory?

[ ... ]

Quoted 4 lines
drivers/input/misc/isa1200.c new file +4 -0
+static int isa1200_suspend(struct device *dev)
+{
+	struct isa1200 *isa = dev_get_drvdata(dev);
+

drivers/input/misc/isa1200.c line 488

Quoted 10 lines
drivers/input/misc/isa1200.c new file +10 -0
+	guard(mutex)(&isa->input->mutex);
+
+	if (input_device_enabled(isa->input)) {
+		cancel_work_sync(&isa->play_work);
+		if (isa->level)
+			isa1200_stop(isa);
+	}
+
+	return 0;
+}

If the user has already requested the motor to stop (level is 0), this skips calling isa1200_stop(). If the workqueue is cancelled before it gets a chance to shut down the hardware, would this leave the device active and leak power throughout suspend?

Additionally, looking at the resume function:

[ ... ]

drivers/input/misc/isa1200.c line 501

Quoted 12 lines
drivers/input/misc/isa1200.c new file +12 -0
+static int isa1200_resume(struct device *dev)
+{
+	struct isa1200 *isa = dev_get_drvdata(dev);
+
+	guard(mutex)(&isa->input->mutex);
+
+	if (input_device_enabled(isa->input))
+		if (isa->level)
+			isa1200_start(isa);
+
+	return 0;
+}

Since isa1200_stop() unconditionally sets isa->level to 0 during suspend, will this check always evaluate to false, causing the driver to permanently lose its haptic state after resuming?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#8 lore raw

Re: [PATCH v5 2/2] Input: isa1200 - new driver for Imagis ISA1200

In reply to Svyatoslav Ryhel

вт, 12 трав. 2026 р. о 13:24 Svyatoslav Ryhel <[email protected]> пише:

Quoted 16 lines

From: Linus Walleij <[email protected]>

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.

Quoted 7 lines
---
 drivers/input/misc/Kconfig   |  12 +
 drivers/input/misc/Makefile  |   1 +
 drivers/input/misc/isa1200.c | 524 +++++++++++++++++++++++++++++++++++
 3 files changed, 537 insertions(+)
 create mode 100644 drivers/input/misc/isa1200.c

Hello Dmitry! Do I need to make any further adjustments to this driver?

#9 lore raw

Re: [PATCH v5 2/2] Input: isa1200 - new driver for Imagis ISA1200

чт, 28 трав. 2026 р. о 08:38 Svyatoslav Ryhel <[email protected]> пише:

Quoted 26 lines

вт, 12 трав. 2026 р. о 13:24 Svyatoslav Ryhel <[email protected]> пише:

Quoted 16 lines

From: Linus Walleij <[email protected]>

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.

Quoted 7 lines
---
 drivers/input/misc/Kconfig   |  12 +
 drivers/input/misc/Makefile  |   1 +
 drivers/input/misc/isa1200.c | 524 +++++++++++++++++++++++++++++++++++
 3 files changed, 537 insertions(+)
 create mode 100644 drivers/input/misc/isa1200.c
Quoted 1 line

Hello Dmitry! Do I need to make any further adjustments to this driver?

Hello Dmitry! Do I need to make any further adjustments to this driver? This driver is hanging in LKML for some time already without responds from input maintainer. It is still relevant and I would like it to move forward.

maintainer
#10 lore raw

Re: [PATCH v5 2/2] Input: isa1200 - new driver for Imagis ISA1200

Hi Svyatoslav,

Quoted 27 lines · Svyatoslav Ryhel

чт, 28 трав. 2026 р. о 08:38 Svyatoslav Ryhel <[email protected]> пише:

Quoted 26 lines

вт, 12 трав. 2026 р. о 13:24 Svyatoslav Ryhel <[email protected]> пише:

Quoted 23 lines

From: Linus Walleij <[email protected]>

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.

---
 drivers/input/misc/Kconfig   |  12 +
 drivers/input/misc/Makefile  |   1 +
 drivers/input/misc/isa1200.c | 524 +++++++++++++++++++++++++++++++++++
 3 files changed, 537 insertions(+)
 create mode 100644 drivers/input/misc/isa1200.c
Quoted 6 lines
Quoted 1 line

Hello Dmitry! Do I need to make any further adjustments to this driver?

Hello Dmitry! Do I need to make any further adjustments to this driver? This driver is hanging in LKML for some time already without responds from input maintainer. It is still relevant and I would like it to move forward.

There were valid sashiko comments on the patch regarding resetting "level" to 0 and also potential racing conditions, as well as suggestion to check number of gpios specified in the device tree.

Please see if the following works for you:

drivers/input/misc/isa1200.c +23 -11
index ff82252a08e1..c61adc4b605c 100644
@@ -131,6 +131,7 @@ struct isa1200 {
 	struct work_struct play_work;
 	struct isa1200_config config;
 
+	bool suspended;
 	bool active;
 	int level;
 };
@@ -247,17 +248,21 @@ static void isa1200_stop(struct isa1200 *isa)
 			       isa->supplies);
 
 	isa->active = false;
-	isa->level = 0;
 }
 
 static void isa1200_play_work(struct work_struct *work)
 {
 	struct isa1200 *isa = container_of(work, struct isa1200, play_work);
-
-	if (isa->level)
-		isa1200_start(isa);
-	else
-		isa1200_stop(isa);
+	struct input_dev *input = isa->input;
+
+	scoped_guard(mutex_try, &input->mutex) {
+		if (!isa->suspended) {
+			if (isa->level)
+				isa1200_start(isa);
+			else
+				isa1200_stop(isa);
+		}
+	}
 }
 
 static int isa1200_vibrator_play_effect(struct input_dev *input, void *data,
@@ -280,7 +285,8 @@ static int isa1200_vibrator_play_effect(struct input_dev *input, void *data,
 
 	if (isa->level != level) {
 		isa->level = level;
-		schedule_work(&isa->play_work);
+		if (!READ_ONCE(isa->suspended))
+			schedule_work(&isa->play_work);
 	}
 
 	return 0;
@@ -292,6 +298,7 @@ static void isa1200_vibrator_close(struct input_dev *input)
 
 	cancel_work_sync(&isa->play_work);
 	isa1200_stop(isa);
+	isa->level = 0;
 }
 
 static int isa1200_of_probe(struct i2c_client *client)
@@ -331,6 +338,9 @@ static int isa1200_of_probe(struct i2c_client *client)
 		return dev_err_probe(dev, PTR_ERR(isa->enable_gpios),
 				     "failed to get enable gpios\n");
 
+	if (isa->enable_gpios && isa->enable_gpios->ndescs > ISA1200_EN_PINS_MAX)
+		return dev_err_probe(dev, -EINVAL, "too many enable gpios\n");
+
 	ldo_node = device_get_named_child_node(dev, "ldo");
 	if (!ldo_node)
 		return dev_err_probe(dev, -ENODEV,
@@ -479,9 +489,9 @@ static int isa1200_suspend(struct device *dev)
 	guard(mutex)(&isa->input->mutex);
 
 	if (input_device_enabled(isa->input)) {
+		WRITE_ONCE(isa->suspended, true);
 		cancel_work_sync(&isa->play_work);
-		if (isa->level)
-			isa1200_stop(isa);
+		isa1200_stop(isa);
 	}
 
 	return 0;
@@ -493,9 +503,11 @@ static int isa1200_resume(struct device *dev)
 
 	guard(mutex)(&isa->input->mutex);
 
-	if (input_device_enabled(isa->input))
+	if (input_device_enabled(isa->input)) {
+		WRITE_ONCE(isa->suspended, false);
 		if (isa->level)
-			isa1200_start(isa);
+			schedule_work(&isa->play_work);
+	}
 
 	return 0;
 }
Signature · 1 line
Dmitry
#11 lore raw

Re: [PATCH v5 2/2] Input: isa1200 - new driver for Imagis ISA1200

вт, 16 черв. 2026 р. о 07:16 Dmitry Torokhov <[email protected]> пише:

Quoted 140 lines

Hi Svyatoslav,

Quoted 27 lines · Svyatoslav Ryhel

чт, 28 трав. 2026 р. о 08:38 Svyatoslav Ryhel <[email protected]> пише:

Quoted 26 lines

вт, 12 трав. 2026 р. о 13:24 Svyatoslav Ryhel <[email protected]> пише:

Quoted 23 lines

From: Linus Walleij <[email protected]>

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.

---
 drivers/input/misc/Kconfig   |  12 +
 drivers/input/misc/Makefile  |   1 +
 drivers/input/misc/isa1200.c | 524 +++++++++++++++++++++++++++++++++++
 3 files changed, 537 insertions(+)
 create mode 100644 drivers/input/misc/isa1200.c
Quoted 6 lines
Quoted 1 line

Hello Dmitry! Do I need to make any further adjustments to this driver?

Hello Dmitry! Do I need to make any further adjustments to this driver? This driver is hanging in LKML for some time already without responds from input maintainer. It is still relevant and I would like it to move forward.

There were valid sashiko comments on the patch regarding resetting "level" to 0 and also potential racing conditions, as well as suggestion to check number of gpios specified in the device tree.

Please see if the following works for you:

drivers/input/misc/isa1200.c +23 -12
index ff82252a08e1..c61adc4b605c 100644
@@ -131,6 +131,7 @@ struct isa1200 {
        struct work_struct play_work;
        struct isa1200_config config;
 
+       bool suspended;
        bool active;
        int level;
 };
@@ -247,17 +248,21 @@ static void isa1200_stop(struct isa1200 *isa)
                               isa->supplies);
 
        isa->active = false;
-       isa->level = 0;
 }
 
 static void isa1200_play_work(struct work_struct *work)
 {
        struct isa1200 *isa = container_of(work, struct isa1200, play_work);
-
-       if (isa->level)
-               isa1200_start(isa);
-       else
-               isa1200_stop(isa);
+       struct input_dev *input = isa->input;
+
+       scoped_guard(mutex_try, &input->mutex) {
+               if (!isa->suspended) {
+                       if (isa->level)
+                               isa1200_start(isa);
+                       else
+                               isa1200_stop(isa);
+               }
+       }
 }
 
 static int isa1200_vibrator_play_effect(struct input_dev *input, void *data,
@@ -280,7 +285,8 @@ static int isa1200_vibrator_play_effect(struct input_dev *input, void *data,
 
        if (isa->level != level) {
                isa->level = level;
-               schedule_work(&isa->play_work);
+               if (!READ_ONCE(isa->suspended))
+                       schedule_work(&isa->play_work);
        }
 
        return 0;
@@ -292,6 +298,7 @@ static void isa1200_vibrator_close(struct input_dev *input)
 
        cancel_work_sync(&isa->play_work);
        isa1200_stop(isa);
+       isa->level = 0;
 }
 
 static int isa1200_of_probe(struct i2c_client *client)
@@ -331,6 +338,9 @@ static int isa1200_of_probe(struct i2c_client *client)
                return dev_err_probe(dev, PTR_ERR(isa->enable_gpios),
                                     "failed to get enable gpios\n");
 
+       if (isa->enable_gpios && isa->enable_gpios->ndescs > ISA1200_EN_PINS_MAX)
+               return dev_err_probe(dev, -EINVAL, "too many enable gpios\n");
+
        ldo_node = device_get_named_child_node(dev, "ldo");
        if (!ldo_node)
                return dev_err_probe(dev, -ENODEV,
@@ -479,9 +489,9 @@ static int isa1200_suspend(struct device *dev)
        guard(mutex)(&isa->input->mutex);
 
        if (input_device_enabled(isa->input)) {
+               WRITE_ONCE(isa->suspended, true);
                cancel_work_sync(&isa->play_work);
-               if (isa->level)
-                       isa1200_stop(isa);
+               isa1200_stop(isa);
        }
 
        return 0;
@@ -493,9 +503,11 @@ static int isa1200_resume(struct device *dev)
 
        guard(mutex)(&isa->input->mutex);
 
-       if (input_device_enabled(isa->input))
+       if (input_device_enabled(isa->input)) {
+               WRITE_ONCE(isa->suspended, false);
                if (isa->level)
-                       isa1200_start(isa);
+                       schedule_work(&isa->play_work);
+       }
 
        return 0;
 }
 
--
Quoted 1 line

Dmitry

I have tested your code on my P895 and it works perfectly fine. Should I resend with these changes or you can integrate them while picking patchset?

Thank you for your suggestions and efforts!

Best regards,
Svyatoslav R.

maintainer
#12 lore raw

Re: [PATCH v5 2/2] Input: isa1200 - new driver for Imagis ISA1200

Quoted 4 lines · Svyatoslav Ryhel

I have tested your code on my P895 and it works perfectly fine. Should I resend with these changes or you can integrate them while picking patchset?

I think there was an update requested by Rob for the bindings?

Quoted 2 lines

Thank you for your suggestions and efforts!

Thank you for your patience.

Signature · 1 line
Dmitry
#13 lore raw

Re: [PATCH v5 2/2] Input: isa1200 - new driver for Imagis ISA1200

вт, 16 черв. 2026 р. о 23:30 Dmitry Torokhov <[email protected]> пише:

Quoted 9 lines · Svyatoslav Ryhel
Quoted 4 lines

I have tested your code on my P895 and it works perfectly fine. Should I resend with these changes or you can integrate them while picking patchset?

I think there was an update requested by Rob for the bindings?

Acknowledged, I will resend with both changes.

Quoted 7 lines
Quoted 2 lines

Thank you for your suggestions and efforts!

Thank you for your patience.

--
Dmitry