Commit Graph

1094001 Commits

Author SHA1 Message Date
Fenglin Wu
a7691a0f8e input: qcom-hv-haptics: reset haptics module if it's stuck in SWR mode
The haptics module would get stuck in SWR mode if SWR port is
disconnected during SWR play, and this can happen if ADSP SSR
(subsystem reset) is triggered when playing in SWR mode. This
stuck condition can be detected by checking if haptics module
has already been in SWR mode when swr-haptics driver requests
to enable SWR haptics. When it's detected, ignore SWR mode
temporarily and toggle HAPTICS_EN for a HW reset. When SWR play
is attempted again i.e. when swr_haptics driver request to turn
on SWR slave device, SWR mode would get re-enabled.

Change-Id: Ie55d331e3c689972b42dd9688f0d2b182b3fd282
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:13 -07:00
Fenglin Wu
d4607df438 input: qcom-hv-haptics: Ignore checking HBoost status when SWR is playing
HBoost would be kept on when triggering a non-FIFO play with SWR playing
in the background, there is no need to wait HBoost to be ready hence bypass
the HBoost ready check in this case.

Change-Id: I68c4a97d1c5953fb5dc0dd53fa8792a02df4b3de
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:13 -07:00
Fenglin Wu
23895eba21 input: qcom-hv-haptics: update LRA frequency detection sequence
Update following settings in LRA frequency detection sequence according
to HW recommendation:
  1) Increase to 6 drive cycles before enabling High-Z period for auto
     resonance config.
  2) Disable adaptive drive duty function.

Change-Id: I551974603c99fcdad5d38fdef6edf15746c0033e
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:12 -07:00
Fenglin Wu
f0d2102bf1 input: qcom-hv-haptics: check playing effect pointer in IRQ handler
When uploading a constant effect after stopping FIFO play, the effect
pointer in haptics_play_info structure will be set to NULL. If there
is any pending fifo-empty IRQ gets served after that, it will trigger
a NULL pointer dereference issue. To avoid this, check the playing
effect pointer before use it in the IRQ handler.

Change-Id: Iacfea5e48d0a9519fa2c930ec821e395c43b6281
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:12 -07:00
Fenglin Wu
6e93432c87 input: qcom-hv-haptics: ensure HBoost is ready before the play
HBoost is required to be in disabled state before triggering the play.
Check this through DTEST1 signal and ensure the HBoost is ready before
serving a new vibration request.

Change-Id: I0d4b73fef39aa6da15abbb832369579221665d07
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:11 -07:00
Fenglin Wu
1116978168 input: qcom-hv-haptics: config interrupt in haptics_set_fifo()
Currently, haptics_fifo_empty_irq_config() uses a mutex lock and it's
called from playback() of input framework which is from an atomic
context. Fix this by moving it out of haptics_playback() and call it
from haptics_set_fifo() which gets eventually called in upload().

With this change, the irq_lock mutex is no longer needed because all
the calling paths of haptics_fifo_empty_irq_config() have been protected
by the mutex lock defined in haptics_play_info structure, hence remove
it.

Change-Id: I4e4d353f8427fb279fd3f4d6a28737acbdb22a0a
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:11 -07:00
Fenglin Wu
2d78e72322 input: qcom-hv-haptics: toggle HAPTICS_EN bit before playing FIFO
When FIFO samples are played back to back along with SWR mode, there is
a chance that FIFO samples won't get flushed out if they're not fully
played before FIFO mode is stopped. When this happens, FIFO samples gets
accumulated leading to overflow after which FIFO mode stops working.
Only way to recover from this is to toggle HAPTICS_EN_BIT before
starting FIFO mode playing again. While at it, add logs to print out
FIFO real time fill status which is helpful for debugging.

Change-Id: I07cd9ac34ad5ccfe7011850db554ba727f568482
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:11 -07:00
Fenglin Wu
72e5413d75 input: qcom-hv-haptics: keep FORCE_VREG_RDY always set in non-HBoost case
FORCE_VREG_RDY bit can be always set when non-HBoost regulator is used
and don't clear it when stopping play in non-HBoost case. Also set this
bit in driver initialization in non-HBoost case so that swr-haptics
driver can take the advantage of triggering SWR play without setting
this bit.

