Skip to content

Commit d30a41d

Browse files
tudorlgregkh
authored andcommitted
staging: fsl-mc: move mc-cmd.h contents in the public header
mc-cmd.h contains some low level functions used to encode and decode commands to the MC. They are used by the drivers so move them to the public headers and get rid of the mc-cmd.h header. Signed-off-by: Laurentiu Tudor <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fab8ca5 commit d30a41d

File tree

11 files changed

+94
-140
lines changed

11 files changed

+94
-140
lines changed

drivers/staging/fsl-dpaa2/ethernet/dpni.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <linux/kernel.h>
3434
#include <linux/errno.h>
3535
#include "../../fsl-mc/include/mc.h"
36-
#include "../../fsl-mc/include/mc-cmd.h"
3736
#include "dpni.h"
3837
#include "dpni-cmd.h"
3938

drivers/staging/fsl-mc/bus/dpbp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
*/
3232
#include <linux/kernel.h>
3333
#include "../include/mc.h"
34-
#include "../include/mc-cmd.h"
3534
#include "../include/dpbp.h"
3635

3736
#include "dpbp-cmd.h"

drivers/staging/fsl-mc/bus/dpcon.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
*/
3232
#include <linux/kernel.h>
3333
#include "../include/mc.h"
34-
#include "../include/mc-cmd.h"
3534
#include "../include/dpcon.h"
3635

3736
#include "dpcon-cmd.h"

drivers/staging/fsl-mc/bus/dpio/dpio.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
*/
3333
#include <linux/kernel.h>
3434
#include "../../include/mc.h"
35-
#include "../../include/mc-cmd.h"
3635

3736
#include "dpio.h"
3837
#include "dpio-cmd.h"

drivers/staging/fsl-mc/bus/dpmcp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
*/
3232
#include <linux/kernel.h>
3333
#include "../include/mc.h"
34-
#include "../include/mc-cmd.h"
3534

3635
#include "dpmcp.h"
3736
#include "dpmcp-cmd.h"

drivers/staging/fsl-mc/bus/dprc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
*/
3232
#include <linux/kernel.h>
3333
#include "../include/mc.h"
34-
#include "../include/mc-cmd.h"
3534
#include "../include/dprc.h"
3635

3736
#include "dprc-cmd.h"

drivers/staging/fsl-mc/bus/fsl-mc-bus.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <linux/bitops.h>
2121
#include <linux/msi.h>
2222
#include <linux/dma-mapping.h>
23-
#include "../include/mc-cmd.h"
2423

2524
#include "fsl-mc-private.h"
2625
#include "dprc-cmd.h"

drivers/staging/fsl-mc/bus/fsl-mc-msi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <linux/irq.h>
1717
#include <linux/irqdomain.h>
1818
#include <linux/msi.h>
19-
#include "../include/mc-cmd.h"
2019
#include "fsl-mc-private.h"
2120

