qpnp: revid: Add support to read TP Rev

Some PMICs software drivers (PM660) require the TP revision
information to implement specific logic. Add an optional
property qcom,tp-rev-valid to check if support for TP REV is
available in the REVID peripheral for the PMIC.

Change-Id: Ia7a344e60bedcc6fb28d9ed9f18dc29a3d7f4fd7
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
This commit is contained in:
Rama Krishna Phani A 2017-07-30 19:04:31 +05:30
parent 553433ff26
commit 36c8f370e0
3 changed files with 12 additions and 2 deletions

View file

@ -9,6 +9,8 @@ Required properties:
Optional property:
- qcom,fab-id-valid: Use this property when support to read Fab
identification from REV ID peripheral is available.
- qcom,tp-rev-valid: Use this property when support to read TP
revision identification from REV ID peripheral.
Example:
qcom,revid@100 {

View file

@ -27,6 +27,7 @@
#define REVID_SUBTYPE 0x5
#define REVID_STATUS1 0x8
#define REVID_SPARE_0 0x60
#define REVID_TP_REV 0xf1
#define REVID_FAB_ID 0xf2
#define QPNP_REVID_DEV_NAME "qcom,qpnp-revid"
@ -157,9 +158,9 @@ static size_t build_pmic_string(char *buf, size_t n, int sid,
static int qpnp_revid_probe(struct platform_device *pdev)
{
u8 rev1, rev2, rev3, rev4, pmic_type, pmic_subtype, pmic_status;
u8 option1, option2, option3, option4, spare0, fab_id;
u8 option1, option2, option3, option4, spare0;
unsigned int base;
int rc;
int rc, fab_id, tp_rev;
char pmic_string[PMIC_STRING_MAXLENGTH] = {'\0'};
struct revid_chip *revid_chip;
struct regmap *regmap;
@ -207,6 +208,11 @@ static int qpnp_revid_probe(struct platform_device *pdev)
else
fab_id = -EINVAL;
if (of_property_read_bool(pdev->dev.of_node, "qcom,tp-rev-valid"))
tp_rev = qpnp_read_byte(regmap, base + REVID_TP_REV);
else
tp_rev = -EINVAL;
revid_chip = devm_kzalloc(&pdev->dev, sizeof(struct revid_chip),
GFP_KERNEL);
if (!revid_chip)
@ -220,6 +226,7 @@ static int qpnp_revid_probe(struct platform_device *pdev)
revid_chip->data.pmic_subtype = pmic_subtype;
revid_chip->data.pmic_type = pmic_type;
revid_chip->data.fab_id = fab_id;
revid_chip->data.tp_rev = tp_rev;
if (pmic_subtype < ARRAY_SIZE(pmic_names))
revid_chip->data.pmic_name = pmic_names[pmic_subtype];

View file

@ -252,6 +252,7 @@ struct pmic_revid_data {
u8 pmic_subtype;
const char *pmic_name;
int fab_id;
int tp_rev;
};
#ifdef CONFIG_QPNP_REVID