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