[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 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 = <>;
+   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 0x00 0x00
+ 0x00 

[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 = <>;
+   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 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 {
> > +  

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 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 = <>;
+   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 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

[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 = <>;
+   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 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 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 = <>;
+   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 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



[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 = <>;
+   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 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



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

2018-09-11 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 3/3] Input: new da7280 haptic driver

2018-09-11 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 V5 3/3] Input: new da7280 haptic driver

2018-08-27 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 

---
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..3a64730
--- /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 mem_update;
+   u8

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

2018-08-27 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 

---
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..3a64730
--- /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 mem_update;
+   u8

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

2018-08-27 Thread Roy Im


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

Signed-off-by: Roy Im 

---
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 = <>;
+   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 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 

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

2018-08-27 Thread Roy Im


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

Signed-off-by: Roy Im 

---
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 = <>;
+   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 0x00 0x00
+ 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+ 

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

2018-08-27 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.18

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 V5



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

2018-08-27 Thread Roy Im


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

Signed-off-by: Roy Im 

---
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 544cac8..720f9fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,6 +4221,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
@@ -4229,6 +4230,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 V5



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

2018-08-27 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.18

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 V5



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

2018-08-27 Thread Roy Im


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

Signed-off-by: Roy Im 

---
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 544cac8..720f9fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,6 +4221,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
@@ -4229,6 +4230,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 V5



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

2018-08-26 Thread Roy Im
Hi Pavel,

On Sunday, August 26, 2018 3:52 PM, Pavel Machek wrote:
>
> > +++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
> > @@ -0,0 +1,101 @@
> > +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,vib-mode:
> > +  "LRA-MODE" - Linear Resonance Actuator mode.
> > +  "ERM-BAR" - Bar type Eccentric Rotating Mass mode.
> > +  "ERM-COIN" - Coin type Eccentric Rotating Mass mode.
> 
> So this is some kind of "vibration motor" on steroids)?

I will add some descriptions more here in v5.

> > +- dlg,op-mode: Haptic operation mode.
> > +  Possible values:
> > +   1 - Direct register override mode triggered by i2c(default),
> > +   2 - PWM data source mode setting duty to 0 - 0x(0% - 100%),
> 
> Space after 0x?

I will remove this in v5.

> 
> > +   3 - Register triggered waveform memory mode, the pattern assigned
> > +   to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
> > +   4 - Edge triggered waveform memory mode, external GPI(N) condtrol
> 
> "control"

I will fix this in v5

>
> > +   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
> 
> "below."

I will fix this in v5

> 
> > +- dlg,imax-microamp: Actuator max current rating.
> > +  Valid values: 0 - 252000.
> > +  Default: 13.
> > +- dlg,impd-micro-ohms: the impedance of the actuator in micro ohm,
> 
> "ohms"

I will fix this in v5.

> 
> > +  as read from its datasheet.
> 
> "as read" does not sound english.

I will correct this in v5.

> 
> > +- dlg,mem-array: use in case that memory registers should be updated,
> > +  Please fill the whole buffers(100 bytes) to avoid any error in driver.
> > +  For example,
> > +   dlg,mem-array = <
> > +   0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A
> > +   ...
> > +   0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A
> > +   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> > +   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> > +   >;
> 
> I'd not understand what this is from this description. (And I'd put
> example below... in the exampls section).

I will improve and update the description including the example section in v5.

Regards,
Roy

> 
> > +For further information, see device datasheet.
> > +
> > +==
> > +
> > +Example:
> > +
> > +   haptics: da7280-haptics@4a {
> > +   compatible = "dlg,da7280";
> > +   reg = <0x4a>;
> > +   interrupt-parent = <>;
> > +   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
> > +   dlg,vib-mode = "LRA-MODE";
> > +   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;
> > +   };
> 
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures)
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


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

2018-08-26 Thread Roy Im
Hi Pavel,

On Sunday, August 26, 2018 3:52 PM, Pavel Machek wrote:
>
> > +++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
> > @@ -0,0 +1,101 @@
> > +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,vib-mode:
> > +  "LRA-MODE" - Linear Resonance Actuator mode.
> > +  "ERM-BAR" - Bar type Eccentric Rotating Mass mode.
> > +  "ERM-COIN" - Coin type Eccentric Rotating Mass mode.
> 
> So this is some kind of "vibration motor" on steroids)?

I will add some descriptions more here in v5.

