xref: /openbmc/u-boot/drivers/dma/MCD_tasksInit.c (revision 1e52fea3)
1 /*
2  * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
3  *
4  * See file CREDITS for list of people who contributed to this
5  * project.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20  * MA 02111-1307 USA
21  */
22 
23 #include <common.h>
24 
25 /* Functions for initializing variable tables of different types of tasks. */
26 
27 /*
28  * Do not edit!
29  */
30 
31 #include <MCD_dma.h>
32 
33 extern dmaRegs *MCD_dmaBar;
34 
35 /* Task 0 */
36 
37 void MCD_startDmaChainNoEu(int *currBD, short srcIncr, short destIncr,
38 			   int xferSize, short xferSizeIncr, int *cSave,
39 			   volatile TaskTableEntry * taskTable, int channel)
40 {
41 	volatile TaskTableEntry *taskChan = taskTable + channel;
42 
43 	MCD_SET_VAR(taskChan, 2, (u32) currBD);	/* var[2] */
44 	MCD_SET_VAR(taskChan, 25, (u32) (0xe000 << 16) | (0xffff & srcIncr));	/* inc[1] */
45 	MCD_SET_VAR(taskChan, 24, (u32) (0xe000 << 16) | (0xffff & destIncr));	/* inc[0] */
46 	MCD_SET_VAR(taskChan, 11, (u32) xferSize);	/* var[11] */
47 	MCD_SET_VAR(taskChan, 26, (u32) (0x2000 << 16) | (0xffff & xferSizeIncr));	/* inc[2] */
48 	MCD_SET_VAR(taskChan, 0, (u32) cSave);	/* var[0] */
49 	MCD_SET_VAR(taskChan, 1, (u32) 0x00000000);	/* var[1] */
50 	MCD_SET_VAR(taskChan, 3, (u32) 0x00000000);	/* var[3] */
51 	MCD_SET_VAR(taskChan, 4, (u32) 0x00000000);	/* var[4] */
52 	MCD_SET_VAR(taskChan, 5, (u32) 0x00000000);	/* var[5] */
53 	MCD_SET_VAR(taskChan, 6, (u32) 0x00000000);	/* var[6] */
54 	MCD_SET_VAR(taskChan, 7, (u32) 0x00000000);	/* var[7] */
55 	MCD_SET_VAR(taskChan, 8, (u32) 0x00000000);	/* var[8] */
56 	MCD_SET_VAR(taskChan, 9, (u32) 0x00000000);	/* var[9] */
57 	MCD_SET_VAR(taskChan, 10, (u32) 0x00000000);	/* var[10] */
58 	MCD_SET_VAR(taskChan, 12, (u32) 0x00000000);	/* var[12] */
59 	MCD_SET_VAR(taskChan, 13, (u32) 0x80000000);	/* var[13] */
60 	MCD_SET_VAR(taskChan, 14, (u32) 0x00000010);	/* var[14] */
61 	MCD_SET_VAR(taskChan, 15, (u32) 0x00000004);	/* var[15] */
62 	MCD_SET_VAR(taskChan, 16, (u32) 0x08000000);	/* var[16] */
63 	MCD_SET_VAR(taskChan, 27, (u32) 0x00000000);	/* inc[3] */
64 	MCD_SET_VAR(taskChan, 28, (u32) 0x80000000);	/* inc[4] */
65 	MCD_SET_VAR(taskChan, 29, (u32) 0x80000001);	/* inc[5] */
66 	MCD_SET_VAR(taskChan, 30, (u32) 0x40000000);	/* inc[6] */
67 
68 	/* Set the task's Enable bit in its Task Control Register */
69 	MCD_dmaBar->taskControl[channel] |= (u16) 0x8000;
70 }
71 
72 /* Task 1 */
73 
74 void MCD_startDmaSingleNoEu(char *srcAddr, short srcIncr, char *destAddr,
75 			    short destIncr, int dmaSize, short xferSizeIncr,
76 			    int flags, int *currBD, int *cSave,
77 			    volatile TaskTableEntry * taskTable, int channel)
78 {
79 	volatile TaskTableEntry *taskChan = taskTable + channel;
80 
81 	MCD_SET_VAR(taskChan, 7, (u32) srcAddr);	/* var[7] */
82 	MCD_SET_VAR(taskChan, 25, (u32) (0xe000 << 16) | (0xffff & srcIncr));	/* inc[1] */
83 	MCD_SET_VAR(taskChan, 2, (u32) destAddr);	/* var[2] */
84 	MCD_SET_VAR(taskChan, 24, (u32) (0xe000 << 16) | (0xffff & destIncr));	/* inc[0] */
85 	MCD_SET_VAR(taskChan, 3, (u32) dmaSize);	/* var[3] */
86 	MCD_SET_VAR(taskChan, 26, (u32) (0x2000 << 16) | (0xffff & xferSizeIncr));	/* inc[2] */
87 	MCD_SET_VAR(taskChan, 5, (u32) flags);	/* var[5] */
88 	MCD_SET_VAR(taskChan, 1, (u32) currBD);	/* var[1] */
89 	MCD_SET_VAR(taskChan, 0, (u32) cSave);	/* var[0] */
90 	MCD_SET_VAR(taskChan, 4, (u32) 0x00000000);	/* var[4] */
91 	MCD_SET_VAR(taskChan, 6, (u32) 0x00000000);	/* var[6] */
92 	MCD_SET_VAR(taskChan, 8, (u32) 0x00000000);	/* var[8] */
93 	MCD_SET_VAR(taskChan, 9, (u32) 0x00000004);	/* var[9] */
94 	MCD_SET_VAR(taskChan, 10, (u32) 0x08000000);	/* var[10] */
95 	MCD_SET_VAR(taskChan, 27, (u32) 0x00000000);	/* inc[3] */
96 	MCD_SET_VAR(taskChan, 28, (u32) 0x80000001);	/* inc[4] */
97 	MCD_SET_VAR(taskChan, 29, (u32) 0x40000000);	/* inc[5] */
98 
99 	/* Set the task's Enable bit in its Task Control Register */
100 	MCD_dmaBar->taskControl[channel] |= (u16) 0x8000;
101 }
102 
103 /* Task 2 */
104 
105 void MCD_startDmaChainEu(int *currBD, short srcIncr, short destIncr,
106 			 int xferSize, short xferSizeIncr, int *cSave,
107 			 volatile TaskTableEntry * taskTable, int channel)
108 {
109 	volatile TaskTableEntry *taskChan = taskTable + channel;
110 
111 	MCD_SET_VAR(taskChan, 3, (u32) currBD);	/* var[3] */
112 	MCD_SET_VAR(taskChan, 25, (u32) (0xe000 << 16) | (0xffff & srcIncr));	/* inc[1] */
113 	MCD_SET_VAR(taskChan, 24, (u32) (0xe000 << 16) | (0xffff & destIncr));	/* inc[0] */
114 	MCD_SET_VAR(taskChan, 12, (u32) xferSize);	/* var[12] */
115 	MCD_SET_VAR(taskChan, 26, (u32) (0x2000 << 16) | (0xffff & xferSizeIncr));	/* inc[2] */
116 	MCD_SET_VAR(taskChan, 0, (u32) cSave);	/* var[0] */
117 	MCD_SET_VAR(taskChan, 1, (u32) 0x00000000);	/* var[1] */
118 	MCD_SET_VAR(taskChan, 2, (u32) 0x00000000);	/* var[2] */
119 	MCD_SET_VAR(taskChan, 4, (u32) 0x00000000);	/* var[4] */
120 	MCD_SET_VAR(taskChan, 5, (u32) 0x00000000);	/* var[5] */
121 	MCD_SET_VAR(taskChan, 6, (u32) 0x00000000);	/* var[6] */
122 	MCD_SET_VAR(taskChan, 7, (u32) 0x00000000);	/* var[7] */
123 	MCD_SET_VAR(taskChan, 8, (u32) 0x00000000);	/* var[8] */
124 	MCD_SET_VAR(taskChan, 9, (u32) 0x00000000);	/* var[9] */
125 	MCD_SET_VAR(taskChan, 10, (u32) 0x00000000);	/* var[10] */
126 	MCD_SET_VAR(taskChan, 11, (u32) 0x00000000);	/* var[11] */
127 	MCD_SET_VAR(taskChan, 13, (u32) 0x00000000);	/* var[13] */
128 	MCD_SET_VAR(taskChan, 14, (u32) 0x80000000);	/* var[14] */
129 	MCD_SET_VAR(taskChan, 15, (u32) 0x00000010);	/* var[15] */
130 	MCD_SET_VAR(taskChan, 16, (u32) 0x00000001);	/* var[16] */
131 	MCD_SET_VAR(taskChan, 17, (u32) 0x00000004);	/* var[17] */
132 	MCD_SET_VAR(taskChan, 18, (u32) 0x08000000);	/* var[18] */
133 	MCD_SET_VAR(taskChan, 27, (u32) 0x00000000);	/* inc[3] */
134 	MCD_SET_VAR(taskChan, 28, (u32) 0x80000000);	/* inc[4] */
135 	MCD_SET_VAR(taskChan, 29, (u32) 0xc0000000);	/* inc[5] */
136 	MCD_SET_VAR(taskChan, 30, (u32) 0x80000001);	/* inc[6] */
137 	MCD_SET_VAR(taskChan, 31, (u32) 0x40000000);	/* inc[7] */
138 
139 	/* Set the task's Enable bit in its Task Control Register */
140 	MCD_dmaBar->taskControl[channel] |= (u16) 0x8000;
141 }
142 
143 /* Task 3 */
144 
145 void MCD_startDmaSingleEu(char *srcAddr, short srcIncr, char *destAddr,
146 			  short destIncr, int dmaSize, short xferSizeIncr,
147 			  int flags, int *currBD, int *cSave,
148 			  volatile TaskTableEntry * taskTable, int channel)
149 {
150 	volatile TaskTableEntry *taskChan = taskTable + channel;
151 
152 	MCD_SET_VAR(taskChan, 8, (u32) srcAddr);	/* var[8] */
153 	MCD_SET_VAR(taskChan, 25, (u32) (0xe000 << 16) | (0xffff & srcIncr));	/* inc[1] */
154 	MCD_SET_VAR(taskChan, 3, (u32) destAddr);	/* var[3] */
155 	MCD_SET_VAR(taskChan, 24, (u32) (0xe000 << 16) | (0xffff & destIncr));	/* inc[0] */
156 	MCD_SET_VAR(taskChan, 4, (u32) dmaSize);	/* var[4] */
157 	MCD_SET_VAR(taskChan, 26, (u32) (0x2000 << 16) | (0xffff & xferSizeIncr));	/* inc[2] */
158 	MCD_SET_VAR(taskChan, 6, (u32) flags);	/* var[6] */
159 	MCD_SET_VAR(taskChan, 2, (u32) currBD);	/* var[2] */
160 	MCD_SET_VAR(taskChan, 0, (u32) cSave);	/* var[0] */
161 	MCD_SET_VAR(taskChan, 1, (u32) 0x00000000);	/* var[1] */
162 	MCD_SET_VAR(taskChan, 5, (u32) 0x00000000);	/* var[5] */
163 	MCD_SET_VAR(taskChan, 7, (u32) 0x00000000);	/* var[7] */
164 	MCD_SET_VAR(taskChan, 9, (u32) 0x00000000);	/* var[9] */
165 	MCD_SET_VAR(taskChan, 10, (u32) 0x00000001);	/* var[10] */
166 	MCD_SET_VAR(taskChan, 11, (u32) 0x00000004);	/* var[11] */
167 	MCD_SET_VAR(taskChan, 12, (u32) 0x08000000);	/* var[12] */
168 	MCD_SET_VAR(taskChan, 27, (u32) 0x00000000);	/* inc[3] */
169 	MCD_SET_VAR(taskChan, 28, (u32) 0xc0000000);	/* inc[4] */
170 	MCD_SET_VAR(taskChan, 29, (u32) 0x80000000);	/* inc[5] */
171 	MCD_SET_VAR(taskChan, 30, (u32) 0x80000001);	/* inc[6] */
172 	MCD_SET_VAR(taskChan, 31, (u32) 0x40000000);	/* inc[7] */
173 
174 	/* Set the task's Enable bit in its Task Control Register */
175 	MCD_dmaBar->taskControl[channel] |= (u16) 0x8000;
176 }
177 
178 /* Task 4 */
179 
180 void MCD_startDmaENetRcv(char *bDBase, char *currBD, char *rcvFifoPtr,
181 			 volatile TaskTableEntry * taskTable, int channel)
182 {
183 	volatile TaskTableEntry *taskChan = taskTable + channel;
184 
185 	MCD_SET_VAR(taskChan, 0, (u32) bDBase);	/* var[0] */
186 	MCD_SET_VAR(taskChan, 3, (u32) currBD);	/* var[3] */
187 	MCD_SET_VAR(taskChan, 6, (u32) rcvFifoPtr);	/* var[6] */
188 	MCD_SET_VAR(taskChan, 1, (u32) 0x00000000);	/* var[1] */
189 	MCD_SET_VAR(taskChan, 2, (u32) 0x00000000);	/* var[2] */
190 	MCD_SET_VAR(taskChan, 4, (u32) 0x00000000);	/* var[4] */
191 	MCD_SET_VAR(taskChan, 5, (u32) 0x00000000);	/* var[5] */
192 	MCD_SET_VAR(taskChan, 7, (u32) 0x00000000);	/* var[7] */
193 	MCD_SET_VAR(taskChan, 8, (u32) 0x00000000);	/* var[8] */
194 	MCD_SET_VAR(taskChan, 9, (u32) 0x0000ffff);	/* var[9] */
195 	MCD_SET_VAR(taskChan, 10, (u32) 0x30000000);	/* var[10] */
196 	MCD_SET_VAR(taskChan, 11, (u32) 0x0fffffff);	/* var[11] */
197 	MCD_SET_VAR(taskChan, 12, (u32) 0x00000008);	/* var[12] */
198 	MCD_SET_VAR(taskChan, 24, (u32) 0x00000000);	/* inc[0] */
199 	MCD_SET_VAR(taskChan, 25, (u32) 0x60000000);	/* inc[1] */
200 	MCD_SET_VAR(taskChan, 26, (u32) 0x20000004);	/* inc[2] */
201 	MCD_SET_VAR(taskChan, 27, (u32) 0x40000000);	/* inc[3] */
202 
203 	/* Set the task's Enable bit in its Task Control Register */
204 	MCD_dmaBar->taskControl[channel] |= (u16) 0x8000;
205 }
206 
207 /* Task 5 */
208 
209 void MCD_startDmaENetXmit(char *bDBase, char *currBD, char *xmitFifoPtr,
210 			  volatile TaskTableEntry * taskTable, int channel)
211 {
212 	volatile TaskTableEntry *taskChan = taskTable + channel;
213 
214 	MCD_SET_VAR(taskChan, 0, (u32) bDBase);	/* var[0] */
215 	MCD_SET_VAR(taskChan, 3, (u32) currBD);	/* var[3] */
216 	MCD_SET_VAR(taskChan, 11, (u32) xmitFifoPtr);	/* var[11] */
217 	MCD_SET_VAR(taskChan, 1, (u32) 0x00000000);	/* var[1] */
218 	MCD_SET_VAR(taskChan, 2, (u32) 0x00000000);	/* var[2] */
219 	MCD_SET_VAR(taskChan, 4, (u32) 0x00000000);	/* var[4] */
220 	MCD_SET_VAR(taskChan, 5, (u32) 0x00000000);	/* var[5] */
221 	MCD_SET_VAR(taskChan, 6, (u32) 0x00000000);	/* var[6] */
222 	MCD_SET_VAR(taskChan, 7, (u32) 0x00000000);	/* var[7] */
223 	MCD_SET_VAR(taskChan, 8, (u32) 0x00000000);	/* var[8] */
224 	MCD_SET_VAR(taskChan, 9, (u32) 0x00000000);	/* var[9] */
225 	MCD_SET_VAR(taskChan, 10, (u32) 0x00000000);	/* var[10] */
226 	MCD_SET_VAR(taskChan, 12, (u32) 0x00000000);	/* var[12] */
227 	MCD_SET_VAR(taskChan, 13, (u32) 0x0000ffff);	/* var[13] */
228 	MCD_SET_VAR(taskChan, 14, (u32) 0xffffffff);	/* var[14] */
229 	MCD_SET_VAR(taskChan, 15, (u32) 0x00000004);	/* var[15] */
230 	MCD_SET_VAR(taskChan, 16, (u32) 0x00000008);	/* var[16] */
231 	MCD_SET_VAR(taskChan, 24, (u32) 0x00000000);	/* inc[0] */
232 	MCD_SET_VAR(taskChan, 25, (u32) 0x60000000);	/* inc[1] */
233 	MCD_SET_VAR(taskChan, 26, (u32) 0x40000000);	/* inc[2] */
234 	MCD_SET_VAR(taskChan, 27, (u32) 0xc000fffc);	/* inc[3] */
235 	MCD_SET_VAR(taskChan, 28, (u32) 0xe0000004);	/* inc[4] */
236 	MCD_SET_VAR(taskChan, 29, (u32) 0x80000000);	/* inc[5] */
237 	MCD_SET_VAR(taskChan, 30, (u32) 0x4000ffff);	/* inc[6] */
238 	MCD_SET_VAR(taskChan, 31, (u32) 0xe0000001);	/* inc[7] */
239 
240 	/* Set the task's Enable bit in its Task Control Register */
241 	MCD_dmaBar->taskControl[channel] |= (u16) 0x8000;
242 }
243