diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-26 00:00:29 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-26 00:00:29 -0400 |
| commit | 56a9ccb7ba5ffd5f285e3a9628cb446192c8639c (patch) | |
| tree | a9d54537cea4761073374ef5fbc9097cbfe52440 | |
| parent | 44bbd7ac2658eb1118342493026ef141e259b739 (diff) | |
| parent | 909a78b320b31ca9709d7ea5f602ec1bd2015192 (diff) | |
Merge git://git.infradead.org/battery-2.6
* 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
...
| -rw-r--r-- | drivers/leds/led-triggers.c | 20 | ||||
| -rw-r--r-- | drivers/power/Kconfig | 14 | ||||
| -rw-r--r-- | drivers/power/bq20z75.c | 310 | ||||
| -rw-r--r-- | drivers/power/bq27x00_battery.c | 725 | ||||
| -rw-r--r-- | drivers/power/ds2782_battery.c | 1 | ||||
| -rw-r--r-- | drivers/power/power_supply_core.c | 4 | ||||
| -rw-r--r-- | drivers/power/power_supply_leds.c | 19 | ||||
| -rw-r--r-- | drivers/power/power_supply_sysfs.c | 2 | ||||
| -rw-r--r-- | drivers/power/s3c_adc_battery.c | 4 | ||||
| -rw-r--r-- | drivers/power/twl4030_charger.c | 25 | ||||
| -rw-r--r-- | drivers/power/z2_battery.c | 3 | ||||
| -rw-r--r-- | include/linux/leds.h | 3 | ||||
| -rw-r--r-- | include/linux/power/bq20z75.h | 39 | ||||
| -rw-r--r-- | include/linux/power/bq27x00_battery.h | 19 | ||||
| -rw-r--r-- | include/linux/power_supply.h | 47 |
15 files changed, 1009 insertions, 226 deletions
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index c41eb6180c9c..4bebae733349 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c | |||
| @@ -231,6 +231,26 @@ void led_trigger_event(struct led_trigger *trigger, | |||
| 231 | } | 231 | } |
| 232 | EXPORT_SYMBOL_GPL(led_trigger_event); | 232 | EXPORT_SYMBOL_GPL(led_trigger_event); |
| 233 | 233 | ||
| 234 | void led_trigger_blink(struct led_trigger *trigger, | ||
| 235 | unsigned long *delay_on, | ||
| 236 | unsigned long *delay_off) | ||
| 237 | { | ||
| 238 | struct list_head *entry; | ||
| 239 | |||
| 240 | if (!trigger) | ||
| 241 | return; | ||
| 242 | |||
| 243 | read_lock(&trigger->leddev_list_lock); | ||
| 244 | list_for_each(entry, &trigger->led_cdevs) { | ||
| 245 | struct led_classdev *led_cdev; | ||
| 246 | |||
| 247 | led_cdev = list_entry(entry, struct led_classdev, trig_list); | ||
| 248 | led_blink_set(led_cdev, delay_on, delay_off); | ||
| 249 | } | ||
| 250 | read_unlock(&trigger->leddev_list_lock); | ||
| 251 | } | ||
| 252 | EXPORT_SYMBOL_GPL(led_trigger_blink); | ||
| 253 | |||
| 234 | void led_trigger_register_simple(const char *name, struct led_trigger **tp) | 254 | void led_trigger_register_simple(const char *name, struct led_trigger **tp) |
| 235 | { | 255 | { |
| 236 | struct led_trigger *trigger; | 256 | struct led_trigger *trigger; |
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 61bf5d724139..52a462fc6b84 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig | |||
| @@ -117,10 +117,24 @@ config BATTERY_BQ20Z75 | |||
| 117 | 117 | ||
| 118 | config BATTERY_BQ27x00 | 118 | config BATTERY_BQ27x00 |
| 119 | tristate "BQ27x00 battery driver" | 119 | tristate "BQ27x00 battery driver" |
| 120 | help | ||
| 121 | Say Y here to enable support for batteries with BQ27x00 (I2C/HDQ) chips. | ||
| 122 | |||
| 123 | config BATTERY_BQ27X00_I2C | ||
| 124 | bool "BQ27200/BQ27500 support" | ||
| 125 | depends on BATTERY_BQ27x00 | ||
| 120 | depends on I2C | 126 | depends on I2C |
| 127 | default y | ||
| 121 | help | 128 | help |
| 122 | Say Y here to enable support for batteries with BQ27x00 (I2C) chips. | 129 | Say Y here to enable support for batteries with BQ27x00 (I2C) chips. |
| 123 | 130 | ||
| 131 | config BATTERY_BQ27X00_PLATFORM | ||
| 132 | bool "BQ27000 support" | ||
| 133 | depends on BATTERY_BQ27x00 | ||
| 134 | default y | ||
| 135 | help | ||
| 136 | Say Y here to enable support for batteries with BQ27000 (HDQ) chips. | ||
| 137 | |||
| 124 | config BATTERY_DA9030 | 138 | config BATTERY_DA9030 |
| 125 | tristate "DA9030 battery driver" | 139 | tristate "DA9030 battery driver" |
| 126 | depends on PMIC_DA903X | 140 | depends on PMIC_DA903X |
diff --git a/drivers/power/bq20z75.c b/drivers/power/bq20z75.c index 492da27e1a47..506585e31a5b 100644 --- a/drivers/power/bq20z75.c +++ b/drivers/power/bq20z75.c | |||
| @@ -25,6 +25,10 @@ | |||
| 25 | #include <linux/power_supply.h> | 25 | #include <linux/power_supply.h> |
| 26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
| 27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
| 28 | #include <linux/interrupt.h> | ||
| 29 | #include <linux/gpio.h> | ||
| 30 | |||
| 31 | #include <linux/power/bq20z75.h> | ||
| 28 | 32 | ||
| 29 | enum { | 33 | enum { |
| 30 | REG_MANUFACTURER_DATA, | 34 | REG_MANUFACTURER_DATA, |
| @@ -38,11 +42,22 @@ enum { | |||
| 38 | REG_CYCLE_COUNT, | 42 | REG_CYCLE_COUNT, |
| 39 | REG_SERIAL_NUMBER, | 43 | REG_SERIAL_NUMBER, |
| 40 | REG_REMAINING_CAPACITY, | 44 | REG_REMAINING_CAPACITY, |
| 45 | REG_REMAINING_CAPACITY_CHARGE, | ||
| 41 | REG_FULL_CHARGE_CAPACITY, | 46 | REG_FULL_CHARGE_CAPACITY, |
| 47 | REG_FULL_CHARGE_CAPACITY_CHARGE, | ||
| 42 | REG_DESIGN_CAPACITY, | 48 | REG_DESIGN_CAPACITY, |
| 49 | REG_DESIGN_CAPACITY_CHARGE, | ||
| 43 | REG_DESIGN_VOLTAGE, | 50 | REG_DESIGN_VOLTAGE, |
| 44 | }; | 51 | }; |
| 45 | 52 | ||
| 53 | /* Battery Mode defines */ | ||
| 54 | #define BATTERY_MODE_OFFSET 0x03 | ||
| 55 | #define BATTERY_MODE_MASK 0x8000 | ||
| 56 | enum bq20z75_battery_mode { | ||
| 57 | BATTERY_MODE_AMPS, | ||
| 58 | BATTERY_MODE_WATTS | ||
| 59 | }; | ||
| 60 | |||
| 46 | /* manufacturer access defines */ | 61 | /* manufacturer access defines */ |
| 47 | #define MANUFACTURER_ACCESS_STATUS 0x0006 | 62 | #define MANUFACTURER_ACCESS_STATUS 0x0006 |
| 48 | #define MANUFACTURER_ACCESS_SLEEP 0x0011 | 63 | #define MANUFACTURER_ACCESS_SLEEP 0x0011 |
| @@ -78,8 +93,12 @@ static const struct bq20z75_device_data { | |||
| 78 | BQ20Z75_DATA(POWER_SUPPLY_PROP_CAPACITY, 0x0E, 0, 100), | 93 | BQ20Z75_DATA(POWER_SUPPLY_PROP_CAPACITY, 0x0E, 0, 100), |
| 79 | [REG_REMAINING_CAPACITY] = | 94 | [REG_REMAINING_CAPACITY] = |
| 80 | BQ20Z75_DATA(POWER_SUPPLY_PROP_ENERGY_NOW, 0x0F, 0, 65535), | 95 | BQ20Z75_DATA(POWER_SUPPLY_PROP_ENERGY_NOW, 0x0F, 0, 65535), |
| 96 | [REG_REMAINING_CAPACITY_CHARGE] = | ||
| 97 | BQ20Z75_DATA(POWER_SUPPLY_PROP_CHARGE_NOW, 0x0F, 0, 65535), | ||
| 81 | [REG_FULL_CHARGE_CAPACITY] = | 98 | [REG_FULL_CHARGE_CAPACITY] = |
| 82 | BQ20Z75_DATA(POWER_SUPPLY_PROP_ENERGY_FULL, 0x10, 0, 65535), | 99 | BQ20Z75_DATA(POWER_SUPPLY_PROP_ENERGY_FULL, 0x10, 0, 65535), |
| 100 | [REG_FULL_CHARGE_CAPACITY_CHARGE] = | ||
| 101 | BQ20Z75_DATA(POWER_SUPPLY_PROP_CHARGE_FULL, 0x10, 0, 65535), | ||
| 83 | [REG_TIME_TO_EMPTY] = | 102 | [REG_TIME_TO_EMPTY] = |
| 84 | BQ20Z75_DATA(POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG, 0x12, 0, | 103 | BQ20Z75_DATA(POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG, 0x12, 0, |
| 85 | 65535), | 104 | 65535), |
| @@ -93,6 +112,9 @@ static const struct bq20z75_device_data { | |||
| 93 | [REG_DESIGN_CAPACITY] = | 112 | [REG_DESIGN_CAPACITY] = |
| 94 | BQ20Z75_DATA(POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, 0x18, 0, | 113 | BQ20Z75_DATA(POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, 0x18, 0, |
| 95 | 65535), | 114 | 65535), |
| 115 | [REG_DESIGN_CAPACITY_CHARGE] = | ||
| 116 | BQ20Z75_DATA(POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, 0x18, 0, | ||
| 117 | 65535), | ||
| 96 | [REG_DESIGN_VOLTAGE] = | 118 | [REG_DESIGN_VOLTAGE] = |
| 97 | BQ20Z75_DATA(POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, 0x19, 0, | 119 | BQ20Z75_DATA(POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, 0x19, 0, |
| 98 | 65535), | 120 | 65535), |
| @@ -117,39 +139,72 @@ static enum power_supply_property bq20z75_properties[] = { | |||
| 117 | POWER_SUPPLY_PROP_ENERGY_NOW, | 139 | POWER_SUPPLY_PROP_ENERGY_NOW, |
| 118 | POWER_SUPPLY_PROP_ENERGY_FULL, | 140 | POWER_SUPPLY_PROP_ENERGY_FULL, |
| 119 | POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, | 141 | POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, |
| 142 | POWER_SUPPLY_PROP_CHARGE_NOW, | ||
| 143 | POWER_SUPPLY_PROP_CHARGE_FULL, | ||
| 144 | POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, | ||
| 120 | }; | 145 | }; |
| 121 | 146 | ||
| 122 | struct bq20z75_info { | 147 | struct bq20z75_info { |
| 123 | struct i2c_client *client; | 148 | struct i2c_client *client; |
| 124 | struct power_supply power_supply; | 149 | struct power_supply power_supply; |
| 150 | struct bq20z75_platform_data *pdata; | ||
| 151 | bool is_present; | ||
| 152 | bool gpio_detect; | ||
| 153 | bool enable_detection; | ||
| 154 | int irq; | ||
| 125 | }; | 155 | }; |
| 126 | 156 | ||
| 127 | static int bq20z75_read_word_data(struct i2c_client *client, u8 address) | 157 | static int bq20z75_read_word_data(struct i2c_client *client, u8 address) |
| 128 | { | 158 | { |
| 129 | s32 ret; | 159 | struct bq20z75_info *bq20z75_device = i2c_get_clientdata(client); |
| 160 | s32 ret = 0; | ||
| 161 | int retries = 1; | ||
| 162 | |||
| 163 | if (bq20z75_device->pdata) | ||
| 164 | retries = max(bq20z75_device->pdata->i2c_retry_count + 1, 1); | ||
| 165 | |||
| 166 | while (retries > 0) { | ||