> > +- dlg,op-mode: Haptic operation mode.
> > +  Possible values:
> > +   1 - Direct register override mode triggered by i2c(default),
> > +   2 - PWM data source mode setting duty to 0 - 0x(0% - 100%),
> 
> Space after 0x?

I will remove this in v5.

> 
> > +   3 - Register triggered waveform memory mode, the pattern assigned
> > +   to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
> > +   4 - Edge triggered waveform memory mode, external GPI(N) condtrol
> 
> "control"

I will fix this in v5

>
> > +   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
> 
> "below."

I will fix this in v5

> 
> > +- dlg,imax-microamp: Actuator max current rating.
> > +  Valid values: 0 - 252000.
> > +  Default: 13.
> > +- dlg,impd-micro-ohms: the impedance of the actuator in micro ohm,
> 
> "ohms"

I will fix this in v5.

> 
> > +  as read from its datasheet.
> 
> "as read" does not sound english.

I will correct this in v5.

> 
> > +- dlg,mem-array: use in case that memory registers should be updated,
> > +  Please fill the whole buffers(100 bytes) to avoid any error in driver.
> > +  For example,
> > +   dlg,mem-array = <
> > +   0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A
> > +   ...
> > +   0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A
> > +   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> > +   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> > +   >;
> 
> I'd not understand what this is from this description. (And I'd put
> example below... in the exampls section).

I will improve and update the description including the example section in v5.

Regards,
Roy

> 
> > +For further information, see device datasheet.
> > +
> > +==
> > +
> > +Example:
> > +
> > +   haptics: da7280-haptics@4a {
> > +   compatible = "dlg,da7280";
> > +   reg = <0x4a>;
> > +   interrupt-parent = <>;
> > +   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
> > +   dlg,vib-mode = "LRA-MODE";
> > +   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;
> > +   };
> 
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures)
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


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

2018-08-23 Thread Roy Im
Hi Randy,

On 08/24/2018 12:28 AM, Randy Dunlap wrote:

> On 08/20/2018 10:44 PM, Roy Im wrote:
> > diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> > index ca59a2b..6e0de69 100644
> > --- a/drivers/input/misc/Kconfig
> > +++ b/drivers/input/misc/Kconfig
> > @@ -851,4 +851,16 @@ config INPUT_SC27XX_VIBRA
> >   To compile this driver as a module, choose M here. The module
> will
> >   be called sc27xx_vibra.
> >
> 
> Hi,
> Can you explain the "depends on" below, please.
> 
> > +config INPUT_DA7280_HAPTICS
> > +   tristate "Dialog Semiconductor DA7280 haptics support"
> > +   depends on (INPUT && I2C && SYSFS) || PWM
> > +   select INPUT_FF_MEMLESS
> > +   select REGMAP_I2C
> 
> If INPUT is disabled, and I2C is disabled, and SYSFS is disabled, but
> PWM=y,
> then the "select"s will have problems with unmet dependencies.

I will fix this in v5.

> 
> > +   help
> > + Say Y to enable support for the haptics controller on
> > + Dialog DA7280 chip.
> > +
> > + To compile this driver as a module, choose M here: the
> > + module will be called da7280-haptic.
> 
> That module name doesn't match what's in the Makefile (below).

I will fix this as well in v5.

> 
> > +
> >  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
> 
> 
> --
> ~Randy

Regards,
Roy


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

2018-08-23 Thread Roy Im
Hi Randy,

On 08/24/2018 12:28 AM, Randy Dunlap wrote:

> On 08/20/2018 10:44 PM, Roy Im wrote:
> > diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> > index ca59a2b..6e0de69 100644
> > --- a/drivers/input/misc/Kconfig
> > +++ b/drivers/input/misc/Kconfig
> > @@ -851,4 +851,16 @@ config INPUT_SC27XX_VIBRA
> >   To compile this driver as a module, choose M here. The module
> will
> >   be called sc27xx_vibra.
> >
> 
> Hi,
> Can you explain the "depends on" below, please.
> 
> > +config INPUT_DA7280_HAPTICS
> > +   tristate "Dialog Semiconductor DA7280 haptics support"
> > +   depends on (INPUT && I2C && SYSFS) || PWM
> > +   select INPUT_FF_MEMLESS
> > +   select REGMAP_I2C
> 
> If INPUT is disabled, and I2C is disabled, and SYSFS is disabled, but
> PWM=y,
> then the "select"s will have problems with unmet dependencies.

