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>
This commit is contained in:
Harry Yang 2016-09-16 11:14:49 -07:00 committed by Subbaraman Narayanamurthy
parent d430da6679
commit 0ceb2fcb8f
3 changed files with 52 additions and 0 deletions

View file

@ -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>

View file

@ -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);

View file

@ -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);