// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)1/*2* Copyright 2013-2016 Freescale Semiconductor Inc.3*4*/5#include <linux/kernel.h>6#include <linux/fsl/mc.h>78#include "fsl-mc-private.h"910/**11* dpmcp_open() - Open a control session for the specified object.12* @mc_io: Pointer to MC portal's I/O object13* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'14* @dpmcp_id: DPMCP unique ID15* @token: Returned token; use in subsequent API calls16*17* This function can be used to open a control session for an18* already created object; an object may have been declared in19* the DPL or by calling the dpmcp_create function.20* This function returns a unique authentication token,21* associated with the specific object ID and the specific MC22* portal; this token must be used in all subsequent commands for23* this specific object24*25* Return: '0' on Success; Error code otherwise.26*/27int dpmcp_open(struct fsl_mc_io *mc_io,28u32 cmd_flags,29int dpmcp_id,30u16 *token)31{32struct fsl_mc_command cmd = { 0 };33struct dpmcp_cmd_open *cmd_params;34int err;3536/* prepare command */37cmd.header = mc_encode_cmd_header(DPMCP_CMDID_OPEN,38cmd_flags, 0);39cmd_params = (struct dpmcp_cmd_open *)cmd.params;40cmd_params->dpmcp_id = cpu_to_le32(dpmcp_id);4142/* send command to mc*/43err = mc_send_command(mc_io, &cmd);44if (err)45return err;4647/* retrieve response parameters */48*token = mc_cmd_hdr_read_token(&cmd);4950return err;51}5253/**54* dpmcp_close() - Close the control session of the object55* @mc_io: Pointer to MC portal's I/O object56* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'57* @token: Token of DPMCP object58*59* After this function is called, no further operations are60* allowed on the object without opening a new control session.61*62* Return: '0' on Success; Error code otherwise.63*/64int dpmcp_close(struct fsl_mc_io *mc_io,65u32 cmd_flags,66u16 token)67{68struct fsl_mc_command cmd = { 0 };6970/* prepare command */71cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CLOSE,72cmd_flags, token);7374/* send command to mc*/75return mc_send_command(mc_io, &cmd);76}777879