Commit Graph

436 Commits

Author SHA1 Message Date
David Keitel
0873d0f00e power: pm8921-charger: do not open OVP on USB suspend
When the usb_suspend bit is set and an the CHG_GONE
interrupt is triggered the ovp fets are opened to
enforce a usb unplug detection.

Fix this by checking the CHG_USB_SUSPEND bit and do not
open the USB OVP FET.

Change-Id: Ibec1908c959f08fb531e43c26b61e1c455b9e6a7
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-03-31 15:08:47 -07:00
David Keitel
b57db9e0e6 power: pm8921-charger: avoid schedule while atomic bug
If the loop_change interrupt handler directly invokes the
unplug_check_worker which uses msleep causing a bug.

Fix this by scheduling the work directly rather than invoking
the work function.

Change-Id: Id1ce75eddc1b7f09b7476af12b68ec8ae8ff1f24
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-03-30 23:15:38 -07:00
Rohit Vaswani
a76e99abc5 Merge branch 'Linux 3.0.21' into msm-3.0
Merge Upstream's stable 3.0.21 branch into msm-3.0
This consists 814 commits and some merge conflicts.

The merge conflicts are because of some local changes to
msm-3.0 as well as some conflicts between google's tree and
the upstream tree.

Conflicts:
	arch/arm/kernel/head.S
	drivers/bluetooth/ath3k.c
	drivers/bluetooth/btusb.c
	drivers/mmc/core/core.c
	drivers/tty/serial/serial_core.c
	drivers/usb/host/ehci-hub.c
	drivers/usb/serial/qcserial.c
	fs/namespace.c
	fs/proc/base.c

Change-Id: I62e2edbe213f84915e27f8cd6e4f6ce23db22a21
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2012-03-30 00:09:34 -07:00
Jay Chokshi
d674a51860 power: pm8921-charger: Add feature to use charger LED
Add a mechanism to configure the power source of
the charger indicator LED anode on the PM8921.
The configuration is specified using platform data.

Change-Id: I9a436f634ddfd5d1822f1fc8beab4936fa8bb61d
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
2012-03-26 11:31:04 -07:00
Linux Build Service Account
12f8788251 Merge "power: pm8921-bms: calculate rbatt only at resume" into msm-3.0 2012-03-23 10:51:04 -07:00
Linux Build Service Account
08ee264139 Merge changes Icba083e8,Ib84e2733,Iae4a3636 into msm-3.0
* changes:
  spi_qsd: Fix compilation warning
  power: ccadc: Initialize voltage_uv to fix compilation warning
  msm: cpuidle: Fix pm.h include path.
2012-03-22 10:55:12 -07:00
Linux Build Service Account
4d9aad3e57 Merge "power: pm8921-charger: add adaptive current limiting" into msm-3.0 2012-03-22 10:55:12 -07:00
Linux Build Service Account
e8d707537b Merge changes Id542b083,I564fa01c into msm-3.0
* changes:
  power: pm8921-charger: remove set_usb_power_supply_type
  USB: OTG: remove pm8921_set_usb_power_supply_type
2012-03-22 03:29:43 -07:00
David Keitel
acf57c86ca power: pm8921-charger: add adaptive current limiting
Adaptive current limiting is a method which tries to
maximize the available usb current by slowly stepping
up the allowed maximum usb current and verifying that
the connected wall-charger is collapsing.

If the USB driver determines that 1500 mA are available
the starting current on usb is 500 mA slowly stepping up
unless

* VIN_MIN is reached (charger is reaching its capacity)
* USBIN goes low for less than 50 ms (charger collapsed)

If one of the two conditions apply then reduce the target
maximum current to the current maximum usb current and
stop trying to stepping up. If the conditions occur again
decrease both the target and current usb maximum setting.

CRs-Fixed: 339022
Change-Id: Icdb46e6346b6b871d81bbacbffe70831dd62d93c
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-03-21 16:46:19 -07:00
David Keitel
c526ddbaeb power: smb349: add support for smb349 charger chip
The SMB349 charger chip allows charge batteries
with a higher current. Add this driver to be able to
control charging from kernel space and deliver charging
information to userspace.

Also add debugfs entries to show current register
settings of SMB349 charger.

Change-Id: Ic88b539304539a49ebe69517d13045cbb18091bf
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-03-21 08:30:20 -07:00
David Keitel
70f6cdc262 power: pm8921-charger: remove set_usb_power_supply_type
This custom API is no longer required since AC charging
reporting to userspace is solely dependent on the maximum
current supplied by the USB rather than the connector
type.