I will fix this in v5.

> 
> > +   help
> > + Say Y to enable support for the haptics controller on
> > + Dialog DA7280 chip.
> > +
> > + To compile this driver as a module, choose M here: the
> > + module will be called da7280-haptic.
> 
> That module name doesn't match what's in the Makefile (below).

I will fix this as well in v5.

> 
> > +
> >  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
> 
> 
> --
> ~Randy

Regards,
Roy


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

2018-08-23 Thread Roy Im


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

Signed-off-by: Roy Im 

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


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

diff --git a/MAINTAINERS b/MAINTAINERS
index 544cac8..720f9fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,6 +4221,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
@@ -4229,6 +4230,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 V4



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

2018-08-23 Thread Roy Im


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

Signed-off-by: Roy Im 

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


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

diff --git a/MAINTAINERS b/MAINTAINERS
index 544cac8..720f9fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,6 +4221,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
@@ -4229,6 +4230,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 V4



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

2018-08-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.

Signed-off-by: Roy Im 

---
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 | 1438 +++
 drivers/input/misc/da7280.h |  412 +
 4 files changed, 1863 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..6e0de69 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,16 @@ 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 && SYSFS) || PWM
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the haptics controller on
+ Dialog DA7280 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280-haptic.
+
 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..da500ab
--- /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 mem_update;
+   u8 snp_mem[DA7280_SNP_MEM_SIZE];
+   const struct attribute_gr

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

2018-08-23 Thread Roy Im
From: 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.18

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   |  101 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1438 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1966 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 V4



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

2018-08-23 Thread Roy Im
From: 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.18

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   |  101 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1438 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1966 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 V4



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

2018-08-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.

Signed-off-by: Roy Im 

---
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 | 1438 +++
 drivers/input/misc/da7280.h |  412 +
 4 files changed, 1863 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..6e0de69 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,16 @@ 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 && SYSFS) || PWM
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the haptics controller on
+ Dialog DA7280 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280-haptic.
+
 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..da500ab
--- /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 mem_update;
+   u8 snp_mem[DA7280_SNP_MEM_SIZE];
+   const struct attribute_gr

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

2018-08-23 Thread Roy Im


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

Signed-off-by: Roy Im 

---
v4: Fixed commit message, properties.

v3: Fixed subject format.

v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |  101 
 1 file changed, 101 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..a61e9f0
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,101 @@
+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,vib-mode:
+  "LRA-MODE" - Linear Resonance Actuator mode.
+  "ERM-BAR" - Bar type Eccentric Rotating Mass mode.
+  "ERM-COIN" - Coin type Eccentric Rotating Mass mode.
+
+- dlg,op-mode: Haptic operation mode.
+  Possible values:
+   1 - Direct register override mode triggered by i2c(default),
+   2 - PWM data source mode setting duty to 0 - 0x(0% - 100%),
+   3 - Register triggered waveform memory mode, the pattern assigned
+   to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   4 - Edge triggered waveform memory mode, external GPI(N) condtrol
+   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 ohm,
+  as read from its datasheet.
+  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-MODE.
+  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: use in case that memory registers should be updated,
+  Please fill the whole buffers(100 bytes) to avoid any error in driver.
+  For example,
+   dlg,mem-array = <
+   0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A
+   ...
+   0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   >;
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,vib-mode = "LRA-MODE";
+   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;
+   };
-- 
end-of-patch for PATCH V4



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

2018-08-23 Thread Roy Im


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

Signed-off-by: Roy Im 

---
v4: Fixed commit message, properties.

v3: Fixed subject format.

v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |  101 
 1 file changed, 101 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..a61e9f0
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,101 @@
+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,vib-mode:
+  "LRA-MODE" - Linear Resonance Actuator mode.
+  "ERM-BAR" - Bar type Eccentric Rotating Mass mode.
+  "ERM-COIN" - Coin type Eccentric Rotating Mass mode.
+
+- dlg,op-mode: Haptic operation mode.
+  Possible values:
+   1 - Direct register override mode triggered by i2c(default),
+   2 - PWM data source mode setting duty to 0 - 0x(0% - 100%),
+   3 - Register triggered waveform memory mode, the pattern assigned
+   to the PS_SEQ_ID played as much times as PS_SEQ_LOOP,
+   4 - Edge triggered waveform memory mode, external GPI(N) condtrol
+   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 ohm,
+  as read from its datasheet.
+  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-MODE.
+  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: use in case that memory registers should be updated,
+  Please fill the whole buffers(100 bytes) to avoid any error in driver.
+  For example,
+   dlg,mem-array = <
+   0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A
+   ...
+   0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   >;
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4a {
+   compatible = "dlg,da7280";
+   reg = <0x4a>;
+   interrupt-parent = <>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,vib-mode = "LRA-MODE";
+   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;
+   };
-- 
end-of-patch for PATCH V4



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

