Commit graph

519 commits

Author SHA1 Message Date
Abhijeet Dharmapurikar
b40e28051a 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.

(cherry picked from commit 7f1d97fd69c3afe66577e731105207e5db544ab2)

CRs-Fixed: 393301
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>

Change-Id: I5c0ba3b8f0653c5f9d64f35346601763c059505a
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
2013-03-07 15:21:13 -08:00
David Keitel
6d599dc826 power: pm8921-charger: Control CHG_USB_SUSPEND enabling boost
Toggle the CHG_USB_SUSPEND bit when utilizing the VBUS boost.
This bit controls ensures that no current is being drawn from
a USB device and the charger runs off the battery.

This makes sure that when pm8921_disable_source_current is called
the correct setting is written to the suspend bit depending
on the disable flag.

(cherry picked from commit d8878596b9b19668fd1f1b226a333d955f2218c4)
CRs-Fixed: 393498
Signed-off-by: David Keitel <dkeitel@codeaurora.org>

Change-Id: Iae390fd10e59d6ba1fe85743c1015eea35b06f7a
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
2013-03-07 15:21:08 -08:00
David Keitel
48f3c23749 power: pm8921-charger: Fix bug in current limit lookup
In the usb_ma_table there exist two consecutive values
that have IUSB_FINE_RES bit set. Some functions
incorrectly assume that this does not happen.

Fix this by checking for consecutive values having
IUSB_FINE_IRES bit set.
(cherry picked from commit 67ebde08e12d246302d133b4510d59c8f96325d1)
CRs-Fixed: 404348
Signed-off-by: David Keitel <dkeitel@codeaurora.org>

Change-Id: I6b6ca96b92ec4b9765e4812352057a0ac8cff380
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
2013-03-07 15:20:55 -08:00
David Keitel
e7fa36ee06 power: pm8921-charger: report DC online for some platforms.
Some hardware platforms can supply VPH_PWR without battery
or charger being present.

To avoid shutting down due to no connected power sources
from the perspective of software set a flag that forces
the DC supply to be online for this type of platform.

Signed-off-by: David Keitel <dkeitel@codeaurora.org>
(cherry picked from commit a3cf943ef8c91435e2cb94b8e8bcc482dc65cb27)

Conflicts:

	drivers/power/pm8921-charger.c

Change-Id: I565edb1ab797384481ce5e37aee73ee0a8e80428
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
2013-03-07 15:20:14 -08:00
Anh Nguyen
b78236b2d8 use msm8960_defconfig instead of mako_defconfig
Change-Id: I338003dc6cc5127febdbcaa00fc0c8b7e81921cc
Signed-off-by: Anh Nguyen <anguyen@codeaurora.org>
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
2013-03-07 15:17:40 -08:00
choongryeol.lee
cf0acb5176 power: pm8921-bms: use fixed ibat_avg instead of shutdown ibat_avg
Using stored average ibat(shutdown ibat_avg) which came from
previous boot sometimes cause SoC sudden drop in boot up time.
So this patch use fixed ibat_avg value instead of shutdown ibat_avg
during 1st SoC calculation.

Change-Id: I9675652c3b4918529be40a8d6f8ee29b6dee1359
Signed-off-by: Iliyan Malchev <malchev@google.com>
2013-03-04 12:48:03 -08:00
choongryeol.lee
8e5fa5d605 power: pm8921-bms: use pmic power reason to check restart
For accurate SoC calculation, bms need to know if target
was booted from reset or power down. Previously, minimum
CC value check was used to detect power on reason.
But this minimum CC value check is useless when charger is
connected. So, this patch use pmic power on reason to know
the exact power on reason.

Signed-off-by: Iliyan Malchev <malchev@google.com>
2013-03-04 12:48:02 -08:00
choongryeol.lee
ccbdadfb5e power: pm8921-bms: handle restart without pmic power on
There are situation when the system undergoes a restart but the
pmic does not execute its power on sequence. In such case the OCV
value is not updated and the CC value is not cleared. Since OCV
and CC values came from the previous boot, we don't have to use
shutdown soc in this case. The use of shutdown soc without reset
of CC increase error of soc. So this patch remove use of shutdown
soc in restart case.

b/7327066

