soc: qcom: socinfo: Add sku sysfs support
Add the support to get the sku information from userspace. Change-Id: I39b60fcc430308cd75e67fa400ad9515b5ad4b65 Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com> Signed-off-by: Swetha Chikkaboraiah <quic_schikk@quicinc.com>
This commit is contained in:
1 parent
55c3ba616d
commit
5c9bc040ea
1 file changed
+116
-2
+116
-2
@@ -240,6 +240,51 @@ static union {
|
||||
/* max socinfo format version supported */
|
||||
#define MAX_SOCINFO_FORMAT SOCINFO_VERSION(0, 16)
|
||||
|
||||
enum {
|
||||
/* External SKU */
|
||||
SKU_UNKNOWN = 0x0,
|
||||
SKU_AA = 0x1,
|
||||
SKU_AB = 0x2,
|
||||
SKU_AC = 0x3,
|
||||
SKU_AD = 0x4,
|
||||
SKU_AE = 0x5,
|
||||
SKU_AF = 0x6,
|
||||
SKU_EXT_RESERVE,
|
||||
|
||||
/* Internal SKU */
|
||||
SKU_Y0 = 0xf1,
|
||||
SKU_Y1 = 0xf2,
|
||||
SKU_Y2 = 0xf3,
|
||||
SKU_Y3 = 0xf4,
|
||||
SKU_Y4 = 0xf5,
|
||||
SKU_Y5 = 0xf6,
|
||||
SKU_Y6 = 0xf7,
|
||||
SKU_Y7 = 0xf8,
|
||||
SKU_INT_RESERVE,
|
||||
};
|
||||
|
||||
static const char * const hw_platform_esku[] = {
|
||||
[SKU_UNKNOWN] = "Unknown",
|
||||
[SKU_AA] = "AA",
|
||||
[SKU_AB] = "AB",
|
||||
[SKU_AC] = "AC",
|
||||
[SKU_AD] = "AD",
|
||||
[SKU_AE] = "AE",
|
||||
[SKU_AF] = "AF",
|
||||
};
|
||||
|
||||
#define SKU_INT_MASK 0x0f
|
||||
static const char * const hw_platform_isku[] = {
|
||||
[SKU_Y0 & SKU_INT_MASK] = "Y0",
|
||||
[SKU_Y1 & SKU_INT_MASK] = "Y1",
|
||||
[SKU_Y2 & SKU_INT_MASK] = "Y2",
|
||||
[SKU_Y3 & SKU_INT_MASK] = "Y3",
|
||||
[SKU_Y4 & SKU_INT_MASK] = "Y4",
|
||||
[SKU_Y5 & SKU_INT_MASK] = "Y5",
|
||||
[SKU_Y6 & SKU_INT_MASK] = "Y6",
|
||||
[SKU_Y7 & SKU_INT_MASK] = "Y7",
|
||||
};
|
||||
|
||||
static struct msm_soc_info cpu_of_id[] = {
|
||||
[0] = {MSM_CPU_UNKNOWN, "Unknown CPU"},
|
||||
/* 8960 IDs */
|
||||
@@ -418,6 +463,7 @@ static struct msm_soc_info cpu_of_id[] = {
|
||||
static enum msm_cpu cur_cpu;
|
||||
static int current_image;
|
||||
static uint32_t socinfo_format;
|
||||
static const char *sku;
|
||||
|
||||
static struct socinfo_v0_1 dummy_socinfo = {
|
||||
.format = SOCINFO_VERSION(0, 1),
|
||||
@@ -667,6 +713,34 @@ static uint32_t socinfo_get_nmodem_supported(void)
|
||||
: 0;
|
||||
}
|
||||
|
||||
static uint32_t socinfo_get_eskuid(void)
|
||||
{
|
||||
return socinfo ?
|
||||
(socinfo_format >= SOCINFO_VERSION(0, 16) ?
|
||||
le32_to_cpu(socinfo->v0_16.esku) : 0)
|
||||
: 0;
|
||||
}
|
||||
|
||||
static const char *socinfo_get_esku_mapping(void)
|
||||
{
|
||||
uint32_t id = socinfo_get_eskuid();
|
||||
|
||||
if (id > SKU_UNKNOWN && id < SKU_EXT_RESERVE)
|
||||
return hw_platform_esku[id];
|
||||
else if (id >= SKU_Y0 && id < SKU_INT_RESERVE)
|
||||
return hw_platform_isku[id & SKU_INT_MASK];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uint32_t socinfo_get_nproduct_code(void)
|
||||
{
|
||||
return socinfo ?
|
||||
(socinfo_format >= SOCINFO_VERSION(0, 16) ?
|
||||
le32_to_cpu(socinfo->v0_16.nproduct_code) : 0)
|
||||
: 0;
|
||||
}
|
||||
|
||||
enum pmic_model socinfo_get_pmic_model(void)
|
||||
{
|
||||
return socinfo ?
|
||||
@@ -998,6 +1072,26 @@ msm_get_nmodem_supported(struct device *dev,
|
||||
socinfo_get_nmodem_supported());
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
msm_get_sku(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n",
|
||||
sku ? sku : "Unknown");
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
msm_get_esku(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
const char *esku = socinfo_get_esku_mapping();
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n",
|
||||
esku ? esku : "Unknown");
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
msm_get_pmic_model(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
@@ -1313,6 +1407,12 @@ static struct device_attribute msm_soc_attr_nmodem_supported =
|
||||
__ATTR(nmodem_supported, 0444,
|
||||
msm_get_nmodem_supported, NULL);
|
||||
|
||||
static struct device_attribute msm_soc_attr_sku =
|
||||
__ATTR(sku, 0444, msm_get_sku, NULL);
|
||||
|
||||
static struct device_attribute msm_soc_attr_esku =
|
||||
__ATTR(esku, 0444, msm_get_esku, NULL);
|
||||
|
||||
static struct device_attribute msm_soc_attr_pmic_model =
|
||||
__ATTR(pmic_model, 0444,
|
||||
msm_get_pmic_model, NULL);
|
||||
@@ -1500,6 +1600,10 @@ static void __init populate_soc_sysfs_files(struct device *msm_soc_device)
|
||||
|
||||
switch (socinfo_format) {
|
||||
case SOCINFO_VERSION(0, 16):
|
||||
device_create_file(msm_soc_device,
|
||||
&msm_soc_attr_sku);
|
||||
device_create_file(msm_soc_device,
|
||||
&msm_soc_attr_esku);
|
||||
case SOCINFO_VERSION(0, 15):
|
||||
device_create_file(msm_soc_device,
|
||||
&msm_soc_attr_nmodem_supported);
|
||||
@@ -1799,7 +1903,7 @@ static void socinfo_print(void)
|
||||
break;
|
||||
|
||||
case SOCINFO_VERSION(0, 16):
|
||||
pr_info("v%u.%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 foundry_id=%u serial_number=%u num_pmics=%u chip_family=0x%x raw_device_family=0x%x raw_device_number=0x%x nproduct_id=0x%x num_clusters=0x%x ncluster_array_offset=0x%x num_subset_parts=0x%x nsubset_parts_array_offset=0x%x nmodem_supported=0x%x\n",
|
||||
pr_info("v%u.%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 foundry_id=%u serial_number=%u num_pmics=%u chip_family=0x%x raw_device_family=0x%x raw_device_number=0x%x nproduct_id=0x%x num_clusters=0x%x ncluster_array_offset=0x%x num_subset_parts=0x%x nsubset_parts_array_offset=0x%x nmodem_supported=0x%x sku=%s\n",
|
||||
f_maj, f_min, socinfo->v0_1.id, v_maj, v_min,
|
||||
socinfo->v0_2.raw_id, socinfo->v0_2.raw_version,
|
||||
socinfo->v0_3.hw_platform,
|
||||
@@ -1819,7 +1923,8 @@ static void socinfo_print(void)
|
||||
socinfo->v0_14.ncluster_array_offset,
|
||||
socinfo->v0_14.num_subset_parts,
|
||||
socinfo->v0_14.nsubset_parts_array_offset,
|
||||
socinfo->v0_15.nmodem_supported);
|
||||
socinfo->v0_15.nmodem_supported,
|
||||
sku ? sku : "Unknown");
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1854,6 +1959,7 @@ int __init socinfo_init(void)
|
||||
static bool socinfo_init_done;
|
||||
size_t size;
|
||||
uint32_t soc_info_id;
|
||||
const char *machine, *esku;
|
||||
|
||||
if (socinfo_init_done)
|
||||
return 0;
|
||||
@@ -1873,6 +1979,14 @@ int __init socinfo_init(void)
|
||||
(!cpu_of_id[soc_info_id].soc_id_string))
|
||||
pr_warn("New IDs added! ID => CPU mapping needs an update.\n");
|
||||
|
||||
if (socinfo_format >= SOCINFO_VERSION(0, 16)) {
|
||||
machine = socinfo_get_id_string();
|
||||
esku = socinfo_get_esku_mapping();
|
||||
if (machine && esku)
|
||||
sku = kasprintf(GFP_KERNEL, "%s-%u-%s",
|
||||
machine, socinfo_get_nproduct_code(), esku);
|
||||
}
|
||||
|
||||
cur_cpu = cpu_of_id[socinfo->v0_1.id].generic_soc_type;
|
||||
boot_stats_init();
|
||||
socinfo_print();
|
||||
|
||||
Reference in new issue
Block a user