RE: [PATCH] pwm: Rename pwm_get_state() to better reflect its semantic

2021-04-06 Thread Roy Im
On Tue, 06 Apr 2021, Uwe Kleine-König  wrote:
> Given that lowlevel drivers usually cannot implement exactly what a 
> consumer requests with pwm_apply_state() there is some
> rounding involved.
> 
> pwm_get_state() traditionally returned the setting that was requested 
> most recently by the consumer (opposed to what was
> actually implemented in hardware in reply to the last request).
> To make this semantic obvious rename the function.
> 
> Signed-off-by: Uwe Kleine-König 
> ---
>  drivers/input/misc/da7280.c        |  2 +-

Acked-by: Roy Im 


RE: [PATCH] Input: da7280 - protect OF match table with CONFIG_OF

2020-12-18 Thread Roy Im
On Friday, December 18, 2020 3:50 PM, Dmitry Torokhov wrote:

> The OF match table is only used when OF is enabled.
> 
> Fixes: cd3f609823a5 ("Input: new da7280 haptic driver")
> Reported-by: kernel test robot 
> Signed-off-by: Dmitry Torokhov 
> ---
>  drivers/input/misc/da7280.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c index 
> 2f698a8c1d65..b08610d6e575 100644
> --- a/drivers/input/misc/da7280.c
> +++ b/drivers/input/misc/da7280.c
> @@ -1300,11 +1300,13 @@ static int __maybe_unused da7280_resume(struct device 
> *dev)
>   return retval;
>  }
> 
> +#ifdef CONFIG_OF
>  static const struct of_device_id da7280_of_match[] = {
>   { .compatible = "dlg,da7280", },
>   { }
>  };
>  MODULE_DEVICE_TABLE(of, da7280_of_match);
> +#endif
> 
>  static const struct i2c_device_id da7280_i2c_id[] = {
>   { "da7280", },
> --
> 2.29.2.729.g45daf8777d-goog
> 
> 
> --
> Dmitry

Thanks!

Acked-by: Roy Im 



RE: [PATCH] Input: da7280 - fix missing error test

2020-12-15 Thread Roy Im
On Wednesday, December 16, 2020 3:13 AM, Dmitry Torokhov wrote:

> An "if" testing for error condition has accidentally been dropped from the 
> code.
> 
> Reported-by: kernel test robot 
> Fixes: cd3f609823a5 ("Input: new da7280 haptic driver")
> Signed-off-by: Dmitry Torokhov 
> ---

Many thanks for your help.

Reviewed-by: Roy Im 


RE: [PATCH][next] Input: da7280: fix spelling mistake "sequemce" -> "sequence"

2020-12-15 Thread Roy Im
On Tuesday, December 15, 2020 7:31 AM, On Colin King wrote:

> There is a spelling mistake in a dev_err message. Fix it.
> 
> Signed-off-by: Colin Ian King 
> ---
> - "Failed to update GPI sequemce: %d\n", error);
> + "Failed to update GPI sequence: %d\n", error);

You are right.

Reviewed-by: Roy Im 


RE: [RESEND PATCH V20 3/3] Input: new da7280 haptic driver

2020-11-30 Thread Roy Im
> On Mon, Nov 30, 2020 4:55 PM, Dmitry Torokhov wrote:
> On Thu, Nov 26, 2020 at 01:07:39AM +0900, Roy Im wrote:
> > Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with multiple
> > mode and integrated waveform memory and wideband support.
> > It communicates via an I2C bus to the device.
> 
> I am looking at the driver and should finish review tomorrow. If you do not 
> hear from me by Wednesday please poke me
> again - I want to get the driver into the upcoming merge window.

Thank you! I got it.

Kind regards,
Roy



[RESEND PATCH V20 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-11-25 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v20: No changes.
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index a008b70..389d6e0b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5107,6 +5107,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5117,6 +5118,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for RESEND PATCH V20



[RESEND PATCH V20 3/3] Input: new da7280 haptic driver

2020-11-25 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Reviewed-by: Jes Sorensen .

Signed-off-by: Roy Im 

---
v20:
- Simplified the code with dev_err_probe().
- Removed some work queues.
v19:
- Corrected some errors and replaced some code to proper one.
- Improved work queues and removed sysfs attributes
- Added changes for gpix id in upload effect.
v18:
- Corrected comments in Kconfig
- Updated to preferred style for multi line comments in c file.
v17:
- fixed an issue.
v16:
- Corrected some code and updated description in Kconfig.
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1375 +++
 3 files changed, 1388 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..d38b466 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,16 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by PWM or GPIO
+ with I2C communication.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..21d4d37
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1375 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL

[RESEND PATCH V20 2/3] dt-bindings: input: Add document bindings for DA7280

2020-11-25 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v20: No changes.
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt

[RESEND PATCH V20 0/3] da7280: haptic driver submission

2020-11-25 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v20 1/3] MAINTAINERS file update for DA7280
[PATCH v20 2/3] DA7280 DT Binding
[PATCH v20 3/3] DA7280 Driver

This patch applies against linux-mainline and v5.10-rc5

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1375 
 5 files changed, 1499 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for RESEND PATCH V20



[RESEND PATCH v20 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-11-03 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v20: No changes.
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index b516bb3..f64e18b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5117,6 +5117,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5127,6 +5128,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for RESEND PATCH v20



[RESEND PATCH v20 0/3] da7280: haptic driver submission

2020-11-03 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v20 1/3] MAINTAINERS file update for DA7280
[PATCH v20 2/3] DA7280 DT Binding
[PATCH v20 3/3] DA7280 Driver

This patch applies against linux-mainline and v5.10-rc2

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1375 
 5 files changed, 1499 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for RESEND PATCH v20



[RESEND PATCH v20 3/3] Input: new da7280 haptic driver

2020-11-03 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Reviewed-by: Jes Sorensen .

Signed-off-by: Roy Im 

---
v20:
- Simplified the code with dev_err_probe().
- Removed some work queues.
v19:
- Corrected some errors and replaced some code to proper one.
- Improved work queues and removed sysfs attributes
- Added changes for gpix id in upload effect.
v18:
- Corrected comments in Kconfig
- Updated to preferred style for multi line comments in c file.
v17:
- fixed an issue.
v16:
- Corrected some code and updated description in Kconfig.
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1375 +++
 3 files changed, 1388 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..d38b466 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,16 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by PWM or GPIO
+ with I2C communication.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..21d4d37
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1375 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL

[RESEND PATCH v20 2/3] dt-bindings: input: Add document bindings for DA7280

2020-11-03 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v20: No changes.
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt

[RESEND PATCH v20 0/3] da7280: haptic driver submission

2020-10-13 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v20 1/3] MAINTAINERS file update for DA7280
[PATCH v20 2/3] DA7280 DT Binding
[PATCH v20 3/3] DA7280 Driver

This patch applies against linux-mainline and v5.9

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1375 
 5 files changed, 1499 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for RESEND PATCH v20



[RESEND PATCH v20 2/3] dt-bindings: input: Add document bindings for DA7280

2020-10-13 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v20: No changes.
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt

[RESEND PATCH v20 3/3] Input: new da7280 haptic driver

2020-10-13 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Reviewed-by: Jes Sorensen .

Signed-off-by: Roy Im 

---
v20:
- Simplified the code with dev_err_probe().
- Removed some work queues.
v19:
- Corrected some errors and replaced some code to proper one.
- Improved work queues and removed sysfs attributes
- Added changes for gpix id in upload effect.
v18:
- Corrected comments in Kconfig
- Updated to preferred style for multi line comments in c file.
v17:
- fixed an issue.
v16:
- Corrected some code and updated description in Kconfig.
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1375 +++
 3 files changed, 1388 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..d38b466 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,16 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by PWM or GPIO
+ with I2C communication.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..21d4d37
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1375 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL

[RESEND PATCH v20 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-10-13 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v20: No changes.
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8671573..f206d4a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5080,6 +5080,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5090,6 +5091,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for RESEND PATCH v20



[PATCH v20 3/3] Input: new da7280 haptic driver

2020-09-22 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Reviewed-by: Jes Sorensen .

Signed-off-by: Roy Im 

---
v20:
- Simplified the code with dev_err_probe().
- Removed some work queues.
v19:
- Corrected some errors and replaced some code to proper one.
- Improved work queues and removed sysfs attributes
- Added changes for gpix id in upload effect.
v18:
- Corrected comments in Kconfig
- Updated to preferred style for multi line comments in c file.
v17:
- fixed an issue.
v16:
- Corrected some code and updated description in Kconfig.
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1375 +++
 3 files changed, 1388 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..d38b466 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,16 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by PWM or GPIO
+ with I2C communication.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..21d4d37
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1375 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL

[PATCH v20 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-09-22 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v20: No changes.
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index d746519..6eff440 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5081,6 +5081,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5091,6 +5092,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for PATCH v20



[PATCH v20 0/3] da7280: haptic driver submission

2020-09-22 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v20 1/3] MAINTAINERS file update for DA7280
[PATCH v20 2/3] DA7280 DT Binding
[PATCH v20 3/3] DA7280 Driver

This patch applies against linux-mainline and v5.9-rc6

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1375 
 5 files changed, 1499 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for PATCH v20



[PATCH v20 2/3] dt-bindings: input: Add document bindings for DA7280

2020-09-22 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v20: No changes.
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt

[RESEND PATCH v19 3/3] Input: new da7280 haptic driver

2020-09-02 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Reviewed-by: Jes Sorensen .

Signed-off-by: Roy Im 

---
v19:
- Corrected some errors and replaced some code to proper one.
- Improved work queues and removed sysfs attributes
- Added changes for gpix id in upload effect.
v18:
- Corrected comments in Kconfig
- Updated to preferred style for multi line comments in c file.
v17:
- fixed an issue.
v16:
- Corrected some code and updated description in Kconfig.
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1476 +++
 3 files changed, 1489 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..d38b466 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,16 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by PWM or GPIO
+ with I2C communication.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..ea292c8
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1476 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#defi

[RESEND PATCH v19 0/3] da7280: haptic driver submission

2020-09-02 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v19 1/3] MAINTAINERS file update for DA7280
[PATCH v19 2/3] DA7280 DT Binding
[PATCH v19 3/3] DA7280 Driver

This patch applies against linux-next and v5.8

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1476 
 5 files changed, 1600 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for RESEND PATCH v19



[RESEND PATCH v19 2/3] dt-bindings: input: Add document bindings for DA7280

2020-09-02 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+

[RESEND PATCH v19 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-09-02 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4e2698c..81a9416 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5003,6 +5003,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5013,6 +5014,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for RESEND PATCH v19



[RESEND PATCH v19 3/3] Input: new da7280 haptic driver

2020-08-17 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Reviewed-by: Jes Sorensen .

Signed-off-by: Roy Im 

---
v19:
- Corrected some errors and replaced some code to proper one.
- Improved work queues and removed sysfs attributes
- Added changes for gpix id in upload effect.
v18:
- Corrected comments in Kconfig
- Updated to preferred style for multi line comments in c file.
v17:
- fixed an issue.
v16:
- Corrected some code and updated description in Kconfig.
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1476 +++
 3 files changed, 1489 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..d38b466 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,16 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by PWM or GPIO
+ with I2C communication.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..ea292c8
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1476 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#defi

[RESEND PATCH v19 0/3] da7280: haptic driver submission

2020-08-17 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v19 1/3] MAINTAINERS file update for DA7280
[PATCH v19 2/3] DA7280 DT Binding
[PATCH v19 3/3] DA7280 Driver

This patch applies against linux-next and v5.8

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1476 
 5 files changed, 1600 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for RESEND PATCH v19



