blob: 9e83a2eb433d0fadf94a511992b253ea44ddd772 [file] [log] [blame]
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07001/*
2 * Copyright (C) 2013-2015 Freescale Semiconductor
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#ifndef _FSL_DPIO_H
8#define _FSL_DPIO_H
9
10/* DPIO Version */
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053011#define DPIO_VER_MAJOR 3
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053012#define DPIO_VER_MINOR 1
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070013
14/* Command IDs */
15#define DPIO_CMDID_CLOSE 0x800
16#define DPIO_CMDID_OPEN 0x803
17
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
22
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)
26
27/* cmd, param, offset, width, type, arg_name */
28#define DPIO_RSP_GET_ATTR(cmd, attr) \
29do { \
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);\
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053034 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);\
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070036 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);\
38} while (0)
39
40/* Data Path I/O Portal API
41 * Contains initialization APIs and runtime control APIs for DPIO
42 */
43
44struct fsl_mc_io;
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053045
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070046/**
47 * dpio_open() - Open a control session for the specified object
48 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053049 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070050 * @dpio_id: DPIO unique ID
51 * @token: Returned token; use in subsequent API calls
52 *
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.
60 *
61 * Return: '0' on Success; Error code otherwise.
62 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053063int dpio_open(struct fsl_mc_io *mc_io,
64 uint32_t cmd_flags,
65 int dpio_id,
66 uint16_t *token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070067
68/**
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053069 * dpio_close() - Close the control session of the object
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070070 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053071 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053072 * @token: Token of DPIO object
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070073 *
74 * Return: '0' on Success; Error code otherwise.
75 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053076int dpio_close(struct fsl_mc_io *mc_io,
77 uint32_t cmd_flags,
78 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070079
80/**
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
86 */
87enum dpio_channel_mode {
88 DPIO_NO_CHANNEL = 0,
89 DPIO_LOCAL_CHANNEL = 1,
90};
91
92/**
93 * dpio_enable() - Enable the DPIO, allow I/O portal operations.
94 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053095 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070096 * @token: Token of DPIO object
97 *
98 * Return: '0' on Success; Error code otherwise
99 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530100int dpio_enable(struct fsl_mc_io *mc_io,
101 uint32_t cmd_flags,
102 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700103
104/**
105 * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
106 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530107 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700108 * @token: Token of DPIO object
109 *
110 * Return: '0' on Success; Error code otherwise
111 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530112int dpio_disable(struct fsl_mc_io *mc_io,
113 uint32_t cmd_flags,
114 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700115
116/**
117 * dpio_reset() - Reset the DPIO, returns the object to initial state.
118 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530119 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700120 * @token: Token of DPIO object
121 *
122 * Return: '0' on Success; Error code otherwise.
123 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530124int dpio_reset(struct fsl_mc_io *mc_io,
125 uint32_t cmd_flags,
126 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700127
128/**
129 * struct dpio_attr - Structure representing DPIO attributes
130 * @id: DPIO object ID
131 * @version: DPIO version
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530132 * @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
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700134 * @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'
138 */
139struct dpio_attr {
140 int id;
141 /**
142 * struct version - DPIO version
143 * @major: DPIO major version
144 * @minor: DPIO minor version
145 */
146 struct {
147 uint16_t major;
148 uint16_t minor;
149 } version;
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530150 uint64_t qbman_portal_ce_offset;
151 uint64_t qbman_portal_ci_offset;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700152 uint16_t qbman_portal_id;
153 enum dpio_channel_mode channel_mode;
154 uint8_t num_priorities;
155};
156
157/**
158 * dpio_get_attributes() - Retrieve DPIO attributes
159 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530160 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700161 * @token: Token of DPIO object
162 * @attr: Returned object's attributes
163 *
164 * Return: '0' on Success; Error code otherwise
165 */
166int dpio_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530167 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700168 uint16_t token,
169 struct dpio_attr *attr);
170
171#endif /* _FSL_DPIO_H */