Commit graph

33 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
f4384a2b5f power: pm8921-charger: increase hearbeat if battery is low
When the battery percent charge goes low we want to increase the
frequency of state of charge updates. This helps the correction
algorithm ample opportunities to correct the state of charge and
prevent a low voltage shutdown.

Change-Id: Ie846350ee4c1fd70198d28646779b20349134ef7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:20:58 -08:00
Abhijeet Dharmapurikar
1d78857112 power: pm8921-bms: dont use override mode if batfet is open
If the battery fet is open, the current sourced or sinked from the
battery is very low. There is a high chance that an open circuit
voltage(OCV) happens. Putting the BMS in override mode resets the timer
whose expiry causes an OCV.

Avoid putting the BMS in override mode if battery fet is open.

Change-Id: Idc463bcc55b51cf188cc8ee440a66f763654f174
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:20:54 -08:00
David Keitel
1218989c85 power: pm8921-charger: add dc_unplug_check option
Add a configuration option to enable or disable
the reverse boost fix for the DC charging path.

Some board designs do not utilize the DC_IN path
on the PMIC, however they do use the presence
detection of DC_IN to enable the auto switching
and interrupt features. In these particular configurations
the PMIC does not control the DC OVP FETs.
Hence add an option to enable or disable the DC path workaround
and leave the workaround disabled by default.

Change-Id: I1e55bbfe37c7cc6f62581af11280a565ed648c06
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2013-02-27 18:18:38 -08:00
David Keitel
87b328d620 power: pm8921-charger: add reverse boost fix for dc_in
Reverse boosting is also seen on the DC charging path
and may cause charger removal detection problems.

Fix this by changing the reverse boost detection to only
check the active charging path. Only the active charging
path will see reverse boosting voltages because the other
path's OVP will automatically be opened (off) by the
hardware.

Change-Id: I23a48cd49d912e2bb2651159ec91d0ccfa7f5e0d
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2013-02-27 18:15:22 -08:00
David Keitel
bd7ad44689 power: pm8921-charger: add UVD threshold API
PM8917 has a new register which allows configuring
the falling USB under voltage detection (UVD) threshold
from 3.85V to 4.35V in 100 mV steps.

Add an API that allows to set this value per default and
also only do this for PM8917 chips.

Change-Id: I9b4259b43f148762ac72af40bdc79b895d9b4fc2
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2013-02-27 18:15:21 -08:00
David Keitel
17ad6cf0f8 power: pm8921-charger: fix decrease_usb_value for PM8917
When decreasing the usb value from the usb_ma_table make
sure to take into account wether the value is available
on the PMIC platform by checking the first bit and if
the iusbfineres flag is set. This ensures that both
PM8917 and PM8921 are supported correctly.

Change-Id: I0be94103a066554924f8b212d3751f13812c49e0
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2013-02-27 18:15:21 -08:00
David Keitel
a79d77b75c power: pm8921-charger: change BOOT_DONE configuration
Set the BOOT_TIMER_EN bit when writing the
BOOT_DONE configuration. This is required to make
sure the boot timer will be enabled during the
next phone boot.

Change-Id: I0c43de3a0c285979f7bccd42e464ca0d2fbbe42a
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2013-02-27 18:15:20 -08:00
Abhijeet Dharmapurikar
5a0002ab37 power: pm8921-charger: support dc charging while in usb host mode
The current code disables charging when the usb is operating in host
mode. This unnecessarily stops charging from the DC path. The board
layout (the ovp fet and otg path) is assumed to support host mode and
charging from dc path.

Also make the usb driver change the power supply framework's scope
property instead of calling 8921 charger apis directly.

CRs-Fixed: 373365
Change-Id: I2a9fb32de22cbe68e26078b97a7d83c40272a370
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:14:19 -08:00
Abhijeet Dharmapurikar
e9db898b3c power: pm8921-bms: remember soc between restarts
Currently the code does not have a mechanism to remember the soc
reported just before shutting down and upon restarting the new
soc reported is off from the previous soc value reported.

This change introduces
- a method to save soc in an unused coincell back register: ssbi address
  0x107 is not used on 8921 and serves the purpose of storing the soc.
  The driver reads this value and uses it to scale the reported soc.
- a method to detect that a battery was removed and perhaps replaced by a
  different one. If the battery is found replaced the driver is notified
  of the change and it disregards the soc value it read from the backup
  register. The charger driver has a battery backed bit (force vref
  therm) which it sets in its initialization sequence. Once set the
  value remains between restarts, unless the battery is removed. The
  default value of this bit is 0. Hence if a zero is detected before
  writing to it, battery was removed between restarts - this mechanism
  is used to notify the BMS to disregard the soc read from the backup
  register.

Note that for this to work correctly the bootloader needs to be updated to
not overwrite register 0x107 upon restart.

CRs-Fixed: 370287
Change-Id: If7d098552d36eb27a396ee7d37f78d3629861f6e
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:14:05 -08:00
Abhijeet Dharmapurikar
22406c702f power: pm8921-charger: force 19.2Mhz clock before accessing registers
The charger was observed to be in locked up state upon booting up. The
initialization time configurations were being ignored causing charging
to not happen.

Fix this by forcing the charger to run from 19.2Mhz clock prior to
accessing any charger registers. This made the charger come out of the
locked up state and accept writes to it.

Change-Id: I0d86c328d4c7022a3bd46c62cb28b12318053f74
CRs-Fixed: 372383
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-27 18:12:21 -08:00
Abhijeet Dharmapurikar
fcdba5c296 power: pm8921_charger: Add charger driver
Change-Id: I76671b841668aea365c72729e046fb37c15f671b
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2013-02-25 11:32:29 -08:00