2018-08-20 Thread Roy Im


from: Roy Im 

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

Signed-off-by: Roy Im 

---
v3: Fixed subject format.

v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |   91 
 1 file changed, 91 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..759bcfe
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,91 @@
+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.
+- interrupts: IRQ line info for DA7280.
+  (See Documentation/devicetree/bindings/interrupt-controller/
+   interrupts.txt for further information relating to interrupt properties)
+- dlg,vib-mode:
+  "LRA-MODE" - Linear Resonance Actuator mode.
+  "ERM-BAR" - Bar type Eccentric Rotating Mass mode.
+  "ERM-COIN" - Coin type Eccentric Rotating Mass mode.
+- dlg,play-mode: choose one in below five modes.
+  "DRO-MODE" - Direct register override mode.
+  "PWM-MODE" - PWM data source mode.
+   In this case, user is able to set duty to 0 ~ 0x(0% ~ 100%)
+  "RTWM-MODE" - Register triggered waveform memory mode.
+   In this case, when enable this mode the pattern assigned
+   to the PS_SEQ_ID will be played as much times as PS_SEQ_LOOP.
+  "ETWM-MODE" - Edge triggered waveform memory mode.
+   In this case, external GPI(N) control are required to enable/disable
+   and it needs to keep device enabled by sending magnitude (X > 0)
+   the pattern assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+- dlg,imax-microamp: Actuator max current rating.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohm,
+  as read from its datasheet.
+
+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.
+- 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.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0~2.
+- 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-MODE, default 205Hz.
+  the freq range: 50Hz ~ 300Hz.
+  It will be set to 205Hz if the value is out of range.
+- 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: use in case that memory registers should be updated,
+  Please fill the whole buffers(100 bytes) to avoid any error in driver.
+  For example,
+   dlg,mem-array = <
+   0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A
+   ...
+   0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   >;
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4A {
+   compatible = "dlg,da7280";
+   reg = <0x4A>;
+   interrupt-parent = <>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,vib-mode = "LRA-MODE";
+   dlg,play-mode = "DRO-MODE";
+   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;
+   };
-- 
end-of-patch for PATCH V3



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

2018-08-20 Thread Roy Im


from: Roy Im 

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

Signed-off-by: Roy Im 

---
v3: Fixed subject format.

v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |   91 
 1 file changed, 91 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..759bcfe
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,91 @@
+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.
+- interrupts: IRQ line info for DA7280.
+  (See Documentation/devicetree/bindings/interrupt-controller/
+   interrupts.txt for further information relating to interrupt properties)
+- dlg,vib-mode:
+  "LRA-MODE" - Linear Resonance Actuator mode.
+  "ERM-BAR" - Bar type Eccentric Rotating Mass mode.
+  "ERM-COIN" - Coin type Eccentric Rotating Mass mode.
+- dlg,play-mode: choose one in below five modes.
+  "DRO-MODE" - Direct register override mode.
+  "PWM-MODE" - PWM data source mode.
+   In this case, user is able to set duty to 0 ~ 0x(0% ~ 100%)
+  "RTWM-MODE" - Register triggered waveform memory mode.
+   In this case, when enable this mode the pattern assigned
+   to the PS_SEQ_ID will be played as much times as PS_SEQ_LOOP.
+  "ETWM-MODE" - Edge triggered waveform memory mode.
+   In this case, external GPI(N) control are required to enable/disable
+   and it needs to keep device enabled by sending magnitude (X > 0)
+   the pattern assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+- dlg,imax-microamp: Actuator max current rating.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohm,
+  as read from its datasheet.
+
+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.
+- 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.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0~2.
+- 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-MODE, default 205Hz.
+  the freq range: 50Hz ~ 300Hz.
+  It will be set to 205Hz if the value is out of range.
+- 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: use in case that memory registers should be updated,
+  Please fill the whole buffers(100 bytes) to avoid any error in driver.
+  For example,
+   dlg,mem-array = <
+   0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A
+   ...
+   0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   >;
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4A {
+   compatible = "dlg,da7280";
+   reg = <0x4A>;
+   interrupt-parent = <>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,vib-mode = "LRA-MODE";
+   dlg,play-mode = "DRO-MODE";
+   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;
+   };
-- 
end-of-patch for PATCH V3



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

