ecf8772bfd29187b8ae914dd443dc68cc0058be9
[openwrt/openwrt.git] / target / linux / ipq807x / patches-5.15 / 0059-v6.0-mfd-qcom-spmi-pmic-read-fab-id-on-supported-PMICs.patch
1 From 0c309f4e86c827cd5fd2eb0e36d5d1f19927380d Mon Sep 17 00:00:00 2001
2 From: Caleb Connolly <caleb.connolly@linaro.org>
3 Date: Fri, 29 Apr 2022 23:08:58 +0100
4 Subject: [PATCH] mfd: qcom-spmi-pmic: read fab id on supported PMICs
5
6 The PMI8998 and PM660 expose the fab_id, this is needed by drivers like
7 the RRADC to calibrate ADC values.
8
9 Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
10 Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
11 Tested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
12 Acked-by: Lee Jones <lee.jones@linaro.org>
13 Link: https://lore.kernel.org/r/20220429220904.137297-4-caleb.connolly@linaro.org
14 Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
15 ---
16 drivers/mfd/qcom-spmi-pmic.c | 7 +++++++
17 include/soc/qcom/qcom-spmi-pmic.h | 1 +
18 2 files changed, 8 insertions(+)
19
20 --- a/drivers/mfd/qcom-spmi-pmic.c
21 +++ b/drivers/mfd/qcom-spmi-pmic.c
22 @@ -19,6 +19,7 @@
23 #define PMIC_REV4 0x103
24 #define PMIC_TYPE 0x104
25 #define PMIC_SUBTYPE 0x105
26 +#define PMIC_FAB_ID 0x1f2
27
28 #define PMIC_TYPE_VALUE 0x51
29
30 @@ -157,6 +158,12 @@ static int pmic_spmi_load_revid(struct r
31 if (ret < 0)
32 return ret;
33
34 + if (pmic->subtype == PMI8998_SUBTYPE || pmic->subtype == PM660_SUBTYPE) {
35 + ret = regmap_read(map, PMIC_FAB_ID, &pmic->fab_id);
36 + if (ret < 0)
37 + return ret;
38 + }
39 +
40 /*
41 * In early versions of PM8941 and PM8226, the major revision number
42 * started incrementing from 0 (eg 0 = v1.0, 1 = v2.0).
43 --- a/include/soc/qcom/qcom-spmi-pmic.h
44 +++ b/include/soc/qcom/qcom-spmi-pmic.h
45 @@ -52,6 +52,7 @@ struct qcom_spmi_pmic {
46 unsigned int major;
47 unsigned int minor;
48 unsigned int rev2;
49 + unsigned int fab_id;
50 const char *name;
51 };
52