1 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
6 #include <linux/kernel.h>
7 #include <linux/fsl/mc.h>
9 #include "fsl-mc-private.h"
12 * dpmcp_open() - Open a control session for the specified object.
13 * @mc_io: Pointer to MC portal's I/O object
14 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15 * @dpmcp_id: DPMCP unique ID
16 * @token: Returned token; use in subsequent API calls
18 * This function can be used to open a control session for an
19 * already created object; an object may have been declared in
20 * the DPL or by calling the dpmcp_create function.
21 * This function returns a unique authentication token,
22 * associated with the specific object ID and the specific MC
23 * portal; this token must be used in all subsequent commands for
24 * this specific object
26 * Return: '0' on Success; Error code otherwise.
28 int dpmcp_open(struct fsl_mc_io
*mc_io
,
33 struct fsl_mc_command cmd
= { 0 };
34 struct dpmcp_cmd_open
*cmd_params
;
38 cmd
.header
= mc_encode_cmd_header(DPMCP_CMDID_OPEN
,
40 cmd_params
= (struct dpmcp_cmd_open
*)cmd
.params
;
41 cmd_params
->dpmcp_id
= cpu_to_le32(dpmcp_id
);
43 /* send command to mc*/
44 err
= mc_send_command(mc_io
, &cmd
);
48 /* retrieve response parameters */
49 *token
= mc_cmd_hdr_read_token(&cmd
);
55 * dpmcp_close() - Close the control session of the object
56 * @mc_io: Pointer to MC portal's I/O object
57 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
58 * @token: Token of DPMCP object
60 * After this function is called, no further operations are
61 * allowed on the object without opening a new control session.
63 * Return: '0' on Success; Error code otherwise.
65 int dpmcp_close(struct fsl_mc_io
*mc_io
,
69 struct fsl_mc_command cmd
= { 0 };
72 cmd
.header
= mc_encode_cmd_header(DPMCP_CMDID_CLOSE
,
75 /* send command to mc*/
76 return mc_send_command(mc_io
, &cmd
);
80 * dpmcp_reset() - Reset the DPMCP, returns the object to initial state.
81 * @mc_io: Pointer to MC portal's I/O object
82 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
83 * @token: Token of DPMCP object
85 * Return: '0' on Success; Error code otherwise.
87 int dpmcp_reset(struct fsl_mc_io
*mc_io
,
91 struct fsl_mc_command cmd
= { 0 };
94 cmd
.header
= mc_encode_cmd_header(DPMCP_CMDID_RESET
,
97 /* send command to mc*/
98 return mc_send_command(mc_io
, &cmd
);