2018-08-20 Thread Roy Im
From: 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.18

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   |   91 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1451 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1969 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 V3



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

2018-08-20 Thread Roy Im
From: 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.18

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   |   91 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1451 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1969 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 V3



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

2018-08-20 Thread Roy Im


from: 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 

---
v3: No changes.

v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1451 +++
 drivers/input/misc/da7280.h |  412 
 4 files changed, 1876 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..6e0de69 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,16 @@ 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 && SYSFS) || PWM
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the haptics controller on
+ Dialog DA7280 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280-haptic.
+
 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..f2e1d3a
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1451 @@
+// 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_MAX0x
+#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 mem_update;
+   u8 snp_mem[DA7280_SNP_MEM_SIZE];
+   const struct attribute_group **attr_group;
+};
+
+static bool da7280_volatile_r

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

2018-08-20 Thread Roy Im


From: Roy Im 

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

Signed-off-by: Roy Im 

---
v3: No changes.

v2: No changes.


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

diff --git a/MAINTAINERS b/MAINTAINERS
index 544cac8..720f9fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,6 +4221,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
@@ -4229,6 +4230,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 V3



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

2018-08-20 Thread Roy Im


from: 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 

---
v3: No changes.

v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1451 +++
 drivers/input/misc/da7280.h |  412 
 4 files changed, 1876 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..6e0de69 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,16 @@ 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 && SYSFS) || PWM
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the haptics controller on
+ Dialog DA7280 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280-haptic.
+
 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..f2e1d3a
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1451 @@
+// 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_MAX0x
+#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 mem_update;
+   u8 snp_mem[DA7280_SNP_MEM_SIZE];
+   const struct attribute_group **attr_group;
+};
+
+static bool da7280_volatile_r

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

2018-08-20 Thread Roy Im


From: Roy Im 

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

Signed-off-by: Roy Im 

---
v3: No changes.

v2: No changes.


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

diff --git a/MAINTAINERS b/MAINTAINERS
index 544cac8..720f9fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,6 +4221,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
@@ -4229,6 +4230,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 V3



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

2018-08-16 Thread Roy Im


From: Roy Im 

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

Signed-off-by: Roy Im 

---
v2: No changes

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

diff --git a/MAINTAINERS b/MAINTAINERS
index 544cac8..720f9fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,6 +4221,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
@@ -4229,6 +4230,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 V2



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

2018-08-16 Thread Roy Im


From: Roy Im 

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

Signed-off-by: Roy Im 

---
v2: No changes

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

diff --git a/MAINTAINERS b/MAINTAINERS
index 544cac8..720f9fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,6 +4221,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
@@ -4229,6 +4230,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 V2



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

2018-08-16 Thread Roy Im
From: 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.18

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  Documentation: devicetree: input: new binding for da7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |   91 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1451 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1969 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 V2



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

2018-08-16 Thread Roy Im
From: 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.18

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  Documentation: devicetree: input: new binding for da7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |   91 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1451 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1969 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 V2



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

2018-08-16 Thread Roy Im


from: 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 

