Skip to content

Commit 03ffa9a

Browse files
Dhaval Shahlinusw
authored andcommitted
firmware: xilinx: Add support to get platform information
Add function to get family code and sub family code from the idcode. This family code and sub family code helps to identify the platform. Family code of any platform is on bits 21 to 27 and Sub family code is on bits 19 and 20. Signed-off-by: Dhaval Shah <[email protected]> Signed-off-by: Sai Krishna Potthuri <[email protected]> Reviewed-by: Michal Simek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 046d354 commit 03ffa9a

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

drivers/firmware/xilinx/zynqmp.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1,
339339

340340
static u32 pm_api_version;
341341
static u32 pm_tz_version;
342+
static u32 pm_family_code;
343+
static u32 pm_sub_family_code;
342344

343345
int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset)
344346
{
@@ -404,6 +406,39 @@ int zynqmp_pm_get_chipid(u32 *idcode, u32 *version)
404406
}
405407
EXPORT_SYMBOL_GPL(zynqmp_pm_get_chipid);
406408

409+
/**
410+
* zynqmp_pm_get_family_info() - Get family info of platform
411+
* @family: Returned family code value
412+
* @subfamily: Returned sub-family code value
413+
*
414+
* Return: Returns status, either success or error+reason
415+
*/
416+
static int zynqmp_pm_get_family_info(u32 *family, u32 *subfamily)
417+
{
418+
u32 ret_payload[PAYLOAD_ARG_CNT];
419+
u32 idcode;
420+
int ret;
421+
422+
/* Check is family or sub-family code already received */
423+
if (pm_family_code && pm_sub_family_code) {
424+
*family = pm_family_code;
425+
*subfamily = pm_sub_family_code;
426+
return 0;
427+
}
428+
429+
ret = zynqmp_pm_invoke_fn(PM_GET_CHIPID, 0, 0, 0, 0, ret_payload);
430+
if (ret < 0)
431+
return ret;
432+
433+
idcode = ret_payload[1];
434+
pm_family_code = FIELD_GET(FAMILY_CODE_MASK, idcode);
435+
pm_sub_family_code = FIELD_GET(SUB_FAMILY_CODE_MASK, idcode);
436+
*family = pm_family_code;
437+
*subfamily = pm_sub_family_code;
438+
439+
return 0;
440+
}
441+
407442
/**
408443
* zynqmp_pm_get_trustzone_version() - Get secure trustzone firmware version
409444
* @version: Returned version value
@@ -1919,6 +1954,11 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
19191954
pr_info("%s Platform Management API v%d.%d\n", __func__,
19201955
pm_api_version >> 16, pm_api_version & 0xFFFF);
19211956

1957+
/* Get the Family code and sub family code of platform */
1958+
ret = zynqmp_pm_get_family_info(&pm_family_code, &pm_sub_family_code);
1959+
if (ret < 0)
1960+
return ret;
1961+
19221962
/* Check trustzone version number */
19231963
ret = zynqmp_pm_get_trustzone_version(&pm_tz_version);
19241964
if (ret)

include/linux/firmware/xlnx-zynqmp.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@
3434
/* PM API versions */
3535
#define PM_API_VERSION_2 2
3636

37+
#define ZYNQMP_FAMILY_CODE 0x23
38+
#define VERSAL_FAMILY_CODE 0x26
39+
40+
/* When all subfamily of platform need to support */
41+
#define ALL_SUB_FAMILY_CODE 0x00
42+
#define VERSAL_SUB_FAMILY_CODE 0x01
43+
#define VERSALNET_SUB_FAMILY_CODE 0x03
44+
45+
#define FAMILY_CODE_MASK GENMASK(27, 21)
46+
#define SUB_FAMILY_CODE_MASK GENMASK(20, 19)
47+
3748
/* ATF only commands */
3849
#define TF_A_PM_REGISTER_SGI 0xa04
3950
#define PM_GET_TRUSTZONE_VERSION 0xa03

0 commit comments

Comments
 (0)