aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan T. Ivanov <iivanov@mm-sol.com>2015-03-17 06:47:24 -0400
committerLee Jones <lee.jones@linaro.org>2015-03-30 05:07:08 -0400
commitdc716bbf1d487503110139b019c3e6e526bf7cc8 (patch)
treec15ad5ecd46472dd3dc812fc12a89977199a8b3e
parentc31e858b1ae5a7d0b0beb37f66b1f0e1effa0c6e (diff)
mfd: qcom-spmi-pmic: Add specific compatible strings for Qualcomm's SPMI PMIC's
Some of the PMIC's could have specific regmap configuration tables in future, so add specific compatible strings for known PMIC's. Also print runtime detected chip revision information. Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com> Acked-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.txt19
-rw-r--r--drivers/mfd/qcom-spmi-pmic.c103
2 files changed, 111 insertions, 11 deletions
diff --git a/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.txt b/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.txt
index 7182b8857f57..6ac06c1b9aec 100644
--- a/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.txt
+++ b/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.txt
@@ -15,10 +15,21 @@ each. A function can consume one or more of these fixed-size register regions.
15 15
16Required properties: 16Required properties:
17- compatible: Should contain one of: 17- compatible: Should contain one of:
18 "qcom,pm8941" 18 "qcom,pm8941",
19 "qcom,pm8841" 19 "qcom,pm8841",
20 "qcom,pma8084" 20 "qcom,pma8084",
21 or generalized "qcom,spmi-pmic". 21 "qcom,pm8019",
22 "qcom,pm8226",
23 "qcom,pm8110",
24 "qcom,pma8084",
25 "qcom,pmi8962",
26 "qcom,pmd9635",
27 "qcom,pm8994",
28 "qcom,pmi8994",
29 "qcom,pm8916",
30 "qcom,pm8004",
31 "qcom,pm8909",
32 or generalized "qcom,spmi-pmic".
22- reg: Specifies the SPMI USID slave address for this device. 33- reg: Specifies the SPMI USID slave address for this device.
23 For more information see: 34 For more information see:
24 Documentation/devicetree/bindings/spmi/spmi.txt 35 Documentation/devicetree/bindings/spmi/spmi.txt
diff --git a/drivers/mfd/qcom-spmi-pmic.c b/drivers/mfd/qcom-spmi-pmic.c
index 4b8beb2a1579..af6ac1c4b45c 100644
--- a/drivers/mfd/qcom-spmi-pmic.c
+++ b/drivers/mfd/qcom-spmi-pmic.c
@@ -17,6 +17,100 @@
17#include <linux/regmap.h> 17#include <linux/regmap.h>
18#include <linux/of_platform.h> 18#include <linux/of_platform.h>
19 19
20#define PMIC_REV2 0x101
21#define PMIC_REV3 0x102
22#define PMIC_REV4 0x103
23#define PMIC_TYPE 0x104
24#define PMIC_SUBTYPE 0x105
25
26#define PMIC_TYPE_VALUE 0x51
27
28#define COMMON_SUBTYPE 0x00
29#define PM8941_SUBTYPE 0x01
30#define PM8841_SUBTYPE 0x02
31#define PM8019_SUBTYPE 0x03
32#define PM8226_SUBTYPE 0x04
33#define PM8110_SUBTYPE 0x05
34#define PMA8084_SUBTYPE 0x06
35#define PMI8962_SUBTYPE 0x07
36#define PMD9635_SUBTYPE 0x08
37#define PM8994_SUBTYPE 0x09
38#define PMI8994_SUBTYPE 0x0a
39#define PM8916_SUBTYPE 0x0b
40#define PM8004_SUBTYPE 0x0c
41#define PM8909_SUBTYPE 0x0d
42
43static const struct of_device_id pmic_spmi_id_table[] = {
44 { .compatible = "qcom,spmi-pmic", .data = (void *)COMMON_SUBTYPE },
45 { .compatible = "qcom,pm8941", .data = (void *)PM8941_SUBTYPE },
46 { .compatible = "qcom,pm8841", .data = (void *)PM8841_SUBTYPE },
47 { .compatible = "qcom,pm8019", .data = (void *)PM8019_SUBTYPE },
48 { .compatible = "qcom,pm8226", .data = (void *)PM8226_SUBTYPE },
49 { .compatible = "qcom,pm8110", .data = (void *)PM8110_SUBTYPE },
50 { .compatible = "qcom,pma8084", .data = (void *)PMA8084_SUBTYPE },
51 { .compatible = "qcom,pmi8962", .data = (void *)PMI8962_SUBTYPE },
52 { .compatible = "qcom,pmd9635", .data = (void *)PMD9635_SUBTYPE },
53 { .compatible = "qcom,pm8994", .data = (void *)PM8994_SUBTYPE },
54 { .compatible = "qcom,pmi8994", .data = (void *)PMI8994_SUBTYPE },
55 { .compatible = "qcom,pm8916", .data = (void *)PM8916_SUBTYPE },
56 { .compatible = "qcom,pm8004", .data = (void *)PM8004_SUBTYPE },
57 { .compatible = "qcom,pm8909", .data = (void *)PM8909_SUBTYPE },
58 { }
59};
60
61static void pmic_spmi_show_revid(struct regmap *map, struct device *dev)
62{
63 unsigned int rev2, minor, major, type, subtype;
64 const char *name = "unknown";
65 int ret, i;
66
67 ret = regmap_read(map, PMIC_TYPE, &type);
68 if (ret < 0)
69 return;
70
71 if (type != PMIC_TYPE_VALUE)
72 return;
73
74 ret = regmap_read(map, PMIC_SUBTYPE, &subtype);
75 if (ret < 0)
76 return;
77
78 for (i = 0; i < ARRAY_SIZE(pmic_spmi_id_table); i++) {
79 if (subtype == (unsigned long)pmic_spmi_id_table[i].data)
80 break;
81 }
82
83 if (i != ARRAY_SIZE(pmic_spmi_id_table))
84 name = pmic_spmi_id_table[i].compatible;
85
86 ret = regmap_read(map, PMIC_REV2, &rev2);
87 if (ret < 0)
88 return;
89
90 ret = regmap_read(map, PMIC_REV3, &minor);
91 if (ret < 0)
92 return;
93
94 ret = regmap_read(map, PMIC_REV4, &major);
95 if (ret < 0)
96 return;
97
98 /*
99 * In early versions of PM8941 and PM8226, the major revision number
100 * started incrementing from 0 (eg 0 = v1.0, 1 = v2.0).
101 * Increment the major revision number here if the chip is an early
102 * version of PM8941 or PM8226.
103 */
104 if ((subtype == PM8941_SUBTYPE || subtype == PM8226_SUBTYPE) &&
105 major < 0x02)
106 major++;
107
108 if (subtype == PM8110_SUBTYPE)
109 minor = rev2;
110
111 dev_dbg(dev, "%x: %s v%d.%d\n", subtype, name, major, minor);
112}
113
20static const struct regmap_config spmi_regmap_config = { 114static const struct regmap_config spmi_regmap_config = {
21 .reg_bits = 16, 115 .reg_bits = 16,
22 .val_bits = 8, 116 .val_bits = 8,
@@ -33,6 +127,8 @@ static int pmic_spmi_probe(struct spmi_device *sdev)
33 if (IS_ERR(regmap)) 127 if (IS_ERR(regmap))
34 return PTR_ERR(regmap); 128 return PTR_ERR(regmap);
35 129
130 pmic_spmi_show_revid(regmap, &sdev->dev);
131
36 return of_platform_populate(root, NULL, NULL, &sdev->dev); 132 return of_platform_populate(root, NULL, NULL, &sdev->dev);
37} 133}
38 134
@@ -41,13 +137,6 @@ static void pmic_spmi_remove(struct spmi_device *sdev)
41 of_platform_depopulate(&sdev->dev); 137 of_platform_depopulate(&sdev->dev);
42} 138}
43 139
44static const struct of_device_id pmic_spmi_id_table[] = {
45 { .compatible = "qcom,spmi-pmic" },
46 { .compatible = "qcom,pm8941" },
47 { .compatible = "qcom,pm8841" },
48 { .compatible = "qcom,pma8084" },
49 { }
50};
51MODULE_DEVICE_TABLE(of, pmic_spmi_id_table); 140MODULE_DEVICE_TABLE(of, pmic_spmi_id_table);
52 141
53static struct spmi_driver pmic_spmi_driver = { 142static struct spmi_driver pmic_spmi_driver = {