2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2015-03-19 16:20:45 +00:00
|
|
|
/*
|
2018-05-09 05:22:17 +00:00
|
|
|
* Copyright 2013-2016 Freescale Semiconductor, Inc.
|
2017-11-15 06:29:31 +00:00
|
|
|
* Copyright 2017 NXP
|
2015-03-19 16:20:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <fsl-mc/fsl_mc_sys.h>
|
|
|
|
#include <fsl-mc/fsl_mc_cmd.h>
|
|
|
|
#include <fsl-mc/fsl_dpio.h>
|
|
|
|
|
2015-07-07 10:10:06 +00:00
|
|
|
int dpio_open(struct fsl_mc_io *mc_io,
|
|
|
|
uint32_t cmd_flags,
|
2017-11-15 06:29:31 +00:00
|
|
|
uint32_t dpio_id,
|
2015-07-07 10:10:06 +00:00
|
|
|
uint16_t *token)
|
2015-03-19 16:20:45 +00:00
|
|
|
{
|
|
|
|
struct mc_command cmd = { 0 };
|
|
|
|
int err;
|
|
|
|
|
|
|
|
/* prepare command */
|
|
|
|
cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN,
|
2015-07-07 10:10:06 +00:00
|
|
|
cmd_flags,
|
|
|
|
0);
|
2015-03-19 16:20:45 +00:00
|
|
|
DPIO_CMD_OPEN(cmd, dpio_id);
|
|
|
|
|
|
|
|
/* send command to mc*/
|
|
|
|
err = mc_send_command(mc_io, &cmd);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/* retrieve response parameters */
|
|
|
|
*token = MC_CMD_HDR_READ_TOKEN(cmd.header);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-07 10:10:06 +00:00
|
|
|
int dpio_close(struct fsl_mc_io *mc_io,
|
|
|
|
uint32_t cmd_flags,
|
|
|
|
uint16_t token)
|
2015-03-19 16:20:45 +00:00
|
|
|
{
|
|
|
|
struct mc_command cmd = { 0 };
|
|
|
|
|
|
|
|
/* prepare command */
|
|
|
|
cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLOSE,
|
2015-07-07 10:10:06 +00:00
|
|
|
cmd_flags,
|
|
|
|
token);
|
2015-03-19 16:20:45 +00:00
|
|
|
|
|
|
|
/* send command to mc*/
|
|
|
|
return mc_send_command(mc_io, &cmd);
|
|
|
|
}
|
|
|
|
|
2015-11-04 06:55:53 +00:00
|
|
|
int dpio_create(struct fsl_mc_io *mc_io,
|
2017-11-15 06:29:31 +00:00
|
|
|
uint16_t dprc_token,
|
2015-11-04 06:55:53 +00:00
|
|
|
uint32_t cmd_flags,
|
|
|
|
const struct dpio_cfg *cfg,
|
2017-11-15 06:29:31 +00:00
|
|
|
uint32_t *obj_id)
|
2015-11-04 06:55:53 +00:00
|
|
|
{
|
|
|
|
struct mc_command cmd = { 0 };
|
|
|
|
int err;
|
|
|
|
|
|
|
|
/* prepare command */
|
|
|
|
cmd.header = mc_encode_cmd_header(DPIO_CMDID_CREATE,
|
|
|
|
cmd_flags,
|
2017-11-15 06:29:31 +00:00
|
|
|
dprc_token);
|
2015-11-04 06:55:53 +00:00
|
|
|
DPIO_CMD_CREATE(cmd, cfg);
|
|
|
|
|
|
|
|
/* send command to mc*/
|
|
|
|
err = mc_send_command(mc_io, &cmd);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/* retrieve response parameters */
|
2017-11-15 06:29:31 +00:00
|
|
|
MC_CMD_READ_OBJ_ID(cmd, *obj_id);
|
2015-11-04 06:55:53 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dpio_destroy(struct fsl_mc_io *mc_io,
|
2017-11-15 06:29:31 +00:00
|
|
|
uint16_t dprc_token,
|
2015-11-04 06:55:53 +00:00
|
|
|
uint32_t cmd_flags,
|
2017-11-15 06:29:31 +00:00
|
|
|
uint32_t obj_id)
|
2015-11-04 06:55:53 +00:00
|
|
|
{
|
|
|
|
struct mc_command cmd = { 0 };
|
|
|
|
|
|
|
|
/* prepare command */
|
|
|
|
cmd.header = mc_encode_cmd_header(DPIO_CMDID_DESTROY,
|
|
|
|
cmd_flags,
|
2017-11-15 06:29:31 +00:00
|
|
|
dprc_token);
|
|
|
|
|
|
|
|
/* set object id to destroy */
|
|
|
|
CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id);
|
2015-11-04 06:55:53 +00:00
|
|
|
|
|
|
|
/* send command to mc*/
|
|
|
|
return mc_send_command(mc_io, &cmd);
|
|
|
|
}
|
|
|
|
|
2015-07-07 10:10:06 +00:00
|
|
|
int dpio_enable(struct fsl_mc_io *mc_io,
|
|
|
|
uint32_t cmd_flags,
|
|
|
|
uint16_t token)
|
2015-03-19 16:20:45 +00:00
|
|
|
{
|
|
|
|
struct mc_command cmd = { 0 };
|
|
|
|
|
|
|
|
/* prepare command */
|
|
|
|
cmd.header = mc_encode_cmd_header(DPIO_CMDID_ENABLE,
|
2015-07-07 10:10:06 +00:00
|
|
|
cmd_flags,
|
|
|
|
token);
|
2015-03-19 16:20:45 +00:00
|
|
|
|
|
|
|
/* send command to mc*/
|
|
|
|
return mc_send_command(mc_io, &cmd);
|
|
|
|
}
|
|
|
|
|
2015-07-07 10:10:06 +00:00
|
|
|
int dpio_disable(struct fsl_mc_io *mc_io,
|
|
|
|
uint32_t cmd_flags,
|
|
|
|
uint16_t token)
|
2015-03-19 16:20:45 +00:00
|
|
|
{
|
|
|
|
struct mc_command cmd = { 0 };
|
|
|
|
|
|
|
|
/* prepare command */
|
|
|
|
cmd.header = mc_encode_cmd_header(DPIO_CMDID_DISABLE,
|
2015-07-07 10:10:06 +00:00
|
|
|
cmd_flags,
|
2015-03-19 16:20:45 +00:00
|
|
|
token);
|
|
|
|
|
|
|
|
/* send command to mc*/
|
|
|
|
return mc_send_command(mc_io, &cmd);
|
|
|
|
}
|
|
|
|
|
2015-07-07 10:10:06 +00:00
|
|
|
int dpio_reset(struct fsl_mc_io *mc_io,
|
|
|
|
uint32_t cmd_flags,
|
|
|
|
uint16_t token)
|
2015-03-19 16:20:45 +00:00
|
|
|
{
|
|
|
|
struct mc_command cmd = { 0 };
|
|
|
|
|
|
|
|
/* prepare command */
|
|
|
|
cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET,
|
2015-07-07 10:10:06 +00:00
|
|
|
cmd_flags,
|
|
|
|
token);
|
2015-03-19 16:20:45 +00:00
|
|
|
|
|
|
|
/* send command to mc*/
|
|
|
|
return mc_send_command(mc_io, &cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
int dpio_get_attributes(struct fsl_mc_io *mc_io,
|
2015-07-07 10:10:06 +00:00
|
|
|
uint32_t cmd_flags,
|
2015-03-19 16:20:45 +00:00
|
|
|
uint16_t token,
|
|
|
|
struct dpio_attr *attr)
|
|
|
|
{
|
|
|
|
struct mc_command cmd = { 0 };
|
|
|
|
int err;
|
|
|
|
|
|
|
|
/* prepare command */
|
|
|
|
cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_ATTR,
|
2015-07-07 10:10:06 +00:00
|
|
|
cmd_flags,
|
2015-03-19 16:20:45 +00:00
|
|
|
token);
|
|
|
|
|
|
|
|
/* send command to mc*/
|
|
|
|
err = mc_send_command(mc_io, &cmd);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/* retrieve response parameters */
|
|
|
|
DPIO_RSP_GET_ATTR(cmd, attr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-11-15 06:29:31 +00:00
|
|
|
|
|
|
|
int dpio_get_api_version(struct fsl_mc_io *mc_io,
|
|
|
|
u32 cmd_flags,
|
|
|
|
u16 *major_ver,
|
|
|
|
u16 *minor_ver)
|
|
|
|
{
|
|
|
|
struct mc_command cmd = { 0 };
|
|
|
|
int err;
|
|
|
|
|
|
|
|
/* prepare command */
|
|
|
|
cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_API_VERSION,
|
|
|
|
cmd_flags, 0);
|
|
|
|
|
|
|
|
/* send command to mc */
|
|
|
|
err = mc_send_command(mc_io, &cmd);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/* retrieve response parameters */
|
|
|
|
mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|