[RESEND PATCH v19 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-08-17 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4e2698c..81a9416 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5003,6 +5003,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5013,6 +5014,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for RESEND PATCH v19



[RESEND PATCH v19 2/3] dt-bindings: input: Add document bindings for DA7280

2020-08-17 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+

[PATCH v19 3/3] Input: new da7280 haptic driver

2020-08-04 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Reviewed-by: Jes Sorensen .

Signed-off-by: Roy Im 

---
v19:
- Corrected some errors and replaced some code to proper one.
- Improved work queues and removed sysfs attributes
- Added changes for gpix id in upload effect.
v18:
- Corrected comments in Kconfig
- Updated to preferred style for multi line comments in c file.
v17:
- fixed an issue.
v16:
- Corrected some code and updated description in Kconfig.
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1476 +++
 3 files changed, 1489 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..d38b466 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,16 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by PWM or GPIO
+ with I2C communication.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..ea292c8
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1476 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#defi

[PATCH v19 2/3] dt-bindings: input: Add document bindings for DA7280

2020-08-04 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+

[PATCH v19 0/3] da7280: haptic driver submission

2020-08-04 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v19 1/3] MAINTAINERS file update for DA7280
[PATCH v19 2/3] DA7280 DT Binding
[PATCH v19 3/3] DA7280 Driver

This patch applies against linux-next and v5.8

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1476 
 5 files changed, 1600 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for PATCH v19



[PATCH v19 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-08-04 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v19: No changes.
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4e2698c..81a9416 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5003,6 +5003,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5013,6 +5014,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for PATCH v19



RE: [PATCH v18 3/3] Input: new da7280 haptic driver

2020-08-02 Thread Roy Im
On Sun, August 2, 2020 8:54 PM, Pavel Machek wrote: 
> Hi!
> 
> > > +static DEVICE_ATTR_RW(ps_seq_id);
> > > +static DEVICE_ATTR_RW(ps_seq_loop); static
> > > +DEVICE_ATTR_RW(gpi_seq_id0); static DEVICE_ATTR_RW(gpi_seq_id1);
> > > +static DEVICE_ATTR_RW(gpi_seq_id2); static
> > > +DEVICE_ATTR_WO(patterns);
> >
> > Should this be a binary attribute instead of having string parsing in
> > the kernel?
> 
> Plus... is this suitable userland interface? Should it be documetned?

It could be used by sysfs interface and string parsing, and I added some 
examples ahead of id and loop attributes, but for the patterns yes, it should 
be. As I have already added some comment before for the first comment from 
Dmitry, now the upload effect covers this attributes, so I would like to remove 
them and I have added some code a little bit more in the upload effect function 
in the next patch.

Thanks for your comments.

> 
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) 
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Kind regards
Roy


RE: [PATCH v18 3/3] Input: new da7280 haptic driver

2020-07-31 Thread Roy Im


On Thu, July 30, 2020 2:10 PM, Dmitry Torokhov
> On Wed, Jul 29, 2020 at 02:09:48PM +0000, Roy Im wrote:
> > Wednesday, July 29, 2020 3:37 PM, Dmitry Torokhov wrote:
> > > On Wed, Jul 29, 2020 at 11:59:40AM +0900, Roy Im wrote:
> > > > v11:
> > > > - Updated the pwm related code, comments and typo.
> > > > v10:
> > > > - Updated the pwm related function and added some comments.
> > > > v9:
> > > > - Removed the header file and put the definitions into the c 
> > > > file.
> > > > - Updated the pwm code and error logs with %pE
> > >
> > > I believe the %pE is to format an escaped buffer, you probably want
> > > to %pe (lowercase) to print errors. I am also not quite sure if we want 
> > > to use it in cases when we have non-pointer error, or
> we should stick with %d as most of the kernel does.
> >
> > Right, it should be %pe as you and Uwe said, Uwe suggested %pe to 
> > understand easier.. do you still prefer to stick with %d?
> 
> Depends on the situation. If you already have ERR_PTR-encoded error there is 
> no reason for not using %pe, but if you have
> integer error, or you have already converted pointer to integer I'd prefer we 
> stick with %d.
> 
> As I mentioned in another message maybe we should consider adding '%de'
> or similar for formatting integer errors.

I have seen the discussion messages in another email, then I am not still quite 
sure what could be good for now.
Do you still prefer to be with %d if I have already converted pointer to 
integer and with %pe for something that I already have ERR_PTR-encoded error?

Kind regards,
Roy


RE: [PATCH v18 3/3] Input: new da7280 haptic driver

2020-07-29 Thread Roy Im
Hello Dmitry and Uwe,

Wednesday, July 29, 2020 3:37 PM, Dmitry Torokhov wrote: 

> On Wed, Jul 29, 2020 at 11:59:40AM +0900, Roy Im wrote:
> > Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with multiple
> > mode and integrated waveform memory and wideband support.
> > It communicates via an I2C bus to the device.
> 
> A few questions/suggestions...
> 
> >
> > Reviewed-by: Jes Sorensen .
> >
> > Signed-off-by: Roy Im 
> >
> > ---
> > v18:
> > - Corrected comments in Kconfig
> > - Updated to preferred style for multi line comments in c file.
> > v17:
> > - fixed an issue.
> > v16:
> > - Corrected some code and updated description in Kconfig.
> > v15:
> > - Removed some defines and updated some comments.
> > v14:
> > - Updated pwm related code, alignments and comments.
> > v13:
> > - Updated some conditions in pwm function and alignments.
> > v12: No changes.
> > v11:
> > - Updated the pwm related code, comments and typo.
> > v10:
> > - Updated the pwm related function and added some comments.
> > v9:
> > - Removed the header file and put the definitions into the c file.
> > - Updated the pwm code and error logs with %pE
> 
> I believe the %pE is to format an escaped buffer, you probably want to %pe 
> (lowercase) to print errors. I am also not quite sure
> if we want to use it in cases when we have non-pointer error, or we should 
> stick with %d as most of the kernel does.

Right, it should be %pe as you and Uwe said, Uwe suggested %pe to understand 
easier.. do you still prefer to stick with %d?

> 
> ...
> > +
> > +/* DA7280_ACTUATOR3 (Address 0x0e) */
> > +#define DA7280_IMAX_MASK   (31 << 0)
> 
> We have GENMASK(h,l) macro in include/linux/bits.h that could be used here 
> and in other mask definitions.

I will do.

> 
> > +
> > +   bool legacy;
> > +   struct delayed_work work_duration;
> > +   struct work_struct work_playback;
> > +   struct work_struct work_setgain;
> 
> How do we ensure that all these works do not clash with each other?
> As far as I can see we could have the "duration" work executing 
> simultaneously with playback...

You are right, I will use use cancel_delayed_work_sync()/duration and 
cancel_work_sync()/playback before scheduling playback work. And same as for 
the work_setgain. For setgain, there is no problem to run this regardless the 
playback.