---
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1451 +++
 drivers/input/misc/da7280.h |  412 
 4 files changed, 1876 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..6e0de69 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,16 @@ 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 && SYSFS) || PWM
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the haptics controller on
+ Dialog DA7280 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280-haptic.
+
 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..f2e1d3a
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1451 @@
+// 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_MAX0x
+#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 mem_update;
+   u8 snp_mem[DA7280_SNP_MEM_SIZE];
+   const struct attribute_group **attr_group;
+};
+
+static bool da7280_volatile_register(

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

2018-08-16 Thread Roy Im


from: 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 

---
v2: Fixed kbuild error/warning


 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1451 +++
 drivers/input/misc/da7280.h |  412 
 4 files changed, 1876 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..6e0de69 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,16 @@ 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 && SYSFS) || PWM
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the haptics controller on
+ Dialog DA7280 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280-haptic.
+
 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..f2e1d3a
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1451 @@
+// 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_MAX0x
+#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 mem_update;
+   u8 snp_mem[DA7280_SNP_MEM_SIZE];
+   const struct attribute_group **attr_group;
+};
+
+static bool da7280_volatile_register(

[PATCH V2 2/3] Documentation: devicetree: input: new binding for da7280

2018-08-16 Thread Roy Im


from: Roy Im 

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

Signed-off-by: Roy Im 

---
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |   91 
 1 file changed, 91 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..759bcfe
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,91 @@
+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.
+- interrupts: IRQ line info for DA7280.
+  (See Documentation/devicetree/bindings/interrupt-controller/
+   interrupts.txt for further information relating to interrupt properties)
+- dlg,vib-mode:
+  "LRA-MODE" - Linear Resonance Actuator mode.
+  "ERM-BAR" - Bar type Eccentric Rotating Mass mode.
+  "ERM-COIN" - Coin type Eccentric Rotating Mass mode.
+- dlg,play-mode: choose one in below five modes.
+  "DRO-MODE" - Direct register override mode.
+  "PWM-MODE" - PWM data source mode.
+   In this case, user is able to set duty to 0 ~ 0x(0% ~ 100%)
+  "RTWM-MODE" - Register triggered waveform memory mode.
+   In this case, when enable this mode the pattern assigned
+   to the PS_SEQ_ID will be played as much times as PS_SEQ_LOOP.
+  "ETWM-MODE" - Edge triggered waveform memory mode.
+   In this case, external GPI(N) control are required to enable/disable
+   and it needs to keep device enabled by sending magnitude (X > 0)
+   the pattern assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+- dlg,imax-microamp: Actuator max current rating.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohm,
+  as read from its datasheet.
+
+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.
+- 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.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0~2.
+- 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-MODE, default 205Hz.
+  the freq range: 50Hz ~ 300Hz.
+  It will be set to 205Hz if the value is out of range.
+- 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: use in case that memory registers should be updated,
+  Please fill the whole buffers(100 bytes) to avoid any error in driver.
+  For example,
+   dlg,mem-array = <
+   0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A
+   ...
+   0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   >;
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4A {
+   compatible = "dlg,da7280";
+   reg = <0x4A>;
+   interrupt-parent = <>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,vib-mode = "LRA-MODE";
+   dlg,play-mode = "DRO-MODE";
+   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;
+   };
-- 
end-of-patch for PATCH V2



[PATCH V2 2/3] Documentation: devicetree: input: new binding for da7280

2018-08-16 Thread Roy Im


from: Roy Im 

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

Signed-off-by: Roy Im 

---
v2: No changes


 .../devicetree/bindings/input/dlg,da7280.txt   |   91 
 1 file changed, 91 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..759bcfe
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,91 @@
+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.
+- interrupts: IRQ line info for DA7280.
+  (See Documentation/devicetree/bindings/interrupt-controller/
+   interrupts.txt for further information relating to interrupt properties)
+- dlg,vib-mode:
+  "LRA-MODE" - Linear Resonance Actuator mode.
+  "ERM-BAR" - Bar type Eccentric Rotating Mass mode.
+  "ERM-COIN" - Coin type Eccentric Rotating Mass mode.
+- dlg,play-mode: choose one in below five modes.
+  "DRO-MODE" - Direct register override mode.
+  "PWM-MODE" - PWM data source mode.
+   In this case, user is able to set duty to 0 ~ 0x(0% ~ 100%)
+  "RTWM-MODE" - Register triggered waveform memory mode.
+   In this case, when enable this mode the pattern assigned
+   to the PS_SEQ_ID will be played as much times as PS_SEQ_LOOP.
+  "ETWM-MODE" - Edge triggered waveform memory mode.
+   In this case, external GPI(N) control are required to enable/disable
+   and it needs to keep device enabled by sending magnitude (X > 0)
+   the pattern assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+- dlg,imax-microamp: Actuator max current rating.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohm,
+  as read from its datasheet.
+
+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.
+- 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.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0~2.
+- 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-MODE, default 205Hz.
+  the freq range: 50Hz ~ 300Hz.
+  It will be set to 205Hz if the value is out of range.
+- 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: use in case that memory registers should be updated,
+  Please fill the whole buffers(100 bytes) to avoid any error in driver.
+  For example,
+   dlg,mem-array = <
+   0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A
+   ...
+   0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   >;
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4A {
+   compatible = "dlg,da7280";
+   reg = <0x4A>;
+   interrupt-parent = <>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,vib-mode = "LRA-MODE";
+   dlg,play-mode = "DRO-MODE";
+   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;
+   };
-- 
end-of-patch for PATCH V2



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

2018-08-15 Thread Roy Im
From: Roy Im 

This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

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

This patch applies against linux-next and v4.18

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  Documentation: devicetree: input: new binding for da7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |   91 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1452 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1970 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 V1



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

2018-08-15 Thread Roy Im
From: Roy Im 

This patch adds support for the Dialog DA7280 Haptic driver IC.

In this patch set the following is provided:

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

This patch applies against linux-next and v4.18

Thank you,
Roy Im, Dialog Semiconductor Ltd.

Roy Im (3):
  MAINTAINERS: da7280 updates to the Dialog Semiconductor search terms
  Documentation: devicetree: input: new binding for da7280
  Input: new da7280 haptic driver

 .../devicetree/bindings/input/dlg,da7280.txt   |   91 ++
 MAINTAINERS|2 +
 drivers/input/misc/Kconfig |   12 +
 drivers/input/misc/Makefile|1 +
 drivers/input/misc/da7280.c| 1452 
 drivers/input/misc/da7280.h|  412 ++
 6 files changed, 1970 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 V1



[PATCH V1 2/3] Documentation: devicetree: input: new binding for da7280

2018-08-15 Thread Roy Im


from: Roy Im 

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

Signed-off-by: Roy Im 

---

 .../devicetree/bindings/input/dlg,da7280.txt   |   91 
 1 file changed, 91 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..759bcfe
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,91 @@
+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.
+- interrupts: IRQ line info for DA7280.
+  (See Documentation/devicetree/bindings/interrupt-controller/
+   interrupts.txt for further information relating to interrupt properties)
+- dlg,vib-mode:
+  "LRA-MODE" - Linear Resonance Actuator mode.
+  "ERM-BAR" - Bar type Eccentric Rotating Mass mode.
+  "ERM-COIN" - Coin type Eccentric Rotating Mass mode.
+- dlg,play-mode: choose one in below five modes.
+  "DRO-MODE" - Direct register override mode.
+  "PWM-MODE" - PWM data source mode.
+   In this case, user is able to set duty to 0 ~ 0x(0% ~ 100%)
+  "RTWM-MODE" - Register triggered waveform memory mode.
+   In this case, when enable this mode the pattern assigned
+   to the PS_SEQ_ID will be played as much times as PS_SEQ_LOOP.
+  "ETWM-MODE" - Edge triggered waveform memory mode.
+   In this case, external GPI(N) control are required to enable/disable
+   and it needs to keep device enabled by sending magnitude (X > 0)
+   the pattern assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+- dlg,imax-microamp: Actuator max current rating.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohm,
+  as read from its datasheet.
+
+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.
+- 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.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0~2.
+- 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-MODE, default 205Hz.
+  the freq range: 50Hz ~ 300Hz.
+  It will be set to 205Hz if the value is out of range.
+- 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: use in case that memory registers should be updated,
+  Please fill the whole buffers(100 bytes) to avoid any error in driver.
+  For example,
+   dlg,mem-array = <
+   0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A
+   ...
+   0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   >;
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4A {
+   compatible = "dlg,da7280";
+   reg = <0x4A>;
+   interrupt-parent = <>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,vib-mode = "LRA-MODE";
+   dlg,play-mode = "DRO-MODE";
+   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;
+   };
-- 
end-of-patch for PATCH V1



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

2018-08-15 Thread Roy Im


from: 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 

---

 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1452 +++
 drivers/input/misc/da7280.h |  412 
 4 files changed, 1877 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..6e0de69 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,16 @@ 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 && SYSFS) || PWM
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the haptics controller on
+ Dialog DA7280 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280-haptic.
+
 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..8827711
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1452 @@
+// 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_MAX0x
+#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 DA7280_IRQ_FLAGS   (IRQF_TRIGGER_LOW | IRQF_ONESHOT)
+#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 mem_update;
+   u8 snp_mem[DA7280_SNP_MEM_SIZE];
+   const struct attribute_group **attr_group;
+};
+
+

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

