aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/power/ds2760_battery.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c
index f439071c2aa2..ed0ea5e275c5 100644
--- a/drivers/power/ds2760_battery.c
+++ b/drivers/power/ds2760_battery.c
@@ -66,6 +66,10 @@ static unsigned int pmod_enabled;
66module_param(pmod_enabled, bool, 0644); 66module_param(pmod_enabled, bool, 0644);
67MODULE_PARM_DESC(pmod_enabled, "PMOD enable bit"); 67MODULE_PARM_DESC(pmod_enabled, "PMOD enable bit");
68 68
69static unsigned int rated_capacity;
70module_param(rated_capacity, uint, 0644);
71MODULE_PARM_DESC(rated_capacity, "rated battery capacity, 10*mAh or index");
72
69/* Some batteries have their rated capacity stored a N * 10 mAh, while 73/* Some batteries have their rated capacity stored a N * 10 mAh, while
70 * others use an index into this table. */ 74 * others use an index into this table. */
71static int rated_capacities[] = { 75static int rated_capacities[] = {
@@ -274,6 +278,17 @@ static void ds2760_battery_write_status(struct ds2760_device_info *di,
274 w1_ds2760_recall_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK1); 278 w1_ds2760_recall_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK1);
275} 279}
276 280
281static void ds2760_battery_write_rated_capacity(struct ds2760_device_info *di,
282 unsigned char rated_capacity)
283{
284 if (rated_capacity == di->raw[DS2760_RATED_CAPACITY])
285 return;
286
287 w1_ds2760_write(di->w1_dev, &rated_capacity, DS2760_RATED_CAPACITY, 1);
288 w1_ds2760_store_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK1);
289 w1_ds2760_recall_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK1);
290}
291
277static void ds2760_battery_work(struct work_struct *work) 292static void ds2760_battery_work(struct work_struct *work)
278{ 293{
279 struct ds2760_device_info *di = container_of(work, 294 struct ds2760_device_info *di = container_of(work,
@@ -399,6 +414,10 @@ static int ds2760_battery_probe(struct platform_device *pdev)
399 414
400 ds2760_battery_write_status(di, status); 415 ds2760_battery_write_status(di, status);
401 416
417 /* set rated capacity from module param */
418 if (rated_capacity)
419 ds2760_battery_write_rated_capacity(di, rated_capacity);
420
402 retval = power_supply_register(&pdev->dev, &di->bat); 421 retval = power_supply_register(&pdev->dev, &di->bat);
403 if (retval) { 422 if (retval) {
404 dev_err(di->dev, "failed to register battery\n"); 423 dev_err(di->dev, "failed to register battery\n");