Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit decd3d0c authored by Ioana Ciornei's avatar Ioana Ciornei Committed by Greg Kroah-Hartman
Browse files

staging: fsl-mc: uprev binary interface to match MC v10.x



DPAA2 will not support MC firmware versions prior to MC v10.x.
Update the MC interface code and drivers to reflect this.
   -update the object .h files and code that builds commands to include
    the new command version in the command header
   -object versions are no longer available in the object attributes,
    so remove references to them and instead get the version from the
    new get_api_version() command
   -create/destroy commands for all objects have new arguments
   -dpmng_get_container_id() is replaced by dprc_get_container_id()

This supports a hardware ABI change and thus to match the new ABI
all the above changes need to happen in a single patch.

All MC firmware versions >= 10 will be supported going forward.

Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: default avatarStuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6466dac7
Loading
Loading
Loading
Loading
+34 −23
Original line number Diff line number Diff line
@@ -33,37 +33,48 @@
#define _FSL_DPBP_CMD_H

/* DPBP Version */
#define DPBP_VER_MAJOR				2
#define DPBP_VER_MAJOR				3
#define DPBP_VER_MINOR				2

/* Command versioning */
#define DPBP_CMD_BASE_VERSION			1
#define DPBP_CMD_ID_OFFSET			4

#define DPBP_CMD(id)	((id << DPBP_CMD_ID_OFFSET) | DPBP_CMD_BASE_VERSION)

/* Command IDs */
#define DPBP_CMDID_CLOSE				0x800
#define DPBP_CMDID_OPEN					0x804
#define DPBP_CMDID_CREATE				0x904
#define DPBP_CMDID_DESTROY				0x900

#define DPBP_CMDID_ENABLE				0x002
#define DPBP_CMDID_DISABLE				0x003
#define DPBP_CMDID_GET_ATTR				0x004
#define DPBP_CMDID_RESET				0x005
#define DPBP_CMDID_IS_ENABLED				0x006

#define DPBP_CMDID_SET_IRQ				0x010
#define DPBP_CMDID_GET_IRQ				0x011
#define DPBP_CMDID_SET_IRQ_ENABLE			0x012
#define DPBP_CMDID_GET_IRQ_ENABLE			0x013
#define DPBP_CMDID_SET_IRQ_MASK				0x014
#define DPBP_CMDID_GET_IRQ_MASK				0x015
#define DPBP_CMDID_GET_IRQ_STATUS			0x016
#define DPBP_CMDID_CLEAR_IRQ_STATUS			0x017

#define DPBP_CMDID_SET_NOTIFICATIONS		0x01b0
#define DPBP_CMDID_GET_NOTIFICATIONS		0x01b1
#define DPBP_CMDID_CLOSE		DPBP_CMD(0x800)
#define DPBP_CMDID_OPEN			DPBP_CMD(0x804)
#define DPBP_CMDID_CREATE		DPBP_CMD(0x904)
#define DPBP_CMDID_DESTROY		DPBP_CMD(0x984)
#define DPBP_CMDID_GET_API_VERSION	DPBP_CMD(0xa04)

#define DPBP_CMDID_ENABLE		DPBP_CMD(0x002)
#define DPBP_CMDID_DISABLE		DPBP_CMD(0x003)
#define DPBP_CMDID_GET_ATTR		DPBP_CMD(0x004)
#define DPBP_CMDID_RESET		DPBP_CMD(0x005)
#define DPBP_CMDID_IS_ENABLED		DPBP_CMD(0x006)

#define DPBP_CMDID_SET_IRQ		DPBP_CMD(0x010)
#define DPBP_CMDID_GET_IRQ		DPBP_CMD(0x011)
#define DPBP_CMDID_SET_IRQ_ENABLE	DPBP_CMD(0x012)
#define DPBP_CMDID_GET_IRQ_ENABLE	DPBP_CMD(0x013)
#define DPBP_CMDID_SET_IRQ_MASK		DPBP_CMD(0x014)
#define DPBP_CMDID_GET_IRQ_MASK		DPBP_CMD(0x015)
#define DPBP_CMDID_GET_IRQ_STATUS	DPBP_CMD(0x016)
#define DPBP_CMDID_CLEAR_IRQ_STATUS	DPBP_CMD(0x017)

