soc: qcom: socinfo: Add APIs for part count and subpart information
Add kernel APIs to provide part count and subpart information. Change-Id: Ie0f67555ec3561efa4832c1e0a6863f5842ccb53 Signed-off-by: Naina Mehta <quic_nainmeht@quicinc.com> Signed-off-by: Tengfei Fan <quic_tengfan@quicinc.com> Signed-off-by: jianzhou <quic_jianzhou@quicinc.com>
This commit is contained in:
parent
a206f247de
commit
12d73dd3fd
@ -783,25 +783,70 @@ msm_get_subset_parts(struct device *dev,
|
|||||||
}
|
}
|
||||||
ATTR_DEFINE(subset_parts);
|
ATTR_DEFINE(subset_parts);
|
||||||
|
|
||||||
int32_t
|
/*
|
||||||
socinfo_get_subpart_info(enum subset_part_type part, uint32_t *nIdx, uint32_t *part_info)
|
* socinfo_get_part_count - Get part count
|
||||||
|
* @part: The subset_part_type to be checked
|
||||||
|
*
|
||||||
|
* Return the number of instance supported by the
|
||||||
|
* firmware for the part on success and a negative
|
||||||
|
* errno will be returned in error cases.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
socinfo_get_part_count(enum subset_part_type part)
|
||||||
{
|
{
|
||||||
uint32_t num_parts = 0, offset = 0;
|
int part_count = 1;
|
||||||
void *info = socinfo;
|
|
||||||
|
|
||||||
if (part >= NUM_PARTS_MAX) {
|
/* TODO: part_count to be read from SMEM after firmware adds support */
|
||||||
|
if ((part <= PART_UNKNOWN) || (part >= NUM_PARTS_MAX)) {
|
||||||
pr_err("Bad part number\n");
|
pr_err("Bad part number\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_parts = socinfo_get_num_subset_parts();
|
return part_count;
|
||||||
offset = socinfo_get_nsubset_parts_array_offset();
|
}
|
||||||
if (!num_parts || !offset)
|
EXPORT_SYMBOL(socinfo_get_part_count);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* socinfo_get_subpart_info - Get subpart information
|
||||||
|
* @part: The subset_part_type to be checked
|
||||||
|
* @part_info: Pointer to the subpart information.
|
||||||
|
* Used to store the subpart information
|
||||||
|
* for num_parts instances of the part.
|
||||||
|
* @num_parts: Number of instances of the part for
|
||||||
|
* which the subpart information is required.
|
||||||
|
*
|
||||||
|
* On success subpart information will be stored in the part_info
|
||||||
|
* array for minimum of the number of instances requested and
|
||||||
|
* the number of instances supported by the firmware.
|
||||||
|
*
|
||||||
|
* A value of zero will be returned on success and a negative
|
||||||
|
* errno will be returned in error cases.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
socinfo_get_subpart_info(enum subset_part_type part,
|
||||||
|
u32 *part_info,
|
||||||
|
u32 num_parts)
|
||||||
|
{
|
||||||
|
uint32_t num_subset_parts = 0, offset = 0;
|
||||||
|
void *info = socinfo;
|
||||||
|
u32 i = 0, count = 0;
|
||||||
|
int part_count = 0;
|
||||||
|
|
||||||
|
part_count = socinfo_get_part_count(part);
|
||||||
|
if (part_count <= 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
info += (offset + (part * sizeof(uint32_t)));
|
num_subset_parts = socinfo_get_num_subset_parts();
|
||||||
*part_info = get_unaligned_le32(info);
|
offset = socinfo_get_nsubset_parts_array_offset();
|
||||||
*nIdx = 0;
|
if (!num_subset_parts || !offset)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
info += (offset + (part * sizeof(u32)));
|
||||||
|
count = min_t(u32, num_parts, part_count);
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
part_info[i] = get_unaligned_le32(info);
|
||||||
|
info += sizeof(u32);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,10 @@ uint32_t socinfo_get_serial_number(void);
|
|||||||
const char *socinfo_get_id_string(void);
|
const char *socinfo_get_id_string(void);
|
||||||
uint32_t socinfo_get_cluster_info(enum subset_cluster_type cluster);
|
uint32_t socinfo_get_cluster_info(enum subset_cluster_type cluster);
|
||||||
bool socinfo_get_part_info(enum subset_part_type part);
|
bool socinfo_get_part_info(enum subset_part_type part);
|
||||||
int32_t socinfo_get_subpart_info(enum subset_part_type part, uint32_t *nIdx, uint32_t *part_info);
|
int socinfo_get_part_count(enum subset_part_type part);
|
||||||
|
int socinfo_get_subpart_info(enum subset_part_type part,
|
||||||
|
u32 *part_info,
|
||||||
|
u32 num_parts);
|
||||||
int socinfo_get_oem_variant_id(void);
|
int socinfo_get_oem_variant_id(void);
|
||||||
#else
|
#else
|
||||||
static inline uint32_t socinfo_get_id(void)
|
static inline uint32_t socinfo_get_id(void)
|
||||||
@ -65,7 +68,13 @@ bool socinfo_get_part_info(enum subset_part_type part)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int32_t socinfo_get_subpart_info(enum subset_part_type part, uint32_t *nIdx, uint32_t *part_info)
|
int socinfo_get_part_count(enum subset_part_type part)
|
||||||
|
{
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
int socinfo_get_subpart_info(enum subset_part_type part,
|
||||||
|
u32 *part_info,
|
||||||
|
u32 num_parts)
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user