Average current drawn can be calculated by reading the coulomb
counter based charge before and after the usecase is run and
dividing the difference in the charge by the time it took to
run the usecase.
Use power supply property POWER_SUPPLY_PROP_CHARGE_NOW, to
expose the coulomb counter based charge.
Change-Id: I43e26a2932ab3e3d9d79bb5af7daf2364ca133b7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
In high temperature environment, charger will occur over-voltage
and it will latch charging battery function, we need to refine
JEITA function to avoid it
Bug: 9847839
Change-Id: I1185fd3a49e318ebd83b30d843d2b72c39f22e40
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
Because AC has first priority of charging, we need to
disable wireless charging IRQ when AC plugged to avoid
reconfig AC input current frequently
Bug: 9615541
Change-Id: I908b4825193dc463ef11d7eaf47ac61204b6692a
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
USBIN input current limit may load smb345 default(500mA)
even AC adapter due to VBUS drop, we need to reconfig it
Bug: 9474296
Change-Id: I46ae320180a6ec6c3f9c6e9bab6a2b1f7c7ce05a
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
The system resume then suspend too fast
when put on or remove wireless charging dock
Change-Id: Idddb823036b58f1c390aee500574d8379a91731f
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
Reboot the device to charger mode when user turn off device and
Wirless/AC/USB is plugged.
verify ok in android-msm-flo-3.4-wip-debug.
Change-Id: I9b0ff5c9f4cb0f11677d978cb34bbd2db2082c51
Signed-off-by: singhome_lee <singhome_lee@asus.com>
To avoid battery is drained to critial low state,
it needs to shutdown device when charging + battery capacity = 0%
Change-Id: If62f1808fdfa527fba065f16268907fedc319601
Signed-off-by: hank_lee <hank_lee@asus.com>
Signed-off-by: alan_lu <alan_lu@asus.com>
1. If there is charging source, set Hard/Soft Hot Limit
when system is awake or suspend(shutdown)
2. Monitor battery temperature to set corresponding float voltage
and disable/enable charger
Change-Id: Ia804a935570bbb5a1fe22067a712eaef36e903c0
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
1. detect wireless charging
2. set input current limit as 300 mA and disable AICL
3. after 2 seconds, set input current limit as 500 mA
4. after 2 seconds, set input current limit as 700 mA
Change-Id: Ia91ea674ba7eea45f92421d13b75a578a2d21a77
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
Priority is : 1. AC, 2. wireless charging, 3. USB.
Charger default setting is that wireless charger has higher priority,
so disable wireless charging when AC is plugged in since hardare rev_c.
Bug: 8411313
Change-Id: I6da25d1d6fbdf683421918229babba0ab97afebc
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
If there is no charging source, we should not report "Full"
battery status or it will show charging icon
Bug: 8728645
Change-Id: If74cedaca272428208c536e647094cf81af20619
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
Report battery current to check charging/discharging
of system
Change-Id: I49705758992c9d21529a2e3f7874b990c7474d1b
Signed-off-by: hank_lee <hank_lee@asus.com>
Signed-off-by: alan_lu <alan_lu@asus.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
The current code can divide by zero in the scale_soc_while_chg
function if calculated_soc drops while charging.
This patch fix it.
Change-Id: I83c7e9c7056990499f474c9e1882f0377df05f0c
Rather than checking for the value 1 check that
bit zero is set.
Change-Id: Ie2842b28648084d8970329d7c76fcf0d0666a847
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
Some workarounds that are required for PMIC die version 3.0
differ slightly for die version 3.0.1.
Fix this by checking the PMIC subversion register to distinguish
between 3.0 and 3.0.1.
CRs-Fixed: 403150
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
(cherry picked from commit 913c55e2706c36132fd42f90c05530b8e55a26ed)
Conflicts:
drivers/power/pm8921-charger.c
Change-Id: I11155d6180de09e1b9e0137f7943603d44102d07
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
During charging adjustment, the measurement of voltage is not accurate.
Since the measured voltage during charging adjustment is not OCV
(open circuit voltage), it cannot show real battery voltage at CC to CV
point. But current implementation use inaccurate voltage as a voltage of
CC to CV point. This inaccurate voltage of CC to CV point can cause
wrong SoC adjusting. For instance, the SoC could stick at fixed value
until end of charging.
This patch increase accuracy of voltage measurement by using battery
current and battery resister.
Change-Id: I3a4cc4e58e409be5422ec6bf64678a9a92b9fe25
We observed that SoC suddenly increase from 98% or 99% to 100%
right after charger removal. This issue caused by charging adjusting
algorithm which adjust SoC to sync 100% with end of charging.
During charging adjustment, the adjusted SoC could be smaller than
original SoC. So when we remove charger, charging adjusting algorithm
stop adjusting SoC and then bms report original SoC which is larger
than before.
Previously, bms driver considered most of this case by using previous
SoC when SoC increase during discharging. But if SoC is 100%, previous
patch doesn't work.
So this patch add SoC 100% case by checking if charger is enabled.
Change-Id: I70945d391c9d821eaf875f1bcd1e8787077b98da
When being completely charged in the offmode charging and pulling out TA
from sleep condition, I gave 1 sec. delay until entering sleep condition again,
in order to prevent the phenomenon that a device doesn't turn off.
We need sometime for an userspace application to handle the usb disconnection
events. There is no effect of power consumption.
Change-Id: I0851cc2b47c3780fd68d3e8965fd0d6f5b7e8312
The userspace fails to detect the supply type as USB if "type"
property of usb_psy power-supply class is set to anything other
than USB at init. The driver ends up setting this to type
-UNKNOWN at bootup if there is no USB source present
-USB_DCP/ACA if a wall charger is present
This causes issues with displaying the charger source later on
since the USB path is not noted by the userspace. Moreover, the
userspace ignores the changes to the type property at runtime
making it futile for the driver to update it.
Use local driver data to store the usb type information
and use this to determine the supply-type. Keep the
usb_psy.type set to USB always.
CRs-Fixed: 451196
Change-Id: I69d6935826a05dd0310b960b4fd1735bc77ec67f
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Add boundary check to avoid any possible array index out of bounds
Change-Id: Ifad79991298e9d779b38a33a270af5197d2fc060
Signed-off-by: Willie Ruan <wruan@codeaurora.org>
We saw a problem where the charger was locked up and it reported
incorrect FSM states.
The root cause was that PMIC could be doing short sleeps while
LPM is set to 0. This means it would enter 32Khz and exit 32Khz
fairly quickly causing the lockup.
For e.g.
pm_chg_write gets called
write LPM = 0
pmic enters and exits sleep quickly.
charger locks up
the writes and reads are unreliable from this point on.
To prevent the lock up instead of using the LPM bit force
the charger to run from 19.2Mhz while doing a write.
Change-Id: I2211f030e053378ed01d564dec4fb9aea24ccb9d
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
There are certain conditions where AICL should be disabled. For example,
cases where a strong usb charger capable of supporting the usb_max_current
or cases where a wireless charger is used.
Use the power supply property HEALTH to indicate whether AICL is desired
or not. If HEALTH is unknown enable AICL, if HEALTH is good disable
AICL.
While at it clean up the vbus_draw callback
- there is no need of the vbus_lock, remove it
- there were , comma separated statements in the probe function, use ;
instead
- the commit to verify the_chip is initialized, defeats the purpose of
remembering the usb current when the_chip is not initialized. Clean
this up
Change-Id: I8b21ccdf5ed69ea917cb370d2e8930c9d8a5003f
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
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>