Change-Id: I6283396d9d5a4f0b87d87932d6db2d8e7bb7a623
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:10 -07:00
Fenglin Wu
19b7ad347f input: qcom-hv-haptics: fix out of bound of FIFO samples array
When calculating play length for FIFO play, it is out of bound
of the FIFO samples array. Fix it.

Change-Id: I8ad458802a0070f493ac53160ab90a6cf648d9e7
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:10 -07:00
Fenglin Wu
883ca13501 input: qcom-hv-haptics: add mutex lock for FIFO play
When stop command comes during FIFO refill, it would free custom_effect
FIFO sample memory and set the pointer to NULL, and this would cause
the NULL pointer dereference during FIFO refill. To fix this, add a
mutex lock between FIFO stop and FIFO refill sequence to avoid a race.

Change-Id: I8792c2183f06e84fca3a7c4dddfed667b25f2528
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:09 -07:00
Fenglin Wu
f1cd3fe57e input: qcom-hv-haptics: add support to operate from non-HBoost regulator
By default, haptics module is supplied from HBoost module and it
talks to HBoost module in hardware to get an appropriate operating
voltage. Haptics module can also be supplied from non-HBoost regulator
and it requires software to request the voltage.

Add support to operate haptics under a fixed voltage from a non-HBoost
regulator. Make the following modifications:
  1) Set voltage and enable the regulator before enabling the play.
  2) Force VREG_RDY signal in haptics module before enabling the play.
  3) Scale the DIRECT_PLAY amplitude to achieve appropriate output
     voltage in constant playing.
  4) Scale the DIRECT_PLAY amplitude instead of Vmax setting for
     gain setting in constant playing.
  5) Adjust the LRA impedance detectability according to the regulator
     output voltage.

Change-Id: If832b6512d7641ad3d271bb68f4bdb7dbb90a5c5
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:09 -07:00
Fenglin Wu
19152cdd28 input: qcom-hv-haptics: switch API to trigger PBS for ISC configuration
SW trigger for PBS to configure ISC in LRA detection doesn't need to
pass any parameter or wait on any condition including checking status.
Hence switch using qpnp_pbs_trigger_single_event() instead of
qpnp_pbs_trigger_event() to trigger PBS.

Change-Id: I8b252e293265994976924435f8a6a11d9b463119
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:08 -07:00
Fenglin Wu
be0172dabf input: qcom-hv-haptics: correct register values when toggling RC_CLK_CAL
Correct register values when toggling RC_CLK_CAL for playing haptics in
HBoost open loop case.

Change-Id: Ia48ab3af93181c61ec719716634e94a819353c8b
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:08 -07:00
Fenglin Wu
01f0d334a8 input: qcom-hv-haptics: only use 4-byte writes when refilling FIFO
The haptics module supports writing FIFO samples using 4-byte burst
mode as well as 1-byte mode. During FIFO refilling, if a 1-byte write
was used, then the hardware would fill zeros automatically after that
to keep the FIFO data 4-byte aligned. When this happened in the middle
of playing, the hardware inserted 0 values would cause spurs on the
haptics output. To fix this, only use 4-byte burst writes during FIFO
refilling until the end of the play.

Change-Id: I0441942585e0e0d5da62ec4a7123b2763b292739
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:08 -07:00
Subbaraman Narayanamurthy
155e0147ff input: qcom-hv-haptics: Disable haptics module during suspend
To help with power savings, disable haptics module when the device
enters suspend and enable it when it exits suspend.

Change-Id: I8956be849b876a2b514c1de49f8ff447267d28a1
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:07 -07:00
Fenglin Wu
75cf6e2792 input: misc: qcom-hv-haptics: disable auto resonance for FIFO streaming
Auto resonance needs to be disabled for FIFO streaming mode. Hence
disable it when playing custom FIFO data.

