Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
0002 /*
0003  * Copyright 2013-2016 Freescale Semiconductor Inc.
0004  *
0005  */
0006 #include <linux/kernel.h>
0007 #include <linux/fsl/mc.h>
0008 
0009 #include "fsl-mc-private.h"
0010 
0011 /**
0012  * dpmcp_open() - Open a control session for the specified object.
0013  * @mc_io:  Pointer to MC portal's I/O object
0014  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
0015  * @dpmcp_id:   DPMCP unique ID
0016  * @token:  Returned token; use in subsequent API calls
0017  *
0018  * This function can be used to open a control session for an
0019  * already created object; an object may have been declared in
0020  * the DPL or by calling the dpmcp_create function.
0021  * This function returns a unique authentication token,
0022  * associated with the specific object ID and the specific MC
0023  * portal; this token must be used in all subsequent commands for
0024  * this specific object
0025  *
0026  * Return:  '0' on Success; Error code otherwise.
0027  */
0028 int dpmcp_open(struct fsl_mc_io *mc_io,
0029            u32 cmd_flags,
0030            int dpmcp_id,
0031            u16 *token)
0032 {
0033     struct fsl_mc_command cmd = { 0 };
0034     struct dpmcp_cmd_open *cmd_params;
0035     int err;
0036 
0037     /* prepare command */
0038     cmd.header = mc_encode_cmd_header(DPMCP_CMDID_OPEN,
0039                       cmd_flags, 0);
0040     cmd_params = (struct dpmcp_cmd_open *)cmd.params;
0041     cmd_params->dpmcp_id = cpu_to_le32(dpmcp_id);
0042 
0043     /* send command to mc*/
0044     err = mc_send_command(mc_io, &cmd);
0045     if (err)
0046         return err;
0047 
0048     /* retrieve response parameters */
0049     *token = mc_cmd_hdr_read_token(&cmd);
0050 
0051     return err;
0052 }
0053 
0054 /**
0055  * dpmcp_close() - Close the control session of the object
0056  * @mc_io:  Pointer to MC portal's I/O object
0057  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
0058  * @token:  Token of DPMCP object
0059  *
0060  * After this function is called, no further operations are
0061  * allowed on the object without opening a new control session.
0062  *
0063  * Return:  '0' on Success; Error code otherwise.
0064  */
0065 int dpmcp_close(struct fsl_mc_io *mc_io,
0066         u32 cmd_flags,
0067         u16 token)
0068 {
0069     struct fsl_mc_command cmd = { 0 };
0070 
0071     /* prepare command */
0072     cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CLOSE,
0073                       cmd_flags, token);
0074 
0075     /* send command to mc*/
0076     return mc_send_command(mc_io, &cmd);
0077 }
0078 
0079 /**
0080  * dpmcp_reset() - Reset the DPMCP, returns the object to initial state.
0081  * @mc_io:  Pointer to MC portal's I/O object
0082  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
0083  * @token:  Token of DPMCP object
0084  *
0085  * Return:  '0' on Success; Error code otherwise.
0086  */
0087 int dpmcp_reset(struct fsl_mc_io *mc_io,
0088         u32 cmd_flags,
0089         u16 token)
0090 {
0091     struct fsl_mc_command cmd = { 0 };
0092 
0093     /* prepare command */
0094     cmd.header = mc_encode_cmd_header(DPMCP_CMDID_RESET,
0095                       cmd_flags, token);
0096 
0097     /* send command to mc*/
0098     return mc_send_command(mc_io, &cmd);
0099 }