Commit graph

578 commits

Author SHA1 Message Date
Hank_Lee
77f043e2e3 power: bq27541: add error handle to report previous valid capacity
Bug: 9984381
Change-Id: Ie27d105c8e42b9e9f69dfa219759de23526b21f9
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
2013-08-13 06:42:10 +00:00
Ajay Dudani
6f78c7af16 power: pm8921-bms: expose coulomb counter based charge
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>
2013-07-17 10:23:28 -07:00
Hank_Lee
b647aab926 power: bq27541: re-read capacity to insure valid return value
Bug: 9772236
Change-Id: I294bd8ded38080b4b86b8878a52ee9d048ffaa5b
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
2013-07-16 16:22:02 +08:00
Hank_Lee
149c49f191 charger: smb345: refine JEITA to avoid battery over voltage
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>
2013-07-15 17:31:52 +00:00
Hank_Lee
bf432b3836 charger: smb345: hold wakelock when wireless charging
Bug: 9474292
Change-Id: I6d149bfbf5b2d7557f6aa2a28b1168e5fc7b4499
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
2013-07-11 02:48:17 +00:00
Hank_Lee
b38c87af16 charger: smb345: disable wireless charging IRQ when AC plugged
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>
2013-06-28 18:34:23 +00:00
Hank_Lee
7c8ac74b83 charger: smb345: reconfig USBIN input current limit
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>
2013-06-18 19:16:39 +08:00
Hank_Lee
35b0d3174f charger: smb345: hold 2s tiemout wakelock during resume
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>
2013-06-17 20:28:24 +00:00
singhome_lee
19ff52b7dc charger mode: one scenario of charger mode.
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>
2013-06-12 21:46:24 +00:00
Hank_Lee
a5cefa74bb charger: smb345: set float voltage as 4.3V
Bug: 9263415
Change-Id: I6ba49f7d2409476eb85963509ce90f9423b15be7
Signed-off-by: alan_lu <alan_lu@asus.com>
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
2013-06-05 00:13:10 +00:00
alan_lu
e9835c3117 charger: smb345: shutdown system when battery capacity is 0%
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>
2013-05-23 16:29:14 +00:00
Hank_Lee
7d34741b7e power: bq27541: speed up reporting battery status during resume
Bug: 9005526
Change-Id: Ie1d4451a1872549294fc7443bf91cc66c350da36
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
2013-05-23 07:46:50 +08:00
alan_lu
b7e372e772 power: bq27541: hold 5s timeout wakelock when plug/unplug cable
For the system suspend/resume issue.

Bug: 8747455

Change-Id: Ic4a8eac520efc73e8313f3a1832d043cc19644b0
Signed-off-by: alan_lu <alan_lu@asus.com>
2013-05-22 16:37:30 +00:00
Hank_Lee
97a9311d96 charger: smb345: add JEITA function
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>
2013-05-16 17:42:08 +00:00
Hank_Lee
56659cd8ce power: bq27541: support negative temperature from -20°C ~ 80°C
Change-Id: I206e4bc4eaa6268631d988b8d712fee4cdd0bb33
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
2013-05-10 17:17:07 +08:00
Hank_Lee
b9076c3865 power: bq27541: just notify read temp fail instead of shutdown
Bug: 8785774
Change-Id: Ib494c82a0d14d3af3523b3b2a2d780243a651461
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
2013-05-10 03:24:23 +00:00
Hank_Lee
3291013b3d charger: smb345: setup wireless charging current limit orderly
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>
2013-05-09 16:41:50 +00:00
Hank_Lee
fdf1b1cd3a charger: smb345: config charging type priority since hardware rev_c
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>
2013-04-30 16:30:18 +08:00
Hank_Lee
846a2318df power: bq27541: only show "Full" status when charging source exists
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>
2013-04-30 14:34:24 +08:00
alan_lu
5fc86932ed charger: smb345: support wireless charging
Change-Id: I8dc909a5befdb4a2d6bbb0457c6ab4ea3e732f28
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>
2013-04-18 16:08:47 -07:00
mars_kao
a7984c9884 TouchScreen: add update power source state.
add callback function in power driver.

