Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1 | /* |
| 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 Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 11 | #define DPIO_VER_MAJOR 3 |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 12 | #define DPIO_VER_MINOR 1 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 13 | |
| 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) \ |
| 29 | do { \ |
| 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 Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 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);\ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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);\ |
| 38 | } while (0) |
| 39 | |
| 40 | /* Data Path I/O Portal API |
| 41 | * Contains initialization APIs and runtime control APIs for DPIO |
| 42 | */ |
| 43 | |
| 44 | struct fsl_mc_io; |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 45 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 46 | /** |
| 47 | * dpio_open() - Open a control session for the specified object |
| 48 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 49 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 50 | * @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 Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 63 | int dpio_open(struct fsl_mc_io *mc_io, |
| 64 | uint32_t cmd_flags, |
| 65 | int dpio_id, |
| 66 | uint16_t *token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 69 | * dpio_close() - Close the control session of the object |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 70 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 71 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 72 | * @token: Token of DPIO object |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 73 | * |
| 74 | * Return: '0' on Success; Error code otherwise. |
| 75 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 76 | int dpio_close(struct fsl_mc_io *mc_io, |
| 77 | uint32_t cmd_flags, |
| 78 | uint16_t token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 79 | |
| 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 | */ |
| 87 | enum 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 Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 95 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 96 | * @token: Token of DPIO object |
| 97 | * |
| 98 | * Return: '0' on Success; Error code otherwise |
| 99 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 100 | int dpio_enable(struct fsl_mc_io *mc_io, |
| 101 | uint32_t cmd_flags, |
| 102 | uint16_t token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 103 | |
| 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 Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 107 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 108 | * @token: Token of DPIO object |
| 109 | * |
| 110 | * Return: '0' on Success; Error code otherwise |
| 111 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 112 | int dpio_disable(struct fsl_mc_io *mc_io, |
| 113 | uint32_t cmd_flags, |
| 114 | uint16_t token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 115 | |
| 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 Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 119 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 120 | * @token: Token of DPIO object |
| 121 | * |
| 122 | * Return: '0' on Success; Error code otherwise. |
| 123 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 124 | int dpio_reset(struct fsl_mc_io *mc_io, |
| 125 | uint32_t cmd_flags, |
| 126 | uint16_t token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * struct dpio_attr - Structure representing DPIO attributes |
| 130 | * @id: DPIO object ID |
| 131 | * @version: DPIO version |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 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 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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' |
| 138 | */ |
| 139 | struct 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 Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 150 | uint64_t qbman_portal_ce_offset; |
| 151 | uint64_t qbman_portal_ci_offset; |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 152 | 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 Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 160 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 161 | * @token: Token of DPIO object |
| 162 | * @attr: Returned object's attributes |
| 163 | * |
| 164 | * Return: '0' on Success; Error code otherwise |
| 165 | */ |
| 166 | int dpio_get_attributes(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame^] | 167 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 168 | uint16_t token, |
| 169 | struct dpio_attr *attr); |
| 170 | |
| 171 | #endif /* _FSL_DPIO_H */ |