Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
/*	$NetBSD: tx39biureg.h,v 1.6 2008/04/28 20:23:21 martin Exp $ */

/*-
 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by UCHIYAMA Yasushi.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
/*
 * Toshiba TX3912/3922 BIU module (Bus Interface Unit)
 */

/*
 * System Address Map
 */
#define TX39_SYSADDR_DRAMBANK0CS1	0x00000000
#define TX39_SYSADDR_DRAMBANK1CS1	0x02000000
#define TX39_SYSADDR_DRAMBANK0		0x04000000
#define TX39_SYSADDR_DRAMBANK1		0x06000000
#define TX39_SYSADDR_DRAMBANK_LEN	0x02000000

#define TX39_SYSADDR_CARD1		0x08000000
#define TX39_SYSADDR_CARD2		0x0C000000
/* 64MByte */
#define TX39_SYSADDR_CARD_SIZE		0x04000000 

#define TX39_SYSADDR_CS1		0x10000000
#define TX39_SYSADDR_CS2		0x10400000
#define TX39_SYSADDR_CS3		0x10800000
/* 4MByte */
#define TX39_SYSADDR_CS_SIZE		0x00400000

#define TX39_SYSADDR_CONFIG_REG		0x10c00000
#define TX39_SYSADDR_CONFIG_REG_LEN	0x00200000

#define TX39_SYSADDR_SDRAMBANK0MODE_REG	0x10e00000
#define TX39_SYSADDR_SDRAMBANK1MODE_REG	0x10f00000
#define TX39_SYSADDR_CS0		0x11000000
#define TX39_SYSADDR_KUSEG_DRAMBANK0CS1	0x40000000
#define TX39_SYSADDR_KUSEG_DRAMBANK1CS1	0x42000000
#define TX39_SYSADDR_KUSEG_DRAMBANK0	0x44000000
#define TX39_SYSADDR_KUSEG_DRAMBANK1	0x46000000
#define TX39_SYSADDR_KUSEG_CS0		0x50000000
#define TX39_SYSADDR_KUSEG_CS1		0x58000000
#define TX39_SYSADDR_KUSEG_CS2		0x5c000000
#define TX39_SYSADDR_KUSEG_CS3		0x60000000
/* 64MByte */
#define TX39_SYSADDR_KUCS_SIZE		0x04000000

#define TX39_SYSADDR_CARD1MEM		0x64000000
#define TX39_SYSADDR_CARD2MEM		0x68000000
#define TX39_SYSADDR_MCS0		0x6c000000
#define TX39_SYSADDR_MCS1		0x70000000
#ifdef TX391X
#define TX39_SYSADDR_MCS2		0x74000000
#define TX39_SYSADDR_MCS3		0x78000000
#endif /* TX391X */
/* 64MByte */
#define TX39_SYSADDR_MCS_SIZE		0x04000000

/*
 *	BIU module registers.
 */
#define TX39_MEMCONFIG0_REG		0x00
#define TX39_MEMCONFIG1_REG		0x04
#define TX39_MEMCONFIG2_REG		0x08
#define TX39_MEMCONFIG3_REG		0x0C
#define TX39_MEMCONFIG4_REG		0x10
#define TX39_MEMCONFIG5_REG		0x14
#define TX39_MEMCONFIG6_REG		0x18
#define TX39_MEMCONFIG7_REG		0x1C
#define TX39_MEMCONFIG8_REG		0x20

/*
 *	Memory Configuration 0 Register
 */
/* R/W */
#define TX39_MEMCONFIG0_ENDCLKOUTTRI	0x40000000
#define TX39_MEMCONFIG0_DISDQMINIT	0x20000000
#define TX39_MEMCONFIG0_ENSDRAMPD	0x10000000
#define TX39_MEMCONFIG0_SHOWDINO	0x08000000
#define TX39_MEMCONFIG0_ENRMAP2		0x04000000
#define TX39_MEMCONFIG0_ENRMAP1		0x02000000
#define TX39_MEMCONFIG0_ENWRINPAGE	0x01000000
#define TX39_MEMCONFIG0_ENCS3USER	0x00800000
#define TX39_MEMCONFIG0_ENCS2USER	0x00400000
#define TX39_MEMCONFIG0_ENCS1USER	0x00200000
#define TX39_MEMCONFIG0_ENCS1DRAM	0x00100000