Change-Id: I11bb2e944bebf642b780b964bdea7907cae3c843
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:07 -07:00
Fenglin Wu
368406daae input: qcom-hv-haptics: add LRA impedance detection support
Add support for detecting LRA impedance. The detection is done using
following procedure: set ISC to 250 mA and Vmax to 10 V, then sweep
the duty cycle using binary approach based on the SC_FAULT status until
reaching to the last step. The impedance can be only detected between
a range and the resolution depends on the sweeping steps. Currently,
total number of steps used for calculating LRA impedance using
approximation is 5 which can achieve an accuracy of 1.25 Ohms.

This detection is only available for PM8350B 2.0 chip and it can be
triggered using command:
    echo 1 > /sys/class/qcom-haptics/lra_calibration

After that, the result can be read out using command:
    cat /sys/class/qcom-haptics/lra_impedance

Change-Id: I7edc00ecdb019ccf7ca5af459dec8105834706f5
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:06 -07:00
Fenglin Wu
cdd93c2f17 input: qcom-hv-haptics: toggle CAL_EN mode if HBST is in open loop
When RC_CLK_CAL_EN is set in auto mode while haptics boost is working
in open loop, the first cycle of the vibration would be played
incorrectly because the haptics module couldn't get enough clock count
before the play gets triggered. Fix this by toggling the RC clock
calibration mode from disabled to auto mode.

Change-Id: I80b3c48b9bb508b12841a679eafa2c618771edf2
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:06 -07:00
Fenglin Wu
8c72c8fead input: qcom-hv-haptics: read CAL_TLRA_CL_STS from SDAM after boot up
During LRA frequency calibration, reading CAL_TLRA_CL_STS has to be
done before de-asserting play. In the boot up LRA frequency calibration
sequence, CAL_TLRA_CL_STS was read out and stored in SDAM module
registers by the bootloader. Later, HLOS haptics driver can read it from
there and use it for calculating LRA frequency. This boot up LRA
frequency calibration sequence is only available for PM8350B 2.0 chip.
Update the driver to support this.

Change-Id: I0b81e79bad57160f9c79e01151e2d4060b4bbd41
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:05 -07:00
Fenglin Wu
bc5fd27b2b input: qcom-hv-haptics: update RC_CLK_CAL_COUNT calculation
RC_CLK_CAL_COUNT is the calibration count used in manual RC_CLK_CAL
mode when playing FIFO patterns. For haptics module in PM8350B 2.0,
there are new equations recommended to calculate RC_CLK_CAL_COUNT
based on CAL_TLRA_CL_STS and LAST_GOOD_TLRA_CL_STS status to achieve
better accuracy. Update the driver to support this.

Change-Id: I983c1b1f284006847549d2b3d23a0c1039f8b4c1
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:05 -07:00
Fenglin Wu
ab3f9346d3 input: qcom-hv-haptics: update LRA period calculations
There is a new scheme recommended in PM8350B 2.0 haptics module for
getting close-loop LRA period. There are 4 situations need to be
considered depending on if auto mode RC CLK calibration is used
and if auto resonance calibration is done during the playing. In
each situation, different status values and equations are used for
calculating close-loop LRA period. Update the driver to support this.

Change-Id: I8f5fdcdd3ebae71af333a0b05fb4860e1c43ce10
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:05 -07:00
Fenglin Wu
8a32254027 input: qcom-hv-haptics: notify HBOOST to keep VREG on during play
HAPTICS module controls the output voltage of HAPTICS_BOOST module
through hardware signals when playing a vibration. During FIFO mode
playing, HAPTICS module would request HAPTICS_BOOST module to turn
on/off the output based on FIFO empty status. HAPTICS_BOOST is turned
off when FIFO is empty and it's turned on again when more FIFO samples
are filled.

During this voltage transition request (off->on), HAPTICS_BOOST module
may have a race condition if this requests comes in rapid succession.
This can lead to its FSM getting stuck. To avoid this race condition,
notify HAPTICS_BOOST module to keep the output enabled until the
playing is stopped. This is done by triggering a PBS sequence through
a SDAM module.

