summaryrefslogtreecommitdiffstats
path: root/drivers/power/ab8500_fg.c
Commit message (Collapse)AuthorAgeFilesLines
* ab8500-fg: Use correct battery charge full designRajkumar Kasirajan2013-01-231-1/+2
| | | | | | | | | | | | | | | | If battery is not identified while fg probe, mah_max_design gets initialized with unknown battery's charge full design. Reinitialize mah_max_design if battery is identified after fg probe. Signed-off-by: Rajkumar Kasirajan <rajkumar.kasirajan@stericsson.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Vijaya Kumar K-1 <vijay.kilari@stericsson.com> Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com> Reviewed-by: Olivier CLERGEAUD <olivier.clergeaud@stericsson.com> Reviewed-by: Arun MURTHY <arun.murthy@stericsson.com> Reviewed-by: Rabin VINCENT <rabin.vincent@stericsson.com> Tested-by: Rupesh KUMAR <rupesh.kumar@stericsson.com> Tested-by: Jonas ABERG <jonas.aberg@stericsson.com>
* ab8500-bm: Flush all work queues before suspendingJonas Aaberg2013-01-231-0/+5
| | | | | | | | Flush all workqueues at suspend time to avoid suspending during work. Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com>
* ab8500-fg: Go to INIT_RECOVERY when charger removedMartin Bergström2013-01-231-1/+1
| | | | | | | | | | | When the charger is removed we need to go to INIT_RECOVERY state instead of directly to RECOVERY state. Signed-off-by: Martin Bergstrom <martin.bergstrom@stericsson.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com> Tested-by: Jonas ABERG <jonas.aberg@stericsson.com>
* ab8500-fg: Adjust for RF bursts voltage dropsHakan Berg2013-01-231-14/+27
| | | | | | | | | | | | Changed conditions for restarting low battery measurements counter and adjusted the interval between measurements to avoid RF burst induced voltage drops, and to shorten time to decide to shut down. Signed-off-by: Hakan Berg <hakan.berg@stericsson.com> Signed-off-by: Martin Bergstrom <martin.bergstrom@stericsson.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com> Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com>
* ab8500_fg: Remove pointless round_jiffies() callLee Jones2013-01-161-1/+1
| | | | | | | | As HZ is a full-second, there is little point in rounding it. Let's save a few cycles by using HZ directly. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* ab8500_fg: Overflow in current calculationPaer-Olof Haakansson2013-01-161-5/+4Star
| | | | | | | | | | | | When calculating the average current the nominator will overflow when the charging current is high. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Henrik Sölver <henrik.solver@stericsson.com> Reviewed-by: Par-Olof HAKANSSON <par-olof.hakansson@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com> Tested-by: Par-Olof HAKANSSON <par-olof.hakansson@stericsson.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* ab8500_fg: Added support for BATT_OVVHakan Berg2013-01-161-15/+15
| | | | | | | | | Add support for the battery over-voltage situation Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Hakan Berg <hakan.berg@stericsson.com> Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* ab8500_fg: Round capacity outputpender012013-01-161-13/+15
| | | | | | | | | | Round the capacity values for better enduser experience. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: pender01 <peter.enderborg@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com> Tested-by: Marcus COOPER <marcus.xm.cooper@stericsson.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* ab8500_fg: Balance IRQ enableRickard Andersson2013-01-161-0/+1
| | | | | | | | | | In case of time out error IRQ needs to be disabled otherwise we will get unbalanced enable/disable pairs. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Rickard Andersson <rickard.andersson@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* ab8500_bm: Recharge condition not optimal for batteryMarcus Cooper2013-01-161-11/+135
| | | | | | | | | | | | | | | | | | | | | | | Today the battery recharge is determined with a voltage threshold. This voltage threshold is only valid when the battery is relaxed. In charging algorithm the voltage read is the loaded battery voltage and no compensation is done to get the relaxed voltage. When maintenance charging is not selected, this makes the recharging condition to almost immediately activate when there is a discharge present on the battery. Depending on which vendor the battery comes from this behavior can wear out the battery much faster than normal. The fuelgauge driver is responsible to monitor the actual battery capacity and is able to estimate the remaining capacity. It is better to use the remaining capacity as a limit to determine when battery should be recharged. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Marcus Cooper <marcus.xm.cooper@stericsson.com> Reviewed-by: Hakan BERG <hakan.berg@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* ab8500_fg: Replace msleep() with usleep_range() for greater accuracyJonas Aaberg2013-01-161-1/+1
| | | | | | | | | | | Doing so provides a greater degree of accuracy when dealing with time-frames between 1us and 20ms. msleep() is only accurate for wake-ups greater than 20ms. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Jonas ABERG <jonas.aberg@stericsson.com> Reviewed-by: Johan BJORNSTEDT <johan.bjornstedt@stericsson.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* ab8500_bm: Skip first CCEOC irq for instant currentJohan Bjornstedt2013-01-161-8/+55
| | | | | | | | | | | | When enabling the CCEOC irq we might get false interrupt from ab8500-driver due to the latched value will be saved and interpreted as an IRQ when enabled Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Johan Bjornstedt <johan.bjornstedt@stericsson.com> Signed-off-by: Henrik Solver <henrik.solver@stericsson.com> Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* Merge branch 'for-anton' of git://git.linaro.org/people/ljones/linux-3.0-ux500Anton Vorontsov2013-01-061-62/+61Star
|\
| * ab8500_fg: Reorder obtainment of platform specific battery management dataLee Jones2012-12-111-14/+13Star
| | | | | | | | | | | | | | | | | | | | | | Now that we always pass platform specific battery management data through platform_data instead of obtaining it via different means depending the way be boot the system (DT or ATAGs); we need to re-jiggle the way we acquire it in the driver start-up functions. Now it is wrong for it to be missing, but we still allow Device Tree code to fiddle with it once we've confirmed it's there. Signed-off-by: Lee Jones <lee.jones@linaro.org>
| * ab8500_bm: Always send platform specific battery information via pdataLee Jones2012-12-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the AB8500 battery management subsystem receives platform specific information via two different means depending on how the platform is booted. If DT is not enabled, a reference to a *_bm_data data structure containing each platform specific attribute is passed though platform_data. However, if DT is enabled, then platform_data is empty and the reference is gained though a DT specific probe function. There are two issues here 1) the same reference is being collected each time and 2) the DT way doesn't allow any provisions to select different platform specific attributes, which kind of defeats the object. Cc: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
| * ab8500_bm: Rename battery management platform data to something more logicalLee Jones2012-12-111-48/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | The platform specific battery management configuration data structure is currently called 'bat' short for 'battery'; however, it contains information for all components of the battery management group, rather than information pertaining to the battery itself - there are other structures for that. So, in keeping with its structure namesake 'abx500_bm_data', we rename it to 'bm' here. Using similar logic, we're also renaming 'bmdevs_of_probe' to the more device specific 'ab8500_bm_of_probe'. Signed-off-by: Lee Jones <lee.jones@linaro.org>
| * ab8500_fg: Don't clear the CCMuxOffset bitKalle Komierowski2012-12-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | The CCMuxOffset bit is not kept set. This will force the columb counter of the AB8500 to use the measure offset calibration. This should increase the accuracy of the fuel gauge. Signed-off-by: Kalle Komierowski <karl.komierowski@stericsson.com> Signed-off-by: Marcus Cooper <marcus.xm.cooper@stericsson.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
* | Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linuxAnton Vorontsov2012-12-121-3/+3
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | The merge is merely to fix conflicts before sending a pull request. Conflicts: drivers/power/ab8500_btemp.c drivers/power/ab8500_charger.c drivers/power/ab8500_fg.c drivers/power/abx500_chargalg.c drivers/power/max8925_power.c Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
| * power: remove use of __devexitBill Pemberton2012-11-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | CONFIG_HOTPLUG is going away as an option so __devexit is no longer needed. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Cc: Anton Vorontsov <cbou@mail.ru> Cc: David Woodhouse <dwmw2@infradead.org> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * power: remove use of __devinitBill Pemberton2012-11-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | CONFIG_HOTPLUG is going away as an option so __devinit is no longer needed. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Cc: Anton Vorontsov <cbou@mail.ru> Cc: David Woodhouse <dwmw2@infradead.org> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * power: remove use of __devexit_pBill Pemberton2012-11-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer needed. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Cc: Anton Vorontsov <cbou@mail.ru> Cc: David Woodhouse <dwmw2@infradead.org> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | ab8500: Add devicetree support for fuelgaugeRajanikanth H.V2012-11-191-40/+42
|/ | | | | | | | | | | | - This patch adds device tree support for fuelgauge driver - optimize bm devices platform_data usage and of_probe(...) Note: of_probe() routine for battery managed devices is made common across all bm drivers. - test status: - interrupt numbers assigned differs between legacy and FDT mode. Signed-off-by: Rajanikanth H.V <rajanikanth.hv@stericsson.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* Merge tag 'for-v3.7' of git://git.infradead.org/battery-2.6Linus Torvalds2012-10-071-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull battery updates from Anton Vorontsov: "1. New drivers: - Marvell 88pm860x charger and battery drivers; - Texas Instruments LP8788 charger driver; 2. Two new power supply properties: whether a battery is authentic, and chargers' maximal currents and voltages; 3. A lot of TI LP8727 Charger cleanups; 4. New features for Charger Manager, mainly now we can disable specific regulators; 5. Random fixes and cleanups for other drivers." Fix up trivial conflicts in <linux/mfd/88pm860x.h> * tag 'for-v3.7' of git://git.infradead.org/battery-2.6: (52 commits) pda_power: Remove ac_draw_failed goto and label charger-manager: Add support sysfs entry for charger charger-manager: Support limit of maximum possible charger-manager: Check fully charged state of battery periodically lp8727_charger: More pure cosmetic improvements lp8727_charger: Fix checkpatch warning lp8727_charger: Add description in the private data lp8727_charger: Fix a typo - chg_parm to chg_param lp8727_charger: Make some cosmetic changes in lp8727_delayed_func() lp8727_charger: Clean up lp8727_charger_changed() lp8727_charger: Return if the battery is discharging lp8727_charger: Make lp8727_charger_get_propery() simpler lp8727_charger: Make lp8727_ctrl_switch() inline lp8727_charger: Make lp8727_init_device() shorter lp8727_charger: Clean up lp8727_is_charger_attached() lp8727_charger: Use specific definition lp8727_charger: Clean up lp8727 definitions lp8727_charger: Use the definition rather than enum lp8727_charger: Fix code for getting battery temp lp8727_charger: Clear interrrupts at inital time ...
| * ab8500_fg: Fix error return codeJulia Lawall2012-08-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initialize return variable before exiting on an error path. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* | workqueue: make deferrable delayed_work initializer names consistentTejun Heo2012-08-211-4/+4
|/ | | | | | | | | | | | | | | | | | Initalizers for deferrable delayed_work are confused. * __DEFERRED_WORK_INITIALIZER() * DECLARE_DEFERRED_WORK() * INIT_DELAYED_WORK_DEFERRABLE() Rename them to * __DEFERRABLE_WORK_INITIALIZER() * DECLARE_DEFERRABLE_WORK() * INIT_DEFERRABLE_WORK() This patch doesn't cause any functional changes. Signed-off-by: Tejun Heo <tj@kernel.org>
* ab8500: Clean up probe routinesLee Jones2012-05-051-6/+10
| | | | | | | | These patches clean up some ugliness and brings the variable initialisation formatting more into line with other drivers. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* ab8500_fg: Harden platform data checkLinus Walleij2012-05-051-2/+2
| | | | | | | | | | If no platform data at all is supplied the driver crashes, extend the checks to be more careful so we can compile in the driver and boot also without platform data present. Acked-by: Arun Murthy <arun.murthy@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* ab8500_fg: Fix some build warnings on x86_64Anton Vorontsov2012-03-261-2/+2
| | | | | | | | | | | | | | Noticed the following warnings: CC drivers/power/ab8500_fg.o drivers/power/ab8500_fg.c: In function 'charge_full_store': drivers/power/ab8500_fg.c:2258:2: warning: format '%d' expects argument of type 'int', but argument 4 has type 'ssize_t' [-Wformat] drivers/power/ab8500_fg.c: In function ‘charge_now_store’: drivers/power/ab8500_fg.c:2280:2: warning: format '%d' expects argument of type 'int', but argument 4 has type 'ssize_t' [-Wformat] This patch fixes the issues. Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* ab8500: Turn unneeded global symbols into local onesAnton Vorontsov2012-03-261-1/+1
| | | | | | | | | | The patch fixes the following sparse warning: drivers/power/ab8500_charger.c:1619:6: warning: symbol 'ab8500_charger_detect_usb_type_work' was not declared. Should it be static? drivers/power/abx500_chargalg.c:1709:24: warning: symbol 'abx500_chargalg_sysfs_ops' was not declared. Should it be static? drivers/power/ab8500_fg.c:2328:24: warning: symbol 'ab8500_fg_sysfs_ops' was not declared. Should it be static? Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* ab8500_fg: Fix copy-paste errorAnton Vorontsov2012-03-261-1/+1
| | | | | | | | ab8500_fg_discharge_state_to() function should accept 'enum ab8500_fg_discharge_state' argument, not 'enum ab8500_fg_charge_state'. Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* ab8500_fg: Get rid of 'struct battery_type'Anton Vorontsov2012-03-261-1/+2
| | | | | | | | | | The struct is duplicated, plus causes the following flood: CC drivers/power/ab8500_fg.o ab8500_fg.c: In function ‘ab8500_fg_get_ext_psy_data’: b8500_fg.c:2081:8: warning: assignment from incompatible pointer type [enabled by default] Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* ab8500_fg: Get rid of 'struct v_to_cap'Anton Vorontsov2012-03-261-1/+1
| | | | | | | | | | | | | | | The struct is duplicated, plus when used it causes the following warnings: CHECK drivers/power/ab8500_fg.c ab8500_fg.c:818:13: warning: incorrect type in assignment (different base types) ab8500_fg.c:818:13: expected struct v_to_cap *tbl ab8500_fg.c:818:13: got struct abx500_v_to_cap *const v_to_cap_tbl CC drivers/power/ab8500_fg.o ab8500_fg.c: In function 'ab8500_fg_volt_to_capacity': ab8500_fg.c:818:6: warning: assignment from incompatible pointer type [enabled by default] Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* ab8500-fg: A8500 fuel gauge driverArun Murthy2012-03-261-0/+2636
This driver is responsible for provide battery parameters to user space via sysfs by registers to power supply class. It uses fuel gauge and gpadc driver in obtaining the battery parameters. These battery properties are used by abx500 charging algorithm driver to monitor the battery. Signed-off-by: Arun Murthy <arun.murthy@stericsson.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>