CRs-Fixed: 339841
Change-Id: Id542b083dd4f0ba5679d64f9e20d3b04cf14d972
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-03-20 10:36:08 -07:00
Trilok Soni
c6e541eaca power: ccadc: Initialize voltage_uv to fix compilation warning
Fixes following compilation warning:
pm8xxx-ccadc.c:552: warning: 'voltage_uv' may be used uninitialized

Change-Id: Ib84e2733d91af0fd12dd73662079c5e564e8bffb
Signed-off-by: Trilok Soni <tsoni@codeaurora.org>
2012-03-20 14:35:13 +05:30
Abhijeet Dharmapurikar
1a7561a47a power: pm8921-bms: calculate rbatt only at resume
The battery resistance (rbatt) measurement can only happen when the
current consumption of the device goes very low. This implies that
rbatt should be checked for only while resuming.

Update the driver to check and measure for rbatt only during resume.
As a result separate the functions that read state of charge (soc)
parameters from rbatt parameters. Also note the battery temperature
right before suspend. This will be used for adjusting the rbatt based
on temperature.

Change-Id: I254833f437605d6d64dcd6159edb8440d08383db
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-03-14 10:41:09 -07:00
David Keitel
a1648831cd power: pm8921-charger: remove obsolete wakelock
Remove an obsolete wakelock which used to be part of
the reverse boost fix. The wakelock is not required
because the reverse boost fix relies on the loop
change interrupt when the device is suspended.

Change-Id: Ieea5bcfa76727486a76e238ff1568904170d8545
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-03-14 10:41:09 -07:00
Abhijeet Dharmapurikar
c9ba27184e power: pm8921-charger: calibrate hkadc upon insertion/removal
The hkadc should be calibrated every time a charger is plugged in
or plugged out. This is because the reference voltage shifts a bit
when a charger is plugged in.

Call the bms api to calibrate hkadc.

Change-Id: I89564dcc3ef32af2c3abe422b901c499e91fd2d5
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-03-14 10:41:09 -07:00
Abhijeet Dharmapurikar
40491ce8d0 power: pm8921-charger: implement ir compensation
The charger hardware has a +/-30mv error for vdd_max settings. This
means that when vdd_max is set to 4200mV the actual voltage on vph_pwr
line could range from 4170mV to 4230mV. This further means that when
constant current to constant voltage transition happens, the battery
may not be charged up to 4200mV - leading to an premature end of charge.

Fix this by implementing periodic IR compensation. On a device measure the
resistance from the vbat terminal to the ground by shorting the +ve and
-ve of the battery terminals (without a battery), this will be referred to
as rconn in the description. In the code it is rconn_mohm to reflect the
units.

The voltage at battery terminal will be
Vbat(terminal) = Vbat(xoadc) + Ibat * rconn
where Ibat is the current flowing out of (or into if -ve) of the battery.

Vbat(xoadc) and Ibat can be obtained by using the override mode of the
bms. So Vbat(terminal) can be deduced and compensated by increasing
vdd_max. This also helps in increasing constant current mode thereby
decreasing constant voltage mode and decreasing the overall charging time.

The value of rconn will be specific to a PCB layout, it is
passed in from platform_data.

Change-Id: If8df93333ca6b0bad35505895a4fc5577562fadd
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-03-14 10:41:08 -07:00
Abhijeet Dharmapurikar
9da392dc3c power: pm8921-charger: do not report usb present while in otg
When a usb slave device is being powered by the pmic, the charger
sees a valid voltage on the usb_in line incorrectly reporting that
a valid charger source is present.

It is expected that when a slave device is present the charger is
asked to not draw any current from usb. Use this setting as a flag
to indicate if a valid charger source is present.

Also clean up the implementation by splitting the get property function
in to two - one for usb charger and other for the dc charger.

CRs-Fixed: 339000
Change-Id: I5665f7b2364c61a6f618f4725facf32b209e0249
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-03-13 16:39:13 -07:00
Abhijeet Dharmapurikar
e451f3463b power: pm8921-charger: reset chg failed bit regularly
The charger was observed to freeze for unknown reasons. Clear the failed
bit upon insertion/removal of usb. Also clear that bit in eoc check worker
and the heartbeat worker.

