summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Troast <ntroast@codeaurora.org>2017-01-31 19:23:10 -0800
committerNicholas Troast <ntroast@codeaurora.org>2017-02-07 13:40:00 -0800
commit82ca1cbfca7c49661fdad81a46cdd3e371fbf6ac (patch)
tree1c988b9b61e2a9ac14bc00837edbc2ee4957b21a
parent294cded42df4ae4ccff74b63063b964331777214 (diff)
smb138x-charger: configure connector temp thresholds
Add a device tree property qcom,connector-temp-max-mdegc to configure the connector temperature at which mitigation should start. This will set the thresholds for when the temperature-change IRQ will fire. Change-Id: I47df477b56a6654fbf94b5bb0f7dfdfb80e2f16e Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
-rw-r--r--Documentation/devicetree/bindings/power/supply/qcom/smb138x-charger.txt6
-rw-r--r--drivers/power/supply/qcom/smb-lib.h3
-rw-r--r--drivers/power/supply/qcom/smb138x-charger.c50
3 files changed, 59 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/power/supply/qcom/smb138x-charger.txt b/Documentation/devicetree/bindings/power/supply/qcom/smb138x-charger.txt
index 862dd013c700..c8f2a5a8e496 100644
--- a/Documentation/devicetree/bindings/power/supply/qcom/smb138x-charger.txt
+++ b/Documentation/devicetree/bindings/power/supply/qcom/smb138x-charger.txt
@@ -58,6 +58,12 @@ Charger specific properties:
Definition: Specifies the maximum charger temperature in milli-degrees
Celsius. If unspecified a default of 80000 will be used.
+- qcom,connector-temp-max-mdegc
+ Usage: optional
+ Value type: <u32>
+ Definition: Specifies the maximum connector temperature in milli-degrees
+ Celsius. If unspecified a default value of 105000 will be used.
+
- io-channels
Usage: optional
Value type: List of <phandle u32>
diff --git a/drivers/power/supply/qcom/smb-lib.h b/drivers/power/supply/qcom/smb-lib.h
index 860cd64ba8f8..18ec904651b0 100644
--- a/drivers/power/supply/qcom/smb-lib.h
+++ b/drivers/power/supply/qcom/smb-lib.h
@@ -135,6 +135,9 @@ struct smb_iio {
struct iio_channel *usbin_i_chan;
struct iio_channel *usbin_v_chan;
struct iio_channel *batt_i_chan;
+ struct iio_channel *connector_temp_thr1_chan;
+ struct iio_channel *connector_temp_thr2_chan;
+ struct iio_channel *connector_temp_thr3_chan;
};
struct reg_info {
diff --git a/drivers/power/supply/qcom/smb138x-charger.c b/drivers/power/supply/qcom/smb138x-charger.c
index 8b646887eb2e..336183bb6842 100644
--- a/drivers/power/supply/qcom/smb138x-charger.c
+++ b/drivers/power/supply/qcom/smb138x-charger.c
@@ -93,6 +93,7 @@ struct smb_dt_props {
int usb_icl_ua;
int dc_icl_ua;
int chg_temp_max_mdegc;
+ int connector_temp_max_mdegc;
};
struct smb138x {
@@ -142,6 +143,12 @@ static int smb138x_parse_dt(struct smb138x *chip)
if (rc < 0)
chip->dt.chg_temp_max_mdegc = 80000;
+ rc = of_property_read_u32(node,
+ "qcom,connector-temp-max-mdegc",
+ &chip->dt.chg_temp_max_mdegc);
+ if (rc < 0)
+ chip->dt.connector_temp_max_mdegc = 105000;
+
return 0;
}
@@ -672,6 +679,8 @@ static int smb138x_init_vconn_regulator(struct smb138x *chip)
* HARDWARE INITIALIZATION *
***************************/
+#define MDEGC_3 3000
+#define MDEGC_15 15000
static int smb138x_init_slave_hw(struct smb138x *chip)
{
struct smb_charger *chg = &chip->chg;
@@ -771,6 +780,26 @@ static int smb138x_init_slave_hw(struct smb138x *chip)
return rc;
}
+ rc = iio_write_channel_processed(chg->iio.connector_temp_thr1_chan,
+ chip->dt.connector_temp_max_mdegc);
+ if (rc < 0) {
+ pr_err("Couldn't set connector temp threshold1 rc=%d\n", rc);
+ return rc;
+ }
+
+ rc = iio_write_channel_processed(chg->iio.connector_temp_thr2_chan,
+ chip->dt.connector_temp_max_mdegc + MDEGC_3);
+ if (rc < 0) {
+ pr_err("Couldn't set connector temp threshold2 rc=%d\n", rc);
+ return rc;
+ }
+
+ rc = iio_write_channel_processed(chg->iio.connector_temp_thr3_chan,
+ chip->dt.connector_temp_max_mdegc + MDEGC_15);
+ if (rc < 0) {
+ pr_err("Couldn't set connector temp threshold3 rc=%d\n", rc);
+ return rc;
+ }
return 0;
}
@@ -1277,6 +1306,27 @@ static int smb138x_slave_probe(struct smb138x *chip)
goto cleanup;
}
+ chg->iio.connector_temp_thr1_chan = iio_channel_get(chg->dev,
+ "connector_temp_thr1");
+ if (IS_ERR(chg->iio.connector_temp_thr1_chan)) {
+ rc = PTR_ERR(chg->iio.connector_temp_thr1_chan);
+ goto cleanup;
+ }
+
+ chg->iio.connector_temp_thr2_chan = iio_channel_get(chg->dev,
+ "connector_temp_thr2");
+ if (IS_ERR(chg->iio.connector_temp_thr2_chan)) {
+ rc = PTR_ERR(chg->iio.connector_temp_thr2_chan);
+ goto cleanup;
+ }
+
+ chg->iio.connector_temp_thr3_chan = iio_channel_get(chg->dev,
+ "connector_temp_thr3");
+ if (IS_ERR(chg->iio.connector_temp_thr3_chan)) {
+ rc = PTR_ERR(chg->iio.connector_temp_thr3_chan);
+ goto cleanup;
+ }
+
rc = smb138x_parse_dt(chip);
if (rc < 0) {
pr_err("Couldn't parse device tree rc=%d\n", rc);