#define TX39_MEMCONFIG0_BANK1CONF_SHIFT 18
#define TX39_MEMCONFIG0_BANK1CONF_MASK	0x3
#define TX39_MEMCONFIG0_BANK1CONF(cr)					\
	(((cr) >> TX39_MEMCONFIG0_BANK1CONF_SHIFT) &			\
	TX39_MEMCONFIG0_BANK1CONF_MASK)
#define TX39_MEMCONFIG0_BANK1CONF_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG0_BANK1CONF_SHIFT) &		\
	(TX39_MEMCONFIG0_BANK1CONF_MASK << TX39_MEMCONFIG0_BANK1CONF_SHIFT)))
#define TX39_MEMCONFIG0_BANK0CONF_SHIFT 16
#define TX39_MEMCONFIG0_BANK0CONF_MASK	0x3
#define TX39_MEMCONFIG0_BANK0CONF(cr)					\
	(((cr) >> TX39_MEMCONFIG0_BANK0CONF_SHIFT) &			\
	TX39_MEMCONFIG0_BANK0CONF_MASK)
#define TX39_MEMCONFIG0_BANK0CONF_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG0_BANK0CONF_SHIFT) &		\
	(TX39_MEMCONFIG0_BANK0CONF_MASK << TX39_MEMCONFIG0_BANK0CONF_SHIFT)))
#define TX39_MEMCONFIG0_BANKCONF_16BITSDRAM	0x3
#define TX39_MEMCONFIG0_BANKCONF_8BITSDRAM	0x2
#define TX39_MEMCONFIG0_BANKCONF_32BITSDHDRAM	0x1
#define TX39_MEMCONFIG0_BANKCONF_16BITSDHDRAM	0x0

#define TX39_MEMCONFIG0_ROWSEL1_SHIFT 14
#define TX39_MEMCONFIG0_ROWSEL1_MASK	0x3
#define TX39_MEMCONFIG0_ROWSEL1(cr)					\
	(((cr) >> TX39_MEMCONFIG0_ROWSEL1_SHIFT) &			\
	TX39_MEMCONFIG0_ROWSEL1_MASK)
#define TX39_MEMCONFIG0_ROWSEL1_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG0_ROWSEL1_SHIFT) &		\
	(TX39_MEMCONFIG0_ROWSEL1_MASK << TX39_MEMCONFIG0_ROWSEL1_SHIFT)))
#define TX39_MEMCONFIG0_ROWSEL0_SHIFT 12
#define TX39_MEMCONFIG0_ROWSEL0_MASK	0x3
#define TX39_MEMCONFIG0_ROWSEL0(cr)					\
	(((cr) >> TX39_MEMCONFIG0_ROWSEL0_SHIFT) &			\
	TX39_MEMCONFIG0_ROWSEL0_MASK)
#define TX39_MEMCONFIG0_ROWSEL0_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG0_ROWSEL0_SHIFT) &		\
	(TX39_MEMCONFIG0_ROWSEL0_MASK << TX39_MEMCONFIG0_ROWSEL0_SHIFT)))

#define TX39_MEMCONFIG0_COLSEL1_SHIFT 8
#define TX39_MEMCONFIG0_COLSEL1_MASK	0xf
#define TX39_MEMCONFIG0_COLSEL1(cr)					\
	(((cr) >> TX39_MEMCONFIG0_COLSEL1_SHIFT) &			\
	TX39_MEMCONFIG0_COLSEL1_MASK)
#define TX39_MEMCONFIG0_COLSEL1_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG0_COLSEL1_SHIFT) &		\
	(TX39_MEMCONFIG0_COLSEL1_MASK << TX39_MEMCONFIG0_COLSEL1_SHIFT)))
#define TX39_MEMCONFIG0_COLSEL0_SHIFT 4
#define TX39_MEMCONFIG0_COLSEL0_MASK	0xf
#define TX39_MEMCONFIG0_COLSEL0(cr)					\
	(((cr) >> TX39_MEMCONFIG0_COLSEL0_SHIFT) &			\
	TX39_MEMCONFIG0_COLSEL0_MASK)
#define TX39_MEMCONFIG0_COLSEL0_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG0_COLSEL0_SHIFT) &		\
	(TX39_MEMCONFIG0_COLSEL0_MASK << TX39_MEMCONFIG0_COLSEL0_SHIFT)))