Change-Id: I6419b7ecbfc4d9b73537285357be1e810efa0411
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-03-13 16:39:13 -07:00
Abhijeet Dharmapurikar
acca418a19 power: pm8921-bms: add delta param to bms
The master band gap (MBG) drifts when usb is inserted - a known
problem with the hardware. This drifts in the MBG cause errors
in adc readings - in particular the open circuit voltage of the
battery.

Use the driver to measure how much the 0.625V channel drifts when
a usb is inserted and compensate adc readings using that delta.

Also changed the unsigned nature of the calculations done for
adjusting the battery voltage, it was found doing incorrect
adjustments at very low battery voltages.

Change-Id: I15ea0e8ec0cf7ddd679fda1a7fc864f1ba1b46c2
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-03-13 16:38:08 -07:00
Abhijeet Dharmapurikar
c9857ca398 power: pm8921-bms: add api to simultaneously read vbatt and ibatt
The compensation algorithms need simultaneous readings of the battery
voltage (vbatt) and the current flowing through it (ibatt).

One needs to put the BMS in override mode to get simultaneous vbatt
and ibatt readings.

Note that since one would need to sleep for 20 milliseconds after the
BMS is put in override mode the spin_lock is changed to mutex in the bms
driver.

Change-Id: I1bfdc1f4e84d5d3c2cd6502dd66afdfba650cc0d
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-02-29 21:02:37 -08:00
Abhijeet Dharmapurikar
1b8e8293b6 power: pm8921-bms: calibrate xoadc more often
Improve the values of the battery voltage read from xoadc by periodically
calibrating the xoadc.

The xoadc needs to be calibrated every time a charger is plugged in
or plugged out. This is because the reference voltage shifts a bit
when a charger is plugged in.

Provide an api to calibrate xoadc. This api will be used by the charger
driver.

CRs-Fixed: 334825
Change-Id: I09735f6e5c5d4ab8be379fe001fff81c25c95397
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-02-29 21:02:37 -08:00
Abhijeet Dharmapurikar
bbae8831f4 power: pm8921-bms: add protection against divide by zero
There is a unprotected divide by zero in the driver- when full charge
capacity of the battery and unusable charge of the battery are calculated
equal.

In such a case set state of charge to 0% without the actual division.

Change-Id: I57f3333e780396de29435d29c30e54940c657d4e
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-02-29 21:02:36 -08:00
Abhijeet Dharmapurikar
08e7e0a792 power: pm8921-charger: fix 10mv error on vdd_max
It was observed that the charging voltage is off by 10mV. The root
cause was the 10mV bit in the vdd_max register adds 10mV to the voltage
instead of reducing the voltage by 10mV.

The current driver thinks it subtracts 10mV. Fix this.

Change-Id: I37949113cb4c25642c873ce0cf39ac9fdeb276e1
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-02-29 21:02:36 -08:00
David Keitel
8c5201aec9 power: pm8921-charger: fix reverse boosting
The reverse boosting of PM8921 may cause the USB to be
deemed as present even though it has been unplugged. This
causes unplug detection to fail and also break charging.

Fix this by disabling input regulation (vin_min) as well
as opening the OVP fets to allow capacitors to discharge.

Disabling input regulation nullifies reverse boosting. The usbin
voltage then is stuck at vph_pwr minus some diode drop across
fets. The CHG_GONE_IRQ is indicative of this condition.
This voltage is further reduced by opening up the ovp fets.

Note that before disabling input regulation we reduce the current
drawn from the usb to 500mA. It is expected that at such low current
the charger will not drop its voltage while input regulation remains
disabled.

The condition for detecting reverse boosting remains the same - input
regulation is active and the battery is supplying current instead of
getting charged.

Parameters allowing this workaround to be fine tuned:

param_vin_disable_counter:
max number of times vin_min is disabled, each iteration disables
input regulation for 20 milliseconds. The loop is exited if a
successful usb removal is detected.

param_open_ovp_counter:
number of times OVP fet is forced opened in steps of 20 millisecond.
The loop exits if a valid usb removal is detected.

Change-Id: Ic9e9ca4ef8585f70700053153c825e4f0df645b3
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-02-29 21:02:35 -08:00
David Keitel
35e1187ef9 msm: 8960/8064: robust battery detection
To ensure proper battery id dectection on LiQUID and MTP
use machine_is_msm8960/8064_mtp/cdp to determine which
calibration data to use for battery. If platform is
unknown fall back on regular battery id detection.

Change-Id: I2f5629572d1e5fcac0a2feb114947b91a96f3bf0
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-02-27 10:50:41 -08:00
David Keitel
8f2601b9af power: bms: add desay calibration data
Add the calibration data and battery ID information for the
Desay 5200 mAh battery which is used in LiQUID platform
devices.