#define DPBP_CMDID_SET_NOTIFICATIONS	DPBP_CMD(0x01b0)
#define DPBP_CMDID_GET_NOTIFICATIONS	DPBP_CMD(0x01b1)

struct dpbp_cmd_open {
	__le32 dpbp_id;
};

struct dpbp_cmd_destroy {
	__le32 object_id;
};

#define DPBP_ENABLE			0x1

struct dpbp_rsp_is_enabled {
+50 −17
Original line number Diff line number Diff line
@@ -108,28 +108,26 @@ EXPORT_SYMBOL(dpbp_close);
/**
 * dpbp_create() - Create the DPBP object.
 * @mc_io:	Pointer to MC portal's I/O object
 * @dprc_token:	Parent container token; '0' for default container
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @cfg:	Configuration structure
 * @token:	Returned token; use in subsequent API calls
 * @obj_id:	Returned object id; use in subsequent API calls
 *
 * Create the DPBP object, allocate required resources and
 * perform required initialization.
 *
 * The object can be created either by declaring it in the
 * DPL file, or by calling this function.
 * This function returns a unique authentication token,
 * associated with the specific object ID and the specific MC
 * portal; this token must be used in all subsequent calls to
 * this specific object. For objects that are created using the
 * DPL file, call dpbp_open function to get an authentication
 * token first.
 * This function accepts an authentication token of a parent
 * container that this object should be assigned to and returns
 * an object id. This object_id will be used in all subsequent calls to
 * this specific object.
 *
 * Return:	'0' on Success; Error code otherwise.
 */
int dpbp_create(struct fsl_mc_io *mc_io,
		u16 dprc_token,
		u32 cmd_flags,
		const struct dpbp_cfg *cfg,
		u16 *token)
		u32 *obj_id)
{
	struct mc_command cmd = { 0 };
	int err;
@@ -138,7 +136,7 @@ int dpbp_create(struct fsl_mc_io *mc_io,

	/* prepare command */
	cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE,
					  cmd_flags, 0);
					  cmd_flags, dprc_token);

	/* send command to mc*/
	err = mc_send_command(mc_io, &cmd);
@@ -146,7 +144,7 @@ int dpbp_create(struct fsl_mc_io *mc_io,
		return err;

	/* retrieve response parameters */
	*token = mc_cmd_hdr_read_token(&cmd);
	*obj_id = mc_cmd_read_object_id(&cmd);

	return 0;
}
@@ -154,20 +152,25 @@ int dpbp_create(struct fsl_mc_io *mc_io,
/**
 * dpbp_destroy() - Destroy the DPBP object and release all its resources.
 * @mc_io:	Pointer to MC portal's I/O object
 * @dprc_token:	Parent container token; '0' for default container
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @token:	Token of DPBP object
 * @obj_id:	ID of DPBP object
 *
 * Return:	'0' on Success; error code otherwise.
 */
int dpbp_destroy(struct fsl_mc_io *mc_io,
		 u16 dprc_token,
		 u32 cmd_flags,
		 u16 token)
		 u32 obj_id)
{
	struct dpbp_cmd_destroy *cmd_params;
	struct mc_command cmd = { 0 };

	/* prepare command */
	cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY,
					  cmd_flags, token);
					  cmd_flags, dprc_token);
	cmd_params = (struct dpbp_cmd_destroy *)cmd.params;
	cmd_params->object_id = cpu_to_le32(obj_id);

	/* send command to mc*/
	return mc_send_command(mc_io, &cmd);
@@ -610,8 +613,6 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io,
	rsp_params = (struct dpbp_rsp_get_attributes *)cmd.params;
	attr->bpid = le16_to_cpu(rsp_params->bpid);
	attr->id = le32_to_cpu(rsp_params->id);
	attr->version.major = le16_to_cpu(rsp_params->version_major);
	attr->version.minor = le16_to_cpu(rsp_params->version_minor);

	return 0;
}
@@ -690,3 +691,35 @@ int dpbp_get_notifications(struct fsl_mc_io *mc_io,

	return 0;
}

/**
 * dpbp_get_api_version - Get Data Path Buffer Pool API version
 * @mc_io:	Pointer to Mc portal's I/O object
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @major_ver:	Major version of Buffer Pool API
 * @minor_ver:	Minor version of Buffer Pool API
 *
 * Return:	'0' on Success; Error code otherwise.
 */
