Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <dhaval.r.shah@amd.com>
Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
Reviewed-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/20230731095026.3766675-2-sai.krishna.potthuri@amd.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Dhaval Shah and committed by
Linus Walleij
03ffa9af 046d3546

+51
+40
drivers/firmware/xilinx/zynqmp.c
··· 339 339 340 340 static u32 pm_api_version; 341 341 static u32 pm_tz_version; 342 + static u32 pm_family_code; 343 + static u32 pm_sub_family_code; 342 344 343 345 int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset) 344 346 { ··· 405 403 return ret; 406 404 } 407 405 EXPORT_SYMBOL_GPL(zynqmp_pm_get_chipid); 406 + 407 + /** 408 + * zynqmp_pm_get_family_info() - Get family info of platform 409 + * @family: Returned family code value 410 + * @subfamily: Returned sub-family code value 411 + * 412 + * Return: Returns status, either success or error+reason 413 + */ 414 + static int zynqmp_pm_get_family_info(u32 *family, u32 *subfamily) 415 + { 416 + u32 ret_payload[PAYLOAD_ARG_CNT]; 417 + u32 idcode; 418 + int ret; 419 + 420 + /* Check is family or sub-family code already received */ 421 + if (pm_family_code && pm_sub_family_code) { 422 + *family = pm_family_code; 423 + *subfamily = pm_sub_family_code; 424 + return 0; 425 + } 426 + 427 + ret = zynqmp_pm_invoke_fn(PM_GET_CHIPID, 0, 0, 0, 0, ret_payload); 428 + if (ret < 0) 429 + return ret; 430 + 431 + idcode = ret_payload[1]; 432 + pm_family_code = FIELD_GET(FAMILY_CODE_MASK, idcode); 433 + pm_sub_family_code = FIELD_GET(SUB_FAMILY_CODE_MASK, idcode); 434 + *family = pm_family_code; 435 + *subfamily = pm_sub_family_code; 436 + 437 + return 0; 438 + } 408 439 409 440 /** 410 441 * zynqmp_pm_get_trustzone_version() - Get secure trustzone firmware version ··· 1953 1918 1954 1919 pr_info("%s Platform Management API v%d.%d\n", __func__, 1955 1920 pm_api_version >> 16, pm_api_version & 0xFFFF); 1921 + 1922 + /* Get the Family code and sub family code of platform */ 1923 + ret = zynqmp_pm_get_family_info(&pm_family_code, &pm_sub_family_code); 1924 + if (ret < 0) 1925 + return ret; 1956 1926 1957 1927 /* Check trustzone version number */ 1958 1928 ret = zynqmp_pm_get_trustzone_version(&pm_tz_version);
+11
include/linux/firmware/xlnx-zynqmp.h
··· 34 34 /* PM API versions */ 35 35 #define PM_API_VERSION_2 2 36 36 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 + 37 48 /* ATF only commands */ 38 49 #define TF_A_PM_REGISTER_SGI 0xa04 39 50 #define PM_GET_TRUSTZONE_VERSION 0xa03