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 */ 11 #define DPIO_VER_MAJOR 3 12 #define DPIO_VER_MINOR 0 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);\ 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);\ 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; 45 46 /** 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 51 * 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. 59 * 60 * Return: '0' on Success; Error code otherwise. 61 */ 62 int dpio_open(struct fsl_mc_io *mc_io, int dpio_id, uint16_t *token); 63 64 /** 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 68 * 69 * Return: '0' on Success; Error code otherwise. 70 */ 71 int dpio_close(struct fsl_mc_io *mc_io, uint16_t token); 72 73 /** 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 79 */ 80 enum dpio_channel_mode { 81 DPIO_NO_CHANNEL = 0, 82 DPIO_LOCAL_CHANNEL = 1, 83 }; 84 85 /** 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 89 * 90 * Return: '0' on Success; Error code otherwise 91 */ 92 int dpio_enable(struct fsl_mc_io *mc_io, uint16_t token); 93 94 /** 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 98 * 99 * Return: '0' on Success; Error code otherwise 100 */ 101 int dpio_disable(struct fsl_mc_io *mc_io, uint16_t token); 102 103 /** 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 107 * 108 * Return: '0' on Success; Error code otherwise. 109 */ 110 int dpio_reset(struct fsl_mc_io *mc_io, uint16_t token); 111 112 /** 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' 122 */ 123 struct dpio_attr { 124 int id; 125 /** 126 * struct version - DPIO version 127 * @major: DPIO major version 128 * @minor: DPIO minor version 129 */ 130 struct { 131 uint16_t major; 132 uint16_t minor; 133 } 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; 139 }; 140 141 /** 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 146 * 147 * Return: '0' on Success; Error code otherwise 148 */ 149 int dpio_get_attributes(struct fsl_mc_io *mc_io, 150 uint16_t token, 151 struct dpio_attr *attr); 152 153 #endif /* _FSL_DPIO_H */ 154