Change-Id: I2c5c5974a4c8ace076c1f8c56c856718b7140fb8
2013-03-04 12:47:53 -08:00
Devin Kim
319cb1e416 power: pm8921-charger: not change the usb supply type
usb_psy type should be POWER_SUPPLY_TYPE_USB. Do not change the type.

Otherwise, if you boot up with DC, userspace might recognize usb_psy
as DC, not USB charger. After that, device might not detect the USB charger.

Change-Id: I73f743e77fbfee0cb5847be1fc6747fd48e41790
Signed-off-by: Iliyan Malchev <malchev@google.com>
2013-03-04 12:47:49 -08:00
Ajay Dudani
0cfe78965e power: pm8921-bms: use consistent temperature units
There is bug in the code where interpolate_pc is passed temperature in
DegC at one call site vs deciDegCelcius at other.

Use degC consistently.

Change-Id: I3e5e92e39adf904e62d4c5ffcb6d370c0655f7cf
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-03-04 12:47:21 -08:00
choongryeol.lee
6d5eafbcdf power: pm8921-bms: support wireless charger bms
Since WLC(wireless charger) supply power to battery without PM8921 charger,
the SoC value is not accurate. This patch adjust OCV(open circuit voltage)
and max CV(constant voltage) value to compensate difference between
WLC and pm8921-charger.

Change-Id: I8fa368f706866d93451c2f663da69c010f9b2a35
2013-03-04 12:47:20 -08:00
choongryeol.lee
9843a708f3 power: pm8921-bms: use restart reason for usb detection
When the charger is not initialized it returns -EINVAL when asked
whether usb charger is plugged in. Use the restart reason to check
if we started with a charger insertion.

Change-Id: I2e8fcb4a15af3a66331a921d378bfd5d2dfe4533
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-03-04 12:47:19 -08:00
choongryeol.lee
c904c588f0 power: pm8921-bms: remove SoC fluctuation during discharging
Calculated SoC could be fluctuated by system load. This patch
remove these fluctuation by using previous SoC if calculated Soc
is higher than previous value during discharging.

Change-Id: I1d144207125ed3c55030004fee1eb4b2489a298c
2013-03-04 12:47:06 -08:00
kibum.lee
24e044ad29 power: pm8921-bms: fix unintended diff between reported SoC and calculated SoC
There is adjustment to prevent discontinuous SoC change when
calculated SoC is reported. This adjustment is performed while
device is charged only. In current implementation, the
determination of charging is not accurate. So in some case,
the adjustment is performed even device is not charged. This cause
unintended difference between reported SoC and calculated Soc.
This patch change the method of charging determination for
reported Soc adjustment.

Change-Id: I7caedf7d696be57c96d5f777e44f8ddecbdbc7f2
2013-03-04 12:46:30 -08:00
choongryeol.lee
0338875786 power: pm8921-charger: prevent recharging when batt is overheat
When battery is forced to stop charging by overheat, re-charging
should not be initiated even if re-charging condition is satisfied.

Change-Id: I0070039a186ccf3f12c0e79a8696a7aa3c61e538
2013-03-04 12:46:23 -08:00
roy.park
e62e15cc2e power: charger: set under threshold as vddmax_min for unplug_usbcheck_work.
When usb mode is changed from MTP to Tethering, chg_gone_irq_handler is called
and then disconnect tethering by turning off ovpfet from unplug_ovp_fet_open.
So we add under threshold to protect this error while usb is being connected.

Change-Id: Id66a3db0822c291ba348cf93d2e7a72f6ae857ae
2013-03-04 12:46:22 -08:00
kibum.lee
0139570c10 power: battery: disable USBIN_OV_IRQ USBIN_UV_IRQ irq
Change-Id: I0c44b76056f7a778cfc4f8b651a72d2796bd4d42
2013-03-04 12:46:05 -08:00
kyungtae.oh
5a934bae83 power: cleanup the messages of wireless charger
Change-Id: Ie86b46cb9f30fd2e795a144123eec0282ac6e664
2013-03-04 12:45:59 -08:00
Ajay Dudani
af92feb032 power: pm8921-charger: adjust vdd max earlier
The charger hardware decides Constant Current VS Constant Voltage based
on the VPH_PWR voltage and not on battery voltage (vbatt) as it should.

