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>
Change priority of kernel message to avoid message flooding in logs.

kernel logs are flooded with info message from mdp4_overlay_mdp_perf_upd,
so changed the priority of message to debug.

Change-Id: Ia2ac181477ddc18df358a9419d6317e6122600d0
Signed-off-by: Sangani Suryanarayana Raju <csuryan@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>
hwmon: pm8xxx-adc: Vote for a PMIC clock buffer

Incorrect PMIC_THERM/XO_THERM readings are seen when
the XO clock is disabled.

The internal PMIC therm relies on the PMIC band gap
reference which in turn is enabled when any of the
PMIC clock buffers are enabled. The XO_THERM relies
on the VREF_XO as its reference source which gets
enabled when any of the PMIC clock buffers are
switched on. Therefore vote for a clock buffer when
a PMIC_THERM/XO_THERM is requested.

CRs-Fixed: 392602
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
(cherry picked from commit f9dfe1b7b70b634422fbbbf65756aa997536bd33)

Change-Id: I37cae177baa34e80ec739dd01a182e401ea1c812
Signed-off-by: Vivek Panwar <vpanwa@codeaurora.org>
Update copyright to The Linux Foundation

Change-Id: Ieaf8d24c36b87db12cc4f8584ec6ef32cadad656
Signed-off-by: Duy Truong <dtruong@codeaurora.org>