[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
+#define DA7280_MEM_CTL2   

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

2020-08-18 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
+#define DA7280_MEM_CTL2   

[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
+#define DA7280_MEM_CTL2