diff options
author | Bibek Basu <bbasu@nvidia.com> | 2014-04-30 12:41:52 +0530 |
---|---|---|
committer | Mandar Padmawar <mpadmawar@nvidia.com> | 2014-05-07 01:17:22 -0700 |
commit | 2fed492ff26b82539f1f36bdb86182b9b0c2df2c (patch) | |
tree | 484dd4a4f4c989b311c5e7759d49e93f93741aff /drivers | |
parent | a575b112924cd4a1151b098b44919de32cb7c224 (diff) |
mfd: as3722: initialize backup battery charging state
Initialize the backup battery charging state based on
device tree or platform provided data
Bug 1508216
Change-Id: I2bc7c0778b466bb61cd984bfeece97cd9c0059e4
Signed-off-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-on: http://git-master/r/403344
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mfd/as3722.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/drivers/mfd/as3722.c b/drivers/mfd/as3722.c index e877b7da8cb7..c08356134e4c 100644 --- a/drivers/mfd/as3722.c +++ b/drivers/mfd/as3722.c @@ -496,6 +496,14 @@ static int as3722_i2c_of_probe(struct i2c_client *i2c, as3722->irq_base = -1; of_property_read_u32(np, "ams,major-rev", &as3722->major_rev); of_property_read_u32(np, "ams,minor-rev", &as3722->minor_rev); + as3722->backup_battery_chargable = + of_property_read_bool(np, "ams,backup-battery-chargable"); + of_property_read_u32(np, "ams,battery-backup-charge-current", + &as3722->backup_battery_charge_current); + as3722->battery_backup_enable_bypass = + of_property_read_bool(np, "ams,battery-backup-enable-bypass"); + of_property_read_u32(np, "ams,battery-backup-charge-mode", + &as3722->battery_backup_charge_mode); dev_dbg(&i2c->dev, "IRQ flags are 0x%08lx\n", as3722->irq_flags); return 0; } @@ -515,6 +523,12 @@ static int as3722_i2c_non_of_probe(struct i2c_client *i2c, as3722->en_ac_ok_pwr_on = pdata->enable_ac_ok_power_on; as3722->major_rev = pdata->major_rev; as3722->minor_rev = pdata->minor_rev; + as3722->backup_battery_chargable = pdata->backup_battery_chargable; + as3722->backup_battery_charge_current = + pdata->backup_battery_charge_current; + as3722->battery_backup_enable_bypass = + pdata->battery_backup_enable_bypass; + as3722->battery_backup_charge_mode = pdata->battery_backup_charge_mode; return 0; } @@ -577,7 +591,36 @@ static int as3722_i2c_probe(struct i2c_client *i2c, dev_err(as3722->dev, "CTRL_SEQ1 update failed: %d\n", ret); goto scrub; } - + if (as3722->backup_battery_chargable) { + ret = as3722_update_bits(as3722, AS3722_BB_CHARGER_REG, + AS3722_BBCCUR_MASK, + AS3722_BBCCUR_VAL(as3722->backup_battery_charge_current) + ); + if (ret < 0) { + dev_err(as3722->dev, + "BB_CHARGING current update failed: %d\n", ret); + goto scrub; + } + if (as3722->battery_backup_enable_bypass) + val = AS3722_BBCRESOFF_MASK; + else + val = 0; + ret = as3722_update_bits(as3722, AS3722_BB_CHARGER_REG, + AS3722_BBCRESOFF_MASK, val); + if (ret < 0) { + dev_err(as3722->dev, + "BB_CHARGING reg offset update failed: %d\n", ret); + goto scrub; + } + ret = as3722_update_bits(as3722, AS3722_BB_CHARGER_REG, + AS3722_BBCMODE_MASK, + as3722->battery_backup_charge_mode); + if (ret < 0) { + dev_err(as3722->dev, + "BB_CHARGING mode update failed: %d\n", ret); + goto scrub; + } + } ret = mfd_add_devices(&i2c->dev, -1, as3722_devs, ARRAY_SIZE(as3722_devs), NULL, 0, regmap_irq_get_domain(as3722->irq_data)); |