2018-08-15 Thread Roy Im


From: Roy Im 

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

Signed-off-by: Roy Im 

---

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

diff --git a/MAINTAINERS b/MAINTAINERS
index 544cac8..720f9fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,6 +4221,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
@@ -4229,6 +4230,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 V1



[PATCH V1 2/3] Documentation: devicetree: input: new binding for da7280

2018-08-15 Thread Roy Im


from: Roy Im 

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

Signed-off-by: Roy Im 

---

 .../devicetree/bindings/input/dlg,da7280.txt   |   91 
 1 file changed, 91 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..759bcfe
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/dlg,da7280.txt
@@ -0,0 +1,91 @@
+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.
+- interrupts: IRQ line info for DA7280.
+  (See Documentation/devicetree/bindings/interrupt-controller/
+   interrupts.txt for further information relating to interrupt properties)
+- dlg,vib-mode:
+  "LRA-MODE" - Linear Resonance Actuator mode.
+  "ERM-BAR" - Bar type Eccentric Rotating Mass mode.
+  "ERM-COIN" - Coin type Eccentric Rotating Mass mode.
+- dlg,play-mode: choose one in below five modes.
+  "DRO-MODE" - Direct register override mode.
+  "PWM-MODE" - PWM data source mode.
+   In this case, user is able to set duty to 0 ~ 0x(0% ~ 100%)
+  "RTWM-MODE" - Register triggered waveform memory mode.
+   In this case, when enable this mode the pattern assigned
+   to the PS_SEQ_ID will be played as much times as PS_SEQ_LOOP.
+  "ETWM-MODE" - Edge triggered waveform memory mode.
+   In this case, external GPI(N) control are required to enable/disable
+   and it needs to keep device enabled by sending magnitude (X > 0)
+   the pattern assigned to the GPI(N)_SEQUENCE_ID below.
+   For more details, please see the datasheet.
+- dlg,nom-microvolt: Nominal actuator voltage rating.
+- dlg,abs-max-microvolt: Absolute actuator maximum voltage rating.
+- dlg,imax-microamp: Actuator max current rating.
+- dlg,impd-micro-ohms: the impedance of the actuator in micro ohm,
+  as read from its datasheet.
+
+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.
+- 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.
+- dlg,gpiN-seq-id: the GPI(N)_SEQUENCE_ID, pattern to play
+  when gpi0 is triggered, 'N' must be 0~2.
+- 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-MODE, default 205Hz.
+  the freq range: 50Hz ~ 300Hz.
+  It will be set to 205Hz if the value is out of range.
+- 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: use in case that memory registers should be updated,
+  Please fill the whole buffers(100 bytes) to avoid any error in driver.
+  For example,
+   dlg,mem-array = <
+   0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A
+   ...
+   0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
+   >;
+
+For further information, see device datasheet.
+
+==
+
+Example:
+
+   haptics: da7280-haptics@4A {
+   compatible = "dlg,da7280";
+   reg = <0x4A>;
+   interrupt-parent = <>;
+   interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+   dlg,vib-mode = "LRA-MODE";
+   dlg,play-mode = "DRO-MODE";
+   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;
+   };
-- 
end-of-patch for PATCH V1



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

