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