int dpbp_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(DPBP_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;
}
+28 −17
Original line number Diff line number Diff line
@@ -36,22 +36,29 @@
#define DPMCP_MIN_VER_MAJOR		3
#define DPMCP_MIN_VER_MINOR		0

/* Command versioning */
#define DPMCP_CMD_BASE_VERSION		1
#define DPMCP_CMD_ID_OFFSET		4

#define DPMCP_CMD(id)	((id << DPMCP_CMD_ID_OFFSET) | DPMCP_CMD_BASE_VERSION)

/* Command IDs */
#define DPMCP_CMDID_CLOSE				0x800
#define DPMCP_CMDID_OPEN				0x80b
#define DPMCP_CMDID_CREATE				0x90b
#define DPMCP_CMDID_DESTROY				0x900

#define DPMCP_CMDID_GET_ATTR				0x004
#define DPMCP_CMDID_RESET				0x005

#define DPMCP_CMDID_SET_IRQ				0x010
#define DPMCP_CMDID_GET_IRQ				0x011
#define DPMCP_CMDID_SET_IRQ_ENABLE			0x012
#define DPMCP_CMDID_GET_IRQ_ENABLE			0x013
#define DPMCP_CMDID_SET_IRQ_MASK			0x014
#define DPMCP_CMDID_GET_IRQ_MASK			0x015
#define DPMCP_CMDID_GET_IRQ_STATUS			0x016
#define DPMCP_CMDID_CLOSE		DPMCP_CMD(0x800)
#define DPMCP_CMDID_OPEN		DPMCP_CMD(0x80b)
#define DPMCP_CMDID_CREATE		DPMCP_CMD(0x90b)
#define DPMCP_CMDID_DESTROY		DPMCP_CMD(0x98b)
#define DPMCP_CMDID_GET_API_VERSION	DPMCP_CMD(0xa0b)

#define DPMCP_CMDID_GET_ATTR		DPMCP_CMD(0x004)
#define DPMCP_CMDID_RESET		DPMCP_CMD(0x005)

#define DPMCP_CMDID_SET_IRQ		DPMCP_CMD(0x010)
#define DPMCP_CMDID_GET_IRQ		DPMCP_CMD(0x011)
#define DPMCP_CMDID_SET_IRQ_ENABLE	DPMCP_CMD(0x012)
#define DPMCP_CMDID_GET_IRQ_ENABLE	DPMCP_CMD(0x013)
#define DPMCP_CMDID_SET_IRQ_MASK	DPMCP_CMD(0x014)
#define DPMCP_CMDID_GET_IRQ_MASK	DPMCP_CMD(0x015)
#define DPMCP_CMDID_GET_IRQ_STATUS	DPMCP_CMD(0x016)

