vibrator: Add new msm8974 pwm vibrator driver

msm8974_pwm_vibrator: Improve the accuracy for duration
When you press 2 more touches simultaneously, vibration would be weak.
This is the reason why the driving state is not gauranteed.
If the vibrator is already in the driving state. just keep going
for the driving force.

Change-Id: Iea3f1b4895d0798b0465eaa16b83381c6f4ae914
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm8974_pwm_vibrator: Fix the negative remaining timeout
It's possible that hrtimer_get_remaining() returns the nagative value.
It causes the unintended behavior in the delayed workqueue scheduling.
So if the value is native, it means the timer has been already expired.
We just set the delay to 0 in this case.

And use the monotonic timer for the time stamp.

Change-Id: Ia16433d6c2715875f2d6f9da14e8e39824c15aa7
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm8974_pwm_vibrator: Add sysfs for vibrator tuning
Change-Id: I6ca3326523fe4e3c6505985f77cf1b91c41fb8b8
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm8974_pwm_vibrator: Enhance the feedback feeling
Add the braking/driving force feature to enhance the feedback feeling.
The braking avoid the residual vibration. The driving force enhance
the feedback feeling.

Change-Id: I0f7c40f5579f9ce014057a481d128d4f7d830a9a
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm8974_pwm_vibrator: rework for vibration start/stop
To be flexible, we use the delayed workqueue instead of usleep.
And the driver already support for vibrator stop. So We don't need to stop
it repeatedly. We need a force stop only when upperlayer send a stop signal
during vibing.

Change-Id: I6940119924f6b6919453fde60dc56cb7eb46aa39
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm8974_pwm_vibrator: Clean up codes
Change-Id: I5ef3bb3bf21f438712de7fe7e63e368707bc890c
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm8974_pwm_vibrator: Use the dedicated workqueue
Use the dedicated workqueue for quick response. There may be some delay
for the other workitem schedule when we use the system workqueue.

Change-Id: I0ba7269f6dfd12b177a2fe1b1329cbef169f6859
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm8974_pwm_vibrator: Improve the haptic response
Remove the unnecessary using atomic values. and Fix the incorrect clock
control.

Previously the driver controlled the clocks in atomic. But the clock
control might be sleepable. So use mutex instead of spinlock for locking.

Change-Id: I8fe1b1e39973d9d8b5505c02491bfabea731d3c3
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm8974_pwm_vibrator: Fix the vibrator on/off sequence
Remove the unnecessary ROOT_EN register control. And set UPDATE register
only when the vibrator is enabled. Turn on the power before controling
vibrator and turn off the power after.

Change-Id: I17093ff1c468ce4712f279b77c7e67e7d012a926
Signed-off-by: kwangbum.kim <kwangbum.kim@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm_pwm_vibrator: Do not set the regulator voltage
The voltage is board specific. So it should be set via the device tree
or the regulator init on board specific init.

Change-Id: I28d24f2a539cdf193eb8e6afcafc150a543efcfa
Signed-off-by: Kwangbum Kim <kwangbum.kim@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm_pwm_vibrator: Turn the PWM off when vibrator off
When vibrator finishes to work, the PWM is still alive.
Turn the PWM for vibrator off using MMSS_CC_CAMSS_GP1_CBCR.

Change-Id: I64bdb9a42b6d6543fb326a3d99d872a749a77e43
Signed-off-by: kwangbum.kim <kwangbum.kim@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm8974_pwm_vibrator: Tune the vibrator
Use MDN divider and normalize the amp value (available range is 0~100).
And improve the error handling.

Change-Id: I1d699c4b2571b1ff403512ff7ead44550784f79d
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm_pwm_vibrator: Check the error codes in parse_dt
We should get the device specific information from device tree when
device tree is enabled. If there is an error in parsing device tree,
we need to handle that properly.

Change-Id: If44980a1c900c40554d70a678524e3ec805c06ca
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm_pwm_vibrator: Fix the compiler warning due to uninitialized variable
Change-Id: I0416d28df95dfa8819ec02a144f49cd8dcdab0c6
Signed-off-by: Devin Kim <dojip.kim@lge.com>

msm8974_pwm_vibrator: Remove CONFIG_OF
Change-Id: I96df18fa4fa9dd5ec08c17a09a87ee876a3a33e1
Signed-off-by: Devin Kim <dojip.kim@lge.com>

vibrator: Change message level (pr_info->pr_debug)
Change-Id: Iba3cf34473cf11a7b81d54f1242f0ea9f240a6b0

msm8974_pwm_vibrator: Add regulator control
Device would use vdd for power source. add regulator control for that.

Change-Id: Ida5879836f0a5d0765dc7eb016207e7523faf974
Signed-off-by: Devin Kim <dojip.kim@lge.com>

Signed-off-by: houst0nn <houstonn@gmail.com>