#define TX39_MEMCONFIG0_CS3SIZE		0x00000008
#define TX39_MEMCONFIG0_CS2SIZE		0x00000004
#define TX39_MEMCONFIG0_CS1SIZE		0x00000002
#define TX39_MEMCONFIG0_CS0SIZE		0x00000001

/*
 *	Memory Configuration 1 Register
 */
#ifdef TX391X
#define TX39_MEMCONFIG1_MCS3ACCVAL1_SHIFT	28
#define TX39_MEMCONFIG1_MCS3ACCVAL1_MASK	0xf
#define TX39_MEMCONFIG1_MCS3ACCVAL1(cr)					\
	(((cr) >> TX39_MEMCONFIG1_MCS3ACCVAL1_SHIFT) &			\
	TX39_MEMCONFIG1_MCS3ACCVAL1_MASK)
#define TX39_MEMCONFIG1_MCS3ACCVAL1_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG1_MCS3ACCVAL1_SHIFT) &		\
	(TX39_MEMCONFIG1_MCS3ACCVAL1_MASK <<				\
	TX39_MEMCONFIG1_MCS3ACCVAL1_SHIFT)))

#define TX39_MEMCONFIG1_MCS3ACCVAL2_SHIFT	24
#define TX39_MEMCONFIG1_MCS3ACCVAL2_MASK	0xf
#define TX39_MEMCONFIG1_MCS3ACCVAL2(cr)					\
	(((cr) >> TX39_MEMCONFIG1_MCS3ACCVAL2_SHIFT) &			\
	TX39_MEMCONFIG1_MCS3ACCVAL2_MASK)
#define TX39_MEMCONFIG1_MCS3ACCVAL2_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG1_MCS3ACCVAL2_SHIFT) &		\
	(TX39_MEMCONFIG1_MCS3ACCVAL2_MASK <<				\
	TX39_MEMCONFIG1_MCS3ACCVAL2_SHIFT)))

#define TX39_MEMCONFIG1_MCS2ACCVAL1_SHIFT	20
#define TX39_MEMCONFIG1_MCS2ACCVAL1_MASK	0xf
#define TX39_MEMCONFIG1_MCS2ACCVAL1(cr)					\
	(((cr) >> TX39_MEMCONFIG1_MCS2ACCVAL1_SHIFT) &			\
	TX39_MEMCONFIG1_MCS2ACCVAL1_MASK)
#define TX39_MEMCONFIG1_MCS2ACCVAL1_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG1_MCS2ACCVAL1_SHIFT) &		\
	(TX39_MEMCONFIG1_MCS2ACCVAL1_MASK <<				\
	TX39_MEMCONFIG1_MCS2ACCVAL1_SHIFT)))

#define TX39_MEMCONFIG1_MCS2ACCVAL2_SHIFT	16
#define TX39_MEMCONFIG1_MCS2ACCVAL2_MASK	0xf
#define TX39_MEMCONFIG1_MCS2ACCVAL2(cr)					\
	(((cr) >> TX39_MEMCONFIG1_MCS2ACCVAL2_SHIFT) &			\
	TX39_MEMCONFIG1_MCS2ACCVAL2_MASK)
#define TX39_MEMCONFIG1_MCS2ACCVAL2_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG1_MCS2ACCVAL2_SHIFT) &		\
	(TX39_MEMCONFIG1_MCS2ACCVAL2_MASK <<				\
	TX39_MEMCONFIG1_MCS2ACCVAL2_SHIFT)))
#endif /* TX391X */
#ifdef TX392X
#define	TX39_MEMCONFIG1_C48MPLLON	0x40000000
#define	TX39_MEMCONFIG1_ENMCS1BE	0x20000000
#define	TX39_MEMCONFIG1_ENMCS0BE	0x10000000
#define	TX39_MEMCONFIG1_ENMCS1ACC	0x08000000
#define	TX39_MEMCONFIG1_ENMCS0ACC	0x04000000
#define TX39_MEMCONFIG1_BCLKDIV_SHIFT	23
#define TX39_MEMCONFIG1_BCLKDIV_MASK	0x7
#define TX39_MEMCONFIG1_BCLKDIV(cr)					\
	(((cr) >> TX39_MEMCONFIG1_BCLKDIV_SHIFT) &			\
	TX39_MEMCONFIG1_BCLKDIV_MASK)
#define TX39_MEMCONFIG1_BCLKDIV_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG1_BCLKDIV_SHIFT) &		\
	(TX39_MEMCONFIG1_BCLKDIV_MASK << TX39_MEMCONFIG1_BCLKDIV_SHIFT)))
