power: pm8921-charger: add USB soft trim procedure

To improve accuracy of USB input current limits add
a soft trim procedure. This procedure subtracts codes
from the original trim value in the USB_OVP_TRIM
register based on the selected USB input current limit.

Note that the USB_OVP_TRIM is not reset if there is
a watchdog restart. In such cases we don't want to
overwrite a already corrected trim value. The trick
is to update the boot loader to save the original trim
value in register 0x10A and 0x09C and the kernel driver
to use that as the starting point instead of the
USB_OVP_TRIM.

Also note that we choose the value of 0xFF to indicate that
the driver has not yet read the trim value. The trim value
is only 6 bits and so 0xFF serves as an uninitialized value.

CRs-Fixed: 389937
CRs-Fixed: 418033
Change-Id: I445676d558e05a6c5e9dd1e76e80ba2f5e8cd6c1
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
1 file changed