aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-18 18:35:09 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-18 18:35:09 -0500
commita709bd585f291b9a6d0a3691ab4a0b9d3300a7a1 (patch)
treee35ef74281f1aefd23bcdb712832685ddb6f0668 /drivers/power
parent3ea369eea07eb64adf36a6fb7fddb5d082c84143 (diff)
parentc8024234c20eaf7b163cc4dbd963cb9cd03a4ff1 (diff)
Merge tag 'for-v3.13' of git://git.infradead.org/battery-2.6
Pull battery updates from Anton Vorontsov: "Highlights: - A new driver for TI BQ24735 Battery Chargers, courtesy of NVidia. - Device tree bindings for TWL4030 chips. - Random fixes and cleanups" * tag 'for-v3.13' of git://git.infradead.org/battery-2.6: pm2301-charger: Remove unneeded NULL checks twl4030_charger: Add devicetree support power_supply: Fix documentation for TEMP_*ALERT* properties max17042_battery: Support regmap to access device's registers max17042_battery: Use SIMPLE_DEV_PM_OPS charger-manager : Replace kzalloc to devm_kzalloc and remove uneccessary code bq2415x_charger: Fix max battery regulation voltage tps65090-charger: Use "IS_ENABLED(CONFIG_OF)" for DT code tps65090-charger: Drop devm_free_irq of devm_ allocated irq power_supply: Add support for bq24735 charger pm2301-charger: Staticize pm2xxx_charger_die_therm_mngt pm2301-charger: Check return value of regulator_enable ab8500-charger: Remove redundant break ab8500-charger: Check return value of regulator_enable isp1704_charger: Fix driver to work with changes introduced in v3.5
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/Kconfig6
-rw-r--r--drivers/power/Makefile1
-rw-r--r--drivers/power/ab8500_charger.c17
-rw-r--r--drivers/power/bq2415x_charger.c6
-rw-r--r--drivers/power/bq24735-charger.c419
-rw-r--r--drivers/power/charger-manager.c85
-rw-r--r--drivers/power/isp1704_charger.c91
-rw-r--r--drivers/power/max17042_battery.c373
-rw-r--r--drivers/power/pm2301_charger.c27
-rw-r--r--drivers/power/tps65090-charger.c30
-rw-r--r--drivers/power/twl4030_charger.c47
11 files changed, 751 insertions, 351 deletions
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index e6f92b450913..5e2054afe840 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -346,6 +346,12 @@ config CHARGER_BQ24190
346 help 346 help
347 Say Y to enable support for the TI BQ24190 battery charger. 347 Say Y to enable support for the TI BQ24190 battery charger.
348 348
349config CHARGER_BQ24735
350 tristate "TI BQ24735 battery charger support"
351 depends on I2C && GPIOLIB
352 help
353 Say Y to enable support for the TI BQ24735 battery charger.
354
349config CHARGER_SMB347 355config CHARGER_SMB347
350 tristate "Summit Microelectronics SMB347 Battery Charger" 356 tristate "Summit Microelectronics SMB347 Battery Charger"
351 depends on I2C 357 depends on I2C
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index a4b74177706f..372b4e8ab598 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o
52obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o 52obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o
53obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o 53obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
54obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o 54obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o
55obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o
55obj-$(CONFIG_POWER_AVS) += avs/ 56obj-$(CONFIG_POWER_AVS) += avs/
56obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o 57obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o
57obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o 58obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index a4c4a10b3a41..19110aa613a1 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -766,7 +766,6 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di,
766 ret = -ENXIO; 766 ret = -ENXIO;
767 break; 767 break;
768 } 768 }
769 break;
770 case USB_STAT_CARKIT_1: 769 case USB_STAT_CARKIT_1:
771 case USB_STAT_CARKIT_2: 770 case USB_STAT_CARKIT_2:
772 case USB_STAT_ACA_DOCK_CHARGER: 771 case USB_STAT_ACA_DOCK_CHARGER:
@@ -1387,8 +1386,12 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger,
1387 * the GPADC module independant of the AB8500 chargers 1386 * the GPADC module independant of the AB8500 chargers
1388 */ 1387 */
1389 if (!di->vddadc_en_ac) { 1388 if (!di->vddadc_en_ac) {
1390 regulator_enable(di->regu); 1389 ret = regulator_enable(di->regu);
1391 di->vddadc_en_ac = true; 1390 if (ret)
1391 dev_warn(di->dev,
1392 "Failed to enable regulator\n");
1393 else
1394 di->vddadc_en_ac = true;
1392 } 1395 }
1393 1396
1394 /* Check if the requested voltage or current is valid */ 1397 /* Check if the requested voltage or current is valid */
@@ -1556,8 +1559,12 @@ static int ab8500_charger_usb_en(struct ux500_charger *charger,
1556 * the GPADC module independant of the AB8500 chargers 1559 * the GPADC module independant of the AB8500 chargers
1557 */ 1560 */
1558 if (!di->vddadc_en_usb) { 1561 if (!di->vddadc_en_usb) {
1559 regulator_enable(di->regu); 1562 ret = regulator_enable(di->regu);
1560 di->vddadc_en_usb = true; 1563 if (ret)
1564 dev_warn(di->dev,
1565 "Failed to enable regulator\n");
1566 else
1567 di->vddadc_en_usb = true;
1561 } 1568 }
1562 1569
1563 /* Enable USB charging */ 1570 /* Enable USB charging */
diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c
index 0727f9256138..df893dd1447d 100644
--- a/drivers/power/bq2415x_charger.c
+++ b/drivers/power/bq2415x_charger.c
@@ -605,9 +605,13 @@ static int bq2415x_set_battery_regulation_voltage(struct bq2415x_device *bq,
605{ 605{
606 int val = (mV/10 - 350) / 2; 606 int val = (mV/10 - 350) / 2;
607 607
608 /*
609 * According to datasheet, maximum battery regulation voltage is
610 * 4440mV which is b101111 = 47.
611 */
608 if (val < 0) 612 if (val < 0)
609 val = 0; 613 val = 0;
610 else if (val > 94) /* FIXME: Max is 94 or 122 ? Set max value ? */ 614 else if (val > 47)
611 return -EINVAL; 615 return -EINVAL;
612 616
613 return bq2415x_i2c_write_mask(bq, BQ2415X_REG_VOLTAGE, val, 617 return bq2415x_i2c_write_mask(bq, BQ2415X_REG_VOLTAGE, val,
diff --git a/drivers/power/bq24735-charger.c b/drivers/power/bq24735-charger.c
new file mode 100644
index 000000000000..d022b823305b
--- /dev/null
+++ b/drivers/power/bq24735-charger.c
@@ -0,0 +1,419 @@
1/*
2 * Battery charger driver for TI BQ24735
3 *
4 * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#include <linux/err.h>
21#include <linux/gpio.h>
22#include <linux/i2c.h>
23#include <linux/init.h>
24#include <linux/interrupt.h>
25#include <linux/kernel.h>
26#include <linux/module.h>
27#include <linux/of.h>
28#include <linux/of_gpio.h>
29#include <linux/power_supply.h>
30#include <linux/slab.h>
31
32#include <linux/power/bq24735-charger.h>
33
34#define BQ24735_CHG_OPT 0x12
35#define BQ24735_CHG_OPT_CHARGE_DISABLE (1 << 0)
36#define BQ24735_CHG_OPT_AC_PRESENT (1 << 4)
37#define BQ24735_CHARGE_CURRENT 0x14
38#define BQ24735_CHARGE_CURRENT_MASK 0x1fc0
39#define BQ24735_CHARGE_VOLTAGE 0x15
40#define BQ24735_CHARGE_VOLTAGE_MASK 0x7ff0
41#define BQ24735_INPUT_CURRENT 0x3f
42#define BQ24735_INPUT_CURRENT_MASK 0x1f80
43#define BQ24735_MANUFACTURER_ID 0xfe
44#define BQ24735_DEVICE_ID 0xff
45
46struct bq24735 {
47 struct power_supply charger;
48 struct i2c_client *client;
49 struct bq24735_platform *pdata;
50};
51
52static inline struct bq24735 *to_bq24735(struct power_supply *psy)
53{
54 return container_of(psy, struct bq24735, charger);
55}
56
57static enum power_supply_property bq24735_charger_properties[] = {
58 POWER_SUPPLY_PROP_ONLINE,
59};
60
61static inline int bq24735_write_word(struct i2c_client *client, u8 reg,
62 u16 value)
63{
64 return i2c_smbus_write_word_data(client, reg, le16_to_cpu(value));
65}
66
67static inline int bq24735_read_word(struct i2c_client *client, u8 reg)
68{
69 s32 ret = i2c_smbus_read_word_data(client, reg);
70