2221
/*

drivers/staging/fsl-mc/bus/mc-sys.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include <linux/ioport.h>
3838
#include <linux/device.h>
3939
#include <linux/io.h>
40-
#include "../include/mc-cmd.h"
4140
#include "../include/mc.h"
4241

4342
#include "dpmcp.h"

drivers/staging/fsl-mc/include/mc-cmd.h

Lines changed: 0 additions & 130 deletions
This file was deleted.

drivers/staging/fsl-mc/include/mc.h

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ struct msi_domain_info;
2323

2424
struct fsl_mc_device;
2525
struct fsl_mc_io;
26-
struct mc_command;
2726

2827
/**
2928
* struct fsl_mc_driver - MC object device driver object
@@ -202,6 +201,100 @@ struct fsl_mc_device {
202201
#define to_fsl_mc_device(_dev) \
203202
container_of(_dev, struct fsl_mc_device, dev)
204203

204+
#define MC_CMD_NUM_OF_PARAMS 7
205+
206+
struct mc_cmd_header {
207+
u8 src_id;
208+
u8 flags_hw;
209+
u8 status;
210+
u8 flags_sw;
211+
__le16 token;
212+
__le16 cmd_id;
213+
};
214+
215+
struct mc_command {
216+
u64 header;
217+
u64 params[MC_CMD_NUM_OF_PARAMS];
218+
};
219+
220+
enum mc_cmd_status {
221+
MC_CMD_STATUS_OK = 0x0, /* Completed successfully */
222+
MC_CMD_STATUS_READY = 0x1, /* Ready to be processed */
223+
MC_CMD_STATUS_AUTH_ERR = 0x3, /* Authentication error */
224+
MC_CMD_STATUS_NO_PRIVILEGE = 0x4, /* No privilege */
225+
MC_CMD_STATUS_DMA_ERR = 0x5, /* DMA or I/O error */
226+
MC_CMD_STATUS_CONFIG_ERR = 0x6, /* Configuration error */
227+
MC_CMD_STATUS_TIMEOUT = 0x7, /* Operation timed out */
228+
MC_CMD_STATUS_NO_RESOURCE = 0x8, /* No resources */
229+
MC_CMD_STATUS_NO_MEMORY = 0x9, /* No memory available */
230+
MC_CMD_STATUS_BUSY = 0xA, /* Device is busy */
231+
MC_CMD_STATUS_UNSUPPORTED_OP = 0xB, /* Unsupported operation */
232+
MC_CMD_STATUS_INVALID_STATE = 0xC /* Invalid state */
233+
};
234+
235+
/*
236+
* MC command flags
237+
*/
238+
239+
/* High priority flag */
240+
#define MC_CMD_FLAG_PRI 0x80
241+
/* Command completion flag */
242+
#define MC_CMD_FLAG_INTR_DIS 0x01
243+
244+
static inline u64 mc_encode_cmd_header(u16 cmd_id,
245+
u32 cmd_flags,
246+
u16 token)
247+
{
248+
u64 header = 0;
249+
struct mc_cmd_header *hdr = (struct mc_cmd_header *)&header;
250+
251+
hdr->cmd_id = cpu_to_le16(cmd_id);
252+
hdr->token = cpu_to_le16(token);
253+
hdr->status = MC_CMD_STATUS_READY;
254+
if (cmd_flags & MC_CMD_FLAG_PRI)
255+
hdr->flags_hw = MC_CMD_FLAG_PRI;
256+
if (cmd_flags & MC_CMD_FLAG_INTR_DIS)
257+
hdr->flags_sw = MC_CMD_FLAG_INTR_DIS;
258+
259+
return header;
260+
}
261+
262+
static inline u16 mc_cmd_hdr_read_token(struct mc_command *cmd)
263+
{
264+
struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;
265+
u16 token = le16_to_cpu(hdr->token);
266+
267+
return token;
268+
}
269+
270+
struct mc_rsp_create {
271+
__le32 object_id;
272+
};
273+
274+
struct mc_rsp_api_ver {
275+
__le16 major_ver;
276+
__le16 minor_ver;
277+
};
278+
279+
static inline u32 mc_cmd_read_object_id(struct mc_command *cmd)
280+
{
281+
struct mc_rsp_create *rsp_params;
282+
283+
rsp_params = (struct mc_rsp_create *)cmd->params;
284+
return le32_to_cpu(rsp_params->object_id);
285+
}
286+
287+
static inline void mc_cmd_read_api_version(struct mc_command *cmd,
288+
u16 *major_ver,
289+
u16 *minor_ver)
290+
{
291+
struct mc_rsp_api_ver *rsp_params;
292+
293+
rsp_params = (struct mc_rsp_api_ver *)cmd->params;
294+
*major_ver = le16_to_cpu(rsp_params->major_ver);
295+
*minor_ver = le16_to_cpu(rsp_params->minor_ver);
296+
}
297+
205298
/**
206299
* Bit masks for a MC I/O object (struct fsl_mc_io) flags
207300
*/

0 commit comments

Comments
 (0)