Change-Id: I5cef13df7a1fa4608dd64d509c802e0bcfde6b92
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:04 -07:00
Fenglin Wu
5850a67068 input: qcom-hv-haptics: set effect to NULL in constant playing
In constant waveform playing, there is no need to use an effect data
structure to capture the current playing effect, hence set it to NULL.
This also helps the set_gain() callback to use the correct Vmax when
it's called in constant playing case. Also add a debug message to show
the Vmax setting.

Change-Id: I763ec7407b8696300dbe93f5e6935900544e75a8
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:04 -07:00
Fenglin Wu
6050776464 input: qcom-hv-haptics: Update sequence of reading STATUS_DATA
Per HW recommendation, when reading HAP_CFG_STATUS_DATA registers,
MOD_STATUS_XT.SEL need to be written first to select the right mux,
then update MOD_STATUS_SEL register so haptics module can present the
desired status values into STATUS_DATA registers.

Change-Id: I24205072074ff75b25b42c752333b5f99d83d067
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:03 -07:00
Fenglin Wu
e678995484 input: qcom-hv-haptics: clear HW faults before enabling play
If there was any HW fault generated in previous playing, it would
be retained until writing the FAULT_CLR register. Clear the HW faults
before triggering play to make sure it won't be started with any
retained fault status.

Change-Id: Ibac0e1ed3c745efeb5048845a073605642d8407d
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:03 -07:00
Fenglin Wu
9794c4dbeb input: qcom-hv-haptics: adjust frequency calibration sequence
Adjust following settings in frequency calibration sequence according to
HW recommendation:
 1) Use 50% auto resonance detection error window.
 2) Play for 150 ms before reading the calibration result.

Change-Id: Id43376f6878daedaf98b1d9065a3b0b363314add
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:02 -07:00
Subbaraman Narayanamurthy
50982ecf58 input: qcom-hv-haptics: Fix a possible NULL pointer dereference
Use Vmax from play effect in haptics_set_gain() only if the effect
is valid. Otherwise, use Vmax from the haptics configuration instead.

Change-Id: I7ec0f8c869096bccb26f7fda0057e3db3a51225d
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
2022-05-25 14:54:02 -07:00
Fenglin Wu
55eb147a56 input: qcom-hv-haptics: restore RC calibration mode after FIFO playing
Auto RC clock calibration is used as default configuration. When playing
FIFO streaming data, manual RC clock calibration is used for adjusting
the FIFO pattern based on the detected LRA frequency. Restore back to use
auto RC clock calibration after FIFO pattern is played.

Change-Id: I335552cfeafe559aa35a76bf6aa218a92b62d3db
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:02 -07:00
Fenglin Wu
bb4c542b49 input: qcom-hv-haptics: Deglitch fifo-empty interrupt
Check INT_RT_STS in FIFO empty IRQ handler and ignore the interrupt
if FIFO_EMPTY real time status bit is not set.

Change-Id: I7a276fa1d8c79d530fc26f74263e0608096a99f8
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:01 -07:00
Fenglin Wu
1f31666769 input: qcom-hv-haptics: update drive waveform data format
Use 2's complement data format for driving pattern waveform because
the pattern/FIFO samples used in the driver are all having unsigned
data type.

Change-Id: Ib0f7c1c7fe272068177237821debbd3cc1ad4ec8
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:01 -07:00
Fenglin Wu
c6ebd39a1e input: qcom-hv-haptics: detect 5V variant and update gain setting
PM8350B has a variant which only supports haptics with Vmax up to 5V.
Detect this variant and update Vmax settings accordingly to make sure
the gain setting change can be correctly reflected.

Change-Id: I916fba21d8a441b9e95edeef5af715d451ba70cf
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:00 -07:00
Fenglin Wu
6daa29c301 input: qcom-hv-haptics: adjust T_LRA for auto RC CLK calibration case
When auto RC clock calibration mode is selected, the 32.768 KHz sleep
clock is used as the reference clock but the hardware module assumes
the reference clock is 32 KHz. This results in inaccuracy on output
drive frequency. Correct this by scaling the LRA period using a factor
of 1.024 in auto RC clock calibration case.

