summaryrefslogtreecommitdiff
path: root/drivers/power
AgeCommit message (Collapse)Author
2011-04-26Merge branch 'master' into for-nextJiri Kosina
Fast-forwarded to current state of Linus' tree as there are patches to be applied for files that didn't exist on the old branch.
2011-04-10treewide: remove extra semicolonsJustin P. Mattock
Signed-off-by: Justin P. Mattock <justinmattock@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-03-29drivers: Final irq namespace conversionThomas Gleixner
Scripted with coccinelle. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2011-03-25Merge git://git.infradead.org/battery-2.6Linus Torvalds
* git://git.infradead.org/battery-2.6: (30 commits) bq20z75: Fix time and temp units bq20z75: Fix issues with present and suspend z2_battery: Fix count of properties s3c_adc_battery: Fix method names when PM not set z2_battery: Add MODULE_DEVICE_TABLE ds2782_battery: Add MODULE_DEVICE_TABLE bq20z75: Add MODULE_DEVICE_TABLE power_supply: Update power_supply_is_watt_property bq20z75: Add i2c retry mechanism bq20z75: Add optional battery detect gpio twl4030_charger: Make the driver atomic notifier safe bq27x00: Use single i2c_transfer call for property read bq27x00: Cleanup bq27x00_i2c_read bq27x00: Minor cleanups bq27x00: Give more specific reports on battery status bq27x00: Add MODULE_DEVICE_TABLE bq27x00: Add new properties bq27x00: Poll battery state bq27x00: Cache battery registers bq27x00: Add bq27000 support ...
2011-03-23jz4740: silence warnings related to mfd_get_cell changesAndres Salomon
mfd_get_cell returns a const, so change the jz4740 clients to store a const mfd cell. This silences type mismatch warnings. Signed-off-by: Andres Salomon <dilinger@queued.net> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2011-03-23mfd: mfd_cell is now implicitly available to jz4740 driversAndres Salomon
No need to explicitly set the cell's platform_data/data_size. Modify clients to use mfd_get_cell helper function instead of accessing platform_data directly. Signed-off-by: Andres Salomon <dilinger@queued.net> Acked-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2011-03-16bq20z75: Fix time and temp unitsBenson Leung
Corrected temperature and time to empty/full conversions. Temperature is in 0.1°C, time is in seconds. Corrected units in comment. "Convert to µWh." Signed-off-by: Benson Leung <bleung@chromium.org> Acked-by: Rhyland Klein <rklein@nvidia.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-03-16bq20z75: Fix issues with present and suspendRhyland Klein
There are a few issues found around the battery not being present. If the battery isn't present, then a few undesirable things happen. The first was excessive reporting of failed properties. This was fixed by instead returning ENODATA for all properties other than PRESENT if the battery isn't present. That way the callers can identify the difference between a failure and the battery not being there. The next issue was in the suspend logic. It was found that if the battery wasn't present, then it would return a failure, preventing the system from going into suspend. If there is no battery present, the io is expected to fail, so in that case, we shouldn't return the failure and just acknowledge that it was expected. I also found that when a gpio was used, i didn't maintain the internal is_present state properly. I added a set of that to fix that. Lastly, the code to see io's fail and figure out that the battery isn't present when not using a gpio had a problem. In that code, it looked for the read to fail and if it did, then handled it. The problem is that in function to get the property, it first writes a value and that write can fail, causing the code to never reach the logic after the read. Fix is to move the logic till after the write. Signed-off-by: Rhyland Klein <rklein@nvidia.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-03-16z2_battery: Fix count of propertiesVasily Khoruzhick
PROP_STATUS property was not counted, as result VOLTAGE_MIN property is missing in sysfs. Fix it. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Acked-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-03-16s3c_adc_battery: Fix method names when PM not setHeiko Stuebner
s3c_adc_battery declares wrong method names when CONFIG_PM is not set. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Acked-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-03-01z2_battery: Add MODULE_DEVICE_TABLEAxel Lin
The device table is required to load modules based on modaliases. After adding the MODULE_DEVICE_TABLE, below entry will be added to modules.alias: alias i2c:aer915 z2_battery Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-03-01ds2782_battery: Add MODULE_DEVICE_TABLEAxel Lin
The device table is required to load modules based on modaliases. After adding the MODULE_DEVICE_TABLE, below entries will be added to modules.alias: alias i2c:ds2786 ds2782_battery alias i2c:ds2782 ds2782_battery Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-03-01bq20z75: Add MODULE_DEVICE_TABLEAxel Lin
The device table is required to load modules based on modaliases. After adding the MODULE_DEVICE_TABLE, below entry will be added to modules.alias: alias i2c:bq20z75 bq20z75 Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-03-01bq20z75: Add i2c retry mechanismRhyland Klein
With the support of platform data, now adding support for option i2c retries on read/write failures. Ths is specified through the optional platform data. Signed-off-by: Rhyland Klein <rklein@nvidia.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-03-01bq20z75: Add optional battery detect gpioRhyland Klein
Adding support for an optional gpio for battery detection. This is passed in through the i2c platform data. It also accepts another field, battery_detect_present to signify the gpio state which means the battery is present, either 0 (low) or 1 (high). Signed-off-by: Rhyland Klein <rklein@nvidia.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-02-28Merge branch 'bq27x00-for-upstream' of git://git.metafoo.de/linux-2.6Anton Vorontsov
2011-02-28twl4030_charger: Make the driver atomic notifier safeHeikki Krogerus
This queues work from the otg notification where the i2c operations can be safely made. Needed for atomic otg notifiers. Signed-off-by: Heikki Krogerus <heikki.krogerus@nokia.com> Tested-by: Grazvydas Ignotas <notasas@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-02-22bq27x00: Use single i2c_transfer call for property readGrazvydas Ignotas
Doing this by using 2 calls sometimes results in unexpected values being returned on OMAP3 i2c controller. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2011-02-22bq27x00: Cleanup bq27x00_i2c_readLars-Peter Clausen
Some minor stylistic cleanups. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Minor cleanupsPali Rohár
* Consistently use uppercase for hexadecimal values. * Clarify/fix the unit of functions return value in its comment. Signed-off-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Give more specific reports on battery statusLars-Peter Clausen
The current code only reports whether the battery is charging or discharging. But the battery also reports whether it is fully charged, furthermore by look at if the battery is supplied we can tell whether it is discharging or not charging. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Rodolfo Giometti <giometti@linux.it> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Add MODULE_DEVICE_TABLEPali Rohár
This patch adds MODULE_DEVICE_TABLE for module bq27x00_battery. Signed-off-by: Pali Rohár <pali.rohar@gmail.com> Tested-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Rodolfo Giometti <giometti@linux.it> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Add new propertiesPali Rohár
This patch add support for reporting properties POWER_SUPPLY_PROP_CHARGE_NOW, POWER_SUPPLY_PROP_CHARGE_FULL, POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, POWER_SUPPLY_PROP_CHARGE_COUNTER, POWER_SUPPLY_PROP_ENERGY_NOW in module bq27x00_battery. Signed-off-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Poll battery stateLars-Peter Clausen
This patch adds support for polling the battery state and generating a power_supply_changed() event if it has changed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Cache battery registersLars-Peter Clausen
This patch adds a register cache to the bq27x00 battery driver. Usually multiple, if not all, power_supply properties are queried at once, for example when an uevent is generated. Since some registers are used by multiple properties caching the registers should reduce the number of reads. The cache is valid for 5 seconds this roughly matches the internal update interval of the current register for the bq27000/bq27200. Fast changing properties(*_NOW) which can be obtained by reading a single register are not cached. It will also be used in the follow up patch to check if the battery status has been changed since the last update to emit power_supply_changed events. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Add bq27000 supportLars-Peter Clausen
This patch adds support for the bq27000 battery to the bq27x00 driver. The bq27000 is similar to the bq27200 except that it uses the HDQ bus instead of I2C to communicate with the host system. The driver is implemented as a platform driver. The driver expects to be provided with a read callback function through its platform data. The read function is assumed to do the lowlevel HDQ handling and read out the value of a certain register. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Prepare code for addition of bq27000 platform driverLars-Peter Clausen
This patch simplifies the drivers data structure and moves code to be shared by the bq27000 and bq27200/bq27500 init functions into a common function. This patch has no functional changes, it only moves code around. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Rodolfo Giometti <giometti@linux.it> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Return -ENODEV for properties if the battery is not presentLars-Peter Clausen
This patch changes get_property callback of the bq27x00 battery to return -ENODEV for properties other then the PROP_PRESENT if the battery is not present. The power subsystem core expects a driver to behave that way. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Rodolfo Giometti <giometti@linux.it> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Fix CURRENT_NOW propertyPali Rohár
According to the bq27000 datasheet the current should be calculated by the following formula: current = AI * 3570 / 20 This patch adjust the drivers code accordingly. Signed-off-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Rodolfo Giometti <giometti@linux.it> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Improve temperature property precessionLars-Peter Clausen
This patch improves the precession of the temperature property of the bq27x00 driver. By dividing before multiplying the current code effectively cuts of the last decimal digit. This patch fixes it by multiplying before dividing. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Rodolfo Giometti <giometti@linux.it> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22bq27x00: Add type propertyLars-Peter Clausen
This patch adds the type property to the bq27x00 battery driver. All bq27x00 are lithium ion batteries. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Rodolfo Giometti <giometti@linux.it> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22power_supply: Initialize changed_work before calling device_addLars-Peter Clausen
Calling device_add causes an inital uevent for that device to be generated. The power_supply uevent function calls the drivers get_property function, which might causes the driver to update its state, which again might causes the driver to call power_supply_changed(). Since the power_supplys changed_work has not been initialized at this point the behavior is undefined and can result in an OOPS. This patch fixes the issue by initializing the power_supplys changed_work prior to adding the power_supplys device to the device tree. Reported-by: Grazvydas Ignotas <notasas@gmail.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-02-22power_supply: Ignore -ENODATA errors when generating ueventsLars-Peter Clausen
Sometimes a driver can not report a meaningful value for a certain property and returns -ENODATA. Currently when generating a uevent and a property return -ENODATA it is treated as an error an no uevent is generated at all. This is not an desirable behavior. This patch adds a special case for -ENODATA and ignores properties which return this error code when generating the uevent. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
2011-01-31power_supply: Add new LED trigger charging-blink-solid-fullVasily Khoruzhick
Add new trigger to power_supply LEDs. It will blink when battery is charging, and stay solid when battery is charged. It's usefull to indicate battery state when there's only one LED available. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-01-31bq20z75: Add support for charge propertiesRhyland Klein
Adding support for charge properties for gas gauge. Also ensuring that battery mode is correct now for energy as well as charge properties by setting it on the fly. I also added 2 functions to power_supply.h to help identify the units for specific properties more easily by power supplies. Signed-off-by: Rhyland Klein <rklein@nvidia.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-01-14Merge git://git.infradead.org/battery-2.6Linus Torvalds
* git://git.infradead.org/battery-2.6: (21 commits) power_supply: Add MAX17042 Fuel Gauge Driver olpc_battery: Fix up XO-1.5 properties list olpc_battery: Add support for CURRENT_NOW and VOLTAGE_NOW olpc_battery: Add support for CHARGE_NOW olpc_battery: Add support for CHARGE_FULL_DESIGN olpc_battery: Ambient temperature is not available on XO-1.5 jz4740-battery: Should include linux/io.h s3c_adc_battery: Add gpio_inverted field to pdata power_supply: Don't use flush_scheduled_work() power_supply: Fix use after free and memory leak gpio-charger: Fix potential race between irq handler and probe/remove gpio-charger: Provide default name for the power_supply gpio-charger: Check result of kzalloc jz4740-battery: Check if platform_data is supplied isp1704_charger: Detect charger after probe isp1704_charger: Set isp->dev before anything needs it isp1704_charger: Detect HUB/Host chargers isp1704_charger: Correct length for storing model power_supply: Add gpio charger driver jz4740-battery: Protect against concurrent battery readings ...
2011-01-14power_supply: Add MAX17042 Fuel Gauge DriverMyungJoo Ham
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>
2011-01-13Merge branch 'for-next' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (43 commits) Documentation/trace/events.txt: Remove obsolete sched_signal_send. writeback: fix global_dirty_limits comment runtime -> real-time ppc: fix comment typo singal -> signal drivers: fix comment typo diable -> disable. m68k: fix comment typo diable -> disable. wireless: comment typo fix diable -> disable. media: comment typo fix diable -> disable. remove doc for obsolete dynamic-printk kernel-parameter remove extraneous 'is' from Documentation/iostats.txt Fix spelling milisec -> ms in snd_ps3 module parameter description Fix spelling mistakes in comments Revert conflicting V4L changes i7core_edac: fix typos in comments mm/rmap.c: fix comment sound, ca0106: Fix assignment to 'channel'. hrtimer: fix a typo in comment init/Kconfig: fix typo anon_inodes: fix wrong function name in comment fix comment typos concerning "consistent" poll: fix a typo in comment ... Fix up trivial conflicts in: - drivers/net/wireless/iwlwifi/iwl-core.c (moved to iwl-legacy.c) - fs/ext4/ext4.h Also fix missed 'diabled' typo in drivers/net/bnx2x/bnx2x.h while at it.
2011-01-13olpc_battery: Fix up XO-1.5 properties listSascha Silbe
The patches adding support for CURRENT_NOW, VOLTAGE_NOW, CHARGE_NOW and CHARGE_FULL_DESIGN were based on a tree not including c566d299 ("olpc_battery: Ambient temperature is not available on XO-1.5") and therefore only modified the then-common, now-XO-1 properties list. This patch adds the new properties to XO-1.5 as well. Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-01-12olpc_battery: Add support for CURRENT_NOW and VOLTAGE_NOWSascha Silbe
{CURRENT,VOLTAGE}_AVG are actually {CURRENT,VOLTAGE}_NOW (the EC code directly passes through the value from the gas gauge instead of the internally used average). We retain {CURRENT,VOLTAGE}_AVG as an alias for compatibility reasons, it will be removed later. Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org> [ pgf@laptop.org: added VOLTAGE_NOW, aliased to VOLTAGE_AVG ] Signed-off-by: Paul Fox <pgf@laptop.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-01-12olpc_battery: Add support for CHARGE_NOWSascha Silbe
CHARGE_NOW is needed by some user space software (read: UPower) for internal calculations. This patch violates the power supply class definition (as we already do for CAPACITY though it isn't as obvious there), but this is the best we can do without adding rather sophisticated algorithms to either the EC or UPower. Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org> Signed-off-by: Paul Fox <pgf@laptop.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-01-12olpc_battery: Add support for CHARGE_FULL_DESIGNSascha Silbe
Some user space software (read: UPower) uses CHARGE_FULL_DESIGN for internal calculations. The design capacity of the OLPC batteries is effectively fixed and only needs to be exported. Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org> Signed-off-by: Paul Fox <pgf@laptop.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2011-01-12olpc_battery: Ambient temperature is not available on XO-1.5Daniel Drake
The XO-1.5 does not support the ambient temperature property. Create a separate list of properties for that configuration where ambient temperature is not included, and apply the correct property list at runtime. Signed-off-by: Daniel Drake <dsd@laptop.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2010-12-22jz4740-battery: Should include linux/io.hAnton Vorontsov
During test-build (with disabled 'depends on') I found that jz4740-battery driver lacks linux/io.h, which makes build break like this (on x86): CC [M] drivers/power/isp1704_charger.o jz4740-battery.c: In function 'jz_battery_read_voltage': jz4740-battery.c:84: error: implicit declaration of function 'readw’ jz4740-battery.c: In function 'jz_battery_probe': jz4740-battery.c:284: error: implicit declaration of function 'ioremap_nocache’ jz4740-battery.c:285: warning: assignment makes pointer from integer without a cast jz4740-battery.c:372: error: implicit declaration of function 'iounmap' make[2]: *** [drivers/power/jz4740-battery.o] Error 1 This patch fixes the issues, and thus makes it easier to build-test the driver for me. Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2010-12-22s3c_adc_battery: Add gpio_inverted field to pdataVasily Khoruzhick
Add support for inverted gpio_charge_finished values. This change is necessary for H1940 support. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2010-12-22power_supply: Don't use flush_scheduled_work()Tejun Heo
flush_scheduled_work() is deprecated and scheduled to be removed. In battery drivers, the work can be canceled on probe failure and removal and should be flushed on suspend. Replace flush_scheduled_work() usages with direct cancels and flushes. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2010-12-22power_supply: Fix use after free and memory leakVasiliy Kulikov
device_unregister() might free its argument. This leads to freed memory use in kfree(). Also use put_device() instead of kfree() as dev may be already used in another layer after call to device_add(). Signed-off-by: Vasiliy Kulikov <segoon@openwall.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2010-12-22gpio-charger: Fix potential race between irq handler and probe/removeLars-Peter Clausen
This patch fixes a potential race between the irq handler and the probe and remove functions. The irq should not be requested before the chargers power_supply has been registered and has to be freed before the power_supply is unregistered, otherwise it is possible that the irq fires while the power_supply is not initialized yet or has already been freed. While we are at it replace request_irq with request_any_context_irq. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2010-12-22gpio-charger: Provide default name for the power_supplyLars-Peter Clausen
This patch sets a default name for the power_supply in case there was no name supplied through the platform_data. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2010-12-22gpio-charger: Check result of kzallocLars-Peter Clausen
Since kzalloc can return NULL we have to check its result. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com> Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>