Skip to contentSkip to conversation

input: drv260x: Add TI drv260x haptics driver

PATCH In review Dan Murphy 2 participants 7 messages Aug 15, 2014 – Aug 19, 2014

Subsystems (3)
lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

PATCH v6 1/1 input: drv260x: Add TI drv260x haptics driver

Add the TI drv260x haptics/vibrator driver.
This device uses the input force feedback
to produce a wave form to driver an
ERM or LRA actuator device.

The initial driver supports the devices
real time playback mode. But the device
has additional wave patterns in ROM.

This functionality will be added in
future patchsets.

Product data sheet is located here:
http://www.ti.com/product/drv2605

---

v6 - Updated bindings doc to reflect correct pre-programmed library,
updated the vib-overdrive and rated voltage to add -mv, removed _ from
the same, add check to verify LRA libraries are only used in LRA mode,
and finally changed supply -> vbat-supply in binding doc - https://patchwork.kernel.org/patch/4658661/
v5 - Move register defines to c file and rm header file, error check
init in probe, fixed identation, remove empty labels in probe
and just return on fail and removed the remove callback and function.
Did not factor out the suspend into a stop function. - https://patchwork.kernel.org/patch/4649631/
v4 - Convert regulator to devm, added error checking where required,
updated bindings doc, moved dt parsing to separate call and made platform
data the first data point, moved vibrator enable and mode programming from
play entry to worker thread, added user check and input mutex in suspend/resume
calls, moved platform data to individual file and into include platform-data directory,
removed file names from file headers - https://patchwork.kernel.org/patch/4642221/
v3 - Updated binding doc, changed to memless device, updated input alloc to
devm, removed mutex locking, add sanity checks for mode and library - https://patchwork.kernel.org/patch/4635421/
v2 - Fixed binding doc and patch headline - https://patchwork.kernel.org/patch/4619641/

 .../devicetree/bindings/input/ti,drv260x.txt       |   51 ++
 drivers/input/misc/Kconfig                         |    9 +
 drivers/input/misc/Makefile                        |    1 +
 drivers/input/misc/drv260x.c                       |  704 ++++++++++++++++++++
 include/dt-bindings/input/ti-drv260x.h             |   36 +
 include/linux/platform_data/drv260x-pdata.h        |   29 +
 6 files changed, 830 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/ti,drv260x.txt
 create mode 100644 drivers/input/misc/drv260x.c
 create mode 100644 include/dt-bindings/input/ti-drv260x.h
 create mode 100644 include/linux/platform_data/drv260x-pdata.h
Documentation/devicetree/bindings/input/ti,drv260x.txt new file +51 -0
new file mode 100644
index 0000000..d54be15
@@ -0,0 +1,51 @@
+Texas Instruments - drv260x Haptics driver family
+
+The drv260x family serial control bus communicates through I2C protocols
+
+Required properties:
+	- compatible - One of:
+		"ti,drv2604" - DRV2604
+		"ti,drv2605" - DRV2605
+		"ti,drv2605l" - DRV2605L
+	- reg -  I2C slave address
+	- vbat-supply- Required supply regulator
+	- mode - Power up mode of the chip (defined in include/dt-bindings/input/ti-drv260x.h)
+		DRV260X_LRA_MODE - Linear Resonance Actuator mode (Piezoelectric)
+		DRV260X_LRA_NO_CAL_MODE - This is a LRA Mode but there is no calibration
+				sequence during init.  And the device is configured for real
+				time playback mode (RTP mode).
+		DRV260X_ERM_MODE - Eccentric Rotating Mass mode (Rotary vibrator)
+	- library-sel - These are ROM based waveforms pre-programmed into the IC.
+				This should be set to set the library to use at power up.
+				(defined in include/dt-bindings/input/ti-drv260x.h)
+		DRV260X_LIB_EMPTY - Do not use a pre-programmed library
+		DRV260X_ERM_LIB_A - Pre-programmed Library
+		DRV260X_ERM_LIB_B - Pre-programmed Library
+		DRV260X_ERM_LIB_C - Pre-programmed Library
+		DRV260X_ERM_LIB_D - Pre-programmed Library
+		DRV260X_ERM_LIB_E - Pre-programmed Library
+		DRV260X_ERM_LIB_F - Pre-programmed Library
+		DRV260X_LIB_LRA - Pre-programmed LRA Library
+
+Optional properties:
+	- enable-gpio - gpio pin to enable/disable the device.
+	- vib-rated-mv - The rated voltage of the actuator in millivolts.
+			  If this is not set then the value will be defaulted to
+			  3.2 v.
+	- vib-overdrive-mv - The overdrive voltage of the actuator in millivolts.
+			  If this is not set then the value will be defaulted to
+			  3.2 v.
+Example:
+
+drv2605l: drv2605l@5a {
+		compatible = "ti,drv2605l";
+		reg = <0x5a>;
+		enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+		mode = <DRV260X_LRA_MODE>;
+		library-sel = <DRV260X_LIB_LRA>;
+		vib-rated-mv = <3200>;
+		vib-overdriver-mv = <3200>;
+};
+
+For more product information please see the link below:
+http://www.ti.com/product/drv2605
drivers/input/misc/Kconfig +9 -0
index 2ff4425..99f6762 100644
@@ -676,4 +676,13 @@ config INPUT_SOC_BUTTON_ARRAY
 	  To compile this driver as a module, choose M here: the
 	  module will be called soc_button_array.
 