Change-Id: I1d4f6cb90c00ffbd9932928e64666a2122d8d4af
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:00 -07:00
Fenglin Wu
c834c967bf input: qcom-hv-haptics: check FIFO fill status before stopping play
Check the FIFO real time fill status and only stop FIFO playing in
FIFO empty interrupt handler after confirming all FIFO samples have
been played.

Change-Id: I634f424c960893e22456734f30ae28f5030ca9e1
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:54:00 -07:00
Fenglin Wu
0368a68e2e input: qcom-hv-haptics: Add debugfs files for more brake settings
Add debugfs parameters per effect to enable brake and brake sine
waveform gain setting. Meanwhile, change to print the FIFO samples
with signed magnitude values so that they can be used offline to
plot pattern waveform.

Change-Id: Iaeeeedbba570333c8c4fa9793e2b4e9c1b4af09a
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:59 -07:00
Fenglin Wu
8dce088a14 input: qcom-hv-haptics: Add LRA frequency calibration interfaces
Add interfaces to run calibration sequence and read out the closed
loop LRA frequency. With this change, the closed loop LRA frequency
can be read out using following commands:

    echo 1 > /sys/class/qcom-haptics/lra_calibration
    cat /sys/class/qcom-haptics/lra_frequency_hz

Meanwhile, correct the setting for direct play, it expects a 8-bit
value to represent the proportion of vmax instead of the actual vmax
voltage.

Change-Id: I9f3bfb978240ca853446dee4877d6ece4b465058
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:59 -07:00
Fenglin Wu
1af05bc261 input: qcom-hv-haptics: set auto resonance when loading effects
Set auto resonance when loading effect according to the effect
settings.

Change-Id: I8dc9ac99a57e396d67da28ae7b1eb31813ab3362
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:58 -07:00
Fenglin Wu
6992edc015 input: misc: qcom-hv-haptics: check nvmem before using it
Currently, nvmem device is used to store closed loop brake settings. If
nvmem-cells is not specified for closed loop brake, then nvmem device
can be NULL. For such case, skip updating closed loop brake settings by
not writing to the nvmem device.

Change-Id: I18d455814f3731af519949f21a3a553bd1692548
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:58 -07:00
Shyam Kumar Thella
d768902aed input: qcom-hv-haptics: add RC clock calibration for FIFO mode
As per the hardware documentation, adjust T_LRA using RC clock
calibration when playing in FIFO mode with play rate not less than
8 KHz. Based on the closed loop T_LRA, adjust the open loop T_LRA
specified in the device tree and use it in the calculation.

Change-Id: I5197bd04051c2aaab38c5ff5f37a47e0ef4b48d3
Signed-off-by: Shyam Kumar Thella <sthella@codeaurora.org>
2022-05-25 14:53:58 -07:00
Fenglin Wu
1f89f3b09d input: misc: qcom-hv-haptics: Add support to play custom waveform
Custom waveform with FIFO data samples and play rate setting would
be passed down from userspace through custom_data memory in periodic
effect data structure. Load the waveform into FIFO memory and play
it using FIFO mode.

Change-Id: I26b78df809efbe398c91c89394152caebafbe1b6
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:57 -07:00
Fenglin Wu
7cec6589d2 input: qcom-hv-haptics: store closed-loop brake settings into SDAM
Read the closed-loop brake calibration settings from status register
and store them into a SDAM register for hardware to re-use them after
system reboot.

Change-Id: I9068559fffba58927eefc140ed58afc054257b22
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:57 -07:00
Fenglin Wu
326c01c11c input: qcom-hv-haptics: limit play rate for PM8350B v1 hardware
Due to a hardware limitation, PM8350B v1 cannot play more than 8 KHz as
it has a FIFO size of 104 bytes. Hence limit the play rate for PM8350B
v1 to 8 KHz.

Change-Id: Ibeabd4c0229a54e2d99023c8fbc5970b1a7a1e64
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:56 -07:00
Fenglin Wu
6679b3b4e6 input: qcom-hv-haptics: update FIFO samples in IRQ thread
Instead of sending a completion from the IRQ thread to notify a
worker thread to update the FIFO samples, update the samples in
the IRQ thread directly. This should help achieve lower latency
which is good for FIFO playing.