2018-08-15 Thread Roy Im


from: 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 

---

 drivers/input/misc/Kconfig  |   12 +
 drivers/input/misc/Makefile |1 +
 drivers/input/misc/da7280.c | 1452 +++
 drivers/input/misc/da7280.h |  412 
 4 files changed, 1877 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..6e0de69 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -851,4 +851,16 @@ 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 && SYSFS) || PWM
+   select INPUT_FF_MEMLESS
+   select REGMAP_I2C
+   help
+ Say Y to enable support for the haptics controller on
+ Dialog DA7280 chip.
+
+ To compile this driver as a module, choose M here: the
+ module will be called da7280-haptic.
+
 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..8827711
--- /dev/null
+++ b/drivers/input/misc/da7280.c
@@ -0,0 +1,1452 @@
+// 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_MAX0x
+#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 DA7280_IRQ_FLAGS   (IRQF_TRIGGER_LOW | IRQF_ONESHOT)
+#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 mem_update;
+   u8 snp_mem[DA7280_SNP_MEM_SIZE];
+   const struct attribute_group **attr_group;
+};
+
+

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

2018-08-15 Thread Roy Im


From: Roy Im 

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

Signed-off-by: Roy Im 

---

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

diff --git a/MAINTAINERS b/MAINTAINERS
index 544cac8..720f9fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,6 +4221,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
@@ -4229,6 +4230,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 V1



<    1   2