soc: qcom: smem: get serial number from socinfo
Implement socinfo support to fetch the serial number if available. Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Simon Glass
parent
efc20ac01f
commit
9f333e1708
@@ -14,6 +14,8 @@
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/sizes.h>
|
||||
#include <soc/qcom/smem.h>
|
||||
#include <soc/qcom/socinfo.h>
|
||||
#include <env.h>
|
||||
|
||||
/*
|
||||
* The Qualcomm shared memory system is a allocate only heap structure that
|
||||
@@ -983,6 +985,29 @@ static int qcom_smem_map_global(struct qcom_smem *smem, u32 size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qcom_socinfo_init(void)
|
||||
{
|
||||
struct socinfo *info;
|
||||
size_t item_size;
|
||||
char buf[32] = { 0 };
|
||||
|
||||
info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID,
|
||||
&item_size);
|
||||
if (IS_ERR(info)) {
|
||||
log_err("Couldn't find socinfo: %ld\n", PTR_ERR(info));
|
||||
return PTR_ERR(info);
|
||||
}
|
||||
|
||||
if (offsetof(struct socinfo, serial_num) <= item_size) {
|
||||
snprintf(buf, sizeof(buf), "%u", le32_to_cpu(info->serial_num));
|
||||
env_set("serial#", buf);
|
||||
} else {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qcom_smem_init(void)
|
||||
{
|
||||
struct smem_header *header;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#define QCOM_SMEM_HOST_ANY -1
|
||||
|
||||
int qcom_smem_init(void);
|
||||
int qcom_socinfo_init(void);
|
||||
|
||||
bool qcom_smem_is_available(void);
|
||||
int qcom_smem_alloc(unsigned host, unsigned item, size_t size);
|
||||
|
||||
Reference in New Issue
Block a user