Meanwhile, following changes are made for FIFO playing:
 1) Defer stopping command into erase() function if it's coming
    before all FIFO samples are played. This gives the hardware
    a little more time to play before stopping.
 2) Restore FIFO play rate to T_LRA after playing is done according
    to hardware recommendation.

Change-Id: I7b21589641d753d45b1261ce0e342373c249f4e5
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:56 -07:00
Fenglin Wu
e64d358465 input: qcom-hv-haptics: Add a property to specify FIFO empty threshold
In FIFO mode playing, when the number of samples in the FIFO memory
is less than the FIFO empty threshold, an interrupt is triggered for
notifying the driver to refill the FIFO memory if there is still any
samples pending to be played. FIFO empty threshold can be a tuning
parameter for the driver to refill the FIFO memory timely before the
hardware drains out the FIFO samples to avoid an intermittent pause
in vibration effect. Add a DT property to specify FIFO empty threshold.
Also, expose it under debugfs for modifying it runtime.

Meanwhile, return proper values when creating debugfs nodes failed.

Change-Id: I3ac9e6210173ab6878b4487959bc4b3fc3f20ab0
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:56 -07:00
Fenglin Wu
08e6fb57aa input: misc: qcom-hv-haptics: Add support for V2 HW module
HV-haptics module with V2 revision supports 640 bytes FIFO memory and
each byte contains a FIFO sample. There are 4 adjacent SPMI registers
which can be used for filling 4 FIFO samples together by using SPMI
burst writes and also a single register for filling FIFO samples while
the samples are less than 4.

Also update the logic of writing FIFO samples: Check the available
FIFO memory first and then write FIFO with samples no more than the
available FIFO memory space. With this new logic, it's not necessory
to read FIFO_READY_STS register before writing FIFO samples and this
helps on reducing FIFO writing latency.

Change-Id: If65a81327dfd2c6af0d58055c0ae93ad6c1dcba0
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:55 -07:00
Fenglin Wu
8f9d499001 input: qcom-hv-haptics: Add a regulator device to control SWR slave
Add a regulator device for swr-haptics driver to control the reset
behavior of the SWR slave in haptics module.

Change-Id: I810428e7f8aad3ff73a31b20067d434b3ac01da2
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:55 -07:00
Fenglin Wu
0bfa6b4fc7 input: qcom-hv-haptics: ignore parsing non-effect subnodes
Only parse effect subnodes which have qcom,effect-id property.

Change-Id: I70b2c1401bbf7d5238de818ac5b6ed55943a19f6
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:53:54 -07:00
Fenglin Wu
9f3a5f2187 input: qcom-hv-haptics: correct pattern source checking logic
The pattern source check before loading predefined effect is incorrect.
Correct it.

Change-Id: I8026f6ee24ce17dfe43bc514eeb526300af99746
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:52:36 -07:00
Fenglin Wu
0460c5ea34 input: qti-hv-haptics: Add debugfs parameters to configure effects
Add debugfs parameters to configure different settings per haptics
effect which is useful for testing.

Change-Id: Iace6dab1ca11cad20d5b44eaf81e704053bc3e0b
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:52:24 -07:00
Fenglin Wu
d42848ae19 input: qcom,hv-haptics: Add DT definitions
Add DT definitions for a few properties that are used to specify
haptics hardware configuration and vibration effect settings.

Change-Id: Icd9da49e87eca9c865e7f6add5638842c20a3bd6
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:51:43 -07:00
Fenglin Wu
5ef7f0d84f input: misc: Add initial driver to support QTI HV haptics
QTI HV (High Voltage) haptics is a module which can play haptics
effects for LRA or ERM with drive voltage up to 10 V. It has
several pattern sources built inside and each pattern source can
be used for playing different vibration effects.

Add the driver to support QTI HV haptics module, which will be
registered as an input FF device and can be controlled by calling
read/write/ ioctl APIs on the input device node.

Change-Id: I8323bdf3f7a631570604577719d5b7876fc65ef1
Signed-off-by: Fenglin Wu <fenglinw@codeaurora.org>
2022-05-25 14:49:19 -07:00