Merge changes I39b60fcc,I11b5182c into kernel.lnx.5.4.r3-rel

* changes:
  soc: qcom: socinfo: Add sku sysfs support
  soc: qcom: socinfo: Add revision 16 support in socinfo structure
This commit is contained in:
Linux Build Service Account 2023-08-28 07:44:57 -07:00 • committed by Gerrit - the friendly Code Review server
commit f0d27d4efa

View file

@ -34,6 +34,7 @@
#define SMEM_IMAGE_VERSION_TABLE 469
static uint32_t socinfo_format;
static const char *sku;
enum {
HW_PLATFORM_UNKNOWN = 0,
@ -121,6 +122,51 @@ static const char * const hw_platform_subtype[] = {
[PLATFORM_SUBTYPE_INVALID] = "Invalid",
};
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",
};
/* Socinfo SMEM item structure */
static struct socinfo {
__le32 fmt;
@ -167,6 +213,11 @@ static struct socinfo {
__le32 ndefective_parts_array_offset;
/* Version 15 */
__le32 nmodem_supported;
/* Version 16 */
__le32 esku;
__le32 nproduct_code;
__le32 npartnamemap_offset;
__le32 nnum_partname_mapping;
} *socinfo;
/* sysfs attributes */
@ -362,6 +413,35 @@ static uint32_t socinfo_get_nmodem_supported(void)
: 0;
}
/* Version 16 */
static uint32_t socinfo_get_eskuid(void)
{
return socinfo ?
(socinfo_format >= SOCINFO_VERSION(0, 16) ?
le32_to_cpu(socinfo->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->nproduct_code) : 0)
: 0;
}
/* Version 2 */
static ssize_t
msm_get_raw_id(struct device *dev,
@ -612,6 +692,27 @@ msm_get_nmodem_supported(struct device *dev,
}
ATTR_DEFINE(nmodem_supported);
/* Version 16 */
static ssize_t
msm_get_sku(struct device *dev,
struct device_attribute *attr,
char *buf)
{
return sysfs_emit(buf, "%s\n", sku ? sku : "Unknown");
}
ATTR_DEFINE(sku);
static ssize_t
msm_get_esku(struct device *dev,
struct device_attribute *attr,
char *buf)
{
const char *esku = socinfo_get_esku_mapping();
return sysfs_emit(buf, "%s\n", esku ? esku : "Unknown");
}
ATTR_DEFINE(esku);
struct qcom_socinfo {
struct soc_device *soc_dev;
struct soc_device_attribute attr;
@ -959,6 +1060,9 @@ static void socinfo_populate_sysfs(struct qcom_socinfo *qcom_socinfo)
int i = 0;
switch (socinfo_format) {
case SOCINFO_VERSION(0, 16):
msm_custom_socinfo_attrs[i++] = &dev_attr_sku.attr;
msm_custom_socinfo_attrs[i++] = &dev_attr_esku.attr;
case SOCINFO_VERSION(0, 15):
msm_custom_socinfo_attrs[i++] = &dev_attr_nmodem_supported.attr;
case SOCINFO_VERSION(0, 14):
@ -1200,6 +1304,30 @@ static void socinfo_print(void)
socinfo->nmodem_supported);
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_defective_parts=0x%x ndefective_parts_array_offset=0x%x nmodem_supported=0x%x sku=%s\n",
f_maj, f_min, socinfo->id, v_maj, v_min,
socinfo->raw_id, socinfo->raw_ver,
socinfo->hw_plat,
socinfo->plat_ver,
socinfo->accessory_chip,
socinfo->hw_plat_subtype,
socinfo->pmic_model,
socinfo->pmic_die_rev,
socinfo->foundry_id,
socinfo->serial_num,
socinfo->num_pmics,
socinfo->chip_family,
socinfo->raw_device_family,
socinfo->raw_device_num,
socinfo->nproduct_id,
socinfo->num_clusters,
socinfo->ncluster_array_offset,
socinfo->num_defective_parts,
socinfo->ndefective_parts_array_offset,
socinfo->nmodem_supported,
sku ? sku : "Unknown");
default:
pr_err("Unknown format found: v%u.%u\n", f_maj, f_min);
break;
@ -1237,6 +1365,7 @@ static int qcom_socinfo_probe(struct platform_device *pdev)
struct qcom_socinfo *qs;
struct socinfo *info;
size_t item_size;
const char *machine, *esku;
info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID,
&item_size);
@ -1261,6 +1390,14 @@ static int qcom_socinfo_probe(struct platform_device *pdev)
SOCINFO_MINOR(le32_to_cpu(info->ver)));
qs->attr.soc_id = kasprintf(GFP_KERNEL, "%d", socinfo_get_id());
if (socinfo_format >= SOCINFO_VERSION(0, 16)) {
machine = socinfo_machine(le32_to_cpu(info->id));
esku = socinfo_get_esku_mapping();
if (machine && esku)
sku = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-%u-%s",
machine, socinfo_get_nproduct_code(), esku);
}
qsocinfo = qs;
init_rwsem(&qs->current_image_rwsem);
socinfo_populate_sysfs(qs);