/******************************************************************************* * cpuTargetWinOverlap - Detect CPU address decode windows overlapping * * DESCRIPTION: * An unpredicted behaviur is expected in case CPU address decode * windows overlapps. * This function detects CPU address decode windows overlapping of a * specified target. The function does not check the target itself for * overlapping. The function also skipps disabled address decode windows. * * INPUT: * target - Peripheral target enumerator. * pAddrDecWin - An address decode window struct. * * OUTPUT: * None. * * RETURN: * MV_TRUE if the given address window overlaps current address * decode map, MV_FALSE otherwise. * *******************************************************************************/ static MV_BOOL cpuTargetWinOverlap(MV_TARGET target, MV_ADDR_WIN *pAddrWin) { MV_U32 targetNum; MV_CPU_DEC_WIN addrDecWin; MV_STATUS status; for(targetNum = 0; targetNum < MAX_TARGETS; targetNum++) { #if defined(MV_RUN_FROM_FLASH) if(MV_TARGET_IS_AS_BOOT(target)) { if (MV_CHANGE_BOOT_CS(targetNum) == target) continue; } #endif /* MV_RUN_FROM_FLASH */ /* don't check our target or illegal targets */ if (targetNum == target) { continue; } /* Get window parameters */ status = mvCpuIfTargetWinGet(targetNum, &addrDecWin); if(MV_NO_SUCH == status) { continue; } if(MV_OK != status) { DB(mvOsPrintf("cpuTargetWinOverlap: ERR. TargetWinGet failed\n")); return MV_TRUE; } /* Do not check disabled windows */ if (MV_FALSE == addrDecWin.enable) { continue; } if(MV_TRUE == ctrlWinOverlapTest(pAddrWin, &addrDecWin.addrWin)) { DB(mvOsPrintf( "cpuTargetWinOverlap: Required target %d overlap current %d\n", target, targetNum)); return MV_TRUE; } } return MV_FALSE; }
/******************************************************************************* * mvCpuIfInit - Initialize Controller CPU interface * * DESCRIPTION: * This function initialize Controller CPU interface: * 1. Set CPU interface configuration registers. * 2. Set CPU master Pizza arbiter control according to static * configuration described in configuration file. * 3. Opens CPU address decode windows. DRAM windows are assumed to be * already set (auto detection). * * INPUT: * None. * * OUTPUT: * None. * * RETURN: * None. * *******************************************************************************/ MV_STATUS mvCpuIfInit(MV_CPU_DEC_WIN *cpuAddrWinMap) { MV_U32 regVal; MV_TARGET target; MV_ADDR_WIN addrWin; int ii; if (cpuAddrWinMap == NULL) { DB(mvOsPrintf("mvCpuIfInit:ERR. cpuAddrWinMap == NULL\n")); return MV_ERROR; } /* Set ARM Configuration register */ regVal = MV_REG_READ(CPU_CONFIG_REG); regVal &= ~CPU_CONFIG_DEFAULT_MASK; /* regVal |= CPU_CONFIG_DEFAULT; Note: not needed */ MV_REG_WRITE(CPU_CONFIG_REG,regVal); /* First disable all CPU target windows */ for (target = 0; cpuAddrWinMap[target].enable != TBL_TERM; target++) { if ((MV_TARGET_IS_DRAM(target))||(target == INTER_REGS)) { continue; } #if defined(MV_MEM_OVER_PCI_WA) || defined(MV_UART_OVER_PCI_WA) /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ if (MV_TARGET_IS_PCI(target)) { continue; } #endif #if defined(MV_MEM_OVER_PEX_WA) || defined(MV_UART_OVER_PEX_WA) /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ if (MV_TARGET_IS_PEX(target)) { continue; } #endif #if defined(MV_RUN_FROM_FLASH) /* Don't disable the boot device. */ if (target == DEV_BOOCS) { continue; } #endif /* MV_RUN_FROM_FLASH */ mvCpuIfTargetWinEnable(MV_CHANGE_BOOT_CS(target),MV_FALSE); } /* TODO */ for (ii = 0; ii < 8; ii++) MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(ii), 0); #if defined(MV_RUN_FROM_FLASH) /* Resize the bootcs windows before other windows, because this */ /* window is enabled and will cause an overlap if not resized. */ target = DEV_BOOCS; if (MV_OK != mvCpuIfTargetWinSet(target, &cpuAddrWinMap[target])) { DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinSet fail\n")); return MV_ERROR; } addrWin.baseLow = cpuAddrWinMap[target].addrWin.baseLow; addrWin.baseHigh = cpuAddrWinMap[target].addrWin.baseHigh; if (0xffffffff == mvAhbToMbusWinRemap(cpuAddrWinMap[target].winNum ,&addrWin)) { DB(mvOsPrintf("mvCpuIfInit:WARN. mvAhbToMbusWinRemap can't remap winNum=%d\n", cpuAddrWinMap[target].winNum)); } #endif /* MV_RUN_FROM_FLASH */ /* Go through all targets in user table until table terminator */ for (target = 0; cpuAddrWinMap[target].enable != TBL_TERM; target++) { #if defined(MV_RUN_FROM_FLASH) if (target == DEV_BOOCS) { continue; } #endif /* MV_RUN_FROM_FLASH */ /* if DRAM auto sizing is used do not initialized DRAM target windows, */ /* assuming this already has been done earlier. */ #ifdef MV_DRAM_AUTO_SIZE if (MV_TARGET_IS_DRAM(target)) { continue; } #endif #if defined(MV_MEM_OVER_PCI_WA) || defined(MV_UART_OVER_PCI_WA) /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ if (MV_TARGET_IS_PCI(target)) { continue; } #endif #if defined(MV_MEM_OVER_PEX_WA) || defined(MV_UART_OVER_PEX_WA) /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ if (MV_TARGET_IS_PEX(target)) { continue; } #endif /* If the target attribute is the same as the boot device attribute */ /* then it's stays disable */ if (MV_TARGET_IS_AS_BOOT(target)) { continue; } if((0 == cpuAddrWinMap[target].addrWin.size) || (DIS == cpuAddrWinMap[target].enable)) { if (MV_OK != mvCpuIfTargetWinEnable(target, MV_FALSE)) { DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinEnable fail\n")); return MV_ERROR; } } else { if (MV_OK != mvCpuIfTargetWinSet(target, &cpuAddrWinMap[target])) { DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinSet fail\n")); return MV_ERROR; } addrWin.baseLow = cpuAddrWinMap[target].addrWin.baseLow; addrWin.baseHigh = cpuAddrWinMap[target].addrWin.baseHigh; if (0xffffffff == mvAhbToMbusWinRemap(cpuAddrWinMap[target].winNum ,&addrWin)) { DB(mvOsPrintf("mvCpuIfInit:WARN. mvAhbToMbusWinRemap can't remap winNum=%d\n", cpuAddrWinMap[target].winNum)); } } } #ifdef MV_INCLUDE_PEX mvCpuIfEnablePex(); #endif #ifdef MV_INCLUDE_PMU mvCpuIfEnablePmu(); #endif return MV_OK; }
/******************************************************************************* * mvCpuIfInit - Initialize Controller CPU interface * * DESCRIPTION: * This function initialize Controller CPU interface: * 1. Set CPU interface configuration registers. * 2. Set CPU master Pizza arbiter control according to static * configuration described in configuration file. * 3. Opens CPU address decode windows. DRAM windows are assumed to be * already set (auto detection). * * INPUT: * None. * * OUTPUT: * None. * * RETURN: * None. * *******************************************************************************/ MV_STATUS mvCpuIfInit(MV_CPU_DEC_WIN *cpuAddrWinMap) { MV_U32 regVal; MV_TARGET target; MV_ADDR_WIN addrWin; if (cpuAddrWinMap == NULL) { DB(mvOsPrintf("mvCpuIfInit:ERR. cpuAddrWinMap == NULL\n")); return MV_ERROR; } /*Initialize the boot target array according to device type*/ if(mvCtrlModelGet() == MV_6180_DEV_ID || mvCtrlModelGet() == MV_6280_DEV_ID) sampleAtResetTargetArray = sampleAtResetTargetArray6180P; else sampleAtResetTargetArray = sampleAtResetTargetArrayP; /* Set ARM Configuration register */ regVal = MV_REG_READ(CPU_CONFIG_REG); regVal &= ~CPU_CONFIG_DEFAULT_MASK; regVal |= CPU_CONFIG_DEFAULT; MV_REG_WRITE(CPU_CONFIG_REG,regVal); /* First disable all CPU target windows */ for (target = 0; cpuAddrWinMap[target].enable != TBL_TERM; target++) { if ((MV_TARGET_IS_DRAM(target))||(target == INTER_REGS)) { continue; } #if defined(MV_MEM_OVER_PCI_WA) || defined(MV_UART_OVER_PCI_WA) /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ if (MV_TARGET_IS_PCI(target)) { continue; } #endif #if defined(MV_MEM_OVER_PEX_WA) || defined(MV_UART_OVER_PEX_WA) /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ if (MV_TARGET_IS_PEX(target)) { continue; } #endif #if defined(MV_RUN_FROM_FLASH) /* Don't disable the boot device. */ if (target == DEV_BOOCS) { continue; } #endif /* MV_RUN_FROM_FLASH */ /* Only MV88F6282 have 2 PCIe interfaces */ if((mvCtrlModelGet() != MV_6282_DEV_ID) && MV_TARGET_IS_PEX1(target)) continue; mvCpuIfTargetWinEnable(MV_CHANGE_BOOT_CS(target),MV_FALSE); } #if defined(MV_RUN_FROM_FLASH) /* Resize the bootcs windows before other windows, because this */ /* window is enabled and will cause an overlap if not resized. */ target = DEV_BOOCS; if (MV_OK != mvCpuIfTargetWinSet(target, &cpuAddrWinMap[target])) { DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinSet fail\n")); return MV_ERROR; } addrWin.baseLow = cpuAddrWinMap[target].addrWin.baseLow; addrWin.baseHigh = cpuAddrWinMap[target].addrWin.baseHigh; if (0xffffffff == mvAhbToMbusWinRemap(cpuAddrWinMap[target].winNum ,&addrWin)) { DB(mvOsPrintf("mvCpuIfInit:WARN. mvAhbToMbusWinRemap can't remap winNum=%d\n", cpuAddrWinMap[target].winNum)); } #endif /* MV_RUN_FROM_FLASH */ /* Go through all targets in user table until table terminator */ for (target = 0; cpuAddrWinMap[target].enable != TBL_TERM; target++) { #if defined(MV_RUN_FROM_FLASH) if (target == DEV_BOOCS) { continue; } #endif /* MV_RUN_FROM_FLASH */ /* if DRAM auto sizing is used do not initialized DRAM target windows, */ /* assuming this already has been done earlier. */ #ifdef MV_DRAM_AUTO_SIZE if (MV_TARGET_IS_DRAM(target)) { continue; } #endif #if defined(MV_MEM_OVER_PCI_WA) || defined(MV_UART_OVER_PCI_WA) /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ if (MV_TARGET_IS_PCI(target)) { continue; } #endif #if defined(MV_MEM_OVER_PEX_WA) || defined(MV_UART_OVER_PEX_WA) /* If the target PEX or PCI and memory is over PEX or PCI we don't touch this CPU windows */ if (MV_TARGET_IS_PEX(target)) { continue; } #endif /* If the target attribute is the same as the boot device attribute */ /* then it's stays disable */ if (MV_TARGET_IS_AS_BOOT(target)) { continue; } /* Only MV88F6282 have 2 PCIe interfaces */ if((mvCtrlModelGet() != MV_6282_DEV_ID) && MV_TARGET_IS_PEX1(target)) continue; if((0 == cpuAddrWinMap[target].addrWin.size) || (DIS == cpuAddrWinMap[target].enable)) { if (MV_OK != mvCpuIfTargetWinEnable(target, MV_FALSE)) { DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinEnable fail\n")); return MV_ERROR; } } else { if (MV_OK != mvCpuIfTargetWinSet(target, &cpuAddrWinMap[target])) { DB(mvOsPrintf("mvCpuIfInit:ERR. mvCpuIfTargetWinSet fail\n")); return MV_ERROR; } addrWin.baseLow = cpuAddrWinMap[target].addrWin.baseLow; addrWin.baseHigh = cpuAddrWinMap[target].addrWin.baseHigh; if (0xffffffff == mvAhbToMbusWinRemap(cpuAddrWinMap[target].winNum ,&addrWin)) { DB(mvOsPrintf("mvCpuIfInit:WARN. mvAhbToMbusWinRemap can't remap winNum=%d\n", cpuAddrWinMap[target].winNum)); } } } return MV_OK; }