dma.h
Go to the documentation of this file.
1 /*
2  * dma.h
3  *
4  * Copyright (c) 2014 Jeremy Garff <jer @ jers.net>
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without modification, are permitted
9  * provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this list of
12  * conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
14  * of conditions and the following disclaimer in the documentation and/or other materials
15  * provided with the distribution.
16  * 3. Neither the name of the owner nor the names of its contributors may be used to endorse
17  * or promote products derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #ifndef __DMA_H__
31 #define __DMA_H__
32 
33 #include <stdint.h>
34 
35 /*
36  * DMA Control Block in Main Memory
37  *
38  * Note: Must start at a 256 byte aligned address.
39  * Use corresponding register field definitions.
40  */
41 typedef struct
42 {
43  uint32_t ti;
44  uint32_t source_ad;
45  uint32_t dest_ad;
46  uint32_t txfr_len;
47  uint32_t stride;
48  uint32_t nextconbk;
49  uint32_t resvd_0x18[2];
50 } __attribute__((packed, aligned(4))) dma_cb_t;
51 
52 /*
53  * DMA register set
54  */
55 typedef struct
56 {
57  uint32_t cs;
58 #define RPI_DMA_CS_RESET (1 << 31)
59 #define RPI_DMA_CS_ABORT (1 << 30)
60 #define RPI_DMA_CS_DISDEBUG (1 << 29)
61 #define RPI_DMA_CS_WAIT_OUTSTANDING_WRITES (1 << 28)
62 #define RPI_DMA_CS_PANIC_PRIORITY(val) ((val & 0xf) << 20)
63 #define RPI_DMA_CS_PRIORITY(val) ((val & 0xf) << 16)
64 #define RPI_DMA_CS_ERROR (1 << 8)
65 #define RPI_DMA_CS_WAITING_OUTSTANDING_WRITES (1 << 6)
66 #define RPI_DMA_CS_DREQ_STOPS_DMA (1 << 5)
67 #define RPI_DMA_CS_PAUSED (1 << 4)
68 #define RPI_DMA_CS_DREQ (1 << 3)
69 #define RPI_DMA_CS_INT (1 << 2)
70 #define RPI_DMA_CS_END (1 << 1)
71 #define RPI_DMA_CS_ACTIVE (1 << 0)
72  uint32_t conblk_ad;
73  uint32_t ti;
74 #define RPI_DMA_TI_NO_WIDE_BURSTS (1 << 26)
75 #define RPI_DMA_TI_WAITS(val) ((val & 0x1f) << 21)
76 #define RPI_DMA_TI_PERMAP(val) ((val & 0x1f) << 16)
77 #define RPI_DMA_TI_BURST_LENGTH(val) ((val & 0xf) << 12)
78 #define RPI_DMA_TI_SRC_IGNORE (1 << 11)
79 #define RPI_DMA_TI_SRC_DREQ (1 << 10)
80 #define RPI_DMA_TI_SRC_WIDTH (1 << 9)
81 #define RPI_DMA_TI_SRC_INC (1 << 8)
82 #define RPI_DMA_TI_DEST_IGNORE (1 << 7)
83 #define RPI_DMA_TI_DEST_DREQ (1 << 6)
84 #define RPI_DMA_TI_DEST_WIDTH (1 << 5)
85 #define RPI_DMA_TI_DEST_INC (1 << 4)
86 #define RPI_DMA_TI_WAIT_RESP (1 << 3)
87 #define RPI_DMA_TI_TDMODE (1 << 1)
88 #define RPI_DMA_TI_INTEN (1 << 0)
89  uint32_t source_ad;
90  uint32_t dest_ad;
91  uint32_t txfr_len;
92 #define RPI_DMA_TXFR_LEN_YLENGTH(val) ((val & 0xffff) << 16)
93 #define RPI_DMA_TXFR_LEN_XLENGTH(val) ((val & 0xffff) << 0)
94  uint32_t stride;
95 #define RPI_DMA_STRIDE_D_STRIDE(val) ((val & 0xffff) << 16)
96 #define RPI_DMA_STRIDE_S_STRIDE(val) ((val & 0xffff) << 0)
97  uint32_t nextconbk;
98  uint32_t debug;
99 } __attribute__((packed, aligned(4))) dma_t;
100 
101 
102 #define DMA0_OFFSET (0x00007000)
103 #define DMA1_OFFSET (0x00007100)
104 #define DMA2_OFFSET (0x00007200)
105 #define DMA3_OFFSET (0x00007300)
106 #define DMA4_OFFSET (0x00007400)
107 #define DMA5_OFFSET (0x00007500)
108 #define DMA6_OFFSET (0x00007600)
109 #define DMA7_OFFSET (0x00007700)
110 #define DMA8_OFFSET (0x00007800)
111 #define DMA9_OFFSET (0x00007900)
112 #define DMA10_OFFSET (0x00007a00)
113 #define DMA11_OFFSET (0x00007b00)
114 #define DMA12_OFFSET (0x00007c00)
115 #define DMA13_OFFSET (0x00007d00)
116 #define DMA14_OFFSET (0x00007e00)
117 #define DMA15_OFFSET (0x00e05000)
118 
119 
120 #define PAGE_SIZE (1 << 12)
121 #define PAGE_MASK (~(PAGE_SIZE - 1))
122 #define PAGE_OFFSET(page) (page & (PAGE_SIZE - 1))
123 
124 
125 uint32_t dmanum_to_offset(int dmanum);
126 
127 #endif /* __DMA_H__ */
uint32_t cs
Definition: dma.h:57
uint32_t dmanum_to_offset(int dmanum)
Definition: dma.c:66
uint32_t stride
Definition: dma.h:47
uint32_t source_ad
Definition: dma.h:44
uint32_t debug
Definition: dma.h:98
uint32_t nextconbk
Definition: dma.h:48
uint32_t txfr_len
Definition: dma.h:46
uint32_t conblk_ad
Definition: dma.h:72
uint32_t ti
Definition: dma.h:43
aligned(4))) dma_cb_t
uint32_t dest_ad
Definition: dma.h:45


ws281x
Author(s): Alexey Rogachevskiy , Oleg Kalachev
autogenerated on Wed Jun 15 2022 02:46:00