> 
> > +static int da7280_haptics_playback(struct input_dev *dev,
> > +  int effect_id, int val)
> > +{
> > +   struct da7280_haptic *haptics = input_get_drvdata(dev);
> > +
> > +   if (!haptics->op_mode) {
> > +   dev_warn(haptics->dev,
> > +"Any effects are not uploaded yet\n");
> 
> "No effects have been uploaded"?

Ok, let me update so.

> 
> > +   return -EPERM;
> 
> I'd say EINVAL.

OK

> 
> > +static DEVICE_ATTR_RW(ps_seq_id);
> > +static DEVICE_ATTR_RW(ps_seq_loop);
> > +static DEVICE_ATTR_RW(gpi_seq_id0);
> > +static DEVICE_ATTR_RW(gpi_seq_id1);
> > +static DEVICE_ATTR_RW(gpi_seq_id2);
> > +static DEVICE_ATTR_WO(patterns);
> 
> Should this be a binary attribute instead of having string parsing in the 
> kernel?

I have carefully reviewed my driver again with your comments, now the upload 
effect covers this attributes, so I would like to remove them and add some code 
more for gpi_seq_idx update.

Thanks for your comments.

Kinds regards,
Roy


[PATCH v18 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-07-28 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index f0569cf..6d76a80 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5003,6 +5003,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5013,6 +5014,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for PATCH v18



[PATCH v18 3/3] Input: new da7280 haptic driver

2020-07-28 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Reviewed-by: Jes Sorensen .

Signed-off-by: Roy Im 

---
v18:
- Corrected comments in Kconfig
- Updated to preferred style for multi line comments in c file.
v17:
- fixed an issue.
v16:
- Corrected some code and updated description in Kconfig.
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1845 +++
 3 files changed, 1858 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..d38b466 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,16 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by PWM or GPIO
+ with I2C communication.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..ecc8428
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1845 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#define DA7280_MEM_CTL2   0x2D
+#define DA7280_TOP_CFG5   0x6E
+#define DA7280_IRQ_MASK2  0x83
+#define DA7280_SNP_MEM_99 0xE7
+

[PATCH v18 2/3] dt-bindings: input: Add document bindings for DA7280

2020-07-28 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v18: No changes.
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg

[PATCH v18 0/3] da7280: haptic driver submission

2020-07-28 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v18 1/3] MAINTAINERS file update for DA7280
[PATCH v18 2/3] DA7280 DT Binding
[PATCH v18 3/3] DA7280 Driver

This patch applies against linux-next and v5.8-rc7

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1845 
 5 files changed, 1969 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for PATCH v18



RE: [PATCH V17 3/3] Input: new da7280 haptic driver

2020-07-23 Thread Roy Im
Friday, July 24, 2020 11:57 AM, Randy Dunlap wrote 
> On 7/23/20 6:54 PM, Roy Im wrote:
> > On Fri, July 24, 2020 5:51 AM, Randy Dunlap wrote
> >> On 7/23/20 8:01 AM, Roy Im wrote:
> >>> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> >>> index 362e8a0..06dc5a3 100644
> >>> --- a/drivers/input/misc/Kconfig
> >>> +++ b/drivers/input/misc/Kconfig
> >>> @@ -869,4 +869,17 @@ config INPUT_STPMIC1_ONKEY
> >>> To compile this driver as a module, choose M here: the
> >>> module will be called stpmic1_onkey.
> >>>
> >>> +config INPUT_DA7280_HAPTICS
> >>> + tristate "Dialog Semiconductor DA7280 haptics support"
> >>> + depends on INPUT && I2C
> >>> + select INPUT_FF_MEMLESS
> >>> + select REGMAP_I2C
> >>> + help
> >>> +   Say Y to enable support for the Dialog DA7280 haptics driver.
> >>> +   The haptics can be controlled by I2C communication,
> >>> +   or by PWM input, or by GPI.
> >>
> >>  Is thatGPIO.
> >> ?
> > The Haptics can be working by GPI(if see from the haptic device), but from 
> > the Host it is GPO. Do you think the GPIO is
> correct?
> 
> To me it needs to represent what services/interfaces/facilities are used by 
> this driver that are provided by the Linux kernel.
> If it uses Linux GPIO services, then it should say GPIO -- although I don't 
> see it using any Linux GPIO services.

OK, let me change to GPIO.

> 
> >>
> >> Can the haptics be controlled only by PWM or only by GPI(O)?
> >>
> >> Just curious: why is I2C required to build the driver if a user is only 
> >> controlling the device by PWM or GPI?
> >
> > I2C is required to control registers and it can be triggered by I2C or PWM 
> > or GPI(controlled by host outside this driver),
> so PWM and GPI are optional.
> > With your comments, I think it's better to remove below lines(//remove) to 
> > avoid confusion and add PWM as below if
> you agree.
> >  // remove
> >   The haptics can be controlled by I2C communication,
> >   or by PWM input, or by GPI.
> >  // update, adding || PWM
> >  depends on (INPUT && I2C) || PWM
> 
> Since  provides stubs for when CONFIG_PWM is not enabled, it 
> appears that "depends on  PWM" is not
> required.
> 
> I'll leave it up to you. I was just trying to understand better.
> It may be that no changes are needed.

OK, thanks for your comments. To be clearer, I would like to update as below if 
you agree

depends on INPUT && I2C
...
The haptics can be controlled by PWM or GPIO
with I2C communication.
> 
> 
> thanks.
> --
> ~Randy

Kind regards,
Roy


RE: [PATCH V17 3/3] Input: new da7280 haptic driver

2020-07-23 Thread Roy Im
On Fri July 24, 2020 5:55 AM, Randy Dunlap wrote: 
> On 7/23/20 8:01 AM, Roy Im wrote:
> > Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with multiple
> > mode and integrated waveform memory and wideband support.
> > It communicates via an I2C bus to the device.
> >
> > Reviewed-by: Jes Sorensen .
> >
> > Signed-off-by: Roy Im 
> >
> > ---
> >
> >
> >  drivers/input/misc/Kconfig  |   13 +
> >  drivers/input/misc/Makefile |1 +
> >  drivers/input/misc/da7280.c | 1840
> > +++
> >  3 files changed, 1854 insertions(+)
> >  create mode 100644 drivers/input/misc/da7280.c
> >
> 
> > diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
> > new file mode 100644 index 000..6e3ead5
> > --- /dev/null
> > +++ b/drivers/input/misc/da7280.c
> > @@ -0,0 +1,1840 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * DA7280 Haptic device driver
> > + *
> > + * Copyright (c) 2020 Dialog Semiconductor.
> > + * Author: Roy Im   */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> 
> ...
> 
> 
> > +static int da7280_haptic_set_pwm(struct da7280_haptic *haptics, bool
> > +enabled) {
> > +   struct pwm_state state;
> > +   u64 period_mag_multi;
> > +   int error;
> > +
> > +   if (!haptics->gain && enabled) {
> > +   dev_err(haptics->dev,
> > +   "Please set the gain first for the pwm mode\n");
> > +   return -EINVAL;
> > +   }
> > +
> > +   pwm_get_state(haptics->pwm_dev, &state);
> > +   state.enabled = enabled;
> > +   if (enabled) {
> > +   period_mag_multi = (u64)state.period * haptics->gain;
> > +   period_mag_multi >>= MAX_MAGNITUDE_SHIFT;
> > +
> > +   /* The interpretation of duty cycle depends on the acc_en,
> > +* it should be between 50% and 100% for acc_en = 0.
> > +* See datasheet 'PWM mode' section.
> > +*/
> 
> from coding-style.rst:
> 
>   /*
>* This is the preferred style for multi-line
>* comments in the Linux kernel source code.
>* Please use it consistently.
>*
>* Description:  A column of asterisks on the left side,
>* with beginning and ending almost-blank lines.
>*/
> 
> (except for networking code)
> 
> Please fix multiple locations.
OK, I will fix them.

> 
> 
> thanks.
> --
> ~Randy

Kind regards,
Roy


RE: [PATCH V17 3/3] Input: new da7280 haptic driver

2020-07-23 Thread Roy Im
On Fri, July 24, 2020 5:51 AM, Randy Dunlap wrote
> On 7/23/20 8:01 AM, Roy Im wrote:
> > diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> > index 362e8a0..06dc5a3 100644
> > --- a/drivers/input/misc/Kconfig
> > +++ b/drivers/input/misc/Kconfig
> > @@ -869,4 +869,17 @@ config INPUT_STPMIC1_ONKEY
> >   To compile this driver as a module, choose M here: the
> >   module will be called stpmic1_onkey.
> >
> > +config INPUT_DA7280_HAPTICS
> > +   tristate "Dialog Semiconductor DA7280 haptics support"
> > +   depends on INPUT && I2C
> > +   select INPUT_FF_MEMLESS
> > +   select REGMAP_I2C
> > +   help
> > + Say Y to enable support for the Dialog DA7280 haptics driver.
> > + The haptics can be controlled by I2C communication,
> > + or by PWM input, or by GPI.
> 
> Is thatGPIO.
> ?
The Haptics can be working by GPI(if see from the haptic device), but from the 
Host it is GPO. Do you think the GPIO is correct?

> 
> Can the haptics be controlled only by PWM or only by GPI(O)?
> 
> Just curious: why is I2C required to build the driver if a user is only 
> controlling the device by PWM or GPI?

I2C is required to control registers and it can be triggered by I2C or PWM or 
GPI(controlled by host outside this driver), so PWM and GPI are optional.
With your comments, I think it's better to remove below lines(//remove) to 
avoid confusion and add PWM as below if you agree.
 // remove
  The haptics can be controlled by I2C communication,
  or by PWM input, or by GPI.
 // update, adding || PWM
 depends on (INPUT && I2C) || PWM
> 
> 
> > +
> > + To compile this driver as a module, choose M here: the
> > + module will be called da7280.
> > +
> >  endif
> 
> thanks.
> --
> ~Randy

Kind regards,
Roy


[PATCH v17 2/3] dt-bindings: input: Add document bindings for DA7280

2020-07-23 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg

[PATCH V17 3/3] Input: new da7280 haptic driver

2020-07-23 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Reviewed-by: Jes Sorensen .

Signed-off-by: Roy Im 

---
v17:
- fixed an issue.
v16:
- Corrected some code and updated description in Kconfig.
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1840 +++
 3 files changed, 1854 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..06dc5a3 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,17 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by I2C communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..6e3ead5
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1840 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#define DA7280_MEM_CTL2   0x2D
+#define DA7280_TOP_CFG5   0x6E
+#define DA7280_IRQ_MASK2  0x83
+#define DA7280_SNP_MEM_99 0xE7
+
+/* Register field */
+
+/* DA7280_IRQ_EVENT1 (Address 0x03) */
+#define DA7280_E

[PATCH v17 0/3] da7280: haptic driver submission

2020-07-23 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v17 1/3] MAINTAINERS file update for DA7280
[PATCH v17 2/3] DA7280 DT Binding
[PATCH v17 3/3] DA7280 Driver

This patch applies against linux-next and v5.8-rc6

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1840 
 5 files changed, 1965 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for PATCH v17



[PATCH v17 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-07-23 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v17: No changes.
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index d53db30..8e6f364 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5003,6 +5003,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5013,6 +5014,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for PATCH v17



RE: [PATCH v16 3/3] Input: new da7280 haptic driver

2020-07-22 Thread Roy Im
On Thursday, July 23, 2020 12:24 AM, Jes Sorensen wrote:
> On 7/9/20 3:27 AM, Roy Im wrote:
> > Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with multiple
> > mode and integrated waveform memory and wideband support.
> > It communicates via an I2C bus to the device.
> >
> > Signed-off-by: Roy Im 
> > ---
> > v16:
> > - Corrected some code and updated description in Kconfig.
> > v15:
> > - Removed some defines and updated some comments.
> > v14:
> > - Updated pwm related code, alignments and comments.
> > v13:
> > - Updated some conditions in pwm function and alignments.
> > v12: No changes.
> > v11:
> > - Updated the pwm related code, comments and typo.
> > v10:
> > - Updated the pwm related function and added some comments.
> > v9:
> > - Removed the header file and put the definitions into the c file.
> > - Updated the pwm code and error logs with %pE
> > v8:
> > - Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
> > - Updated the dt-related code.
> > - Removed memless related functions.
> > v7:
> > - Added more attributes to handle one value per file.
> > - Replaced and updated the dt-related code and functions called.
> > - Fixed error/functions.
> > v6: No changes.
> > v5: Fixed errors in Kconfig file.
> > v4: Updated code as dt-bindings are changed.
> > v3: No changes.
> > v2: Fixed kbuild error/warning
> >
> >
> >  drivers/input/misc/Kconfig  |   13 +
> >  drivers/input/misc/Makefile |1 +
> >  drivers/input/misc/da7280.c | 1840
> > +++
> >  3 files changed, 1854 insertions(+)
> >  create mode 100644 drivers/input/misc/da7280.c
> 
> Hi Roy,
> 
> Overall the driver looks pretty good now. I did find one issue, see below. If 
> you fix that I am happy to add a Reviewed-by line.
> 
> Reviewed-By: Jes Sorensen 

Thanks a lot and I will fix as you advised below, then I will add a 
Reviewed-line in the next patch.

> 
> > diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
> > new file mode 100644 index 000..c8c42ac
> > --- /dev/null
> > +++ b/drivers/input/misc/da7280.c
> 
> [snip]
> 
> > +static int da7280_haptic_set_pwm(struct da7280_haptic *haptics, bool 
> > enabled)
> > +{
> > +   struct pwm_state state;
> > +   u64 period_mag_multi;
> > +   int error;
> > +
> > +   if (!haptics->gain && enabled) {
> > +   dev_err(haptics->dev,
> > +   "Please set the gain first for the pwm mode\n");
> > +   return -EINVAL;
> > +   }
> > +
> > +   pwm_get_state(haptics->pwm_dev, &state);
> > +   state.enabled = enabled;
> > +   if (enabled) {
> > +   period_mag_multi = state.period * haptics->gain;
> 
> You are multiplying an unsigned int to a u16 and storing it in a u64.
> However, C doesn't promote the types, so you'll end up with an
> unexpected result here. You can fix it by promoting state.period to u64, ie:
> 
>   period_mage_multi = (u64)state.period * haptics->gain;
> 
> See the following example code which demonstrates the problem.
> 
> #include 
> #include 
> 
> uint64_t foo(unsigned int a, uint16_t b)
> {
>   uint64_t tmp = a * b;
>   return tmp;
> }
> 
> uint64_t bar(unsigned int a, uint16_t b)
> {
>   uint64_t tmp = (uint64_t)a * b;
>   return tmp;
> }
> 
> int main()
> {
>   uint64_t val;
>   unsigned int a = 0xff00ff00;
>   uint16_t b = 0x200;
> 
>   val = foo(a, b);
>   printf("result(%0x, %0x) = %0llx\n", a, b, val);
> 
>   val = bar(a, b);
>   printf("result(%0x, %0x) = %0llx\n", a, b, val);
> }
> 
> Cheers,
> Jes

Yes, you are right, I see the different result, I will fix this.

Kind regards,
Roy



[PATCH v16 0/3] da7280: haptic driver submission

2020-07-09 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v16 1/3] MAINTAINERS file update for DA7280
[PATCH v16 2/3] DA7280 DT Binding
[PATCH v16 3/3] DA7280 Driver

This patch applies against linux-next and v5.8-rc4

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1840 
 5 files changed, 1965 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for PATCH v16



[PATCH v16 3/3] Input: new da7280 haptic driver

2020-07-09 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Signed-off-by: Roy Im 

---
v16:
- Corrected some code and updated description in Kconfig.
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1840 +++
 3 files changed, 1854 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..06dc5a3 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,17 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by I2C communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..c8c42ac
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1840 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#define DA7280_MEM_CTL2   0x2D
+#define DA7280_TOP_CFG5   0x6E
+#define DA7280_IRQ_MASK2  0x83
+#define DA7280_SNP_MEM_99 0xE7
+
+/* Register field */
+
+/* DA7280_IRQ_EVENT1 (Address 0x03) */
+#define DA7280_E_SEQ_CONTINUE_MASK BIT(0)
+#define 

[PATCH v16 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-07-09 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 1d4aa7f..2aa7348 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5002,6 +5002,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5012,6 +5013,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for PATCH v16



[PATCH v16 2/3] dt-bindings: input: Add document bindings for DA7280

2020-07-09 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v16: No changes.
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>

RE: [PATCH v15 3/3] Input: new da7280 haptic driver

2020-07-02 Thread Roy Im

On Fri, July 3, 2020 3:02 AM, Jes Sorensen wrote:
> On 6/29/20 9:01 AM, Roy Im wrote:
> > Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with multiple
> > mode and integrated waveform memory and wideband support.
> > It communicates via an I2C bus to the device.
> >
> > Signed-off-by: Roy Im 
> > ---
> > v15:
> > - Removed some defines and updated some comments.
> > v14:
> > - Updated pwm related code, alignments and comments.
> > v13:
> > - Updated some conditions in pwm function and alignments.
> > v12: No changes.
> > v11:
> > - Updated the pwm related code, comments and typo.
> > v10:
> > - Updated the pwm related function and added some comments.
> > v9:
> > - Removed the header file and put the definitions into the c file.
> > - Updated the pwm code and error logs with %pE
> > v8:
> > - Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
> > - Updated the dt-related code.
> > - Removed memless related functions.
> > v7:
> > - Added more attributes to handle one value per file.
> > - Replaced and updated the dt-related code and functions called.
> > - Fixed error/functions.
> > v6: No changes.
> > v5: Fixed errors in Kconfig file.
> > v4: Updated code as dt-bindings are changed.
> > v3: No changes.
> > v2: Fixed kbuild error/warning
> >
> >
> >  drivers/input/misc/Kconfig  |   13 +
> >  drivers/input/misc/Makefile |1 +
> >  drivers/input/misc/da7280.c | 1838
> > +++
> >  3 files changed, 1852 insertions(+)
> >  create mode 100644 drivers/input/misc/da7280.c
> 
> [snip]
> 
> > +static ssize_t
> > +patterns_store(struct device *dev,
> > +  struct device_attribute *attr,
> > +  const char *buf,
> > +  size_t count)
> > +{
> > +   struct da7280_haptic *haptics = dev_get_drvdata(dev);
> > +   char cmd[MAX_USER_INPUT_LEN];
> > +   struct parse_data_t mem;
> > +   unsigned int val;
> > +   int error;
> > +
> > +   error = regmap_read(haptics->regmap, DA7280_MEM_CTL1, &val);
> > +   if (error)
> > +   return error;
> > +
> > +   if (count > MAX_USER_INPUT_LEN)
> > +   memcpy(cmd, buf, MAX_USER_INPUT_LEN);
> > +   else
> > +   memcpy(cmd, buf, count);
> > +
> > +   /* chop of '\n' introduced by echo at the end of the input */
> > +   if (cmd[count - 1] == '\n')
> > +   cmd[count - 1] = '\0';
> 
> You have a potential memory corruption bug here for the case where  count > 
> MAX_USER_INPUT_LEN. The code
> correctly clamps the memcpy() length, but it still is at risk of writing 
> beyond the end of the cmd buffer when doing the \0
> termination.
> 
> If you change the code above to say
> 
>   if (count > MAX_USER_INPUT_LEN)
>   count = MAX_USER_INPUT_LEN
>   memcpy(cmd, buf, count);
> 
> it should take care of it, and it will also return the actual count written 
> to the caller.

You are right and thanks for your comment, I will change the code as you 
suggested.

Kind regards,
Roy


RE: [PATCH v15 3/3] Input: new da7280 haptic driver

2020-06-29 Thread Roy Im
On Tue, June 30, 2020 12:14 PM, Randy Dunlap wrote: 
> On 6/29/20 6:01 AM, Roy Im wrote:
> > diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> > index 362e8a0..79fbddb 100644
> > --- a/drivers/input/misc/Kconfig
> > +++ b/drivers/input/misc/Kconfig
> > @@ -869,4 +869,17 @@ config INPUT_STPMIC1_ONKEY
> >   To compile this driver as a module, choose M here: the
> >   module will be called stpmic1_onkey.
> >
> > +config INPUT_DA7280_HAPTICS
> > +   tristate "Dialog Semiconductor DA7280 haptics support"
> > +   depends on INPUT && I2C
> > +   select INPUT_FF_MEMLESS
> > +   select REGMAP_I2C
> > +   help
> > + Say Y to enable support for the Dialog DA7280 haptics driver.
> > + The haptics can be controlled by i2c communication,
> 
> If you make any more updates, make this:   I2C communication,
> please.

OK, I will do. Thanks for your comment.

> 
> > + or by PWM input, or by GPI.
> > +
> > + To compile this driver as a module, choose M here: the
> > + module will be called da7280.
> > +
> >  endif
> 
> thanks.
> --
> ~Randy



[PATCH v15 3/3] Input: new da7280 haptic driver

2020-06-29 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Signed-off-by: Roy Im 

---
v15:
- Removed some defines and updated some comments.
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1838 +++
 3 files changed, 1852 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..79fbddb 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,17 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by i2c communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..c1414f9
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1838 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#define DA7280_MEM_CTL2   0x2D
+#define DA7280_TOP_CFG5   0x6E
+#define DA7280_IRQ_MASK2  0x83
+#define DA7280_SNP_MEM_99 0xE7
+
+/* Register field */
+
+/* DA7280_IRQ_EVENT1 (Address 0x03) */
+#define DA7280_E_SEQ_CONTINUE_MASK BIT(0)
+#define DA7280_E_UVLO_MASK BIT(1)
+#define DA7280_E_SEQ_DONE_MASK

[PATCH v15 2/3] dt-bindings: input: Add document bindings for DA7280

2020-06-29 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v15: No changes.
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>

[PATCH v15 0/3] da7280: haptic driver submission

2020-06-29 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v15 1/3] MAINTAINERS file update for DA7280
[PATCH v15 2/3] DA7280 DT Binding
[PATCH v15 3/3] DA7280 Driver

This patch applies against linux-next and v5.8-rc3

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1838 
 5 files changed, 1963 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for PATCH v15



[PATCH v15 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-06-29 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v15: No changes.
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 496fd4e..9a45a7b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5002,6 +5002,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5012,6 +5013,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for PATCH v15



RE: [PATCH v14 3/3] Input: new da7280 haptic driver

2020-06-28 Thread Roy Im
On Sat, June 27, 2020 12:56 AM, Uwe Kleine-König wrote:
> On Fri, Jun 26, 2020 at 01:17:29PM +0000, Roy Im wrote:
> > > On Fri, June 26, 2020 3:19 PM, Uwe Kleine-König wrote:
> > > Hello,
> > > from the PWM POV I'm happy now. Just a few minor comments that I noticed 
> > > while checking the PWM details.
> >
> > Many thanks for your comments.
> >
> > >
> > > On Thu, Jun 25, 2020 at 01:59:29AM +0900, Roy Im wrote:
> > > > +   val = haptics->ps_seq_id << DA7280_PS_SEQ_ID_SHIFT |
> > > > +   haptics->ps_seq_loop << 
> > > > DA7280_PS_SEQ_LOOP_SHIFT;
> > >
> > > If you write this as:
> > >
> > >   val = FIELD_PREP(DA7280_PS_SEQ_ID_MASK, haptics->ps_seq_id) |
> > >   FIELD_PREP(DA7280_PS_SEQ_LOOP_MASK, haptics->ps_seq_loop);
> > >
> > > you get some additional checks for free and can drop all defines for 
> > > ..._SHIFT .
> >
> > It is not difficult to update that as you advise, but I think having
> > the shift there explicitly makes it more readable, so most of the
> > drivers from my team have the defines(shift) up to now. I guess this
> > is a kind of subjective thing.
> > Do you think it is still necessary? Then I will update as you said.
> 
> No, from my side it's not a hard requirement (and after all I'm not the one 
> who will take your commit). I personally like it better
> with FIELD_PREP, but I can still sleep if you don't agree :-)
> 
> What I don't like about having both ..._SHIFT and ..._MASK is that there is 
> some duplication as ..._SHIFT can be calculated
> from ..._MASK:
> 
>   #define LALA_SHIFT (ffs(LALA_MASK) - 1)

OK, I got it and I will update.

> 
> Best regards
> Uwe
> 
> --
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | https://www.pengutronix.de/ |


RE: [PATCH v14 3/3] Input: new da7280 haptic driver

2020-06-26 Thread Roy Im
> On Fri, June 26, 2020 3:19 PM, Uwe Kleine-König wrote:
> Hello,
> from the PWM POV I'm happy now. Just a few minor comments that I noticed 
> while checking the PWM details.

Many thanks for your comments.

> 
> On Thu, Jun 25, 2020 at 01:59:29AM +0900, Roy Im wrote:
> > +   val = haptics->ps_seq_id << DA7280_PS_SEQ_ID_SHIFT |
> > +   haptics->ps_seq_loop << DA7280_PS_SEQ_LOOP_SHIFT;
> 
> If you write this as:
> 
>   val = FIELD_PREP(DA7280_PS_SEQ_ID_MASK, haptics->ps_seq_id) |
>   FIELD_PREP(DA7280_PS_SEQ_LOOP_MASK, haptics->ps_seq_loop);
> 
> you get some additional checks for free and can drop all defines for 
> ..._SHIFT .

It is not difficult to update that as you advise, but I think having the shift 
there explicitly makes it more readable, so most of the drivers from my team 
have the defines(shift) up to now. I guess this is a kind of subjective thing. 
Do you think it is still necessary? Then I will update as you said.

> 
> > +static u8 da7280_haptic_of_gpi_pol_str(struct device *dev,
> > +  const char *str)
> > +{
> > +   if (!strcmp(str, "Rising-edge"))
> > +   return 0;
> > +   else if (!strcmp(str, "Falling-edge"))
> > +   return 1;
> > +   else if (!strcmp(str, "Both-edge"))
> > +   return 2;
> > +
> > +   dev_warn(dev, "Invalid string - set to default\n");
> 
> Maybe mention "Rising-edge" being the default?

OK, I will change them to be clear.

> 
> > +   return 0;
> > +}
> 
> Best regards
> Uwe
> 
> --
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | https://www.pengutronix.de/ |


[PATCH v14 3/3] Input: new da7280 haptic driver

2020-06-25 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Signed-off-by: Roy Im 

---
v14:
- Updated pwm related code, alignments and comments.
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1880 +++
 3 files changed, 1894 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 362e8a0..79fbddb 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -869,4 +869,17 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by i2c communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a48e5f2..9cfd6ab 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..39bc3c4
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1880 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#define DA7280_MEM_CTL2   0x2D
+#define DA7280_TOP_CFG5   0x6E
+#define DA7280_IRQ_MASK2  0x83
+#define DA7280_SNP_MEM_99 0xE7
+
+/* Register field */
+
+/* DA7280_IRQ_EVENT1 (Address 0x03) */
+#define DA7280_E_SEQ_CONTINUE_SHIFT0
+#define DA7280_E_SEQ_CONTINUE_MASK BIT(0)
+#define DA7280_E_UVLO_SHIFT1
+#define DA7280_E_UVLO_MASK  

[PATCH v14 0/3] da7280: haptic driver submission

2020-06-25 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH v14 1/3] MAINTAINERS file update for DA7280
[PATCH v14 2/3] DA7280 DT Binding
[PATCH v14 3/3] DA7280 Driver

This patch applies against linux-next and v5.8-rc2

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1880 
 5 files changed, 2005 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for PATCH v14



[PATCH v14 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-06-25 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v14: No changes.
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7b5ffd6..26fdec0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5002,6 +5002,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -5012,6 +5013,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for PATCH v14



[PATCH v14 2/3] dt-bindings: input: Add document bindings for DA7280

2020-06-25 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v14: No changes.
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>;
+   dlg,resonant-freq-h

RE: [RESEND PATCH V13 3/3] Input: new da7280 haptic driver

2020-06-24 Thread Roy Im
On Thu, June 25, 2020 1:28 AM, Uwe Kleine-König
> On Wed, Jun 24, 2020 at 03:39:52PM +0000, Roy Im wrote:
> > On Wed, Jun 24, 2020 at 10:37 PM, Uwe Kleine-König wrote:
> > > On Wed, Jun 24, 2020 at 12:04:24PM +0900, Roy Im wrote:
> > > > period2freq = 100 / state.period;
> > > > if (period2freq < DA7280_MIN_PWM_FREQ_KHZ ||
> > > > period2freq > DA7280_MAX_PWM_FREQ_KHZ) {
> > > > dev_err(dev, "Unsupported PWM frequency (%u)\n",
> > > > period2freq);
> > > > return -EINVAL;
> > > > }
> > > > If you look ok, let me update this so.
> > >
> > > looks fine.
> > >
> > > Note that you don't need the division if you check for:
> > >
> > >   if (state.period > 10 || state.period < 4000) {
> > >   ...
> > >
> > > (maybe the compiler is already clever enough to get rid of the division 
> > > for you, but then the check is:
> > >
> > >   if (state.period > 10 || state.period < 3985) {
> > >
> > > because of rounding errors.)
> >
> > OK, you are right, that will be better. So let me change that as below
> > if you look fine.
> 
> I look fine, the code however is wrong. :-)
> 
> > /* Check PWM period, PWM freq = 100 / state.period.
> >  * The valid PWM freq range: 10k ~ 250kHz.
> >  */
> > if (state.period > 10 || state.period < 3985) {
> 
> You want 4000 here -, don't you?

Yes, it is now based on period, not frequency. You are right.
4000 is correct now. Thanks.

> 
> > dev_err(dev, "Unsupported PWM period (%u)\n",
> > state.period);
> > return -EINVAL;
> > }
> 
> Best regards
> Uwe
> 
> --
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | https://www.pengutronix.de/ |


RE: [RESEND PATCH V13 3/3] Input: new da7280 haptic driver

2020-06-24 Thread Roy Im
On Wed, Jun 24, 2020 at 10:37 PM, Uwe Kleine-König wrote:
> On Wed, Jun 24, 2020 at 12:04:24PM +0900, Roy Im wrote:
> > Hello Uwe,
> >
> > On Tue, June 23, 2020 11:41 PM, Uwe Kleine-König wrote:
> > >
> > > Hello,
> > >
> > > On Mon, Jun 15, 2020 at 08:40:23PM +0900, Roy Im wrote:
> > > > Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
> > > > multiple mode and integrated waveform memory and wideband support.
> > > > It communicates via an I2C bus to the device.
> > > >
> > > > Signed-off-by: Roy Im 
> > > >
> > > > +   period2freq = 100 / state.period;
> > > > +   if (period2freq < DA7280_MIN_PWM_FREQ_KHZ ||
> > > > +   period2freq > DA7280_MAX_PWM_FREQ_KHZ) {
> > > > +   dev_err(dev, "Not supported PWM 
> > > > frequency(%d)\n",
> > > > +   period2freq);
> > >
> > > Doesn't the compiler warn here about period2freq being unsigned and %d 
> > > being for signed int values?
> > >
> > > For my (non-native) English ear s/Not supported/Unsupported/ sounds
> > > better. Also my eyes would be pleases by a space before the opening brace.
> >
> > I didn't see any warning message, but I will change/improve them to proper 
> > one and the log as below.
> >
> > period2freq = 100 / state.period;
> > if (period2freq < DA7280_MIN_PWM_FREQ_KHZ ||
> > period2freq > DA7280_MAX_PWM_FREQ_KHZ) {
> > dev_err(dev, "Unsupported PWM frequency (%u)\n",
> > period2freq);
> > return -EINVAL;
> > }
> > If you look ok, let me update this so.
> 
> looks fine.
> 
> Note that you don't need the division if you check for:
> 
>   if (state.period > 10 || state.period < 4000) {
>   ...
> 
> (maybe the compiler is already clever enough to get rid of the division for 
> you, but then the check is:
> 
>   if (state.period > 10 || state.period < 3985) {
> 
> because of rounding errors.)

OK, you are right, that will be better. So let me change that as below if you 
look fine.
/* Check PWM period, PWM freq = 100 / state.period.
 * The valid PWM freq range: 10k ~ 250kHz.
 */
if (state.period > 10 || state.period < 3985) {
dev_err(dev, "Unsupported PWM period (%u)\n",
state.period);
return -EINVAL;
}
> 
> Best regards
> Uwe
> 
> --
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | https://www.pengutronix.de/ |


RE: [RESEND PATCH V13 3/3] Input: new da7280 haptic driver

2020-06-24 Thread Roy Im
Hello Uwe,

On Tue, June 23, 2020 11:41 PM, Uwe Kleine-König wrote:
> 
> Hello,
> 
> On Mon, Jun 15, 2020 at 08:40:23PM +0900, Roy Im wrote:
> > Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with multiple
> > mode and integrated waveform memory and wideband support.
> > It communicates via an I2C bus to the device.
> >
> > Signed-off-by: Roy Im 
> 
> Just some picky comments below.
> 
> > +   error = pwm_apply_state(haptics->pwm_dev, &state);
> > +   if (error)
> > +   dev_err(haptics->dev,
> > +   "failed to apply pwm state: %pE\n",
> > +   ERR_PTR(error));
> 
> You can save some horizontal space here by dropping the \n after the first 
> comma. (There are a few more occurences.)
> 
Ok, is this what you want?
error = pwm_apply_state(haptics->pwm_dev, &state);
if (error)
dev_err(haptics->dev, "failed to apply pwm state: %pE\n",
ERR_PTR(error));

> > +   return error;
> > +}
> > +[...]
> > +
> > +   /* Sync up PWM state and ensure it is off. */
> > +   pwm_init_state(haptics->pwm_dev, &state);
> > +   state.enabled = false;
> > +   error = pwm_apply_state(haptics->pwm_dev, &state);
> > +   if (error) {
> > +   dev_err(dev,
> > +   "failed to apply initial PWM state: %pE\n",
> > +   ERR_PTR(error));
> > +   return error;
> > +   }
> > +
> > +   /* Check PWM Period, it must be in 10k ~ 250kHz */
> 
> The unit of a PWM period is in (nano)seconds, to it cannot be in the range 
> [10kHz, 250kHz]. (Is this too picky?)

No, it isn't. The 'Period' should be changed to 'frequency', I will fix this as 
below.

/* Check PWM frequency, valid range: 10k ~ 250kHz */

> 
> > +   period2freq = 100 / state.period;
> > +   if (period2freq < DA7280_MIN_PWM_FREQ_KHZ ||
> > +   period2freq > DA7280_MAX_PWM_FREQ_KHZ) {
> > +   dev_err(dev, "Not supported PWM frequency(%d)\n",
> > +   period2freq);
> 
> Doesn't the compiler warn here about period2freq being unsigned and %d being 
> for signed int values?
> 
> For my (non-native) English ear s/Not supported/Unsupported/ sounds better. 
> Also my eyes would be pleases by a space
> before the opening brace.

I didn't see any warning message, but I will change/improve them to proper one 
and the log as below.

period2freq = 100 / state.period;
if (period2freq < DA7280_MIN_PWM_FREQ_KHZ ||
period2freq > DA7280_MAX_PWM_FREQ_KHZ) {
dev_err(dev, "Unsupported PWM frequency (%u)\n",
period2freq);
return -EINVAL;
}
If you look ok, let me update this so.

> 
> > +   return -EINVAL;
> > +   }
> > +   }
> > +
> > +
> > +[...]
> > +static struct i2c_driver da7280_driver = {
> > +   .driver = {
> > +   .name   = "da7280",
> > +   .of_match_table = of_match_ptr(da7280_of_match),
> > +   .pm = &da7280_pm_ops,
> 
> I don't like alignment of =, but I'm aware this is a subjective thing.
> (The reason for me is that adding a new member that is longer than the 
> already existing requires touching all lines. So I
> stick to a single space before a =.)

OK, I will do as you said.

> 
> > +   },
> > +   .probe= da7280_probe,
> > +   .id_table = da7280_i2c_id,
> > +};
> > +module_i2c_driver(da7280_driver);
> > +
> > +MODULE_DESCRIPTION("DA7280 haptics driver"); MODULE_AUTHOR("Roy Im
> > +");
> > +MODULE_LICENSE("GPL");
> > --
> > end-of-patch for RESEND PATCH V13
> 
> Best regards
> Uwe
> 
> --
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | https://www.pengutronix.de/ |


[RESEND PATCH V13 2/3] dt-bindings: input: Add document bindings for DA7280

2020-06-15 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>;
+   dlg,resonant-freq-hz = <180>

[RESEND PATCH V13 3/3] Input: new da7280 haptic driver

2020-06-15 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Signed-off-by: Roy Im 

---
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1898 +++
 3 files changed, 1912 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7e2e658..e2bf442 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -879,4 +879,17 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by i2c communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 8fd187f..71dc381 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..05ec1abd3
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1898 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#define DA7280_MEM_CTL2   0x2D
+#define DA7280_TOP_CFG5   0x6E
+#define DA7280_IRQ_MASK2  0x83
+#define DA7280_SNP_MEM_99 0xE7
+
+/* Register field */
+
+/* DA7280_IRQ_EVENT1 (Address 0x03) */
+#define DA7280_E_SEQ_CONTINUE_SHIFT0
+#define DA7280_E_SEQ_CONTINUE_MASK BIT(0)
+#define DA7280_E_UVLO_SHIFT1
+#define DA7280_E_UVLO_MASK BIT(1)
+#define DA7280_E_SEQ_DONE_SHIFT2
+#define DA72

[RESEND PATCH V13 0/3] da7280: haptic driver submission

2020-06-15 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH V13 1/3] MAINTAINERS file update for DA7280
[PATCH V13 2/3] DA7280 DT Binding
[PATCH V13 3/3] DA7280 Driver

This patch applies against linux-mainline and v5.7

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1898 
 5 files changed, 2023 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for RESEND PATCH V13



[RESEND PATCH V13 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-06-15 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 50659d7..eff15f4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4938,6 +4938,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -4948,6 +4949,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for RESEND PATCH V13



[RESEND PATCH V13 2/3] dt-bindings: input: Add document bindings for DA7280

2020-05-21 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>;
+   dlg,resonant-freq-hz = <180>

[RESEND PATCH V13 3/3] Input: new da7280 haptic driver

2020-05-21 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Signed-off-by: Roy Im 

---
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1898 +++
 3 files changed, 1912 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7e2e658..e2bf442 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -879,4 +879,17 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by i2c communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 8fd187f..71dc381 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..05ec1abd3
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1898 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#define DA7280_MEM_CTL2   0x2D
+#define DA7280_TOP_CFG5   0x6E
+#define DA7280_IRQ_MASK2  0x83
+#define DA7280_SNP_MEM_99 0xE7
+
+/* Register field */
+
+/* DA7280_IRQ_EVENT1 (Address 0x03) */
+#define DA7280_E_SEQ_CONTINUE_SHIFT0
+#define DA7280_E_SEQ_CONTINUE_MASK BIT(0)
+#define DA7280_E_UVLO_SHIFT1
+#define DA7280_E_UVLO_MASK BIT(1)
+#define DA7280_E_SEQ_DONE_SHIFT2
+#define DA72

[RESEND PATCH V13 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-05-21 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2926327..56e83e9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4942,6 +4942,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -4952,6 +4953,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for RESEND PATCH V13



[RESEND PATCH V13 0/3] da7280: haptic driver submission

2020-05-21 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH V13 1/3] MAINTAINERS file update for DA7280
[PATCH V13 2/3] DA7280 DT Binding
[PATCH V13 3/3] DA7280 Driver

This patch applies against linux-next and v5.7-rc4

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1898 
 5 files changed, 2023 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for RESEND PATCH V13



[PATCH V13 0/3] da7280: haptic driver submission

2020-05-07 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH V13 1/3] MAINTAINERS file update for DA7280
[PATCH V13 2/3] DA7280 DT Binding
[PATCH V13 3/3] DA7280 Driver

This patch applies against linux-next and v5.7-rc4

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  109 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1898 
 5 files changed, 2023 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c

-- 
end-of-patch for PATCH V13



[PATCH V13 3/3] Input: new da7280 haptic driver

2020-05-07 Thread Roy Im
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Signed-off-by: Roy Im 

---
v13:
- Updated some conditions in pwm function and alignments.
v12: No changes.
v11: 
- Updated the pwm related code, comments and typo.
v10: 
- Updated the pwm related function and added some comments.
v9: 
- Removed the header file and put the definitions into the c file.
- Updated the pwm code and error logs with %pE
v8: 
- Added changes to support FF_PERIODIC/FF_CUSTOM and FF_CONSTANT.
- Updated the dt-related code.
- Removed memless related functions.
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1898 +++
 3 files changed, 1912 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7e2e658..e2bf442 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -879,4 +879,17 @@ config INPUT_STPMIC1_ONKEY
  To compile this driver as a module, choose M here: the
  module will be called stpmic1_onkey.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by i2c communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 8fd187f..71dc381 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..05ec1abd3
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1898 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2020 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers */
+#define DA7280_IRQ_EVENT1 0x03
+#define DA7280_IRQ_EVENT_WARNING_DIAG 0x04
+#define DA7280_IRQ_EVENT_SEQ_DIAG 0x05
+#define DA7280_IRQ_STATUS10x06
+#define DA7280_IRQ_MASK1  0x07
+#define DA7280_FRQ_LRA_PER_H  0x0A
+#define DA7280_FRQ_LRA_PER_L  0x0B
+#define DA7280_ACTUATOR1  0x0C
+#define DA7280_ACTUATOR2  0x0D
+#define DA7280_ACTUATOR3  0x0E
+#define DA7280_CALIB_V2I_H0x0F
+#define DA7280_CALIB_V2I_L0x10
+#define DA7280_TOP_CFG1   0x13
+#define DA7280_TOP_CFG2   0x14
+#define DA7280_TOP_CFG4   0x16
+#define DA7280_TOP_INT_CFG1   0x17
+#define DA7280_TOP_CTL1   0x22
+#define DA7280_TOP_CTL2   0x23
+#define DA7280_SEQ_CTL2   0x28
+#define DA7280_GPI_0_CTL  0x29
+#define DA7280_GPI_1_CTL  0x2A
+#define DA7280_GPI_2_CTL  0x2B
+#define DA7280_MEM_CTL1   0x2C
+#define DA7280_MEM_CTL2   0x2D
+#define DA7280_TOP_CFG5   0x6E
+#define DA7280_IRQ_MASK2  0x83
+#define DA7280_SNP_MEM_99 0xE7
+
+/* Register field */
+
+/* DA7280_IRQ_EVENT1 (Address 0x03) */
+#define DA7280_E_SEQ_CONTINUE_SHIFT0
+#define DA7280_E_SEQ_CONTINUE_MASK BIT(0)
+#define DA7280_E_UVLO_SHIFT1
+#define DA7280_E_UVLO_MASK BIT(1)
+#define DA7280_E_SEQ_DONE_SHIFT2
+#define DA72

[PATCH V13 2/3] dt-bindings: input: Add document bindings for DA7280

2020-05-07 Thread Roy Im
Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v13: No changes.
v12: No changes.
v11: No changes.
v10: No changes.
v9: No changes.
v8: Updated descriptions for new properties.
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   | 109 +
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..e6b719d
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,109 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,const-op-mode: Haptic operation mode for FF_CONSTANT.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+- dlg,periodic-op-mode: Haptic operation mode for FF_PERIODIC.
+  Possible values:
+   1 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   2 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   The default value is 1 for both of the operation modes.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,dlg,const-op-mode = <1>;
+   dlg,dlg,periodic-op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>;
+   dlg,resonant-freq-hz = <180>

[PATCH V13 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2020-05-07 Thread Roy Im
This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v13: No changes.
v12: Corrected file list order.
v11: No changes.
v10: No changes.
v9: No changes.
v8: No changes.
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2926327..56e83e9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4942,6 +4942,7 @@ M:Support Opensource 

 S: Supported
 W: http://www.dialog-semiconductor.com/products
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/regulator/slg51000.txt
@@ -4952,6 +4953,7 @@ F:Documentation/hwmon/da90??.rst
 F: drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/misc/da90??_onkey.c
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
-- 
end-of-patch for PATCH V13



RE: [RESEND PATCH V11 3/3] Input: new da7280 haptic driver

2020-05-02 Thread Roy Im
Friday, May 1, 2020 4:46 AM, Uwe Kleine-König wrote:
> On Mon, Apr 27, 2020 at 09:57:12AM +0900, Roy Im wrote:
> > +   /* It is recommended to update the patterns
> > +* during haptic is not working in order to avoid conflict
> > +*/
> 
> I thought only in net related code the comment style is like the above and in 
> all other areas the /* is on a line for itself.

OK, I will change the comment to a line.

[...]
> > +static int da7280_haptic_set_pwm(struct da7280_haptic *haptics, bool
> > +enabled) {
> > +   struct pwm_state state;
> > +   u64 period_mag_multi;
> > +   int error;
> > +
> > +   if (!haptics->gain) {
> > +   dev_err(haptics->dev,
> > +   "Please set the gain first for the pwm mode\n");
> > +   return -EINVAL;
> 
> If enabled == false haptics->gain is unused. Does it make sense to only error 
> out for enabled == true?

Yes, you are right and it make sense, I will add the condition(enabled == true) 
into that.

[...]
> > +static int da7280_probe(struct i2c_client *client,
> > +   const struct i2c_device_id *id)
> > +{
> > +   struct device *dev = &client->dev;
> > +   struct da7280_haptic *haptics;
> > +   struct input_dev *input_dev;
> > +   struct ff_device *ff;
> > +   struct pwm_state state;
> > +   unsigned int period2freq;
> 
> This variable could be local to the if body below.

Ok. That would be better. I will move it below(to Here).

> 
> > +   int error;
> > +
> > +   haptics = devm_kzalloc(dev, sizeof(*haptics), GFP_KERNEL);
> > +   if (!haptics)
> > +   return -ENOMEM;
> > +   haptics->dev = dev;
> > +
> > +   if (!client->irq) {
> > +   dev_err(dev, "No IRQ configured\n");
> > +   return -EINVAL;
> > +   }
> > +
> > +   da7280_parse_properties(dev, haptics);
> > +
> > +   if (haptics->const_op_mode == DA7280_PWM_MODE) {
unsigned int period2freq;
Here.

> > +   haptics->pwm_dev = devm_pwm_get(dev, NULL);
> > +   if (IS_ERR(haptics->pwm_dev)) {
> > [...]

> > +   error = devm_request_threaded_irq(dev, client->irq, NULL,
> > + da7280_irq_handler,
> > + IRQF_ONESHOT,
> > + "da7280-haptics", haptics);
> > +   if (error)
> > +   dev_err(dev, "Failed to request IRQ : %d\n", client->irq);
> 
> I'd say emitting the error code would be helpful here, the actual irq number 
> not so.

I will do so

> > +static struct i2c_driver da7280_driver = {
> > +   .driver = {
> > +   .name   = "da7280",
> > +   .of_match_table = of_match_ptr(da7280_of_match),
> > +   .pm = &da7280_pm_ops,
> > +   },
> > +   .probe  = da7280_probe,
> > +   .id_table   = da7280_i2c_id,
> 
> Inconsistent alignment of the = signs. My preference is a single space before 
> the equal sign, but aligning them in the same
> column is another usual style.

I will align as your preference, it looks better in this case. Thanks for your 
comments.

> Best regards
> Uwe
> 
> --
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | https://www.pengutronix.de/ |

Kind regards,
Roy


[RESEND PATCH V7 2/3] dt-bindings: input: Add document bindings for DA7280

2018-11-07 Thread Roy Im


Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |  105 
 1 file changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..a25a12f
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,105 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,op-mode: Haptic operation mode.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+   3 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   4 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>;
+   dlg,resonant-freq-hz = <180>;
+   dlg,impd-micro-ohms = <1050>;
+   dlg,freq-track-enable;
+   dlg,rapid-stop-enable;
+   dlg,mem-array = <
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00

[RESEND PATCH V7 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2018-11-07 Thread Roy Im


This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS |2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index b22e7fd..1af587f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4313,6 +4313,7 @@ S:Supported
 F: Documentation/hwmon/da90??
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/thermal/da90??-thermal.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/watchdog/da90??-wdt.txt
@@ -4321,6 +4322,7 @@ F:drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
 F: drivers/input/misc/da90??_onkey.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
 F: drivers/mfd/da903x.c
-- 
end-of-patch for RESEND PATCH V7



[RESEND PATCH V7 3/3] Input: new da7280 haptic driver

2018-11-07 Thread Roy Im


Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Signed-off-by: Roy Im 

---
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
- Rebased to v4.19-rc6.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1409 +++
 drivers/input/misc/da7280.h |  412 +
 4 files changed, 1835 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c
 create mode 100644 drivers/input/misc/da7280.h

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index ca59a2b..751cac6 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,17 @@ config INPUT_SC27XX_VIBRA
  To compile this driver as a module, choose M here. The module will
  be called sc27xx_vibra.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by i2c communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 9d0f9d1..d941348 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..b1072ef
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1409 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2018 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "da7280.h"
+
+/* uV unit for voltage rate */
+#define DA7280_VOLTAGE_RATE_MAX600
+#define DA7280_VOLTAGE_RATE_STEP   23400
+#define DA7280_NOMMAX_DFT  0x6B
+#define DA7280_ABSMAX_DFT  0x78
+
+#define DA7280_IMPD_MAX15
+#define DA7280_IMPD_DEFAULT2200
+
+#define DA7280_IMAX_DEFAULT0x0E
+/* uA unit step and limit for IMAX*/
+#define DA7280_IMAX_STEP   7200
+#define DA7280_IMAX_LIMIT  252000
+
+#define DA7280_RESONT_FREQH_DFT0x39
+#define DA7280_RESONT_FREQL_DFT0x32
+#define DA7280_MIN_RESONAT_FREQ_HZ 50
+#define DA7280_MAX_RESONAT_FREQ_HZ 300
+#define DA7280_MIN_PWM_FREQ_KHZ10
+#define DA7280_MAX_PWM_FREQ_KHZ250
+
+#define DA7280_SEQ_ID_MAX  15
+#define DA7280_SEQ_LOOP_MAX15
+#define DA7280_GPI1_SEQ_ID_DEFT0x0
+
+#define DA7280_SNP_MEM_SIZE100
+#define DA7280_SNP_MEM_MAX DA7280_SNP_MEM_99
+
+#define IRQ_NUM3
+
+#define DA7280_SKIP_INIT   0x100
+
+enum da7280_haptic_dev_t {
+   DA7280_LRA  = 0,
+   DA7280_ERM_BAR  = 1,
+   DA7280_ERM_COIN = 2,
+   DA7280_DEV_MAX,
+};
+
+enum da7280_op_mode {
+   DA7280_INACTIVE = 0,
+   DA7280_DRO_MODE = 1,
+   DA7280_PWM_MODE = 2,
+   DA7280_RTWM_MODE= 3,
+   DA7280_ETWM_MODE= 4,
+   DA7280_OPMODE_MAX,
+};
+
+struct da7280_gpi_ctl {
+   u8 seq_id;
+   u8 mode;
+   u8 polarity;
+};
+
+struct da7280_haptic {
+   struct regmap *regmap;
+   struct input_dev *input_dev;
+   struct device *dev;
+   struct i2c_client *client;
+   struct pwm_device *pwm_dev;
+   boollegacy;
+   int pwm_id;
+   struct work_struct work;
+
+   unsigned int magnitude;
+
+   u8 dev_type;
+   u8 op_mode;
+   u16 nommax;
+   u16 absmax;
+   u32 imax;
+   u32 impd;
+   u32 resonant_freq_h;
+   u32 resonant_freq_l;
+   bool bemf_sense_en;
+   bool freq_track_en;
+

[RESEND PATCH V7 0/3] da7280: haptic driver submission

2018-11-07 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH V7 1/3] MAINTAINERS file update for DA7280
[PATCH V7 2/3] DA7280 DT Binding
[PATCH V7 3/3] DA7280 Driver

This patch applies against linux-next and v4.19-rc6

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  105 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1409 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1942 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c
 create mode 100644 drivers/input/misc/da7280.h

-- 
end-of-patch for RESEND PATCH V7



[RESEND PATCH V7 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2018-10-16 Thread Roy Im


This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS |2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index b22e7fd..1af587f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4313,6 +4313,7 @@ S:Supported
 F: Documentation/hwmon/da90??
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/thermal/da90??-thermal.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/watchdog/da90??-wdt.txt
@@ -4321,6 +4322,7 @@ F:drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
 F: drivers/input/misc/da90??_onkey.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
 F: drivers/mfd/da903x.c
-- 
end-of-patch for RESEND PATCH V7



[RESEND PATCH V7 3/3] Input: new da7280 haptic driver

2018-10-16 Thread Roy Im


Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Signed-off-by: Roy Im 

---
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
- Rebased to v4.19-rc6.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1409 +++
 drivers/input/misc/da7280.h |  412 +
 4 files changed, 1835 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c
 create mode 100644 drivers/input/misc/da7280.h

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index ca59a2b..751cac6 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,17 @@ config INPUT_SC27XX_VIBRA
  To compile this driver as a module, choose M here. The module will
  be called sc27xx_vibra.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by i2c communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 9d0f9d1..d941348 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..b1072ef
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1409 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2018 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "da7280.h"
+
+/* uV unit for voltage rate */
+#define DA7280_VOLTAGE_RATE_MAX600
+#define DA7280_VOLTAGE_RATE_STEP   23400
+#define DA7280_NOMMAX_DFT  0x6B
+#define DA7280_ABSMAX_DFT  0x78
+
+#define DA7280_IMPD_MAX15
+#define DA7280_IMPD_DEFAULT2200
+
+#define DA7280_IMAX_DEFAULT0x0E
+/* uA unit step and limit for IMAX*/
+#define DA7280_IMAX_STEP   7200
+#define DA7280_IMAX_LIMIT  252000
+
+#define DA7280_RESONT_FREQH_DFT0x39
+#define DA7280_RESONT_FREQL_DFT0x32
+#define DA7280_MIN_RESONAT_FREQ_HZ 50
+#define DA7280_MAX_RESONAT_FREQ_HZ 300
+#define DA7280_MIN_PWM_FREQ_KHZ10
+#define DA7280_MAX_PWM_FREQ_KHZ250
+
+#define DA7280_SEQ_ID_MAX  15
+#define DA7280_SEQ_LOOP_MAX15
+#define DA7280_GPI1_SEQ_ID_DEFT0x0
+
+#define DA7280_SNP_MEM_SIZE100
+#define DA7280_SNP_MEM_MAX DA7280_SNP_MEM_99
+
+#define IRQ_NUM3
+
+#define DA7280_SKIP_INIT   0x100
+
+enum da7280_haptic_dev_t {
+   DA7280_LRA  = 0,
+   DA7280_ERM_BAR  = 1,
+   DA7280_ERM_COIN = 2,
+   DA7280_DEV_MAX,
+};
+
+enum da7280_op_mode {
+   DA7280_INACTIVE = 0,
+   DA7280_DRO_MODE = 1,
+   DA7280_PWM_MODE = 2,
+   DA7280_RTWM_MODE= 3,
+   DA7280_ETWM_MODE= 4,
+   DA7280_OPMODE_MAX,
+};
+
+struct da7280_gpi_ctl {
+   u8 seq_id;
+   u8 mode;
+   u8 polarity;
+};
+
+struct da7280_haptic {
+   struct regmap *regmap;
+   struct input_dev *input_dev;
+   struct device *dev;
+   struct i2c_client *client;
+   struct pwm_device *pwm_dev;
+   boollegacy;
+   int pwm_id;
+   struct work_struct work;
+
+   unsigned int magnitude;
+
+   u8 dev_type;
+   u8 op_mode;
+   u16 nommax;
+   u16 absmax;
+   u32 imax;
+   u32 impd;
+   u32 resonant_freq_h;
+   u32 resonant_freq_l;
+   bool bemf_sense_en;
+   bool freq_track_en;
+

[RESEND PATCH V7 0/3] da7280: haptic driver submission

2018-10-16 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH V7 1/3] MAINTAINERS file update for DA7280
[PATCH V7 2/3] DA7280 DT Binding
[PATCH V7 3/3] DA7280 Driver

This patch applies against linux-next and v4.19-rc6

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  105 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1409 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1942 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c
 create mode 100644 drivers/input/misc/da7280.h

-- 
end-of-patch for RESEND PATCH V7



[RESEND PATCH V7 2/3] dt-bindings: input: Add document bindings for DA7280

2018-10-16 Thread Roy Im


Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |  105 
 1 file changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..a25a12f
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,105 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,op-mode: Haptic operation mode.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+   3 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   4 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>;
+   dlg,resonant-freq-hz = <180>;
+   dlg,impd-micro-ohms = <1050>;
+   dlg,freq-track-enable;
+   dlg,rapid-stop-enable;
+   dlg,mem-array = <
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00

[PATCH V7 0/3] da7280: haptic driver submission

2018-10-04 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH V2 1/3] MAINTAINERS file update for DA7280
[PATCH V2 2/3] DA7280 DT Binding
[PATCH V2 3/3] DA7280 Driver

This patch applies against linux-next and v4.19-rc6

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  105 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1393 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1926 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c
 create mode 100644 drivers/input/misc/da7280.h

-- 
end-of-patch for PATCH V7



[PATCH V7 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2018-10-04 Thread Roy Im


This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v7: No changes.
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS |2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index b22e7fd..1af587f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4313,6 +4313,7 @@ S:Supported
 F: Documentation/hwmon/da90??
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/thermal/da90??-thermal.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/watchdog/da90??-wdt.txt
@@ -4321,6 +4322,7 @@ F:drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
 F: drivers/input/misc/da90??_onkey.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
 F: drivers/mfd/da903x.c
-- 
end-of-patch for PATCH V7



[PATCH V7 3/3] Input: new da7280 haptic driver

2018-10-04 Thread Roy Im


Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Signed-off-by: Roy Im 

---
v7: 
- Added more attributes to handle one value per file.
- Replaced and updated the dt-related code and functions called.
- Fixed error/functions.
- Rebased to v4.19-rc6.
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1393 +++
 drivers/input/misc/da7280.h |  412 +
 4 files changed, 1819 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c
 create mode 100644 drivers/input/misc/da7280.h

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index ca59a2b..751cac6 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,17 @@ config INPUT_SC27XX_VIBRA
  To compile this driver as a module, choose M here. The module will
  be called sc27xx_vibra.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by i2c communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 9d0f9d1..d941348 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..b87bf7c
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1393 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2018 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "da7280.h"
+
+/* uV unit for voltage rate */
+#define DA7280_VOLTAGE_RATE_MAX600
+#define DA7280_VOLTAGE_RATE_STEP   23400
+#define DA7280_NOMMAX_DFT  0x6B
+#define DA7280_ABSMAX_DFT  0x78
+
+#define DA7280_IMPD_MAX15
+#define DA7280_IMPD_DEFAULT2200
+
+#define DA7280_IMAX_DEFAULT0x0E
+/* uA unit step and limit for IMAX*/
+#define DA7280_IMAX_STEP   7200
+#define DA7280_IMAX_LIMIT  252000
+
+#define DA7280_RESONT_FREQH_DFT0x39
+#define DA7280_RESONT_FREQL_DFT0x32
+#define DA7280_MIN_RESONAT_FREQ_HZ 50
+#define DA7280_MAX_RESONAT_FREQ_HZ 300
+#define DA7280_MIN_PWM_FREQ_KHZ10
+#define DA7280_MAX_PWM_FREQ_KHZ250
+
+#define DA7280_SEQ_ID_MAX  15
+#define DA7280_SEQ_LOOP_MAX15
+#define DA7280_GPI1_SEQ_ID_DEFT0x0
+
+#define DA7280_SNP_MEM_SIZE100
+#define DA7280_SNP_MEM_MAX DA7280_SNP_MEM_99
+
+#define IRQ_NUM3
+
+#define DA7280_SKIP_INIT   0x100
+
+enum da7280_haptic_dev_t {
+   DA7280_LRA  = 0,
+   DA7280_ERM_BAR  = 1,
+   DA7280_ERM_COIN = 2,
+   DA7280_DEV_MAX,
+};
+
+enum da7280_op_mode {
+   DA7280_INACTIVE = 0,
+   DA7280_DRO_MODE = 1,
+   DA7280_PWM_MODE = 2,
+   DA7280_RTWM_MODE= 3,
+   DA7280_ETWM_MODE= 4,
+   DA7280_OPMODE_MAX,
+};
+
+struct da7280_gpi_ctl {
+   u8 seq_id;
+   u8 mode;
+   u8 polarity;
+};
+
+struct da7280_haptic {
+   struct regmap *regmap;
+   struct input_dev *input_dev;
+   struct device *dev;
+   struct i2c_client *client;
+   struct pwm_device *pwm_dev;
+   boollegacy;
+   int pwm_id;
+   struct work_struct work;
+
+   unsigned int magnitude;
+
+   u8 dev_type;
+   u8 op_mode;
+   u16 nommax;
+   u16 absmax;
+   u32 imax;
+   u32 impd;
+   u32 resonant_freq_h;
+   u32 resonant_freq_l;
+   bool bemf_sense_en;
+   bool freq_track_en;
+

[PATCH V7 2/3] dt-bindings: input: Add document bindings for DA7280

2018-10-04 Thread Roy Im


Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v7: No changes.
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |  105 
 1 file changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..a25a12f
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,105 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,op-mode: Haptic operation mode.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+   3 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   4 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>;
+   dlg,resonant-freq-hz = <180>;
+   dlg,impd-micro-ohms = <1050>;
+   dlg,freq-track-enable;
+   dlg,rapid-stop-enable;
+   dlg,mem-array = <
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00

RE: [RESEND PATCH V6 3/3] Input: new da7280 haptic driver

2018-09-20 Thread Roy Im
Hi Dmitry,

On Thursday, September 20, 2018 9:35 AM, Dmitry wrote:
> 
> Hi Roy,
> 
> On Wed, Sep 19, 2018 at 07:35:04PM +0900, Roy Im wrote:
> >
> > Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
> > multiple mode and integrated waveform memory and wideband support.
> > It communicates via an I2C bus to the device.
> >
> > Signed-off-by: Roy Im 
> >
> > ---
> > v6: No changes.
> > v5: Fixed errors in Kconfig file.
> > v4: Updated code as dt-bindings are changed.
> > v3: No changes.
> > v2: Fixed kbuild error/warning
> >
> >
> >  drivers/input/misc/Kconfig  |   13 +
> >  drivers/input/misc/Makefile |1 +
> >  drivers/input/misc/da7280.c | 1438 
> > +++
> >  drivers/input/misc/da7280.h |  412 +
> >  4 files changed, 1864 insertions(+)
> >  create mode 100644 drivers/input/misc/da7280.c
> >  create mode 100644 drivers/input/misc/da7280.h
> >
> > diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> > index ca59a2b..751cac6 100644
> > --- a/drivers/input/misc/Kconfig
> > +++ b/drivers/input/misc/Kconfig
> > @@ -851,4 +851,17 @@ config INPUT_SC27XX_VIBRA
> >   To compile this driver as a module, choose M here. The module will
> >   be called sc27xx_vibra.
> >
> > +config INPUT_DA7280_HAPTICS
> > +   tristate "Dialog Semiconductor DA7280 haptics support"
> > +   depends on INPUT && I2C
> > +   select INPUT_FF_MEMLESS
> > +   select REGMAP_I2C
> > +   help
> > + Say Y to enable support for the Dialog DA7280 haptics driver.
> > + The haptics can be controlled by i2c communication,
> > + or by PWM input, or by GPI.
> > +
> > + To compile this driver as a module, choose M here: the
> > + module will be called da7280.
> > +
> >  endif
> > diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
> > index 9d0f9d1..d941348 100644
> > --- a/drivers/input/misc/Makefile
> > +++ b/drivers/input/misc/Makefile
> > @@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
> >  obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
> >  obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
> >  obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
> > +obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
> >  obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
> >  obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
> >  obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
> > diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
> > new file mode 100644
> > index 000..041a9f4
> > --- /dev/null
> > +++ b/drivers/input/misc/da7280.c
> > @@ -0,0 +1,1438 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * DA7280 Haptic device driver
> > + *
> > + * Copyright (c) 2018 Dialog Semiconductor.
> > + * Author: Roy Im 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include "da7280.h"
> > +
> > +/* uV unit for voltage rate */
> > +#define DA7280_VOLTAGE_RATE_MAX600
> > +#define DA7280_VOLTAGE_RATE_STEP   23400
> > +#define DA7280_NOMMAX_DFT  0x6B
> > +#define DA7280_ABSMAX_DFT  0x78
> > +
> > +#define DA7280_IMPD_MAX15
> > +#define DA7280_IMPD_DEFAULT2200
> > +
> > +#define DA7280_IMAX_DEFAULT0x0E
> > +/* uA unit step and limit for IMAX*/
> > +#define DA7280_IMAX_STEP   7200
> > +#define DA7280_IMAX_LIMIT  252000
> > +
> > +#define DA7280_RESONT_FREQH_DFT0x39
> > +#define DA7280_RESONT_FREQL_DFT0x32
> > +#define DA7280_MIN_RESONAT_FREQ_HZ 50
> > +#define DA7280_MAX_RESONAT_FREQ_HZ 300
> > +#define DA7280_MIN_PWM_FREQ_KHZ10
> > +#define DA7280_MAX_PWM_FREQ_KHZ250
> > +
> > +#define DA7280_SEQ_ID_MAX  15
> > +#define DA7280_SEQ_LOOP_MAX15
> > +#define DA7280_GPI1_SEQ_ID_DEFT0x0
> > +
> > +#define DA7280_SNP_MEM_SIZE100
> > +#define DA7280_SNP_MEM_MAX DA7280_SNP_MEM_99
> > +
> > +#define IRQ_NUM3
> > +
> > +#define DA7280_SKIP_INIT   0x100
> > +
> > +enum da7280_haptic_dev_t {
> > +  

[RESEND PATCH V6 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2018-09-19 Thread Roy Im


This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS |2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index d870cb5..6244a7d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4313,6 +4313,7 @@ S:Supported
 F: Documentation/hwmon/da90??
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/thermal/da90??-thermal.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/watchdog/da90??-wdt.txt
@@ -4321,6 +4322,7 @@ F:drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
 F: drivers/input/misc/da90??_onkey.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
 F: drivers/mfd/da903x.c
-- 
end-of-patch for RESEND PATCH V6



[RESEND PATCH V6 2/3] dt-bindings: input: Add document bindings for DA7280

2018-09-19 Thread Roy Im


Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |  105 
 1 file changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..a25a12f
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,105 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,op-mode: Haptic operation mode.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+   3 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   4 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>;
+   dlg,resonant-freq-hz = <180>;
+   dlg,impd-micro-ohms = <1050>;
+   dlg,freq-track-enable;
+   dlg,rapid-stop-enable;
+   dlg,mem-array = <
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

[RESEND PATCH V6 0/3] da7280: haptic driver submission

2018-09-19 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH V2 1/3] MAINTAINERS file update for DA7280
[PATCH V2 2/3] DA7280 DT Binding
[PATCH V2 3/3] DA7280 Driver

This patch applies against linux-next and v4.19-rc3

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  105 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1438 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1971 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c
 create mode 100644 drivers/input/misc/da7280.h

-- 
end-of-patch for RESEND PATCH V6



[RESEND PATCH V6 3/3] Input: new da7280 haptic driver

2018-09-19 Thread Roy Im


Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with
multiple mode and integrated waveform memory and wideband support.
It communicates via an I2C bus to the device.

Signed-off-by: Roy Im 

---
v6: No changes.
v5: Fixed errors in Kconfig file.
v4: Updated code as dt-bindings are changed.
v3: No changes.
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   13 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1438 +++
 drivers/input/misc/da7280.h |  412 +
 4 files changed, 1864 insertions(+)
 create mode 100644 drivers/input/misc/da7280.c
 create mode 100644 drivers/input/misc/da7280.h

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index ca59a2b..751cac6 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,17 @@ config INPUT_SC27XX_VIBRA
  To compile this driver as a module, choose M here. The module will
  be called sc27xx_vibra.
 
+config INPUT_DA7280_HAPTICS
+   tristate "Dialog Semiconductor DA7280 haptics support"
+   depends on INPUT && I2C
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the Dialog DA7280 haptics driver.
+ The haptics can be controlled by i2c communication,
+ or by PWM input, or by GPI.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280.
+
 endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 9d0f9d1..d941348 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000)   += cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_DA7280_HAPTICS) += da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)   += da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)   += da9055_onkey.o
 obj-$(CONFIG_INPUT_DA9063_ONKEY)   += da9063_onkey.o
diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c
new file mode 100644
index 000..041a9f4
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1438 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DA7280 Haptic device driver
+ *
+ * Copyright (c) 2018 Dialog Semiconductor.
+ * Author: Roy Im 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "da7280.h"
+
+/* uV unit for voltage rate */
+#define DA7280_VOLTAGE_RATE_MAX600
+#define DA7280_VOLTAGE_RATE_STEP   23400
+#define DA7280_NOMMAX_DFT  0x6B
+#define DA7280_ABSMAX_DFT  0x78
+
+#define DA7280_IMPD_MAX15
+#define DA7280_IMPD_DEFAULT2200
+
+#define DA7280_IMAX_DEFAULT0x0E
+/* uA unit step and limit for IMAX*/
+#define DA7280_IMAX_STEP   7200
+#define DA7280_IMAX_LIMIT  252000
+
+#define DA7280_RESONT_FREQH_DFT0x39
+#define DA7280_RESONT_FREQL_DFT0x32
+#define DA7280_MIN_RESONAT_FREQ_HZ 50
+#define DA7280_MAX_RESONAT_FREQ_HZ 300
+#define DA7280_MIN_PWM_FREQ_KHZ10
+#define DA7280_MAX_PWM_FREQ_KHZ250
+
+#define DA7280_SEQ_ID_MAX  15
+#define DA7280_SEQ_LOOP_MAX15
+#define DA7280_GPI1_SEQ_ID_DEFT0x0
+
+#define DA7280_SNP_MEM_SIZE100
+#define DA7280_SNP_MEM_MAX DA7280_SNP_MEM_99
+
+#define IRQ_NUM3
+
+#define DA7280_SKIP_INIT   0x100
+
+enum da7280_haptic_dev_t {
+   DA7280_LRA  = 0,
+   DA7280_ERM_BAR  = 1,
+   DA7280_ERM_COIN = 2,
+   DA7280_DEV_MAX,
+};
+
+enum da7280_op_mode {
+   DA7280_INACTIVE = 0,
+   DA7280_DRO_MODE = 1,
+   DA7280_PWM_MODE = 2,
+   DA7280_RTWM_MODE= 3,
+   DA7280_ETWM_MODE= 4,
+   DA7280_OPMODE_MAX,
+};
+
+struct da7280_gpi_ctl {
+   u8 seq_id;
+   u8 mode;
+   u8 polarity;
+};
+
+struct da7280_haptic {
+   struct regmap *regmap;
+   struct input_dev *input_dev;
+   struct device *dev;
+   struct i2c_client *client;
+   struct pwm_device *pwm_dev;
+   boollegacy;
+   int pwm_id;
+   struct work_struct work;
+
+   bool suspend_state;
+   unsigned int magnitude;
+
+   u8 dev_type;
+   u8 op_mode;
+   u16 nommax;
+   u16 absmax;
+   u32 imax;
+   u32 impd;
+   u32 resonant_freq_h;
+   u32 resonant_freq_l;
+   u8 bemf_sense_en;
+   u8 freq_track_en;
+   u8 acc_en;
+   u8 rapid_stop_en;
+   u8 amp_pid_en;
+   u8 ps_seq_id;
+   u8 ps_seq_loop;
+   struct da7280_gpi_ctl gpi_ctl[3];
+   bool me

[PATCH V6 0/3] da7280: haptic driver submission

2018-09-11 Thread Roy Im
This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

[PATCH V2 1/3] MAINTAINERS file update for DA7280
[PATCH V2 2/3] DA7280 DT Binding
[PATCH V2 3/3] DA7280 Driver

This patch applies against linux-next and v4.19-rc3

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  dt-bindings: input: Add document bindings for DA7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |  105 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   13 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1438 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1971 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt
 create mode 100644 drivers/input/misc/da7280.c
 create mode 100644 drivers/input/misc/da7280.h

-- 
end-of-patch for PATCH V6



[PATCH V6 2/3] dt-bindings: input: Add document bindings for DA7280

2018-09-11 Thread Roy Im


Add device tree binding information for DA7280 haptic driver.
Example bindings for DA7280 are added.

Reviewed-by: Rob Herring .

Signed-off-by: Roy Im 

---
v6: No changes.
v5: Updated descriptions and fixed errors.
v4: Fixed commit message, properties.
v3: Fixed subject format.
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |  105 
 1 file changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/dlg,da7280.txt

diff --git a/Documentation/devicetree/bindings/input/dlg,da7280.txt 
b/Documentation/devicetree/bindings/input/dlg,da7280.txt
new file mode 100644
index 000..a25a12f
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,105 @@
+Dialog Semiconductor DA7280 Haptics bindings
+
+Required properties:
+- compatible: Should be "dlg,da7280".
+- reg: Specifies the I2C slave address.
+
+- interrupt-parent : Specifies the phandle of the interrupt controller to
+  which the IRQs from DA7280 are delivered to.
+
+- dlg,actuator-type: Set Actuator type. it should be one of:
+  "LRA" - Linear Resonance Actuator type.
+  "ERM-bar" - Bar type Eccentric Rotating Mass.
+  "ERM-coin" - Coin type Eccentric Rotating Mass.
+
+- dlg,op-mode: Haptic operation mode.
+  Possible values:
+   1 - Direct register override(DRO) mode triggered by i2c(default),
+   2 - PWM data source mode controlled by PWM duty,
+   3 - Register triggered waveform memory(RTWM) mode, the pattern
+   assigned to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   4 - Edge triggered waveform memory(ETWM) mode, external GPI(N)
+   control are required to enable/disable and it needs to keep
+   device enabled by sending magnitude (X > 0),
+   the pattern is assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+  Valid values: 0 - 600.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+  Valid values: 0 - 600.
+- dlg,imax-microamp: Actuator max current rating.
+  Valid values: 0 - 252000.
+  Default: 13.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohms.
+  Valid values: 0 - 15.
+
+Optional properties:
+- pwms : phandle to the physical PWM(Pulse Width Modulation) device.
+  PWM properties should be named "pwms". And number of cell is different
+  for each pwm device.
+  (See Documentation/devicetree/bindings/pwm/pwm.txt
+   for further information relating to pwm properties)
+
+- dlg,ps-seq-id: the PS_SEQ_ID(pattern ID in waveform memory inside chip)
+  to play back when RTWM-MODE is enabled.
+  Valid range: 0 - 15.
+- dlg,ps-seq-loop: the PS_SEQ_LOOP, Number of times the pre-stored sequence
+  pointed to by PS_SEQ_ID or GPI(N)_SEQUENCE_ID is repeated.
+  Valid range: 0 - 15.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0 - 2.
+  Valid range: 0 - 15.
+- dlg,gpiN-mode: the pattern mode which can select either
+  "Single-pattern" or "Multi-pattern", 'N' must be 0 - 2.
+- dlg,gpiN-polarity: gpiN polarity which can be chosen among
+  "Rising-edge", "Falling-edge" and "Both-edge",
+  'N' must be 0 - 2
+  Haptic will work by this edge option in case of ETWM mode.
+
+- dlg,resonant-freq-hz: use in case of LRA.
+  the frequency range: 50 - 300.
+  Default: 205.
+
+- dlg,bemf-sens-enable: Enable for internal loop computations.
+- dlg,freq-track-enable: Enable for resonant frequency tracking.
+- dlg,acc-enable: Enable for active acceleration.
+- dlg,rapid-stop-enable: Enable for rapid stop.
+- dlg,amp-pid-enable: Enable for the amplitude PID.
+- dlg,mem-array: Customized waveform memory(patterns) data downloaded to
+  the device during initialization. This is an array of 100 values(u8).
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <&gpio6>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,actuator-type = "LRA";
+   dlg,op-mode = <1>;
+   dlg,nom-microvolt = <200>;
+   dlg,abs-max-microvolt = <200>;
+   dlg,imax-microamp = <17>;
+   dlg,resonant-freq-hz = <180>;
+   dlg,impd-micro-ohms = <1050>;
+   dlg,freq-track-enable;
+   dlg,rapid-stop-enable;
+   dlg,mem-array = <
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

[PATCH V6 1/3] MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms

2018-09-11 Thread Roy Im


This patch adds the da7280 bindings doc and driver to the Dialog
Semiconductor support list.

Signed-off-by: Roy Im 

---
v6: No changes.
v5: No changes.
v4: No changes.
v3: No changes.
v2: No changes.


 MAINTAINERS |2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index d870cb5..6244a7d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4313,6 +4313,7 @@ S:Supported
 F: Documentation/hwmon/da90??
 F: Documentation/devicetree/bindings/mfd/da90*.txt
 F: Documentation/devicetree/bindings/input/da90??-onkey.txt
+F: Documentation/devicetree/bindings/input/dlg,da72??.txt
 F: Documentation/devicetree/bindings/thermal/da90??-thermal.txt
 F: Documentation/devicetree/bindings/regulator/da92*.txt
 F: Documentation/devicetree/bindings/watchdog/da90??-wdt.txt
@@ -4321,6 +4322,7 @@ F:drivers/gpio/gpio-da90??.c
 F: drivers/hwmon/da90??-hwmon.c
 F: drivers/iio/adc/da91??-*.c
 F: drivers/input/misc/da90??_onkey.c
+F: drivers/input/misc/da72??.[ch]
 F: drivers/input/touchscreen/da9052_tsi.c
 F: drivers/leds/leds-da90??.c
 F: drivers/mfd/da903x.c
-- 
end-of-patch for PATCH V6



  1   2   >