1 /*******************************************************************************
2 Copyright (C) Marvell International Ltd. and its affiliates
4 This software file (the "File") is owned and distributed by Marvell
5 International Ltd. and/or its affiliates ("Marvell") under the following
6 alternative licensing terms. Once you have made an election to distribute the
7 File under one of the following license alternatives, please (i) delete this
8 introductory statement regarding license alternatives, (ii) delete the two
9 license alternatives that you have not elected to use and (iii) preserve the
10 Marvell copyright notice above.
12 ********************************************************************************
13 Marvell Commercial License Option
15 If you received this File from Marvell and you have entered into a commercial
16 license agreement (a "Commercial License") with Marvell, the File is licensed
17 to you under the terms of the applicable Commercial License.
19 ********************************************************************************
20 Marvell GPL License Option
22 If you received this File from Marvell, you may opt to use, redistribute and/or
23 modify this File in accordance with the terms and conditions of the General
24 Public License Version 2, June 1991 (the "GPL License"), a copy of which is
25 available along with the File in the license.txt file or by writing to the Free
26 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or
27 on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
29 THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED
30 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY
31 DISCLAIMED. The GPL License provides additional details about this warranty
33 ********************************************************************************
34 Marvell BSD License Option
36 If you received this File from Marvell, you may opt to use, redistribute and/or
37 modify this File under the following licensing terms.
38 Redistribution and use in source and binary forms, with or without modification,
39 are permitted provided that the following conditions are met:
41 * Redistributions of source code must retain the above copyright notice,
42 this list of conditions and the following disclaimer.
44 * Redistributions in binary form must reproduce the above copyright
45 notice, this list of conditions and the following disclaimer in the
46 documentation and/or other materials provided with the distribution.
48 * Neither the name of Marvell nor the names of its contributors may be
49 used to endorse or promote products derived from this software without
50 specific prior written permission.
52 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
53 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
54 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
55 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
56 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
57 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
58 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
59 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
61 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 *******************************************************************************/
67 #include "ctrlEnv/sys/mvCpuIf.h"
68 #include "ctrlEnv/sys/mvAhbToMbusRegs.h"
69 #include "cpu/mvCpu.h"
70 #include "ctrlEnv/mvCtrlEnvLib.h"
71 #include "mvSysHwConfig.h"
72 #include "mvSysDram.h"
84 /* static functions */
85 static MV_BOOL cpuTargetWinOverlap(MV_TARGET target, MV_ADDR_WIN *pAddrWin);
87 MV_TARGET * sampleAtResetTargetArray;
88 MV_TARGET sampleAtResetTargetArrayP[] = BOOT_TARGETS_NAME_ARRAY;
89 MV_TARGET sampleAtResetTargetArray6180P[] = BOOT_TARGETS_NAME_ARRAY_6180;
90 /*******************************************************************************
91 * mvCpuIfInit - Initialize Controller CPU interface
94 * This function initialize Controller CPU interface:
95 * 1. Set CPU interface configuration registers.
96 * 2. Set CPU master Pizza arbiter control according to static
97 * configuration described in configuration file.
98 * 3. Opens CPU address decode windows. DRAM windows are assumed to be
99 * already set (auto detection).
110 *******************************************************************************/
111 MV_STATUS mvCpuIfInit(MV_CPU_DEC_WIN *cpuAddrWinMap)
117 if (cpuAddrWinMap == NULL)
119 DB(mvOsPrintf("mvCpuIfInit:ERR. cpuAddrWinMap == NULL\n"));
123 /*Initialize the boot target array according to device type*/
124 if(mvCtrlModelGet() == MV_6180_DEV_ID)
125 sampleAtResetTargetArray = sampleAtResetTargetArray6180P;
127 sampleAtResetTargetArray = sampleAtResetTargetArrayP;
129 /* Set ARM Configuration register */
130 regVal = MV_REG_READ(CPU_CONFIG_REG);
131 regVal &= ~CPU_CONFIG_DEFAULT_MASK;
132 regVal |= CPU_CONFIG_DEFAULT;
133 MV_REG_WRITE(CPU_CONFIG_REG,regVal);
135 /* First disable all CPU target windows */
136 for (target = 0; cpuAddrWinMap[target].enable != TBL_TERM; target++)
138 if ((MV_TARGET_IS_DRAM(target))||(target == INTER_REGS))
143 #if defined(MV_MEM_OVER_PCI_WA) || defined(MV_UART_OVER_PCI_WA)
144 /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */
145 if (MV_TARGET_IS_PCI(target))
151 #if defined(MV_MEM_OVER_PEX_WA) || defined(MV_UART_OVER_PEX_WA)
152 /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */
153 if (MV_TARGET_IS_PEX(target))
158 #if defined(MV_RUN_FROM_FLASH)
159 /* Don't disable the boot device. */
160 if (target == DEV_BOOCS)
164 #endif /* MV_RUN_FROM_FLASH */
165 mvCpuIfTargetWinEnable(MV_CHANGE_BOOT_CS(target),MV_FALSE);
168 #if defined(MV_RUN_FROM_FLASH)
169 /* Resize the bootcs windows before other windows, because this */
170 /* window is enabled and will cause an overlap if not resized. */
173 if (MV_OK != mvCpuIfTargetWinSet(target, &cpuAddrWinMap[target]))
175 DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinSet fail\n"));
179 addrWin.baseLow = cpuAddrWinMap[target].addrWin.baseLow;
180 addrWin.baseHigh = cpuAddrWinMap[target].addrWin.baseHigh;
181 if (0xffffffff == mvAhbToMbusWinRemap(cpuAddrWinMap[target].winNum ,&addrWin))
183 DB(mvOsPrintf("mvCpuIfInit:WARN. mvAhbToMbusWinRemap can't remap winNum=%d\n",
184 cpuAddrWinMap[target].winNum));
187 #endif /* MV_RUN_FROM_FLASH */
189 /* Go through all targets in user table until table terminator */
190 for (target = 0; cpuAddrWinMap[target].enable != TBL_TERM; target++)
193 #if defined(MV_RUN_FROM_FLASH)
194 if (target == DEV_BOOCS)
198 #endif /* MV_RUN_FROM_FLASH */
200 /* if DRAM auto sizing is used do not initialized DRAM target windows, */
201 /* assuming this already has been done earlier. */
202 #ifdef MV_DRAM_AUTO_SIZE
203 if (MV_TARGET_IS_DRAM(target))
209 #if defined(MV_MEM_OVER_PCI_WA) || defined(MV_UART_OVER_PCI_WA)
210 /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */
211 if (MV_TARGET_IS_PCI(target))
217 #if defined(MV_MEM_OVER_PEX_WA) || defined(MV_UART_OVER_PEX_WA)
218 /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */
219 if (MV_TARGET_IS_PEX(target))
224 /* If the target attribute is the same as the boot device attribute */
225 /* then it's stays disable */
226 if (MV_TARGET_IS_AS_BOOT(target))
231 if((0 == cpuAddrWinMap[target].addrWin.size) ||
232 (DIS == cpuAddrWinMap[target].enable))
235 if (MV_OK != mvCpuIfTargetWinEnable(target, MV_FALSE))
237 DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinEnable fail\n"));
244 if (MV_OK != mvCpuIfTargetWinSet(target, &cpuAddrWinMap[target]))
246 DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinSet fail\n"));
250 addrWin.baseLow = cpuAddrWinMap[target].addrWin.baseLow;
251 addrWin.baseHigh = cpuAddrWinMap[target].addrWin.baseHigh;
252 if (0xffffffff == mvAhbToMbusWinRemap(cpuAddrWinMap[target].winNum ,&addrWin))
254 DB(mvOsPrintf("mvCpuIfInit:WARN. mvAhbToMbusWinRemap can't remap winNum=%d\n",
255 cpuAddrWinMap[target].winNum));
268 /*******************************************************************************
269 * mvCpuIfTargetWinSet - Set CPU-to-peripheral target address window
272 * This function sets a peripheral target (e.g. SDRAM bank0, PCI0_MEM0)
273 * address window, also known as address decode window.
274 * A new address decode window is set for specified target address window.
275 * If address decode window parameter structure enables the window,
276 * the routine will also enable the target window, allowing CPU to access
280 * target - Peripheral target enumerator.
281 * pAddrDecWin - CPU target window data structure.
287 * MV_OK if CPU target window was set correctly, MV_ERROR in case of
288 * address window overlapps with other active CPU target window or
289 * trying to assign 36bit base address while CPU does not support that.
290 * The function returns MV_NOT_SUPPORTED, if the target is unsupported.
292 *******************************************************************************/
293 MV_STATUS mvCpuIfTargetWinSet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin)
295 MV_AHB_TO_MBUS_DEC_WIN decWin;
296 MV_U32 existingWinNum;
297 MV_DRAM_DEC_WIN addrDecWin;
299 target = MV_CHANGE_BOOT_CS(target);
301 /* Check parameters */
302 if (target >= MAX_TARGETS)
304 mvOsPrintf("mvCpuIfTargetWinSet: target %d is Illigal\n", target);
308 /* 2) Check if the requested window overlaps with current windows */
309 if (MV_TRUE == cpuTargetWinOverlap(target, &pAddrDecWin->addrWin))
311 mvOsPrintf("mvCpuIfTargetWinSet: ERR. Target %d overlap\n", target);
315 if (MV_TARGET_IS_DRAM(target))
317 /* copy relevant data to MV_DRAM_DEC_WIN structure */
318 addrDecWin.addrWin.baseHigh = pAddrDecWin->addrWin.baseHigh;
319 addrDecWin.addrWin.baseLow = pAddrDecWin->addrWin.baseLow;
320 addrDecWin.addrWin.size = pAddrDecWin->addrWin.size;
321 addrDecWin.enable = pAddrDecWin->enable;
324 if (mvDramIfWinSet(target,&addrDecWin) != MV_OK);
326 mvOsPrintf("mvCpuIfTargetWinSet: mvDramIfWinSet Failed\n");
333 /* copy relevant data to MV_AHB_TO_MBUS_DEC_WIN structure */
334 decWin.addrWin.baseLow = pAddrDecWin->addrWin.baseLow;
335 decWin.addrWin.baseHigh = pAddrDecWin->addrWin.baseHigh;
336 decWin.addrWin.size = pAddrDecWin->addrWin.size;
337 decWin.enable = pAddrDecWin->enable;
338 decWin.target = target;
340 existingWinNum = mvAhbToMbusWinTargetGet(target);
342 /* check if there is already another Window configured
344 if ((existingWinNum < MAX_AHB_TO_MBUS_WINS )&&
345 (existingWinNum != pAddrDecWin->winNum))
347 /* if we want to enable the new winow number
348 passed by the user , then the old one should
350 if (MV_TRUE == pAddrDecWin->enable)
352 /* be sure it is disabled */
353 mvAhbToMbusWinEnable(existingWinNum , MV_FALSE);
357 if (mvAhbToMbusWinSet(pAddrDecWin->winNum,&decWin) != MV_OK)
359 mvOsPrintf("mvCpuIfTargetWinSet: mvAhbToMbusWinSet Failed\n");
368 /*******************************************************************************
369 * mvCpuIfTargetWinGet - Get CPU-to-peripheral target address window
372 * Get the CPU peripheral target address window.
375 * target - Peripheral target enumerator
378 * pAddrDecWin - CPU target window information data structure.
381 * MV_OK if target exist, MV_ERROR otherwise.
383 *******************************************************************************/
384 MV_STATUS mvCpuIfTargetWinGet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin)
387 MV_U32 winNum=0xffffffff;
388 MV_AHB_TO_MBUS_DEC_WIN decWin;
389 MV_DRAM_DEC_WIN addrDecWin;
391 target = MV_CHANGE_BOOT_CS(target);
393 /* Check parameters */
394 if (target >= MAX_TARGETS)
396 mvOsPrintf("mvCpuIfTargetWinGet: target %d is Illigal\n", target);
400 if (MV_TARGET_IS_DRAM(target))
402 if (mvDramIfWinGet(target,&addrDecWin) != MV_OK)
404 mvOsPrintf("mvCpuIfTargetWinGet: Failed to get window target %d\n",
409 /* copy relevant data to MV_CPU_DEC_WIN structure */
410 pAddrDecWin->addrWin.baseLow = addrDecWin.addrWin.baseLow;
411 pAddrDecWin->addrWin.baseHigh = addrDecWin.addrWin.baseHigh;
412 pAddrDecWin->addrWin.size = addrDecWin.addrWin.size;
413 pAddrDecWin->enable = addrDecWin.enable;
414 pAddrDecWin->winNum = 0xffffffff;
419 /* get the Window number associated with this target */
421 winNum = mvAhbToMbusWinTargetGet(target);
422 if (winNum >= MAX_AHB_TO_MBUS_WINS)
428 if (mvAhbToMbusWinGet(winNum , &decWin) != MV_OK)
430 mvOsPrintf("%s: mvAhbToMbusWinGet Failed at winNum = %d\n",
431 __FUNCTION__, winNum);
436 /* copy relevant data to MV_CPU_DEC_WIN structure */
437 pAddrDecWin->addrWin.baseLow = decWin.addrWin.baseLow;
438 pAddrDecWin->addrWin.baseHigh = decWin.addrWin.baseHigh;
439 pAddrDecWin->addrWin.size = decWin.addrWin.size;
440 pAddrDecWin->enable = decWin.enable;
441 pAddrDecWin->winNum = winNum;
452 /*******************************************************************************
453 * mvCpuIfTargetWinEnable - Enable/disable a CPU address decode window
456 * This function enable/disable a CPU address decode window.
457 * if parameter 'enable' == MV_TRUE the routine will enable the
458 * window, thus enabling CPU accesses (before enabling the window it is
459 * tested for overlapping). Otherwise, the window will be disabled.
462 * target - Peripheral target enumerator.
463 * enable - Enable/disable parameter.
469 * MV_ERROR if protection window number was wrong, or the window
470 * overlapps other target window.
472 *******************************************************************************/
473 MV_STATUS mvCpuIfTargetWinEnable(MV_TARGET target,MV_BOOL enable)
476 MV_CPU_DEC_WIN addrDecWin;
478 target = MV_CHANGE_BOOT_CS(target);
480 /* Check parameters */
481 if (target >= MAX_TARGETS)
483 mvOsPrintf("mvCpuIfTargetWinEnable: target %d is Illigal\n", target);
487 /* get the window and check if it exist */
488 temp = mvCpuIfTargetWinGet(target, &addrDecWin);
489 if (MV_NO_SUCH == temp)
491 return (enable? MV_ERROR: MV_OK);
493 else if( MV_OK != temp)
495 mvOsPrintf("%s: ERR. Getting target %d failed.\n",__FUNCTION__, target);
502 if (MV_TRUE == enable)
504 if (MV_TRUE == cpuTargetWinOverlap(target, &addrDecWin.addrWin))
506 DB(mvOsPrintf("%s: ERR. Target %d overlap\n",__FUNCTION__, target));
513 if (MV_TARGET_IS_DRAM(target))
515 if (mvDramIfWinEnable(target , enable) != MV_OK)
517 mvOsPrintf("mvCpuIfTargetWinGet: mvDramIfWinEnable Failed at \n");
525 /* get the Window number associated with this target */
527 winNum = mvAhbToMbusWinTargetGet(target);
529 if (winNum >= MAX_AHB_TO_MBUS_WINS)
531 return (enable? MV_ERROR: MV_OK);
534 if (mvAhbToMbusWinEnable(winNum , enable) != MV_OK)
536 mvOsPrintf("mvCpuIfTargetWinGet: Failed to enable window = %d\n",
548 /*******************************************************************************
549 * mvCpuIfTargetWinSizeGet - Get CPU target address window size
552 * Get the size of CPU-to-peripheral target window.
555 * target - Peripheral target enumerator
561 * 32bit size. Function also returns '0' if window is closed.
562 * Function returns 0xFFFFFFFF in case of an error.
564 *******************************************************************************/
565 MV_U32 mvCpuIfTargetWinSizeGet(MV_TARGET target)
567 MV_CPU_DEC_WIN addrDecWin;
569 target = MV_CHANGE_BOOT_CS(target);
571 /* Check parameters */
572 if (target >= MAX_TARGETS)
574 mvOsPrintf("mvCpuIfTargetWinSizeGet: target %d is Illigal\n", target);
578 /* Get the winNum window */
579 if (MV_OK != mvCpuIfTargetWinGet(target, &addrDecWin))
581 mvOsPrintf("mvCpuIfTargetWinSizeGet:ERR. Getting target %d failed.\n",
586 /* Check if window is enabled */
587 if (addrDecWin.enable == MV_TRUE)
589 return (addrDecWin.addrWin.size);
593 return 0; /* Window disabled. return 0 */
597 /*******************************************************************************
598 * mvCpuIfTargetWinBaseLowGet - Get CPU target address window base low
601 * CPU-to-peripheral target address window base is constructed of
602 * two parts: Low and high.
603 * This function gets the CPU peripheral target low base address.
606 * target - Peripheral target enumerator
612 * 32bit low base address.
614 *******************************************************************************/
615 MV_U32 mvCpuIfTargetWinBaseLowGet(MV_TARGET target)
617 MV_CPU_DEC_WIN addrDecWin;
619 target = MV_CHANGE_BOOT_CS(target);
621 /* Check parameters */
622 if (target >= MAX_TARGETS)
624 mvOsPrintf("mvCpuIfTargetWinBaseLowGet: target %d is Illigal\n", target);
628 /* Get the target window */
629 if (MV_OK != mvCpuIfTargetWinGet(target, &addrDecWin))
631 mvOsPrintf("mvCpuIfTargetWinBaseLowGet:ERR. Getting target %d failed.\n",
636 if (MV_FALSE == addrDecWin.enable)
640 return (addrDecWin.addrWin.baseLow);
643 /*******************************************************************************
644 * mvCpuIfTargetWinBaseHighGet - Get CPU target address window base high
647 * CPU-to-peripheral target address window base is constructed of
648 * two parts: Low and high.
649 * This function gets the CPU peripheral target high base address.
652 * target - Peripheral target enumerator
658 * 32bit high base address.
660 *******************************************************************************/
661 MV_U32 mvCpuIfTargetWinBaseHighGet(MV_TARGET target)
663 MV_CPU_DEC_WIN addrDecWin;
665 target = MV_CHANGE_BOOT_CS(target);
667 /* Check parameters */
668 if (target >= MAX_TARGETS)
670 mvOsPrintf("mvCpuIfTargetWinBaseLowGet: target %d is Illigal\n", target);
674 /* Get the target window */
675 if (MV_OK != mvCpuIfTargetWinGet(target, &addrDecWin))
677 mvOsPrintf("mvCpuIfTargetWinBaseHighGet:ERR. Getting target %d failed.\n",
682 if (MV_FALSE == addrDecWin.enable)
687 return (addrDecWin.addrWin.baseHigh);
690 #if defined(MV_INCLUDE_PEX)
691 /*******************************************************************************
692 * mvCpuIfPexRemap - Set CPU remap register for address windows.
697 * pexTarget - Peripheral target enumerator. Must be a PEX target.
698 * pAddrDecWin - CPU target window information data structure.
699 * Note that caller has to fill in the base field only. The
700 * size field is ignored.
706 * MV_ERROR if target is not a PEX one, MV_OK otherwise.
708 *******************************************************************************/
709 MV_U32 mvCpuIfPexRemap(MV_TARGET pexTarget, MV_ADDR_WIN *pAddrDecWin)
713 /* Check parameters */
715 if (mvCtrlPexMaxIfGet() > 1)
717 if ((!MV_TARGET_IS_PEX1(pexTarget))&&(!MV_TARGET_IS_PEX0(pexTarget)))
719 mvOsPrintf("mvCpuIfPexRemap: target %d is Illigal\n",pexTarget);
726 if (!MV_TARGET_IS_PEX0(pexTarget))
728 mvOsPrintf("mvCpuIfPexRemap: target %d is Illigal\n",pexTarget);
734 /* get the Window number associated with this target */
735 winNum = mvAhbToMbusWinTargetGet(pexTarget);
737 if (winNum >= MAX_AHB_TO_MBUS_WINS)
739 mvOsPrintf("mvCpuIfPexRemap: mvAhbToMbusWinTargetGet Failed\n");
744 return mvAhbToMbusWinRemap(winNum , pAddrDecWin);
749 #if defined(MV_INCLUDE_PCI)
750 /*******************************************************************************
751 * mvCpuIfPciRemap - Set CPU remap register for address windows.
756 * pciTarget - Peripheral target enumerator. Must be a PCI target.
757 * pAddrDecWin - CPU target window information data structure.
758 * Note that caller has to fill in the base field only. The
759 * size field is ignored.
765 * MV_ERROR if target is not a PCI one, MV_OK otherwise.
767 *******************************************************************************/
768 MV_U32 mvCpuIfPciRemap(MV_TARGET pciTarget, MV_ADDR_WIN *pAddrDecWin)
772 /* Check parameters */
773 if (!MV_TARGET_IS_PCI(pciTarget))
775 mvOsPrintf("mvCpuIfPciRemap: target %d is Illigal\n",pciTarget);
779 /* get the Window number associated with this target */
780 winNum = mvAhbToMbusWinTargetGet(pciTarget);
782 if (winNum >= MAX_AHB_TO_MBUS_WINS)
784 mvOsPrintf("mvCpuIfPciRemap: mvAhbToMbusWinTargetGet Failed\n");
789 return mvAhbToMbusWinRemap(winNum , pAddrDecWin);
791 #endif /* MV_INCLUDE_PCI */
794 /*******************************************************************************
795 * mvCpuIfPciIfRemap - Set CPU remap register for address windows.
800 * pciTarget - Peripheral target enumerator. Must be a PCI target.
801 * pAddrDecWin - CPU target window information data structure.
802 * Note that caller has to fill in the base field only. The
803 * size field is ignored.
809 * MV_ERROR if target is not a PCI one, MV_OK otherwise.
811 *******************************************************************************/
812 MV_U32 mvCpuIfPciIfRemap(MV_TARGET pciIfTarget, MV_ADDR_WIN *pAddrDecWin)
814 #if defined(MV_INCLUDE_PEX)
815 if (MV_TARGET_IS_PEX(pciIfTarget))
817 return mvCpuIfPexRemap(pciIfTarget,pAddrDecWin);
820 #if defined(MV_INCLUDE_PCI)
822 if (MV_TARGET_IS_PCI(pciIfTarget))
824 return mvCpuIfPciRemap(pciIfTarget,pAddrDecWin);
832 /*******************************************************************************
833 * mvCpuIfTargetOfBaseAddressGet - Get the target according to base address
838 * baseAddress - base address to be checked
844 * the target number that baseAddress belongs to or MAX_TARGETS is not
847 *******************************************************************************/
849 MV_TARGET mvCpuIfTargetOfBaseAddressGet(MV_U32 baseAddress)
854 for( target = 0; target < MAX_TARGETS; target++ )
856 if( mvCpuIfTargetWinGet( target, &win ) == MV_OK )
860 if ((baseAddress >= win.addrWin.baseLow) &&
861 (baseAddress < win.addrWin.baseLow + win.addrWin.size)) break;
864 else return MAX_TARGETS;
870 /*******************************************************************************
871 * cpuTargetWinOverlap - Detect CPU address decode windows overlapping
874 * An unpredicted behaviur is expected in case CPU address decode
876 * This function detects CPU address decode windows overlapping of a
877 * specified target. The function does not check the target itself for
878 * overlapping. The function also skipps disabled address decode windows.
881 * target - Peripheral target enumerator.
882 * pAddrDecWin - An address decode window struct.
888 * MV_TRUE if the given address window overlaps current address
889 * decode map, MV_FALSE otherwise.
891 *******************************************************************************/
892 static MV_BOOL cpuTargetWinOverlap(MV_TARGET target, MV_ADDR_WIN *pAddrWin)
895 MV_CPU_DEC_WIN addrDecWin;
899 for(targetNum = 0; targetNum < MAX_TARGETS; targetNum++)
901 #if defined(MV_RUN_FROM_FLASH)
902 if(MV_TARGET_IS_AS_BOOT(target))
904 if (MV_CHANGE_BOOT_CS(targetNum) == target)
907 #endif /* MV_RUN_FROM_FLASH */
909 /* don't check our target or illegal targets */
910 if (targetNum == target)
915 /* Get window parameters */
916 status = mvCpuIfTargetWinGet(targetNum, &addrDecWin);
917 if(MV_NO_SUCH == status)
923 DB(mvOsPrintf("cpuTargetWinOverlap: ERR. TargetWinGet failed\n"));
927 /* Do not check disabled windows */
928 if (MV_FALSE == addrDecWin.enable)
933 if(MV_TRUE == ctrlWinOverlapTest(pAddrWin, &addrDecWin.addrWin))
936 "cpuTargetWinOverlap: Required target %d overlap current %d\n",
946 /*******************************************************************************
947 * mvCpuIfAddDecShow - Print the CPU address decode map.
950 * This function print the CPU address decode map.
961 *******************************************************************************/
962 MV_VOID mvCpuIfAddDecShow(MV_VOID)
967 mvOsOutput( "CPU Interface\n" );
968 mvOsOutput( "-------------\n" );
970 for( target = 0; target < MAX_TARGETS; target++ )
973 memset( &win, 0, sizeof(MV_CPU_DEC_WIN) );
975 mvOsOutput( "%s ",mvCtrlTargetNameGet(target));
976 mvOsOutput( "...." );
978 if( mvCpuIfTargetWinGet( target, &win ) == MV_OK )
982 mvOsOutput( "base %08x, ", win.addrWin.baseLow );
983 mvSizePrint( win.addrWin.size );
988 mvOsOutput( "disable\n" );
990 else if( mvCpuIfTargetWinGet( target, &win ) == MV_NO_SUCH )
992 mvOsOutput( "no such\n" );
997 /*******************************************************************************
998 * mvCpuIfEnablePex - Enable PCI Express.
1001 * This function Enable PCI Express.
1004 * pexIf - PEX interface number.
1005 * pexType - MV_PEX_ROOT_COMPLEX - root complex device
1006 * MV_PEX_END_POINT - end point device
1013 *******************************************************************************/
1014 #if defined(MV_INCLUDE_PEX)
1015 MV_VOID mvCpuIfEnablePex(MV_U32 pexIf, MV_PEX_TYPE pexType)
1017 /* Set pex mode incase S@R not exist */
1018 if( pexType == MV_PEX_END_POINT)
1020 MV_REG_BIT_RESET(PEX_CTRL_REG(pexIf),PXCR_DEV_TYPE_CTRL_MASK);
1021 /* Change pex mode in capability reg */
1022 MV_REG_BIT_RESET(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_CAPABILITY_REG), BIT22);
1023 MV_REG_BIT_SET(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_CAPABILITY_REG), BIT20);
1028 MV_REG_BIT_SET(PEX_CTRL_REG(pexIf),PXCR_DEV_TYPE_CTRL_MASK);
1031 /* CPU config register Pex enable */
1032 MV_REG_BIT_SET(CPU_CTRL_STAT_REG,CCSR_PCI_ACCESS_MASK);