Commit Graph

132 Commits

Author SHA1 Message Date
a24c65a6ea msm5.15: Import ayn changes from ayn_8550.xz (01/18/2026)
Signed-off-by: AnierinB <anierin@evolution-x.org>
2026-01-19 09:53:56 +00:00
Jishnu Prakash
a2cc7ad8d4 input: misc: add check for number of input patterns in pattern_s_dbgfs_write
Add a check for number of input patterns detected in string read from
userspace in pattern_s_dbgfs_write() API, to avoid out-of-bounds write
in a local array.

Change-Id: Ic35561ae34f95c67fbd54ae4db4a7174342f45f4
Signed-off-by: Jishnu Prakash <quic_jprakash@quicinc.com>
2023-12-04 12:00:57 +05:30
xuanpeng
da6f5e0b56 input: qcom-hv-haptics: correct some printings
Correct some message printings.

Change-Id: Idb248134d6b8d640dfa938ac35fa042227405cd5
Signed-off-by: xuanpeng <quic_xuanpeng@quicinc.com>
2023-05-05 16:31:59 +08:00
Jishnu Prakash
093380bd44 input: qcom-hv-haptics: update driver's remove callback
Remove the call to input_ff_destroy from remove callback as
it is needed only in error path. This fixes an issue
where there is a crash from input_ff_flush() due to NULL
pointer dereference if haptics module is removed with
rmmod. In addition, add input_unregister_device() call
in remove callback to ensure proper cleanup.

This is the call stack for the crash:

 __mutex_lock+0x60/0x89c
 mutex_lock_nested+0x4c/0x5c
 input_ff_flush+0x3c/0xb4
 input_flush_device+0x64/0xb8
 evdev_cleanup+0xa4/0xc4
 evdev_disconnect+0x38/0x74
 __input_unregister_device+0x164/0x24c
 devm_input_device_unregister+0x24/0x78
 release_nodes+0x244/0x2cc
 devres_release_all+0x40/0x60
 device_release_driver_internal+0x288/0x3bc
 device_release_driver+0x1c/0x2c
 bus_remove_device+0x110/0x170
 device_del+0x324/0x500
 platform_device_unregister+0x34/0xb4

Change-Id: Ieae1ec1630c018b91dd8290143b9b3859be2b0c5
Signed-off-by: Jishnu Prakash <quic_jprakash@quicinc.com>
2023-01-22 13:20:29 +05:30
Hui Liu
23a87d4f7d input: qcom-hv-haptics: get hBoost base address before it's used
There is an issue introduced in commit b40e334321
("input: qcom-hv-haptics: update HW type detection logic") that
the hBoost module register address base is used before parsed
from device-tree. Fix it.

Fixes: b40e334321 ("input: qcom-hv-haptics: update HW type detection logic")
Change-Id: I801d09228b2483e45adb7e96eb883cbb40334dca
Signed-off-by: Hui Liu <quic_huliu@quicinc.com>
2023-01-17 16:37:06 +08:00
xuanpeng
47a878804a input: qcom-hv-haptics: remove cancel_work_sync() in haptics_set_gain()
Remove cancel_work_sync() as it would sleep on waiting work execution
but this is not permitted in haptics_set_gain(). Also it's fine to keep
any pending work because the work function has appropriate protection
for reentrance.