#define	TX39_MEMCONFIG1_ENBCLK		0x00400000
#define	TX39_MEMCONFIG1_ENMCS1PAGE	0x00200000
#define	TX39_MEMCONFIG1_ENMCS0PAGE	0x00100000
#define	TX39_MEMCONFIG1_ENMCS1WAIT	0x00080000
#define	TX39_MEMCONFIG1_ENMCS0WAIT	0x00040000
#define	TX39_MEMCONFIG1_MCS1_32		0x00020000
#define	TX39_MEMCONFIG1_MCS0_32		0x00010000
#endif /* TX392X */

#define TX39_MEMCONFIG1_MCS1ACCVAL1_SHIFT	12
#define TX39_MEMCONFIG1_MCS1ACCVAL1_MASK	0xf
#define TX39_MEMCONFIG1_MCS1ACCVAL1(cr)					\
	(((cr) >> TX39_MEMCONFIG1_MCS1ACCVAL1_SHIFT) &			\
	TX39_MEMCONFIG1_MCS1ACCVAL1_MASK)
#define TX39_MEMCONFIG1_MCS1ACCVAL1_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG1_MCS1ACCVAL1_SHIFT) &		\
	(TX39_MEMCONFIG1_MCS1ACCVAL1_MASK <<				\
	TX39_MEMCONFIG1_MCS1ACCVAL1_SHIFT)))

#define TX39_MEMCONFIG1_MCS1ACCVAL2_SHIFT	8
#define TX39_MEMCONFIG1_MCS1ACCVAL2_MASK	0xf
#define TX39_MEMCONFIG1_MCS1ACCVAL2(cr)					\
	(((cr) >> TX39_MEMCONFIG1_MCS1ACCVAL2_SHIFT) &			\
	TX39_MEMCONFIG1_MCS1ACCVAL2_MASK)
#define TX39_MEMCONFIG1_MCS1ACCVAL2_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG1_MCS1ACCVAL2_SHIFT) &		\
	(TX39_MEMCONFIG1_MCS1ACCVAL2_MASK <<				\
	TX39_MEMCONFIG1_MCS1ACCVAL2_SHIFT)))

#define TX39_MEMCONFIG1_MCS0ACCVAL1_SHIFT	4
#define TX39_MEMCONFIG1_MCS0ACCVAL1_MASK	0xf
#define TX39_MEMCONFIG1_MCS0ACCVAL1(cr)					\
	(((cr) >> TX39_MEMCONFIG1_MCS0ACCVAL1_SHIFT) &			\
	TX39_MEMCONFIG1_MCS0ACCVAL1_MASK)
#define TX39_MEMCONFIG1_MCS0ACCVAL1_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG1_MCS0ACCVAL1_SHIFT) &		\
	(TX39_MEMCONFIG1_MCS0ACCVAL1_MASK <<				\
	TX39_MEMCONFIG1_MCS0ACCVAL1_SHIFT)))

#define TX39_MEMCONFIG1_MCS0ACCVAL2_SHIFT	0
#define TX39_MEMCONFIG1_MCS0ACCVAL2_MASK	0xf
#define TX39_MEMCONFIG1_MCS0ACCVAL2(cr)					\
	(((cr) >> TX39_MEMCONFIG1_MCS0ACCVAL2_SHIFT) &			\
	TX39_MEMCONFIG1_MCS0ACCVAL2_MASK)
#define TX39_MEMCONFIG1_MCS0ACCVAL2_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG1_MCS0ACCVAL2_SHIFT) &		\
	(TX39_MEMCONFIG1_MCS0ACCVAL2_MASK <<				\
	TX39_MEMCONFIG1_MCS0ACCVAL2_SHIFT)))

/*
 *	Memory Configuration 2 Register
 */
/* Define access timing. not required yet */
#define TX39_MEMCONFIG2_CS3ACCVAL1_SHIFT	28
#define TX39_MEMCONFIG2_CS3ACCVAL1_MASK		0xf
#define TX39_MEMCONFIG2_CS3ACCVAL1(cr)					\
	(((cr) >> TX39_MEMCONFIG2_CS3ACCVAL1_SHIFT) &			\
	TX39_MEMCONFIG2_CS3ACCVAL1_MASK)
