Skip to content

Commit 81bbb2b

Browse files
konradybcioandersson
authored andcommitted
soc: qcom: smem: Add a feature code getter
Recent (SM8550+ ish) Qualcomm SoCs have a new mechanism for precisely identifying the specific SKU and the precise speed bin (in the general meaning of this word, anyway): a pair of values called Product Code and Feature Code. Based on this information, we can deduce the available frequencies for things such as Adreno. In the case of Adreno specifically, Pcode is useless for non-prototype SoCs. Introduce a getter for the feature code and export it. Reviewed-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Konrad Dybcio <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 9267997 commit 81bbb2b

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

drivers/soc/qcom/smem.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,39 @@ int qcom_smem_get_soc_id(u32 *id)
795795
}
796796
EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id);
797797

798+
/**
799+
* qcom_smem_get_feature_code() - return the feature code
800+
* @code: On success, return the feature code here.
801+
*
802+
* Look up the feature code identifier from SMEM and return it.
803+
*
804+
* Return: 0 on success, negative errno on failure.
805+
*/
806+
int qcom_smem_get_feature_code(u32 *code)
807+
{
808+
struct socinfo *info;
809+
u32 raw_code;
810+
811+
info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL);
812+
if (IS_ERR(info))
813+
return PTR_ERR(info);
814+
815+
/* This only makes sense for socinfo >= 16 */
816+
if (__le32_to_cpu(info->fmt) < SOCINFO_VERSION(0, 16))
817+
return -EOPNOTSUPP;
818+
819+
raw_code = __le32_to_cpu(info->feature_code);
820+
821+
/* Ensure the value makes sense */
822+
if (raw_code > SOCINFO_FC_INT_MAX)
823+
raw_code = SOCINFO_FC_UNKNOWN;
824+
825+
*code = raw_code;
826+
827+
return 0;
828+
}
829+
EXPORT_SYMBOL_GPL(qcom_smem_get_feature_code);
830+
798831
static int qcom_smem_get_sbl_version(struct qcom_smem *smem)
799832
{
800833
struct smem_header *header;

include/linux/soc/qcom/smem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ int qcom_smem_get_free_space(unsigned host);
1313
phys_addr_t qcom_smem_virt_to_phys(void *p);
1414

1515
int qcom_smem_get_soc_id(u32 *id);
16+
int qcom_smem_get_feature_code(u32 *code);
1617

1718
#endif

include/linux/soc/qcom/socinfo.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#ifndef __QCOM_SOCINFO_H__
44
#define __QCOM_SOCINFO_H__
55

6+
#include <linux/types.h>
7+
68
/*
79
* SMEM item id, used to acquire handles to respective
810
* SMEM region.
@@ -82,4 +84,28 @@ struct socinfo {
8284
__le32 boot_core;
8385
};
8486

87+
/* Internal feature codes */
88+
enum qcom_socinfo_feature_code {
89+
/* External feature codes */
90+
SOCINFO_FC_UNKNOWN = 0x0,
91+
SOCINFO_FC_AA,
92+
SOCINFO_FC_AB,
93+
SOCINFO_FC_AC,
94+
SOCINFO_FC_AD,
95+
SOCINFO_FC_AE,
96+
SOCINFO_FC_AF,
97+
SOCINFO_FC_AG,
98+
SOCINFO_FC_AH,
99+
};
100+
101+
/* Internal feature codes */
102+
/* Valid values: 0 <= n <= 0xf */
103+
#define SOCINFO_FC_Yn(n) (0xf1 + (n))
104+
#define SOCINFO_FC_INT_MAX SOCINFO_FC_Yn(0xf)
105+
106+
/* Product codes */
107+
#define SOCINFO_PC_UNKNOWN 0
108+
#define SOCINFO_PCn(n) ((n) + 1)
109+
#define SOCINFO_PC_RESERVE (BIT(31) - 1)
110+
85111
#endif

0 commit comments

Comments
 (0)