mirror of https://gitee.com/openkylin/linux.git
soc: qcom: socinfo: Expose image information
The socinfo driver provides information about version of the various images loaded in the system. Expose this to user space for debugging purpose. Tested-by: Vinod Koul <vkoul@kernel.org> Reviewed-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Vaishali Thakkar <vaishali.thakkar@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
parent
9c84c1e786
commit
cd23d1405b
|
@ -32,6 +32,39 @@
|
|||
#define SMEM_HW_SW_BUILD_ID 137
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#define SMEM_IMAGE_VERSION_BLOCKS_COUNT 32
|
||||
#define SMEM_IMAGE_VERSION_SIZE 4096
|
||||
#define SMEM_IMAGE_VERSION_NAME_SIZE 75
|
||||
#define SMEM_IMAGE_VERSION_VARIANT_SIZE 20
|
||||
#define SMEM_IMAGE_VERSION_OEM_SIZE 32
|
||||
|
||||
/*
|
||||
* SMEM Image table indices
|
||||
*/
|
||||
#define SMEM_IMAGE_TABLE_BOOT_INDEX 0
|
||||
#define SMEM_IMAGE_TABLE_TZ_INDEX 1
|
||||
#define SMEM_IMAGE_TABLE_RPM_INDEX 3
|
||||
#define SMEM_IMAGE_TABLE_APPS_INDEX 10
|
||||
#define SMEM_IMAGE_TABLE_MPSS_INDEX 11
|
||||
#define SMEM_IMAGE_TABLE_ADSP_INDEX 12
|
||||
#define SMEM_IMAGE_TABLE_CNSS_INDEX 13
|
||||
#define SMEM_IMAGE_TABLE_VIDEO_INDEX 14
|
||||
#define SMEM_IMAGE_VERSION_TABLE 469
|
||||
|
||||
/*
|
||||
* SMEM Image table names
|
||||
*/
|
||||
static const char *const socinfo_image_names[] = {
|
||||
[SMEM_IMAGE_TABLE_ADSP_INDEX] = "adsp",
|
||||
[SMEM_IMAGE_TABLE_APPS_INDEX] = "apps",
|
||||
[SMEM_IMAGE_TABLE_BOOT_INDEX] = "boot",
|
||||
[SMEM_IMAGE_TABLE_CNSS_INDEX] = "cnss",
|
||||
[SMEM_IMAGE_TABLE_MPSS_INDEX] = "mpss",
|
||||
[SMEM_IMAGE_TABLE_RPM_INDEX] = "rpm",
|
||||
[SMEM_IMAGE_TABLE_TZ_INDEX] = "tz",
|
||||
[SMEM_IMAGE_TABLE_VIDEO_INDEX] = "video",
|
||||
};
|
||||
|
||||
static const char *const pmic_models[] = {
|
||||
[0] = "Unknown PMIC model",
|
||||
[9] = "PM8994",
|
||||
|
@ -103,6 +136,13 @@ struct socinfo_params {
|
|||
u32 hw_plat;
|
||||
u32 fmt;
|
||||
};
|
||||
|
||||
struct smem_image_version {
|
||||
char name[SMEM_IMAGE_VERSION_NAME_SIZE];
|
||||
char variant[SMEM_IMAGE_VERSION_VARIANT_SIZE];
|
||||
char pad;
|
||||
char oem[SMEM_IMAGE_VERSION_OEM_SIZE];
|
||||
};
|
||||
#endif /* CONFIG_DEBUG_FS */
|
||||
|
||||
struct qcom_socinfo {
|
||||
|
@ -230,10 +270,37 @@ QCOM_OPEN(build_id, qcom_show_build_id);
|
|||
QCOM_OPEN(pmic_model, qcom_show_pmic_model);
|
||||
QCOM_OPEN(pmic_die_rev, qcom_show_pmic_die_revision);
|
||||
|
||||
#define DEFINE_IMAGE_OPS(type) \
|
||||
static int show_image_##type(struct seq_file *seq, void *p) \
|
||||
{ \
|
||||
struct smem_image_version *image_version = seq->private; \
|
||||
seq_puts(seq, image_version->type); \
|
||||
seq_puts(seq, "\n"); \
|
||||
return 0; \
|
||||
} \
|
||||
static int open_image_##type(struct inode *inode, struct file *file) \
|
||||
{ \
|
||||
return single_open(file, show_image_##type, inode->i_private); \
|
||||
} \
|
||||
\
|
||||
static const struct file_operations qcom_image_##type##_ops = { \
|
||||
.open = open_image_##type, \
|
||||
.read = seq_read, \
|
||||
.llseek = seq_lseek, \
|
||||
.release = single_release, \
|
||||
}
|
||||
|
||||
DEFINE_IMAGE_OPS(name);
|
||||
DEFINE_IMAGE_OPS(variant);
|
||||
DEFINE_IMAGE_OPS(oem);
|
||||
|
||||
static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo,
|
||||
struct socinfo *info)
|
||||
{
|
||||
struct smem_image_version *versions;
|
||||
struct dentry *dentry;
|
||||
size_t size;
|
||||
int i;
|
||||
|
||||
qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL);
|
||||
|
||||
|
@ -302,6 +369,23 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo,
|
|||
DEBUGFS_ADD(info, build_id);
|
||||
break;
|
||||
}
|
||||
|
||||
versions = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_IMAGE_VERSION_TABLE,
|
||||
&size);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(socinfo_image_names); i++) {
|
||||
if (!socinfo_image_names[i])
|
||||
continue;
|
||||
|
||||
dentry = debugfs_create_dir(socinfo_image_names[i],
|
||||
qcom_socinfo->dbg_root);
|
||||
debugfs_create_file("name", 0400, dentry, &versions[i],
|
||||
&qcom_image_name_ops);
|
||||
debugfs_create_file("variant", 0400, dentry, &versions[i],
|
||||
&qcom_image_variant_ops);
|
||||
debugfs_create_file("oem", 0400, dentry, &versions[i],
|
||||
&qcom_image_oem_ops);
|
||||
}
|
||||
}
|
||||
|
||||
static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo)
|
||||
|
|
Loading…
Reference in New Issue