The problem is, becuase of IR drop between VPH_PWR and VBATT,  VPH_PWR
reaches the voltage programmed in vdd_max earlier while the VBATT stays
lower causing the charger hardware switch to constant voltage mode
prematurely.

To fix this issue, adjust the vdd_max early.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
2013-03-04 12:45:45 -08:00
Iliyan Malchev
cccbcc429f Revert "power: pm8921-charger: enable unplug_check for PC USB"
This reverts commit 4fa0eb8ca5cf0eb9b0f5c01cd20e0ee50fa2c853

Change-Id: I16d5e60d436750ce65cd41ec0607df439f886d7f
2013-03-04 12:45:44 -08:00
Ajay Dudani
067e93a522 power: pm8921-charger: enable unplug_check for PC USB
For some platforms disabling the input voltage
regulation is not sufficent to prevent unplug events
from going unnoticed.

Fix this by making sure the unplug_check_worker
is also running when a PC USB connection with
a current limit of 500 mA is set.

Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2013-03-04 12:45:38 -08:00
choongryeol.lee
a81a841921 power: pm8921-charger: use SoC % value for charging stop and resume
Current pm8921 charger code doesn't consider the SoC % to determine
end of charging and recharging state. This can cause weird UI display
on SoC % and charging state.
For example, charging is completed when SoC % is not reached 100% or
charging is not completed even if SoC % is already 100%.
So this patch change how to determine end of charging and recharging.

Change-Id: Ice658488744d71117fedb64e0fa0eb7ad34c6573
2013-03-04 12:45:35 -08:00
Devin Kim
718ff53e50 power: pm8921-charger: OVP_FET control for USBIN drop error
In some case, USBIN voltage doesn't drop for a while when
usb cable is unplugged. Due to this error, charger cannot
be detected correctly. This patch introduce OVP_FET
off method to drop USBIN volatge in error case.

Change-Id: I8d279cc8b4e7a489e8bfdc86b2015ff45704f832
2013-03-04 12:45:31 -08:00
choongryeol.lee
8512d27a2f power: battery: fix charging current restoration
When batt temp state is changed to normal state in
battery temperature control, the charging current
is not restored. So this patch fix this bug.

Change-Id: I5ae69d1f4f9b3edba7973efe0d6d8d5dd61d1647
2013-03-04 12:45:17 -08:00
Devin Kim
419c74bd61 power: charger: fix fluctuation between charging and not charging
commit 8126554cf049d13f4dd2d815d86ea289efdc6f3a has fluctuation issue
between charging and not charging. It fixes this issue.

Change-Id: I1cc2f3b51b5c1077b5d317ce324e0ce05a616977
2013-03-04 12:45:01 -08:00
Devin Kim
3ab2918640 power: charger: get the current information from usb-otg
usb_otg is able to know what kind of charger is connected like as
USB, TA and  Slimport. And we can decide the max charging current
by cable type. pm8921-charger is able to use this information.

And unplug_check_worker has some problem. Wrong charging current
might set as 100mA even thought USB charger can be set by max 500mA.
It cause very slow charging.

msg_otg didn't use power supply api properly due to not supported
some POWER_SUPPLY_PROPs in pm8921-charger.c. It's also fixed.

Change-Id: I86661fbe38e3db5522caab6ff316c0100f87fe0d
2013-03-04 12:44:57 -08:00
choongryeol.lee
4e4f4dabfd power: pm8921: consideration of ibat max overwrite
The thermal mitigation and battery temp control can overwrite
the ibat max value each other. So this patch remove the possibility
of overwrite ibat max value by mitigation and battery temp control.

Change-Id: Ib0f7bf2b8bd2e474d1d9c76bd5100b05310cb048
2013-03-04 12:44:44 -08:00
choongryeol.lee
58a482fbef power: battery: add argument to set_health_state()
Add argument to set_health_state() for notification
of current change to charger driver.

Change-Id: I4ae2875c5b2c29689d11f8dbe5be20e5667453d4
2013-03-04 12:44:43 -08:00
taiyeon.kim
23072f0972 power: pm8932-bms: avoid skipping when SoC is 1%
patch for do not skip 1%(SoC level)

