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

Commit 6cbc0709 authored by Xiaozhe Shi's avatar Xiaozhe Shi
Browse files

power: qpnp-fg: fix memif register writes



There is currently a problem in the way the fuel gauge driver writes to
the SRAM through the memory interface. When the driver wants to write
something to the SRAM, it will configure the correct word address and
write to the corresponding byte in the memory interface data registers.

For example, if the fuel gauge driver wants to write to SRAM address
0x444 byte 2, it will configure the word address as 0x444 and write into
the DATA2 register.

This is not how the fuel gauge hardware operates. In the hardware
digital logic, writing to byte 3 of the memory interface data register
will cause the entire word to be written. So if software only writes to
bytes 2 and 3, bytes 0 and 1 will also be updated with whatever was left
over in the DATA0 and DATA1 registers. Furthermore, if the software
tries to only write to DATA0 and DATA1, the entire write will not go
through because DATA3 was never written to.

This can cause SRAM data clobbering, and randomly overwrite
many fuel gauge settings that were not meant to be touched.

Fix this by doing a memory read for the first and last data words in a
fuel gauge memory transaction, and masking the results with the new data
before writing it back into the SRAM.

Change-Id: I61cc5094f91df3308e216541f2f8a926d4a11e4a
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent 069f11cb
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