summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Yang <harryy@codeaurora.org>2016-09-16 11:14:49 -0700
committerSubbaraman Narayanamurthy <subbaram@codeaurora.org>2016-10-04 12:52:16 -0700
commit0ceb2fcb8f8677562a2fb4865d5860d6ec829ee8 (patch)
tree2d1010189358da1b0b9af2bc8ca8f2f85a71d004
parentd430da6679b923bd993a4f8c78204a7db242c8e9 (diff)
qpnp-smb2: introduce workaround bit mask
Add a bit mask to enable workarounds only if they are needed for a particular hardware revision. Change-Id: Ibd9a896ff6746a48ddab249d7c8ab762ed3c2fbe Signed-off-by: Harry Yang <harryy@codeaurora.org> Signed-off-by: Nicholas Troast <ntroast@codeaurora.org> Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
-rw-r--r--Documentation/devicetree/bindings/power/qcom-charger/qpnp-smb2.txt6
-rw-r--r--drivers/power/qcom-charger/qpnp-smb2.c43
-rw-r--r--drivers/power/qcom-charger/smb-lib.h3
3 files changed, 52 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/power/qcom-charger/qpnp-smb2.txt b/Documentation/devicetree/bindings/power/qcom-charger/qpnp-smb2.txt
index 1c5dd91891dc..21404dfc4b7b 100644
--- a/Documentation/devicetree/bindings/power/qcom-charger/qpnp-smb2.txt
+++ b/Documentation/devicetree/bindings/power/qcom-charger/qpnp-smb2.txt
@@ -21,6 +21,12 @@ Charger specific properties:
Value type: <string>
Definition: "qcom,qpnp-smb2".
+- qcom,pmic-revid
+ Usage: required
+ Value type: phandle
+ Definition: Should specify the phandle of PMI's revid module. This is used to
+ identify the PMI subtype.
+
- qcom,batteryless-platform
Usage: optional
Value type: <empty>
diff --git a/drivers/power/qcom-charger/qpnp-smb2.c b/drivers/power/qcom-charger/qpnp-smb2.c
index d19e7827ed83..b6a3e8600d7c 100644
--- a/drivers/power/qcom-charger/qpnp-smb2.c
+++ b/drivers/power/qcom-charger/qpnp-smb2.c
@@ -18,6 +18,7 @@
#include <linux/interrupt.h>
#include <linux/of.h>
#include <linux/of_irq.h>
+#include <linux/qpnp/qpnp-revid.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/machine.h>
@@ -205,6 +206,7 @@ struct smb_dt_props {
int wipower_max_uw;
u32 step_soc_threshold[STEP_CHARGING_MAX_STEPS - 1];
s32 step_cc_delta[STEP_CHARGING_MAX_STEPS];
+ struct device_node *revid_dev_node;
};
struct smb2 {
@@ -1085,6 +1087,40 @@ static int smb2_init_hw(struct smb2 *chip)
return rc;
}
+static int smb2_setup_wa_flags(struct smb2 *chip)
+{
+ struct pmic_revid_data *pmic_rev_id;
+ struct device_node *revid_dev_node;
+
+ revid_dev_node = of_parse_phandle(chip->chg.dev->of_node,
+ "qcom,pmic-revid", 0);
+ if (!revid_dev_node) {
+ pr_err("Missing qcom,pmic-revid property\n");
+ return -EINVAL;
+ }
+
+ pmic_rev_id = get_revid_data(revid_dev_node);
+ if (IS_ERR_OR_NULL(pmic_rev_id)) {
+ /*
+ * the revid peripheral must be registered, any failure
+ * here only indicates that the rev-id module has not
+ * probed yet.
+ */
+ return -EPROBE_DEFER;
+ }
+
+ switch (pmic_rev_id->pmic_subtype) {
+ case PMICOBALT_SUBTYPE:
+ break;
+ default:
+ pr_err("PMIC subtype %d not supported\n",
+ pmic_rev_id->pmic_subtype);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
/****************************
* DETERMINE INITIAL STATUS *
****************************/
@@ -1270,6 +1306,13 @@ static int smb2_probe(struct platform_device *pdev)
return -EINVAL;
}
+ rc = smb2_setup_wa_flags(chip);
+ if (rc < 0) {
+ if (rc != -EPROBE_DEFER)
+ pr_err("Couldn't setup wa flags rc=%d\n", rc);
+ return rc;
+ }
+
rc = smblib_init(chg);
if (rc < 0) {
pr_err("Smblib_init failed rc=%d\n", rc);
diff --git a/drivers/power/qcom-charger/smb-lib.h b/drivers/power/qcom-charger/smb-lib.h
index 289fb1706e97..a9703921e8b3 100644
--- a/drivers/power/qcom-charger/smb-lib.h
+++ b/drivers/power/qcom-charger/smb-lib.h
@@ -161,6 +161,9 @@ struct smb_charger {
bool step_chg_enabled;
bool is_hdc;
+
+ /* workaround flag */
+ u32 wa_flags;
};
int smblib_read(struct smb_charger *chg, u16 addr, u8 *val);