mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-19 02:34:01 +08:00
staging: fsl-mc: convert mc command build/parse to use C structs
The layer abstracting the building of commands and extracting responses is currently based on macros that shift and mask the command fields and requires exposing offset/size values as macro parameters and makes the code harder to read. For clarity and maintainability, instead use an implementation based on mapping the MC command definitions to C structures. These structures contain the hardware command fields (which are naturally-aligned) and individual fields are little-endian ordering (the byte ordering of the hardware). As such, there is no need to perform the conversion between core and hardware (LE) endianness in mc_send_command(), but instead each individual field in a command will be converted separately if needed by the function building the command or extracting the response. This patch does not introduce functional changes, both the hardware ABIs and the APIs exposed for the DPAA2 objects remain the same. Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com> Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
adf72b5ba3
commit
9989b59961
@ -1,4 +1,4 @@
|
||||
/* Copyright 2013-2014 Freescale Semiconductor Inc.
|
||||
/* Copyright 2013-2016 Freescale Semiconductor Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -57,12 +57,14 @@ int dpbp_open(struct fsl_mc_io *mc_io,
|
||||
u16 *token)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_cmd_open *cmd_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN,
|
||||
cmd_flags, 0);
|
||||
cmd.params[0] |= mc_enc(0, 32, dpbp_id);
|
||||
cmd_params = (struct dpbp_cmd_open *)cmd.params;
|
||||
cmd_params->dpbp_id = cpu_to_le32(dpbp_id);
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -70,7 +72,7 @@ int dpbp_open(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*token = MC_CMD_HDR_READ_TOKEN(cmd.header);
|
||||
*token = mc_cmd_hdr_read_token(&cmd);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -143,7 +145,7 @@ int dpbp_create(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*token = MC_CMD_HDR_READ_TOKEN(cmd.header);
|
||||
*token = mc_cmd_hdr_read_token(&cmd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -231,6 +233,7 @@ int dpbp_is_enabled(struct fsl_mc_io *mc_io,
|
||||
int *en)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_rsp_is_enabled *rsp_params;
|
||||
int err;
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_IS_ENABLED, cmd_flags,
|
||||
@ -242,7 +245,8 @@ int dpbp_is_enabled(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*en = (int)mc_dec(cmd.params[0], 0, 1);
|
||||
rsp_params = (struct dpbp_rsp_is_enabled *)cmd.params;
|
||||
*en = rsp_params->enabled & DPBP_ENABLE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -286,14 +290,16 @@ int dpbp_set_irq(struct fsl_mc_io *mc_io,
|
||||
struct dpbp_irq_cfg *irq_cfg)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_cmd_set_irq *cmd_params;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(0, 8, irq_index);
|
||||
cmd.params[0] |= mc_enc(32, 32, irq_cfg->val);
|
||||
cmd.params[1] |= mc_enc(0, 64, irq_cfg->addr);
|
||||
cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num);
|
||||
cmd_params = (struct dpbp_cmd_set_irq *)cmd.params;
|
||||
cmd_params->irq_index = irq_index;
|
||||
cmd_params->irq_val = cpu_to_le32(irq_cfg->val);
|
||||
cmd_params->irq_addr = cpu_to_le64(irq_cfg->addr);
|
||||
cmd_params->irq_num = cpu_to_le32(irq_cfg->irq_num);
|
||||
|
||||
/* send command to mc*/
|
||||
return mc_send_command(mc_io, &cmd);
|
||||
@ -319,12 +325,15 @@ int dpbp_get_irq(struct fsl_mc_io *mc_io,
|
||||
struct dpbp_irq_cfg *irq_cfg)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_cmd_get_irq *cmd_params;
|
||||
struct dpbp_rsp_get_irq *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpbp_cmd_get_irq *)cmd.params;
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -332,10 +341,12 @@ int dpbp_get_irq(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32);
|
||||
irq_cfg->addr = (u64)mc_dec(cmd.params[1], 0, 64);
|
||||
irq_cfg->irq_num = (int)mc_dec(cmd.params[2], 0, 32);
|
||||
*type = (int)mc_dec(cmd.params[2], 32, 32);
|
||||
rsp_params = (struct dpbp_rsp_get_irq *)cmd.params;
|
||||
irq_cfg->val = le32_to_cpu(rsp_params->irq_val);
|
||||
irq_cfg->addr = le64_to_cpu(rsp_params->irq_addr);
|
||||
irq_cfg->irq_num = le32_to_cpu(rsp_params->irq_num);
|
||||
*type = le32_to_cpu(rsp_params->type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -361,12 +372,14 @@ int dpbp_set_irq_enable(struct fsl_mc_io *mc_io,
|
||||
u8 en)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_cmd_set_irq_enable *cmd_params;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ_ENABLE,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(0, 8, en);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpbp_cmd_set_irq_enable *)cmd.params;
|
||||
cmd_params->enable = en & DPBP_ENABLE;
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
return mc_send_command(mc_io, &cmd);
|
||||
@ -389,12 +402,15 @@ int dpbp_get_irq_enable(struct fsl_mc_io *mc_io,
|
||||
u8 *en)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_cmd_get_irq_enable *cmd_params;
|
||||
struct dpbp_rsp_get_irq_enable *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_ENABLE,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpbp_cmd_get_irq_enable *)cmd.params;
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -402,7 +418,8 @@ int dpbp_get_irq_enable(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*en = (u8)mc_dec(cmd.params[0], 0, 8);
|
||||
rsp_params = (struct dpbp_rsp_get_irq_enable *)cmd.params;
|
||||
*en = rsp_params->enabled & DPBP_ENABLE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -429,12 +446,14 @@ int dpbp_set_irq_mask(struct fsl_mc_io *mc_io,
|
||||
u32 mask)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_cmd_set_irq_mask *cmd_params;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ_MASK,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(0, 32, mask);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpbp_cmd_set_irq_mask *)cmd.params;
|
||||
cmd_params->mask = cpu_to_le32(mask);
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
return mc_send_command(mc_io, &cmd);
|
||||
@ -460,12 +479,15 @@ int dpbp_get_irq_mask(struct fsl_mc_io *mc_io,
|
||||
u32 *mask)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_cmd_get_irq_mask *cmd_params;
|
||||
struct dpbp_rsp_get_irq_mask *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_MASK,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpbp_cmd_get_irq_mask *)cmd.params;
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -473,7 +495,9 @@ int dpbp_get_irq_mask(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*mask = (u32)mc_dec(cmd.params[0], 0, 32);
|
||||
rsp_params = (struct dpbp_rsp_get_irq_mask *)cmd.params;
|
||||
*mask = le32_to_cpu(rsp_params->mask);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -497,13 +521,16 @@ int dpbp_get_irq_status(struct fsl_mc_io *mc_io,
|
||||
u32 *status)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_cmd_get_irq_status *cmd_params;
|
||||
struct dpbp_rsp_get_irq_status *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_STATUS,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(0, 32, *status);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpbp_cmd_get_irq_status *)cmd.params;
|
||||
cmd_params->status = cpu_to_le32(*status);
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -511,7 +538,9 @@ int dpbp_get_irq_status(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*status = (u32)mc_dec(cmd.params[0], 0, 32);
|
||||
rsp_params = (struct dpbp_rsp_get_irq_status *)cmd.params;
|
||||
*status = le32_to_cpu(rsp_params->status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -535,12 +564,14 @@ int dpbp_clear_irq_status(struct fsl_mc_io *mc_io,
|
||||
u32 status)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_cmd_clear_irq_status *cmd_params;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLEAR_IRQ_STATUS,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(0, 32, status);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpbp_cmd_clear_irq_status *)cmd.params;
|
||||
cmd_params->status = cpu_to_le32(status);
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
return mc_send_command(mc_io, &cmd);
|
||||
@ -562,6 +593,7 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io,
|
||||
struct dpbp_attr *attr)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_rsp_get_attributes *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
@ -574,10 +606,12 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
attr->bpid = (u16)mc_dec(cmd.params[0], 16, 16);
|
||||
attr->id = (int)mc_dec(cmd.params[0], 32, 32);
|
||||
attr->version.major = (u16)mc_dec(cmd.params[1], 0, 16);
|
||||
attr->version.minor = (u16)mc_dec(cmd.params[1], 16, 16);
|
||||
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;
|
||||
}
|
||||
EXPORT_SYMBOL(dpbp_get_attributes);
|
||||
@ -597,19 +631,19 @@ int dpbp_set_notifications(struct fsl_mc_io *mc_io,
|
||||
struct dpbp_notification_cfg *cfg)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_cmd_set_notifications *cmd_params;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_NOTIFICATIONS,
|
||||
cmd_flags,
|
||||
token);
|
||||
|
||||
cmd.params[0] |= mc_enc(0, 32, cfg->depletion_entry);
|
||||
cmd.params[0] |= mc_enc(32, 32, cfg->depletion_exit);
|
||||
cmd.params[1] |= mc_enc(0, 32, cfg->surplus_entry);
|
||||
cmd.params[1] |= mc_enc(32, 32, cfg->surplus_exit);
|
||||
cmd.params[2] |= mc_enc(0, 16, cfg->options);
|
||||
cmd.params[3] |= mc_enc(0, 64, cfg->message_ctx);
|
||||
cmd.params[4] |= mc_enc(0, 64, cfg->message_iova);
|
||||
cmd_flags, token);
|
||||
cmd_params = (struct dpbp_cmd_set_notifications *)cmd.params;
|
||||
cmd_params->depletion_entry = cpu_to_le32(cfg->depletion_entry);
|
||||
cmd_params->depletion_exit = cpu_to_le32(cfg->depletion_exit);
|
||||
cmd_params->surplus_entry = cpu_to_le32(cfg->surplus_entry);
|
||||
cmd_params->surplus_exit = cpu_to_le32(cfg->surplus_exit);
|
||||
cmd_params->options = cpu_to_le16(cfg->options);
|
||||
cmd_params->message_ctx = cpu_to_le64(cfg->message_ctx);
|
||||
cmd_params->message_iova = cpu_to_le64(cfg->message_iova);
|
||||
|
||||
/* send command to mc*/
|
||||
return mc_send_command(mc_io, &cmd);
|
||||
@ -630,6 +664,7 @@ int dpbp_get_notifications(struct fsl_mc_io *mc_io,
|
||||
struct dpbp_notification_cfg *cfg)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpbp_rsp_get_notifications *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
@ -643,13 +678,14 @@ int dpbp_get_notifications(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
cfg->depletion_entry = (u32)mc_dec(cmd.params[0], 0, 32);
|
||||
cfg->depletion_exit = (u32)mc_dec(cmd.params[0], 32, 32);
|
||||
cfg->surplus_entry = (u32)mc_dec(cmd.params[1], 0, 32);
|
||||
cfg->surplus_exit = (u32)mc_dec(cmd.params[1], 32, 32);
|
||||
cfg->options = (u16)mc_dec(cmd.params[2], 0, 16);
|
||||
cfg->message_ctx = (u64)mc_dec(cmd.params[3], 0, 64);
|
||||
cfg->message_iova = (u64)mc_dec(cmd.params[4], 0, 64);
|
||||
rsp_params = (struct dpbp_rsp_get_notifications *)cmd.params;
|
||||
cfg->depletion_entry = le32_to_cpu(rsp_params->depletion_entry);
|
||||
cfg->depletion_exit = le32_to_cpu(rsp_params->depletion_exit);
|
||||
cfg->surplus_entry = le32_to_cpu(rsp_params->surplus_entry);
|
||||
cfg->surplus_exit = le32_to_cpu(rsp_params->surplus_exit);
|
||||
cfg->options = le16_to_cpu(rsp_params->options);
|
||||
cfg->message_ctx = le64_to_cpu(rsp_params->message_ctx);
|
||||
cfg->message_iova = le64_to_cpu(rsp_params->message_iova);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright 2013-2015 Freescale Semiconductor Inc.
|
||||
/* Copyright 2013-2016 Freescale Semiconductor Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -53,4 +53,88 @@
|
||||
#define DPMCP_CMDID_GET_IRQ_MASK 0x015
|
||||
#define DPMCP_CMDID_GET_IRQ_STATUS 0x016
|
||||
|
||||
struct dpmcp_cmd_open {
|
||||
__le32 dpmcp_id;
|
||||
};
|
||||
|
||||
struct dpmcp_cmd_create {
|
||||
__le32 portal_id;
|
||||
};
|
||||
|
||||
struct dpmcp_cmd_set_irq {
|
||||
/* cmd word 0 */
|
||||
u8 irq_index;
|
||||
u8 pad[3];
|
||||
__le32 irq_val;
|
||||
/* cmd word 1 */
|
||||
__le64 irq_addr;
|
||||
/* cmd word 2 */
|
||||
__le32 irq_num;
|
||||
};
|
||||
|
||||
struct dpmcp_cmd_get_irq {
|
||||
__le32 pad;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpmcp_rsp_get_irq {
|
||||
/* cmd word 0 */
|
||||
__le32 irq_val;
|
||||
__le32 pad;
|
||||
/* cmd word 1 */
|
||||
__le64 irq_paddr;
|
||||
/* cmd word 2 */
|
||||
__le32 irq_num;
|
||||
__le32 type;
|
||||
};
|
||||
|
||||
#define DPMCP_ENABLE 0x1
|
||||
|
||||
struct dpmcp_cmd_set_irq_enable {
|
||||
u8 enable;
|
||||
u8 pad[3];
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpmcp_cmd_get_irq_enable {
|
||||
__le32 pad;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpmcp_rsp_get_irq_enable {
|
||||
u8 enabled;
|
||||
};
|
||||
|
||||
struct dpmcp_cmd_set_irq_mask {
|
||||
__le32 mask;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpmcp_cmd_get_irq_mask {
|
||||
__le32 pad;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpmcp_rsp_get_irq_mask {
|
||||
__le32 mask;
|
||||
};
|
||||
|
||||
struct dpmcp_cmd_get_irq_status {
|
||||
__le32 status;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpmcp_rsp_get_irq_status {
|
||||
__le32 status;
|
||||
};
|
||||
|
||||
struct dpmcp_rsp_get_attributes {
|
||||
/* response word 0 */
|
||||
__le32 pad;
|
||||
__le32 id;
|
||||
/* response word 1 */
|
||||
__le16 version_major;
|
||||
__le16 version_minor;
|
||||
};
|
||||
|
||||
#endif /* _FSL_DPMCP_CMD_H */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright 2013-2015 Freescale Semiconductor Inc.
|
||||
/* Copyright 2013-2016 Freescale Semiconductor Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -57,12 +57,14 @@ int dpmcp_open(struct fsl_mc_io *mc_io,
|
||||
u16 *token)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmcp_cmd_open *cmd_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_OPEN,
|
||||
cmd_flags, 0);
|
||||
cmd.params[0] |= mc_enc(0, 32, dpmcp_id);
|
||||
cmd_params = (struct dpmcp_cmd_open *)cmd.params;
|
||||
cmd_params->dpmcp_id = cpu_to_le32(dpmcp_id);
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -70,7 +72,7 @@ int dpmcp_open(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*token = MC_CMD_HDR_READ_TOKEN(cmd.header);
|
||||
*token = mc_cmd_hdr_read_token(&cmd);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -127,12 +129,15 @@ int dpmcp_create(struct fsl_mc_io *mc_io,
|
||||
u16 *token)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmcp_cmd_create *cmd_params;
|
||||
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CREATE,
|
||||
cmd_flags, 0);
|
||||
cmd.params[0] |= mc_enc(0, 32, cfg->portal_id);
|
||||
cmd_params = (struct dpmcp_cmd_create *)cmd.params;
|
||||
cmd_params->portal_id = cpu_to_le32(cfg->portal_id);
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -140,7 +145,7 @@ int dpmcp_create(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*token = MC_CMD_HDR_READ_TOKEN(cmd.header);
|
||||
*token = mc_cmd_hdr_read_token(&cmd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -206,14 +211,16 @@ int dpmcp_set_irq(struct fsl_mc_io *mc_io,
|
||||
struct dpmcp_irq_cfg *irq_cfg)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmcp_cmd_set_irq *cmd_params;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(0, 8, irq_index);
|
||||
cmd.params[0] |= mc_enc(32, 32, irq_cfg->val);
|
||||
cmd.params[1] |= mc_enc(0, 64, irq_cfg->paddr);
|
||||
cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num);
|
||||
cmd_params = (struct dpmcp_cmd_set_irq *)cmd.params;
|
||||
cmd_params->irq_index = irq_index;
|
||||
cmd_params->irq_val = cpu_to_le32(irq_cfg->val);
|
||||
cmd_params->irq_addr = cpu_to_le64(irq_cfg->paddr);
|
||||
cmd_params->irq_num = cpu_to_le32(irq_cfg->irq_num);
|
||||
|
||||
/* send command to mc*/
|
||||
return mc_send_command(mc_io, &cmd);
|
||||
@ -239,12 +246,15 @@ int dpmcp_get_irq(struct fsl_mc_io *mc_io,
|
||||
struct dpmcp_irq_cfg *irq_cfg)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmcp_cmd_get_irq *cmd_params;
|
||||
struct dpmcp_rsp_get_irq *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpmcp_cmd_get_irq *)cmd.params;
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -252,10 +262,11 @@ int dpmcp_get_irq(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32);
|
||||
irq_cfg->paddr = (u64)mc_dec(cmd.params[1], 0, 64);
|
||||
irq_cfg->irq_num = (int)mc_dec(cmd.params[2], 0, 32);
|
||||
*type = (int)mc_dec(cmd.params[2], 32, 32);
|
||||
rsp_params = (struct dpmcp_rsp_get_irq *)cmd.params;
|
||||
irq_cfg->val = le32_to_cpu(rsp_params->irq_val);
|
||||
irq_cfg->paddr = le64_to_cpu(rsp_params->irq_paddr);
|
||||
irq_cfg->irq_num = le32_to_cpu(rsp_params->irq_num);
|
||||
*type = le32_to_cpu(rsp_params->type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -281,12 +292,14 @@ int dpmcp_set_irq_enable(struct fsl_mc_io *mc_io,
|
||||
u8 en)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmcp_cmd_set_irq_enable *cmd_params;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ_ENABLE,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(0, 8, en);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpmcp_cmd_set_irq_enable *)cmd.params;
|
||||
cmd_params->enable = en & DPMCP_ENABLE;
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
return mc_send_command(mc_io, &cmd);
|
||||
@ -309,12 +322,15 @@ int dpmcp_get_irq_enable(struct fsl_mc_io *mc_io,
|
||||
u8 *en)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmcp_cmd_get_irq_enable *cmd_params;
|
||||
struct dpmcp_rsp_get_irq_enable *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_ENABLE,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpmcp_cmd_get_irq_enable *)cmd.params;
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -322,7 +338,8 @@ int dpmcp_get_irq_enable(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*en = (u8)mc_dec(cmd.params[0], 0, 8);
|
||||
rsp_params = (struct dpmcp_rsp_get_irq_enable *)cmd.params;
|
||||
*en = rsp_params->enabled & DPMCP_ENABLE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -349,12 +366,15 @@ int dpmcp_set_irq_mask(struct fsl_mc_io *mc_io,
|
||||
u32 mask)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmcp_cmd_set_irq_mask *cmd_params;
|
||||
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ_MASK,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(0, 32, mask);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpmcp_cmd_set_irq_mask *)cmd.params;
|
||||
cmd_params->mask = cpu_to_le32(mask);
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
return mc_send_command(mc_io, &cmd);
|
||||
@ -380,12 +400,16 @@ int dpmcp_get_irq_mask(struct fsl_mc_io *mc_io,
|
||||
u32 *mask)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmcp_cmd_get_irq_mask *cmd_params;
|
||||
struct dpmcp_rsp_get_irq_mask *rsp_params;
|
||||
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_MASK,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpmcp_cmd_get_irq_mask *)cmd.params;
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -393,7 +417,9 @@ int dpmcp_get_irq_mask(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*mask = (u32)mc_dec(cmd.params[0], 0, 32);
|
||||
rsp_params = (struct dpmcp_rsp_get_irq_mask *)cmd.params;
|
||||
*mask = le32_to_cpu(rsp_params->mask);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -417,12 +443,16 @@ int dpmcp_get_irq_status(struct fsl_mc_io *mc_io,
|
||||
u32 *status)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmcp_cmd_get_irq_status *cmd_params;
|
||||
struct dpmcp_rsp_get_irq_status *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_STATUS,
|
||||
cmd_flags, token);
|
||||
cmd.params[0] |= mc_enc(32, 8, irq_index);
|
||||
cmd_params = (struct dpmcp_cmd_get_irq_status *)cmd.params;
|
||||
cmd_params->status = cpu_to_le32(*status);
|
||||
cmd_params->irq_index = irq_index;
|
||||
|
||||
/* send command to mc*/
|
||||
err = mc_send_command(mc_io, &cmd);
|
||||
@ -430,7 +460,9 @@ int dpmcp_get_irq_status(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*status = (u32)mc_dec(cmd.params[0], 0, 32);
|
||||
rsp_params = (struct dpmcp_rsp_get_irq_status *)cmd.params;
|
||||
*status = le32_to_cpu(rsp_params->status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -450,6 +482,7 @@ int dpmcp_get_attributes(struct fsl_mc_io *mc_io,
|
||||
struct dpmcp_attr *attr)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmcp_rsp_get_attributes *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
@ -462,8 +495,10 @@ int dpmcp_get_attributes(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
attr->id = (int)mc_dec(cmd.params[0], 32, 32);
|
||||
attr->version.major = (u16)mc_dec(cmd.params[1], 0, 16);
|
||||
attr->version.minor = (u16)mc_dec(cmd.params[1], 16, 16);
|
||||
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;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright 2013-2014 Freescale Semiconductor Inc.
|
||||
/* Copyright 2013-2016 Freescale Semiconductor Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -44,4 +44,14 @@
|
||||
#define DPMNG_CMDID_GET_CONT_ID 0x830
|
||||
#define DPMNG_CMDID_GET_VERSION 0x831
|
||||
|
||||
struct dpmng_rsp_get_container_id {
|
||||
__le32 container_id;
|
||||
};
|
||||
|
||||
struct dpmng_rsp_get_version {
|
||||
__le32 revision;
|
||||
__le32 version_major;
|
||||
__le32 version_minor;
|
||||
};
|
||||
|
||||
#endif /* __FSL_DPMNG_CMD_H */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright 2013-2014 Freescale Semiconductor Inc.
|
||||
/* Copyright 2013-2016 Freescale Semiconductor Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -48,6 +48,7 @@ int mc_get_version(struct fsl_mc_io *mc_io,
|
||||
struct mc_version *mc_ver_info)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmng_rsp_get_version *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
@ -61,9 +62,10 @@ int mc_get_version(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
mc_ver_info->revision = mc_dec(cmd.params[0], 0, 32);
|
||||
mc_ver_info->major = mc_dec(cmd.params[0], 32, 32);
|
||||
mc_ver_info->minor = mc_dec(cmd.params[1], 0, 32);
|
||||
rsp_params = (struct dpmng_rsp_get_version *)cmd.params;
|
||||
mc_ver_info->revision = le32_to_cpu(rsp_params->revision);
|
||||
mc_ver_info->major = le32_to_cpu(rsp_params->version_major);
|
||||
mc_ver_info->minor = le32_to_cpu(rsp_params->version_minor);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -82,6 +84,7 @@ int dpmng_get_container_id(struct fsl_mc_io *mc_io,
|
||||
int *container_id)
|
||||
{
|
||||
struct mc_command cmd = { 0 };
|
||||
struct dpmng_rsp_get_container_id *rsp_params;
|
||||
int err;
|
||||
|
||||
/* prepare command */
|
||||
@ -95,7 +98,8 @@ int dpmng_get_container_id(struct fsl_mc_io *mc_io,
|
||||
return err;
|
||||
|
||||
/* retrieve response parameters */
|
||||
*container_id = mc_dec(cmd.params[0], 0, 32);
|
||||
rsp_params = (struct dpmng_rsp_get_container_id *)cmd.params;
|
||||
*container_id = le32_to_cpu(rsp_params->container_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright 2013-2014 Freescale Semiconductor Inc.
|
||||
/* Copyright 2013-2016 Freescale Semiconductor Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -84,4 +84,381 @@
|
||||
|
||||
#define DPRC_CMDID_GET_CONNECTION 0x16C
|
||||
|
||||
struct dprc_cmd_open {
|
||||
__le32 container_id;
|
||||
};
|
||||
|
||||
struct dprc_cmd_create_container {
|
||||
/* cmd word 0 */
|
||||
__le32 options;
|
||||
__le16 icid;
|
||||
__le16 pad0;
|
||||
/* cmd word 1 */
|
||||
__le32 pad1;
|
||||
__le32 portal_id;
|
||||
/* cmd words 2-3 */
|
||||
u8 label[16];
|
||||
};
|
||||
|
||||
struct dprc_rsp_create_container {
|
||||
/* response word 0 */
|
||||
__le64 pad0;
|
||||
/* response word 1 */
|
||||
__le32 child_container_id;
|
||||
__le32 pad1;
|
||||
/* response word 2 */
|
||||
__le64 child_portal_addr;
|
||||
};
|
||||
|
||||
struct dprc_cmd_destroy_container {
|
||||
__le32 child_container_id;
|
||||
};
|
||||
|
||||
struct dprc_cmd_reset_container {
|
||||
__le32 child_container_id;
|
||||
};
|
||||
|
||||
struct dprc_cmd_set_irq {
|
||||
/* cmd word 0 */
|
||||
__le32 irq_val;
|
||||
u8 irq_index;
|
||||
u8 pad[3];
|
||||
/* cmd word 1 */
|
||||
__le64 irq_addr;
|
||||
/* cmd word 2 */
|
||||
__le32 irq_num;
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_irq {
|
||||
__le32 pad;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_irq {
|
||||
/* response word 0 */
|
||||
__le32 irq_val;
|
||||
__le32 pad;
|
||||
/* response word 1 */
|
||||
__le64 irq_addr;
|
||||
/* response word 2 */
|
||||
__le32 irq_num;
|
||||
__le32 type;
|
||||
};
|
||||
|
||||
#define DPRC_ENABLE 0x1
|
||||
|
||||
struct dprc_cmd_set_irq_enable {
|
||||
u8 enable;
|
||||
u8 pad[3];
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_irq_enable {
|
||||
__le32 pad;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_irq_enable {
|
||||
u8 enabled;
|
||||
};
|
||||
|
||||
struct dprc_cmd_set_irq_mask {
|
||||
__le32 mask;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_irq_mask {
|
||||
__le32 pad;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_irq_mask {
|
||||
__le32 mask;
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_irq_status {
|
||||
__le32 status;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_irq_status {
|
||||
__le32 status;
|
||||
};
|
||||
|
||||
struct dprc_cmd_clear_irq_status {
|
||||
__le32 status;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_attributes {
|
||||
/* response word 0 */
|
||||
__le32 container_id;
|
||||
__le16 icid;
|
||||
__le16 pad;
|
||||
/* response word 1 */
|
||||
__le32 options;
|
||||
__le32 portal_id;
|
||||
/* response word 2 */
|
||||
__le16 version_major;
|
||||
__le16 version_minor;
|
||||
};
|
||||
|
||||
struct dprc_cmd_set_res_quota {
|
||||
/* cmd word 0 */
|
||||
__le32 child_container_id;
|
||||
__le16 quota;
|
||||
__le16 pad;
|
||||
/* cmd words 1-2 */
|
||||
u8 type[16];
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_res_quota {
|
||||
/* cmd word 0 */
|
||||
__le32 child_container_id;
|
||||
__le32 pad;
|
||||
/* cmd word 1-2 */
|
||||
u8 type[16];
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_res_quota {
|
||||
__le32 pad;
|
||||
__le16 quota;
|
||||
};
|
||||
|
||||
struct dprc_cmd_assign {
|
||||
/* cmd word 0 */
|
||||
__le32 container_id;
|
||||
__le32 options;
|
||||
/* cmd word 1 */
|
||||
__le32 num;
|
||||
__le32 id_base_align;
|
||||
/* cmd word 2-3 */
|
||||
u8 type[16];
|
||||
};
|
||||
|
||||
struct dprc_cmd_unassign {
|
||||
/* cmd word 0 */
|
||||
__le32 child_container_id;
|
||||
__le32 options;
|
||||
/* cmd word 1 */
|
||||
__le32 num;
|
||||
__le32 id_base_align;
|
||||
/* cmd word 2-3 */
|
||||
u8 type[16];
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_pool_count {
|
||||
__le32 pool_count;
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_pool {
|
||||
__le32 pool_index;
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_pool {
|
||||
/* response word 0 */
|
||||
__le64 pad;
|
||||
/* response word 1-2 */
|
||||
u8 type[16];
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_obj_count {
|
||||
__le32 pad;
|
||||
__le32 obj_count;
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_obj {
|
||||
__le32 obj_index;
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_obj {
|
||||
/* response word 0 */
|
||||
__le32 pad0;
|
||||
__le32 id;
|
||||
/* response word 1 */
|
||||
__le16 vendor;
|
||||
u8 irq_count;
|
||||
u8 region_count;
|
||||
__le32 state;
|
||||
/* response word 2 */
|
||||
__le16 version_major;
|
||||
__le16 version_minor;
|
||||
__le16 flags;
|
||||
__le16 pad1;
|
||||
/* response word 3-4 */
|
||||
u8 type[16];
|
||||
/* response word 5-6 */
|
||||
u8 label[16];
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_obj_desc {
|
||||
/* cmd word 0 */
|
||||
__le32 obj_id;
|
||||
__le32 pad;
|
||||
/* cmd word 1-2 */
|
||||
u8 type[16];
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_obj_desc {
|
||||
/* response word 0 */
|
||||
__le32 pad0;
|
||||
__le32 id;
|
||||
/* response word 1 */
|
||||
__le16 vendor;
|
||||
u8 irq_count;
|
||||
u8 region_count;
|
||||
__le32 state;
|
||||
/* response word 2 */
|
||||
__le16 version_major;
|
||||
__le16 version_minor;
|
||||
__le16 flags;
|
||||
__le16 pad1;
|
||||
/* response word 3-4 */
|
||||
u8 type[16];
|
||||
/* response word 5-6 */
|
||||
u8 label[16];
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_res_count {
|
||||
/* cmd word 0 */
|
||||
__le64 pad;
|
||||
/* cmd word 1-2 */
|
||||
u8 type[16];
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_res_count {
|
||||
__le32 res_count;
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_res_ids {
|
||||
/* cmd word 0 */
|
||||
u8 pad0[5];
|
||||
u8 iter_status;
|
||||
__le16 pad1;
|
||||
/* cmd word 1 */
|
||||
__le32 base_id;
|
||||
__le32 last_id;
|
||||
/* cmd word 2-3 */
|
||||
u8 type[16];
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_res_ids {
|
||||
/* response word 0 */
|
||||
u8 pad0[5];
|
||||
u8 iter_status;
|
||||
__le16 pad1;
|
||||
/* response word 1 */
|
||||
__le32 base_id;
|
||||
__le32 last_id;
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_obj_region {
|
||||
/* cmd word 0 */
|
||||
__le32 obj_id;
|
||||
__le16 pad0;
|
||||
u8 region_index;
|
||||
u8 pad1;
|
||||
/* cmd word 1-2 */
|
||||
__le64 pad2[2];
|
||||
/* cmd word 3-4 */
|
||||
u8 obj_type[16];
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_obj_region {
|
||||
/* response word 0 */
|
||||
__le64 pad;
|
||||
/* response word 1 */
|
||||
__le64 base_addr;
|
||||
/* response word 2 */
|
||||
__le32 size;
|
||||
};
|
||||
|
||||
struct dprc_cmd_set_obj_label {
|
||||
/* cmd word 0 */
|
||||
__le32 obj_id;
|
||||
__le32 pad;
|
||||
/* cmd word 1-2 */
|
||||
u8 label[16];
|
||||
/* cmd word 3-4 */
|
||||
u8 obj_type[16];
|
||||
};
|
||||
|
||||
struct dprc_cmd_set_obj_irq {
|
||||
/* cmd word 0 */
|
||||
__le32 irq_val;
|
||||
u8 irq_index;
|
||||
u8 pad[3];
|
||||
/* cmd word 1 */
|
||||
__le64 irq_addr;
|
||||
/* cmd word 2 */
|
||||
__le32 irq_num;
|
||||
__le32 obj_id;
|
||||
/* cmd word 3-4 */
|
||||
u8 obj_type[16];
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_obj_irq {
|
||||
/* cmd word 0 */
|
||||
__le32 obj_id;
|
||||
u8 irq_index;
|
||||
u8 pad[3];
|
||||
/* cmd word 1-2 */
|
||||
u8 obj_type[16];
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_obj_irq {
|
||||
/* response word 0 */
|
||||
__le32 irq_val;
|
||||
__le32 pad;
|
||||
/* response word 1 */
|
||||
__le64 irq_addr;
|
||||
/* response word 2 */
|
||||
__le32 irq_num;
|
||||
__le32 type;
|
||||
};
|
||||
|
||||
struct dprc_cmd_connect {
|
||||
/* cmd word 0 */
|
||||
__le32 ep1_id;
|
||||
__le32 ep1_interface_id;
|
||||
/* cmd word 1 */
|
||||
__le32 ep2_id;
|
||||
__le32 ep2_interface_id;
|
||||
/* cmd word 2-3 */
|
||||
u8 ep1_type[16];
|
||||
/* cmd word 4 */
|
||||
__le32 max_rate;
|
||||
__le32 committed_rate;
|
||||
/* cmd word 5-6 */
|
||||
u8 ep2_type[16];
|
||||
};
|
||||
|
||||
struct dprc_cmd_disconnect {
|
||||
/* cmd word 0 */
|
||||
__le32 id;
|
||||
__le32 interface_id;
|
||||
/* cmd word 1-2 */
|
||||
u8 type[16];
|
||||
};
|
||||
|
||||
struct dprc_cmd_get_connection {
|
||||
/* cmd word 0 */
|
||||
__le32 ep1_id;
|
||||
__le32 ep1_interface_id;
|
||||
/* cmd word 1-2 */
|
||||
u8 ep1_type[16];
|
||||
};
|
||||
|
||||
struct dprc_rsp_get_connection {
|
||||
/* response word 0-2 */
|
||||
__le64 pad[3];
|
||||
/* response word 3 */
|
||||
__le32 ep2_id;
|
||||
__le32 ep2_interface_id;
|
||||
/* response word 4-5 */
|
||||
u8 ep2_type[16];
|
||||
/* response word 6 */
|
||||
__le32 state;
|
||||
};
|
||||
|
||||
#endif /* _FSL_DPRC_CMD_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -53,8 +53,20 @@
|
||||
#define MC_CMD_COMPLETION_POLLING_MIN_SLEEP_USECS 10
|
||||
#define MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS 500
|
||||
|
||||
#define MC_CMD_HDR_READ_CMDID(_hdr) \
|
||||
((u16)mc_dec((_hdr), MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S))
|
||||
static enum mc_cmd_status mc_cmd_hdr_read_status(struct mc_command *cmd)
|
||||
{
|
||||
struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;
|
||||
|
||||
return (enum mc_cmd_status)hdr->status;
|
||||
}
|
||||
|
||||
static u16 mc_cmd_hdr_read_cmdid(struct mc_command *cmd)
|
||||
{
|
||||
struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;
|
||||
u16 cmd_id = le16_to_cpu(hdr->cmd_id);
|
||||
|
||||
return (cmd_id & MC_CMD_HDR_CMDID_MASK) >> MC_CMD_HDR_CMDID_SHIFT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an MC I/O object
|
||||
@ -261,10 +273,11 @@ static inline void mc_write_command(struct mc_command __iomem *portal,
|
||||
|
||||
/* copy command parameters into the portal */
|
||||
for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
|
||||
writeq(cmd->params[i], &portal->params[i]);
|
||||
__raw_writeq(cmd->params[i], &portal->params[i]);
|
||||
__iowmb();
|
||||
|
||||
/* submit the command by writing the header */
|
||||
writeq(cmd->header, &portal->header);
|
||||
__raw_writeq(cmd->header, &portal->header);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,14 +297,17 @@ static inline enum mc_cmd_status mc_read_response(struct mc_command __iomem *
|
||||
enum mc_cmd_status status;
|
||||
|
||||
/* Copy command response header from MC portal: */
|
||||
resp->header = readq(&portal->header);
|
||||
status = MC_CMD_HDR_READ_STATUS(resp->header);
|
||||
__iormb();
|
||||
resp->header = __raw_readq(&portal->header);
|
||||
__iormb();
|
||||
status = mc_cmd_hdr_read_status(resp);
|
||||
if (status != MC_CMD_STATUS_OK)
|
||||
return status;
|
||||
|
||||
/* Copy command response data from MC portal: */
|
||||
for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
|
||||
resp->params[i] = readq(&portal->params[i]);
|
||||
resp->params[i] = __raw_readq(&portal->params[i]);
|
||||
__iormb();
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -331,10 +347,8 @@ static int mc_polling_wait_preemptible(struct fsl_mc_io *mc_io,
|
||||
dev_dbg(mc_io->dev,
|
||||
"MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n",
|
||||
mc_io->portal_phys_addr,
|
||||
(unsigned int)
|
||||
MC_CMD_HDR_READ_TOKEN(cmd->header),
|
||||
(unsigned int)
|
||||
MC_CMD_HDR_READ_CMDID(cmd->header));
|
||||
(unsigned int)mc_cmd_hdr_read_token(cmd),
|
||||
(unsigned int)mc_cmd_hdr_read_cmdid(cmd));
|
||||
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
@ -373,10 +387,8 @@ static int mc_polling_wait_atomic(struct fsl_mc_io *mc_io,
|
||||
dev_dbg(mc_io->dev,
|
||||
"MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n",
|
||||
mc_io->portal_phys_addr,
|
||||
(unsigned int)
|
||||
MC_CMD_HDR_READ_TOKEN(cmd->header),
|
||||
(unsigned int)
|
||||
MC_CMD_HDR_READ_CMDID(cmd->header));
|
||||
(unsigned int)mc_cmd_hdr_read_token(cmd),
|
||||
(unsigned int)mc_cmd_hdr_read_cmdid(cmd));
|
||||
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
@ -429,8 +441,8 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd)
|
||||
dev_dbg(mc_io->dev,
|
||||
"MC command failed: portal: %#llx, obj handle: %#x, command: %#x, status: %s (%#x)\n",
|
||||
mc_io->portal_phys_addr,
|
||||
(unsigned int)MC_CMD_HDR_READ_TOKEN(cmd->header),
|
||||
(unsigned int)MC_CMD_HDR_READ_CMDID(cmd->header),
|
||||
(unsigned int)mc_cmd_hdr_read_token(cmd),
|
||||
(unsigned int)mc_cmd_hdr_read_cmdid(cmd),
|
||||
mc_status_to_string(status),
|
||||
(unsigned int)status);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright 2013-2014 Freescale Semiconductor Inc.
|
||||
/* Copyright 2013-2016 Freescale Semiconductor Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -59,4 +59,127 @@
|
||||
|
||||
#define DPBP_CMDID_SET_NOTIFICATIONS 0x01b0
|
||||
#define DPBP_CMDID_GET_NOTIFICATIONS 0x01b1
|
||||
|
||||
struct dpbp_cmd_open {
|
||||
__le32 dpbp_id;
|
||||
};
|
||||
|
||||
#define DPBP_ENABLE 0x1
|
||||
|
||||
struct dpbp_rsp_is_enabled {
|
||||
u8 enabled;
|
||||
};
|
||||
|
||||
struct dpbp_cmd_set_irq {
|
||||
/* cmd word 0 */
|
||||
u8 irq_index;
|
||||
u8 pad[3];
|
||||
__le32 irq_val;
|
||||
/* cmd word 1 */
|
||||
__le64 irq_addr;
|
||||
/* cmd word 2 */
|
||||
__le32 irq_num;
|
||||
};
|
||||
|
||||
struct dpbp_cmd_get_irq {
|
||||
__le32 pad;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpbp_rsp_get_irq {
|
||||
/* response word 0 */
|
||||
__le32 irq_val;
|
||||
__le32 pad;
|
||||
/* response word 1 */
|
||||
__le64 irq_addr;
|
||||
/* response word 2 */
|
||||
__le32 irq_num;
|
||||
__le32 type;
|
||||
};
|
||||
|
||||
struct dpbp_cmd_set_irq_enable {
|
||||
u8 enable;
|
||||
u8 pad[3];
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpbp_cmd_get_irq_enable {
|
||||
__le32 pad;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpbp_rsp_get_irq_enable {
|
||||
u8 enabled;
|
||||
};
|
||||
|
||||
struct dpbp_cmd_set_irq_mask {
|
||||
__le32 mask;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpbp_cmd_get_irq_mask {
|
||||
__le32 pad;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpbp_rsp_get_irq_mask {
|
||||
__le32 mask;
|
||||
};
|
||||
|
||||
struct dpbp_cmd_get_irq_status {
|
||||
__le32 status;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpbp_rsp_get_irq_status {
|
||||
__le32 status;
|
||||
};
|
||||
|
||||
struct dpbp_cmd_clear_irq_status {
|
||||
__le32 status;
|
||||
u8 irq_index;
|
||||
};
|
||||
|
||||
struct dpbp_rsp_get_attributes {
|
||||
/* response word 0 */
|
||||
__le16 pad;
|
||||
__le16 bpid;
|
||||
__le32 id;
|
||||
/* response word 1 */
|
||||
__le16 version_major;
|
||||
__le16 version_minor;
|
||||
};
|
||||
|
||||
struct dpbp_cmd_set_notifications {
|
||||
/* cmd word 0 */
|
||||
__le32 depletion_entry;
|
||||
__le32 depletion_exit;
|
||||
/* cmd word 1 */
|
||||
__le32 surplus_entry;
|
||||
__le32 surplus_exit;
|
||||
/* cmd word 2 */
|
||||
__le16 options;
|
||||
__le16 pad[3];
|
||||
/* cmd word 3 */
|
||||
__le64 message_ctx;
|
||||
/* cmd word 4 */
|
||||
__le64 message_iova;
|
||||
};
|
||||
|
||||
struct dpbp_rsp_get_notifications {
|
||||
/* response word 0 */
|
||||
__le32 depletion_entry;
|
||||
__le32 depletion_exit;
|
||||
/* response word 1 */
|
||||
__le32 surplus_entry;
|
||||
__le32 surplus_exit;
|
||||
/* response word 2 */
|
||||
__le16 options;
|
||||
__le16 pad[3];
|
||||
/* response word 3 */
|
||||
__le64 message_ctx;
|
||||
/* response word 4 */
|
||||
__le64 message_iova;
|
||||
};
|
||||
|
||||
#endif /* _FSL_DPBP_CMD_H */
|
||||
|
@ -34,18 +34,14 @@
|
||||
|
||||
#define MC_CMD_NUM_OF_PARAMS 7
|
||||
|
||||
#define MAKE_UMASK64(_width) \
|
||||
((u64)((_width) < 64 ? ((u64)1 << (_width)) - 1 : -1))
|
||||
|
||||
static inline u64 mc_enc(int lsoffset, int width, u64 val)
|
||||
{
|
||||
return (u64)(((u64)val & MAKE_UMASK64(width)) << lsoffset);
|
||||
}
|
||||
|
||||
static inline u64 mc_dec(u64 val, int lsoffset, int width)
|
||||
{
|
||||
return (u64)((val >> lsoffset) & MAKE_UMASK64(width));
|
||||
}
|
||||
struct mc_cmd_header {
|
||||
u8 src_id;
|
||||
u8 flags_hw;
|
||||
u8 status;
|
||||
u8 flags_sw;
|
||||
__le16 token;
|
||||
__le16 cmd_id;
|
||||
};
|
||||
|
||||
struct mc_command {
|
||||
u64 header;
|
||||
@ -72,60 +68,41 @@ enum mc_cmd_status {
|
||||
*/
|
||||
|
||||
/* High priority flag */
|
||||
#define MC_CMD_FLAG_PRI 0x00008000
|
||||
#define MC_CMD_FLAG_PRI 0x80
|
||||
/* Command completion flag */
|
||||
#define MC_CMD_FLAG_INTR_DIS 0x01000000
|
||||
#define MC_CMD_FLAG_INTR_DIS 0x01
|
||||
|
||||
/*
|
||||
* TODO Remove following two defines after completion of flib 8.0.0
|
||||
* integration
|
||||
*/
|
||||
#define MC_CMD_PRI_LOW 0 /*!< Low Priority command indication */
|
||||
#define MC_CMD_PRI_HIGH 1 /*!< High Priority command indication */
|
||||
|
||||
#define MC_CMD_HDR_CMDID_O 52 /* Command ID field offset */
|
||||
#define MC_CMD_HDR_CMDID_S 12 /* Command ID field size */
|
||||
#define MC_CMD_HDR_TOKEN_O 38 /* Token field offset */
|
||||
#define MC_CMD_HDR_TOKEN_S 10 /* Token field size */
|
||||
#define MC_CMD_HDR_STATUS_O 16 /* Status field offset */
|
||||
#define MC_CMD_HDR_STATUS_S 8 /* Status field size*/
|
||||
#define MC_CMD_HDR_FLAGS_O 0 /* Flags field offset */
|
||||
#define MC_CMD_HDR_FLAGS_S 32 /* Flags field size*/
|
||||
#define MC_CMD_HDR_FLAGS_MASK 0xFF00FF00 /* Command flags mask */
|
||||
|
||||
#define MC_CMD_HDR_READ_STATUS(_hdr) \
|
||||
((enum mc_cmd_status)mc_dec((_hdr), \
|
||||
MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S))
|
||||
|
||||
#define MC_CMD_HDR_READ_TOKEN(_hdr) \
|
||||
((u16)mc_dec((_hdr), MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S))
|
||||
|
||||
#define MC_CMD_HDR_READ_FLAGS(_hdr) \
|
||||
((u32)mc_dec((_hdr), MC_CMD_HDR_FLAGS_O, MC_CMD_HDR_FLAGS_S))
|
||||
|
||||
#define MC_EXT_OP(_ext, _param, _offset, _width, _type, _arg) \
|
||||
((_ext)[_param] |= mc_enc((_offset), (_width), _arg))
|
||||
|
||||
#define MC_CMD_OP(_cmd, _param, _offset, _width, _type, _arg) \
|
||||
((_cmd).params[_param] |= mc_enc((_offset), (_width), _arg))
|
||||
|
||||
#define MC_RSP_OP(_cmd, _param, _offset, _width, _type, _arg) \
|
||||
(_arg = (_type)mc_dec(_cmd.params[_param], (_offset), (_width)))
|
||||
#define MC_CMD_HDR_CMDID_MASK 0xFFF0
|
||||
#define MC_CMD_HDR_CMDID_SHIFT 4
|
||||
#define MC_CMD_HDR_TOKEN_MASK 0xFFC0
|
||||
#define MC_CMD_HDR_TOKEN_SHIFT 6
|
||||
|
||||
static inline u64 mc_encode_cmd_header(u16 cmd_id,
|
||||
u32 cmd_flags,
|
||||
u16 token)
|
||||
{
|
||||
u64 hdr;
|
||||
u64 header = 0;
|
||||
struct mc_cmd_header *hdr = (struct mc_cmd_header *)&header;
|
||||
|
||||
hdr = mc_enc(MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S, cmd_id);
|
||||
hdr |= mc_enc(MC_CMD_HDR_FLAGS_O, MC_CMD_HDR_FLAGS_S,
|
||||
(cmd_flags & MC_CMD_HDR_FLAGS_MASK));
|
||||
hdr |= mc_enc(MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S, token);
|
||||
hdr |= mc_enc(MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S,
|
||||
MC_CMD_STATUS_READY);
|
||||
hdr->cmd_id = cpu_to_le16((cmd_id << MC_CMD_HDR_CMDID_SHIFT) &
|
||||
MC_CMD_HDR_CMDID_MASK);
|
||||
hdr->token = cpu_to_le16((token << MC_CMD_HDR_TOKEN_SHIFT) &
|
||||
MC_CMD_HDR_TOKEN_MASK);
|
||||
hdr->status = MC_CMD_STATUS_READY;
|
||||
if (cmd_flags & MC_CMD_FLAG_PRI)
|
||||
hdr->flags_hw = MC_CMD_FLAG_PRI;
|
||||
if (cmd_flags & MC_CMD_FLAG_INTR_DIS)
|
||||
hdr->flags_sw = MC_CMD_FLAG_INTR_DIS;
|
||||
|
||||
return hdr;
|
||||
return header;
|
||||
}
|
||||
|
||||
static inline u16 mc_cmd_hdr_read_token(struct mc_command *cmd)
|
||||
{
|
||||
struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;
|
||||
u16 token = le16_to_cpu(hdr->token);
|
||||
|
||||
return (token & MC_CMD_HDR_TOKEN_MASK) >> MC_CMD_HDR_TOKEN_SHIFT;
|
||||
}
|
||||
|
||||
#endif /* __FSL_MC_CMD_H */
|
||||
|
Loading…
Reference in New Issue
Block a user