Skip to content

Commit 17051d2

Browse files
robimarkoandersson
authored andcommitted
soc: qcom: smem: introduce qcom_smem_get_soc_id()
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> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Signed-off-by: Bjorn Andersson <andersson@kernel.org> Link: https://lore.kernel.org/r/20230526204802.3081168-3-robimarko@gmail.com
1 parent 1061500 commit 17051d2

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

drivers/soc/qcom/smem.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/sizes.h>
1515
#include <linux/slab.h>
1616
#include <linux/soc/qcom/smem.h>
17+
#include <linux/soc/qcom/socinfo.h>
1718

1819
/*
1920
* The Qualcomm shared memory system is a allocate only heap structure that
@@ -772,6 +773,28 @@ phys_addr_t qcom_smem_virt_to_phys(void *p)
772773
}
773774
EXPORT_SYMBOL_GPL(qcom_smem_virt_to_phys);
774775

776+
/**
777+
* qcom_smem_get_soc_id() - return the SoC ID
778+
* @id: On success, we return the SoC ID here.
779+
*
780+
* Look up SoC ID from HW/SW build ID and return it.
781+
*
782+
* Return: 0 on success, negative errno on failure.
783+
*/
784+
int qcom_smem_get_soc_id(u32 *id)
785+
{
786+
struct socinfo *info;
787+
788+
info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL);
789+
if (IS_ERR(info))
790+
return PTR_ERR(info);
791+
792+
*id = __le32_to_cpu(info->id);
793+
794+
return 0;
795+
}
796+
EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id);
797+
775798
static int qcom_smem_get_sbl_version(struct qcom_smem *smem)
776799
{
777800
struct smem_header *header;

include/linux/soc/qcom/smem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ int qcom_smem_get_free_space(unsigned host);
1111

1212
phys_addr_t qcom_smem_virt_to_phys(void *p);
1313

14+
int qcom_smem_get_soc_id(u32 *id);
15+
1416
#endif

0 commit comments

Comments
 (0)