Change-Id: I19ff1251ee3e71fa71d4fa0c83143d4b7667a80c
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-02-27 10:50:22 -08:00
Abhijeet Dharmapurikar
cad865a0c5 power: pm8921-bms: adjust battery tolerances based on charging state
Some board designs have grounding issues where current flows from
external common ground instead of the rsense resistor. This is typically
seen on a fake battery power supply setup which also has another device
(such as a callbox) connected to the system ground. IOW the gnd of the
power supply and the ground of the callbox are same and the current flows
from this common ground instead of rsense.

This causes the BMS to see incorrect battery current direction, it thinks
the battery is being charged and moves to a high load state. It recovers
after a while to move back in to low load state. This transition continues
causing irregular increase in sleep current.

Fix this by increasing the battery tolerance while not charging.

CRs-Fixed: 337827
Change-Id: I824387568e93191365faead05a70850f0eed423d
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-02-23 18:28:38 -08:00
David Keitel
63f7166e69 power: pm8921-charger: Report DC charging to userspace
When the secondary charging path is being used without an external
charger report the charging status based upon the DCIN_VALID_IRQ.

Change-Id: I4a992e9f6344588249bd1855cbaae24b0e97a601
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-02-16 13:48:42 -08:00
Abhijeet Dharmapurikar
ccfc4f3abd power: pm8xxx-ccadc: reduce boot time for calibration
- reduce the wait time between adc readings to 20ms from 60ms. This
  speeds up the calibration time.

- move the initial calibration to a workqueue.

CRs-Fixed: 331215
Change-Id: I2034c55f2df8d3e1df216dd5a739cbe70e53c2ed
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-02-07 05:43:14 -07:00
David Keitel
cf86723d34 power: pm8921-charger: set vddmax in increments of step size
When charging a dead battery and increasing VDD_MAX
voltage there may be an inrush current causing USB_IN to
severely drop causing the device to reset.

To avoid this severe drop add a method to increase
or decrease VDD_MAX only in increments of 20 mV until
desired voltage has been reached.

Change-Id: Idf522ac837c75bce7b5a2b3e870696afe29eabf3
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-02-06 10:35:13 -08:00
David Keitel
6ed71a590f power: pm8921-charger: add dc_psy to report AC wall charger
Add dc_psy to report a AC/DC wall-charger to userspace with
correct maximum current setting.

Change-Id: I13f02ff230cf2e43d09439c9f6846e932dc37ff5
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-02-03 11:10:20 -08:00
Linux Build Service Account
a489560278 Merge changes I14ce4941,I645554b6 into msm-3.0
* changes:
  power: pm8921-bms: fix reporting  bms_end_cc_uah = 0
  power: pm8921-bms: accumulate last_charge_increase
2012-02-02 17:28:33 -08:00
Abhijeet Dharmapurikar
28fd0c69ac power: pm8921-charger: limit charger current
Not all chargers can support 1500mA. If a high current is drawn from
such a charger, it drops its voltage rapidly. The vin_min regulation
loop does not kick in because of such rapid decline in the voltage.
This drop causes the pmic to see that the charger is removed and it
stops drawing any current from it. This in turn causes the charger to
raise its voltage but the pmic again draws a high current causing it
to collapse. This collapse and build up or removal and reinsertion
continues indefinitely.

Use the max_current module parameter to set the max
current drawn from charger to prevent it from collapsing voltage.

Also an issue was noticed when sometimes the system enters suspend
while the wall charger is plugged in and charging starts while the
device is suspended. Make the fastchg interrupt wake able so that the
driver can start end of charge worker.

Change-Id: I03f7f60d0bc8a87f7da59af947649a8190ab7994
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-30 14:35:23 -08:00
Abhijeet Dharmapurikar
bc38f636fa power: pm8921-charger: Allow setting -ve cool/warm temperature
The current code assumes that the cool or warm battery temperature
can only be +ve numbers. Remove this restriction by allowing -ve
temperature settings.

Change-Id: I3c54b854a8fdf934efcf1ff21b36c7a0f763692a
CRs-Fixed: 320660
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-26 12:10:52 -08:00
Abhijeet Dharmapurikar
57aeb92ca8 power: pm8921-bms: fix reporting bms_end_cc_uah = 0
There is a bug in the driver where the code to fake full battery
causes coulumb counter based charge (bms_end_cc_uah) to be
reported 0mAh. The reason is once the battery is fully charged a 100% OCV
(open circuit voltage) is faked and columb counter value is offset
such that the coulumb reads start from zero. This faking is cleaned up
until a real OCV happens.

