power: pm8921-charger: make safe current configurable
The safe current is a one time write per boot value. It determines
the max charge current that can be pushed in the battery.
Make this configurable via platform data so the safe value can
be set different for different batteries. If not specified use
a default of 1500mA
Change-Id: I830bf2e679e76efe7ed9d8bb30a8d459d8b9a09a
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c
index 01448b7..37f7a45 100644
--- a/drivers/power/pm8921-charger.c
+++ b/drivers/power/pm8921-charger.c
@@ -235,6 +235,7 @@
unsigned int max_voltage_mv;
unsigned int min_voltage_mv;
unsigned int uvd_voltage_mv;
+ unsigned int safe_current_ma;
unsigned int alarm_low_mv;
unsigned int alarm_high_mv;
int cool_temp_dc;
@@ -3753,7 +3754,11 @@
chip->max_voltage_mv, rc);
return rc;
}
- rc = pm_chg_ibatsafe_set(chip, SAFE_CURRENT_MA);
+
+ if (chip->safe_current_ma == 0)
+ chip->safe_current_ma = SAFE_CURRENT_MA;
+
+ rc = pm_chg_ibatsafe_set(chip, chip->safe_current_ma);
if (rc) {
pr_err("Failed to set max voltage to %d rc=%d\n",
SAFE_CURRENT_MA, rc);
@@ -4207,6 +4212,7 @@
chip->alarm_low_mv = pdata->alarm_low_mv;
chip->alarm_high_mv = pdata->alarm_high_mv;
chip->min_voltage_mv = pdata->min_voltage;
+ chip->safe_current_ma = pdata->safe_current_ma;
chip->uvd_voltage_mv = pdata->uvd_thresh_voltage;
chip->resume_voltage_delta = pdata->resume_voltage_delta;
chip->term_current = pdata->term_current;
diff --git a/include/linux/mfd/pm8xxx/pm8921-charger.h b/include/linux/mfd/pm8xxx/pm8921-charger.h
index 0e86f2a..a93c7f1 100644
--- a/include/linux/mfd/pm8xxx/pm8921-charger.h
+++ b/include/linux/mfd/pm8xxx/pm8921-charger.h
@@ -70,6 +70,9 @@
* trickle to fast. This is also the minimum voltage the
* system operates at
* @uvd_thresh_voltage: the USB falling UVD threshold (mV) (PM8917 only)
+ * @safe_current_ma: The upper limit of current allowed to be pushed in
+ * battery. This ends up writing in a one time
+ * programmable register.
* @resume_voltage_delta: the (mV) drop to wait for before resume charging
* after the battery has been fully charged
* @term_current: the charger current (mA) at which EOC happens
@@ -130,6 +133,7 @@
unsigned int max_voltage;
unsigned int min_voltage;
unsigned int uvd_thresh_voltage;
+ unsigned int safe_current_ma;
unsigned int alarm_low_mv;
unsigned int alarm_high_mv;
unsigned int resume_voltage_delta;