+config INPUT_DRV260X_HAPTICS
+	tristate "TI DRV260X haptics support"
+	depends on INPUT && I2C
+	help
+	  Say Y to enable support for the TI DRV260X haptics driver.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called drv260x-haptics.
+
 endif
drivers/input/misc/Makefile +1 -0
index 4955ad3..d8ef3c7 100644
@@ -64,3 +64,4 @@ obj-$(CONFIG_INPUT_WM831X_ON)		+= wm831x-on.o
 obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND)	+= xen-kbdfront.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
 obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR)	+= ideapad_slidebar.o
+obj-$(CONFIG_INPUT_DRV260X_HAPTICS)	+= drv260x.o
drivers/input/misc/drv260x.c new file +704 -0

704 lines not on this page · raw message

include/dt-bindings/input/ti-drv260x.h new file +36 -0
new file mode 100644
index 0000000..b2e5126
@@ -0,0 +1,36 @@
+/*
+ * DRV260X haptics driver family
+ *
+ * Author: Dan Murphy <[email protected]>
+ *
+ * Copyright:   (C) 2014 Texas Instruments, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef _DT_BINDINGS_TI_DRV260X_H
+#define _DT_BINDINGS_TI_DRV260X_H
+
+/* Calibration Types */
+#define DRV260X_LRA_MODE		0x00
+#define DRV260X_LRA_NO_CAL_MODE	0x01
+#define DRV260X_ERM_MODE		0x02
+
+/* Library Selection */
+#define DRV260X_LIB_EMPTY			0x00
+#define DRV260X_ERM_LIB_A			0x01
+#define DRV260X_ERM_LIB_B			0x02
+#define DRV260X_ERM_LIB_C			0x03
+#define DRV260X_ERM_LIB_D			0x04
+#define DRV260X_ERM_LIB_E			0x05
+#define DRV260X_LIB_LRA 			0x06
+#define DRV260X_ERM_LIB_F			0x07
+
+#endif
include/linux/platform_data/drv260x-pdata.h new file +29 -0
new file mode 100644
index 0000000..4091a9b
@@ -0,0 +1,29 @@
+/*
+ * Platform data for DRV260X haptics driver family
+ *
+ * Author: Dan Murphy <[email protected]>
+ *
+ * Copyright:   (C) 2014 Texas Instruments, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef _LINUX_DRV260X_PDATA_H
+#define _LINUX_DRV260X_PDATA_H
+
+struct drv260x_platform_data {
+	int enable_gpio;
+	u32 library_selection;
+	u32 mode;
+	u32 vib_rated_voltage;
+	u32 vib_overdrive_voltage;
+};
+
+#endif
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw

Hi Dan,

drivers/input/misc/Kconfig config INPUT_SOC_BUTTON_ARRAY · line 681

Quoted 11 lines · Dan Murphy
drivers/input/misc/Kconfig +3 -0
index 2ff4425..99f6762 100644
@@ -676,4 +676,13 @@ config INPUT_SOC_BUTTON_ARRAY
 	  To compile this driver as a module, choose M here: the
 	  module will be called soc_button_array.
 
+config INPUT_DRV260X_HAPTICS
+	tristate "TI DRV260X haptics support"
+	depends on INPUT && I2C

This also needs "select REGMAP_I2C"

Quoted 6 lines
drivers/input/misc/Kconfig +6 -0
+	help
+	  Say Y to enable support for the TI DRV260X haptics driver.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called drv260x-haptics.
+

[...]

drivers/input/misc/Kconfig

Quoted 5 lines
drivers/input/misc/Kconfig +5 -0
+#ifndef _LINUX_DRV260X_PDATA_H
+#define _LINUX_DRV260X_PDATA_H
+
+struct drv260x_platform_data {
+	int enable_gpio;

I do not see this used anywhere.

drivers/input/misc/Kconfig

Quoted 7 lines
drivers/input/misc/Kconfig +7 -0
+	u32 library_selection;
+	u32 mode;
+	u32 vib_rated_voltage;
+	u32 vib_overdrive_voltage;
+};
+
+#endif

I fixed up the above issues and did a few more formatting changes and applied to my 'next' branch. Please take a peek and holler if you see something wrong.

Thanks.

Signature · 5 lines
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Dmitry

Quoted 11 lines · Dmitry Torokhov

Hi Dan,

Quoted 8 lines · Dan Murphy
drivers/input/misc/Kconfig +0 -0
index 2ff4425..99f6762 100644
@@ -676,4 +676,13 @@ config INPUT_SOC_BUTTON_ARRAY
 	  To compile this driver as a module, choose M here: the
 	  module will be called soc_button_array.
 
Quoted 6 lines

drivers/input/misc/Kconfig config INPUT_SOC_BUTTON_ARRAY · line 681

Quoted 3 lines
drivers/input/misc/Kconfig +3 -0
+config INPUT_DRV260X_HAPTICS
+	tristate "TI DRV260X haptics support"
+	depends on INPUT && I2C

This also needs "select REGMAP_I2C"

This one is OK

Quoted 9 lines
Quoted 6 lines
drivers/input/misc/Kconfig +6 -0
+	help
+	  Say Y to enable support for the TI DRV260X haptics driver.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called drv260x-haptics.
+

[...]

Quoted 7 lines

drivers/input/misc/Kconfig

Quoted 5 lines
drivers/input/misc/Kconfig +5 -0
+#ifndef _LINUX_DRV260X_PDATA_H
+#define _LINUX_DRV260X_PDATA_H
+
+struct drv260x_platform_data {
+	int enable_gpio;

I do not see this used anywhere.

But this is actually used here

haptics->enable_gpio = devm_gpiod_get(&client->dev, "enable");

for the non-dt case

Quoted 14 lines

drivers/input/misc/Kconfig

Quoted 8 lines
drivers/input/misc/Kconfig +7 -0
+	u32 library_selection;
+	u32 mode;
+	u32 vib_rated_voltage;
+	u32 vib_overdrive_voltage;
+};
+
+#endif

I fixed up the above issues and did a few more formatting changes and applied to my 'next' branch. Please take a peek and holler if you see something wrong.

Thanks.

Signature · 2 lines
------------------
Dan Murphy
maintainer
#3 lore raw
Quoted 40 lines · Dan

Dmitry

Quoted 11 lines · Dmitry Torokhov

Hi Dan,

Quoted 8 lines · Dan Murphy
drivers/input/misc/Kconfig +0 -0
index 2ff4425..99f6762 100644
@@ -676,4 +676,13 @@ config INPUT_SOC_BUTTON_ARRAY
 	  To compile this driver as a module, choose M here: the
 	  module will be called soc_button_array.
 
Quoted 6 lines

drivers/input/misc/Kconfig config INPUT_SOC_BUTTON_ARRAY · line 681

Quoted 3 lines
drivers/input/misc/Kconfig +3 -0
+config INPUT_DRV260X_HAPTICS
+	tristate "TI DRV260X haptics support"
+	depends on INPUT && I2C

This also needs "select REGMAP_I2C"

This one is OK

Quoted 9 lines
Quoted 6 lines
drivers/input/misc/Kconfig +6 -0
+	help
+	  Say Y to enable support for the TI DRV260X haptics driver.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called drv260x-haptics.
+

[...]

Quoted 7 lines

drivers/input/misc/Kconfig

Quoted 5 lines
drivers/input/misc/Kconfig +5 -0
+#ifndef _LINUX_DRV260X_PDATA_H
+#define _LINUX_DRV260X_PDATA_H
+
+struct drv260x_platform_data {
+	int enable_gpio;

I do not see this used anywhere.

Quoted 5 lines

But this is actually used here

haptics->enable_gpio = devm_gpiod_get(&client->dev, "enable");

for the non-dt case

"haptics" is not instance of drv260x_platform_data but drv260x_data which defines:

struct drv260x_data {
	...
	struct gpio_desc *enable_gpio;
	...

That one I kept.

Signature · 1 line
Dmitry
#4 lore raw
Quoted 50 lines · Dmitry Torokhov
Quoted 40 lines · Dan

Dmitry

Quoted 11 lines · Dmitry Torokhov

Hi Dan,

Quoted 8 lines · Dan Murphy
drivers/input/misc/Kconfig +0 -0
index 2ff4425..99f6762 100644
@@ -676,4 +676,13 @@ config INPUT_SOC_BUTTON_ARRAY
 	  To compile this driver as a module, choose M here: the
 	  module will be called soc_button_array.
 
Quoted 6 lines

drivers/input/misc/Kconfig config INPUT_SOC_BUTTON_ARRAY · line 681

Quoted 3 lines
drivers/input/misc/Kconfig +3 -0
+config INPUT_DRV260X_HAPTICS
+	tristate "TI DRV260X haptics support"
+	depends on INPUT && I2C

This also needs "select REGMAP_I2C"

This one is OK

Quoted 9 lines
Quoted 6 lines
drivers/input/misc/Kconfig +6 -0
+	help
+	  Say Y to enable support for the TI DRV260X haptics driver.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called drv260x-haptics.
+

[...]

Quoted 7 lines

drivers/input/misc/Kconfig

Quoted 5 lines
drivers/input/misc/Kconfig +5 -0
+#ifndef _LINUX_DRV260X_PDATA_H
+#define _LINUX_DRV260X_PDATA_H
+
+struct drv260x_platform_data {
+	int enable_gpio;

I do not see this used anywhere.

Quoted 5 lines

But this is actually used here

haptics->enable_gpio = devm_gpiod_get(&client->dev, "enable");

for the non-dt case

"haptics" is not instance of drv260x_platform_data but drv260x_data which defines:

Quoted 7 lines
struct drv260x_data {
	...
	struct gpio_desc *enable_gpio;
	...

That one I kept.

Yes that is correct but the enable_gpio for non-dt enabled devices this enable_gpio needs to come from the platform data structure. Without the enable gpio in the platform data structure there is no way for non-dt enabled devices to set the gpio value.

The haptics instance just stores the gpio descriptor returned from this call.

The devm_gpiod looks at the platform data is CONFIG_OF is not set.

Dan

Signature · 2 lines
------------------
Dan Murphy
maintainer
#5 lore raw
Quoted 56 lines · Dan
Quoted 55 lines · Dmitry Torokhov
Quoted 40 lines · Dan

Dmitry

Quoted 11 lines · Dmitry Torokhov

Hi Dan,

Quoted 8 lines · Dan Murphy
drivers/input/misc/Kconfig +0 -0
index 2ff4425..99f6762 100644
@@ -676,4 +676,13 @@ config INPUT_SOC_BUTTON_ARRAY
 	  To compile this driver as a module, choose M here: the
 	  module will be called soc_button_array.
 
Quoted 6 lines

drivers/input/misc/Kconfig config INPUT_SOC_BUTTON_ARRAY · line 681

Quoted 3 lines
drivers/input/misc/Kconfig +3 -0
+config INPUT_DRV260X_HAPTICS
+	tristate "TI DRV260X haptics support"
+	depends on INPUT && I2C

This also needs "select REGMAP_I2C"

This one is OK

Quoted 9 lines
Quoted 6 lines
drivers/input/misc/Kconfig +6 -0
+	help
+	  Say Y to enable support for the TI DRV260X haptics driver.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called drv260x-haptics.
+

[...]

Quoted 7 lines

drivers/input/misc/Kconfig

Quoted 5 lines
drivers/input/misc/Kconfig +5 -0
+#ifndef _LINUX_DRV260X_PDATA_H
+#define _LINUX_DRV260X_PDATA_H
+
+struct drv260x_platform_data {
+	int enable_gpio;

I do not see this used anywhere.

Quoted 5 lines

But this is actually used here

haptics->enable_gpio = devm_gpiod_get(&client->dev, "enable");

for the non-dt case

"haptics" is not instance of drv260x_platform_data but drv260x_data which defines:

struct drv260x_data {
	...
	struct gpio_desc *enable_gpio;
	...
Quoted 6 lines
Quoted 2 lines

That one I kept.

Yes that is correct but the enable_gpio for non-dt enabled devices this enable_gpio needs to come from the platform data structure. Without the enable gpio in the platform data structure there is no way for non-dt enabled devices to set the gpio value.

What else uses the platform data structure? You are accessing gpio by name, not by number, in the driver so I am not sure how non-dt case will use u32 defined in platform data.

Quoted 2 lines

The haptics instance just stores the gpio descriptor returned from this call.

Right.

Quoted 2 lines

The devm_gpiod looks at the platform data is CONFIG_OF is not set.

Umm, how? You do not pass it anywhere...

Thanks.

Signature · 1 line
Dmitry
#6 lore raw

Dmitry

Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Dan
Quoted 3 lines · Dmitry Torokhov
Quoted 2 lines · Dan

Dmitry

<snip>

Quoted 14 lines
Quoted 8 lines
Quoted 4 lines
	...

That one I kept.

Yes that is correct but the enable_gpio for non-dt enabled devices this enable_gpio needs to come from the platform data structure. Without the enable gpio in the platform data structure there is no way for non-dt enabled devices to set the gpio value.

What else uses the platform data structure? You are accessing gpio by name, not by number, in the driver so I am not sure how non-dt case will use u32 defined in platform data.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

The haptics instance just stores the gpio descriptor returned from this call.

Right.

Quoted 2 lines

The devm_gpiod looks at the platform data is CONFIG_OF is not set.

Umm, how? You do not pass it anywhere...

OK I drop my argument after drilling through gpio code.

Removal of this is OK.

Thanks

Quoted 3 lines

Thanks.

Signature · 2 lines
------------------
Dan Murphy