Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 2 | /* Copyright 2013-2015 Freescale Semiconductor Inc. |
Ioana Ciornei | 1c3769d | 2023-05-31 19:04:36 +0300 | [diff] [blame] | 3 | * Copyright 2023 NXP |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 4 | */ |
| 5 | #include <fsl-mc/fsl_mc_sys.h> |
| 6 | #include <fsl-mc/fsl_mc_cmd.h> |
| 7 | #include <fsl-mc/fsl_dpmng.h> |
| 8 | #include "fsl_dpmng_cmd.h" |
| 9 | |
Ioana Ciornei | 1c3769d | 2023-05-31 19:04:36 +0300 | [diff] [blame] | 10 | /** |
| 11 | * mc_get_version() - Retrieves the Management Complex firmware |
| 12 | * version information |
| 13 | * @mc_io: Pointer to opaque I/O object |
| 14 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 15 | * @mc_ver_info: Returned version information structure |
| 16 | * |
| 17 | * Return: '0' on Success; Error code otherwise. |
| 18 | */ |
| 19 | int mc_get_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, struct mc_version *mc_ver_info) |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 20 | { |
Ioana Ciornei | 1c3769d | 2023-05-31 19:04:36 +0300 | [diff] [blame] | 21 | struct dpmng_rsp_get_version *rsp_params; |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 22 | struct mc_command cmd = { 0 }; |
| 23 | int err; |
| 24 | |
| 25 | /* prepare command */ |
| 26 | cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION, |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 27 | cmd_flags, |
| 28 | 0); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 29 | |
| 30 | /* send command to mc*/ |
| 31 | err = mc_send_command(mc_io, &cmd); |
| 32 | if (err) |
| 33 | return err; |
| 34 | |
| 35 | /* retrieve response parameters */ |
Ioana Ciornei | 1c3769d | 2023-05-31 19:04:36 +0300 | [diff] [blame] | 36 | rsp_params = (struct dpmng_rsp_get_version *)cmd.params; |
| 37 | mc_ver_info->revision = le32_to_cpu(rsp_params->revision); |
| 38 | mc_ver_info->major = le32_to_cpu(rsp_params->version_major); |
| 39 | mc_ver_info->minor = le32_to_cpu(rsp_params->version_minor); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 40 | |
| 41 | return 0; |
| 42 | } |