Merge remote-tracking branch 'staging/staging-next'
[deliverable/linux.git] / drivers / staging / fsl-mc / bus / dpmng.c
CommitLineData
9989b599 1/* Copyright 2013-2016 Freescale Semiconductor Inc.
31c88965
GR
2*
3* Redistribution and use in source and binary forms, with or without
4* modification, are permitted provided that the following conditions are met:
5* * Redistributions of source code must retain the above copyright
6* notice, this list of conditions and the following disclaimer.
7* * Redistributions in binary form must reproduce the above copyright
8* notice, this list of conditions and the following disclaimer in the
9* documentation and/or other materials provided with the distribution.
10* * Neither the name of the above-listed copyright holders nor the
11* names of any contributors may be used to endorse or promote products
12* derived from this software without specific prior written permission.
13*
14*
15* ALTERNATIVELY, this software may be distributed under the terms of the
16* GNU General Public License ("GPL") as published by the Free Software
17* Foundation, either version 2 of that License or (at your option) any
18* later version.
19*
20* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30* POSSIBILITY OF SUCH DAMAGE.
31*/
32#include "../include/mc-sys.h"
33#include "../include/mc-cmd.h"
34#include "../include/dpmng.h"
d4e75132 35
31c88965
GR
36#include "dpmng-cmd.h"
37
e9bf3f20
GR
38/**
39 * mc_get_version() - Retrieves the Management Complex firmware
40 * version information
41 * @mc_io: Pointer to opaque I/O object
42 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
43 * @mc_ver_info: Returned version information structure
44 *
45 * Return: '0' on Success; Error code otherwise.
46 */
40577435 47int mc_get_version(struct fsl_mc_io *mc_io,
ba72f25b 48 u32 cmd_flags,
40577435 49 struct mc_version *mc_ver_info)
31c88965
GR
50{
51 struct mc_command cmd = { 0 };
9989b599 52 struct dpmng_rsp_get_version *rsp_params;
31c88965
GR
53 int err;
54
55 /* prepare command */
56 cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION,
40577435
GR
57 cmd_flags,
58 0);
31c88965
GR
59
60 /* send command to mc*/
61 err = mc_send_command(mc_io, &cmd);
62 if (err)
63 return err;
64
65 /* retrieve response parameters */
9989b599
IR
66 rsp_params = (struct dpmng_rsp_get_version *)cmd.params;
67 mc_ver_info->revision = le32_to_cpu(rsp_params->revision);
68 mc_ver_info->major = le32_to_cpu(rsp_params->version_major);
69 mc_ver_info->minor = le32_to_cpu(rsp_params->version_minor);
31c88965
GR
70
71 return 0;
72}
ec8d35d4 73EXPORT_SYMBOL(mc_get_version);
31c88965 74
e9bf3f20
GR
75/**
76 * dpmng_get_container_id() - Get container ID associated with a given portal.
77 * @mc_io: Pointer to MC portal's I/O object
78 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
79 * @container_id: Requested container ID
80 *
81 * Return: '0' on Success; Error code otherwise.
82 */
40577435 83int dpmng_get_container_id(struct fsl_mc_io *mc_io,
ba72f25b 84 u32 cmd_flags,
40577435 85 int *container_id)
31c88965
GR
86{
87 struct mc_command cmd = { 0 };
9989b599 88 struct dpmng_rsp_get_container_id *rsp_params;
31c88965
GR
89 int err;
90
91 /* prepare command */
92 cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_CONT_ID,
40577435
GR
93 cmd_flags,
94 0);
31c88965
GR
95
96 /* send command to mc*/
97 err = mc_send_command(mc_io, &cmd);
98 if (err)
99 return err;
100
101 /* retrieve response parameters */
9989b599
IR
102 rsp_params = (struct dpmng_rsp_get_container_id *)cmd.params;
103 *container_id = le32_to_cpu(rsp_params->container_id);
31c88965
GR
104
105 return 0;
106}
107
This page took 0.20302 seconds and 5 git commands to generate.