msm: acpuclock-8064: Lower max L2 speed to 1134MHz

There are some testing showing that L2 at 1188MHz may cause
some stability issue. Therefore, lower the max speed to 1134MHz
unitl the root cause is found.

Change-Id: I694c9186128e4b5a679710280046630c0b632165
Signed-off-by: Tianyi Gou <tgou@codeaurora.org>
Merge "msm: acpuclock-8064: Lower max L2 speed to 1134MHz"
msm: timer: Use 32768Hz GPT and SCLK on 8064 family

On 8064 SOC family, a dedicated XO is derived to support
sleep clock at 32768Hz unlike 8960 SOC family where TCXO
divider was used with effective freq. of 32765Hz.

CRs-fixed: 462079
CRs-Fixed: 453095
Change-Id: I79142703c4ffac209f4dedeefebc235eeb8b140d
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
Merge "msm: timer: Use 32768Hz GPT and SCLK on 8064 family"
power: pm8921-charger: resume charging based on SOC

At EOC, the battery is disconnected from the charger and starts
discharging. This can result in SOC dropping to around 93% before
charging starts again.

Manually set the CHG_VBAT_DET threshold high to restart charging once SOC
drops below keep_charge_percent.

CRs-Fixed: 404909
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
(cherry picked from commit 14e8fa1e42c02ea643d16d3f833b5d8e1b5753e6)

Conflicts:

	arch/arm/mach-msm/board-8064-pmic.c
	arch/arm/mach-msm/board-8930-pmic.c
	arch/arm/mach-msm/board-8960-pmic.c
	drivers/power/pm8921-charger.c

Change-Id: Ic54ff2c14866c43b13edee03ad3c8084c1e1791d
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
(cherry picked from commit 1437c79c48893ca2883d99871c7fd9f10604ee42)

Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-charger: make usb_max_current configurable

Allow the module parameter to be configurable through the board
files. This gives another option to set the usb_max_current
setting if userspace is not able to set this during
bootup.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 8e67275cb440be560830089fabc0201eb5830c9e)

Conflicts:

	drivers/power/pm8921-charger.c

Change-Id: I0a8ea4ed5d97cdbadeba55fe3c489eefc2290f86
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
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
(cherry picked from commit 1e3a82fb0a651fdef1e76ca36dd4ca5f5628b92d)

Change-Id: I3ee33df6119f6385a8cfc21acc13441d2eb928ab
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-charger: fix resume SOC check problem

The current code assumes that the battery state of charge (SOC)
increases or decreases by one percent. This is not so. The check
for resume charging could fail and we might enter a condition when
the SOC is lower and we might not resume charging.

Fix it by checking whether we have crossed resume SOC threshold.

While at it there is also an issue where we might not resume
charging if the charger was plugged out before end of charge but
above vbatdet threshold, if the charger is inserted back again
it might not resume because the current algorithm seeks for a
drop in SOC. Update the check to only lookout for a SOC less
than resume percent and if the charging is not in progress.

Change-Id: I8cac84296ddb1e323f28e2476f78d0190f4a1b73
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-charger: fix EOC worker not starting

There are situations when we observe that charging is in progress
but the end of charge (EOC) worker is not running. This leads to
problems like
-never detecting end of charge
-not adjusting vddmax
-not preventing suspend while charging.

The reason is that the bootloader could have started charging already,
causing a fastchg interrupt to not happen. If the fastchg interrupt is
missed the driver will never start EOC worker.

Check the real time status of the fastchg interrupt and if it is fast
charging invoke the handler so that the eoc worker could be
started.

CRs-Fixed: 393301
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 7f1d97fd69c3afe66577e731105207e5db544ab2)

Change-Id: I46c0b6bc7ab9b5ada8c6f30febffff501cadd7ab
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
power: pm8921-charger: Support multiple vbus requests

ACA chargers can generate multiple vbus current draw requests
based on the number of USB peripherals connected to the dock.
Handle this by allowing runtime modification to the max target
current limit.

CRs-Fixed: 427933
Change-Id: Ie508a85bbbe129d77af48c05235376779d799128
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Merge "power: pm8921-charger: resume charging based on SOC"
Merge "power: pm8921-charger: make usb_max_current configurable"
Merge "power: pm8921-charger: add USB soft trim procedure"
Merge "power: pm8921-charger: fix resume SOC check problem"
Merge "power: pm8921-charger: fix EOC worker not starting"
Merge "power: pm8921-charger: Support multiple vbus requests"