Branch data Line data Source code
1 : : /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) 2 : : * 3 : : * Copyright 2013-2015 Freescale Semiconductor Inc. 4 : : * Copyright 2017 NXP 5 : : * 6 : : */ 7 : : #include <fsl_mc_sys.h> 8 : : #include <fsl_mc_cmd.h> 9 : : #include <fsl_dpmng.h> 10 : : #include <fsl_dpmng_cmd.h> 11 : : 12 : : /** 13 : : * mc_get_version() - Retrieves the Management Complex firmware 14 : : * version information 15 : : * @mc_io: Pointer to opaque I/O object 16 : : * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' 17 : : * @mc_ver_info: Returned version information structure 18 : : * 19 : : * Return: '0' on Success; Error code otherwise. 20 : : */ 21 : 0 : int mc_get_version(struct fsl_mc_io *mc_io, 22 : : uint32_t cmd_flags, 23 : : struct mc_version *mc_ver_info) 24 : : { 25 : 0 : struct mc_command cmd = { 0 }; 26 : : struct dpmng_rsp_get_version *rsp_params; 27 : : int err; 28 : : 29 : : /* prepare command */ 30 : 0 : cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION, 31 : : cmd_flags, 32 : : 0); 33 : : 34 : : /* send command to mc*/ 35 : 0 : err = mc_send_command(mc_io, &cmd); 36 [ # # ]: 0 : if (err) 37 : : return err; 38 : : 39 : : /* retrieve response parameters */ 40 : : rsp_params = (struct dpmng_rsp_get_version *)cmd.params; 41 : 0 : mc_ver_info->revision = le32_to_cpu(rsp_params->revision); 42 : 0 : mc_ver_info->major = le32_to_cpu(rsp_params->version_major); 43 : 0 : mc_ver_info->minor = le32_to_cpu(rsp_params->version_minor); 44 : : 45 : 0 : return 0; 46 : : } 47 : : 48 : : /** 49 : : * mc_get_soc_version() - Retrieves the Management Complex firmware 50 : : * version information 51 : : * @mc_io Pointer to opaque I/O object 52 : : * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' 53 : : * @mc_platform_info: Returned version information structure. The structure 54 : : * contains the values of SVR and PVR registers. 55 : : * Please consult platform specific reference manual 56 : : * for detailed information. 57 : : * 58 : : * Return: '0' on Success; Error code otherwise. 59 : : */ 60 : 0 : int mc_get_soc_version(struct fsl_mc_io *mc_io, 61 : : uint32_t cmd_flags, 62 : : struct mc_soc_version *mc_platform_info) 63 : : { 64 : : struct dpmng_rsp_get_soc_version *rsp_params; 65 : 0 : struct mc_command cmd = { 0 }; 66 : : int err; 67 : : 68 : : /* prepare command */ 69 : 0 : cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_SOC_VERSION, 70 : : cmd_flags, 71 : : 0); 72 : : 73 : : /* send command to mc*/ 74 : 0 : err = mc_send_command(mc_io, &cmd); 75 [ # # ]: 0 : if (err) 76 : : return err; 77 : : 78 : : /* retrieve response parameters */ 79 : : rsp_params = (struct dpmng_rsp_get_soc_version *)cmd.params; 80 : 0 : mc_platform_info->svr = le32_to_cpu(rsp_params->svr); 81 : 0 : mc_platform_info->pvr = le32_to_cpu(rsp_params->pvr); 82 : : 83 : 0 : return 0; 84 : : }