Change-Id: I34f394f856512913b1a6e5888b93ddf563a1536d
2013-03-04 12:44:38 -08:00
kyungtae.oh
2d3ebfaeb6 power: pm8921-bms: display the battery information for monitoring
We need to monitor the battery status periodically.So change the message
level and simplify the information.

Change-Id: Ia010ad220875f6863b3cdf1835cf6a4afc555935
2013-03-04 12:44:36 -08:00
roy.park
f4f71ea415 power: charger: change charger detection for TA plug in
There is a problem when is_active_chg_plugged_in API check active_chg_plugged_in
with active_path for TA in unplug_check_worker. So we used the_chip->usb_present
for TA detection correctly due to the same usb port.(USB_IN->USB_OUT->DC_IN->DC_OUT).

Change-Id: If51923ba12e6496bf63123104a158d34cad377b0
2013-03-04 12:44:24 -08:00
kyungtae.oh
f8de54b40d mako: power: use wireless charger api instead of power supply api
This is expected to prevent missing wireless charger state.
The bms needs to know if anything is connected to the wireless charging.

Change-Id: Ie97130cc515d19ab17b67267d9aca7588c1fff72
2013-03-04 12:44:23 -08:00
Devin Kim
5d51c40a8d power: battery: add battery temperature control
The battery temperature should be controlled for safty.
So this patch indroduce battery temperature control.

Change-Id: Ia00e7ce5bf697591be2da94f9a7c2960738642d5
2013-03-04 12:44:22 -08:00
Devin Kim
edd5826b69 Revert "power: add battery type selection and check lge battery"
This reverts commit 619dc8d86f676eb19408044f670174c599e4fb37.

Conflicts:

	drivers/power/Kconfig

Change-Id: I05004eec5b4c09ca8675e3ee3d85778021156634
2013-03-04 12:44:22 -08:00
kyungtae.oh
d843640426 power: pm8921-charger: add device_create_file for charge_state
Change-Id: Ib5c42bfd32e27ddbe95f9159ff1d274496588b70
2013-03-04 12:44:21 -08:00
Brian Muramatsu
4712651d37 report Wireless instead of WIRELESS for charger
This fits in better with Battery and Mains.
2013-03-04 12:44:11 -08:00
Ajay Dudani
51edcc2511 power: pm8921-charger: enable battery alarm
During UVLO events the charger hardware may lock up
if it is in hardware clock switching mode.

To fix this add a battery alarm with a lower threshold
that disables hardware clock switching.

When the system is awake the resume callback ensures
that the charger is running off of the 19.2 MhZ clock
which does not allow the charger to lock up. Therefore
if the battery alarm wakes up the device before hitting
UVLO the charger hardware will not be in hardware clock
switching mode.

CRs-Fixed: 374607
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>

Change-Id: I1bb20b2e7ff1a11f032b12b4abd4804ed130fe4a
2013-03-04 12:43:59 -08:00
roy.park
349526f5fb pm: pm8921_charger: add dc uevent for off mode charger
Change-Id: Ia50d5757a9dcf04936875b40d68905810adaf311
2013-03-04 12:43:56 -08:00
kyungtae.oh
780cfeb38c mako: power: Change bms_change_end value in disconnect WLC
Change-Id: I6f77a5f48774828b41a2a7e0ee264cb8c425bad3
2013-03-04 12:43:51 -08:00
kyungtae.oh
e9efc45c8e mako: power: userspace communications for full charging battery status
Change-Id: Ibfad2d2a5a080d8535bf076e3a61f25d2491bd39
2013-03-04 12:43:50 -08:00
kyungtae.oh
935c9a4c10 power: add wirelesscharger(WLC) bq51051b driver
Change-Id: I61c4b9c3d648e8f709ec78708271f807ceed1715
2013-03-04 12:43:29 -08:00
Devin Kim
cf5ebd11dd power: compilation fixes for gcc 4.6
These changes are reguired to compile sucessfully with gcc 4.6

Change-Id: I683d0edeee5167c715f773f55ec32da0d78f702c
2013-03-04 12:43:18 -08:00
roy.park
c77ee7c1f6 power: add battery type selection and check lge battery
lk should support battery check to enable this feature.
if you want to use it, set CONFIG_LGE_PM_BATTERY_ID_CHECKER=y
in defconfig

