Introduce a helper to return the machid which is used to identify the specific board variant derived from the same SoC.
Signed-off-by: Gokul Sriram Palanisamy <[email protected]> --- drivers/soc/qcom/smem.c | 26 ++++++++++++++++++++++++++ include/linux/soc/qcom/smem.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 592819701809..327f7358191d 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -827,6 +827,32 @@ int qcom_smem_get_soc_id(u32 *id) } EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id); +/** + * qcom_smem_get_machid() - return the machid + * @id: On success, we return the machid here. + * + * generate machid from HW/SW build ID and return it. + * + * Return: 0 on success, negative errno on failure. + */ + +int qcom_smem_get_machid(u32 *id) +{ + struct socinfo *info; + + info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL); + if (IS_ERR(info)) + return PTR_ERR(info); + + *id = ((info->hw_plat << 24) | + (((info->plat_ver & 0xffff0000) >> 16) << 16) | + ((info->plat_ver & 0x0000ffff) << 8) | + (info->hw_plat_subtype)); + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_smem_get_machid); + /** * qcom_smem_get_feature_code() - return the feature code * @code: On success, return the feature code here. diff --git a/include/linux/soc/qcom/smem.h b/include/linux/soc/qcom/smem.h index f946e3beca21..82f2e6df7853 100644 --- a/include/linux/soc/qcom/smem.h +++ b/include/linux/soc/qcom/smem.h @@ -13,6 +13,7 @@ int qcom_smem_get_free_space(unsigned host); phys_addr_t qcom_smem_virt_to_phys(void *p); int qcom_smem_get_soc_id(u32 *id); +int qcom_smem_get_machid(u32 *id); int qcom_smem_get_feature_code(u32 *code); int qcom_smem_bust_hwspin_lock_by_host(unsigned int host); -- 2.34.1
