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 1
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 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
50 * @dpio_id: DPIO unique ID
51 * @token: Returned token; use in subsequent API calls
53 * This function can be used to open a control session for an
54 * already created object; an object may have been declared in
55 * the DPL or by calling the dpio_create() function.
56 * This function returns a unique authentication token,
57 * associated with the specific object ID and the specific MC
58 * portal; this token must be used in all subsequent commands for
59 * this specific object.
61 * Return: '0' on Success; Error code otherwise.
63 int dpio_open(struct fsl_mc_io *mc_io,
69 * dpio_close() - Close the control session of the object
70 * @mc_io: Pointer to MC portal's I/O object
71 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
72 * @token: Token of DPIO object
74 * Return: '0' on Success; Error code otherwise.
76 int dpio_close(struct fsl_mc_io *mc_io,
81 * enum dpio_channel_mode - DPIO notification channel mode
82 * @DPIO_NO_CHANNEL: No support for notification channel
83 * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
84 * dedicated channel in the DPIO; user should point the queue's
85 * destination in the relevant interface to this DPIO
87 enum dpio_channel_mode {
89 DPIO_LOCAL_CHANNEL = 1,
93 * dpio_enable() - Enable the DPIO, allow I/O portal operations.
94 * @mc_io: Pointer to MC portal's I/O object
95 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
96 * @token: Token of DPIO object
98 * Return: '0' on Success; Error code otherwise
100 int dpio_enable(struct fsl_mc_io *mc_io,
105 * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
106 * @mc_io: Pointer to MC portal's I/O object
107 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
108 * @token: Token of DPIO object
110 * Return: '0' on Success; Error code otherwise
112 int dpio_disable(struct fsl_mc_io *mc_io,
117 * dpio_reset() - Reset the DPIO, returns the object to initial state.
118 * @mc_io: Pointer to MC portal's I/O object
119 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
120 * @token: Token of DPIO object
122 * Return: '0' on Success; Error code otherwise.
124 int dpio_reset(struct fsl_mc_io *mc_io,
129 * struct dpio_attr - Structure representing DPIO attributes
130 * @id: DPIO object ID
131 * @version: DPIO version
132 * @qbman_portal_ce_offset: offset of the software portal cache-enabled area
133 * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
134 * @qbman_portal_id: Software portal ID
135 * @channel_mode: Notification channel mode
136 * @num_priorities: Number of priorities for the notification channel (1-8);
137 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
142 * struct version - DPIO version
143 * @major: DPIO major version
144 * @minor: DPIO minor version
150 uint64_t qbman_portal_ce_offset;
151 uint64_t qbman_portal_ci_offset;
152 uint16_t qbman_portal_id;
153 enum dpio_channel_mode channel_mode;
154 uint8_t num_priorities;
158 * dpio_get_attributes() - Retrieve DPIO attributes
159 * @mc_io: Pointer to MC portal's I/O object
160 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
161 * @token: Token of DPIO object
162 * @attr: Returned object's attributes
164 * Return: '0' on Success; Error code otherwise
166 int dpio_get_attributes(struct fsl_mc_io *mc_io,
169 struct dpio_attr *attr);
171 #endif /* _FSL_DPIO_H */