/******************************************************************************* * mvAhbToMbusAddDecShow - Print the AHB to MBus bridge address decode map. * * DESCRIPTION: * This function print the CPU address decode map. * * INPUT: * None. * * OUTPUT: * None. * * RETURN: * None. * *******************************************************************************/ MV_VOID mvAhbToMbusAddDecShow(MV_VOID) { MV_AHB_TO_MBUS_DEC_WIN win; MV_U32 winNum; mvOsOutput( "\n" ); mvOsOutput( "AHB To MBUS Bridge:\n" ); mvOsOutput( "-------------------\n" ); for( winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS; winNum++ ) { memset( &win, 0, sizeof(MV_AHB_TO_MBUS_DEC_WIN) ); mvOsOutput( "win%d - ", winNum ); if( mvAhbToMbusWinGet( winNum, &win ) == MV_OK ) { if( win.enable ) { mvOsOutput( "%s base %08x, ", mvCtrlTargetNameGet(win.target), win.addrWin.baseLow ); mvOsOutput( "...." ); mvSizePrint( win.addrWin.size ); mvOsOutput( "\n" ); } else mvOsOutput( "disable\n" ); } } }
/******************************************************************************* * mvAhbToMbusWinAvailGet - Get First Available window number. * * DESCRIPTION: * * INPUT: * * OUTPUT: * * RETURN: * *******************************************************************************/ MV_U32 mvAhbToMbusWinAvailGet(MV_VOID) { MV_AHB_TO_MBUS_DEC_WIN decWin; MV_U32 winNum; for (winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS ; winNum++) { if (winNum == MV_AHB_TO_MBUS_INTREG_WIN) continue; if (mvAhbToMbusWinGet(winNum,&decWin) != MV_OK) { mvOsPrintf("mvAhbToMbusWinTargetGet: mvAhbToMbusWinGet fail\n"); return 0xffffffff; } if (decWin.enable == MV_FALSE) { return winNum; } } return 0xFFFFFFFF; }
/******************************************************************************* * mvAhbToMbusWinAvailGet - Get First Available window number. * * DESCRIPTION: * * INPUT: * * OUTPUT: * * RETURN: * *******************************************************************************/ MV_U32 mvAhbToMbusWinAvailGet(MV_U32 cpu) { MV_AHB_TO_MBUS_DEC_WIN decWin; MV_U32 winNum; if (cpu >= MV_MAX_CPU) { mvOsPrintf("mvAhbToMbusWinAvailGet: ERR. Invalid cpu %d\n", cpu); return MV_NOT_SUPPORTED; } for (winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS ; winNum++) { if (winNum == MV_AHB_TO_MBUS_INTREG_WIN) continue; if (mvAhbToMbusWinGet(cpu, winNum,&decWin) != MV_OK) { mvOsPrintf("mvAhbToMbusWinTargetGet: mvAhbToMbusWinGet fail\n"); return 0xffffffff; } if (decWin.enable == MV_FALSE) { return winNum; } } return 0xFFFFFFFF; }
/******************************************************************************* * mvAhbToMbusWinTargetGet - Get Window number associated with target * * DESCRIPTION: * * INPUT: * * OUTPUT: * * RETURN: * *******************************************************************************/ MV_U32 mvAhbToMbusWinTargetGet(MV_TARGET target) { MV_AHB_TO_MBUS_DEC_WIN decWin; MV_U32 winNum; /* Check parameters */ if (target >= MAX_TARGETS) { mvOsPrintf("mvAhbToMbusWinTargetGet: target %d is illegal\n", target); return 0xffffffff; } if (INTER_REGS == target) return MV_AHB_TO_MBUS_INTREG_WIN; for (winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS; winNum++) { if (winNum == MV_AHB_TO_MBUS_INTREG_WIN) continue; if (mvAhbToMbusWinGet(winNum, &decWin) != MV_OK) { mvOsPrintf("mvAhbToMbusWinTargetGet: mvAhbToMbusWinGet fail\n"); return 0xffffffff; } if (decWin.enable == MV_TRUE) { if (decWin.target == target) return winNum; } } return 0xFFFFFFFF; }
/******************************************************************************* * mvCpuIfTargetWinGet - Get CPU-to-peripheral target address window * * DESCRIPTION: * Get the CPU peripheral target address window. * * INPUT: * target - Peripheral target enumerator * * OUTPUT: * pAddrDecWin - CPU target window information data structure. * * RETURN: * MV_OK if target exist, MV_ERROR otherwise. * *******************************************************************************/ MV_STATUS mvCpuIfTargetWinGet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin) { MV_U32 winNum=0xffffffff; MV_AHB_TO_MBUS_DEC_WIN decWin; MV_DRAM_DEC_WIN addrDecWin; target = MV_CHANGE_BOOT_CS(target); /* Check parameters */ if (target >= MAX_TARGETS) { mvOsPrintf("mvCpuIfTargetWinGet: target %d is illegal\n", target); return MV_ERROR; } if (MV_TARGET_IS_DRAM(target)) { if (mvDramIfWinGet(target,&addrDecWin) != MV_OK) { mvOsPrintf("mvCpuIfTargetWinGet: Failed to get window target %d\n", target); return MV_ERROR; } /* copy relevant data to MV_CPU_DEC_WIN structure */ pAddrDecWin->addrWin.baseLow = addrDecWin.addrWin.baseLow; pAddrDecWin->addrWin.baseHigh = addrDecWin.addrWin.baseHigh; pAddrDecWin->addrWin.size = addrDecWin.addrWin.size; pAddrDecWin->enable = addrDecWin.enable; pAddrDecWin->winNum = 0xffffffff; } else { /* get the Window number associated with this target */ winNum = mvAhbToMbusWinTargetGet(target); if (winNum >= MAX_AHB_TO_MBUS_WINS) { return MV_NO_SUCH; } if (mvAhbToMbusWinGet(winNum , &decWin) != MV_OK) { mvOsPrintf("%s: mvAhbToMbusWinGet Failed at winNum = %d\n", __FUNCTION__, winNum); return MV_ERROR; } /* copy relevant data to MV_CPU_DEC_WIN structure */ pAddrDecWin->addrWin.baseLow = decWin.addrWin.baseLow; pAddrDecWin->addrWin.baseHigh = decWin.addrWin.baseHigh; pAddrDecWin->addrWin.size = decWin.addrWin.size; pAddrDecWin->enable = decWin.enable; pAddrDecWin->winNum = winNum; } return MV_OK; }
/******************************************************************************* * mvAhbToMbusWinTargetGet - Get Window number associated with target * * DESCRIPTION: * * INPUT: * * OUTPUT: * * RETURN: * *******************************************************************************/ MV_U32 mvAhbToMbusWinTargetGet(MV_TARGET target) { MV_AHB_TO_MBUS_DEC_WIN decWin; MV_U32 winNum; if (target >= MAX_TARGETS) { mvOsPrintf("%s: Error: target %d is illegal\n", __func__, target); return 0xffffffff; } if (INTER_REGS == target) return MV_AHB_TO_MBUS_INTREG_WIN; for (winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS; winNum++) { if (winNum == MV_AHB_TO_MBUS_INTREG_WIN) continue; if (mvAhbToMbusWinGet(winNum, &decWin) != MV_OK) { mvOsPrintf("%s: Error: mvAhbToMbusWinGet(winNum = %d) failed\n", __func__, winNum); return 0xffffffff; } if (decWin.enable == MV_TRUE) { if (decWin.target == target) return winNum; } } return 0xFFFFFFFF; }
static void save_kw2_cpu_win_state(void) { u32 i; MV_AHB_TO_MBUS_DEC_WIN winInfo; /* Save CPU windows state, and enable access for Bootrom * ** according to SoC default address decoding windows. */ for(i = 0; i < MAX_AHB_TO_MBUS_WINS; i++) { mvAhbToMbusWinGet(i, &ahbAddrDecWin[i]); mvAhbToMbusWinRemapGet(i, &ahbAddrWinRemap[i]); /* Disable the window */ mvAhbToMbusWinEnable(i, MV_FALSE); } /* Open default windows for Bootrom, PnC and internal regs. */ /* Bootrom */ winInfo.target = BOOT_ROM_CS; winInfo.addrWin.baseLow = 0xF8000000; winInfo.addrWin.baseHigh = 0x0; winInfo.addrWin.size = _128M; winInfo.enable = MV_TRUE; mvAhbToMbusWinSet(7, &winInfo); /* PnC */ winInfo.target = PNC_BM; winInfo.addrWin.baseLow = 0xC0060000; winInfo.addrWin.baseHigh = 0x0; winInfo.addrWin.size = _64K; winInfo.enable = MV_TRUE; mvAhbToMbusWinSet(6, &winInfo); #if 0 /* Internal regs */ winInfo.target = INTER_REGS; winInfo.addrWin.baseLow = 0xD0000000; winInfo.addrWin.baseHigh = 0x0; winInfo.addrWin.size = _1M; winInfo.enable = MV_TRUE; mvAhbToMbusWinSet(MV_AHB_TO_MBUS_INTREG_WIN, &winInfo); #endif /* Cesa SRAM */ winInfo.target = CRYPT1_ENG; winInfo.addrWin.baseLow = 0xC8010000; winInfo.addrWin.baseHigh = 0x0; winInfo.addrWin.size = _64K; winInfo.enable = MV_TRUE; mvAhbToMbusWinSet(4, &winInfo); }
/******************************************************************************* * mvAhbToMbusWinTargetGet - Get Window number associated with target * * DESCRIPTION: * * INPUT: * * OUTPUT: * * RETURN: * *******************************************************************************/ MV_U32 mvAhbToMbusWinTargetGet(MV_U32 cpu, MV_TARGET target) { MV_AHB_TO_MBUS_DEC_WIN decWin; MV_U32 winNum; /* Parameter checking */ if (cpu >= MV_MAX_CPU) { mvOsPrintf("mvAhbToMbusWinTargetGet: ERR. Invalid cpu %d\n", cpu); return MV_NOT_SUPPORTED; } /* Check parameters */ if (target >= MAX_TARGETS) { mvOsPrintf("mvAhbToMbusWinTargetGet: target %d is Illigal\n", target); return 0xffffffff; } if (INTER_REGS == target) { return MV_AHB_TO_MBUS_INTREG_WIN; } for (winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS ; winNum++) { if (winNum == MV_AHB_TO_MBUS_INTREG_WIN) continue; if (mvAhbToMbusWinGet(cpu,winNum,&decWin) != MV_OK) { mvOsPrintf("mvAhbToMbusWinTargetGet: mvAhbToMbusWinGet fail, win %d\n", winNum); return 0xffffffff; } if (decWin.enable == MV_TRUE) { if (decWin.target == target) { return winNum; } } } return 0xFFFFFFFF; }
/******************************************************************************* * mvAhbToMbusAddDecShow - Print the Ahb to MBus bridge address decode map. * * DESCRIPTION: * This function print the CPU address decode map. * * INPUT: * cpu - CPU id * * OUTPUT: * None. * * RETURN: * None. * *******************************************************************************/ MV_VOID mvAhbToMbusAddDecShow(MV_U32 cpu) { MV_AHB_TO_MBUS_DEC_WIN win; MV_U32 winNum; /* Check parameters */ if (cpu >= MV_MAX_CPU) { mvOsPrintf("mvAhbToMbusAddDecShow: ERR. Invalid cpu %d\n", cpu); return; } mvOsOutput( "\n" ); mvOsOutput( "CPU %d, AHB To MBUS Bridge:\n", cpu); mvOsOutput( "-------------------\n" ); for( winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS; winNum++ ) { memset( &win, 0, sizeof(MV_AHB_TO_MBUS_DEC_WIN) ); mvOsOutput( "win%d - ", winNum ); if( mvAhbToMbusWinGet(cpu, winNum, &win ) == MV_OK ) { if( win.enable ) { mvOsOutput( "%s base %08x, ", mvCtrlTargetNameGet(win.target), win.addrWin.baseLow ); mvOsOutput( "...." ); mvSizePrint( win.addrWin.size ); mvOsOutput( "\n" ); } else mvOsOutput( "disable\n" ); } } }
MV_U32 mvPexHwConfigRead (MV_U32 pexIf, MV_U32 bus, MV_U32 dev, MV_U32 func, MV_U32 regOff) { #endif MV_U32 pexData = 0; MV_U32 localDev,localBus; /* Parameter checking */ if (PEX_DEFAULT_IF != pexIf) { if (pexIf >= mvCtrlPexMaxIfGet()) { mvOsPrintf("mvPexConfigRead: ERR. Invalid PEX interface %d\n",pexIf); return 0xFFFFFFFF; } } if (dev >= MAX_PEX_DEVICES) { DB(mvOsPrintf("mvPexConfigRead: ERR. device number illigal %d\n", dev)); return 0xFFFFFFFF; } if (func >= MAX_PEX_FUNCS) { DB(mvOsPrintf("mvPexConfigRead: ERR. function num illigal %d\n", func)); return 0xFFFFFFFF; } if (bus >= MAX_PEX_BUSSES) { DB(mvOsPrintf("mvPexConfigRead: ERR. bus number illigal %d\n", bus)); return MV_ERROR; } DB(mvOsPrintf("mvPexConfigRead: pexIf %d, bus %d, dev %d, func %d, regOff 0x%x\n", pexIf, bus, dev, func, regOff)); localDev = mvPexLocalDevNumGet(pexIf); localBus = mvPexLocalBusNumGet(pexIf); /* Speed up the process. In case on no link, return MV_ERROR */ if ((dev != localDev) || (bus != localBus)) { pexData = MV_REG_READ(PEX_STATUS_REG(pexIf)); if ((pexData & PXSR_DL_DOWN)) { return MV_ERROR; } } /* in PCI Express we have only one device number */ /* and this number is the first number we encounter else that the localDev*/ /* spec pex define return on config read/write on any device */ if (bus == localBus) { if (localDev == 0) { /* if local dev is 0 then the first number we encounter after 0 is 1 */ if ((dev != 1)&&(dev != localDev)) { return MV_ERROR; } } else { /* if local dev is not 0 then the first number we encounter is 0 */ if ((dev != 0)&&(dev != localDev)) { return MV_ERROR; } } if(func != 0 ) /* i.e bridge */ { return MV_ERROR; } } /* Creating PEX address to be passed */ pexData = (bus << PXCAR_BUS_NUM_OFFS); pexData |= (dev << PXCAR_DEVICE_NUM_OFFS); pexData |= (func << PXCAR_FUNC_NUM_OFFS); pexData |= (regOff & PXCAR_REG_NUM_MASK); /* lgacy register space */ /* extended register space */ pexData |=(((regOff & PXCAR_REAL_EXT_REG_NUM_MASK) >> PXCAR_REAL_EXT_REG_NUM_OFFS) << PXCAR_EXT_REG_NUM_OFFS); pexData |= PXCAR_CONFIG_EN; /* Write the address to the PEX configuration address register */ MV_REG_WRITE(PEX_CFG_ADDR_REG(pexIf), pexData); DB(mvOsPrintf("mvPexConfigRead:address pexData=%x ",pexData)); /* In order to let the PEX controller absorbed the address of the read */ /* transaction we perform a validity check that the address was written */ if(pexData != MV_REG_READ(PEX_CFG_ADDR_REG(pexIf))) { return MV_ERROR; } /* cleaning Master Abort */ MV_REG_BIT_SET(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_STATUS_AND_COMMAND), PXSAC_MABORT); #if 0 /* Guideline (GL# PCI Express-1) Erroneous Read Data on Configuration */ /* This guideline is relevant for all devices except of the following devices: 88F5281-BO and above, 88F5181L-A0 and above, 88F1281 A0 and above 88F6183 A0 and above, 88F6183L */ if ( ( (dev != localDev) || (bus != localBus) ) && ( !(MV_5281_DEV_ID == mvCtrlModelGet())&& !((MV_5181_DEV_ID == mvCtrlModelGet())&& (mvCtrlRevGet() >= MV_5181L_A0_REV))&& !(MV_1281_DEV_ID == mvCtrlModelGet())&& !(MV_6183_DEV_ID == mvCtrlModelGet())&& !(MV_6183L_DEV_ID == mvCtrlModelGet())&& !(MV_6281_DEV_ID == mvCtrlModelGet())&& !(MV_6192_DEV_ID == mvCtrlModelGet())&& !(MV_6190_DEV_ID == mvCtrlModelGet())&& !(MV_6180_DEV_ID == mvCtrlModelGet())&& !(MV_78XX0_DEV_ID == mvCtrlModelGet()) )) { /* PCI-Express configuration read work-around */ /* we will use one of the Punit (AHBToMbus) windows to access the xbar and read the data from there */ /* Need to configure the 2 free Punit (AHB to MBus bridge) address decoding windows: Configure the flash Window to handle Configuration space requests for PEX0/1: 1. write 0x7931/0x7941 to the flash window and the size, 79-xbar attr (pci cfg), 3/4-xbar target (pex0/1), 1-WinEn 2. write base to flash window Configuration transactions from the CPU should write/read the data to/from address of the form: addr[31:28] = 0x5 (for PEX0) or 0x6 (for PEX1) addr[27:24] = extended register number addr[23:16] = bus number addr[15:11] = device number addr[10:8] = function number addr[7:0] = register number */ #include "ctrlEnv/sys/mvAhbToMbus.h" { MV_U32 winNum; MV_AHB_TO_MBUS_DEC_WIN originWin; MV_U32 pciAddr=0; MV_U32 remapLow=0,remapHigh=0; /* We will use DEV_CS2\Flash window for this workarround */ winNum = mvAhbToMbusWinTargetGet(PEX_CONFIG_RW_WA_TARGET); /* save remap values if exist */ if ((1 == winNum)||(0 == winNum)) { remapLow = MV_REG_READ(AHB_TO_MBUS_WIN_REMAP_LOW_REG(winNum)); remapHigh = MV_REG_READ(AHB_TO_MBUS_WIN_REMAP_HIGH_REG(winNum)); } /* save the original window values */ mvAhbToMbusWinGet(winNum,&originWin); if (PEX_CONFIG_RW_WA_USE_ORIGINAL_WIN_VALUES) { /* set the window as xbar window */ if (pexIf) { MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), (0x7931 | (((originWin.addrWin.size >> 16)-1) ) << 16)); } else { MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), (0x7941 | (((originWin.addrWin.size >> 16)-1) ) << 16)); } MV_REG_WRITE(AHB_TO_MBUS_WIN_BASE_REG(winNum), originWin.addrWin.baseLow); /*pciAddr = originWin.addrWin.baseLow;*/ pciAddr = (MV_U32)CPU_MEMIO_UNCACHED_ADDR( (MV_U32)originWin.addrWin.baseLow); }
MV_STATUS mvAhbToMbusWinTargetSwap(MV_TARGET target1,MV_TARGET target2) { MV_U32 winNum1,winNum2; MV_AHB_TO_MBUS_DEC_WIN winDec1,winDec2,winDecTemp; AHB_TO_MBUS_REMAP_REG_OFFS remapRegs1,remapRegs2; MV_U32 remapBaseLow1=0,remapBaseLow2=0; MV_U32 remapBaseHigh1=0,remapBaseHigh2=0; /* Check parameters */ if (target1 >= MAX_TARGETS) { mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d is Illigal\n", target1); return MV_ERROR; } if (target2 >= MAX_TARGETS) { mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d is Illigal\n", target1); return MV_ERROR; } /* get window associated with this target */ winNum1 = mvAhbToMbusWinTargetGet(target1); if (winNum1 == 0xffffffff) { mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d has illigal win %d\n", target1,winNum1); return MV_ERROR; } /* get window associated with this target */ winNum2 = mvAhbToMbusWinTargetGet(target2); if (winNum2 == 0xffffffff) { mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d has illigal win %d\n", target2,winNum2); return MV_ERROR; } /* now Get original values of both Windows */ if (MV_OK != mvAhbToMbusWinGet(winNum1,&winDec1)) { mvOsPrintf("mvAhbToMbusWinTargetSwap: mvAhbToMbusWinGet failed win %d\n", winNum1); return MV_ERROR; } if (MV_OK != mvAhbToMbusWinGet(winNum2,&winDec2)) { mvOsPrintf("mvAhbToMbusWinTargetSwap: mvAhbToMbusWinGet failed win %d\n", winNum2); return MV_ERROR; } /* disable both windows */ if (MV_OK != mvAhbToMbusWinEnable(winNum1,MV_FALSE)) { mvOsPrintf("mvAhbToMbusWinTargetSwap: failed to enable window %d\n", winNum1); return MV_ERROR; } if (MV_OK != mvAhbToMbusWinEnable(winNum2,MV_FALSE)) { mvOsPrintf("mvAhbToMbusWinTargetSwap: failed to enable windo %d\n", winNum2); return MV_ERROR; } /* now swap targets */ /* first save winDec2 values */ winDecTemp.addrWin.baseHigh = winDec2.addrWin.baseHigh; winDecTemp.addrWin.baseLow = winDec2.addrWin.baseLow; winDecTemp.addrWin.size = winDec2.addrWin.size; winDecTemp.enable = winDec2.enable; winDecTemp.target = winDec2.target; /* winDec2 = winDec1 */ winDec2.addrWin.baseHigh = winDec1.addrWin.baseHigh; winDec2.addrWin.baseLow = winDec1.addrWin.baseLow; winDec2.addrWin.size = winDec1.addrWin.size; winDec2.enable = winDec1.enable; winDec2.target = winDec1.target; /* winDec1 = winDecTemp */ winDec1.addrWin.baseHigh = winDecTemp.addrWin.baseHigh; winDec1.addrWin.baseLow = winDecTemp.addrWin.baseLow; winDec1.addrWin.size = winDecTemp.addrWin.size; winDec1.enable = winDecTemp.enable; winDec1.target = winDecTemp.target; /* now set the new values */ mvAhbToMbusWinSet(winNum1,&winDec1); mvAhbToMbusWinSet(winNum2,&winDec2); /* now we will treat the remap windows if exist */ /* now check if one or both windows has a remap window as well after the swap ! */ /* if a window had a remap value differnt than the base value before the swap , then after the swap the remap value will be equal to the base value unless both windows has a remap windows*/ /* first get old values */ if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum1,&remapRegs1)) { remapBaseLow1 = MV_REG_READ(remapRegs1.lowRegOffs); remapBaseHigh1 = MV_REG_READ(remapRegs1.highRegOffs); } if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum2,&remapRegs2)) { remapBaseLow2 = MV_REG_READ(remapRegs2.lowRegOffs); remapBaseHigh2 = MV_REG_READ(remapRegs2.highRegOffs); } /* now do the swap */ if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum1,&remapRegs1)) { if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum2,&remapRegs2)) { /* Two windows has a remap !!! so swap */ MV_REG_WRITE(remapRegs2.highRegOffs,remapBaseHigh1); MV_REG_WRITE(remapRegs2.lowRegOffs,remapBaseLow1); MV_REG_WRITE(remapRegs1.highRegOffs,remapBaseHigh2); MV_REG_WRITE(remapRegs1.lowRegOffs,remapBaseLow2); } else { /* remap == base */ MV_REG_WRITE(remapRegs1.highRegOffs,winDec1.addrWin.baseHigh); MV_REG_WRITE(remapRegs1.lowRegOffs,winDec1.addrWin.baseLow); } } else if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum2,&remapRegs2)) { /* remap == base */ MV_REG_WRITE(remapRegs2.highRegOffs,winDec2.addrWin.baseHigh); MV_REG_WRITE(remapRegs2.lowRegOffs,winDec2.addrWin.baseLow); } return MV_OK; }
/******************************************************************************* * mvCpuIfTargetWinGet - Get CPU-to-peripheral target address window * * DESCRIPTION: * Get the CPU peripheral target address window. * * INPUT: * target - Peripheral target enumerator * * OUTPUT: * pAddrDecWin - CPU target window information data structure. * * RETURN: * MV_OK if target exist, MV_ERROR otherwise. * *******************************************************************************/ MV_STATUS mvCpuIfTargetWinGet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin) { MV_U32 winNum = 0xffffffff; MV_AHB_TO_MBUS_DEC_WIN decWin; MV_DRAM_DEC_WIN addrDecWin; MV_U32 dramEn = 0; MV_TARGET i; target = MV_CHANGE_BOOT_CS(target); /* Check parameters */ if (target >= MAX_TARGETS) { mvOsPrintf("mvCpuIfTargetWinGet: target %d is illegal\n", target); return MV_ERROR; } if (MV_TARGET_IS_DRAM(target)) { /* If none of the DRAM windows is enabled, then the CPU DRAM ** access is going through the XBAR. */ for (i = SDRAM_CS0; i < SDRAM_CS3; i++) { if (mvDramIfWinGet(target, &addrDecWin) != MV_OK) { mvOsPrintf("mvCpuIfTargetWinGet: Failed to get window target %d\n", i); return MV_ERROR; } if (addrDecWin.enable == MV_TRUE) dramEn = 1; } } if ((dramEn == 1) && (MV_TARGET_IS_DRAM(target))) { if (mvDramIfWinGet(target, &addrDecWin) != MV_OK) { mvOsPrintf("mvCpuIfTargetWinGet: Failed to get window target %d\n", target); return MV_ERROR; } /* copy relevant data to MV_CPU_DEC_WIN structure */ pAddrDecWin->addrWin.baseLow = addrDecWin.addrWin.baseLow; pAddrDecWin->addrWin.baseHigh = addrDecWin.addrWin.baseHigh; pAddrDecWin->addrWin.size = addrDecWin.addrWin.size; pAddrDecWin->enable = addrDecWin.enable; pAddrDecWin->winNum = 0xffffffff; } else { /* get the Window number associated with this target */ winNum = mvAhbToMbusWinTargetGet(target); if (winNum >= MAX_AHB_TO_MBUS_WINS) return MV_NO_SUCH; if (mvAhbToMbusWinGet(winNum, &decWin) != MV_OK) { mvOsPrintf("%s: mvAhbToMbusWinGet Failed at winNum = %d\n", __func__, winNum); return MV_ERROR; } /* copy relevant data to MV_CPU_DEC_WIN structure */ pAddrDecWin->addrWin.baseLow = decWin.addrWin.baseLow; pAddrDecWin->addrWin.baseHigh = decWin.addrWin.baseHigh; pAddrDecWin->addrWin.size = decWin.addrWin.size; pAddrDecWin->enable = decWin.enable; pAddrDecWin->winNum = winNum; } return MV_OK; }