@@ -14,6 +14,7 @@
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/soc/qcom/smem.h>
+#include <linux/soc/qcom/socinfo.h>
/*
* The Qualcomm shared memory system is a allocate only heap structure that
@@ -772,6 +773,24 @@ phys_addr_t qcom_smem_virt_to_phys(void *p)
}
EXPORT_SYMBOL(qcom_smem_virt_to_phys);
+/**
+ * qcom_smem_get_msm_id() - return the SoC ID
+ *
+ * Look up SoC ID from HW/SW build ID and return it.
+ */
+int qcom_smem_get_msm_id(void)
+{
+ size_t len;
+ struct socinfo *info;
+
+ info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, &len);
+ if (IS_ERR(info))
+ return PTR_ERR(info);
+
+ return __le32_to_cpu(info->id);
+}
+EXPORT_SYMBOL(qcom_smem_get_msm_id);
+
static int qcom_smem_get_sbl_version(struct qcom_smem *smem)
{
struct smem_header *header;
@@ -11,4 +11,6 @@ int qcom_smem_get_free_space(unsigned host);
phys_addr_t qcom_smem_virt_to_phys(void *p);
+int qcom_smem_get_msm_id(void);
+
#endif
Introduce a helper to return the SoC SMEM ID, which is used to identify the exact SoC model as there may be differences in the same SoC family. Currently, cpufreq-nvmem does this completely in the driver and there has been more interest expresed for other drivers to use this information so lets expose a common helper to prevent redoing it in individual drivers since this field is present on every SMEM table version. Signed-off-by: Robert Marko <robimarko@gmail.com> --- drivers/soc/qcom/smem.c | 19 +++++++++++++++++++ include/linux/soc/qcom/smem.h | 2 ++ 2 files changed, 21 insertions(+)