#define TX39_MEMCONFIG2_CS3ACCVAL1_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG2_CS3ACCVAL1_SHIFT) &		\
	(TX39_MEMCONFIG2_CS3ACCVAL1_MASK << TX39_MEMCONFIG2_CS3ACCVAL1_SHIFT)))

#define TX39_MEMCONFIG2_CS3ACCVAL2_SHIFT	24
#define TX39_MEMCONFIG2_CS3ACCVAL2_MASK		0xf
#define TX39_MEMCONFIG2_CS3ACCVAL2(cr)					\
	(((cr) >> TX39_MEMCONFIG2_CS3ACCVAL2_SHIFT) &			\
	TX39_MEMCONFIG2_CS3ACCVAL2_MASK)
#define TX39_MEMCONFIG2_CS3ACCVAL2_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG2_CS3ACCVAL2_SHIFT) &		\
	(TX39_MEMCONFIG2_CS3ACCVAL2_MASK << TX39_MEMCONFIG2_CS3ACCVAL2_SHIFT)))

#define TX39_MEMCONFIG2_CS2ACCVAL1_SHIFT	20
#define TX39_MEMCONFIG2_CS2ACCVAL1_MASK		0xf
#define TX39_MEMCONFIG2_CS2ACCVAL1(cr)					\
	(((cr) >> TX39_MEMCONFIG2_CS2ACCVAL1_SHIFT) &			\
	TX39_MEMCONFIG2_CS2ACCVAL1_MASK)
#define TX39_MEMCONFIG2_CS2ACCVAL1_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG2_CS2ACCVAL1_SHIFT) &		\
	(TX39_MEMCONFIG2_CS2ACCVAL1_MASK << TX39_MEMCONFIG2_CS2ACCVAL1_SHIFT)))

#define TX39_MEMCONFIG2_CS2ACCVAL2_SHIFT	16
#define TX39_MEMCONFIG2_CS2ACCVAL2_MASK		0xf
#define TX39_MEMCONFIG2_CS2ACCVAL2(cr)					\
	(((cr) >> TX39_MEMCONFIG2_CS2ACCVAL2_SHIFT) &			\
	TX39_MEMCONFIG2_CS2ACCVAL2_MASK)
#define TX39_MEMCONFIG2_CS2ACCVAL2_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG2_CS2ACCVAL2_SHIFT) &		\
	(TX39_MEMCONFIG2_CS2ACCVAL2_MASK << TX39_MEMCONFIG2_CS2ACCVAL2_SHIFT)))

#define TX39_MEMCONFIG2_CS1ACCVAL1_SHIFT	12
#define TX39_MEMCONFIG2_CS1ACCVAL1_MASK		0xf
#define TX39_MEMCONFIG2_CS1ACCVAL1(cr)					\
	(((cr) >> TX39_MEMCONFIG2_CS1ACCVAL1_SHIFT) &			\
	TX39_MEMCONFIG2_CS1ACCVAL1_MASK)
#define TX39_MEMCONFIG2_CS1ACCVAL1_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG2_CS1ACCVAL1_SHIFT) &		\
	(TX39_MEMCONFIG2_CS1ACCVAL1_MASK << TX39_MEMCONFIG2_CS1ACCVAL1_SHIFT)))

#define TX39_MEMCONFIG2_CS1ACCVAL2_SHIFT	8
#define TX39_MEMCONFIG2_CS1ACCVAL2_MASK		0xf
#define TX39_MEMCONFIG2_CS1ACCVAL2(cr)					\
	(((cr) >> TX39_MEMCONFIG2_CS1ACCVAL2_SHIFT) &			\
	TX39_MEMCONFIG2_CS1ACCVAL2_MASK)
#define TX39_MEMCONFIG2_CS1ACCVAL2_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG2_CS1ACCVAL2_SHIFT) &		\
	(TX39_MEMCONFIG2_CS1ACCVAL2_MASK << TX39_MEMCONFIG2_CS1ACCVAL2_SHIFT)))

#define TX39_MEMCONFIG2_CS0ACCVAL1_SHIFT	4
#define TX39_MEMCONFIG2_CS0ACCVAL1_MASK		0xf
#define TX39_MEMCONFIG2_CS0ACCVAL1(cr)					\
	(((cr) >> TX39_MEMCONFIG2_CS0ACCVAL1_SHIFT) &			\
	TX39_MEMCONFIG2_CS0ACCVAL1_MASK)