Fix the code such that bms_end_cc_uah is updated before the columb counter
is made to read 0.

Change-Id: I14ce494182ac899205fa41ad815a030d573ab793
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-25 17:18:59 -08:00
Abhijeet Dharmapurikar
ccac695186 power: pm8921-charger: Handle cxo buffers off
The cxo buffers could be turned off while the main cpu(s) are running. This
can cause few issues with the charging driver.

The pmic generates sleep_b signal when all the buffers derived from the
cxo clocks are turned off. This sleep_b signal is fed to all the h/w
subsystems within the pmic.

The charger h/w block uses this for mainly two reasons
1. Turn off the VREF_BATT_THERM signal. This signal drives the battery
thermistor across a resistor divider circuit. With this signal off the
battery temperature is reported too cold. Update the driver to force this
signal on IOW make it not dependent on sleep_b. Remove this forcing when
the system suspends.

2. Run from a slower clock (sleep clk) and as a result freeze charger
register accesses. Force the charger to run from internal cxo clock while
not suspended. This guarantees charger registers are always accessible to
the cpu(s). While suspending, switch back to hw controlled clock sourcing
mode.

While in hw controlled clock sourcing mode,
the charger system switches between cxo and sleep clk depending on
the sleep_b signal. If sleep_b deactivates within six clock
cycles of the sleep clock, the charger doesn't correctly register
an exit from the sleep state and it stops functioning.

To fix this lockup , apply a "kickstart" procedure while resuming. This
procedure involves a series of steps to switch the charger's clock source
between sleep clk and cxo clock with appropriate delays, before finally
switching to cxo clock.

Change-Id: Icda8eb932df0ee7c270d35e2163be7cb8ddd43c3
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-19 15:05:49 -08:00
Abhijeet Dharmapurikar
8a113f874e power: pm8921-bms: accumulate last_charge_increase
The current code always overwrites last_charger_increase when end
of charging happens. Update the code to add the current percent
increase.

Change-Id: I645554b65de627d26ab01399a6e25a9f5a014fe5
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-19 11:06:26 -08:00
David Keitel
88e1b57f00 power: pm8921-charger: support for external charger drivers
Allow the pm8921-charger driver to initiate charging on a
registered 3rd party charging driver through the power supply class.
Also enable the maintenance of charging properties such as online
and charge type using the power supply class rather than
directly depending on the 3rd party driver.

When a external charger is registered using power_supply_register
the external_power_changed callback of the charger driver checks
for an external charger named "dc". This removes the dependency
of a 3rd party charger to call directly into the charger driver.

Also, update the isl9519q driver to reflect the changes and
utilize power supply class calls to enable charging
on the isl chip from PM8921 charger driver.

This serves as an example for other 3rd party external
chargers supporting PMIC with high current charging.

Finally, add pr_fmt macro which automatically adds function name
to print statements and remove __func__ from individual print
statements.

Change-Id: If05e598be260d924ec3263bad33317cf4e7543a1
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-01-13 12:05:11 -08:00
David Keitel
65ddd84042 power: core: add power supply APIs
Rename power_supply_set_charging_by to power_supply_set_online to
more accurately reflect the intent of the API.

Add power_supply_set_charge_type to enable a charger driver to set
a POWER_SUPPLY_PROP_CHARGE_TYPE. Ultimately this is handled like
a request, the receiving charger driver then can handle the request
and report the adequate POWER_SUPPLY_PROP_CHARGE_TYPE once necessary
action has been taken.

Change-Id: Idf4760c7d6c0f61a9eccc656cd469a6ac5fdc6cd
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-01-13 12:04:50 -08:00
Linux Build Service Account
db7e6f0c34 Merge changes I3d468470,Iea735b96,Ifa95e786,I2eb91f1e into msm-3.0
* changes:
  power: pm8921-charger: Workaround for USB unplug issue
  power: pm8921-charger: check vbatdet signal for battery full
  power: pm8921-charger: fix not reporting battery full status at EOC
  power: pm8921-charger: fix host mode charging state
