cosmetics
[tomato.git] / release / src / include / sbhnddma.h
blobb83baeb614a164cfabbfce13fd51ee8c9834b960
1 /*
2 * Generic Broadcom Home Networking Division (HND) DMA engine HW interface
3 * This supports the following chips: BCM42xx, 44xx, 47xx .
5 * Copyright 2007, Broadcom Corporation
6 * All Rights Reserved.
7 *
8 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
9 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
10 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
11 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
13 * $Id$
16 #ifndef _sbhnddma_h_
17 #define _sbhnddma_h_
19 /* DMA structure:
20 * support two DMA engines: 32 bits address or 64 bit addressing
21 * basic DMA register set is per channel(transmit or receive)
22 * a pair of channels is defined for convenience
26 /* 32 bits addressing */
28 /* dma registers per channel(xmt or rcv) */
29 typedef volatile struct {
30 uint32 control; /* enable, et al */
31 uint32 addr; /* descriptor ring base address (4K aligned) */
32 uint32 ptr; /* last descriptor posted to chip */
33 uint32 status; /* current active descriptor, et al */
34 } dma32regs_t;
36 typedef volatile struct {
37 dma32regs_t xmt; /* dma tx channel */
38 dma32regs_t rcv; /* dma rx channel */
39 } dma32regp_t;
41 typedef volatile struct { /* diag access */
42 uint32 fifoaddr; /* diag address */
43 uint32 fifodatalow; /* low 32bits of data */
44 uint32 fifodatahigh; /* high 32bits of data */
45 uint32 pad; /* reserved */
46 } dma32diag_t;
49 * DMA Descriptor
50 * Descriptors are only read by the hardware, never written back.
52 typedef volatile struct {
53 uint32 ctrl; /* misc control bits & bufcount */
54 uint32 addr; /* data buffer address */
55 } dma32dd_t;
58 * Each descriptor ring must be 4096byte aligned, and fit within a single 4096byte page.
60 #define D32MAXRINGSZ 4096
61 #define D32RINGALIGN 4096
62 #define D32MAXDD (D32MAXRINGSZ / sizeof (dma32dd_t))
64 /* transmit channel control */
65 #define XC_XE ((uint32)1 << 0) /* transmit enable */
66 #define XC_SE ((uint32)1 << 1) /* transmit suspend request */
67 #define XC_LE ((uint32)1 << 2) /* loopback enable */
68 #define XC_FL ((uint32)1 << 4) /* flush request */
69 #define XC_AE ((uint32)3 << 16) /* address extension bits */
70 #define XC_AE_SHIFT 16
72 /* transmit descriptor table pointer */
73 #define XP_LD_MASK 0xfff /* last valid descriptor */
75 /* transmit channel status */
76 #define XS_CD_MASK 0x0fff /* current descriptor pointer */
77 #define XS_XS_MASK 0xf000 /* transmit state */
78 #define XS_XS_SHIFT 12
79 #define XS_XS_DISABLED 0x0000 /* disabled */
80 #define XS_XS_ACTIVE 0x1000 /* active */
81 #define XS_XS_IDLE 0x2000 /* idle wait */
82 #define XS_XS_STOPPED 0x3000 /* stopped */
83 #define XS_XS_SUSP 0x4000 /* suspend pending */
84 #define XS_XE_MASK 0xf0000 /* transmit errors */
85 #define XS_XE_SHIFT 16
86 #define XS_XE_NOERR 0x00000 /* no error */
87 #define XS_XE_DPE 0x10000 /* descriptor protocol error */
88 #define XS_XE_DFU 0x20000 /* data fifo underrun */
89 #define XS_XE_BEBR 0x30000 /* bus error on buffer read */
90 #define XS_XE_BEDA 0x40000 /* bus error on descriptor access */
91 #define XS_AD_MASK 0xfff00000 /* active descriptor */
92 #define XS_AD_SHIFT 20
94 /* receive channel control */
95 #define RC_RE ((uint32)1 << 0) /* receive enable */
96 #define RC_RO_MASK 0xfe /* receive frame offset */
97 #define RC_RO_SHIFT 1
98 #define RC_FM ((uint32)1 << 8) /* direct fifo receive (pio) mode */
99 #define RC_AE ((uint32)3 << 16) /* address extension bits */
100 #define RC_AE_SHIFT 16
102 /* receive descriptor table pointer */
103 #define RP_LD_MASK 0xfff /* last valid descriptor */
105 /* receive channel status */
106 #define RS_CD_MASK 0x0fff /* current descriptor pointer */
107 #define RS_RS_MASK 0xf000 /* receive state */
108 #define RS_RS_SHIFT 12
109 #define RS_RS_DISABLED 0x0000 /* disabled */
110 #define RS_RS_ACTIVE 0x1000 /* active */
111 #define RS_RS_IDLE 0x2000 /* idle wait */
112 #define RS_RS_STOPPED 0x3000 /* reserved */
113 #define RS_RE_MASK 0xf0000 /* receive errors */
114 #define RS_RE_SHIFT 16
115 #define RS_RE_NOERR 0x00000 /* no error */
116 #define RS_RE_DPE 0x10000 /* descriptor protocol error */
117 #define RS_RE_DFO 0x20000 /* data fifo overflow */
118 #define RS_RE_BEBW 0x30000 /* bus error on buffer write */
119 #define RS_RE_BEDA 0x40000 /* bus error on descriptor access */
120 #define RS_AD_MASK 0xfff00000 /* active descriptor */
121 #define RS_AD_SHIFT 20
123 /* fifoaddr */
124 #define FA_OFF_MASK 0xffff /* offset */
125 #define FA_SEL_MASK 0xf0000 /* select */
126 #define FA_SEL_SHIFT 16
127 #define FA_SEL_XDD 0x00000 /* transmit dma data */
128 #define FA_SEL_XDP 0x10000 /* transmit dma pointers */
129 #define FA_SEL_RDD 0x40000 /* receive dma data */
130 #define FA_SEL_RDP 0x50000 /* receive dma pointers */
131 #define FA_SEL_XFD 0x80000 /* transmit fifo data */
132 #define FA_SEL_XFP 0x90000 /* transmit fifo pointers */
133 #define FA_SEL_RFD 0xc0000 /* receive fifo data */
134 #define FA_SEL_RFP 0xd0000 /* receive fifo pointers */
135 #define FA_SEL_RSD 0xe0000 /* receive frame status data */
136 #define FA_SEL_RSP 0xf0000 /* receive frame status pointers */
138 /* descriptor control flags */
139 #define CTRL_BC_MASK 0x1fff /* buffer byte count */
140 #define CTRL_AE ((uint32)3 << 16) /* address extension bits */
141 #define CTRL_AE_SHIFT 16
142 #define CTRL_EOT ((uint32)1 << 28) /* end of descriptor table */
143 #define CTRL_IOC ((uint32)1 << 29) /* interrupt on completion */
144 #define CTRL_EOF ((uint32)1 << 30) /* end of frame */
145 #define CTRL_SOF ((uint32)1 << 31) /* start of frame */
147 /* control flags in the range [27:20] are core-specific and not defined here */
148 #define CTRL_CORE_MASK 0x0ff00000
150 /* 64 bits addressing */
152 /* dma registers per channel(xmt or rcv) */
153 typedef volatile struct {
154 uint32 control; /* enable, et al */
155 uint32 ptr; /* last descriptor posted to chip */
156 uint32 addrlow; /* descriptor ring base address low 32-bits (8K aligned) */
157 uint32 addrhigh; /* descriptor ring base address bits 63:32 (8K aligned) */
158 uint32 status0; /* current descriptor, xmt state */
159 uint32 status1; /* active descriptor, xmt error */
160 } dma64regs_t;
162 typedef volatile struct {
163 dma64regs_t tx; /* dma64 tx channel */
164 dma64regs_t rx; /* dma64 rx channel */
165 } dma64regp_t;
167 typedef volatile struct { /* diag access */
168 uint32 fifoaddr; /* diag address */
169 uint32 fifodatalow; /* low 32bits of data */
170 uint32 fifodatahigh; /* high 32bits of data */
171 uint32 pad; /* reserved */
172 } dma64diag_t;
175 * DMA Descriptor
176 * Descriptors are only read by the hardware, never written back.
178 typedef volatile struct {
179 uint32 ctrl1; /* misc control bits & bufcount */
180 uint32 ctrl2; /* buffer count and address extension */
181 uint32 addrlow; /* memory address of the date buffer, bits 31:0 */
182 uint32 addrhigh; /* memory address of the date buffer, bits 63:32 */
183 } dma64dd_t;
186 * Each descriptor ring must be 8kB aligned, and fit within a contiguous 8kB physical addresss.
188 #define D64MAXRINGSZ 8192
189 #define D64RINGALIGN 8192
190 #define D64MAXDD (D64MAXRINGSZ / sizeof (dma64dd_t))
192 /* transmit channel control */
193 #define D64_XC_XE 0x00000001 /* transmit enable */
194 #define D64_XC_SE 0x00000002 /* transmit suspend request */
195 #define D64_XC_LE 0x00000004 /* loopback enable */
196 #define D64_XC_FL 0x00000010 /* flush request */
197 #define D64_XC_AE 0x00030000 /* address extension bits */
198 #define D64_XC_AE_SHIFT 16
200 /* transmit descriptor table pointer */
201 #define D64_XP_LD_MASK 0x00000fff /* last valid descriptor */
203 /* transmit channel status */
204 #define D64_XS0_CD_MASK 0x00001fff /* current descriptor pointer */
205 #define D64_XS0_XS_MASK 0xf0000000 /* transmit state */
206 #define D64_XS0_XS_SHIFT 28
207 #define D64_XS0_XS_DISABLED 0x00000000 /* disabled */
208 #define D64_XS0_XS_ACTIVE 0x10000000 /* active */
209 #define D64_XS0_XS_IDLE 0x20000000 /* idle wait */
210 #define D64_XS0_XS_STOPPED 0x30000000 /* stopped */
211 #define D64_XS0_XS_SUSP 0x40000000 /* suspend pending */
213 #define D64_XS1_AD_MASK 0x0001ffff /* active descriptor */
214 #define D64_XS1_XE_MASK 0xf0000000 /* transmit errors */
215 #define D64_XS1_XE_SHIFT 28
216 #define D64_XS1_XE_NOERR 0x00000000 /* no error */
217 #define D64_XS1_XE_DPE 0x10000000 /* descriptor protocol error */
218 #define D64_XS1_XE_DFU 0x20000000 /* data fifo underrun */
219 #define D64_XS1_XE_DTE 0x30000000 /* data transfer error */
220 #define D64_XS1_XE_DESRE 0x40000000 /* descriptor read error */
221 #define D64_XS1_XE_COREE 0x50000000 /* core error */
223 /* receive channel control */
224 #define D64_RC_RE 0x00000001 /* receive enable */
225 #define D64_RC_RO_MASK 0x000000fe /* receive frame offset */
226 #define D64_RC_RO_SHIFT 1
227 #define D64_RC_FM 0x00000100 /* direct fifo receive (pio) mode */
228 #define D64_RC_AE 0x00030000 /* address extension bits */
229 #define D64_RC_AE_SHIFT 16
231 /* receive descriptor table pointer */
232 #define D64_RP_LD_MASK 0x00000fff /* last valid descriptor */
234 /* receive channel status */
235 #define D64_RS0_CD_MASK 0x00001fff /* current descriptor pointer */
236 #define D64_RS0_RS_MASK 0xf0000000 /* receive state */
237 #define D64_RS0_RS_SHIFT 28
238 #define D64_RS0_RS_DISABLED 0x00000000 /* disabled */
239 #define D64_RS0_RS_ACTIVE 0x10000000 /* active */
240 #define D64_RS0_RS_IDLE 0x20000000 /* idle wait */
241 #define D64_RS0_RS_STOPPED 0x30000000 /* stopped */
242 #define D64_RS0_RS_SUSP 0x40000000 /* suspend pending */
244 #define D64_RS1_AD_MASK 0x0001ffff /* active descriptor */
245 #define D64_RS1_RE_MASK 0xf0000000 /* receive errors */
246 #define D64_RS1_RE_SHIFT 28
247 #define D64_RS1_RE_NOERR 0x00000000 /* no error */
248 #define D64_RS1_RE_DPO 0x10000000 /* descriptor protocol error */
249 #define D64_RS1_RE_DFU 0x20000000 /* data fifo overflow */
250 #define D64_RS1_RE_DTE 0x30000000 /* data transfer error */
251 #define D64_RS1_RE_DESRE 0x40000000 /* descriptor read error */
252 #define D64_RS1_RE_COREE 0x50000000 /* core error */
254 /* fifoaddr */
255 #define D64_FA_OFF_MASK 0xffff /* offset */
256 #define D64_FA_SEL_MASK 0xf0000 /* select */
257 #define D64_FA_SEL_SHIFT 16
258 #define D64_FA_SEL_XDD 0x00000 /* transmit dma data */
259 #define D64_FA_SEL_XDP 0x10000 /* transmit dma pointers */
260 #define D64_FA_SEL_RDD 0x40000 /* receive dma data */
261 #define D64_FA_SEL_RDP 0x50000 /* receive dma pointers */
262 #define D64_FA_SEL_XFD 0x80000 /* transmit fifo data */
263 #define D64_FA_SEL_XFP 0x90000 /* transmit fifo pointers */
264 #define D64_FA_SEL_RFD 0xc0000 /* receive fifo data */
265 #define D64_FA_SEL_RFP 0xd0000 /* receive fifo pointers */
266 #define D64_FA_SEL_RSD 0xe0000 /* receive frame status data */
267 #define D64_FA_SEL_RSP 0xf0000 /* receive frame status pointers */
269 /* descriptor control flags 1 */
270 #define D64_CTRL1_EOT ((uint32)1 << 28) /* end of descriptor table */
271 #define D64_CTRL1_IOC ((uint32)1 << 29) /* interrupt on completion */
272 #define D64_CTRL1_EOF ((uint32)1 << 30) /* end of frame */
273 #define D64_CTRL1_SOF ((uint32)1 << 31) /* start of frame */
275 /* descriptor control flags 2 */
276 #define D64_CTRL2_BC_MASK 0x00007fff /* buffer byte count mask */
277 #define D64_CTRL2_AE 0x00030000 /* address extension bits */
278 #define D64_CTRL2_AE_SHIFT 16
280 /* control flags in the range [27:20] are core-specific and not defined here */
281 #define D64_CTRL_CORE_MASK 0x0ff00000
284 #endif /* _sbhnddma_h_ */