#define TX39_MEMCONFIG2_CS0ACCVAL1_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG2_CS0ACCVAL1_SHIFT) &		\
	(TX39_MEMCONFIG2_CS0ACCVAL1_MASK << TX39_MEMCONFIG2_CS0ACCVAL1_SHIFT)))

#define TX39_MEMCONFIG2_CS0ACCVAL2_SHIFT	0
#define TX39_MEMCONFIG2_CS0ACCVAL2_MASK		0xf
#define TX39_MEMCONFIG2_CS0ACCVAL2(cr)					\
	(((cr) >> TX39_MEMCONFIG2_CS0ACCVAL2_SHIFT) &			\
	TX39_MEMCONFIG2_CS0ACCVAL2_MASK)
#define TX39_MEMCONFIG2_CS0ACCVAL2_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG2_CS0ACCVAL2_SHIFT) &		\
	(TX39_MEMCONFIG2_CS0ACCVAL2_MASK << TX39_MEMCONFIG2_CS0ACCVAL2_SHIFT)))

/*
 *	Memory Configuration 3 Register
 */
/* Define access timing, enable read page mode, PC-Card. */
#define TX39_MEMCONFIG3_CARD2ACCVAL_SHIFT	28
#define TX39_MEMCONFIG3_CARD2ACCVAL_MASK	0xf
#define TX39_MEMCONFIG3_CARD2ACCVAL(cr)					\
	(((cr) >> TX39_MEMCONFIG3_CARD2ACCVAL_SHIFT) &			\
	TX39_MEMCONFIG3_CARD2ACCVAL_MASK)
#define TX39_MEMCONFIG3_CARD2ACCVAL_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG3_CARD2ACCVAL_SHIFT) &		\
	(TX39_MEMCONFIG3_CARD2ACCVAL_MASK <<				\
	TX39_MEMCONFIG3_CARD2ACCVAL_SHIFT)))

#define TX39_MEMCONFIG3_CARD1ACCVAL_SHIFT	24
#define TX39_MEMCONFIG3_CARD1ACCVAL_MASK	0xf
#define TX39_MEMCONFIG3_CARD1ACCVAL(cr)					\
	(((cr) >> TX39_MEMCONFIG3_CARD1ACCVAL_SHIFT) &			\
	TX39_MEMCONFIG3_CARD1ACCVAL_MASK)
#define TX39_MEMCONFIG3_CARD1ACCVAL_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG3_CARD1ACCVAL_SHIFT) &		\
	(TX39_MEMCONFIG3_CARD1ACCVAL_MASK <<				\
	TX39_MEMCONFIG3_CARD1ACCVAL_SHIFT)))

#define TX39_MEMCONFIG3_CARD2IOACCVAL_SHIFT	20
#define TX39_MEMCONFIG3_CARD2IOACCVAL_MASK	0xf
#define TX39_MEMCONFIG3_CARD2IOACCVAL(cr)				\
	(((cr) >> TX39_MEMCONFIG3_CARD2IOACCVAL_SHIFT) &		\
	TX39_MEMCONFIG3_CARD2IOACCVAL_MASK)
#define TX39_MEMCONFIG3_CARD2IOACCVAL_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG3_CARD2IOACCVAL_SHIFT) &	\
	(TX39_MEMCONFIG3_CARD2IOACCVAL_MASK <<				\
	TX39_MEMCONFIG3_CARD2IOACCVAL_SHIFT)))

#define TX39_MEMCONFIG3_CARD1IOACCVAL_SHIFT	16
#define TX39_MEMCONFIG3_CARD1IOACCVAL_MASK	0xf
#define TX39_MEMCONFIG3_CARD1IOACCVAL(cr)				\
	(((cr) >> TX39_MEMCONFIG3_CARD1IOACCVAL_SHIFT) &		\
	TX39_MEMCONFIG3_CARD1IOACCVAL_MASK)
#define TX39_MEMCONFIG3_CARD1IOACCVAL_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG3_CARD1IOACCVAL_SHIFT) &	\
	(TX39_MEMCONFIG3_CARD1IOACCVAL_MASK <<				\
	TX39_MEMCONFIG3_CARD1IOACCVAL_SHIFT)))
