summaryrefslogtreecommitdiffstats
path: root/drivers/power/max17042_battery.c
Commit message (Collapse)AuthorAgeFilesLines
* power_supply: max17042: Add OF support for setting thresholdsKrzysztof Kozlowski2015-06-101-0/+9
| | | | | | | | | | | | | | The commit edd4ab055931 ("power: max17042_battery: add HEALTH and TEMP_* properties support") added support for setting voltage and temperature thresholds with platform data. For DeviceTree default of 0 was always used. This caused reporting battery health always as over voltage or over heated. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Fixes: edd4ab055931 ("power: max17042_battery: add HEALTH and TEMP_* properties support") Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power: max17042_battery: add HEALTH and TEMP_* properties supportRamakrishna Pallala2015-05-231-11/+179
| | | | | | | | | | | | | | | This patch adds the support for following battery properties to max17042 fuel gauge driver. POWER_SUPPLY_PROP_TEMP_ALERT_MIN POWER_SUPPLY_PROP_TEMP_ALERT_MAX POWER_SUPPLY_PROP_TEMP_MIN POWER_SUPPLY_PROP_TEMP_MAX POWER_SUPPLY_PROP_HEALTH Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power: max17042_battery: add missed blankBeomho Seo2015-04-061-0/+2
| | | | | | | | This patch add missed blank line after decalations. Signed-off-by: Beomho Seo <beomho.seo@samsung.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power: max17042_battery: Use reg type instead of chip typeBeomho Seo2015-04-061-23/+10
| | | | | | | | | | Currently, max17042 battery driver choose register map by MAX17042_DevName register. But it is return IC specific firmware version. So other maxim chip hard to use this drvier. This patch choose chip type from driver_data. Signed-off-by: Beomho Seo <beomho.seo@samsung.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: Change ownership from driver to coreKrzysztof Kozlowski2015-03-131-16/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the ownership of power_supply structure from each driver implementing the class to the power supply core. The patch changes power_supply_register() function thus all drivers implementing power supply class are adjusted. Each driver provides the implementation of power supply. However it should not be the owner of power supply class instance because it is exposed by core to other subsystems with power_supply_get_by_name(). These other subsystems have no knowledge when the driver will unregister the power supply. This leads to several issues when driver is unbound - mostly because user of power supply accesses freed memory. Instead let the core own the instance of struct 'power_supply'. Other users of this power supply will still access valid memory because it will be freed when device reference count reaches 0. Currently this means "it will leak" but power_supply_put() call in next patches will solve it. This solves invalid memory references in following race condition scenario: Thread 1: charger manager Thread 2: power supply driver, used by charger manager THREAD 1 (charger manager) THREAD 2 (power supply driver) ========================== ============================== psy = power_supply_get_by_name() Driver unbind, .remove power_supply_unregister() Device fully removed psy->get_property() The 'get_property' call is executed in invalid context because the driver was unbound and struct 'power_supply' memory was freed. This could be observed easily with charger manager driver (here compiled with max17040 fuel gauge): $ cat /sys/devices/virtual/power_supply/cm-battery/capacity & $ echo "1-0036" > /sys/bus/i2c/drivers/max17040/unbind [ 55.725123] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 55.732584] pgd = d98d4000 [ 55.734060] [00000000] *pgd=5afa2831, *pte=00000000, *ppte=00000000 [ 55.740318] Internal error: Oops: 80000007 [#1] PREEMPT SMP ARM [ 55.746210] Modules linked in: [ 55.749259] CPU: 1 PID: 2936 Comm: cat Tainted: G W 3.19.0-rc1-next-20141226-00048-gf79f475f3c44-dirty #1496 [ 55.760190] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [ 55.766270] task: d9b76f00 ti: daf54000 task.ti: daf54000 [ 55.771647] PC is at 0x0 [ 55.774182] LR is at charger_get_property+0x2f4/0x36c [ 55.779201] pc : [<00000000>] lr : [<c034b0b4>] psr: 60000013 [ 55.779201] sp : daf55e90 ip : 00000003 fp : 00000000 [ 55.790657] r10: 00000000 r9 : c06e2878 r8 : d9b26c68 [ 55.795865] r7 : dad81610 r6 : daec7410 r5 : daf55ebc r4 : 00000000 [ 55.802367] r3 : 00000000 r2 : daf55ebc r1 : 0000002a r0 : d9b26c68 [ 55.808879] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 55.815994] Control: 10c5387d Table: 598d406a DAC: 00000015 [ 55.821723] Process cat (pid: 2936, stack limit = 0xdaf54210) [ 55.827451] Stack: (0xdaf55e90 to 0xdaf56000) [ 55.831795] 5e80: 60000013 c01459c4 0000002a c06f8ef8 [ 55.839956] 5ea0: db651000 c06f8ef8 daebac00 c04cb668 daebac08 c0346864 00000000 c01459c4 [ 55.848115] 5ec0: d99eaa80 c06f8ef8 00000fff 00001000 db651000 c027f25c c027f240 d99eaa80 [ 55.856274] 5ee0: d9a06c00 c0146218 daf55f18 00001000 d99eaa80 db4c18c0 00000001 00000001 [ 55.864468] 5f00: daf55f80 c0144c78 c0144c54 c0107f90 00015000 d99eaab0 00000000 00000000 [ 55.872603] 5f20: 000051c7 00000000 db4c18c0 c04a9370 00015000 00001000 daf55f80 00001000 [ 55.880763] 5f40: daf54000 00015000 00000000 c00e53dc db4c18c0 c00e548c 0000000d 00008124 [ 55.888937] 5f60: 00000001 00000000 00000000 db4c18c0 db4c18c0 00001000 00015000 c00e5550 [ 55.897099] 5f80: 00000000 00000000 00001000 00001000 00015000 00000003 00000003 c000f364 [ 55.905239] 5fa0: 00000000 c000f1a0 00001000 00015000 00000003 00015000 00001000 0001333c [ 55.913399] 5fc0: 00001000 00015000 00000003 00000003 00000002 00000000 00000000 00000000 [ 55.921560] 5fe0: 7fffe000 be999850 0000a225 b6f3c19c 60000010 00000003 00000000 00000000 [ 55.929744] [<c034b0b4>] (charger_get_property) from [<c0346864>] (power_supply_show_property+0x48/0x20c) [ 55.939286] [<c0346864>] (power_supply_show_property) from [<c027f25c>] (dev_attr_show+0x1c/0x48) [ 55.948130] [<c027f25c>] (dev_attr_show) from [<c0146218>] (sysfs_kf_seq_show+0x84/0x104) [ 55.956298] [<c0146218>] (sysfs_kf_seq_show) from [<c0144c78>] (kernfs_seq_show+0x24/0x28) [ 55.964536] [<c0144c78>] (kernfs_seq_show) from [<c0107f90>] (seq_read+0x1b0/0x484) [ 55.972172] [<c0107f90>] (seq_read) from [<c00e53dc>] (__vfs_read+0x18/0x4c) [ 55.979188] [<c00e53dc>] (__vfs_read) from [<c00e548c>] (vfs_read+0x7c/0x100) [ 55.986304] [<c00e548c>] (vfs_read) from [<c00e5550>] (SyS_read+0x40/0x8c) [ 55.993164] [<c00e5550>] (SyS_read) from [<c000f1a0>] (ret_fast_syscall+0x0/0x48) [ 56.000626] Code: bad PC value [ 56.011652] ---[ end trace 7b64343fbdae8ef1 ]--- Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> [for the nvec part] Reviewed-by: Marc Dietrich <marvin24@gmx.de> [for compal-laptop.c] Acked-by: Darren Hart <dvhart@linux.intel.com> [for the mfd part] Acked-by: Lee Jones <lee.jones@linaro.org> [for the hid part] Acked-by: Jiri Kosina <jkosina@suse.cz> [for the acpi part] Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: Move run-time configuration to separate structureKrzysztof Kozlowski2015-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add new structure 'power_supply_config' for holding run-time initialization data like of_node, supplies and private driver data. The power_supply_register() function is changed so all power supply drivers need updating. When registering the power supply this new 'power_supply_config' should be used instead of directly initializing 'struct power_supply'. This allows changing the ownership of power_supply structure from driver to the power supply core in next patches. When a driver does not use of_node or supplies then it should use NULL as config. If driver uses of_node or supplies then it should allocate config on stack and initialize it with proper values. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Acked-by: Pavel Machek <pavel@ucw.cz> [for the nvec part] Reviewed-by: Marc Dietrich <marvin24@gmx.de> [for drivers/platform/x86/compal-laptop.c] Reviewed-by: Darren Hart <dvhart@linux.intel.com> [for drivers/hid/*] Reviewed-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: max17042: Use regmap_update_bits instead read and writeKrzysztof Kozlowski2015-02-251-6/+4
| | | | | | | | | | | Consolidate regmap_read() and regmap_write() into one regmap_update_bits() call. This is more readable and safer because regmap's mutex will prevent any concurrent access to modified registers (the concurrent access could happen through max17042_init_chip() in scheduled work). Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power: max17042: Constify struct regmap_configKrzysztof Kozlowski2015-01-201-1/+1
| | | | | | | | The regmap_config struct may be const because it is not modified by the driver and regmap_init() accepts pointer to const. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* max17042_battery: Add IRQF_ONESHOT flag to use default irq handlerJonghwa Lee2013-12-231-3/+3
| | | | | | | | | | This patch adds IRQF_ONESHOT flag to max17042's irq since it uses primary default handler. Without this flag, requesting irq will be denied with returning error. Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* max17042_battery: Support regmap to access device's registersJonghwa Lee2013-10-251-183/+174
| | | | | | | | | This patch makes max17042 fuelguage driver uses regmap API to access its device's registers. Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* max17042_battery: Use SIMPLE_DEV_PM_OPSManish Badarkhe2013-10-251-11/+5
| | | | | | | Use the SIMPLE_DEV_PM_OPS macro to declare the driver's pm_ops. Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linuxAnton Vorontsov2012-12-111-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>
* | max17042_battery: Fix missing verify_model_lock() return value checkAlan Cox2012-11-181-1/+2
|/ | | | | | | | | The second error check is unreachable because the lock function isn't assigned to ret. Signed-off-by: Alan Cox <alan@linux.intel.com> Acked-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Support CHARGE_COUNTER power supply attributeRamakrishna Pallala2012-06-191-0/+8
| | | | | | | | | | This patch adds the support for CHARGE_COUNTER power supply attribute to max17042/47 driver. Note:QH(Charge Counter) register is not documented in max17042 the Spec. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* max17042_battery: Add support for max17047/50 chipRamakrishna Pallala2012-05-051-11/+58
| | | | | | | | | | | | | | max17047 is improved version of max17042 chip. It has few HW bug fixes with minor changes in register set. max17050 is same as max17047 chip except its silicon packging. So from driver's point of view there is no difference btw max1047 and max1050. This patch adds the support to dynamically detect the chip type and adds steps to initialize the max17047 chip. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Handle irq request failure caseRamakrishna Pallala2012-05-051-1/+3
| | | | | | | | suspend/resume functions take action based upon the fuel gauge interrupt. If the rquest irq fails we should assign 0 to client->irq. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Fix power supply and irq registration orderingRamakrishna Pallala2012-05-041-5/+7
| | | | | | | | | IRQ registration should happen only after power supply object usable. This patch fixes the ordering of power supply and irq registration calls. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* power_supply: Add voltage_ocv property and use it for max17042 driverRamakrishna Pallala2012-05-041-0/+8
| | | | | | | | | | | | | This adds a new sysfs file called 'voltage_ocv' which gives the Open Circuit Voltage of the battery. This property can be used for platform shutdown policies and can be useful for initial capacity estimations. Note: This patch is generated against linux-next branch. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Move dev_pm_ops struct under CONFIG_PMAnton Vorontsov2012-05-041-9/+11
| | | | | | | | This is what we do for the rest of the drivers, saves some bytes. Plus a small style change while at it. Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Add suspend/resume hooksRamakrishna Pallala2012-05-041-0/+41
| | | | | | | | | | | | This patch adds suspend/resume methods to the driver. In suspend method irq line is disabled to avoid i2c read/write errors from the interrupt handler as the i2c bus itself could be in suspend state. In resume function irq line will be re-enabled. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Fix driver exit functionRamakrishna Pallala2012-05-041-0/+2
| | | | | | | This patch fixes driver's remove function: it should free the IRQ. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Fix a couple buffer overflowsDan Carpenter2012-05-041-6/+4
| | | | | | | | | | | | | | | | | | | There are a couple issues here caused by confusion between sizeof() and ARRAY_SIZE(). "table_size" should be the number of elements, but we should allocate it with kcalloc() so that we allocate the correct number of bytes. In max17042_init_model() we don't allocate enough space so we go past the end of the array in max17042_read_model_data() and max17042_model_data_compare(). In max17042_verify_model_lock() we allocate the right amount of space but we call max17042_read_model_data() with the wrong number of elements and also in the for loop we go past the end of the array. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Dirk Brandewie <dirk.brandewie@gmail.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Clean up interrupt handlingRamakrishna Pallala2012-03-261-11/+7
| | | | | | | | | | | | | Max17042 driver has dummy hardIRQ function which does nothing but waking the threaded handler. This patch removes the hardIRQ function and also modifies the interrupt type to falling edge. While we are there, change the macros to comply with the Data sheet. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Fix CHARGE_FULL representation.MyungJoo Ham2012-03-261-5/+2
| | | | | | | | | CHARGE_FULL should represent the full capacity of the battery in uAh. The 0x10 (FullCAP) register shows the compensated full capacity in mAh * 2; e.g., reg(0x10) = 0xBB8 means that it is 1500mAh. Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* power_supply: Convert i2c drivers to module_i2c_driverAxel Lin2012-03-261-12/+1
| | | | | | | | | | | | | | | Factor out some boilerplate code for i2c driver registration into module_i2c_driver. Signed-off-by: Axel Lin <axel.lin@gmail.com> Cc: Woogyom Kim <milo.kim@ti.com> Cc: Daniel Jeong <daniel.jeong@ti.com> Cc: Minkyu Kang <mk7.kang@samsung.com> Cc: Peter Edwards <sweetlilmre@gmail.com> Acked-by: Milo(Woogyom) Kim <milo.kim@ti.com> Acked-by: Rhyland Klein <rklein@nvidia.com> Acked-by: Ryan Mallon <rmallon@gmail.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Make it possible to instantiate driver from DTKarol Lewandowski2012-03-261-1/+49
| | | | | | | | | Allow both device tree (preferred) and platform data-based driver instantiation. Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042_battery: Use devm_kzalloc() where applicableKarol Lewandowski2012-03-261-5/+2
| | | | | | | | This allows us to simplify probe and exit function. Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042: Change capacity property to use reported SOC registerDirk Brandewie2012-03-261-1/+1
| | | | | | | | | | | | | | The SOC register (0dh) reports the state of charge before empty compensation adjustments are applied. The max value reported by this register will decrease as the battery ages. Use the RepSOC register (06h) to report the capacity of the battery. RepSOC contains a filtered version of the battery capacity after empty compensation adjustments have been applied. Reported-by: Gary Keyes <gary.e.keyes@intel.com> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042: Add support for signalling change in SOCRamakrishna Pallala2012-03-261-0/+53
| | | | | | | | | If platform has the alert pin attached to an interrupt source have the driver signal a change in the SOC every 1 percent. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* max17042: Add POR init procedure from Maxim appnoteRamakrishna Pallala2012-03-261-10/+376
| | | | | | | | | | | | | Add power on reset (POR) init procedure defined by the maxim appnote. Using this procedure ensures that the part is configured/initialized correctly at POR and improves early accuracy of the fuel gauge and informs the fuel gauge with the battery characterization parameters. The battery characterization parameters come from the maxim characterization procedure. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* Merge branch 'power-supply-scope' of ↵Anton Vorontsov2012-01-041-0/+1
|\ | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen
| * drivers/power: Add module.h to the actual modules in drivers/powerPaul Gortmaker2011-10-311-0/+1
| | | | | | | | | | | | | | | | | | | | The module.h header is no longer going to be implicitly present everywhere. So real modular users need to call out its use explicitly in advance. [v2: add new users reported by Randy Dunlap <rdunlap@xenotime.net>] Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
* | max17042_battery: Fix error handlingRamakrishna Pallala2011-11-261-27/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | In max17042_get_property(...), the values returned by max17042_read_reg are directly assigned to the variables, even if the read results in an error. This patch checks for the return code from max17042_read_reg and exits the function if there is any error. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* | max17042_battery: Bugfix of incorrect voltage register value interpretationMyungJoo Ham2011-08-191-4/+4
| | | | | | | | | | | | | | | | | | | | The calculation had error in getting voltage values from MAX17042 registers. The least bit denotes 78.125uV (625/8). Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Philip Rakity <prakity@marvell.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* | max17042_battery: Do not lose accuracy calculating current_nowPhilip Rakity2011-08-191-2/+1
| | | | | | | | | | | | | | | | | | | | PROP_CURRENT_NOW value is first divided then multiplied up causing a lose of accuracy. Use the same method as PROP_CURRENT_AVG to do the calculation. Signed-off-by: Philip Rakity <prakity@marvell.com> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* | max17042_battery: Divide by 0 crash because r_sns init too latePhilip Rakity2011-08-191-3/+3
|/ | | | | | | | | | | | | | On MMP2 brownstone divide by 0 error since probe sets r_sns after calling power_supply_register. Move the code up a few lines. r_sns comes from the platform data. PROP_CURRENT_AVG and PROP_CURRENT divide the result by r_sns. Signed-off-by: Philip Rakity <prakity@marvell.com> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* power_supply: MAX17042: Support additional propertiesDonggeun Kim2011-07-081-68/+105
| | | | | | | | | | | | This patch supports additional properties (PRESENT, CYCLE_COUNT, VOLTAGE_MAX, VOLTAGE_MIN_DESIGN, CURRENT_NOW, CURRENT_AVG, CHARGE_FULL, and TEMP). Plus, initialization code for registers is added. Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: KyungMin Park <kyungmin.park@samsung.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* max17042_battery: Remove obsolete cleanup for clientdataWolfram Sang2011-07-081-2/+0
| | | | | | | | | | | | A few new i2c-drivers came into the kernel which clear the clientdata-pointer on exit or error. This is obsolete meanwhile, the core will do it. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Cc: MyungJoo Ham <myungjoo.ham@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* power_supply: Add MAX17042 Fuel Gauge DriverMyungJoo Ham2011-01-141-0/+239
The MAX17042 is a fuel gauge with an I2C interface for lithium-ion betteries. Unlike its predecessor MAX17040, MAX17042 uses 16bit registers. Besides, MAX17042 has much more features than MAX17040; e.g., a thermistor, current and current accumulation measurement, battery internal resistance estimate, average values of measurement, and others. This patch implements a driver for MAX17042. In this initial release, we have implemented the most basic features of a fuel gauge: measure the battery capacity and voltage. Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
OpenPOWER on IntegriCloud