blob: 7788e1962e6448fb77f17005791712cb6a4dcb70 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -07002/*
Yogesh Gaur1a0c4ae2018-05-09 10:52:17 +05303 * Copyright 2013-2016 Freescale Semiconductor, Inc.
Yogesh Gaur318c32f2017-11-15 11:59:31 +05304 * Copyright 2017 NXP
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -07005 */
6
7#ifndef _FSL_DPIO_H
8#define _FSL_DPIO_H
9
10/* DPIO Version */
Yogesh Gaur318c32f2017-11-15 11:59:31 +053011#define DPIO_VER_MAJOR 4
Prabhakar Kushwahac3d06e32015-12-24 15:32:49 +053012#define DPIO_VER_MINOR 2
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070013
14/* Command IDs */
Yogesh Gaur318c32f2017-11-15 11:59:31 +053015#define DPIO_CMDID_CLOSE 0x8001
16#define DPIO_CMDID_OPEN 0x8031
17#define DPIO_CMDID_CREATE 0x9031
18#define DPIO_CMDID_DESTROY 0x9831
19#define DPIO_CMDID_GET_API_VERSION 0xa031
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070020
Yogesh Gaur318c32f2017-11-15 11:59:31 +053021#define DPIO_CMDID_ENABLE 0x0021
22#define DPIO_CMDID_DISABLE 0x0031
23#define DPIO_CMDID_GET_ATTR 0x0041
24#define DPIO_CMDID_RESET 0x0051
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070025
26/* cmd, param, offset, width, type, arg_name */
27#define DPIO_CMD_OPEN(cmd, dpio_id) \
28 MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id)
29
30/* cmd, param, offset, width, type, arg_name */
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +053031#define DPIO_CMD_CREATE(cmd, cfg) \
32do { \
33 MC_CMD_OP(cmd, 0, 16, 2, enum dpio_channel_mode, \
34 cfg->channel_mode);\
35 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->num_priorities);\
36} while (0)
37
38/* cmd, param, offset, width, type, arg_name */
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070039#define DPIO_RSP_GET_ATTR(cmd, attr) \
40do { \
41 MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
42 MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\
43 MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
44 MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +053045 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\
46 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\
Prabhakar Kushwahac3d06e32015-12-24 15:32:49 +053047 MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070048} while (0)
49
50/* Data Path I/O Portal API
51 * Contains initialization APIs and runtime control APIs for DPIO
52 */
53
54struct fsl_mc_io;
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +053055
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070056/**
57 * dpio_open() - Open a control session for the specified object
58 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053059 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070060 * @dpio_id: DPIO unique ID
61 * @token: Returned token; use in subsequent API calls
62 *
63 * This function can be used to open a control session for an
64 * already created object; an object may have been declared in
65 * the DPL or by calling the dpio_create() function.
66 * This function returns a unique authentication token,
67 * associated with the specific object ID and the specific MC
68 * portal; this token must be used in all subsequent commands for
69 * this specific object.
70 *
71 * Return: '0' on Success; Error code otherwise.
72 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053073int dpio_open(struct fsl_mc_io *mc_io,
74 uint32_t cmd_flags,
Yogesh Gaur318c32f2017-11-15 11:59:31 +053075 uint32_t dpio_id,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053076 uint16_t *token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070077
78/**
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +053079 * dpio_close() - Close the control session of the object
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070080 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053081 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +053082 * @token: Token of DPIO object
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070083 *
84 * Return: '0' on Success; Error code otherwise.
85 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053086int dpio_close(struct fsl_mc_io *mc_io,
87 uint32_t cmd_flags,
88 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070089
90/**
91 * enum dpio_channel_mode - DPIO notification channel mode
92 * @DPIO_NO_CHANNEL: No support for notification channel
93 * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
94 * dedicated channel in the DPIO; user should point the queue's
95 * destination in the relevant interface to this DPIO
96 */
97enum dpio_channel_mode {
98 DPIO_NO_CHANNEL = 0,
99 DPIO_LOCAL_CHANNEL = 1,
100};
101
102/**
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530103 * struct dpio_cfg - Structure representing DPIO configuration
104 * @channel_mode: Notification channel mode
105 * @num_priorities: Number of priorities for the notification channel (1-8);
106 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
107 */
108struct dpio_cfg {
109 enum dpio_channel_mode channel_mode;
110 uint8_t num_priorities;
111};
112
113/**
114 * dpio_create() - Create the DPIO object.
115 * @mc_io: Pointer to MC portal's I/O object
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530116 * @token: Authentication token.
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530117 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
118 * @cfg: Configuration structure
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530119 * @obj_id: Returned obj_id; use in subsequent API calls
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530120 *
121 * Create the DPIO object, allocate required resources and
122 * perform required initialization.
123 *
124 * The object can be created either by declaring it in the
125 * DPL file, or by calling this function.
126 *
127 * This function returns a unique authentication token,
128 * associated with the specific object ID and the specific MC
129 * portal; this token must be used in all subsequent calls to
130 * this specific object. For objects that are created using the
131 * DPL file, call dpio_open() function to get an authentication
132 * token first.
133 *
134 * Return: '0' on Success; Error code otherwise.
135 */
136int dpio_create(struct fsl_mc_io *mc_io,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530137 uint16_t token,
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530138 uint32_t cmd_flags,
139 const struct dpio_cfg *cfg,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530140 uint32_t *obj_id);
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530141
142/**
143 * dpio_destroy() - Destroy the DPIO object and release all its resources.
144 * @mc_io: Pointer to MC portal's I/O object
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530145 * @token: Authentication token.
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530146 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530147 * @obj_id: Object ID of DPIO
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530148 *
149 * Return: '0' on Success; Error code otherwise
150 */
151int dpio_destroy(struct fsl_mc_io *mc_io,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530152 uint16_t token,
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530153 uint32_t cmd_flags,
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530154 uint32_t obj_id);
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +0530155
156/**
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700157 * dpio_enable() - Enable the DPIO, allow I/O portal operations.
158 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530159 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700160 * @token: Token of DPIO object
161 *
162 * Return: '0' on Success; Error code otherwise
163 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530164int dpio_enable(struct fsl_mc_io *mc_io,
165 uint32_t cmd_flags,
166 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700167
168/**
169 * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
170 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530171 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700172 * @token: Token of DPIO object
173 *
174 * Return: '0' on Success; Error code otherwise
175 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530176int dpio_disable(struct fsl_mc_io *mc_io,
177 uint32_t cmd_flags,
178 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700179
180/**
181 * dpio_reset() - Reset the DPIO, returns the object to initial state.
182 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530183 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700184 * @token: Token of DPIO object
185 *
186 * Return: '0' on Success; Error code otherwise.
187 */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530188int dpio_reset(struct fsl_mc_io *mc_io,
189 uint32_t cmd_flags,
190 uint16_t token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700191
192/**
193 * struct dpio_attr - Structure representing DPIO attributes
194 * @id: DPIO object ID
195 * @version: DPIO version
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +0530196 * @qbman_portal_ce_offset: offset of the software portal cache-enabled area
197 * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700198 * @qbman_portal_id: Software portal ID
199 * @channel_mode: Notification channel mode
200 * @num_priorities: Number of priorities for the notification channel (1-8);
201 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
Prabhakar Kushwahac3d06e32015-12-24 15:32:49 +0530202 * @qbman_version: QBMAN version
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700203 */
204struct dpio_attr {
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530205 uint32_t id;
Prabhakar Kushwahafd5d1272015-07-02 11:28:59 +0530206 uint64_t qbman_portal_ce_offset;
207 uint64_t qbman_portal_ci_offset;
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700208 uint16_t qbman_portal_id;
209 enum dpio_channel_mode channel_mode;
210 uint8_t num_priorities;
Prabhakar Kushwahac3d06e32015-12-24 15:32:49 +0530211 uint32_t qbman_version;
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700212};
213
214/**
215 * dpio_get_attributes() - Retrieve DPIO attributes
216 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530217 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700218 * @token: Token of DPIO object
219 * @attr: Returned object's attributes
220 *
221 * Return: '0' on Success; Error code otherwise
222 */
223int dpio_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530224 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700225 uint16_t token,
226 struct dpio_attr *attr);
227
Yogesh Gaur318c32f2017-11-15 11:59:31 +0530228/**
229 * dpio_get_api_version - Retrieve DPIO Major and Minor version info.
230 *
231 * @mc_io: Pointer to MC portal's I/O object
232 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
233 * @major_ver: DPIO major version
234 * @minor_ver: DPIO minor version
235 *
236 * Return: '0' on Success; Error code otherwise.
237 */
238int dpio_get_api_version(struct fsl_mc_io *mc_io,
239 u32 cmd_flags,
240 u16 *major_ver,
241 u16 *minor_ver);
242
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700243#endif /* _FSL_DPIO_H */