Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69387742 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg: add support to reset FG when a lockup is detected



Currently when IMA errors are seen, IACS clear sequence is run to
recover from that condition. However, that is not sufficient if
FG HW algorithm itself is found to be locked up and if it had
acquired SRAM access. Detect such conditions and run an error
recovery sequence which does a FG reset. Since this wipes out
SRAM registers that were configured before, save and restore
them to get back closer to a reasonable state.

Backing up SRAM registers happens every time update_sram_data()
work is run and no IMA errors were seen. If the profile is loaded
already once, then it will be restored after the error recovery
sequence completes battery profile loading.

FG lockup is detected based on the following condition. Bit 7
of IMA_OPR_STS is set continuously and FG_SOC_ALG_ST register
reads the same value for a period of 200ms.

FG reset sequence is performed as below.
- Disable the FG SOC interrupts
- Cancel all the works to suspend FG SW algorithms
- Save the last capacity
- Acquire IMA access forcibly from FG_ALG
- Release IMA access to allow FG reset
- FG reset
- Initialize FG SRAM registers as per the specified configuration
- Load battery profile, which includes FG restart
- Restore last SOC
- Enable the FG SOC interrupts

As the above operation requires a secure write to a register in
FG_SOC peripheral, add an API for it.

FG reset on lockup detection is supported by a module parameter
named reset_on_lockup.

CRs-Fixed: 962694
Change-Id: I0be045d7deacd2e97530f6116ee5156ab476a162
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 1906d4e7
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment