/** * * This function Polls for the DMA done or FPGA done. * * @param none * * @return * - XST_SUCCESS if polling for DMA/FPGA done is successful * - XST_FAILURE if polling for DMA/FPGA done fails * * @note none * ****************************************************************************/ int XDcfgPollDone(u32 MaskValue, u32 MaxCount) { int Count = MaxCount; u32 IntrStsReg = 0; /* * poll for the DMA done */ IntrStsReg = XDcfg_IntrGetStatus(DcfgInstPtr); while ((IntrStsReg & MaskValue) != MaskValue) { IntrStsReg = XDcfg_IntrGetStatus(DcfgInstPtr); Count -=1; if (IntrStsReg & FSBL_XDCFG_IXR_ERROR_FLAGS_MASK) { fsbl_printf(DEBUG_INFO,"FATAL errors in PCAP %x\r\n", IntrStsReg); PcapDumpRegisters(); return XST_FAILURE; } if(!Count) { fsbl_printf(DEBUG_GENERAL,"PCAP transfer timed out \r\n"); return XST_FAILURE; } if (Count > (MAX_COUNT-100)) { fsbl_printf(DEBUG_GENERAL,"."); } } fsbl_printf(DEBUG_GENERAL,"\n\r"); XDcfg_IntrClear(DcfgInstPtr, IntrStsReg & MaskValue); return XST_SUCCESS; }
int XDcfg_TransferBitfile(XDcfg *Instance, u32 StartAddress, u32 WordLength) { int Status; volatile u32 IntrStsReg = 0; // TODO : not working although suggested procedure per TRM // Disable AXI Interface and Output Level Shifters (Input Level Shifters are still enabled) // Xil_Out32(SLCR_UNLOCK, SLCR_UNLOCK_VAL); // Xil_Out32(FPGA_RST_CTRL, 0xFFFFFFFF); // Xil_Out32(LVL_SHFTR_EN, 0xA); // Xil_Out32(SLCR_LOCK, SLCR_LOCK_VAL); // Clear DMA and PCAP Done Interrupts XDcfg_IntrClear(Instance, (XDCFG_IXR_DMA_DONE_MASK | XDCFG_IXR_D_P_DONE_MASK)); // Transfer bitstream from DDR into fabric in non secure mode Status = XDcfg_Transfer(Instance, (u32 *) StartAddress, WordLength, (u32 *) XDCFG_DMA_INVALID_ADDRESS, 0, XDCFG_NON_SECURE_PCAP_WRITE); if (Status != XST_SUCCESS) return Status; // Poll DMA Done Interrupt while ((IntrStsReg & XDCFG_IXR_DMA_DONE_MASK) != XDCFG_IXR_DMA_DONE_MASK) IntrStsReg = XDcfg_IntrGetStatus(Instance); // Poll PCAP Done Interrupt while ((IntrStsReg & XDCFG_IXR_D_P_DONE_MASK) != XDCFG_IXR_D_P_DONE_MASK) IntrStsReg = XDcfg_IntrGetStatus(Instance); // Enable AXI Interface and Input/Output Level Shifters // Xil_Out32(SLCR_UNLOCK, SLCR_UNLOCK_VAL); // Xil_Out32(LVL_SHFTR_EN, 0xF); // Xil_Out32(FPGA_RST_CTRL, 0x0); // Xil_Out32(SLCR_LOCK, SLCR_LOCK_VAL); return XST_SUCCESS; }
/** * * This function Clears the PCAP status registers. * * @param None * * @return * - XST_SUCCESS if the pcap status registers are cleared * - XST_FAILURE if errors are there * - XST_DEVICE_BUSY if Pcap device is busy * @note None * ****************************************************************************/ u32 ClearPcapStatus(void) { u32 StatusReg; u32 IntStatusReg; /* * Clear it all, so if Boot ROM comes back, it can proceed */ XDcfg_IntrClear(DcfgInstPtr, 0xFFFFFFFF); /* * Get PCAP Interrupt Status Register */ IntStatusReg = XDcfg_IntrGetStatus(DcfgInstPtr); if (IntStatusReg & FSBL_XDCFG_IXR_ERROR_FLAGS_MASK) { fsbl_printf(DEBUG_INFO,"FATAL errors in PCAP %x\r\n", IntStatusReg); return XST_FAILURE; } /* * Read the PCAP status register for DMA status */ StatusReg = XDcfg_GetStatusRegister(DcfgInstPtr); fsbl_printf(DEBUG_INFO,"PCAP:StatusReg = 0x%.8x\r\n", StatusReg); /* * If the queue is full, return w/ XST_DEVICE_BUSY */ if ((StatusReg & XDCFG_STATUS_DMA_CMD_Q_F_MASK) == XDCFG_STATUS_DMA_CMD_Q_F_MASK) { fsbl_printf(DEBUG_INFO,"PCAP_DEVICE_BUSY\r\n"); return XST_DEVICE_BUSY; } fsbl_printf(DEBUG_INFO,"PCAP:device ready\r\n"); /* * There are unacknowledged DMA commands outstanding */ if ((StatusReg & XDCFG_STATUS_DMA_CMD_Q_E_MASK) != XDCFG_STATUS_DMA_CMD_Q_E_MASK) { IntStatusReg = XDcfg_IntrGetStatus(DcfgInstPtr); if ((IntStatusReg & XDCFG_IXR_DMA_DONE_MASK) != XDCFG_IXR_DMA_DONE_MASK){ /* * Error state, transfer cannot occur */ fsbl_printf(DEBUG_INFO,"PCAP:IntStatus indicates error\r\n"); return XST_FAILURE; } else { /* * clear out the status */ XDcfg_IntrClear(DcfgInstPtr, XDCFG_IXR_DMA_DONE_MASK); } } if ((StatusReg & XDCFG_STATUS_DMA_DONE_CNT_MASK) != 0) { XDcfg_SetStatusRegister(DcfgInstPtr, StatusReg | XDCFG_STATUS_DMA_DONE_CNT_MASK); } fsbl_printf(DEBUG_INFO,"PCAP:Clear done\r\n"); return XST_SUCCESS; }