struct dpmcp_cmd_open {
	__le32 dpmcp_id;
@@ -61,6 +68,10 @@ struct dpmcp_cmd_create {
	__le32 portal_id;
};

struct dpmcp_cmd_destroy {
	__le32 object_id;
};

struct dpmcp_cmd_set_irq {
	/* cmd word 0 */
	u8 irq_index;
+51 −15
Original line number Diff line number Diff line
@@ -106,28 +106,29 @@ int dpmcp_close(struct fsl_mc_io *mc_io,
/**
 * dpmcp_create() - Create the DPMCP object.
 * @mc_io:	Pointer to MC portal's I/O object
 * @dprc_token:	Parent container token; '0' for default container
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @cfg:	Configuration structure
 * @token:	Returned token; use in subsequent API calls
 * @obj_id:	Returned object id; use in subsequent API calls
 *
 * Create the DPMCP object, allocate required resources and
 * perform required initialization.
 *
 * The object can be created either by declaring it in the
 * DPL file, or by calling this function.
 * This function returns a unique authentication token,
 * associated with the specific object ID and the specific MC
 * portal; this token must be used in all subsequent calls to
 * this specific object. For objects that are created using the
 * DPL file, call dpmcp_open function to get an authentication
 * token first.

 * This function accepts an authentication token of a parent
 * container that this object should be assigned to and returns
 * an object id. This object_id will be used in all subsequent calls to
 * this specific object.
 *
 * Return:	'0' on Success; Error code otherwise.
 */
int dpmcp_create(struct fsl_mc_io *mc_io,
		 u16 dprc_token,
		 u32 cmd_flags,
		 const struct dpmcp_cfg *cfg,
		 u16 *token)
		 u32 *obj_id)
{
	struct mc_command cmd = { 0 };
	struct dpmcp_cmd_create *cmd_params;
@@ -136,7 +137,7 @@ int dpmcp_create(struct fsl_mc_io *mc_io,

	/* prepare command */
	cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CREATE,
					  cmd_flags, 0);
					  cmd_flags, dprc_token);
	cmd_params = (struct dpmcp_cmd_create *)cmd.params;
	cmd_params->portal_id = cpu_to_le32(cfg->portal_id);

@@ -146,7 +147,7 @@ int dpmcp_create(struct fsl_mc_io *mc_io,
		return err;

	/* retrieve response parameters */
	*token = mc_cmd_hdr_read_token(&cmd);
	*obj_id = mc_cmd_read_object_id(&cmd);

	return 0;
}
@@ -154,20 +155,25 @@ int dpmcp_create(struct fsl_mc_io *mc_io,
/**
 * dpmcp_destroy() - Destroy the DPMCP object and release all its resources.
 * @mc_io:	Pointer to MC portal's I/O object
 * @dprc_token:	Parent container token; '0' for default container
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @token:	Token of DPMCP object
 * @obj_id:	ID of DPMCP object
 *
 * Return:	'0' on Success; error code otherwise.
 */
int dpmcp_destroy(struct fsl_mc_io *mc_io,
		  u16 dprc_token,
		  u32 cmd_flags,
		  u16 token)
		  u32 obj_id)
{
	struct mc_command cmd = { 0 };
	struct dpmcp_cmd_destroy *cmd_params;

	/* prepare command */
	cmd.header = mc_encode_cmd_header(DPMCP_CMDID_DESTROY,
					  cmd_flags, token);
					  cmd_flags, dprc_token);
	cmd_params = (struct dpmcp_cmd_destroy *)cmd.params;
	cmd_params->object_id = cpu_to_le32(obj_id);

	/* send command to mc*/
	return mc_send_command(mc_io, &cmd);
@@ -497,8 +503,38 @@ int dpmcp_get_attributes(struct fsl_mc_io *mc_io,
	/* retrieve response parameters */
	rsp_params = (struct dpmcp_rsp_get_attributes *)cmd.params;
	attr->id = le32_to_cpu(rsp_params->id);
	attr->version.major = le16_to_cpu(rsp_params->version_major);
	attr->version.minor = le16_to_cpu(rsp_params->version_minor);

	return 0;
}

/**
 * dpmcp_get_api_version - Get Data Path Management Command Portal API version
 * @mc_io:	Pointer to Mc portal's I/O object
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @major_ver:	Major version of Data Path Management Command Portal API
 * @minor_ver:	Minor version of Data Path Management Command Portal API
 *
 * Return:	'0' on Success; Error code otherwise.
 */
int dpmcp_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(DPMCP_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;
}
+5 −13
Original line number Diff line number Diff line
@@ -61,13 +61,15 @@ struct dpmcp_cfg {
};

int dpmcp_create(struct fsl_mc_io *mc_io,
		 u16 dprc_token,
		 u32 cmd_flags,
		 const struct dpmcp_cfg *cfg,
		 u16 *token);
		 u32 *obj_id);

int dpmcp_destroy(struct fsl_mc_io *mc_io,
		  u16 dprc_token,
		  u32 cmd_flags,
		  u16 token);
		  u32 obj_id);

int dpmcp_reset(struct fsl_mc_io *mc_io,
		u32 cmd_flags,
@@ -137,19 +139,9 @@ int dpmcp_get_irq_status(struct fsl_mc_io *mc_io,
/**
 * struct dpmcp_attr - Structure representing DPMCP attributes
 * @id:		DPMCP object ID
 * @version:	DPMCP version
 */
struct dpmcp_attr {
	int id;
	/**
	 * struct version - Structure representing DPMCP version
	 * @major:	DPMCP major version
	 * @minor:	DPMCP minor version
	 */
	struct {
		u16 major;
		u16 minor;
	} version;
};

int dpmcp_get_attributes(struct fsl_mc_io *mc_io,
Loading