2 * Copyright (C) 2013-2015 Freescale Semiconductor
4 * SPDX-License-Identifier: GPL-2.0+
11 #define DPIO_VER_MAJOR 3
12 #define DPIO_VER_MINOR 0
15 #define DPIO_CMDID_CLOSE 0x800
16 #define DPIO_CMDID_OPEN 0x803
18 #define DPIO_CMDID_ENABLE 0x002
19 #define DPIO_CMDID_DISABLE 0x003
20 #define DPIO_CMDID_GET_ATTR 0x004
21 #define DPIO_CMDID_RESET 0x005
23 /* cmd, param, offset, width, type, arg_name */
24 #define DPIO_CMD_OPEN(cmd, dpio_id) \
25 MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id)
27 /* cmd, param, offset, width, type, arg_name */
28 #define DPIO_RSP_GET_ATTR(cmd, attr) \
30 MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
31 MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\
32 MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
33 MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\
34 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\
35 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\
36 MC_RSP_OP(cmd, 3, 0, 16, uint16_t, attr->version.major);\
37 MC_RSP_OP(cmd, 3, 16, 16, uint16_t, attr->version.minor);\
40 /* Data Path I/O Portal API
41 * Contains initialization APIs and runtime control APIs for DPIO
47 * dpio_open() - Open a control session for the specified object
48 * @mc_io: Pointer to MC portal's I/O object
49 * @dpio_id: DPIO unique ID
50 * @token: Returned token; use in subsequent API calls
52 * This function can be used to open a control session for an
53 * already created object; an object may have been declared in
54 * the DPL or by calling the dpio_create() function.
55 * This function returns a unique authentication token,
56 * associated with the specific object ID and the specific MC
57 * portal; this token must be used in all subsequent commands for
58 * this specific object.
60 * Return: '0' on Success; Error code otherwise.
62 int dpio_open(struct fsl_mc_io *mc_io, int dpio_id, uint16_t *token);
65 * dpio_close() - Close the control session of the object
66 * @mc_io: Pointer to MC portal's I/O object
67 * @token: Token of DPIO object
69 * Return: '0' on Success; Error code otherwise.
71 int dpio_close(struct fsl_mc_io *mc_io, uint16_t token);
74 * enum dpio_channel_mode - DPIO notification channel mode
75 * @DPIO_NO_CHANNEL: No support for notification channel
76 * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
77 * dedicated channel in the DPIO; user should point the queue's
78 * destination in the relevant interface to this DPIO
80 enum dpio_channel_mode {
82 DPIO_LOCAL_CHANNEL = 1,
86 * dpio_enable() - Enable the DPIO, allow I/O portal operations.
87 * @mc_io: Pointer to MC portal's I/O object
88 * @token: Token of DPIO object
90 * Return: '0' on Success; Error code otherwise
92 int dpio_enable(struct fsl_mc_io *mc_io, uint16_t token);
95 * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
96 * @mc_io: Pointer to MC portal's I/O object
97 * @token: Token of DPIO object
99 * Return: '0' on Success; Error code otherwise
101 int dpio_disable(struct fsl_mc_io *mc_io, uint16_t token);
104 * dpio_reset() - Reset the DPIO, returns the object to initial state.
105 * @mc_io: Pointer to MC portal's I/O object
106 * @token: Token of DPIO object
108 * Return: '0' on Success; Error code otherwise.
110 int dpio_reset(struct fsl_mc_io *mc_io, uint16_t token);
113 * struct dpio_attr - Structure representing DPIO attributes
114 * @id: DPIO object ID
115 * @version: DPIO version
116 * @qbman_portal_ce_offset: offset of the software portal cache-enabled area
117 * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
118 * @qbman_portal_id: Software portal ID
119 * @channel_mode: Notification channel mode
120 * @num_priorities: Number of priorities for the notification channel (1-8);
121 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
126 * struct version - DPIO version
127 * @major: DPIO major version
128 * @minor: DPIO minor version
134 uint64_t qbman_portal_ce_offset;
135 uint64_t qbman_portal_ci_offset;
136 uint16_t qbman_portal_id;
137 enum dpio_channel_mode channel_mode;
138 uint8_t num_priorities;
142 * dpio_get_attributes() - Retrieve DPIO attributes
143 * @mc_io: Pointer to MC portal's I/O object
144 * @token: Token of DPIO object
145 * @attr: Returned object's attributes
147 * Return: '0' on Success; Error code otherwise
149 int dpio_get_attributes(struct fsl_mc_io *mc_io,
151 struct dpio_attr *attr);
153 #endif /* _FSL_DPIO_H */