blob: 147ca6da9e1f58a3937638d907c597fb4251a2f0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -07002/* Copyright 2013-2015 Freescale Semiconductor Inc.
Ioana Ciornei1c3769d2023-05-31 19:04:36 +03003 * Copyright 2023 NXP
J. German Rivera43e4ae32015-01-06 13:19:02 -08004 */
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 Ciornei1c3769d2023-05-31 19:04:36 +030010/**
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 */
19int mc_get_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, struct mc_version *mc_ver_info)
J. German Rivera43e4ae32015-01-06 13:19:02 -080020{
Ioana Ciornei1c3769d2023-05-31 19:04:36 +030021 struct dpmng_rsp_get_version *rsp_params;
J. German Rivera43e4ae32015-01-06 13:19:02 -080022 struct mc_command cmd = { 0 };
23 int err;
24
25 /* prepare command */
26 cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053027 cmd_flags,
28 0);
J. German Rivera43e4ae32015-01-06 13:19:02 -080029
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 Ciornei1c3769d2023-05-31 19:04:36 +030036 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 Rivera43e4ae32015-01-06 13:19:02 -080040
41 return 0;
42}