2 * Copyright - Galileo technology.
4 * See file CREDITS for list of people who contributed to this
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.
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.
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,
25 * written or collected and sometimes rewritten by
26 * Ingo Assmus <ingo.assmus@keymile.com>
32 #include "../include/core.h"
33 #include "../include/memory.h"
35 /*******************************************************************************
36 * memoryGetBankBaseAddress - Returns the base address of a memory bank.
38 * This function returns the base address of one of the SDRAM’s memory
39 * banks. There are 4 memory banks and each one represents one DIMM side.
41 * MEMORY_BANK bank - Selects one of the four banks as defined in Memory.h.
45 * 32 bit Memory bank base address.
46 *******************************************************************************/
47 static unsigned long memoryGetBankRegOffset (MEMORY_BANK bank
)
51 return SCS_0_LOW_DECODE_ADDRESS
;
53 return SCS_1_LOW_DECODE_ADDRESS
;
55 return SCS_2_LOW_DECODE_ADDRESS
;
57 return SCS_3_LOW_DECODE_ADDRESS
;
60 return SCS_0_LOW_DECODE_ADDRESS
; /* default value */
63 unsigned int memoryGetBankBaseAddress (MEMORY_BANK bank
)
66 unsigned int regOffset
= memoryGetBankRegOffset (bank
);
68 GT_REG_READ (regOffset
, &base
);
69 base
= base
<< 16; /* MV6436x */
73 /*******************************************************************************
74 * memoryGetDeviceBaseAddress - Returns the base address of a device.
76 * This function returns the base address of a device on the system. There
77 * are 5 possible devices (0 - 4 and one boot device) as defined in
78 * gtMemory.h. Each of the device parameters is maped to one of the CS
79 * (Devices chip selects) base address register.
81 * device - Selects one of the five devices as defined in Memory.h.
85 * 32 bit Device base address.
87 *******************************************************************************/
88 static unsigned int memoryGetDeviceRegOffset (DEVICE device
)
92 return CS_0_LOW_DECODE_ADDRESS
;
94 return CS_1_LOW_DECODE_ADDRESS
;
96 return CS_2_LOW_DECODE_ADDRESS
;
98 return CS_3_LOW_DECODE_ADDRESS
;
100 return BOOTCS_LOW_DECODE_ADDRESS
;
102 return CS_0_LOW_DECODE_ADDRESS
; /* default value */
105 unsigned int memoryGetDeviceBaseAddress (DEVICE device
)
107 unsigned int regBase
;
108 unsigned int regOffset
= memoryGetDeviceRegOffset (device
);
110 GT_REG_READ (regOffset
, ®Base
);
112 regBase
= regBase
<< 16; /* MV6436x */
116 /*******************************************************************************
117 * MemoryGetPciBaseAddr - Returns the base address of a PCI window.
119 * This function returns the base address of a PCI window. There are 5
120 * possible PCI windows (memory 0 - 3 and one for I/O) for each PCI
121 * interface as defined in gtMemory.h, used by the CPU's address decoding
125 * pciWindow - Selects one of the PCI windows as defined in Memory.h.
129 * 32 bit PCI window base address.
130 *******************************************************************************/
131 unsigned int MemoryGetPciBaseAddr (PCI_MEM_WINDOW pciWindow
)
133 unsigned int baseAddrReg
, base
;
137 baseAddrReg
= PCI_0I_O_LOW_DECODE_ADDRESS
; /*PCI_0_IO_BASE_ADDR; */
140 baseAddrReg
= PCI_0MEMORY0_LOW_DECODE_ADDRESS
; /*PCI_0_MEMORY0_BASE_ADDR; */
143 baseAddrReg
= PCI_0MEMORY1_LOW_DECODE_ADDRESS
; /*PCI_0_MEMORY1_BASE_ADDR; */
146 baseAddrReg
= PCI_0MEMORY2_LOW_DECODE_ADDRESS
; /*PCI_0_MEMORY2_BASE_ADDR; */
149 baseAddrReg
= PCI_0MEMORY3_LOW_DECODE_ADDRESS
; /*PCI_0_MEMORY3_BASE_ADDR; */
153 baseAddrReg
= PCI_1I_O_LOW_DECODE_ADDRESS
; /*PCI_1_IO_BASE_ADDR; */
156 baseAddrReg
= PCI_1MEMORY0_LOW_DECODE_ADDRESS
; /*PCI_1_MEMORY0_BASE_ADDR; */
159 baseAddrReg
= PCI_1MEMORY1_LOW_DECODE_ADDRESS
; /*PCI_1_MEMORY1_BASE_ADDR; */
162 baseAddrReg
= PCI_1MEMORY2_LOW_DECODE_ADDRESS
; /*PCI_1_MEMORY2_BASE_ADDR; */
165 baseAddrReg
= PCI_1MEMORY3_LOW_DECODE_ADDRESS
; /*PCI_1_MEMORY3_BASE_ADDR; */
167 #endif /* INCLUDE_PCI_1 */
171 GT_REG_READ (baseAddrReg
, &base
);
175 /*******************************************************************************
176 * memoryGetBankSize - Returns the size of a memory bank.
178 * This function returns the size of memory bank as described in
179 * 'gtMemoryGetBankBaseAddress' function.
181 * bank - Selects one of the four banks as defined in Memory.h.
185 * 32 bit size memory bank size or 0 for a closed or non populated bank.
187 *******************************************************************************/
188 unsigned int memoryGetBankSize (MEMORY_BANK bank
)
190 unsigned int sizeReg
, size
;
191 MEMORY_WINDOW window
;
195 sizeReg
= SCS_0_HIGH_DECODE_ADDRESS
; /* CS_0_SIZE; */
196 window
= CS_0_WINDOW
;
199 sizeReg
= SCS_1_HIGH_DECODE_ADDRESS
; /* CS_1_SIZE; */
200 window
= CS_1_WINDOW
;
203 sizeReg
= SCS_2_HIGH_DECODE_ADDRESS
; /* CS_2_SIZE; */
204 window
= CS_2_WINDOW
;
207 sizeReg
= SCS_3_HIGH_DECODE_ADDRESS
; /* CS_3_SIZE; */
208 window
= CS_3_WINDOW
;
214 /* If the window is closed, a size of 0 is returned */
215 if (MemoryGetMemWindowStatus (window
) != MEM_WINDOW_ENABLED
)
217 GT_REG_READ (sizeReg
, &size
);
218 size
= ((size
<< 16) | 0xffff) + 1;
222 /*******************************************************************************
223 * memoryGetDeviceSize - Returns the size of a device memory space.
225 * This function returns the memory space size of a given device.
227 * device - Selects one of the five devices as defined in Memory.h.
231 * 32 bit size of a device memory space.
232 *******************************************************************************/
233 unsigned int memoryGetDeviceSize (DEVICE device
)
235 unsigned int sizeReg
, size
;
236 MEMORY_WINDOW window
;
240 sizeReg
= CS_0_HIGH_DECODE_ADDRESS
; /*DEV_CS0_SIZE; */
241 window
= DEVCS_0_WINDOW
;
244 sizeReg
= CS_1_HIGH_DECODE_ADDRESS
; /*DEV_CS1_SIZE; */
245 window
= DEVCS_1_WINDOW
;
248 sizeReg
= CS_2_HIGH_DECODE_ADDRESS
; /*DEV_CS2_SIZE; */
249 window
= DEVCS_2_WINDOW
;
252 sizeReg
= CS_3_HIGH_DECODE_ADDRESS
; /*DEV_CS3_SIZE; */
253 window
= DEVCS_3_WINDOW
;
256 sizeReg
= BOOTCS_HIGH_DECODE_ADDRESS
; /*BOOTCS_SIZE; */
257 window
= BOOT_CS_WINDOW
;
263 /* If the window is closed, a size of 0 is returned */
264 if (MemoryGetMemWindowStatus (window
) != MEM_WINDOW_ENABLED
)
266 GT_REG_READ (sizeReg
, &size
);
267 size
= ((size
<< 16) | 0xffff) + 1;
271 /*******************************************************************************
272 * MemoryGetPciWindowSize - Returns the size of a PCI memory window.
274 * This function returns the size of a PCI window.
276 * pciWindow - Selects one of the PCI memory windows as defined in
281 * 32 bit size of a PCI memory window.
282 *******************************************************************************/
283 unsigned int MemoryGetPciWindowSize (PCI_MEM_WINDOW pciWindow
)
285 unsigned int sizeReg
, size
;
289 sizeReg
= PCI_0I_O_HIGH_DECODE_ADDRESS
; /*PCI_0_IO_SIZE; */
292 sizeReg
= PCI_0MEMORY0_HIGH_DECODE_ADDRESS
; /*PCI_0_MEMORY0_SIZE; */
295 sizeReg
= PCI_0MEMORY1_HIGH_DECODE_ADDRESS
; /*PCI_0_MEMORY1_SIZE; */
298 sizeReg
= PCI_0MEMORY2_HIGH_DECODE_ADDRESS
; /*PCI_0_MEMORY2_SIZE; */
301 sizeReg
= PCI_0MEMORY3_HIGH_DECODE_ADDRESS
; /*PCI_0_MEMORY3_SIZE; */
305 sizeReg
= PCI_1I_O_HIGH_DECODE_ADDRESS
; /*PCI_1_IO_SIZE; */
308 sizeReg
= PCI_1MEMORY0_HIGH_DECODE_ADDRESS
; /*PCI_1_MEMORY0_SIZE; */
311 sizeReg
= PCI_1MEMORY1_HIGH_DECODE_ADDRESS
; /*PCI_1_MEMORY1_SIZE; */
314 sizeReg
= PCI_1MEMORY2_HIGH_DECODE_ADDRESS
; /*PCI_1_MEMORY2_SIZE; */
317 sizeReg
= PCI_1MEMORY3_HIGH_DECODE_ADDRESS
; /*PCI_1_MEMORY3_SIZE; */
319 #endif /* INCLUDE_PCI_1 */
323 /* If the memory window is disabled, retrun size = 0 */
324 if (MemoryGetMemWindowStatus (PCI_0_IO_WINDOW
<< pciWindow
)
325 == MEM_WINDOW_DISABLED
)
327 GT_REG_READ (sizeReg
, &size
);
328 size
= ((size
<< 16) | 0xffff) + 1;
332 /*******************************************************************************
333 * memoryGetDeviceWidth - Returns the width of a given device.
335 * The MV's device interface supports up to 32 Bit wide devices. A device
336 * can have a 1, 2, 4 or 8 Bytes data width. This function returns the
337 * width of a device as defined by the user or the operating system.
339 * device - Selects one of the five devices as defined in Memory.h.
343 * Device width in Bytes (1,2,4 or 8), 0 if error had occurred.
344 *******************************************************************************/
345 unsigned int memoryGetDeviceWidth (DEVICE device
)
348 unsigned int regValue
;
350 GT_REG_READ (DEVICE_BANK0PARAMETERS
+ device
* 4, ®Value
);
351 width
= (regValue
& (BIT20
| BIT21
)) >> 20;
352 return (BIT0
<< width
);
355 /*******************************************************************************
356 * memoryMapBank - Set new base address and size for one of the memory
360 * The CPU interface address decoding map consists of 21 address windows
361 * for the different devices (e.g. CS[3:0] ,PCI0 Mem 0/1/2/3...). Each
362 * window can have a minimum of 1Mbytes of address space, and up to 4Gbyte
363 * space. Each address window is defined by two registers - base and size.
364 * The CPU address is compared with the values in the various CPU windows
365 * until a match is found and the address is than targeted to that window.
366 * This function sets new base and size for one the memory banks
367 * (CS0 - CS3). It is the programmer`s responsibility to make sure that
368 * there are no conflicts with other memory spaces. When two memory spaces
369 * overlap, the MV’s behavior is not defined .If a bank needs to be closed,
370 * set the ’bankLength’ parameter size to 0x0.
373 * bank - One of the memory banks (CS0-CS3) as defined in gtMemory.h.
374 * bankBase - The memory bank base address.
375 * bankLength - The memory bank size. This function will decrement the
376 * 'bankLength' parameter by one and then check if the size is
377 * valid. A valid size must be programed from LSB to MSB as
378 * sequence of ‘1’s followed by sequence of ‘0’s.
379 * To close a memory window simply set the size to 0.
381 * The size must be in 64Kbyte granularity.
382 * The base address must be aligned to the size.
386 * False for invalid size, true otherwise.
388 * CAUTION: PCI_functions must be implemented later To_do !!!!!!!!!!!!!!!!!
390 *******************************************************************************/
392 bool memoryMapBank (MEMORY_BANK bank
, unsigned int bankBase
,
393 unsigned int bankLength
)
395 unsigned int newBase
, newSize
, baseReg
, sizeReg
, temp
, rShift
;
397 /* PCI_INTERNAL_BAR pciBAR; */
401 baseReg
= SCS_0_LOW_DECODE_ADDRESS
; /*CS_0_BASE_ADDR; */
402 sizeReg
= SCS_0_HIGH_DECODE_ADDRESS
; /*CS_0_SIZE; */
403 /* pciBAR = PCI_CS0_BAR; */
406 baseReg
= SCS_1_LOW_DECODE_ADDRESS
; /*CS_1_BASE_ADDR; */
407 sizeReg
= SCS_1_HIGH_DECODE_ADDRESS
; /*CS_1_SIZE; */
408 /* pciBAR = SCS_0_HIGH_DECODE_ADDRESS; */ /*PCI_CS1_BAR; */
411 baseReg
= SCS_2_LOW_DECODE_ADDRESS
; /*CS_2_BASE_ADDR; */
412 sizeReg
= SCS_2_HIGH_DECODE_ADDRESS
; /*CS_2_SIZE; */
413 /* pciBAR = PCI_CS2_BAR;*/
416 baseReg
= SCS_3_LOW_DECODE_ADDRESS
; /*CS_3_BASE_ADDR; */
417 sizeReg
= SCS_3_HIGH_DECODE_ADDRESS
; /*CS_3_SIZE; */
418 /* pciBAR = PCI_CS3_BAR; */
423 /* If the size is 0, the window will be disabled */
424 if (bankLength
== 0) {
425 MemoryDisableWindow (CS_0_WINDOW
<< bank
);
426 /* Disable the BAR from the PCI slave side */
427 /* gtPci0DisableInternalBAR(pciBAR); */
428 /* gtPci1DisableInternalBAR(pciBAR); */
431 /* The base address must be aligned to the size */
432 if ((bankBase
% bankLength
) != 0) {
435 if (bankLength
>= MINIMUM_MEM_BANK_SIZE
) {
436 newBase
= bankBase
>> 16;
437 newSize
= bankLength
>> 16;
438 /* Checking that the size is a sequence of '1' followed by a
439 sequence of '0' starting from LSB to MSB. */
441 for (rShift
= 0; rShift
< 16; rShift
++) {
442 temp
= temp
>> rShift
;
443 if ((temp
& 0x1) == 0) { /* Either we got to the last '1' */
444 /* or the size is not valid */
453 unsigned int oldBase
, oldSize
;
455 GT_REG_READ (baseReg
, &oldBase
);
456 GT_REG_READ (sizeReg
+ 8, &oldSize
);
458 printf ("b%d Base:%x Size:%x -> Base:%x Size:%x\n",
459 bank
, oldBase
, oldSize
, newBase
, newSize
);
462 /* writing the new values */
463 GT_REG_WRITE (baseReg
, newBase
);
464 GT_REG_WRITE (sizeReg
, newSize
- 1);
465 /* Enable back the window */
466 MemoryEnableWindow (CS_0_WINDOW
<< bank
);
467 /* Enable the BAR from the PCI slave side */
468 /* gtPci0EnableInternalBAR(pciBAR); */
469 /* gtPci1EnableInternalBAR(pciBAR); */
476 /*******************************************************************************
477 * memoryMapDeviceSpace - Set new base address and size for one of the device
481 * The CPU interface address decoding map consists of 21 address windows
482 * for the different devices (e.g. CS[3:0] ,PCI0 Mem 0/1/2/3...). Each
483 * window can have a minimum of 1Mbytes of address space, and up to 4Gbyte
484 * space. Each address window is defined by two registers - base and size.
485 * The CPU address is compared with the values in the various CPU windows
486 * until a match is found and the address is than targeted to that window.
487 * This function sets new base and size for one the device windows
488 * (DEV_CS0 - DEV_CS3). It is the programmer`s responsibility to make sure
489 * that there are no conflicts with other memory spaces. When two memory
490 * spaces overlap, the MV’s behavior is not defined .If a device window
491 * needs to be closed, set the 'deviceLength' parameter size to 0x0.
494 * device - One of the device windows (DEV_CS0-DEV_CS3) as
495 * defined in gtMemory.h.
496 * deviceBase - The device window base address.
497 * deviceLength - The device window size. This function will decrement
498 * the 'deviceLength' parameter by one and then
499 * check if the size is valid. A valid size must be
500 * programed from LSB to MSB as sequence of ‘1’s
501 * followed by sequence of ‘0’s.
502 * To close a memory window simply set the size to 0.
505 * The size must be in 64Kbyte granularity.
506 * The base address must be aligned to the size.
512 * False for invalid size, true otherwise.
514 * CAUTION: PCI_functions must be implemented later To_do !!!!!!!!!!!!!!!!!
516 *******************************************************************************/
518 bool memoryMapDeviceSpace (DEVICE device
, unsigned int deviceBase
,
519 unsigned int deviceLength
)
521 unsigned int newBase
, newSize
, baseReg
, sizeReg
, temp
, rShift
;
523 /* PCI_INTERNAL_BAR pciBAR;*/
527 baseReg
= CS_0_LOW_DECODE_ADDRESS
; /*DEV_CS0_BASE_ADDR; */
528 sizeReg
= CS_0_HIGH_DECODE_ADDRESS
; /*DEV_CS0_SIZE; */
529 /* pciBAR = PCI_DEV_CS0_BAR; */
532 baseReg
= CS_1_LOW_DECODE_ADDRESS
; /*DEV_CS1_BASE_ADDR; */
533 sizeReg
= CS_1_HIGH_DECODE_ADDRESS
; /*DEV_CS1_SIZE; */
534 /* pciBAR = PCI_DEV_CS1_BAR; */
537 baseReg
= CS_2_LOW_DECODE_ADDRESS
; /*DEV_CS2_BASE_ADDR; */
538 sizeReg
= CS_2_HIGH_DECODE_ADDRESS
; /*DEV_CS2_SIZE; */
539 /* pciBAR = PCI_DEV_CS2_BAR; */
542 baseReg
= CS_3_LOW_DECODE_ADDRESS
; /*DEV_CS3_BASE_ADDR; */
543 sizeReg
= CS_3_HIGH_DECODE_ADDRESS
; /*DEV_CS3_SIZE; */
544 /* pciBAR = PCI_DEV_CS3_BAR; */
547 baseReg
= BOOTCS_LOW_DECODE_ADDRESS
; /*BOOTCS_BASE_ADDR; */
548 sizeReg
= BOOTCS_HIGH_DECODE_ADDRESS
; /*BOOTCS_SIZE; */
549 /* pciBAR = PCI_BOOT_CS_BAR; */
554 if (deviceLength
== 0) {
555 MemoryDisableWindow (DEVCS_0_WINDOW
<< device
);
556 /* Disable the BAR from the PCI slave side */
557 /* gtPci0DisableInternalBAR(pciBAR); */
558 /* gtPci1DisableInternalBAR(pciBAR); */
561 /* The base address must be aligned to the size */
562 if ((deviceBase
% deviceLength
) != 0) {
565 if (deviceLength
>= MINIMUM_DEVICE_WINDOW_SIZE
) {
566 newBase
= deviceBase
>> 16;
567 newSize
= deviceLength
>> 16;
568 /* Checking that the size is a sequence of '1' followed by a
569 sequence of '0' starting from LSB to MSB. */
571 for (rShift
= 0; rShift
< 16; rShift
++) {
572 temp
= temp
>> rShift
;
573 if ((temp
& 0x1) == 0) { /* Either we got to the last '1' */
574 /* or the size is not valid */
581 /* writing the new values */
582 GT_REG_WRITE (baseReg
, newBase
);
583 GT_REG_WRITE (sizeReg
, newSize
- 1);
584 MemoryEnableWindow (DEVCS_0_WINDOW
<< device
);
585 /* Enable the BAR from the PCI slave side */
586 /* gtPci0EnableInternalBAR(pciBAR); */
587 /* gtPci1EnableInternalBAR(pciBAR); */
593 /*******************************************************************************
594 * MemorySetPciWindow - Set new base address and size for one of the PCI
598 * The CPU interface address decoding map consists of 21 address windows
599 * for the different devices (e.g. CS[3:0] ,PCI0 Mem 0/1/2/3...). Each
600 * window can have a minimum of 1Mbytes of address space, and up to 4Gbyte
601 * space. Each address window is defined by two registers - base and size.
602 * The CPU address is compared with the values in the various CPU windows
603 * until a match is found and the address is than targeted to that window.
604 * This function sets new base and size for one the PCI windows
605 * (PCI memory0/1/2..). It is the programmer`s responsibility to make sure
606 * that there are no conflicts with other memory spaces. When two memory
607 * spaces overlap, the MV’s behavior is not defined .If a PCI window
608 * needs to be closed, set the 'pciWindowSize' parameter size to 0x0.
611 * pciWindow - One of the PCI windows as defined in gtMemory.h.
612 * pciWindowBase - The PCI window base address.
613 * pciWindowSize - The PCI window size. This function will decrement the
614 * 'pciWindowSize' parameter by one and then check if the
615 * size is valid. A valid size must be programed from LSB
616 * to MSB as sequence of ‘1’s followed by sequence of ‘0’s.
617 * To close a memory window simply set the size to 0.
620 * The size must be in 64Kbyte granularity.
621 * The base address must be aligned to the size.
627 * False for invalid size, true otherwise.
629 *******************************************************************************/
630 bool memorySetPciWindow (PCI_MEM_WINDOW pciWindow
, unsigned int pciWindowBase
,
631 unsigned int pciWindowSize
)
633 unsigned int currentLow
, baseAddrReg
, sizeReg
, temp
, rShift
;
637 baseAddrReg
= PCI_1I_O_LOW_DECODE_ADDRESS
; /*PCI_0_IO_BASE_ADDR; */
638 sizeReg
= PCI_0I_O_HIGH_DECODE_ADDRESS
; /*PCI_0_IO_SIZE; */
641 baseAddrReg
= PCI_0MEMORY0_LOW_DECODE_ADDRESS
; /*PCI_0_MEMORY0_BASE_ADDR; */
642 sizeReg
= PCI_0MEMORY0_HIGH_DECODE_ADDRESS
; /*PCI_0_MEMORY0_SIZE; */
645 baseAddrReg
= PCI_0MEMORY1_LOW_DECODE_ADDRESS
; /*PCI_0_MEMORY1_BASE_ADDR; */
646 sizeReg
= PCI_0MEMORY1_HIGH_DECODE_ADDRESS
; /*PCI_0_MEMORY1_SIZE; */
649 baseAddrReg
= PCI_0MEMORY2_LOW_DECODE_ADDRESS
; /*PCI_0_MEMORY2_BASE_ADDR; */
650 sizeReg
= PCI_0MEMORY2_HIGH_DECODE_ADDRESS
; /*PCI_0_MEMORY2_SIZE; */
653 baseAddrReg
= PCI_0MEMORY3_LOW_DECODE_ADDRESS
; /*PCI_0_MEMORY3_BASE_ADDR; */
654 sizeReg
= PCI_0MEMORY3_HIGH_DECODE_ADDRESS
; /*PCI_0_MEMORY3_SIZE; */
658 baseAddrReg
= PCI_1I_O_LOW_DECODE_ADDRESS
; /*PCI_1_IO_BASE_ADDR; */
659 sizeReg
= PCI_1I_O_HIGH_DECODE_ADDRESS
; /*PCI_1_IO_SIZE; */
662 baseAddrReg
= PCI_1MEMORY0_LOW_DECODE_ADDRESS
; /*PCI_1_MEMORY0_BASE_ADDR; */
663 sizeReg
= PCI_1MEMORY0_HIGH_DECODE_ADDRESS
; /*PCI_1_MEMORY0_SIZE; */
666 baseAddrReg
= PCI_1MEMORY1_LOW_DECODE_ADDRESS
; /*PCI_1_MEMORY1_BASE_ADDR; */
667 sizeReg
= PCI_1MEMORY1_HIGH_DECODE_ADDRESS
; /*PCI_1_MEMORY1_SIZE; */
670 baseAddrReg
= PCI_1MEMORY2_LOW_DECODE_ADDRESS
; /*PCI_1_MEMORY2_BASE_ADDR; */
671 sizeReg
= PCI_1MEMORY2_HIGH_DECODE_ADDRESS
; /*PCI_1_MEMORY2_SIZE; */
674 baseAddrReg
= PCI_1MEMORY3_LOW_DECODE_ADDRESS
; /*PCI_1_MEMORY3_BASE_ADDR; */
675 sizeReg
= PCI_1MEMORY3_HIGH_DECODE_ADDRESS
; /*PCI_1_MEMORY3_SIZE; */
677 #endif /* INCLUDE_PCI_1 */
681 if (pciWindowSize
== 0) {
682 MemoryDisableWindow (PCI_0_IO_WINDOW
<< pciWindow
);
685 /* The base address must be aligned to the size */
686 if ((pciWindowBase
% pciWindowSize
) != 0) {
689 if (pciWindowSize
>= MINIMUM_PCI_WINDOW_SIZE
) {
690 pciWindowBase
>>= 16;
691 pciWindowSize
>>= 16;
692 /* Checking that the size is a sequence of '1' followed by a
693 sequence of '0' starting from LSB to MSB. */
694 temp
= pciWindowSize
- 1;
695 for (rShift
= 0; rShift
< 16; rShift
++) {
696 temp
= temp
>> rShift
;
697 if ((temp
& 0x1) == 0) { /* Either we got to the last '1' */
698 /* or the size is not valid */
705 GT_REG_WRITE (sizeReg
, pciWindowSize
- 1);
706 GT_REG_READ (baseAddrReg
, ¤tLow
);
708 (pciWindowBase
& 0xfffff) | (currentLow
& 0xfff00000);
709 GT_REG_WRITE (baseAddrReg
, pciWindowBase
);
710 MemoryEnableWindow (PCI_0_IO_WINDOW
<< pciWindow
);
716 /*******************************************************************************
717 * memoryMapInternalRegistersSpace - Sets new base address for the internal
718 * registers memory space.
721 * This function set new base address for the internal register’s memory
722 * space (the size is fixed and cannot be modified). The function does not
723 * handle overlapping with other memory spaces, it is the programer's
724 * responsibility to ensure that overlapping does not occur.
725 * When two memory spaces overlap, the MV’s behavior is not defined.
728 * internalRegBase - new base address for the internal register’s memory
735 * true on success, false on failure
737 *******************************************************************************/
738 /********************************************************************
739 * memoryMapInternalRegistersSpace - Sets new base address for the internals
742 * INPUTS: unsigned int internalRegBase - The new base address.
743 * RETURNS: true on success, false on failure
744 *********************************************************************/
745 bool memoryMapInternalRegistersSpace (unsigned int internalRegBase
)
747 unsigned int currentValue
;
748 unsigned int internalValue
= internalRegBase
;
750 internalRegBase
= (internalRegBase
>> 16);
751 GT_REG_READ (INTERNAL_SPACE_DECODE
, ¤tValue
);
752 internalRegBase
= (currentValue
& 0xff000000) | internalRegBase
;
753 GT_REG_WRITE (INTERNAL_SPACE_DECODE
, internalRegBase
);
754 /* initializing also the global variable 'internalRegBaseAddr' */
755 /* gtInternalRegBaseAddr = internalValue; */
756 INTERNAL_REG_BASE_ADDR
= internalValue
;
760 /*******************************************************************************
761 * memoryGetInternalRegistersSpace - Returns the internal registers Base
765 * This function returns the base address of the internal register’s
775 * 32 bit base address of the internal register’s memory space.
777 *******************************************************************************/
778 unsigned int memoryGetInternalRegistersSpace (void)
780 unsigned int currentValue
= 0;
782 GT_REG_READ (INTERNAL_SPACE_DECODE
, ¤tValue
);
783 return ((currentValue
& 0x000fffff) << 16);
786 /*******************************************************************************
787 * gtMemoryGetInternalSramBaseAddr - Returns the integrated SRAM base address.
790 * The Atlantis incorporate integrated 2Mbit SRAM for general use. This
791 * funcnion return the SRAM's base address.
797 * 32 bit SRAM's base address.
799 *******************************************************************************/
800 unsigned int memoryGetInternalSramBaseAddr (void)
802 return ((GTREGREAD (INTEGRATED_SRAM_BASE_ADDR
) & 0xfffff) << 16);
805 /*******************************************************************************
806 * gtMemorySetInternalSramBaseAddr - Set the integrated SRAM base address.
809 * The Atlantis incorporate integrated 2Mbit SRAM for general use. This
810 * function sets a new base address to the SRAM .
812 * sramBaseAddress - The SRAM's base address.
818 *******************************************************************************/
819 void gtMemorySetInternalSramBaseAddr (unsigned int sramBaseAddress
)
821 GT_REG_WRITE (INTEGRATED_SRAM_BASE_ADDR
, sramBaseAddress
>> 16);
824 /*******************************************************************************
825 * memorySetProtectRegion - Set protection mode for one of the 8 regions.
828 * The CPU interface supports configurable access protection. This includes
829 * up to eight address ranges defined to a different protection type :
830 * whether the address range is cacheable or not, whether it is writable or
831 * not , and whether it is accessible or not. A Low and High registers
832 * define each window while the minimum address range of each window is
833 * 1Mbyte. An address driven by the CPU, in addition to the address
834 * decoding and remapping process, is compared against the eight Access
835 * Protection Low/High registers , if an address matches one of the windows
836 * , the MV device checks the transaction type against the protection bits
837 * defined in CPU Access Protection register, to determine if the access is
838 * allowed. This function set a protection mode to one of the 8 possible
841 * The CPU address windows are restricted to a size of 2 power n and the
842 * start address must be aligned to the window size. For example, if using
843 * a 16 MB window, the start address bits [23:0] must be 0.The MV's
844 * internal registers space is not protected, even if the access protection
845 * windows contain this space.
848 * region - selects which region to be configured. The values defined in
855 * memAccess - Allows or forbids access (read or write ) to the region. The
856 * values defined in gtMemory.h:
858 * - MEM_ACCESS_ALLOWED
859 * - MEM_ACCESS_FORBIDEN
861 * memWrite - CPU write protection to the region. The values defined in
864 * - MEM_WRITE_ALLOWED
865 * - MEM_WRITE_FORBIDEN
867 * cacheProtection - Defines whether caching the region is allowed or not.
868 * The values defined in gtMemory.h:
870 * - MEM_CACHE_ALLOWED
871 * - MEM_CACHE_FORBIDEN
873 * baseAddress - the region's base Address.
874 * regionSize - The region's size. This function will decrement the
875 * 'regionSize' parameter by one and then check if the size
876 * is valid. A valid size must be programed from LSB to MSB
877 * as sequence of ‘1’s followed by sequence of ‘0’s.
878 * To close a memory window simply set the size to 0.
881 * The size must be in 64Kbyte granularity.
882 * The base address must be aligned to the size.
888 * False for invalid size, true otherwise.
890 *******************************************************************************/
891 bool memorySetProtectRegion (MEMORY_PROTECT_WINDOW window
,
892 MEMORY_ACCESS memAccess
,
893 MEMORY_ACCESS_WRITE memWrite
,
894 MEMORY_CACHE_PROTECT cacheProtection
,
895 unsigned int baseAddress
, unsigned int size
)
897 unsigned int dataForReg
, temp
, rShift
;
900 GT_REG_WRITE ((CPU_PROTECT_WINDOW_0_SIZE
+ 0x10 * window
),
904 /* The base address must be aligned to the size. */
905 if (baseAddress
% size
!= 0) {
908 if (size
>= MINIMUM_ACCESS_WIN_SIZE
) {
909 baseAddress
= ((baseAddress
>> 16) & 0xfffff);
910 dataForReg
= baseAddress
| ((memAccess
<< 20) & BIT20
) |
911 ((memWrite
<< 21) & BIT21
) | ((cacheProtection
<< 22)
913 GT_REG_WRITE (CPU_PROTECT_WINDOW_0_BASE_ADDR
+ 0x10 * window
,
916 /* Checking that the size is a sequence of '1' followed by a
917 sequence of '0' starting from LSB to MSB. */
919 for (rShift
= 0; rShift
< 16; rShift
++) {
920 temp
= temp
>> rShift
;
921 if ((temp
& 0x1) == 0) { /* Either we got to the last '1' */
922 /* or the size is not valid */
929 GT_REG_WRITE ((CPU_PROTECT_WINDOW_0_SIZE
+ 0x10 * window
),
936 /*******************************************************************************
937 * gtMemoryDisableProtectRegion - Disable a protected window.
940 * This function disable a protected window set by
941 * 'gtMemorySetProtectRegion' function.
944 * window - one of the 4 windows ( defined in gtMemory.h ).
952 *******************************************************************************/
953 void memoryDisableProtectRegion (MEMORY_PROTECT_WINDOW window
)
955 RESET_REG_BITS (((CPU_PROTECT_WINDOW_0_BASE_ADDR
) + (0x10 * window
)),
959 /*******************************************************************************
960 * memorySetPciRemapValue - Set a remap value to a PCI memory space target.
963 * In addition to the address decoding mechanism, the CPU has an address
964 * remapping mechanism to be used by every PCI decoding window. Each PCI
965 * window can be remaped to a desired address target according to the remap
966 * value within the remap register. The address remapping is useful when a
967 * CPU address range must be reallocated to a different location on the
968 * PCI bus. Also, it enables CPU access to a PCI agent located above the
969 * 4Gbyte space. On system boot, each of the PCI memory spaces is maped to
970 * a defualt value (see CPU interface section in the MV spec for the
971 * default values). The remap mechanism does not always produce the desired
972 * address on the PCI bus because of the remap mechanism way of working
973 * (to fully understand why, please see the 'Address Remapping' section in
974 * the MV's spec). Therefor, this function sets a desired remap value to
975 * one of the PCI memory windows and return the effective address that
976 * should be used when exiting the PCI memory window. You should ALWAYS use
977 * the returned value by this function when remapping a PCI window and
978 * exiting it. If for example the base address of PCI0 memory 0 is
979 * 0x90000000, the size is 0x03ffffff and the remap value is 0x11000000,
980 * the function will return the value of 0x91000000 that MUST
981 * be used to exit this memory window in order to achive the deisred
985 * memoryWindow - One of the PCI memory windows as defined in Memory.h
986 * remapValueLow - The low remap value.
987 * remapValueHigh - The high remap value.
992 * The effective base address to exit the PCI, or 0xffffffff if one of the
993 * parameters is erroneous or the effective base address is higher the top
996 *******************************************************************************/
997 unsigned int memorySetPciRemapValue (PCI_MEM_WINDOW memoryWindow
,
998 unsigned int remapValueHigh
,
999 unsigned int remapValueLow
)
1001 unsigned int pciMemWindowBaseAddrReg
= 0, baseAddrValue
= 0;
1002 unsigned int pciMemWindowSizeReg
= 0, windowSizeValue
= 0;
1003 unsigned int effectiveBaseAddress
, remapRegLow
, remapRegHigh
;
1005 /* Initializing the base and size variables of the PCI
1007 switch (memoryWindow
) {
1009 pciMemWindowBaseAddrReg
= PCI_0_IO_BASE_ADDR
;
1010 pciMemWindowSizeReg
= PCI_0_IO_SIZE
;
1011 remapRegLow
= PCI_0_IO_ADDR_REMAP
;
1012 remapRegHigh
= PCI_0_IO_ADDR_REMAP
;
1015 pciMemWindowBaseAddrReg
= PCI_0_MEMORY0_BASE_ADDR
;
1016 pciMemWindowSizeReg
= PCI_0_MEMORY0_SIZE
;
1017 remapRegLow
= PCI_0_MEMORY0_LOW_ADDR_REMAP
;
1018 remapRegHigh
= PCI_0_MEMORY0_HIGH_ADDR_REMAP
;
1021 pciMemWindowBaseAddrReg
= PCI_0_MEMORY1_BASE_ADDR
;
1022 pciMemWindowSizeReg
= PCI_0_MEMORY1_SIZE
;
1023 remapRegLow
= PCI_0_MEMORY1_LOW_ADDR_REMAP
;
1024 remapRegHigh
= PCI_0_MEMORY1_HIGH_ADDR_REMAP
;
1027 pciMemWindowBaseAddrReg
= PCI_0_MEMORY2_BASE_ADDR
;
1028 pciMemWindowSizeReg
= PCI_0_MEMORY2_SIZE
;
1029 remapRegLow
= PCI_0_MEMORY2_LOW_ADDR_REMAP
;
1030 remapRegHigh
= PCI_0_MEMORY2_HIGH_ADDR_REMAP
;
1033 pciMemWindowBaseAddrReg
= PCI_0_MEMORY3_BASE_ADDR
;
1034 pciMemWindowSizeReg
= PCI_0_MEMORY3_SIZE
;
1035 remapRegLow
= PCI_0_MEMORY3_LOW_ADDR_REMAP
;
1036 remapRegHigh
= PCI_0_MEMORY3_HIGH_ADDR_REMAP
;
1038 #ifdef INCLUDE_PCI_1
1040 pciMemWindowBaseAddrReg
= PCI_1_IO_BASE_ADDR
;
1041 pciMemWindowSizeReg
= PCI_1_IO_SIZE
;
1042 remapRegLow
= PCI_1_IO_ADDR_REMAP
;
1043 remapRegHigh
= PCI_1_IO_ADDR_REMAP
;
1046 pciMemWindowBaseAddrReg
= PCI_1_MEMORY0_BASE_ADDR
;
1047 pciMemWindowSizeReg
= PCI_1_MEMORY0_SIZE
;
1048 remapRegLow
= PCI_1_MEMORY0_LOW_ADDR_REMAP
;
1049 remapRegHigh
= PCI_1_MEMORY0_HIGH_ADDR_REMAP
;
1052 pciMemWindowBaseAddrReg
= PCI_1_MEMORY1_BASE_ADDR
;
1053 pciMemWindowSizeReg
= PCI_1_MEMORY1_SIZE
;
1054 remapRegLow
= PCI_1_MEMORY1_LOW_ADDR_REMAP
;
1055 remapRegHigh
= PCI_1_MEMORY1_HIGH_ADDR_REMAP
;
1058 pciMemWindowBaseAddrReg
= PCI_1_MEMORY1_BASE_ADDR
;
1059 pciMemWindowSizeReg
= PCI_1_MEMORY1_SIZE
;
1060 remapRegLow
= PCI_1_MEMORY1_LOW_ADDR_REMAP
;
1061 remapRegHigh
= PCI_1_MEMORY1_HIGH_ADDR_REMAP
;
1064 pciMemWindowBaseAddrReg
= PCI_1_MEMORY3_BASE_ADDR
;
1065 pciMemWindowSizeReg
= PCI_1_MEMORY3_SIZE
;
1066 remapRegLow
= PCI_1_MEMORY3_LOW_ADDR_REMAP
;
1067 remapRegHigh
= PCI_1_MEMORY3_HIGH_ADDR_REMAP
;
1069 #endif /* INCLUDE_PCI_1 */
1071 /* Retrun an invalid effective base address */
1074 /* Writing the remap value to the remap regisers */
1075 GT_REG_WRITE (remapRegHigh
, remapValueHigh
);
1076 GT_REG_WRITE (remapRegLow
, remapValueLow
>> 16);
1077 /* Reading the values from the base address and size registers */
1078 baseAddrValue
= GTREGREAD (pciMemWindowBaseAddrReg
) & 0xfffff;
1079 windowSizeValue
= GTREGREAD (pciMemWindowSizeReg
) & 0xffff;
1080 /* Start calculating the effective Base Address */
1081 effectiveBaseAddress
= baseAddrValue
<< 16;
1082 /* The effective base address will be combined from the chopped (if any)
1083 remap value (according to the size value and remap mechanism) and the
1084 window's base address */
1085 effectiveBaseAddress
|=
1086 (((windowSizeValue
<< 16) | 0xffff) & remapValueLow
);
1087 /* If the effectiveBaseAddress exceed the window boundaries return an
1089 if (effectiveBaseAddress
>
1090 ((baseAddrValue
<< 16) + ((windowSizeValue
<< 16) | 0xffff)))
1092 return effectiveBaseAddress
;
1095 /********************************************************************
1096 * memorySetRegionSnoopMode - This function modifys one of the 4 regions which
1097 * supports Cache Coherency.
1100 * Inputs: SNOOP_REGION region - One of the four regions.
1101 * SNOOP_TYPE snoopType - There is four optional Types:
1103 * 2. Snoop to WT region.
1104 * 3. Snoop to WB region.
1105 * 4. Snoop & Invalidate to WB region.
1106 * unsigned int baseAddress - Base Address of this region.
1107 * unsigned int topAddress - Top Address of this region.
1108 * Returns: false if one of the parameters is wrong and true else
1109 *********************************************************************/
1112 bool memorySetRegionSnoopMode(MEMORY_SNOOP_REGION region
,
1113 MEMORY_SNOOP_TYPE snoopType
,
1114 unsigned int baseAddress
,
1115 unsigned int regionLength
)
1117 unsigned int snoopXbaseAddress
;
1118 unsigned int snoopXtopAddress
;
1120 unsigned int snoopHigh
= baseAddress
+ regionLength
;
1122 if( (region
> MEM_SNOOP_REGION3
) || (snoopType
> MEM_SNOOP_WB
) )
1124 snoopXbaseAddress
= SNOOP_BASE_ADDRESS_0
+ 0x10 * region
;
1125 snoopXtopAddress
= SNOOP_TOP_ADDRESS_0
+ 0x10 * region
;
1126 if(regionLength
== 0) /* closing the region */
1128 GT_REG_WRITE(snoopXbaseAddress
,0x0000ffff);
1129 GT_REG_WRITE(snoopXtopAddress
,0);
1132 baseAddress
= baseAddress
& 0xffff0000;
1133 data
= (baseAddress
>> 16) | snoopType
<< 16;
1134 GT_REG_WRITE(snoopXbaseAddress
,data
);
1135 snoopHigh
= (snoopHigh
& 0xfff00000) >> 20;
1136 GT_REG_WRITE(snoopXtopAddress
,snoopHigh
- 1);
1141 /********************************************************************
1142 * memoryRemapAddress - This fubction used for address remapping.
1145 * Inputs: regOffset: remap register
1147 * Returns: false if one of the parameters is erroneous,true otherwise.
1149 * Not needed function To_do !!!!
1150 *********************************************************************/
1151 bool memoryRemapAddress (unsigned int remapReg
, unsigned int remapValue
)
1153 unsigned int valueForReg
;
1155 valueForReg
= (remapValue
& 0xfff00000) >> 20;
1156 GT_REG_WRITE (remapReg
, valueForReg
);
1160 /*******************************************************************************
1161 * memoryGetDeviceParam - Extract the device parameters from the device bank
1162 * parameters register.
1165 * To allow interfacing with very slow devices and fast synchronous SRAMs,
1166 * each device can be programed to different timing parameters. Each bank
1167 * has its own parameters register. Bank width can be programmed to 8, 16,
1168 * or 32-bits. Bank timing parameters can be programmed to support
1169 * different device types (e.g. Sync Burst SRAM, Flash , ROM, I/O
1170 * Controllers). The MV allows you to set timing parameters and width for
1171 * each device through parameters register .
1172 * This function extracts the parameters described from the Device Bank
1173 * parameters register and fills the given 'deviceParam' (defined in
1174 * gtMemory.h) structure with the read data.
1177 * deviceParam - pointer to a structure DEVICE_PARAM (defined in
1178 * Memory.h).For details about each structure field please
1179 * see the device timing parameter section in the MV
1181 * deviceNum - Select on of the five device banks (defined in
1193 * false if one of the parameters is erroneous,true otherwise.
1195 *******************************************************************************/
1196 /********************************************************************
1197 * memoryGetDeviceParam - This function used for getting device parameters from
1198 * DEVICE BANK PARAMETERS REGISTER
1201 * Inputs: - deviceParam: STRUCT with paramiters for DEVICE BANK
1202 * PARAMETERS REGISTER
1203 * - deviceNum : number of device
1204 * Returns: false if one of the parameters is erroneous,true otherwise.
1205 *********************************************************************/
1207 bool memoryGetDeviceParam (DEVICE_PARAM
* deviceParam
, DEVICE deviceNum
)
1209 unsigned int valueOfReg
;
1210 unsigned int calcData
;
1214 GT_REG_READ (DEVICE_BANK0PARAMETERS
+ 4 * deviceNum
, &valueOfReg
);
1215 calcData
= (0x7 & valueOfReg
) + ((BIT22
& valueOfReg
) >> 19);
1216 deviceParam
->turnOff
= calcData
; /* Turn Off */
1218 calcData
= ((0x78 & valueOfReg
) >> 3) + ((BIT23
& valueOfReg
) >> 19);
1219 deviceParam
->acc2First
= calcData
; /* Access To First */
1221 calcData
= ((0x780 & valueOfReg
) >> 7) + ((BIT24
& valueOfReg
) >> 20);
1222 deviceParam
->acc2Next
= calcData
; /* Access To Next */
1225 ((0x3800 & valueOfReg
) >> 11) + ((BIT25
& valueOfReg
) >> 22);
1226 deviceParam
->ale2Wr
= calcData
; /* Ale To Write */
1228 calcData
= ((0x1c000 & valueOfReg
) >> 14) +
1229 ((BIT26
& valueOfReg
) >> 23);
1230 deviceParam
->wrLow
= calcData
; /* Write Active */
1232 calcData
= ((0xe0000 & valueOfReg
) >> 17) +
1233 ((BIT27
& valueOfReg
) >> 24);
1234 deviceParam
->wrHigh
= calcData
; /* Write High */
1236 calcData
= ((0x300000 & valueOfReg
) >> 20);
1237 deviceParam
->deviceWidth
= (BIT0
<< calcData
); /* In bytes */
1238 calcData
= ((0x30000000 & valueOfReg
) >> 28);
1239 deviceParam
->badrSkew
= calcData
; /* Cycles gap between BAdr
1240 toggle to read data sample. */
1241 calcData
= ((0x40000000 & valueOfReg
) >> 30);
1242 deviceParam
->DPEn
= calcData
; /* Data Parity enable */
1246 /*******************************************************************************
1247 * memorySetDeviceParam - Set new parameters for a device.
1251 * To allow interfacing with very slow devices and fast synchronous SRAMs,
1252 * each device can be programed to different timing parameters. Each bank
1253 * has its own parameters register. Bank width can be programmed to 8, 16,
1254 * or 32-bits. Bank timing parameters can be programmed to support
1255 * different device types (e.g. Sync Burst SRAM, Flash , ROM, I/O
1256 * Controllers). The MV allows you to set timing parameters and width for
1257 * each device through parameters register. This function set new
1258 * parameters to a device Bank from the delivered structure 'deviceParam'
1259 * (defined in gtMemory.h). The structure must be initialized with data
1260 * prior to the use of these function.
1263 * deviceParam - pointer to a structure DEVICE_PARAM (defined in
1264 * Memory.h).For details about each structure field please
1265 * see the device timing parameter section in the MV
1267 * deviceNum - Select on of the five device banks (defined in
1279 * false if one of the parameters is erroneous,true otherwise.
1281 *******************************************************************************/
1282 /********************************************************************
1283 * memorySetDeviceParam - This function used for setting device parameters to
1284 * DEVICE BANK PARAMETERS REGISTER
1287 * Inputs: - deviceParam: STRUCT for store paramiters from DEVICE BANK
1288 * PARAMETERS REGISTER
1289 * - deviceNum : number of device
1290 * Returns: false if one of the parameters is erroneous,true otherwise.
1291 *********************************************************************/
1292 bool memorySetDeviceParam (DEVICE_PARAM
* deviceParam
, DEVICE deviceNum
)
1294 unsigned int valueForReg
;
1296 if ((deviceParam
->turnOff
> 0x7) || (deviceParam
->acc2First
> 0xf) ||
1297 (deviceParam
->acc2Next
> 0xf) || (deviceParam
->ale2Wr
> 0x7) ||
1298 (deviceParam
->wrLow
> 0x7) || (deviceParam
->wrHigh
> 0x7) ||
1299 (deviceParam
->badrSkew
> 0x2) || (deviceParam
->DPEn
> 0x1)) {
1302 valueForReg
= (((deviceParam
->turnOff
) & 0x7) |
1303 (((deviceParam
->turnOff
) & 0x8) << 19) |
1304 (((deviceParam
->acc2First
) & 0xf) << 3) |
1305 (((deviceParam
->acc2First
) & 0x10) << 19) |
1306 (((deviceParam
->acc2Next
) & 0xf) << 7) |
1307 (((deviceParam
->acc2Next
) & 0x10) << 20) |
1308 (((deviceParam
->ale2Wr
) & 0x7) << 11) |
1309 (((deviceParam
->ale2Wr
) & 0xf) << 22) |
1310 (((deviceParam
->wrLow
) & 0x7) << 14) |
1311 (((deviceParam
->wrLow
) & 0xf) << 23) |
1312 (((deviceParam
->wrHigh
) & 0x7) << 17) |
1313 (((deviceParam
->wrHigh
) & 0xf) << 24) |
1314 (((deviceParam
->badrSkew
) & 0x3) << 28) |
1315 (((deviceParam
->DPEn
) & 0x1) << 30));
1317 /* insert the device width: */
1318 switch (deviceParam
->deviceWidth
) {
1320 valueForReg
= valueForReg
| _8BIT
;
1323 valueForReg
= valueForReg
| _16BIT
;
1326 valueForReg
= valueForReg
| _32BIT
;
1329 valueForReg
= valueForReg
| _8BIT
;
1332 GT_REG_WRITE (DEVICE_BANK0PARAMETERS
+ 4 * deviceNum
, valueForReg
);
1336 /*******************************************************************************
1337 * MemoryDisableWindow - Disable a memory space by the disable bit.
1339 * This function disables one of the 21 availiable windows dedicated for
1340 * the CPU decoding mechanism. Its possible to combine several windows with
1343 * window - One or more of the memory windows (defined in gtMemory.h).
1348 *******************************************************************************/
1349 void MemoryDisableWindow (MEMORY_WINDOW window
)
1351 SET_REG_BITS (BASE_ADDR_ENABLE
, window
);
1354 /*******************************************************************************
1355 * MemoryEnableWindow - Enable a memory space that was disabled by
1356 * 'MemoryDisableWindow'.
1358 * This function enables one of the 21 availiable windows dedicated for the
1359 * CPU decoding mechanism. Its possible to combine several windows with the
1362 * window - One or more of the memory windows (defined in gtMemory.h).
1367 *******************************************************************************/
1368 void MemoryEnableWindow (MEMORY_WINDOW window
)
1370 RESET_REG_BITS (BASE_ADDR_ENABLE
, window
);
1373 /*******************************************************************************
1374 * MemoryGetMemWindowStatus - This function check whether the memory window is
1377 * This function checks if the given memory window is closed .
1379 * window - One or more of the memory windows (defined in gtMemory.h).
1383 * True for a closed window, false otherwise .
1384 *******************************************************************************/
1385 MEMORY_WINDOW_STATUS
MemoryGetMemWindowStatus (MEMORY_WINDOW window
)
1387 if (GTREGREAD (BASE_ADDR_ENABLE
) & window
)
1388 return MEM_WINDOW_DISABLED
;
1389 return MEM_WINDOW_ENABLED
;