xref: /freebsd/sys/arm/ti/ti_sdma.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2011
5  *	Ben Gray <ben.r.gray@gmail.com>.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 /**
31  * sDMA device driver interface for the TI SoC
32  *
33  * See the ti_sdma.c file for implementation details.
34  *
35  * Reference:
36  *  OMAP35x Applications Processor
37  *   Technical Reference Manual
38  *  (omap35xx_techref.pdf)
39  */
40 #ifndef _TI_DMA_H_
41 #define _TI_DMA_H_
42 
43 #define TI_SDMA_ENDIAN_BIG          0x1
44 #define TI_SDMA_ENDIAN_LITTLE       0x0
45 
46 #define TI_SDMA_BURST_NONE          0x0
47 #define TI_SDMA_BURST_16            0x1
48 #define TI_SDMA_BURST_32            0x2
49 #define TI_SDMA_BURST_64            0x3
50 
51 #define TI_SDMA_DATA_8BITS_SCALAR   0x0
52 #define TI_SDMA_DATA_16BITS_SCALAR  0x1
53 #define TI_SDMA_DATA_32BITS_SCALAR  0x2
54 
55 #define TI_SDMA_ADDR_CONSTANT       0x0
56 #define TI_SDMA_ADDR_POST_INCREMENT 0x1
57 #define TI_SDMA_ADDR_SINGLE_INDEX   0x2
58 #define TI_SDMA_ADDR_DOUBLE_INDEX   0x3
59 
60 /**
61  * Status flags for the DMA callback
62  *
63  */
64 #define TI_SDMA_STATUS_DROP                  (1UL << 1)
65 #define TI_SDMA_STATUS_HALF                  (1UL << 2)
66 #define TI_SDMA_STATUS_FRAME                 (1UL << 3)
67 #define TI_SDMA_STATUS_LAST                  (1UL << 4)
68 #define TI_SDMA_STATUS_BLOCK                 (1UL << 5)
69 #define TI_SDMA_STATUS_SYNC                  (1UL << 6)
70 #define TI_SDMA_STATUS_PKT                   (1UL << 7)
71 #define TI_SDMA_STATUS_TRANS_ERR             (1UL << 8)
72 #define TI_SDMA_STATUS_SECURE_ERR            (1UL << 9)
73 #define TI_SDMA_STATUS_SUPERVISOR_ERR        (1UL << 10)
74 #define TI_SDMA_STATUS_MISALIGNED_ADRS_ERR   (1UL << 11)
75 #define TI_SDMA_STATUS_DRAIN_END             (1UL << 12)
76 
77 #define TI_SDMA_SYNC_FRAME                   (1UL << 0)
78 #define TI_SDMA_SYNC_BLOCK                   (1UL << 1)
79 #define TI_SDMA_SYNC_PACKET                  (TI_SDMA_SYNC_FRAME | TI_SDMA_SYNC_BLOCK)
80 #define TI_SDMA_SYNC_TRIG_ON_SRC             (1UL << 8)
81 #define TI_SDMA_SYNC_TRIG_ON_DST             (1UL << 9)
82 
83 #define TI_SDMA_IRQ_FLAG_DROP                (1UL << 1)
84 #define TI_SDMA_IRQ_FLAG_HALF_FRAME_COMPL    (1UL << 2)
85 #define TI_SDMA_IRQ_FLAG_FRAME_COMPL         (1UL << 3)
86 #define TI_SDMA_IRQ_FLAG_START_LAST_FRAME    (1UL << 4)
87 #define TI_SDMA_IRQ_FLAG_BLOCK_COMPL         (1UL << 5)
88 #define TI_SDMA_IRQ_FLAG_ENDOF_PKT           (1UL << 7)
89 #define TI_SDMA_IRQ_FLAG_DRAIN               (1UL << 12)
90 
91 int ti_sdma_activate_channel(unsigned int *ch,
92     void (*callback)(unsigned int ch, uint32_t status, void *data), void *data);
93 int ti_sdma_deactivate_channel(unsigned int ch);
94 int ti_sdma_start_xfer(unsigned int ch, unsigned int src_paddr,
95     unsigned long dst_paddr, unsigned int frmcnt, unsigned int elmcnt);
96 int ti_sdma_start_xfer_packet(unsigned int ch, unsigned int src_paddr,
97     unsigned long dst_paddr, unsigned int frmcnt, unsigned int elmcnt,
98     unsigned int pktsize);
99 int ti_sdma_stop_xfer(unsigned int ch);
100 int ti_sdma_enable_channel_irq(unsigned int ch, uint32_t flags);
101 int ti_sdma_disable_channel_irq(unsigned int ch);
102 int ti_sdma_get_channel_status(unsigned int ch, uint32_t *status);
103 int ti_sdma_set_xfer_endianess(unsigned int ch, unsigned int src, unsigned int dst);
104 int ti_sdma_set_xfer_burst(unsigned int ch, unsigned int src, unsigned int dst);
105 int ti_sdma_set_xfer_data_type(unsigned int ch, unsigned int type);
106 int ti_sdma_set_callback(unsigned int ch,
107     void (*callback)(unsigned int ch, uint32_t status, void *data), void *data);
108 int ti_sdma_sync_params(unsigned int ch, unsigned int trigger, unsigned int mode);
109 int ti_sdma_set_addr_mode(unsigned int ch, unsigned int src_mode, unsigned int dst_mode);
110 
111 #endif /* _TI_SDMA_H_ */
112