2012-01-10 19:05:19 -08:00
Linux Build Service Account
ea74dd9318 Merge "power: pm8921-bms: Fix coulomb counter overflow" into msm-3.0 2012-01-10 16:04:35 -08:00
Abhijeet Dharmapurikar
c459955b74 power: pm8921-charger: Workaround for USB unplug issue
A problem in PM8921 occurs when a dc charger is unplugged which
leads to the result that the USBIN_VALID_IRQ is not triggered.

Fix this by adding a worker that verifies the sign on the battery
current as well as checking the VIN_ACTIVE loop. If that is the
case we increase the VIN_MIN threshold to trigger the
USBIN_VALID_IRQ to go low.

Also since this worker won't run while the device is suspended,
use the loop change irq to wakeup the device and run the workaround.
While entering suspend, if the usb is plugged in enable the loop change
irq and mark it up as wakeup interrupt.  While resuming restore the
state of loop change irq.

CRs-Fixed: 327861, 326190
Change-Id: I3d46847028ffdad94f76d50f498ab37ce1a3d10e
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-10 15:29:47 -08:00
Abhijeet Dharmapurikar
75c0350ae0 power: pm8921-charger: check vbatdet signal for battery full
The current driver reports a battery full if fsm = 1, the battery is
present and neither the battery nor the charger is hot. However this
could lead to an incorrect reporting as the battery voltage may be
low.

Check the output of vbatdet comparator in addition to the above cases.

Also check the output of vbatdet comparator for end of charging
detection and while at it split, the eoc_worker() function to make it
more readable.

CRs-Fixed: 327890
Change-Id: Iea735b96271da641803670068c1333e5102dc911
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-10 15:29:47 -08:00
Abhijeet Dharmapurikar
a2814a6381 power: pm8921-charger: fix not reporting battery full status at EOC
When EOC (End of Charging) happens the pmic will transition to
FSM_STATE_ON_CHG_HIGHI_1 state and opens the batfet isolating
the battery.

In such a case a FULL status needs to be reported via the power
supply properties. There is bug where the code does not report FULL
status if the charger is not hot.

CRs-Fixed: 327889
Change-Id: Ifa95e786e07f3282912c0325a1f1d98df60a1d63
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-10 15:29:46 -08:00
Abhijeet Dharmapurikar
be05488cdc power: pm8921-charger: fix host mode charging state
While the phone is in usb host mode (supplying power to a usb peripheral)
a charging state is reported. The phone cannot be charging from usb while
supplying power to a usb peripheral.

The fix is to make the usb vbus power code disable charging from usb before
enabling the otg regulators. In addition, the power supply class should not
show a usb charger source present or online when charging is disabled.

CRs-Fixed: 322516
Change-Id: I2eb91f1ea70665b7753924537982b183eb3e8894
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-10 15:29:45 -08:00
Linux Build Service Account
3415e107d0 Merge changes I393f8f0f,I4d3fdc39 into msm-3.0
* changes:
  power: pm8921-bms: allow setting battery charge value
  power: pm8921-bms: change charge units to uAh
2012-01-09 13:44:13 -08:00
Abhijeet Dharmapurikar
da8c3d51bc power: pm8921-bms: Fix coulomb counter overflow
The coulomb counter in hardware is 32bits and is signed. The software
also adds a 32bit value (the cc reading when end of charge happened).
This addition might cause the value of the coulomb counter to overflow.

Fix it by switching to 64bit values before adding to it.

CRs-Fixed: 328352
Change-Id: Ic8268014fccca00acd03b0693896ab494fe94d87
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-06 17:50:46 -08:00
Abhijeet Dharmapurikar
986bd8a2d7 power: pm8921-bms: allow setting battery charge value
Some test teams need to be able to fake certain battery charge percent
values. Update the bms_fake_battery parameter to do that.

Change-Id: I393f8f0f34f717e7ae6facc17eac8b0925ae040a
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-05 15:19:01 -08:00
Abhijeet Dharmapurikar
9c1e399bf2 power: pm8921-bms: change charge units to uAh
Power supply frameworks requires charge units to be in uAh.
Change the driver to use uAh instead of mAh.

Change-Id: I4d3fdc39e4b4104271c417bd36f94a2861149726
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2012-01-05 10:21:49 -08:00
David Keitel
6df9cea2c8 power: pm8921-charger: Add pm8921_set_usb_power_supply_type
USB can distinguish between types of USB connections such as a
DC charger or PC connection.

Let the USB drivers set the specifc power_supply_type via this
function.

CRs-Fixed: 326548
Change-Id: I31954b3f8d2b1e5fd72712e1f94f67fdbc2e205d
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2012-01-04 11:47:00 -08:00