#ifdef TX391X
#define TX39_MEMCONFIG3_ENMCS3PAGE		0x00008000
#define TX39_MEMCONFIG3_ENMCS2PAGE		0x00004000
#define TX39_MEMCONFIG3_ENMCS1PAGE		0x00002000
#define TX39_MEMCONFIG3_ENMCS0PAGE		0x00001000
#endif /* TX391X */
#define TX39_MEMCONFIG3_ENCS3PAGE		0x00000800
#define TX39_MEMCONFIG3_ENCS2PAGE		0x00000400
#define TX39_MEMCONFIG3_ENCS1PAGE		0x00000200
#define TX39_MEMCONFIG3_ENCS0PAGE		0x00000100
#define TX39_MEMCONFIG3_CARD2WAITEN		0x00000080
#define TX39_MEMCONFIG3_CARD1WAITEN		0x00000040
#define TX39_MEMCONFIG3_CARD2IOEN		0x00000020
#define TX39_MEMCONFIG3_CARD1IOEN		0x00000010
#ifdef TX391X
#define TX39_MEMCONFIG3_PORT8SEL		0x00000008
#endif /* TX391X */
#ifdef TX392X
#define TX39_MEMCONFIG3_CARD2_8SEL		0x00000008
#define TX39_MEMCONFIG3_CARD1_8SEL		0x00000004
#endif /* TX392X */
/*
 *	Memory Configuration 4 Register
 */
/* DMA */
#define TX39_MEMCONFIG4_ENBANK1HDRAM		0x80000000
#define TX39_MEMCONFIG4_ENBANK0HDRAM		0x40000000
#define TX39_MEMCONFIG4_ENARB			0x20000000
#define TX39_MEMCONFIG4_DISSNOOP		0x10000000
#define TX39_MEMCONFIG4_CLRWRBUSERRINT		0x08000000
#define TX39_MEMCONFIG4_ENBANK1OPT		0x04000000
#define TX39_MEMCONFIG4_ENBANK0OPT		0x02000000
#define TX39_MEMCONFIG4_ENWATCH			0x01000000

/*
 * WatchDogTimerRate = (WATCHTIME[3:0] + 1) * 64 / 36.864MHz
 */
#define TX39_MEMCONFIG4_WATCHTIMEVAL_SHIFT	20
#define TX39_MEMCONFIG4_WATCHTIMEVAL_MASK	0xf
#define TX39_MEMCONFIG4_WATCHTIMEVAL(cr)				\
	(((cr) >> TX39_MEMCONFIG4_WATCHTIMEVAL_SHIFT) &			\
	TX39_MEMCONFIG4_WATCHTIMEVAL_MASK)
#define TX39_MEMCONFIG4_WATCHTIMEVAL_SET(cr, val)			\
	((cr) | (((val) << TX39_MEMCONFIG4_WATCHTIMEVAL_SHIFT) &	\
	(TX39_MEMCONFIG4_WATCHTIMEVAL_MASK <<				\
	TX39_MEMCONFIG4_WATCHTIMEVAL_SHIFT)))


#define TX39_MEMCONFIG4_MEMPOWERDOWN		0x00010000
#define TX39_MEMCONFIG4_ENRFSH1			0x00008000
#define TX39_MEMCONFIG4_ENRFSH0			0x00004000

#define TX39_MEMCONFIG4_RFSHVAL1_SHIFT	8
#define TX39_MEMCONFIG4_RFSHVAL1_MASK	0x3f
#define TX39_MEMCONFIG4_RFSHVAL1(cr)					\
	(((cr) >> TX39_MEMCONFIG4_RFSHVAL1_SHIFT) &			\
	TX39_MEMCONFIG4_RFSHVAL1_MASK)
#define TX39_MEMCONFIG4_RFSHVAL1_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG4_RFSHVAL1_SHIFT) &		\
	(TX39_MEMCONFIG4_RFSHVAL1_MASK << TX39_MEMCONFIG4_RFSHVAL1_SHIFT)))

#define TX39_MEMCONFIG4_RFSHVAL0_SHIFT	0
#define TX39_MEMCONFIG4_RFSHVAL0_MASK	0x3f
#define TX39_MEMCONFIG4_RFSHVAL0(cr)					\
	(((cr) >> TX39_MEMCONFIG4_RFSHVAL0_SHIFT) &			\
	TX39_MEMCONFIG4_RFSHVAL0_MASK)
#define TX39_MEMCONFIG4_RFSHVAL0_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG4_RFSHVAL0_SHIFT) &		\
	(TX39_MEMCONFIG4_RFSHVAL0_MASK << TX39_MEMCONFIG4_RFSHVAL0_SHIFT)))