Fixes: 279ed1a5b9 ("input: qcom-hv-haptics: move set_gain() operation into a work")
Change-Id: Idf1f7eabd7ae391353de691cc8bc3707e09f4194
Signed-off-by: xuanpeng <quic_xuanpeng@quicinc.com>
2023-01-12 12:39:31 +08:00
qctecmdr
6f67896359 Merge "input: qcom-hv-haptics: move set_gain() operation into a work" 2023-01-06 23:17:28 -08:00
xuanpeng
279ed1a5b9 input: qcom-hv-haptics: move set_gain() operation into a work
In commit ba1e02b8f5b0("input: qcom-hv-haptics: poll HPWR_INTF status
after setting Vmax"), the mutex lock in haptics_play_info is used to
protect the data structure in haptics_set_gain(), and set_vmax() also
introduced a mutex lock and it's also called in haptics_set_gain().
However, haptics_set_gain() is running in an atomic context with
spinlock held and it shouldn't call any sleep function, hence, move the
set_gain() operation into to a work.

Fixes: ba1e02b8f5b0("input: qcom-hv-haptics: poll HPWR_INTF status after setting Vmax")
Change-Id: Ic2c95cb6dd6fc4646ac9038cdda0e311a3b71e62
Signed-off-by: xuanpeng <quic_xuanpeng@quicinc.com>
2023-01-06 13:21:51 +08:00
qctecmdr
09a7c3e0b0 Merge "input: qcom-hv-haptics: stop constant effect play with a timer" 2023-01-04 07:15:06 -08:00
xuanpeng
33b7318ce9 input: qcom-hv-haptics: stop constant effect play with a timer
Some of the application might not send stop command after triggered
constant effect play, stop the play when its play length is reached.

Change-Id: I87f8260af8b395c6f7616ec9f26a87e08129e0c0
Signed-off-by: xuanpeng <quic_xuanpeng@quicinc.com>
2023-01-04 12:30:16 +08:00
qctecmdr
cc879baa16 Merge "input: qcom-hv-haptics: update measured LRA impedance resolution" 2022-12-28 04:50:40 -08:00
qctecmdr
5f014b51d1 Merge "input: qcom-hv-haptics: poll HPWR_DISABLED status after stopping play" 2022-12-28 04:50:39 -08:00
Fenglin Wu
a3f910bbf5 input: qcom-hv-haptics: update measured LRA impedance resolution
Update the LRA impedance resolution in SDAM register which has been
updated to 250 mohm per LSB.

CRs-Fixed: 3351475
Change-Id: I2e7cea15594adb2e07899c32cc4bffdd3e73e187
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-12-28 10:40:36 +08:00
Fenglin Wu
87de0dd11a input: qcom-hv-haptics: poll HPWR_DISABLED status after stopping play
The haptics HW may be still driving after PLAY bit is deasserted,
especially when brake is enabled. Haptics HW would be still driving
output for brake sychronization and playing the brake patterns. If
haptics is configured to trigger another play at the same time, it
would cause HW problem, such as: If a FIFO effect with a high Vmax
setting is triggered while haptics is driving brake pattern right after
the DIRECT play is stopped, the high Vmax will be applied to the brake
pattern and it would cause the LRA overdriving.

To avoid this, poll HPWR_DISABLED status after the play is stopped to
guarantee that HW has fully stopped before trigger a new play.

Meanwhile, move the play disabling function to erase() hook because the
playback(0) is running in an atomic context and it couldn't call sleep
functions.

Change-Id: Ief7fe88b5b3ab3bbfe2eb69542e778062c544af8
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-12-27 16:18:51 +08:00
Hui Liu
82819dd0c4 input: qcom-hv-haptics: add three lost periodic configurations
Add three lost periodic configurations.

Change-Id: Ib064e2104d3ccd5755d7811435b033f942c566d3
Signed-off-by: Hui Liu <quic_huliu@quicinc.com>
2022-12-20 13:55:06 +08:00
Hui Liu
b40e334321 input: qcom-hv-haptics: update HW type detection logic
Currently, hw_type is used before it's been set when reading
revision registers, correct it.

Change-Id: Ic543d8d059492c6a6f656194319e49d2b1eba90e
Signed-off-by: Hui Liu <quic_huliu@quicinc.com>
2022-12-20 13:47:30 +08:00
Hui Liu
a31f7d319d input: qcom-hv-haptics: Disable ILIM before LRA impedance detection
Disable ILIM(cycle by cycle current limiting) before LRA impedance
detection for monaco.

Change-Id: I1eb019eae1aa46250cb6aa99db46013ae009179f
Signed-off-by: Hui Liu <quic_huliu@quicinc.com>
2022-12-08 10:41:10 +08:00
qctecmdr
739f2ca318 Merge "input: qcom-hv-haptics: Update haptics_parse_per_effect_dt()" 2022-12-02 00:22:40 -08:00
Anjelique Melendez
a6c2165127 input: qcom-hv-haptics: Update haptics_parse_per_effect_dt()
Update haptics_parse_per_effect_dt() to remove reading
"qcom,effect-id" property.

Change-Id: I18f362e8a02dbca6038b80e503050fe8574e3a5f
Fixes: f6c37c09587a ("input: qcom-hv-haptics: add support for primitive effect")
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
2022-11-11 17:45:41 -08:00
qctecmdr
8b05817b50 Merge "input: qcom-hv-haptics: poll HPWR_INTF status after setting Vmax" 2022-11-07 07:05:12 -08:00
xuanpeng
ba1e02b8f5 input: qcom-hv-haptics: poll HPWR_INTF status after setting Vmax
When Vmax setting is updated, haptics module would request corresponding
voltage from hBoost when the driving waveform is zero crossing. This
would take some time for the Vmax setting to complete. The voltage
requesting status is shown in HPWR_INTF register and it is expected to
be either HPWR_DISABLED or HPWR_READY. Haptics module can only switch
play mode or request another voltage change after that, otherwise the
haptics module may get stuck.

To address this, poll HPWR_INTF register for a period of 10 ms after
updating Vmax. If Vmax setting is not complete in that period, toggle
HAPTICS_EN to reset haptics HW from that stuck state. Also, add a mutex
lock for updating Vmax settings to avoid multiple requests interfere
with each other.

Change-Id: Ibcb37adad43d9814baaa5a97fc8799b8fd69aee9
Signed-off-by: xuanpeng <quic_xuanpeng@quicinc.com>
2022-11-07 09:28:07 +08:00
qctecmdr
359d06918d Merge "input: qcom-hv-haptics: Toggle EN_CTL for PM5100 v1.0" 2022-10-14 03:09:24 -07:00
Hui Liu
5e4979a192 input: qcom-hv-haptics: Toggle EN_CTL for PM5100 v1.0
This part of logic was missed when propagating the change 'commit
<3377e29a1222> ("<input: qcom-hv-haptics: Toggle EN_CTL for PM5100 v1.0>")'
so add it back as a separate change.

Change-Id: I06eb093fe012ddcabf6ec8657254d9c79eb95ada
Signed-off-by: Hui Liu <quic_huliu@quicinc.com>
2022-10-11 18:40:48 +08:00
Umang Chheda
3a268ac4a4 input: qcom-hv-haptics: Use pm_suspend_via_firmware() for DS
Replace using mem_sleep_current node to check for Deep Sleep(DS)
with pm_suspend_via_firmware() API for GKI compliance.

Change-Id: I628416aaf3a3a72cf3d029c154a64dff9d5f602c
Signed-off-by: Umang Chheda <quic_uchheda@quicinc.com>
2022-09-27 16:12:50 +05:30
Fenglin Wu
f728fbcd58 input: qcom-hv-haptics: clear HW fault after lra_calibration
HW faults may be happened after LRA calibration sequence, clear the
faults after the sequence to prevent any faults blocking next vibration
request.

Change-Id: I03004c83268b1d772c110c868ab9f93446f881f1
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-09-07 11:41:07 +08:00
Fenglin Wu
1a6e98f0d7 input: qcom-hv-haptics: update configuration for PATx_MEM mode
Disable auto resonance explicitly for PATx_MEM mode play according to HW
recommendation. Also, clear MEM_PAT_ACCESS_BIT after written PATx_MEM
samples and it reduces device quiescent current in power off state.

Change-Id: Iafaca15482bf1a03a19a49ee4d5e30faeb2fdeeb
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-09-06 11:22:22 +08:00
qctecmdr
9f24cccbcb Merge "input: qcom-hv-haptics: Update autoresonance registers for F0 calibration" 2022-09-01 03:55:13 -07:00
Anjelique Melendez
23bb0bc416 input: qcom-hv-haptics: Update autoresonance registers for F0 calibration
Update the register configuration for F0 detection/calibration
based on hardware recommendation.

Change-Id: I423ed84bf10508dc6ded2bc4248ac9ce396ce8cb
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
2022-08-30 14:50:21 -07:00
qctecmdr
74357158f5 Merge "input: qcom-hv-haptics: move predefined effect preload logging" 2022-08-18 20:40:54 -07:00
Hui Liu
a46013afb3 input: qcom-hv-haptics: move predefined effect preload logging
Move the logging after calculating Vmax so that the right Vmax value
can be printed out.

Change-Id: I8d916a13685c8d85f1363e7a8bc766aeb4d5e2ba
Signed-off-by: Hui Liu <quic_huliu@quicinc.com>
2022-08-17 17:28:37 +08:00
Umang Chheda
64592564c7 input: qcom-hv-haptics: Disable INT and module in shutdown cb
On SKUs with MSM + Co-proc there can be possiblity that
because of Interrupts enabled from MSM side (SPMI) the exit
of LPM might not work because PBS gets locked because of
which the sequence to exit LPM might not get triggered.

Add support for shutdown callback and disable INT in shutdown
cb to ensure that INT are disabled before entering LPM.

Change-Id: I29bafb72bef3a5591839015f2a598fa4ad85072a
Signed-off-by: Umang Chheda <quic_uchheda@quicinc.com>
2022-08-16 13:12:22 +08:00
Shyam Kumar Thella
3377e29a12 input: qcom-hv-haptics: Toggle EN_CTL for PM5100 v1.0
Toggle Haptics EN_CTL as workaround for HW issue in PM5100 v1.0.

Change-Id: I83e82f261d4185132bb5a721600950f90f71db3f
Signed-off-by: Shyam Kumar Thella <sthella@codeaurora.org>
2022-08-16 13:12:22 +08:00
Hui Liu
c39bb0aa60 input: qcom-hv-haptics: add support for primitive effect
Primitive effect is very similar to predefined effect
which has been supported and each primitive effect has
an unique id defined in "qcom,primitive-id" devicetree
property. Add support for it.

Change-Id: I4a03dd09e97f1b7988d4ab87e1cf78f075b05101
Signed-off-by: Hui Liu <quic_huliu@quicinc.com>
2022-07-27 10:46:08 +08:00
Kiran Gunda
9740630020 input: qcom-hv-haptics: Add support for DeepSleep/Hibernate
Free/request the fifo empty interrupt during the DeepSleep and
hibernate entry or exit respectively. Also restore the hardware
initial configuration done during the boot.

Change-Id: I6b0d4838a6d1c48869ca760d4e93788440983b3c
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
2022-07-27 10:46:08 +08:00
Kiran Gunda
9e264835da input: qcom-hv-haptics: Enable boot-up F0 calibration for PM5100
In the boot up LRA frequency calibration sequence, CAL_TLRA_CL_STS
is read out and stored in SDAM module registers by the bootloader.
Later, the HLOS haptics driver can read it from there and use it
for calculating LRA frequency. Enable the same for PM5100 PMIC.

Change-Id: Ia5e307e5d536a42b29ab05e9888640121188312c
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
2022-07-27 10:46:08 +08:00
Fenglin Wu
bd7497136b input: qcom-hv-haptics: move predefined effect preload logging
Move the logging after calculating Vmax so that the right Vmax value
can be printed out.

CRs-Fixed: 3227145
Change-Id: I17b64f9e3a230058b7e30ca4c30de4d3000d1f87
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-07-18 11:18:17 +08:00
Fenglin Wu
186f98b80b input: qcom-hv-haptics: ignore disabling hBoost when it's in open-loop
When hBoost is working in open-loop mode, it's supposed to be used by
other modules like the charger firmware and it shouldn't be turned off
by haptics driver. Ignore turning on and off hBoost in such case.

Change-Id: Id3eb2c37cf7316b4617872614cc2a7adc50d12d8
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-06-13 09:11:31 +08:00
Subbaraman Narayanamurthy
3ae7cf0d3c input: misc: qcom-hv-haptics: Fix print format identifier
Print in hex when a read/write to an address fails.

Change-Id: I35dddaa33d18f72079ec3d814a36fd304cd0f331
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
2022-05-31 19:38:42 -07:00
Fenglin Wu
008c2fe2c4 input: qcom-hv-haptics: update initial FIFO programming count
Update initial FIFO programming count to 320 which can help to reduce
vibration request latency.

Change-Id: If0e12dd626dda66a0b296b9832562bbeaee57fd9
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-05-16 15:39:06 +08:00
qctecmdr
c8763ce599 Merge "input: qcom-hv-haptics: force vreg ready base on VMAX_CLAMP notification" 2022-05-03 17:18:48 -07:00
qctecmdr
83d2296eec Merge "input: qcom-hv-haptics: update LRA_IMPEDANCE_MOHMS_LSB value" 2022-05-03 08:42:16 -07:00
Fenglin Wu
bc5b9ab5df input: qcom-hv-haptics: force vreg ready base on VMAX_CLAMP notification
When hBoost is enabled by the charger firmware, force-vreg-ready need
to be set before triggering haptics play. This applies to all play modes
including SWR play mode. Set it base on VMAX_CLAMP notification and
keep it until the charger firmware unvote VMAX_CLAMP which indicates
it's no longer using hBoost. This helps to trigger SWR mode play
correctly in such case from swr-haptics driver which has no SPMI
regiser access in there.

Change-Id: I0a318dd7c5e9d856e200264b11eaea184be15e50
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-04-27 18:38:28 +08:00
Fenglin Wu
6b61f5a040 input: qcom-hv-haptics: Add trace events for FIFO play
Add trace events to log down the FIFO play process for debug purpose.

Change-Id: I54671a0b6a1228351067db8b6a7a052d11d8d080
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-04-27 18:24:38 +08:00
Fenglin Wu
816332cfb4 input: qcom-hv-haptics: update LRA_IMPEDANCE_MOHMS_LSB value
Update LRA impedance measurement resolution to 250 mohms per HW
recommendation.

Change-Id: I31a588ed027674cc2fa081d611a4c96f6001a90b
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-04-27 14:32:21 +08:00
Fenglin Wu
a4039156db input: qcom-hv-haptics: parse devicetree effect in different functions
Split haptics_parse_per_effect_dt() into smaller functions for parsing
pattern, FIFO, brake settings from devicetree respectively.

Change-Id: I36a0e430752754a1e16b8f1acccc2f6f41ab8833
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-04-15 09:28:43 +08:00
Fenglin Wu
19240b09f6 input: qcom-hv-haptics: Add LRA impedance detection for new modules
Add LRA impedance detection for HAP520_MV and HAP525_HV haptics
modules. Both modules can support binary search based impedance
detection as before which relies on the short circuit comparators.
HAP525_HV module has added a new impedance detection comparator
which can be used to support realtime impedance measurement. Add
binary search based impedance detection for both haptics modules,
and also add realtime impedance measurement for HAP525_HV module
but use a devicetree bool property to keep it as optional.

Change-Id: I4cb3f5360084c2d3d36778bed4c8d878f3b465ad
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-03-22 18:56:41 +08:00
Fenglin Wu
2d2ebf5e40 input: qcom-hv-haptics: discard 1-byte FIFO write for HAP520
For haptics module with HAP520 HW revision, the HW would only read 1
valid byte in every 4 bytes if the 1-byte FIFO write clashes with the
FIFO read operation. To avoid this, don't use 1-byte write but just
pad zeros at end of the pattern to keep the samples 4-byte aligned
and always use 4-byte write for FIFO programming.

Change-Id: I3ebde0fe7378c0dcffb5c51e15e6ffaae5af3e29
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-03-21 16:40:19 +08:00
Fenglin Wu
45a383d91f input: qcom-hv-haptics: Update RC_CLK_CAL_COUNT calculation
The equations for calculating RC_CLK_CAL_COUNT need to be updated
when flag SLEEP_CLK_32K_SCALE is not set. Update it by introducing
a coefficient named as SLEEP_CLK_CAL_DIVIDER which is the divider
of the 19.2 MHz system clock to generate the sleep clock.

Change-Id: I75d16eca3fe160c425af5cf3545272e0d1999a8a
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-03-21 13:41:51 +08:00
Fenglin Wu
04e122df55 input: qcom-hv-haptics: Handle VMAX_CLAMP notification
Handle VMAX_CLAMP notification which contains a desired Vmax value when
hBoost is enabled by the charger firmware. Any vibration after this
notification should be set to a Vmax not higher than that to avoid
hBoost overloading.

Change-Id: I6fb1b66663df60041967e2cad0a914f57c310158
Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com>
2022-03-21 08:51:05 +08:00
qctecmdr
c3358ef5e5 Merge "input: qcom-hv-haptics: enable SW_CTRL_HBST workarounds for PM8550B V1" 2022-03-18 23:00:28 -07:00