Merge "power: qpnp-charger: add use-default-batt-values flag"
diff --git a/Documentation/devicetree/bindings/power/qpnp-charger.txt b/Documentation/devicetree/bindings/power/qpnp-charger.txt
index 2103bbc..04e9868 100644
--- a/Documentation/devicetree/bindings/power/qpnp-charger.txt
+++ b/Documentation/devicetree/bindings/power/qpnp-charger.txt
@@ -30,10 +30,14 @@
- qcom,chg-ibatterm-ma: Current at which charging is terminated in mA.
Parent node optional properties:
-- qcom,chg-charging-disabled: Set this property to disable charging
- by default. This can then be overriden
- writing the the module parameter
- "charging_disabled".
+- qcom,chg-charging-disabled: Set this property to disable charging
+ by default. This can then be overriden
+ writing the the module parameter
+ "charging_disabled".
+- qcom,chg-use-default-batt-values: Set this flag to force reporting of
+ battery temperature of 250 decidegree
+ Celsius, state of charge to be 50%
+ and disable charging.
Sub node required structure:
- A qcom,chg node must be a child of an SPMI node that has specified
diff --git a/drivers/power/qpnp-charger.c b/drivers/power/qpnp-charger.c
index a0d84df..612b0e9 100644
--- a/drivers/power/qpnp-charger.c
+++ b/drivers/power/qpnp-charger.c
@@ -161,6 +161,7 @@
* @chg_done: indicates that charging is completed
* @usb_present: present status of usb
* @dc_present: present status of dc
+ * @use_default_batt_values: flag to report default battery properties
* @max_voltage_mv: the max volts the batt should be charged up to
* @min_voltage_mv: the min battery voltage before turning the FETon
* @term_current: the charging based term current
@@ -191,6 +192,7 @@
bool usb_present;
bool dc_present;
bool charging_disabled;
+ bool use_default_batt_values;
unsigned int max_bat_chg_current;
unsigned int safe_voltage_mv;
unsigned int max_voltage_mv;
@@ -734,6 +736,9 @@
{
union power_supply_propval ret = {0,};
+ if (chip->use_default_batt_values || !get_prop_batt_present(chip))
+ return DEFAULT_CAPACITY;
+
if (chip->bms_psy) {
chip->bms_psy->get_property(chip->bms_psy,
POWER_SUPPLY_PROP_CAPACITY, &ret);
@@ -747,7 +752,7 @@
return DEFAULT_CAPACITY;
}
-#define DEFAULT_TEMP 25
+#define DEFAULT_TEMP 250
#define MAX_TOLERABLE_BATT_TEMP_DDC 680
static int
get_prop_batt_temp(struct qpnp_chg_chip *chip)
@@ -755,6 +760,9 @@
int rc = 0;
struct qpnp_vadc_result results;
+ if (chip->use_default_batt_values || !get_prop_batt_present(chip))
+ return DEFAULT_TEMP;
+
if (chip->revision > 0) {
rc = qpnp_vadc_read(LR_MUX1_BATT_THERM, &results);
if (rc) {
@@ -1239,6 +1247,14 @@
chip->charging_disabled = of_property_read_bool(spmi->dev.of_node,
"qcom,chg-charging-disabled");
+ /* Get the fake-batt-values property */
+ chip->use_default_batt_values = of_property_read_bool(spmi->dev.of_node,
+ "qcom,chg-use-default-batt-values");
+
+ /* Disable charging when faking battery values */
+ if (chip->use_default_batt_values)
+ chip->charging_disabled = true;
+
spmi_for_each_container_dev(spmi_resource, spmi) {
if (!spmi_resource) {
pr_err("qpnp_chg: spmi resource absent\n");