Change-Id: I3f6749d21d0fde61e77d4fb12008d08618a43947
Signed-off-by: mars_kao <mars_kao@asus.com>
2013-04-18 16:08:19 -07:00
Iliyan Malchev
62fa6ca3f3 bq27541: correctly sign-extend 16-bit current value
Signed-off-by: Iliyan Malchev <malchev@google.com>
2013-04-18 16:08:19 -07:00
alan_lu
1f5fde7c3a power: bq27541: add battery current property
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>
2013-04-18 16:08:16 -07:00
hank_lee
816adc29f5 power: bq27541: show charging status when USB plugged
Change-Id: I6dd4eb88eef83b6f647b7d2fbbcab3f2bf13c60a
Reviewed-on: http://mcrd1-5.corpnet.asus/code-review/master/68990
Reviewed-by: Nick Cheng <nick_cheng@asus.com>
Tested-by: Nick Cheng <nick_cheng@asus.com>
2013-04-18 16:08:02 -07:00
jerryyc_hu
026fab6399 charger: Add smb345 battery charger driver.
Change-Id: Ifec1f2671989258a7dd53afa2e828d90a4e69e3c
Change-Id: Ieeeea299f3302db284c5eadaa06cc66d35495d7a
Reviewed-on: http://mcrd1-5.corpnet.asus/code-review/master/68144
Reviewed-by: Nick Cheng <nick_cheng@asus.com>
Tested-by: Nick Cheng <nick_cheng@asus.com>
2013-04-18 16:07:58 -07:00
hank_lee
8540d346be power: bq27541: add support for bq27541 fuel gauge chip
Change-Id: I901dbf45efe2926e999105e64025484bcd2a91f8
Reviewed-on: http://mcrd1-5.corpnet.asus/code-review/master/68185
Reviewed-by: Nick Cheng <nick_cheng@asus.com>
Tested-by: Nick Cheng <nick_cheng@asus.com>
2013-04-18 16:07:57 -07:00
choongryeol.lee
d477b42619 power: pm8921-bms: fix divide by 0 issue when charging
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
2013-03-15 17:13:30 -07:00
Iliyan Malchev
bd000f8543 Revert "use msm8960_defconfig instead of mako_defconfig"
This reverts commit b78236b2d8.
2013-03-15 17:13:29 -07:00
David Keitel
4a52ad6f2b power: pm8921-charger: fix sub revision check
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>
2013-03-15 17:13:28 -07:00
David Keitel
dd8dd68b32 power: pm8921-charger: distinguish between PMIC 3.0.1 and 3.0
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>
2013-03-15 17:13:27 -07:00
choongryeol.lee
37c59c5e44 power: pm8921-bms: increase accuracy of voltage during charging adjusting
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
2013-03-15 17:13:26 -07:00
choongryeol.lee
1819bd4e44 power: pm8921-bms: fix soc rising from 99% to 100% during discharging
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
2013-03-15 17:13:26 -07:00
Iliyan Malchev
491b58e1ca Revert "msm: power: Revert LGE power patches"
This reverts commit 2f24cb771c.
2013-03-15 17:13:25 -07:00
Iliyan Malchev
b8c65bc60a Revert "msm: power: update power drivers to msm-3.4 tip"
This reverts commit fae0afd7be.
2013-03-15 17:13:24 -07:00
Iliyan Malchev
2625e4584b Revert "msm: power: update copyright markings"
This reverts commit 3f9f19a7c50fe47e1b963c25c68cc3ed89dd25a8.
2013-03-15 17:13:23 -07:00
Iliyan Malchev
a0e2488b39 Revert "power: pm8921-charger: don't apply kickstart unless it is 8921 pmic"
This reverts commit 22e27d01fe204b41e0ae415cafaf320ac1500234.
2013-03-15 17:13:23 -07:00
Iliyan Malchev
0fd7b8e1a9 Revert "power: pm8921-bms: fix the mismatch of container_of member type"
This reverts commit 879df6553254868150616f051a641f2d2e4bdfc6.
2013-03-15 17:13:22 -07:00
Iliyan Malchev
995c4f62d3 Revert "power: pm8921-charger: fix a potential array out of bound access"
This reverts commit 0f1be62ee48338994611035d664d26fadabeb2fb.
2013-03-15 17:13:22 -07:00
Iliyan Malchev
4f9e5f593a Revert "power: pm8921-charger: Support multiple vbus requests"
This reverts commit 51ab66c6a8cc19898971570d41fdf846c18f43eb.
2013-03-15 17:13:21 -07:00
Iliyan Malchev
c5d10ae0e5 Revert "power: pm8921-charger: disable AICL"
This reverts commit a6a33432dc20a3e43539dfa22ca25d51c6c9d57f.
2013-03-15 17:13:20 -07:00
Iliyan Malchev
3d2444690c Revert "power: pm8921-charger: force 19.2Mhz while writing to a register"
This reverts commit c77b173eebe4781dd37103a505e246c20213ab03.
2013-03-15 17:13:20 -07:00
Iliyan Malchev
c77ba171cd Revert "power: pm8921-charger: add boundary check for out of bounds issues"
This reverts commit dcf3cb14cb70b2517647f6091adc2fb95e46b426.
2013-03-15 17:13:19 -07:00
Iliyan Malchev
7e2ca03d39 Revert "power: pm8921-charger: Do not update "type" property of usb_psy"
This reverts commit 8f82b881f1e2a4828c89fa4f9d3b59b398127766.
2013-03-15 17:13:18 -07:00
Iliyan Malchev
aef8a2e0f2 Revert "power: charger: need sometime to handle the usb disconnecting events"
This reverts commit 7499d9cbd4d1294721b0e8aed31f9efa5548a91f.
2013-03-15 17:13:17 -07:00
Devin Kim
145292ae72 power: charger: need sometime to handle the usb disconnecting events
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
2013-03-15 17:09:33 -07:00
Anirudh Ghayal
37853d4091 power: pm8921-charger: Do not update "type" property of usb_psy
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>
2013-03-15 17:08:57 -07:00
Willie Ruan
cd05abfc10 power: pm8921-charger: add boundary check for out of bounds issues
Add boundary check to avoid any possible array index out of bounds

Change-Id: Ifad79991298e9d779b38a33a270af5197d2fc060
Signed-off-by: Willie Ruan <wruan@codeaurora.org>
2013-03-15 17:08:57 -07:00
Abhijeet Dharmapurikar
26599ba334 power: pm8921-charger: force 19.2Mhz while writing to a register
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>
2013-03-15 17:08:53 -07:00
Abhijeet Dharmapurikar
c92073ad40 power: pm8921-charger: disable AICL
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>
2013-03-15 17:08:52 -07:00
Anirudh Ghayal
598a5e2124 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>
2013-03-15 17:08:52 -07:00