Yan He | c53399f | 2013-03-12 16:15:13 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | /* Smart-Peripheral-Switch (SPS) API. */ |
| 14 | |
| 15 | #ifndef _SPS_H_ |
| 16 | #define _SPS_H_ |
| 17 | |
| 18 | #include <linux/types.h> /* u32 */ |
| 19 | |
| 20 | /* SPS device handle indicating use of system memory */ |
| 21 | #define SPS_DEV_HANDLE_MEM ((u32)0x7ffffffful) |
| 22 | |
| 23 | /* SPS device handle indicating use of BAM-DMA */ |
| 24 | |
| 25 | /* SPS device handle invalid value */ |
| 26 | #define SPS_DEV_HANDLE_INVALID ((u32)0) |
| 27 | |
| 28 | /* BAM invalid IRQ value */ |
| 29 | #define SPS_IRQ_INVALID 0 |
| 30 | |
| 31 | /* Invalid address value */ |
| 32 | #define SPS_ADDR_INVALID 0 |
| 33 | |
| 34 | /* Invalid peripheral device enumeration class */ |
| 35 | #define SPS_CLASS_INVALID ((u32)-1) |
| 36 | |
| 37 | /* |
| 38 | * This value specifies different configurations for an SPS connection. |
| 39 | * A non-default value instructs the SPS driver to search for the configuration |
| 40 | * in the fixed connection mapping table. |
| 41 | */ |
| 42 | #define SPS_CONFIG_DEFAULT 0 |
| 43 | |
| 44 | /* |
| 45 | * This value instructs the SPS driver to use the default BAM-DMA channel |
| 46 | * threshold |
| 47 | */ |
| 48 | #define SPS_DMA_THRESHOLD_DEFAULT 0 |
| 49 | |
| 50 | /* Flag bits supported by SPS hardware for struct sps_iovec */ |
| 51 | #define SPS_IOVEC_FLAG_INT 0x8000 /* Generate interrupt */ |
| 52 | #define SPS_IOVEC_FLAG_EOT 0x4000 /* Generate end-of-transfer indication */ |
| 53 | #define SPS_IOVEC_FLAG_EOB 0x2000 /* Generate end-of-block indication */ |
Yan He | f879bb0 | 2011-12-22 15:38:03 -0800 | [diff] [blame] | 54 | #define SPS_IOVEC_FLAG_NWD 0x1000 /* notify when done */ |
| 55 | #define SPS_IOVEC_FLAG_CMD 0x0800 /* command descriptor */ |
| 56 | #define SPS_IOVEC_FLAG_LOCK 0x0400 /* pipe lock */ |
| 57 | #define SPS_IOVEC_FLAG_UNLOCK 0x0200 /* pipe unlock */ |
| 58 | #define SPS_IOVEC_FLAG_IMME 0x0100 /* immediate command descriptor */ |
| 59 | #define SPS_IOVEC_FLAG_NO_SUBMIT 0x0002 /* Do not submit descriptor to HW */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 60 | #define SPS_IOVEC_FLAG_DEFAULT 0x0001 /* Use driver default */ |
| 61 | |
Yan He | 9b45368 | 2012-08-07 11:32:17 -0700 | [diff] [blame] | 62 | /* Maximum descriptor/iovec size */ |
| 63 | #define SPS_IOVEC_MAX_SIZE (32 * 1024 - 1) /* 32K-1 bytes due to HW limit */ |
| 64 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 65 | /* BAM device options flags */ |
| 66 | |
| 67 | /* |
| 68 | * BAM will be configured and enabled at boot. Otherwise, BAM will be |
| 69 | * configured and enabled when first pipe connect occurs. |
| 70 | */ |
| 71 | #define SPS_BAM_OPT_ENABLE_AT_BOOT 1UL |
| 72 | /* BAM IRQ is disabled */ |
| 73 | #define SPS_BAM_OPT_IRQ_DISABLED (1UL << 1) |
| 74 | /* BAM peripheral is a BAM-DMA */ |
| 75 | #define SPS_BAM_OPT_BAMDMA (1UL << 2) |
Yan He | c324a79 | 2011-11-10 17:19:48 -0800 | [diff] [blame] | 76 | /* BAM IRQ is registered for apps wakeup */ |
| 77 | #define SPS_BAM_OPT_IRQ_WAKEUP (1UL << 3) |
Yan He | 821e276 | 2012-08-22 16:49:43 -0700 | [diff] [blame] | 78 | /* Ignore external block pipe reset */ |
| 79 | #define SPS_BAM_NO_EXT_P_RST (1UL << 4) |
Yan He | 7c775b4 | 2012-12-20 16:04:24 -0800 | [diff] [blame] | 80 | /* Don't enable local clock gating */ |
| 81 | #define SPS_BAM_NO_LOCAL_CLK_GATING (1UL << 5) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 82 | |
| 83 | /* BAM device management flags */ |
| 84 | |
| 85 | /* BAM global device control is managed remotely */ |
| 86 | #define SPS_BAM_MGR_DEVICE_REMOTE 1UL |
| 87 | /* BAM device supports multiple execution environments */ |
| 88 | #define SPS_BAM_MGR_MULTI_EE (1UL << 1) |
| 89 | /* BAM pipes are *not* allocated locally */ |
| 90 | #define SPS_BAM_MGR_PIPE_NO_ALLOC (1UL << 2) |
| 91 | /* BAM pipes are *not* configured locally */ |
| 92 | #define SPS_BAM_MGR_PIPE_NO_CONFIG (1UL << 3) |
| 93 | /* BAM pipes are *not* controlled locally */ |
| 94 | #define SPS_BAM_MGR_PIPE_NO_CTRL (1UL << 4) |
| 95 | /* "Globbed" management properties */ |
| 96 | #define SPS_BAM_MGR_NONE \ |
| 97 | (SPS_BAM_MGR_DEVICE_REMOTE | SPS_BAM_MGR_PIPE_NO_ALLOC | \ |
| 98 | SPS_BAM_MGR_PIPE_NO_CONFIG | SPS_BAM_MGR_PIPE_NO_CTRL) |
| 99 | #define SPS_BAM_MGR_LOCAL 0 |
| 100 | #define SPS_BAM_MGR_LOCAL_SHARED SPS_BAM_MGR_MULTI_EE |
| 101 | #define SPS_BAM_MGR_REMOTE_SHARED \ |
| 102 | (SPS_BAM_MGR_DEVICE_REMOTE | SPS_BAM_MGR_MULTI_EE | \ |
| 103 | SPS_BAM_MGR_PIPE_NO_ALLOC) |
| 104 | #define SPS_BAM_MGR_ACCESS_MASK SPS_BAM_MGR_NONE |
| 105 | |
| 106 | /* |
| 107 | * BAM security configuration |
| 108 | */ |
| 109 | #define SPS_BAM_NUM_EES 4 |
| 110 | #define SPS_BAM_SEC_DO_NOT_CONFIG 0 |
| 111 | #define SPS_BAM_SEC_DO_CONFIG 0x0A434553 |
| 112 | |
Yan He | 0eead89 | 2012-07-03 17:38:56 -0700 | [diff] [blame] | 113 | /* BAM pipe selection */ |
| 114 | #define SPS_BAM_PIPE(n) (1UL << (n)) |
| 115 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 116 | /* This enum specifies the operational mode for an SPS connection */ |
| 117 | enum sps_mode { |
| 118 | SPS_MODE_SRC = 0, /* end point is the source (producer) */ |
| 119 | SPS_MODE_DEST, /* end point is the destination (consumer) */ |
| 120 | }; |
| 121 | |
| 122 | |
| 123 | /* |
| 124 | * This enum is a set of bit flag options for SPS connection. |
| 125 | * The enums should be OR'd together to create the option set |
| 126 | * for the SPS connection. |
| 127 | */ |
| 128 | enum sps_option { |
| 129 | /* |
| 130 | * Options to enable specific SPS hardware interrupts. |
| 131 | * These bit flags are also used to indicate interrupt source |
| 132 | * for the SPS_EVENT_IRQ event. |
| 133 | */ |
| 134 | SPS_O_DESC_DONE = 0x00000001, /* Descriptor processed */ |
| 135 | SPS_O_INACTIVE = 0x00000002, /* Inactivity timeout */ |
| 136 | SPS_O_WAKEUP = 0x00000004, /* Peripheral wake up */ |
| 137 | SPS_O_OUT_OF_DESC = 0x00000008,/* Out of descriptors */ |
| 138 | SPS_O_ERROR = 0x00000010, /* Error */ |
| 139 | SPS_O_EOT = 0x00000020, /* End-of-transfer */ |
| 140 | |
| 141 | /* Options to enable hardware features */ |
| 142 | SPS_O_STREAMING = 0x00010000, /* Enable streaming mode (no EOT) */ |
| 143 | /* Use MTI/SETPEND instead of BAM interrupt */ |
| 144 | SPS_O_IRQ_MTI = 0x00020000, |
Yan He | f879bb0 | 2011-12-22 15:38:03 -0800 | [diff] [blame] | 145 | /* NWD bit written with EOT for BAM2BAM producer pipe */ |
| 146 | SPS_O_WRITE_NWD = 0x00040000, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 147 | |
| 148 | /* Options to enable software features */ |
Yan He | c82218b | 2013-04-04 09:33:23 -0700 | [diff] [blame] | 149 | /* Do not disable a pipe during disconnection */ |
| 150 | SPS_O_NO_DISABLE = 0x00800000, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 151 | /* Transfer operation should be polled */ |
| 152 | SPS_O_POLL = 0x01000000, |
| 153 | /* Disable queuing of transfer events for the connection end point */ |
| 154 | SPS_O_NO_Q = 0x02000000, |
| 155 | SPS_O_FLOWOFF = 0x04000000, /* Graceful halt */ |
| 156 | /* SPS_O_WAKEUP will be disabled after triggered */ |
| 157 | SPS_O_WAKEUP_IS_ONESHOT = 0x08000000, |
| 158 | /** |
| 159 | * Client must read each descriptor from the FIFO |
| 160 | * using sps_get_iovec() |
| 161 | */ |
| 162 | SPS_O_ACK_TRANSFERS = 0x10000000, |
| 163 | /* Connection is automatically enabled */ |
| 164 | SPS_O_AUTO_ENABLE = 0x20000000, |
| 165 | /* DISABLE endpoint synchronization for config/enable/disable */ |
| 166 | SPS_O_NO_EP_SYNC = 0x40000000, |
Yan He | 2295c27 | 2012-11-26 16:56:11 -0800 | [diff] [blame] | 167 | /* Allow partial polling duing IRQ mode */ |
| 168 | SPS_O_HYBRID = 0x80000000, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | /** |
| 172 | * This enum specifies BAM DMA channel priority. Clients should use |
| 173 | * SPS_DMA_PRI_DEFAULT unless a specific priority is required. |
| 174 | */ |
| 175 | enum sps_dma_priority { |
| 176 | SPS_DMA_PRI_DEFAULT = 0, |
| 177 | SPS_DMA_PRI_LOW, |
| 178 | SPS_DMA_PRI_MED, |
| 179 | SPS_DMA_PRI_HIGH, |
| 180 | }; |
| 181 | |
| 182 | /* |
| 183 | * This enum specifies the ownership of a connection resource. |
| 184 | * Remote or shared ownership is only possible/meaningful on the processor |
| 185 | * that controls resource. |
| 186 | */ |
| 187 | enum sps_owner { |
| 188 | SPS_OWNER_LOCAL = 0x1, /* Resource is owned by local processor */ |
| 189 | SPS_OWNER_REMOTE = 0x2, /* Resource is owned by a satellite processor */ |
| 190 | }; |
| 191 | |
| 192 | /* This enum indicates the event associated with a client event trigger */ |
| 193 | enum sps_event { |
| 194 | SPS_EVENT_INVALID = 0, |
| 195 | |
| 196 | SPS_EVENT_EOT, /* End-of-transfer */ |
| 197 | SPS_EVENT_DESC_DONE, /* Descriptor processed */ |
| 198 | SPS_EVENT_OUT_OF_DESC, /* Out of descriptors */ |
| 199 | SPS_EVENT_WAKEUP, /* Peripheral wake up */ |
| 200 | SPS_EVENT_FLOWOFF, /* Graceful halt (idle) */ |
| 201 | SPS_EVENT_INACTIVE, /* Inactivity timeout */ |
| 202 | SPS_EVENT_ERROR, /* Error */ |
| 203 | SPS_EVENT_MAX, |
| 204 | }; |
| 205 | |
| 206 | /* |
| 207 | * This enum specifies the event trigger mode and is an argument for the |
| 208 | * sps_register_event() function. |
| 209 | */ |
| 210 | enum sps_trigger { |
| 211 | /* Trigger with payload for callback */ |
| 212 | SPS_TRIGGER_CALLBACK = 0, |
| 213 | /* Trigger without payload for wait or poll */ |
| 214 | SPS_TRIGGER_WAIT, |
| 215 | }; |
| 216 | |
| 217 | /* |
| 218 | * This enum indicates the desired halting mechanism and is an argument for the |
| 219 | * sps_flow_off() function |
| 220 | */ |
| 221 | enum sps_flow_off { |
| 222 | SPS_FLOWOFF_FORCED = 0, /* Force hardware into halt state */ |
| 223 | /* Allow hardware to empty pipe before halting */ |
| 224 | SPS_FLOWOFF_GRACEFUL, |
| 225 | }; |
| 226 | |
| 227 | /* |
| 228 | * This enum indicates the target memory heap and is an argument for the |
| 229 | * sps_mem_alloc() function. |
| 230 | */ |
| 231 | enum sps_mem { |
| 232 | SPS_MEM_LOCAL = 0, /* SPS subsystem local (pipe) memory */ |
| 233 | SPS_MEM_UC, /* Microcontroller (ARM7) local memory */ |
| 234 | }; |
| 235 | |
| 236 | /* |
| 237 | * This enum indicates a timer control operation and is an argument for the |
| 238 | * sps_timer_ctrl() function. |
| 239 | */ |
| 240 | enum sps_timer_op { |
| 241 | SPS_TIMER_OP_CONFIG = 0, |
| 242 | SPS_TIMER_OP_RESET, |
| 243 | /* SPS_TIMER_OP_START, Not supported by hardware yet */ |
| 244 | /* SPS_TIMER_OP_STOP, Not supported by hardware yet */ |
| 245 | SPS_TIMER_OP_READ, |
| 246 | }; |
| 247 | |
| 248 | /* |
| 249 | * This enum indicates the inactivity timer operating mode and is an |
| 250 | * argument for the sps_timer_ctrl() function. |
| 251 | */ |
| 252 | enum sps_timer_mode { |
| 253 | SPS_TIMER_MODE_ONESHOT = 0, |
| 254 | /* SPS_TIMER_MODE_PERIODIC, Not supported by hardware yet */ |
| 255 | }; |
| 256 | |
Yan He | fcddf6f | 2012-03-13 12:41:18 -0700 | [diff] [blame] | 257 | /* This enum indicates the cases when callback the user of BAM */ |
| 258 | enum sps_callback_case { |
| 259 | SPS_CALLBACK_BAM_ERROR_IRQ = 1, /* BAM ERROR IRQ */ |
| 260 | SPS_CALLBACK_BAM_HRESP_ERR_IRQ, /* Erroneous HResponse */ |
| 261 | }; |
| 262 | |
Yan He | f879bb0 | 2011-12-22 15:38:03 -0800 | [diff] [blame] | 263 | /* |
| 264 | * This enum indicates the command type in a command element |
| 265 | */ |
| 266 | enum sps_command_type { |
| 267 | SPS_WRITE_COMMAND = 0, |
| 268 | SPS_READ_COMMAND, |
| 269 | }; |
| 270 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 271 | /** |
| 272 | * This data type corresponds to the native I/O vector (BAM descriptor) |
| 273 | * supported by SPS hardware |
| 274 | * |
| 275 | * @addr - Buffer physical address. |
| 276 | * @size - Buffer size in bytes. |
| 277 | * @flags -Flag bitmask (see SPS_IOVEC_FLAG_ #defines). |
| 278 | * |
| 279 | */ |
| 280 | struct sps_iovec { |
| 281 | u32 addr; |
| 282 | u32 size:16; |
| 283 | u32 flags:16; |
| 284 | }; |
| 285 | |
Yan He | f879bb0 | 2011-12-22 15:38:03 -0800 | [diff] [blame] | 286 | /** |
| 287 | * This data type corresponds to the native Command Element |
| 288 | * supported by SPS hardware |
| 289 | * |
| 290 | * @addr - register address. |
| 291 | * @command - command type. |
| 292 | * @data - for write command: content to be written into peripheral register. |
| 293 | * for read command: dest addr to write peripheral register value to. |
| 294 | * @mask - register mask. |
| 295 | * @reserved - for future usage. |
| 296 | * |
| 297 | */ |
| 298 | struct sps_command_element { |
| 299 | u32 addr:24; |
| 300 | u32 command:8; |
| 301 | u32 data; |
| 302 | u32 mask; |
| 303 | u32 reserved; |
| 304 | }; |
| 305 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 306 | /* |
| 307 | * BAM device's security configuation |
| 308 | */ |
| 309 | struct sps_bam_pipe_sec_config_props { |
| 310 | u32 pipe_mask; |
| 311 | u32 vmid; |
| 312 | }; |
| 313 | |
| 314 | struct sps_bam_sec_config_props { |
| 315 | /* Per-EE configuration - This is a pipe bit mask for each EE */ |
| 316 | struct sps_bam_pipe_sec_config_props ees[SPS_BAM_NUM_EES]; |
| 317 | }; |
| 318 | |
| 319 | /** |
| 320 | * This struct defines a BAM device. The client must memset() this struct to |
| 321 | * zero before writing device information. A value of zero for uninitialized |
| 322 | * values will instruct the SPS driver to use general defaults or |
| 323 | * hardware/BIOS supplied values. |
| 324 | * |
| 325 | * |
| 326 | * @options - See SPS_BAM_OPT_* bit flag. |
| 327 | * @phys_addr - BAM base physical address (not peripheral address). |
| 328 | * @virt_addr - BAM base virtual address. |
| 329 | * @virt_size - For virtual mapping. |
| 330 | * @irq - IRQ enum for use in ISR vector install. |
| 331 | * @num_pipes - number of pipes. Can be read from hardware. |
| 332 | * @summing_threshold - BAM event threshold. |
| 333 | * |
| 334 | * @periph_class - Peripheral device enumeration class. |
| 335 | * @periph_dev_id - Peripheral global device ID. |
| 336 | * @periph_phys_addr - Peripheral base physical address, for BAM-DMA only. |
| 337 | * @periph_virt_addr - Peripheral base virtual address. |
| 338 | * @periph_virt_size - Size for virtual mapping. |
| 339 | * |
Yan He | fcddf6f | 2012-03-13 12:41:18 -0700 | [diff] [blame] | 340 | * @callback - callback function for BAM user. |
| 341 | * @user - pointer to user data. |
| 342 | * |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 343 | * @event_threshold - Pipe event threshold. |
| 344 | * @desc_size - Size (bytes) of descriptor FIFO. |
| 345 | * @data_size - Size (bytes) of data FIFO. |
| 346 | * @desc_mem_id - Heap ID for default descriptor FIFO allocations. |
| 347 | * @data_mem_id - Heap ID for default data FIFO allocations. |
| 348 | * |
| 349 | * @manage - BAM device management flags (see SPS_BAM_MGR_*). |
| 350 | * @restricted_pipes - Bitmask of pipes restricted from local use. |
| 351 | * @ee - Local execution environment index. |
| 352 | * |
| 353 | * @irq_gen_addr - MTI interrupt generation address. This configuration only |
| 354 | * applies to BAM rev 1 and 2 hardware. MTIs are only supported on BAMs when |
| 355 | * global config is controlled by a remote processor. |
| 356 | * NOTE: This address must correspond to the MTI associated with the "irq" IRQ |
| 357 | * enum specified above. |
| 358 | * |
| 359 | * @sec_config - must be set to SPS_BAM_SEC_DO_CONFIG to perform BAM security |
| 360 | * configuration. Only the processor that manages the BAM is allowed to |
| 361 | * perform the configuration. The global (top-level) BAM interrupt will be |
| 362 | * assigned to the EE of the processor that manages the BAM. |
| 363 | * |
| 364 | * @p_sec_config_props - BAM device's security configuation |
| 365 | * |
| 366 | */ |
| 367 | struct sps_bam_props { |
| 368 | |
| 369 | /* BAM device properties. */ |
| 370 | |
| 371 | u32 options; |
| 372 | u32 phys_addr; |
| 373 | void *virt_addr; |
| 374 | u32 virt_size; |
| 375 | u32 irq; |
| 376 | u32 num_pipes; |
| 377 | u32 summing_threshold; |
| 378 | |
| 379 | /* Peripheral device properties */ |
| 380 | |
| 381 | u32 periph_class; |
| 382 | u32 periph_dev_id; |
| 383 | u32 periph_phys_addr; |
| 384 | void *periph_virt_addr; |
| 385 | u32 periph_virt_size; |
| 386 | |
| 387 | /* Connection pipe parameter defaults. */ |
| 388 | |
| 389 | u32 event_threshold; |
| 390 | u32 desc_size; |
| 391 | u32 data_size; |
| 392 | u32 desc_mem_id; |
| 393 | u32 data_mem_id; |
| 394 | |
Yan He | fcddf6f | 2012-03-13 12:41:18 -0700 | [diff] [blame] | 395 | /* Feedback to BAM user */ |
| 396 | void (*callback)(enum sps_callback_case, void *); |
| 397 | void *user; |
| 398 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 399 | /* Security properties */ |
| 400 | |
| 401 | u32 manage; |
| 402 | u32 restricted_pipes; |
| 403 | u32 ee; |
| 404 | |
| 405 | /* BAM MTI interrupt generation */ |
| 406 | |
| 407 | u32 irq_gen_addr; |
| 408 | |
| 409 | /* Security configuration properties */ |
| 410 | |
| 411 | u32 sec_config; |
| 412 | struct sps_bam_sec_config_props *p_sec_config_props; |
| 413 | }; |
| 414 | |
| 415 | /** |
| 416 | * This struct specifies memory buffer properties. |
| 417 | * |
| 418 | * @base - Buffer virtual address. |
| 419 | * @phys_base - Buffer physical address. |
| 420 | * @size - Specifies buffer size (or maximum size). |
| 421 | * @min_size - If non-zero, specifies buffer minimum size. |
| 422 | * |
| 423 | */ |
| 424 | struct sps_mem_buffer { |
| 425 | void *base; |
| 426 | u32 phys_base; |
| 427 | u32 size; |
| 428 | u32 min_size; |
| 429 | }; |
| 430 | |
| 431 | /** |
| 432 | * This struct defines a connection's end point and is used as the argument |
| 433 | * for the sps_connect(), sps_get_config(), and sps_set_config() functions. |
| 434 | * For system mode pipe, use SPS_DEV_HANDLE_MEM for the end point that |
| 435 | * corresponds to system memory. |
| 436 | * |
| 437 | * The client can force SPS to reserve a specific pipe on a BAM. |
| 438 | * If the pipe is in use, the sps_connect/set_config() will fail. |
| 439 | * |
| 440 | * @source - Source BAM. |
| 441 | * @src_pipe_index - BAM pipe index, 0 to 30. |
| 442 | * @destination - Destination BAM. |
| 443 | * @dest_pipe_index - BAM pipe index, 0 to 30. |
| 444 | * |
| 445 | * @mode - specifies which end (source or destination) of the connection will |
| 446 | * be controlled/referenced by the client. |
| 447 | * |
| 448 | * @config - This value is for future use and should be set to |
| 449 | * SPS_CONFIG_DEFAULT or left as default from sps_get_config(). |
| 450 | * |
| 451 | * @options - OR'd connection end point options (see SPS_O defines). |
| 452 | * |
| 453 | * WARNING: The memory provided should be physically contiguous and non-cached. |
| 454 | * The user can use one of the following: |
| 455 | * 1. sps_alloc_mem() - allocated from pipe-memory. |
| 456 | * 2. dma_alloc_coherent() - allocate coherent DMA memory. |
| 457 | * 3. dma_map_single() - for using memory allocated by kmalloc(). |
| 458 | * |
| 459 | * @desc - Descriptor FIFO. |
| 460 | * @data - Data FIFO (BAM-to-BAM mode only). |
| 461 | * |
| 462 | * @event_thresh - Pipe event threshold or derivative. |
Yan He | f879bb0 | 2011-12-22 15:38:03 -0800 | [diff] [blame] | 463 | * @lock_group - The lock group this pipe belongs to. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 464 | * |
| 465 | * @sps_reserved - Reserved word - client must not modify. |
| 466 | * |
| 467 | */ |
| 468 | struct sps_connect { |
| 469 | u32 source; |
| 470 | u32 src_pipe_index; |
| 471 | u32 destination; |
| 472 | u32 dest_pipe_index; |
| 473 | |
| 474 | enum sps_mode mode; |
| 475 | |
| 476 | u32 config; |
| 477 | |
| 478 | enum sps_option options; |
| 479 | |
| 480 | struct sps_mem_buffer desc; |
| 481 | struct sps_mem_buffer data; |
| 482 | |
| 483 | u32 event_thresh; |
| 484 | |
Yan He | f879bb0 | 2011-12-22 15:38:03 -0800 | [diff] [blame] | 485 | u32 lock_group; |
| 486 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 487 | /* SETPEND/MTI interrupt generation parameters */ |
| 488 | |
| 489 | u32 irq_gen_addr; |
| 490 | u32 irq_gen_data; |
| 491 | |
| 492 | u32 sps_reserved; |
| 493 | |
| 494 | }; |
| 495 | |
| 496 | /** |
| 497 | * This struct defines a satellite connection's end point. The client of the |
| 498 | * SPS driver on the satellite processor must call sps_get_config() to |
| 499 | * initialize a struct sps_connect, then copy the values from the struct |
| 500 | * sps_satellite to the struct sps_connect before making the sps_connect() |
| 501 | * call to the satellite SPS driver. |
| 502 | * |
| 503 | */ |
| 504 | struct sps_satellite { |
| 505 | /** |
| 506 | * These values must be copied to either the source or destination |
| 507 | * corresponding values in the connect struct. |
| 508 | */ |
| 509 | u32 dev; |
| 510 | u32 pipe_index; |
| 511 | |
| 512 | /** |
| 513 | * These values must be copied to the corresponding values in the |
| 514 | * connect struct |
| 515 | */ |
| 516 | u32 config; |
| 517 | enum sps_option options; |
| 518 | |
| 519 | }; |
| 520 | |
| 521 | /** |
| 522 | * This struct defines parameters for allocation of a BAM DMA channel. The |
| 523 | * client must memset() this struct to zero before writing allocation |
| 524 | * information. A value of zero for uninitialized values will instruct |
| 525 | * the SPS driver to use defaults or "don't care". |
| 526 | * |
| 527 | * @dev - Associated BAM device handle, or SPS_DEV_HANDLE_DMA. |
| 528 | * |
| 529 | * @src_owner - Source owner processor ID. |
| 530 | * @dest_owner - Destination owner processor ID. |
| 531 | * |
| 532 | */ |
| 533 | struct sps_alloc_dma_chan { |
| 534 | u32 dev; |
| 535 | |
| 536 | /* BAM DMA channel configuration parameters */ |
| 537 | |
| 538 | u32 threshold; |
| 539 | enum sps_dma_priority priority; |
| 540 | |
| 541 | /** |
| 542 | * Owner IDs are global host processor identifiers used by the system |
| 543 | * SROT when establishing execution environments. |
| 544 | */ |
| 545 | u32 src_owner; |
| 546 | u32 dest_owner; |
| 547 | |
| 548 | }; |
| 549 | |
| 550 | /** |
| 551 | * This struct defines parameters for an allocated BAM DMA channel. |
| 552 | * |
| 553 | * @dev - BAM DMA device handle. |
| 554 | * @dest_pipe_index - Destination/input/write pipe index. |
| 555 | * @src_pipe_index - Source/output/read pipe index. |
| 556 | * |
| 557 | */ |
| 558 | struct sps_dma_chan { |
| 559 | u32 dev; |
| 560 | u32 dest_pipe_index; |
| 561 | u32 src_pipe_index; |
| 562 | }; |
| 563 | |
| 564 | /** |
| 565 | * This struct is an argument passed payload when triggering a callback event |
| 566 | * object registered for an SPS connection end point. |
| 567 | * |
| 568 | * @user - Pointer registered with sps_register_event(). |
| 569 | * |
| 570 | * @event_id - Which event. |
| 571 | * |
| 572 | * @iovec - The associated I/O vector. If the end point is a system-mode |
| 573 | * producer, the size will reflect the actual number of bytes written to the |
| 574 | * buffer by the pipe. NOTE: If this I/O vector was part of a set submitted to |
| 575 | * sps_transfer(), then the vector array itself will be updated with all of |
| 576 | * the actual counts. |
| 577 | * |
| 578 | * @user - Pointer registered with the transfer. |
| 579 | * |
| 580 | */ |
| 581 | struct sps_event_notify { |
| 582 | void *user; |
| 583 | |
| 584 | enum sps_event event_id; |
| 585 | |
| 586 | /* Data associated with the event */ |
| 587 | |
| 588 | union { |
| 589 | /* Data for SPS_EVENT_IRQ */ |
| 590 | struct { |
| 591 | u32 mask; |
| 592 | } irq; |
| 593 | |
| 594 | /* Data for SPS_EVENT_EOT or SPS_EVENT_DESC_DONE */ |
| 595 | |
| 596 | struct { |
| 597 | struct sps_iovec iovec; |
| 598 | void *user; |
| 599 | } transfer; |
| 600 | |
| 601 | /* Data for SPS_EVENT_ERROR */ |
| 602 | |
| 603 | struct { |
| 604 | u32 status; |
| 605 | } err; |
| 606 | |
| 607 | } data; |
| 608 | }; |
| 609 | |
| 610 | /** |
| 611 | * This struct defines a event registration parameters and is used as the |
| 612 | * argument for the sps_register_event() function. |
| 613 | * |
| 614 | * @options - Event options that will trigger the event object. |
| 615 | * @mode - Event trigger mode. |
| 616 | * |
| 617 | * @xfer_done - a pointer to a completion object. NULL if not in use. |
| 618 | * |
| 619 | * @callback - a callback to call on completion. NULL if not in use. |
| 620 | * |
| 621 | * @user - User pointer that will be provided in event callback data. |
| 622 | * |
| 623 | */ |
| 624 | struct sps_register_event { |
| 625 | enum sps_option options; |
| 626 | enum sps_trigger mode; |
| 627 | struct completion *xfer_done; |
| 628 | void (*callback)(struct sps_event_notify *notify); |
| 629 | void *user; |
| 630 | }; |
| 631 | |
| 632 | /** |
| 633 | * This struct defines a system memory transfer's parameters and is used as the |
| 634 | * argument for the sps_transfer() function. |
| 635 | * |
| 636 | * @iovec_phys - Physical address of I/O vectors buffer. |
| 637 | * @iovec - Pointer to I/O vectors buffer. |
| 638 | * @iovec_count - Number of I/O vectors. |
| 639 | * @user - User pointer passed in callback event. |
| 640 | * |
| 641 | */ |
| 642 | struct sps_transfer { |
| 643 | u32 iovec_phys; |
| 644 | struct sps_iovec *iovec; |
| 645 | u32 iovec_count; |
| 646 | void *user; |
| 647 | }; |
| 648 | |
| 649 | /** |
| 650 | * This struct defines a timer control operation parameters and is used as an |
| 651 | * argument for the sps_timer_ctrl() function. |
| 652 | * |
| 653 | * @op - Timer control operation. |
| 654 | * @timeout_msec - Inactivity timeout (msec). |
| 655 | * |
| 656 | */ |
| 657 | struct sps_timer_ctrl { |
| 658 | enum sps_timer_op op; |
| 659 | |
| 660 | /** |
| 661 | * The following configuration parameters must be set when the timer |
| 662 | * control operation is SPS_TIMER_OP_CONFIG. |
| 663 | */ |
| 664 | enum sps_timer_mode mode; |
| 665 | u32 timeout_msec; |
| 666 | }; |
| 667 | |
| 668 | /** |
| 669 | * This struct defines a timer control operation result and is used as an |
| 670 | * argument for the sps_timer_ctrl() function. |
| 671 | */ |
| 672 | struct sps_timer_result { |
| 673 | u32 current_timer; |
| 674 | }; |
| 675 | |
| 676 | |
| 677 | /*---------------------------------------------------------------------------- |
| 678 | * Functions specific to sps interface |
| 679 | * -------------------------------------------------------------------------*/ |
| 680 | struct sps_pipe; /* Forward declaration */ |
| 681 | |
Yan He | 2eafd74 | 2012-04-09 16:07:15 -0700 | [diff] [blame] | 682 | #ifdef CONFIG_SPS |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 683 | /** |
| 684 | * Register a BAM device |
| 685 | * |
| 686 | * This function registers a BAM device with the SPS driver. For each |
| 687 | *peripheral that includes a BAM, the peripheral driver must register |
| 688 | * the BAM with the SPS driver. |
| 689 | * |
| 690 | * A requirement is that the peripheral driver must remain attached |
| 691 | * to the SPS driver until the BAM is deregistered. Otherwise, the |
| 692 | * system may attempt to unload the SPS driver. BAM registrations would |
| 693 | * be lost. |
| 694 | * |
| 695 | * @bam_props - Pointer to struct for BAM device properties. |
| 696 | * |
| 697 | * @dev_handle - Device handle will be written to this location (output). |
| 698 | * |
| 699 | * @return 0 on success, negative value on error |
| 700 | * |
| 701 | */ |
| 702 | int sps_register_bam_device(const struct sps_bam_props *bam_props, |
| 703 | u32 *dev_handle); |
| 704 | |
| 705 | /** |
| 706 | * Deregister a BAM device |
| 707 | * |
| 708 | * This function deregisters a BAM device from the SPS driver. The peripheral |
| 709 | * driver should deregister a BAM when the peripheral driver is shut down or |
| 710 | * when BAM use should be disabled. |
| 711 | * |
| 712 | * A BAM cannot be deregistered if any of its pipes is in an active connection. |
| 713 | * |
| 714 | * When all BAMs have been deregistered, the system is free to unload the |
| 715 | * SPS driver. |
| 716 | * |
| 717 | * @dev_handle - BAM device handle. |
| 718 | * |
| 719 | * @return 0 on success, negative value on error |
| 720 | * |
| 721 | */ |
| 722 | int sps_deregister_bam_device(u32 dev_handle); |
| 723 | |
| 724 | /** |
| 725 | * Allocate client state context |
| 726 | * |
| 727 | * This function allocate and initializes a client state context struct. |
| 728 | * |
| 729 | * @return pointer to client state context |
| 730 | * |
| 731 | */ |
| 732 | struct sps_pipe *sps_alloc_endpoint(void); |
| 733 | |
| 734 | /** |
| 735 | * Free client state context |
| 736 | * |
| 737 | * This function de-initializes and free a client state context struct. |
| 738 | * |
| 739 | * @ctx - client context for SPS connection end point |
| 740 | * |
| 741 | * @return 0 on success, negative value on error |
| 742 | * |
| 743 | */ |
| 744 | int sps_free_endpoint(struct sps_pipe *h); |
| 745 | |
| 746 | /** |
| 747 | * Get the configuration parameters for an SPS connection end point |
| 748 | * |
| 749 | * This function retrieves the configuration parameters for an SPS connection |
| 750 | * end point. |
| 751 | * This function may be called before the end point is connected (before |
| 752 | * sps_connect is called). This allows the client to specify parameters before |
| 753 | * the connection is established. |
| 754 | * |
| 755 | * The client must call this function to fill it's struct sps_connect |
| 756 | * struct before modifying values and passing the struct to sps_set_config(). |
| 757 | * |
| 758 | * @h - client context for SPS connection end point |
| 759 | * |
| 760 | * @config - Pointer to buffer for the end point's configuration parameters. |
| 761 | * Must not be NULL. |
| 762 | * |
| 763 | * @return 0 on success, negative value on error |
| 764 | * |
| 765 | */ |
| 766 | int sps_get_config(struct sps_pipe *h, struct sps_connect *config); |
| 767 | |
| 768 | /** |
| 769 | * Allocate memory from the SPS Pipe-Memory. |
| 770 | * |
| 771 | * @h - client context for SPS connection end point |
| 772 | * |
| 773 | * @mem - memory type - N/A. |
| 774 | * |
| 775 | * @mem_buffer - Pointer to struct for allocated memory properties. |
| 776 | * |
| 777 | * @return 0 on success, negative value on error |
| 778 | * |
| 779 | */ |
| 780 | int sps_alloc_mem(struct sps_pipe *h, enum sps_mem mem, |
| 781 | struct sps_mem_buffer *mem_buffer); |
| 782 | |
| 783 | /** |
| 784 | * Free memory from the SPS Pipe-Memory. |
| 785 | * |
| 786 | * @h - client context for SPS connection end point |
| 787 | * |
| 788 | * @mem_buffer - Pointer to struct for allocated memory properties. |
| 789 | * |
| 790 | * @return 0 on success, negative value on error |
| 791 | * |
| 792 | */ |
| 793 | int sps_free_mem(struct sps_pipe *h, struct sps_mem_buffer *mem_buffer); |
| 794 | |
| 795 | /** |
| 796 | * Connect an SPS connection end point |
| 797 | * |
| 798 | * This function creates a connection between two SPS peripherals or between |
| 799 | * an SPS peripheral and the local host processor (via system memory, end |
| 800 | *point SPS_DEV_HANDLE_MEM). Establishing the connection includes |
| 801 | * initialization of the SPS hardware and allocation of any other connection |
| 802 | * resources (buffer memory, etc.). |
| 803 | * |
| 804 | * This function requires the client to specify both the source and |
| 805 | * destination end points of the SPS connection. However, the handle |
| 806 | * returned applies only to the end point of the connection that the client |
| 807 | * controls. The end point under control must be specified by the |
| 808 | * enum sps_mode mode argument, either SPS_MODE_SRC, SPS_MODE_DEST, or |
| 809 | * SPS_MODE_CTL. Note that SPS_MODE_CTL is only supported for I/O |
| 810 | * accelerator connections, and only a limited set of control operations are |
| 811 | * allowed (TBD). |
| 812 | * |
| 813 | * For a connection involving system memory |
| 814 | * (SPS_DEV_HANDLE_MEM), the peripheral end point must be |
| 815 | * specified. For example, SPS_MODE_SRC must be specified for a |
| 816 | * BAM-to-system connection, since the BAM pipe is the data |
| 817 | * producer. |
| 818 | * |
| 819 | * For a specific peripheral-to-peripheral connection, there may be more than |
| 820 | * one required configuration. For example, there might be high-performance |
| 821 | * and low-power configurations for a connection between the two peripherals. |
| 822 | * The config argument allows the client to specify different configurations, |
| 823 | * which may require different system resource allocations and hardware |
| 824 | * initialization. |
| 825 | * |
| 826 | * A client is allowed to create one and only one connection for its |
| 827 | * struct sps_pipe. The handle is used to identify the connection end point |
| 828 | * in subsequent SPS driver calls. A specific connection source or |
| 829 | * destination end point can be associated with one and only one |
| 830 | * struct sps_pipe. |
| 831 | * |
| 832 | * The client must establish an open device handle to the SPS. To do so, the |
| 833 | * client must attach to the SPS driver and open the SPS device by calling |
| 834 | * the following functions. |
| 835 | * |
| 836 | * @h - client context for SPS connection end point |
| 837 | * |
| 838 | * @connect - Pointer to connection parameters |
| 839 | * |
| 840 | * @return 0 on success, negative value on error |
| 841 | * |
| 842 | */ |
| 843 | int sps_connect(struct sps_pipe *h, struct sps_connect *connect); |
| 844 | |
| 845 | /** |
| 846 | * Disconnect an SPS connection end point |
| 847 | * |
| 848 | * This function disconnects an SPS connection end point. |
| 849 | * The SPS hardware associated with that end point will be disabled. |
| 850 | * For a connection involving system memory (SPS_DEV_HANDLE_MEM), all |
| 851 | * connection resources are deallocated. For a peripheral-to-peripheral |
| 852 | * connection, the resources associated with the connection will not be |
| 853 | * deallocated until both end points are closed. |
| 854 | * |
| 855 | * The client must call sps_connect() for the handle before calling |
| 856 | * this function. |
| 857 | * |
| 858 | * @h - client context for SPS connection end point |
| 859 | * |
| 860 | * @return 0 on success, negative value on error |
| 861 | * |
| 862 | */ |
| 863 | int sps_disconnect(struct sps_pipe *h); |
| 864 | |
| 865 | /** |
| 866 | * Register an event object for an SPS connection end point |
| 867 | * |
| 868 | * This function registers a callback event object for an SPS connection end |
| 869 | *point. The registered event object will be triggered for the set of |
| 870 | * events specified in reg->options that are enabled for the end point. |
| 871 | * |
| 872 | * There can only be one registered event object for each event. If an event |
| 873 | * object is already registered for an event, it will be replaced. If |
| 874 | *reg->event handle is NULL, then any registered event object for the |
| 875 | * event will be deregistered. Option bits in reg->options not associated |
| 876 | * with events are ignored. |
| 877 | * |
| 878 | * The client must call sps_connect() for the handle before calling |
| 879 | * this function. |
| 880 | * |
| 881 | * @h - client context for SPS connection end point |
| 882 | * |
| 883 | * @reg - Pointer to event registration parameters |
| 884 | * |
| 885 | * @return 0 on success, negative value on error |
| 886 | * |
| 887 | */ |
| 888 | int sps_register_event(struct sps_pipe *h, struct sps_register_event *reg); |
| 889 | |
| 890 | /** |
| 891 | * Perform a single DMA transfer on an SPS connection end point |
| 892 | * |
| 893 | * This function submits a DMA transfer request consisting of a single buffer |
| 894 | * for an SPS connection end point associated with a peripheral-to/from-memory |
| 895 | * connection. The request will be submitted immediately to hardware if the |
| 896 | * hardware is idle (data flow off, no other pending transfers). Otherwise, it |
| 897 | * will be queued for later handling in the SPS driver work loop. |
| 898 | * |
| 899 | * The data buffer must be DMA ready. The client is responsible for insuring |
| 900 | *physically contiguous memory, cache maintenance, and memory barrier. For |
| 901 | * more information, see Appendix A. |
| 902 | * |
| 903 | * The client must not modify the data buffer until the completion indication is |
| 904 | * received. |
| 905 | * |
| 906 | * This function cannot be used if transfer queuing is disabled (see option |
| 907 | * SPS_O_NO_Q). The client must set the SPS_O_EOT option to receive a callback |
| 908 | * event trigger when the transfer is complete. The SPS driver will insure the |
| 909 | * appropriate flags in the I/O vectors are set to generate the completion |
| 910 | * indication. |
| 911 | * |
| 912 | * The return value from this function may indicate that an error occurred. |
| 913 | * Possible causes include invalid arguments. |
| 914 | * |
| 915 | * @h - client context for SPS connection end point |
| 916 | * |
| 917 | * @addr - Physical address of buffer to transfer. |
| 918 | * |
| 919 | * WARNING: The memory provided should be physically contiguous and |
| 920 | * non-cached. |
| 921 | * |
| 922 | * The user can use one of the following: |
| 923 | * 1. sps_alloc_mem() - allocated from pipe-memory. |
| 924 | * 2. dma_alloc_coherent() - allocate DMA memory. |
| 925 | * 3. dma_map_single() for memory allocated by kmalloc(). |
| 926 | * |
| 927 | * @size - Size in bytes of buffer to transfer |
| 928 | * |
| 929 | * @user - User pointer that will be returned to user as part of |
| 930 | * event payload |
| 931 | * |
| 932 | * @return 0 on success, negative value on error |
| 933 | * |
| 934 | */ |
| 935 | int sps_transfer_one(struct sps_pipe *h, u32 addr, u32 size, |
| 936 | void *user, u32 flags); |
| 937 | |
| 938 | /** |
| 939 | * Read event queue for an SPS connection end point |
| 940 | * |
| 941 | * This function reads event queue for an SPS connection end point. |
| 942 | * |
| 943 | * @h - client context for SPS connection end point |
| 944 | * |
| 945 | * @event - pointer to client's event data buffer |
| 946 | * |
| 947 | * @return 0 on success, negative value on error |
| 948 | * |
| 949 | */ |
| 950 | int sps_get_event(struct sps_pipe *h, struct sps_event_notify *event); |
| 951 | |
| 952 | /** |
| 953 | * Get processed I/O vector (completed transfers) |
| 954 | * |
| 955 | * This function fetches the next processed I/O vector. |
| 956 | * |
| 957 | * @h - client context for SPS connection end point |
| 958 | * |
| 959 | * @iovec - Pointer to I/O vector struct (output). |
| 960 | * This struct will be zeroed if there are no more processed I/O vectors. |
| 961 | * |
| 962 | * @return 0 on success, negative value on error |
| 963 | * |
| 964 | */ |
| 965 | int sps_get_iovec(struct sps_pipe *h, struct sps_iovec *iovec); |
| 966 | |
| 967 | /** |
| 968 | * Enable an SPS connection end point |
| 969 | * |
| 970 | * This function enables an SPS connection end point. |
| 971 | * |
| 972 | * @h - client context for SPS connection end point |
| 973 | * |
| 974 | * @return 0 on success, negative value on error |
| 975 | * |
| 976 | */ |
| 977 | int sps_flow_on(struct sps_pipe *h); |
| 978 | |
| 979 | /** |
| 980 | * Disable an SPS connection end point |
| 981 | * |
| 982 | * This function disables an SPS connection end point. |
| 983 | * |
| 984 | * @h - client context for SPS connection end point |
| 985 | * |
| 986 | * @mode - Desired mode for disabling pipe data flow |
| 987 | * |
| 988 | * @return 0 on success, negative value on error |
| 989 | * |
| 990 | */ |
| 991 | int sps_flow_off(struct sps_pipe *h, enum sps_flow_off mode); |
| 992 | |
| 993 | /** |
| 994 | * Perform a Multiple DMA transfer on an SPS connection end point |
| 995 | * |
| 996 | * This function submits a DMA transfer request for an SPS connection end point |
| 997 | * associated with a peripheral-to/from-memory connection. The request will be |
| 998 | * submitted immediately to hardware if the hardware is idle (data flow off, no |
| 999 | * other pending transfers). Otherwise, it will be queued for later handling in |
| 1000 | * the SPS driver work loop. |
| 1001 | * |
| 1002 | * The data buffers referenced by the I/O vectors must be DMA ready. |
| 1003 | * The client is responsible for insuring physically contiguous memory, |
| 1004 | * any cache maintenance, and memory barrier. For more information, |
| 1005 | * see Appendix A. |
| 1006 | * |
| 1007 | * The I/O vectors must specify physical addresses for the referenced buffers. |
| 1008 | * |
| 1009 | * The client must not modify the data buffers referenced by I/O vectors until |
| 1010 | * the completion indication is received. |
| 1011 | * |
| 1012 | * If transfer queuing is disabled (see option SPS_O_NO_Q), the client is |
| 1013 | * responsible for setting the appropriate flags in the I/O vectors to generate |
| 1014 | * the completion indication. Also, the client is responsible for enabling the |
| 1015 | * appropriate connection callback event options for completion indication (see |
| 1016 | * sps_connect(), sps_set_config()). |
| 1017 | * |
| 1018 | * If transfer queuing is enabled, the client must set the SPS_O_EOT option to |
| 1019 | * receive a callback event trigger when the transfer is complete. The SPS |
| 1020 | * driver will insure the appropriate flags in the I/O vectors are set to |
| 1021 | * generate the completion indication. The client must not set any flags in the |
| 1022 | * I/O vectors, as this may cause the SPS driver to become out of sync with the |
| 1023 | * hardware. |
| 1024 | * |
| 1025 | * The return value from this function may indicate that an error occurred. |
| 1026 | * Possible causes include invalid arguments. If transfer queuing is disabled, |
| 1027 | * an error will occur if the pipe is already processing a transfer. |
| 1028 | * |
| 1029 | * @h - client context for SPS connection end point |
| 1030 | * |
| 1031 | * @transfer - Pointer to transfer parameter struct |
| 1032 | * |
| 1033 | * @return 0 on success, negative value on error |
| 1034 | * |
| 1035 | */ |
| 1036 | int sps_transfer(struct sps_pipe *h, struct sps_transfer *transfer); |
| 1037 | |
| 1038 | /** |
| 1039 | * Determine whether an SPS connection end point FIFO is empty |
| 1040 | * |
| 1041 | * This function returns the empty state of an SPS connection end point. |
| 1042 | * |
| 1043 | * @h - client context for SPS connection end point |
| 1044 | * |
| 1045 | * @empty - pointer to client's empty status word (boolean) |
| 1046 | * |
| 1047 | * @return 0 on success, negative value on error |
| 1048 | * |
| 1049 | */ |
| 1050 | int sps_is_pipe_empty(struct sps_pipe *h, u32 *empty); |
| 1051 | |
| 1052 | /** |
| 1053 | * Reset an SPS BAM device |
| 1054 | * |
| 1055 | * This function resets an SPS BAM device. |
| 1056 | * |
| 1057 | * @dev - device handle for the BAM |
| 1058 | * |
| 1059 | * @return 0 on success, negative value on error |
| 1060 | * |
| 1061 | */ |
| 1062 | int sps_device_reset(u32 dev); |
| 1063 | |
| 1064 | /** |
| 1065 | * Set the configuration parameters for an SPS connection end point |
| 1066 | * |
| 1067 | * This function sets the configuration parameters for an SPS connection |
| 1068 | * end point. This function may be called before the end point is connected |
| 1069 | * (before sps_connect is called). This allows the client to specify |
| 1070 | *parameters before the connection is established. The client is allowed |
| 1071 | * to pre-allocate resources and override driver defaults. |
| 1072 | * |
| 1073 | * The client must call sps_get_config() to fill it's struct sps_connect |
| 1074 | * struct before modifying values and passing the struct to this function. |
| 1075 | * Only those parameters that differ from the current configuration will |
| 1076 | * be processed. |
| 1077 | * |
| 1078 | * @h - client context for SPS connection end point |
| 1079 | * |
| 1080 | * @config - Pointer to the end point's new configuration parameters. |
| 1081 | * |
| 1082 | * @return 0 on success, negative value on error |
| 1083 | * |
| 1084 | */ |
| 1085 | int sps_set_config(struct sps_pipe *h, struct sps_connect *config); |
| 1086 | |
| 1087 | /** |
| 1088 | * Set ownership of an SPS connection end point |
| 1089 | * |
| 1090 | * This function sets the ownership of an SPS connection end point to |
| 1091 | * either local (default) or non-local. This function is used to |
| 1092 | * retrieve the struct sps_connect data that must be used by a |
| 1093 | * satellite processor when calling sps_connect(). |
| 1094 | * |
| 1095 | * Non-local ownership is only possible/meaningful on the processor |
| 1096 | * that controls resource allocations (apps processor). Setting ownership |
| 1097 | * to non-local on a satellite processor will fail. |
| 1098 | * |
| 1099 | * Setting ownership from non-local to local will succeed only if the |
| 1100 | * owning satellite processor has properly brought the end point to |
| 1101 | * an idle condition. |
| 1102 | * |
| 1103 | * This function will succeed if the connection end point is already in |
| 1104 | * the specified ownership state. |
| 1105 | * |
| 1106 | * @h - client context for SPS connection end point |
| 1107 | * |
| 1108 | * @owner - New ownership of the connection end point |
| 1109 | * |
| 1110 | * @connect - Pointer to buffer for satellite processor connect data. |
| 1111 | * Can be NULL to avoid retrieving the connect data. Will be ignored |
| 1112 | * if the end point ownership is set to local. |
| 1113 | * |
| 1114 | * @return 0 on success, negative value on error |
| 1115 | * |
| 1116 | */ |
| 1117 | int sps_set_owner(struct sps_pipe *h, enum sps_owner owner, |
| 1118 | struct sps_satellite *connect); |
| 1119 | |
| 1120 | /** |
| 1121 | * Allocate a BAM DMA channel |
| 1122 | * |
| 1123 | * This function allocates a BAM DMA channel. A "BAM DMA" is a special |
| 1124 | * DMA peripheral with a BAM front end. The DMA peripheral acts as a conduit |
| 1125 | * for data to flow into a consumer pipe and then out of a producer pipe. |
| 1126 | * It's primarily purpose is to serve as a path for interprocessor communication |
| 1127 | * that allows each processor to control and protect it's own memory space. |
| 1128 | * |
| 1129 | * @alloc - Pointer to struct for BAM DMA channel allocation properties. |
| 1130 | * |
| 1131 | * @chan - Allocated channel information will be written to this |
| 1132 | * location (output). |
| 1133 | * |
| 1134 | * @return 0 on success, negative value on error |
| 1135 | * |
| 1136 | */ |
| 1137 | int sps_alloc_dma_chan(const struct sps_alloc_dma_chan *alloc, |
| 1138 | struct sps_dma_chan *chan); |
| 1139 | |
| 1140 | /** |
| 1141 | * Free a BAM DMA channel |
| 1142 | * |
| 1143 | * This function frees a BAM DMA channel. |
| 1144 | * |
| 1145 | * @chan - Pointer to information for channel to free |
| 1146 | * |
| 1147 | * @return 0 on success, negative value on error |
| 1148 | * |
| 1149 | */ |
| 1150 | int sps_free_dma_chan(struct sps_dma_chan *chan); |
| 1151 | |
| 1152 | /** |
| 1153 | * Get the BAM handle for BAM-DMA. |
| 1154 | * |
| 1155 | * The BAM handle should be use as source/destination in the sps_connect(). |
| 1156 | * |
| 1157 | * @return handle on success, zero on error |
| 1158 | * |
| 1159 | */ |
| 1160 | u32 sps_dma_get_bam_handle(void); |
| 1161 | |
| 1162 | /** |
| 1163 | * Free the BAM handle for BAM-DMA. |
| 1164 | * |
| 1165 | */ |
| 1166 | void sps_dma_free_bam_handle(u32 h); |
| 1167 | |
| 1168 | |
| 1169 | /** |
| 1170 | * Get number of free transfer entries for an SPS connection end point |
| 1171 | * |
| 1172 | * This function returns the number of free transfer entries for an |
| 1173 | * SPS connection end point. |
| 1174 | * |
| 1175 | * @h - client context for SPS connection end point |
| 1176 | * |
| 1177 | * @count - pointer to count status |
| 1178 | * |
| 1179 | * @return 0 on success, negative value on error |
| 1180 | * |
| 1181 | */ |
| 1182 | int sps_get_free_count(struct sps_pipe *h, u32 *count); |
| 1183 | |
| 1184 | /** |
| 1185 | * Perform timer control |
| 1186 | * |
| 1187 | * This function performs timer control operations. |
| 1188 | * |
| 1189 | * @h - client context for SPS connection end point |
| 1190 | * |
| 1191 | * @timer_ctrl - Pointer to timer control specification |
| 1192 | * |
| 1193 | * @timer_result - Pointer to buffer for timer operation result. |
| 1194 | * This argument can be NULL if no result is expected for the operation. |
| 1195 | * If non-NULL, the current timer value will always provided. |
| 1196 | * |
| 1197 | * @return 0 on success, negative value on error |
| 1198 | * |
| 1199 | */ |
| 1200 | int sps_timer_ctrl(struct sps_pipe *h, |
| 1201 | struct sps_timer_ctrl *timer_ctrl, |
| 1202 | struct sps_timer_result *timer_result); |
| 1203 | |
Yan He | 2027bd8 | 2011-11-05 14:43:01 -0700 | [diff] [blame] | 1204 | /** |
| 1205 | * Find the handle of a BAM device based on the physical address |
| 1206 | * |
| 1207 | * This function finds a BAM device in the BAM registration list that |
| 1208 | * matches the specified physical address, and returns its handle. |
| 1209 | * |
| 1210 | * @phys_addr - physical address of the BAM |
| 1211 | * |
| 1212 | * @h - device handle of the BAM |
| 1213 | * |
| 1214 | * @return 0 on success, negative value on error |
| 1215 | * |
| 1216 | */ |
| 1217 | int sps_phy2h(u32 phys_addr, u32 *handle); |
| 1218 | |
| 1219 | /** |
| 1220 | * Setup desc/data FIFO for bam-to-bam connection |
| 1221 | * |
| 1222 | * @mem_buffer - Pointer to struct for allocated memory properties. |
| 1223 | * |
| 1224 | * @addr - address of FIFO |
| 1225 | * |
| 1226 | * @size - FIFO size |
| 1227 | * |
| 1228 | * @use_offset - use address offset instead of absolute address |
| 1229 | * |
| 1230 | * @return 0 on success, negative value on error |
| 1231 | * |
| 1232 | */ |
| 1233 | int sps_setup_bam2bam_fifo(struct sps_mem_buffer *mem_buffer, |
| 1234 | u32 addr, u32 size, int use_offset); |
| 1235 | |
Yan He | ce596c1 | 2012-04-06 10:42:33 -0700 | [diff] [blame] | 1236 | /** |
| 1237 | * Get the number of unused descriptors in the descriptor FIFO |
| 1238 | * of a pipe |
| 1239 | * |
| 1240 | * @h - client context for SPS connection end point |
| 1241 | * |
| 1242 | * @desc_num - number of unused descriptors |
| 1243 | * |
| 1244 | * @return 0 on success, negative value on error |
| 1245 | * |
| 1246 | */ |
| 1247 | int sps_get_unused_desc_num(struct sps_pipe *h, u32 *desc_num); |
| 1248 | |
Yan He | 0eead89 | 2012-07-03 17:38:56 -0700 | [diff] [blame] | 1249 | /** |
| 1250 | * Get the debug info of BAM registers and descriptor FIFOs |
| 1251 | * |
| 1252 | * @dev - BAM device handle |
| 1253 | * |
| 1254 | * @option - debugging option |
| 1255 | * |
| 1256 | * @para - parameter used for an option (such as pipe combination) |
| 1257 | * |
Yan He | fc1aa89 | 2012-08-13 15:03:09 -0700 | [diff] [blame] | 1258 | * @tb_sel - testbus selection |
| 1259 | * |
Yan He | 4f9f695 | 2012-09-10 18:39:46 -0700 | [diff] [blame] | 1260 | * @desc_sel - selection of descriptors |
Yan He | fc1aa89 | 2012-08-13 15:03:09 -0700 | [diff] [blame] | 1261 | * |
Yan He | 0eead89 | 2012-07-03 17:38:56 -0700 | [diff] [blame] | 1262 | * @return 0 on success, negative value on error |
| 1263 | * |
| 1264 | */ |
Yan He | fc1aa89 | 2012-08-13 15:03:09 -0700 | [diff] [blame] | 1265 | int sps_get_bam_debug_info(u32 dev, u32 option, u32 para, |
Yan He | c53399f | 2013-03-12 16:15:13 -0700 | [diff] [blame] | 1266 | u32 tb_sel, u32 desc_sel); |
Yan He | 0eead89 | 2012-07-03 17:38:56 -0700 | [diff] [blame] | 1267 | |
Yan He | 2eafd74 | 2012-04-09 16:07:15 -0700 | [diff] [blame] | 1268 | #else |
| 1269 | static inline int sps_register_bam_device(const struct sps_bam_props |
| 1270 | *bam_props, u32 *dev_handle) |
| 1271 | { |
| 1272 | return -EPERM; |
| 1273 | } |
| 1274 | |
| 1275 | static inline int sps_deregister_bam_device(u32 dev_handle) |
| 1276 | { |
| 1277 | return -EPERM; |
| 1278 | } |
| 1279 | |
| 1280 | static inline struct sps_pipe *sps_alloc_endpoint(void) |
| 1281 | { |
| 1282 | return NULL; |
| 1283 | } |
| 1284 | |
| 1285 | static inline int sps_free_endpoint(struct sps_pipe *h) |
| 1286 | { |
| 1287 | return -EPERM; |
| 1288 | } |
| 1289 | |
| 1290 | static inline int sps_get_config(struct sps_pipe *h, struct sps_connect *config) |
| 1291 | { |
| 1292 | return -EPERM; |
| 1293 | } |
| 1294 | |
| 1295 | static inline int sps_alloc_mem(struct sps_pipe *h, enum sps_mem mem, |
| 1296 | struct sps_mem_buffer *mem_buffer) |
| 1297 | { |
| 1298 | return -EPERM; |
| 1299 | } |
| 1300 | |
| 1301 | static inline int sps_free_mem(struct sps_pipe *h, |
| 1302 | struct sps_mem_buffer *mem_buffer) |
| 1303 | { |
| 1304 | return -EPERM; |
| 1305 | } |
| 1306 | |
| 1307 | static inline int sps_connect(struct sps_pipe *h, struct sps_connect *connect) |
| 1308 | { |
| 1309 | return -EPERM; |
| 1310 | } |
| 1311 | |
| 1312 | static inline int sps_disconnect(struct sps_pipe *h) |
| 1313 | { |
| 1314 | return -EPERM; |
| 1315 | } |
| 1316 | |
| 1317 | static inline int sps_register_event(struct sps_pipe *h, |
| 1318 | struct sps_register_event *reg) |
| 1319 | { |
| 1320 | return -EPERM; |
| 1321 | } |
| 1322 | |
| 1323 | static inline int sps_transfer_one(struct sps_pipe *h, u32 addr, u32 size, |
| 1324 | void *user, u32 flags) |
| 1325 | { |
| 1326 | return -EPERM; |
| 1327 | } |
| 1328 | |
| 1329 | static inline int sps_get_event(struct sps_pipe *h, |
| 1330 | struct sps_event_notify *event) |
| 1331 | { |
| 1332 | return -EPERM; |
| 1333 | } |
| 1334 | |
| 1335 | static inline int sps_get_iovec(struct sps_pipe *h, struct sps_iovec *iovec) |
| 1336 | { |
| 1337 | return -EPERM; |
| 1338 | } |
| 1339 | |
| 1340 | static inline int sps_flow_on(struct sps_pipe *h) |
| 1341 | { |
| 1342 | return -EPERM; |
| 1343 | } |
| 1344 | |
| 1345 | static inline int sps_flow_off(struct sps_pipe *h, enum sps_flow_off mode) |
| 1346 | { |
| 1347 | return -EPERM; |
| 1348 | } |
| 1349 | |
| 1350 | static inline int sps_transfer(struct sps_pipe *h, |
| 1351 | struct sps_transfer *transfer) |
| 1352 | { |
| 1353 | return -EPERM; |
| 1354 | } |
| 1355 | |
| 1356 | static inline int sps_is_pipe_empty(struct sps_pipe *h, u32 *empty) |
| 1357 | { |
| 1358 | return -EPERM; |
| 1359 | } |
| 1360 | |
| 1361 | static inline int sps_device_reset(u32 dev) |
| 1362 | { |
| 1363 | return -EPERM; |
| 1364 | } |
| 1365 | |
| 1366 | static inline int sps_set_config(struct sps_pipe *h, struct sps_connect *config) |
| 1367 | { |
| 1368 | return -EPERM; |
| 1369 | } |
| 1370 | |
| 1371 | static inline int sps_set_owner(struct sps_pipe *h, enum sps_owner owner, |
| 1372 | struct sps_satellite *connect) |
| 1373 | { |
| 1374 | return -EPERM; |
| 1375 | } |
| 1376 | |
| 1377 | static inline int sps_get_free_count(struct sps_pipe *h, u32 *count) |
| 1378 | { |
| 1379 | return -EPERM; |
| 1380 | } |
| 1381 | |
| 1382 | static inline int sps_alloc_dma_chan(const struct sps_alloc_dma_chan *alloc, |
| 1383 | struct sps_dma_chan *chan) |
| 1384 | { |
| 1385 | return -EPERM; |
| 1386 | } |
| 1387 | |
| 1388 | static inline int sps_free_dma_chan(struct sps_dma_chan *chan) |
| 1389 | { |
| 1390 | return -EPERM; |
| 1391 | } |
| 1392 | |
| 1393 | static inline u32 sps_dma_get_bam_handle(void) |
| 1394 | { |
| 1395 | return 0; |
| 1396 | } |
| 1397 | |
| 1398 | static inline void sps_dma_free_bam_handle(u32 h) |
| 1399 | { |
| 1400 | } |
| 1401 | |
| 1402 | static inline int sps_timer_ctrl(struct sps_pipe *h, |
| 1403 | struct sps_timer_ctrl *timer_ctrl, |
| 1404 | struct sps_timer_result *timer_result) |
| 1405 | { |
| 1406 | return -EPERM; |
| 1407 | } |
| 1408 | |
| 1409 | static inline int sps_phy2h(u32 phys_addr, u32 *handle) |
| 1410 | { |
| 1411 | return -EPERM; |
| 1412 | } |
| 1413 | |
| 1414 | static inline int sps_setup_bam2bam_fifo(struct sps_mem_buffer *mem_buffer, |
| 1415 | u32 addr, u32 size, int use_offset) |
| 1416 | { |
| 1417 | return -EPERM; |
| 1418 | } |
| 1419 | |
| 1420 | static inline int sps_get_unused_desc_num(struct sps_pipe *h, u32 *desc_num) |
| 1421 | { |
| 1422 | return -EPERM; |
| 1423 | } |
Yan He | 0eead89 | 2012-07-03 17:38:56 -0700 | [diff] [blame] | 1424 | |
Yan He | fc1aa89 | 2012-08-13 15:03:09 -0700 | [diff] [blame] | 1425 | static inline int sps_get_bam_debug_info(u32 dev, u32 option, u32 para, |
Yan He | c53399f | 2013-03-12 16:15:13 -0700 | [diff] [blame] | 1426 | u32 tb_sel, u32 desc_sel) |
Yan He | 0eead89 | 2012-07-03 17:38:56 -0700 | [diff] [blame] | 1427 | { |
| 1428 | return -EPERM; |
| 1429 | } |
Yan He | 2eafd74 | 2012-04-09 16:07:15 -0700 | [diff] [blame] | 1430 | #endif |
| 1431 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1432 | #endif /* _SPS_H_ */ |