summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorVenkat Reddy Talla <vreddytalla@nvidia.com>2014-04-04 16:57:40 +0530
committerMandar Padmawar <mpadmawar@nvidia.com>2014-05-06 03:53:47 -0700
commit40dc23811e92480dccc2ab00a428823d54d955a5 (patch)
tree9aba8c936c4b1fbf86678f61ccd75042516d9c78 /drivers/power
parent7cdf8105e5ddc01402ff404dc0a5dd3c76057bca (diff)
power: bq2419x: configure PWR ON REG when safety timer expires
enable safety timer and configure power on register from ISR and resume path when safety timer expired. set rtc alarm timer based on parameter value passed through dt file only when battery in CHARING done state and high charging current cable connected to wake up device from LP0. Bug 1440235 Change-Id: I2fb8121c6183a8367c8bd869f43373062fdbb630 Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com> Reviewed-on: http://git-master/r/392334 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Change-Id: Iff93242bdc368f711d06eec1b4ec4ff844df5978 Reviewed-on: http://git-master/r/404465 Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com> Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/bq2419x-charger.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/drivers/power/bq2419x-charger.c b/drivers/power/bq2419x-charger.c
index 5e071ebce935..7b52e07f0862 100644
--- a/drivers/power/bq2419x-charger.c
+++ b/drivers/power/bq2419x-charger.c
@@ -104,6 +104,7 @@ struct bq2419x_chip {
int last_charging_current;
bool disable_suspend_during_charging;
int last_temp;
+ u32 auto_recharge_time_supend;
struct bq2419x_reg_info input_src;
struct bq2419x_reg_info chg_current_control;
struct bq2419x_reg_info prechg_term_control;
@@ -702,6 +703,25 @@ static irqreturn_t bq2419x_irq(int irq, void *data)
ret);
return ret;
}
+
+ ret = regmap_read(bq2419x->regmap, BQ2419X_PWR_ON_REG, &val);
+ if (ret < 0) {
+ dev_err(bq2419x->dev, "PWR_ON_REG read failed %d",
+ ret);
+ return ret;
+ }
+
+ if ((val & BQ2419X_ENABLE_CHARGE_MASK) ==
+ BQ2419X_DISABLE_CHARGE) {
+ ret = regmap_update_bits(bq2419x->regmap,
+ BQ2419X_PWR_ON_REG, BQ2419X_ENABLE_CHARGE_MASK,
+ BQ2419X_ENABLE_CHARGE);
+ if (ret < 0) {
+ dev_err(bq2419x->dev,
+ "PWR_ON_REG update failed, %d\n", ret);
+ return ret;
+ }
+ }
check_chg_state = 1;
break;
default:
@@ -1356,6 +1376,13 @@ static struct bq2419x_platform_data *bq2419x_dt_parse(struct i2c_client *client)
chg_restart_time;
ret = of_property_read_u32(batt_reg_node,
+ "ti,auto-recharge-time-suspend",
+ &chg_restart_time);
+ if (!ret)
+ pdata->bcharger_pdata->auto_recharge_time_supend =
+ chg_restart_time;
+
+ ret = of_property_read_u32(batt_reg_node,
"ti,temp-polling-time-sec", &temp_polling_time);
if (!ret)
bcharger_pdata->temp_polling_time_sec =
@@ -1553,6 +1580,8 @@ static int bq2419x_probe(struct i2c_client *client,
bq2419x->last_temp = -1000;
bq2419x->disable_suspend_during_charging =
pdata->bcharger_pdata->disable_suspend_during_charging;
+ bq2419x->auto_recharge_time_supend =
+ pdata->bcharger_pdata->auto_recharge_time_supend;
bq2419x_process_charger_plat_data(bq2419x, pdata->bcharger_pdata);
@@ -1703,7 +1732,18 @@ static int bq2419x_suspend(struct device *dev)
(bq2419x->in_current_limit > 500)) {
battery_charging_wakeup(bq2419x->bc_dev,
bq2419x->wdt_refresh_timeout);
- } else {
+ } else if (bq2419x->cable_connected &&
+ bq2419x->auto_recharge_time_supend &&
+ (bq2419x->in_current_limit > 500) &&
+ (bq2419x->chg_status == BATTERY_CHARGING_DONE)){
+ battery_charging_wakeup(bq2419x->bc_dev,
+ bq2419x->auto_recharge_time_supend);
+ ret = bq2419x_set_charging_current_suspend(
+ bq2419x, 500);
+ if (ret < 0)
+ dev_err(bq2419x->dev,
+ "Configuration of charging failed: %d\n", ret);
+ } else {
ret = bq2419x_set_charging_current_suspend(bq2419x, 500);
if (ret < 0)
dev_err(bq2419x->dev,
@@ -1764,6 +1804,35 @@ static int bq2419x_resume(struct device *dev)
dev_err(bq2419x->dev, "Reset WDT failed: %d\n", ret);
}
+ if(val & BQ2419x_FAULT_CHRG_SAFTY) {
+ bq_chg_err(bq2419x, "Safety timer Expired\n");
+ ret = bq2419x_reset_safety_timer(bq2419x);
+ if (ret < 0) {
+ dev_err(bq2419x->dev,
+ "Reset safety timer failed %d\n", ret);
+ return ret;
+ }
+
+ ret = regmap_read(bq2419x->regmap, BQ2419X_PWR_ON_REG, &val);
+ if (ret < 0) {
+ dev_err(bq2419x->dev,
+ "PWR_ON_REG read failed %d", ret);
+ return ret;
+ }
+
+ if ((val & BQ2419X_ENABLE_CHARGE_MASK) ==
+ BQ2419X_DISABLE_CHARGE) {
+ ret = regmap_update_bits(bq2419x->regmap,
+ BQ2419X_PWR_ON_REG, BQ2419X_ENABLE_CHARGE_MASK,
+ BQ2419X_ENABLE_CHARGE);
+ if (ret < 0) {
+ dev_err(bq2419x->dev,
+ "PWR_ON_REG update failed, %d\n", ret);
+ return ret;
+ }
+ }
+ }
+
return 0;
};
#endif