/*
 *	Memory Configuration 5 Register
 */
/* Address remap region 2 */
#define TX39_MEMCONFIG5_STARTVAL2_SHIFT	9
#define TX39_MEMCONFIG5_STARTVAL2_MASK	0x007fffff
#define TX39_MEMCONFIG5_STARTVAL2(cr)					\
	(((cr) >> TX39_MEMCONFIG5_STARTVAL2_SHIFT) &			\
	TX39_MEMCONFIG5_STARTVAL2_MASK)
#define TX39_MEMCONFIG5_STARTVAL2_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG5_STARTVAL2_SHIFT) &		\
	(TX39_MEMCONFIG5_STARTVAL2_MASK << TX39_MEMCONFIG5_STARTVAL2_SHIFT)))

#define TX39_MEMCONFIG5_MASK2_SHIFT	0
#define TX39_MEMCONFIG5_MASK2_MASK	0xf
#define TX39_MEMCONFIG5_MASK2(cr)					\
	(((cr) >> TX39_MEMCONFIG5_MASK2_SHIFT) &			\
	TX39_MEMCONFIG5_MASK2_MASK)
#define TX39_MEMCONFIG5_MASK2_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG5_MASK2_SHIFT) &		\
	(TX39_MEMCONFIG5_MASK2_MASK << TX39_MEMCONFIG5_MASK2_SHIFT)))

/*
 *	Memory Configuration 6 Register
 */
/* Address remap region 1 */
#define TX39_MEMCONFIG6_STARTVAL1_SHIFT	9
#define TX39_MEMCONFIG6_STARTVAL1_MASK	0x007fffff
#define TX39_MEMCONFIG6_STARTVAL1(cr)					\
	(((cr) >> TX39_MEMCONFIG6_STARTVAL1_SHIFT) &			\
	TX39_MEMCONFIG6_STARTVAL1_MASK)
#define TX39_MEMCONFIG6_STARTVAL1_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG6_STARTVAL1_SHIFT) &		\
	(TX39_MEMCONFIG6_STARTVAL1_MASK << TX39_MEMCONFIG6_STARTVAL1_SHIFT)))

#define TX39_MEMCONFIG6_MASK1_SHIFT	0
#define TX39_MEMCONFIG6_MASK1_MASK	0xf
#define TX39_MEMCONFIG6_MASK1(cr)					\
	(((cr) >> TX39_MEMCONFIG6_MASK1_SHIFT) &			\
	TX39_MEMCONFIG6_MASK1_MASK)
#define TX39_MEMCONFIG6_MASK1_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG6_MASK1_SHIFT) &		\
	(TX39_MEMCONFIG6_MASK1_MASK << TX39_MEMCONFIG6_MASK1_SHIFT)))

/*
 *	Memory Configuration 7 Register
 */
/* Address remap region 2 */
#define TX39_MEMCONFIG7_RMAPADD2_SHIFT	9
#define TX39_MEMCONFIG7_RMAPADD2_MASK	0x007fffff
#define TX39_MEMCONFIG7_RMAPADD2(cr)					\
	(((cr) >> TX39_MEMCONFIG7_RMAPADD2_SHIFT) &			\
	TX39_MEMCONFIG7_RMAPADD2_MASK)
#define TX39_MEMCONFIG7_RMAPADD2_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG7_RMAPADD2_SHIFT) &		\
	(TX39_MEMCONFIG7_RMAPADD2_MASK << TX39_MEMCONFIG7_RMAPADD2_SHIFT)))

/*
 *	Memory Configuration 8 Register
 */
/* Address remap region 1 */
#define TX39_MEMCONFIG8_RMAPADD1_SHIFT	9
#define TX39_MEMCONFIG8_RMAPADD1_MASK	0x007fffff
#define TX39_MEMCONFIG8_RMAPADD1(cr)					\
	(((cr) >> TX39_MEMCONFIG8_RMAPADD1_SHIFT) &			\
	TX39_MEMCONFIG8_RMAPADD1_MASK)
#define TX39_MEMCONFIG8_RMAPADD1_SET(cr, val)				\
	((cr) | (((val) << TX39_MEMCONFIG8_RMAPADD1_SHIFT) &		\
	(TX39_MEMCONFIG8_RMAPADD1_MASK << TX39_MEMCONFIG8_RMAPADD1_SHIFT)))