msm: socinfo: Add support for socinfo v7
A new socinfo format version 7 is added with support for pmic_model and
pmic_die_revision. Adding the corresponding socinfo API to support them.
Change-Id: I6da3ec41da307c72946945bdb10a31e65205a7e1
Signed-off-by: Jin Hong <jinh@codeaurora.org>
(cherry picked from commit 9b556c3aea6433415759e4af4feda74c58c4c3ad)
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
diff --git a/arch/arm/mach-msm/socinfo.c b/arch/arm/mach-msm/socinfo.c
index 39fbba8..e4ac9f4 100644
--- a/arch/arm/mach-msm/socinfo.c
+++ b/arch/arm/mach-msm/socinfo.c
@@ -114,6 +114,14 @@
uint32_t hw_platform_subtype;
};
+struct socinfo_v7 {
+ struct socinfo_v6 v6;
+
+ /* only valid when format==7 */
+ uint32_t pmic_model;
+ uint32_t pmic_die_revision;
+};
+
static union {
struct socinfo_v1 v1;
struct socinfo_v2 v2;
@@ -121,6 +129,7 @@
struct socinfo_v4 v4;
struct socinfo_v5 v5;
struct socinfo_v6 v6;
+ struct socinfo_v7 v7;
} *socinfo;
static enum msm_cpu cpu_of_id[] = {
@@ -343,6 +352,21 @@
: 0;
}
+enum pmic_model socinfo_get_pmic_model(void)
+{
+ return socinfo ?
+ (socinfo->v1.format >= 7 ? socinfo->v7.pmic_model
+ : PMIC_MODEL_UNKNOWN)
+ : PMIC_MODEL_UNKNOWN;
+}
+
+uint32_t socinfo_get_pmic_die_revision(void)
+{
+ return socinfo ?
+ (socinfo->v1.format >= 7 ? socinfo->v7.pmic_die_revision : 0)
+ : 0;
+}
+
enum msm_cpu socinfo_get_msm_cpu(void)
{
return cur_cpu;
@@ -515,6 +539,42 @@
hw_platform_subtype[hw_subtype]);
}
+static ssize_t
+socinfo_show_pmic_model(struct sys_device *dev,
+ struct sysdev_attribute *attr,
+ char *buf)
+{
+ if (!socinfo) {
+ pr_err("%s: No socinfo found!\n", __func__);
+ return 0;
+ }
+ if (socinfo->v1.format < 7) {
+ pr_err("%s: pmic_model not available!\n", __func__);
+ return 0;
+ }
+
+ return snprintf(buf, PAGE_SIZE, "%u\n",
+ socinfo_get_pmic_model());
+}
+
+static ssize_t
+socinfo_show_pmic_die_revision(struct sys_device *dev,
+ struct sysdev_attribute *attr,
+ char *buf)
+{
+ if (!socinfo) {
+ pr_err("%s: No socinfo found!\n", __func__);
+ return 0;
+ }
+ if (socinfo->v1.format < 7) {
+ pr_err("%s: pmic_die_revision not available!\n", __func__);
+ return 0;
+ }
+
+ return snprintf(buf, PAGE_SIZE, "%u\n",
+ socinfo_get_pmic_die_revision());
+}
+
static struct sysdev_attribute socinfo_v1_files[] = {
_SYSDEV_ATTR(id, 0444, socinfo_show_id, NULL),
_SYSDEV_ATTR(version, 0444, socinfo_show_version, NULL),
@@ -545,6 +605,13 @@
socinfo_show_platform_subtype, NULL),
};
+static struct sysdev_attribute socinfo_v7_files[] = {
+ _SYSDEV_ATTR(pmic_model, 0444,
+ socinfo_show_pmic_model, NULL),
+ _SYSDEV_ATTR(pmic_die_revision, 0444,
+ socinfo_show_pmic_die_revision, NULL),
+};
+
static struct sysdev_class soc_sysdev_class = {
.name = "soc",
};
@@ -619,9 +686,14 @@
if (socinfo->v1.format < 6)
return err;
- return socinfo_create_files(&soc_sys_device, socinfo_v6_files,
+ socinfo_create_files(&soc_sys_device, socinfo_v6_files,
ARRAY_SIZE(socinfo_v6_files));
+ if (socinfo->v1.format < 7)
+ return err;
+
+ return socinfo_create_files(&soc_sys_device, socinfo_v7_files,
+ ARRAY_SIZE(socinfo_v7_files));
}
arch_initcall(socinfo_init_sysdev);
@@ -649,7 +721,11 @@
int __init socinfo_init(void)
{
- socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, sizeof(struct socinfo_v6));
+ socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, sizeof(struct socinfo_v7));
+
+ if (!socinfo)
+ socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
+ sizeof(struct socinfo_v6));
if (!socinfo)
socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
@@ -741,6 +817,20 @@
socinfo->v5.accessory_chip,
socinfo->v6.hw_platform_subtype);
break;
+ case 7:
+ pr_info("%s: v%u, id=%u, ver=%u.%u, raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n accessory_chip=%u, hw_plat_subtype=%u, pmic_model=%u, pmic_die_revision=%u\n",
+ __func__,
+ socinfo->v1.format,
+ socinfo->v1.id,
+ SOCINFO_VERSION_MAJOR(socinfo->v1.version),
+ SOCINFO_VERSION_MINOR(socinfo->v1.version),
+ socinfo->v2.raw_id, socinfo->v2.raw_version,
+ socinfo->v3.hw_platform, socinfo->v4.platform_version,
+ socinfo->v5.accessory_chip,
+ socinfo->v6.hw_platform_subtype,
+ socinfo->v7.pmic_model,
+ socinfo->v7.pmic_die_revision);
+ break;
default:
pr_err("%s: Unknown format found\n", __func__);
break;