Change-Id: Ie92c612e197aeede39b8da526332add3fab15a19
2013-03-04 09:11:53 -08:00
roy.park
0f8e962294 power: support LGE battery 2100mAh
Add battery 2100mAh profile and update Battery mornitoring system(BMS)

Change-Id: Iea118f1665241c7e4192a77db791b80426a01b60
2013-03-04 09:11:48 -08:00
Abhijeet Dharmapurikar
0641d0fd7d power: pm8921-bms: fix 0% soc reported when started with a charger
When the device is started with a charger inserted, it reports 0% soc.
This is because a variable "soc_at_cv" is not initialized correctly in
the probe function.

Fix this by initializing it appropriately to -EINVAL.

Change-Id: I106f36e204c5cc4f16a8f52b9fa7a2a012282e35
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:21:23 -08:00
Abhijeet Dharmapurikar
cfe67ce94b power: pm8921-bms: remove forcing shutdown soc
Forcing to return shutdown soc for the first 30 seconds was added so
that we show consistent soc right after bootup.

However with the recent changes to the algorithm viz. using termination
resistance for UUC, restricting UUC changes at most 1% and limiting the
OCV corrections, this forcing is not required. The soc stays within
limits of the shutdown soc.

Remove this forcing of shutdown soc.

Change-Id: Ie74e9318cca29ab60436df6ddec286917fbd0cd7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:21:23 -08:00
Abhijeet Dharmapurikar
5ebb4c45b4 power: pm8921-bms: change OCV when scaling soc for charging
A drop in state of charge (soc) was observed right after End Of Charge
(EOC) happens. This was because calculated soc was still low, while the
scaling algorithm increased the SOC to 100%. There was a situation
where SOC was calculated right when charging finished but charger did not
send the EOC to bms - the charging adjustments algorithm does not scale
since it sees charging is stopped and falls back to the calculated soc
which was lower than the scaled soc.

Fix this by changing the calculated OCV(open circuit voltage) of the
battery so that the calculated soc is same as the scaled soc.

Change-Id: Ieb409721da6fc70d673ccbf4334f94a1793dfe7e
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:21:22 -08:00
Abhijeet Dharmapurikar
2acc8a93ff power: pm8921-bms: charging curve adjustments
It was observed that while charging the reported soc sometimes reaches
100% before end of charging happens. At other times it does not reach
100% at end of charge and a abrupt jump to 100% soc happens.

Fix this by linearly increasing soc based on battery charge current
after constant voltage phase is reached. Constant voltage phase is
reached when battery voltage reaches the max value.

Also once constant voltage phase is reached and the voltage or charge
current decreases keep reporting the earlier soc. This could be because
of a transient system load.

Change-Id: I14c2f42d7897041db038ce85ce1124cf1ef261af
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:21:22 -08:00
Abhijeet Dharmapurikar
1a4192882b power: pm8921-charger: round up vddmax adjustments
It was observed that the battery was charged at voltage less than the
max voltage. This was because the vdd max algorithm rounded down the
voltage.

Use voltage rounding up instead.

Change-Id: Ifb5e9c265b8f616e82abbb979ecfac5e6604b25d
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:21:13 -08:00
Abhijeet Dharmapurikar
7af3a600ce power: pm8921-bms: use termination battery resistance
Unusable Charge(UUC) is based on battery resistance and average load. Since
battery resistance is based on temperature and state of charge, UUC
is essentially based on temperature, state of charge and the load.

The purpose of UUC is to prevent the battery from falling below the
cutoff voltage. In the current implementation, since UUC is dependent
on SOC, it is small when SOC is high and gets bigger as SOC approaches
zero. This increase however is not linear which causes huge jumps in
SOC.

Remove the dependence of UUC on SOC. Simply use the resistance value
which would have been used when SOC = 0.

To find this resistance value, loop from SOC = 0 towards 100 and at each
step calculate/interpolate open circuit voltage, resistance and the
corresponding unusable voltage. The interpolated resistance value where
unusable voltage equals open circuit voltage is the termination
resistance. Use this resistance value for calculation of UUC. Note that
this resistance value is not dependent on the current SOC and will be
constant as long as the load and temperature remain the same.

Change-Id: I3ba91f8b1cb831e257f72363058a6e3a04ffc39b
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:21:13 -08:00