forked from ROMEO/obsw
inertial commit, libxil built externally
This commit is contained in:
39
bsp_z7/ps7_cortexa9_0/libsrc/cpu_cortexa9/src/Makefile
Normal file
39
bsp_z7/ps7_cortexa9_0/libsrc/cpu_cortexa9/src/Makefile
Normal file
@ -0,0 +1,39 @@
|
||||
DRIVER_LIB_VERSION = 1.0
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
CC_FLAGS = $(COMPILER_FLAGS)
|
||||
ECC_FLAGS = $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I$(INCLUDEDIR)
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR), $(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
libs: $(OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
${COMPILER} $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) $< -o $@
|
||||
|
||||
.PHONY: include
|
||||
include: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf ${DEPFILES}
|
@ -0,0 +1,25 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2011 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xcpu_cortexa9.h
|
||||
* @addtogroup cpu_cortexa9_v2_11
|
||||
* @{
|
||||
* @details
|
||||
*
|
||||
* dummy file
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- ---------------------------------------------------------
|
||||
* 2.5 ms 04/18/17 Modified tcl file to add suffix U for XPAR_CPU_ID
|
||||
* parameter of cpu_cortexa9 in xparameters.h
|
||||
# 2.7 mus 07/03/18 Updated tcl to not to add default flags forcefully into
|
||||
# extra compiler flags. Now, user can remove default flags
|
||||
# from extra compiler flags. It fixes CR#998768.
|
||||
******************************************************************************/
|
||||
/** @} */
|
37
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/Makefile
Normal file
37
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
DRIVER_LIB_VERSION = 1.0
|
||||
COMPILER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
|
||||
CC_FLAGS = $(COMPILER_FLAGS)
|
||||
ECC_FLAGS = $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I$(INCLUDEDIR)
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR), $(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
libs: $(OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
${COMPILER} $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) $< -o $@
|
||||
|
||||
.PHONY: include
|
||||
include: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf $(DEPFILES)
|
919
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.c
Normal file
919
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.c
Normal file
@ -0,0 +1,919 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdevcfg.c
|
||||
* @addtogroup devcfg_v3_7
|
||||
* @{
|
||||
*
|
||||
* This file contains the implementation of the interface functions for XDcfg
|
||||
* driver. Refer to the header file xdevcfg.h for more detailed information.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a hvm 02/07/11 First release
|
||||
* 2.00a nm 05/31/12 Updated the driver for CR 660835 so that input length for
|
||||
* source/destination to the XDcfg_InitiateDma, XDcfg_Transfer
|
||||
* APIs is words (32 bit) and not bytes.
|
||||
* Updated the notes for XDcfg_InitiateDma/XDcfg_Transfer APIs
|
||||
* to add information that 2 LSBs of the Source/Destination
|
||||
* address when equal to 2<>b01 indicate the last DMA command
|
||||
* of an overall transfer.
|
||||
* Updated the XDcfg_Transfer function to use the
|
||||
* Destination Address passed to this API for secure transfers
|
||||
* instead of using 0xFFFFFFFF for CR 662197. This issue was
|
||||
* resulting in the failure of secure transfers of
|
||||
* non-bitstream images.
|
||||
* 2.01a nm 08/27/12 Updated the XDcfg_Transfer API to clear the
|
||||
* QUARTER_PCAP_RATE_EN bit in the control register for
|
||||
* non secure writes for CR 675543.
|
||||
* 2.02a nm 01/31/13 Fixed CR# 679335.
|
||||
* Added Setting and Clearing the internal PCAP loopback.
|
||||
* Removed code for enabling/disabling AES engine as BootROM
|
||||
* locks down this setting.
|
||||
* Fixed CR# 681976.
|
||||
* Skip Checking the PCFG_INIT in case of non-secure DMA
|
||||
* loopback.
|
||||
* Fixed CR# 699558.
|
||||
* XDcfg_Transfer fails to transfer data in loopback mode.
|
||||
* 2.03a nm 04/19/13 Fixed CR# 703728.
|
||||
* Updated the register definitions as per the latest TRM
|
||||
* version UG585 (v1.4) November 16, 2012.
|
||||
* 3.0 kpc 21/02/14 Implemented new function XDcfg_ClearControlRegister
|
||||
* 3.2 sb 08/25/14 Fixed XDcfg_PcapReadback() function
|
||||
* updated driver code with != instead of ==,
|
||||
* while checking for Interrupt Status with DMA and
|
||||
* PCAP Done Mask
|
||||
* ((XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
* XDCFG_INT_STS_OFFSET) &
|
||||
* XDCFG_IXR_D_P_DONE_MASK) !=
|
||||
* XDCFG_IXR_D_P_DONE_MASK);
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xdevcfg.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Initialize the Device Config Interface driver. This function
|
||||
* must be called before other functions of the driver are called.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param ConfigPtr is the config structure.
|
||||
* @param EffectiveAddress is the base address for the device. It could be
|
||||
* a virtual address if address translation is supported in the
|
||||
* system, otherwise it is the physical address.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if initialization was successful.
|
||||
* - XST_DEVICE_IS_STARTED if the device has already been started.
|
||||
*
|
||||
* @note The very first APB access to the Device Configuration Interface
|
||||
* block needs to be a write to the UNLOCK register with the value
|
||||
* of 0x757BDF0D. This step is to be done once after reset, any
|
||||
* other APB access has to come after this. The APB access is
|
||||
* considered illegal if the step is not done or if it is done
|
||||
* incorrectly. Furthermore, if any of efuse_sec_cfg[5:0] is high,
|
||||
* the following additional actions would be carried out.
|
||||
* In other words, if all bits are low, the following steps are not
|
||||
* done.
|
||||
* 1. AES is disabled
|
||||
* 2. All APB writes disabled
|
||||
* 3. SoC debug fully enabled
|
||||
*
|
||||
******************************************************************************/
|
||||
int XDcfg_CfgInitialize(XDcfg *InstancePtr,
|
||||
XDcfg_Config *ConfigPtr, u32 EffectiveAddress)
|
||||
{
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(ConfigPtr != NULL);
|
||||
|
||||
/*
|
||||
* If the device is started, disallow the initialize and return a
|
||||
* status indicating it is started. This allows the user to stop the
|
||||
* device and reinitialize, but prevents a user from inadvertently
|
||||
* initializing.
|
||||
*/
|
||||
if (InstancePtr->IsStarted == XIL_COMPONENT_IS_STARTED) {
|
||||
return XST_DEVICE_IS_STARTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy configuration into instance.
|
||||
*/
|
||||
InstancePtr->Config.DeviceId = ConfigPtr->DeviceId;
|
||||
|
||||
/*
|
||||
* Save the base address pointer such that the registers of the block
|
||||
* can be accessed and indicate it has not been started yet.
|
||||
*/
|
||||
InstancePtr->Config.BaseAddr = EffectiveAddress;
|
||||
InstancePtr->IsStarted = 0;
|
||||
|
||||
|
||||
/* Unlock the Device Configuration Interface */
|
||||
XDcfg_Unlock(InstancePtr);
|
||||
|
||||
/*
|
||||
* Indicate the instance is ready to use, successfully initialized.
|
||||
*/
|
||||
InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The functions enables the PCAP interface by setting the PCAP mode bit in the
|
||||
* control register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note Enable FPGA programming from PCAP interface. Enabling this bit
|
||||
* disables all the external interfaces from programming of FPGA
|
||||
* except for ICAP. The user needs to ensure that the FPGA is
|
||||
* programmed through either PCAP or ICAP.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_EnablePCAP(XDcfg *InstancePtr)
|
||||
{
|
||||
u32 CtrlReg;
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
|
||||
CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_CTRL_OFFSET);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_CTRL_OFFSET,
|
||||
(CtrlReg | XDCFG_CTRL_PCAP_MODE_MASK));
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The functions disables the PCAP interface by clearing the PCAP mode bit in
|
||||
* the control register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_DisablePCAP(XDcfg *InstancePtr)
|
||||
{
|
||||
u32 CtrlReg;
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
|
||||
CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_CTRL_OFFSET);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_CTRL_OFFSET,
|
||||
(CtrlReg & ( ~XDCFG_CTRL_PCAP_MODE_MASK)));
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function sets the contents of the Control Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param Mask is the 32 bit mask data to be written to the Register.
|
||||
* The mask definitions are defined in the xdevcfg_hw.h file.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_SetControlRegister(XDcfg *InstancePtr, u32 Mask)
|
||||
{
|
||||
u32 CtrlReg;
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
|
||||
CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_CTRL_OFFSET);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_CTRL_OFFSET,
|
||||
(CtrlReg | Mask));
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function Clears the specified bit positions of the Control Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param Mask is the 32 bit value which holds the bit positions to be cleared.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_ClearControlRegister(XDcfg *InstancePtr, u32 Mask)
|
||||
{
|
||||
u32 CtrlReg;
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
|
||||
CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_CTRL_OFFSET);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_CTRL_OFFSET,
|
||||
(CtrlReg & ~Mask));
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function reads the contents of the Control Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return A 32-bit value representing the contents of the Control
|
||||
* Register.
|
||||
* Use the XDCFG_CTRL_*_MASK constants defined in xdevcfg_hw.h to
|
||||
* interpret the returned value.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XDcfg_GetControlRegister(XDcfg *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the Control Register and return the value.
|
||||
*/
|
||||
return XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_CTRL_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function sets the contents of the Lock Register. These bits
|
||||
* can only be set to a 1. They will be cleared after a Power On Reset.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param Data is the 32 bit data to be written to the Register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_SetLockRegister(XDcfg *InstancePtr, u32 Data)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_LOCK_OFFSET, Data);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function reads the contents of the Lock Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return A 32-bit value representing the contents of the Lock
|
||||
* Register.
|
||||
* Use the XDCFG_CR_*_MASK constants defined in xdevcfg_hw.h to
|
||||
* interpret the returned value.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XDcfg_GetLockRegister(XDcfg *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the Lock Register and return the value.
|
||||
*/
|
||||
return XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_LOCK_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function sets the contents of the Configuration Register with the
|
||||
* given value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param Data is the 32 bit data to be written to the Register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_SetConfigRegister(XDcfg *InstancePtr, u32 Data)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_CFG_OFFSET, Data);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function reads the contents of the Configuration Register with the
|
||||
* given value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return A 32-bit value representing the contents of the Config
|
||||
* Register.
|
||||
* Use the XDCFG_CFG_*_MASK constants defined in xdevcfg_hw.h to
|
||||
* interpret the returned value.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XDcfg_GetConfigRegister(XDcfg *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
return XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_CFG_OFFSET);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function sets the contents of the Status Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param Data is the 32 bit data to be written to the Register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_SetStatusRegister(XDcfg *InstancePtr, u32 Data)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_STATUS_OFFSET, Data);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function reads the contents of the Status Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return A 32-bit value representing the contents of the Status
|
||||
* Register.
|
||||
* Use the XDCFG_STATUS_*_MASK constants defined in
|
||||
* xdevcfg_hw.h to interpret the returned value.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XDcfg_GetStatusRegister(XDcfg *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the Status Register and return the value.
|
||||
*/
|
||||
return XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_STATUS_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function sets the contents of the ROM Shadow Control Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param Data is the 32 bit data to be written to the Register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This register is can only be written and is used to control the
|
||||
* RAM shadow of 32 bit 4K page ROM pages in user mode
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_SetRomShadowRegister(XDcfg *InstancePtr, u32 Data)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_ROM_SHADOW_OFFSET,
|
||||
Data);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function reads the contents of the Software ID Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return 32 Bit boot software ID.
|
||||
*
|
||||
* @note This register is locked for write once the system enters
|
||||
* usermode. Hence API for reading the register only is provided.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XDcfg_GetSoftwareIdRegister(XDcfg *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the Software ID Register and return the value.
|
||||
*/
|
||||
return XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_SW_ID_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function sets the bit mask for the feature in Miscellaneous Control
|
||||
* Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param Mask is the bit-mask of the feature to be set.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_SetMiscControlRegister(XDcfg *InstancePtr, u32 Mask)
|
||||
{
|
||||
u32 RegData;
|
||||
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
|
||||
RegData = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_MCTRL_OFFSET);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_MCTRL_OFFSET,
|
||||
(RegData | Mask));
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* The function reads the contents of the Miscellaneous Control Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return 32 Bit boot software ID.
|
||||
*
|
||||
* @note This register is locked for write once the system enters
|
||||
* usermode. Hence API to reading the register only is provided.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XDcfg_GetMiscControlRegister(XDcfg *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the Miscellaneous Control Register and return the value.
|
||||
*/
|
||||
return XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_MCTRL_OFFSET);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function checks if DMA command queue is full.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return XST_SUCCESS is the DMA is busy
|
||||
* XST_FAILURE if the DMA is idle
|
||||
*
|
||||
* @note The DMA queue has a depth of two.
|
||||
*
|
||||
****************************************************************************/
|
||||
u32 XDcfg_IsDmaBusy(XDcfg *InstancePtr)
|
||||
{
|
||||
|
||||
u32 RegData;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/* Read the PCAP status register for DMA status */
|
||||
RegData = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_STATUS_OFFSET);
|
||||
|
||||
if ((RegData & XDCFG_STATUS_DMA_CMD_Q_F_MASK) ==
|
||||
XDCFG_STATUS_DMA_CMD_Q_F_MASK){
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function initiates the DMA transfer.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param SourcePtr contains a pointer to the source memory where the data
|
||||
* is to be transferred from.
|
||||
* @param SrcWordLength is the number of words (32 bit) to be transferred
|
||||
* for the source transfer.
|
||||
* @param DestPtr contains a pointer to the destination memory
|
||||
* where the data is to be transferred to.
|
||||
* @param DestWordLength is the number of words (32 bit) to be transferred
|
||||
* for the Destination transfer.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note It is the responsibility of the caller function to ensure that
|
||||
* correct values are passed to this function.
|
||||
*
|
||||
* The 2 LSBs of the SourcePtr (Source)/ DestPtr (Destination)
|
||||
* address when equal to 2<>b01 indicates the last DMA command of
|
||||
* an overall transfer.
|
||||
*
|
||||
****************************************************************************/
|
||||
void XDcfg_InitiateDma(XDcfg *InstancePtr, u32 SourcePtr, u32 DestPtr,
|
||||
u32 SrcWordLength, u32 DestWordLength)
|
||||
{
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_DMA_SRC_ADDR_OFFSET,
|
||||
SourcePtr);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_DMA_DEST_ADDR_OFFSET,
|
||||
DestPtr);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_DMA_SRC_LEN_OFFSET,
|
||||
SrcWordLength);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_DMA_DEST_LEN_OFFSET,
|
||||
DestWordLength);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function Implements the DMA Read Command. This command is used to
|
||||
* transfer the image data from FPGA to the external memory.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param SourcePtr contains a pointer to the source memory where the data
|
||||
* is to be transferred from.
|
||||
* @param SrcWordLength is the number of words (32 bit) to be transferred
|
||||
* for the source transfer.
|
||||
* @param DestPtr contains a pointer to the destination memory
|
||||
* where the data is to be transferred to.
|
||||
* @param DestWordLength is the number of words (32 bit) to be transferred
|
||||
* for the Destination transfer.
|
||||
*
|
||||
* @return - XST_INVALID_PARAM if source address/length is invalid.
|
||||
* - XST_SUCCESS if DMA transfer initiated properly.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static u32 XDcfg_PcapReadback(XDcfg *InstancePtr, u32 SourcePtr,
|
||||
u32 SrcWordLength, u32 DestPtr,
|
||||
u32 DestWordLength)
|
||||
{
|
||||
u32 IntrReg;
|
||||
|
||||
/*
|
||||
* Send READ Frame command to FPGA
|
||||
*/
|
||||
XDcfg_InitiateDma(InstancePtr, SourcePtr, XDCFG_DMA_INVALID_ADDRESS,
|
||||
SrcWordLength, 0);
|
||||
|
||||
/*
|
||||
* Store the enabled interrupts to enable before the actual read
|
||||
* transfer is initiated and Disable all the interrupts temporarily.
|
||||
*/
|
||||
IntrReg = XDcfg_IntrGetEnabled(InstancePtr);
|
||||
XDcfg_IntrDisable(InstancePtr, XDCFG_IXR_ALL_MASK);
|
||||
|
||||
/*
|
||||
* Wait till you get the DMA done for the read command sent
|
||||
*/
|
||||
while ((XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_INT_STS_OFFSET) &
|
||||
XDCFG_IXR_D_P_DONE_MASK) !=
|
||||
XDCFG_IXR_D_P_DONE_MASK);
|
||||
/*
|
||||
* Enable the previously stored Interrupts .
|
||||
*/
|
||||
XDcfg_IntrEnable(InstancePtr, IntrReg);
|
||||
|
||||
/*
|
||||
* Initiate the DMA write command.
|
||||
*/
|
||||
XDcfg_InitiateDma(InstancePtr, XDCFG_DMA_INVALID_ADDRESS, (u32)DestPtr,
|
||||
0, DestWordLength);
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function starts the DMA transfer. This function only starts the
|
||||
* operation and returns before the operation may be completed.
|
||||
* If the interrupt is enabled, an interrupt will be generated when the
|
||||
* operation is completed, otherwise it is necessary to poll the Status register
|
||||
* to determine when it is completed. It is the responsibility of the caller to
|
||||
* determine when the operation is completed by handling the generated interrupt
|
||||
* or polling the Status Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param SourcePtr contains a pointer to the source memory where the data
|
||||
* is to be transferred from.
|
||||
* @param SrcWordLength is the number of words (32 bit) to be transferred
|
||||
* for the source transfer.
|
||||
* @param DestPtr contains a pointer to the destination memory
|
||||
* where the data is to be transferred to.
|
||||
* @param DestWordLength is the number of words (32 bit) to be transferred
|
||||
* for the Destination transfer.
|
||||
* @param TransferType contains the type of PCAP transfer being requested.
|
||||
* The definitions can be found in the xdevcfg.h file.
|
||||
* @return
|
||||
* - XST_SUCCESS.if DMA transfer initiated successfully
|
||||
* - XST_DEVICE_BUSY if DMA is busy
|
||||
* - XST_INVALID_PARAM if invalid Source / Destination address
|
||||
* is sent or an invalid Source / Destination length is
|
||||
* sent
|
||||
*
|
||||
* @note It is the responsibility of the caller to ensure that the cache
|
||||
* is flushed and invalidated both before the DMA operation is
|
||||
* started and after the DMA operation completes if the memory
|
||||
* pointed to is cached. The caller must also ensure that the
|
||||
* pointers contain physical address rather than a virtual address
|
||||
* if address translation is being used.
|
||||
*
|
||||
* The 2 LSBs of the SourcePtr (Source)/ DestPtr (Destination)
|
||||
* address when equal to 2<>b01 indicates the last DMA command of
|
||||
* an overall transfer.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XDcfg_Transfer(XDcfg *InstancePtr,
|
||||
void *SourcePtr, u32 SrcWordLength,
|
||||
void *DestPtr, u32 DestWordLength,
|
||||
u32 TransferType)
|
||||
{
|
||||
|
||||
u32 CtrlReg;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
|
||||
if (XDcfg_IsDmaBusy(InstancePtr) == XST_SUCCESS) {
|
||||
return XST_DEVICE_BUSY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check whether the fabric is in initialized state
|
||||
*/
|
||||
if ((XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_STATUS_OFFSET)
|
||||
& XDCFG_STATUS_PCFG_INIT_MASK) == 0) {
|
||||
/*
|
||||
* We don't need to check PCFG_INIT to be high for
|
||||
* non-encrypted loopback transfers.
|
||||
*/
|
||||
if (TransferType != XDCFG_CONCURRENT_NONSEC_READ_WRITE) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((TransferType == XDCFG_SECURE_PCAP_WRITE) ||
|
||||
(TransferType == XDCFG_NON_SECURE_PCAP_WRITE)) {
|
||||
|
||||
/* Check for valid source pointer and length */
|
||||
if ((!SourcePtr) || (SrcWordLength == 0)) {
|
||||
return XST_INVALID_PARAM;
|
||||
}
|
||||
|
||||
/* Clear internal PCAP loopback */
|
||||
CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_MCTRL_OFFSET);
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_MCTRL_OFFSET, (CtrlReg &
|
||||
~(XDCFG_MCTRL_PCAP_LPBK_MASK)));
|
||||
|
||||
if (TransferType == XDCFG_NON_SECURE_PCAP_WRITE) {
|
||||
/*
|
||||
* Clear QUARTER_PCAP_RATE_EN bit
|
||||
* so that the PCAP data is transmitted every clock
|
||||
*/
|
||||
CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_CTRL_OFFSET);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_CTRL_OFFSET, (CtrlReg &
|
||||
~XDCFG_CTRL_PCAP_RATE_EN_MASK));
|
||||
|
||||
}
|
||||
if (TransferType == XDCFG_SECURE_PCAP_WRITE) {
|
||||
/*
|
||||
* AES engine handles only 8 bit data every clock cycle.
|
||||
* Hence, Encrypted PCAP data which is 32 bit data can
|
||||
* only be sent in every 4 clock cycles. Set the control
|
||||
* register QUARTER_PCAP_RATE_EN bit to achieve this
|
||||
* operation.
|
||||
*/
|
||||
XDcfg_SetControlRegister(InstancePtr,
|
||||
XDCFG_CTRL_PCAP_RATE_EN_MASK);
|
||||
}
|
||||
|
||||
XDcfg_InitiateDma(InstancePtr, (u32)SourcePtr,
|
||||
(u32)DestPtr, SrcWordLength, DestWordLength);
|
||||
|
||||
}
|
||||
|
||||
if (TransferType == XDCFG_PCAP_READBACK) {
|
||||
|
||||
if ((!DestPtr) || (DestWordLength == 0)) {
|
||||
|
||||
return XST_INVALID_PARAM;
|
||||
}
|
||||
|
||||
/* Clear internal PCAP loopback */
|
||||
CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_MCTRL_OFFSET);
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_MCTRL_OFFSET, (CtrlReg &
|
||||
~(XDCFG_MCTRL_PCAP_LPBK_MASK)));
|
||||
|
||||
/*
|
||||
* For PCAP readback of FPGA configuration register or memory,
|
||||
* the read command is first sent (written) to the FPGA fabric
|
||||
* which responds by returning the required read data. Read data
|
||||
* from the FPGA is captured if pcap_radata_v is active.A DMA
|
||||
* read transfer is required to obtain the readback command,
|
||||
* which is then sent to the FPGA, followed by a DMA write
|
||||
* transfer to support this mode of operation.
|
||||
*/
|
||||
return XDcfg_PcapReadback(InstancePtr,
|
||||
(u32)SourcePtr, SrcWordLength,
|
||||
(u32)DestPtr, DestWordLength);
|
||||
}
|
||||
|
||||
|
||||
if ((TransferType == XDCFG_CONCURRENT_SECURE_READ_WRITE) ||
|
||||
(TransferType == XDCFG_CONCURRENT_NONSEC_READ_WRITE)) {
|
||||
|
||||
if ((!SourcePtr) || (SrcWordLength == 0) ||
|
||||
(!DestPtr) || (DestWordLength == 0)) {
|
||||
return XST_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (TransferType == XDCFG_CONCURRENT_NONSEC_READ_WRITE) {
|
||||
/* Enable internal PCAP loopback */
|
||||
CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_MCTRL_OFFSET);
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_MCTRL_OFFSET, (CtrlReg |
|
||||
XDCFG_MCTRL_PCAP_LPBK_MASK));
|
||||
|
||||
/*
|
||||
* Clear QUARTER_PCAP_RATE_EN bit
|
||||
* so that the PCAP data is transmitted every clock
|
||||
*/
|
||||
CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_CTRL_OFFSET);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_CTRL_OFFSET, (CtrlReg &
|
||||
~XDCFG_CTRL_PCAP_RATE_EN_MASK));
|
||||
|
||||
}
|
||||
if (TransferType == XDCFG_CONCURRENT_SECURE_READ_WRITE) {
|
||||
/* Clear internal PCAP loopback */
|
||||
CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_MCTRL_OFFSET);
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_MCTRL_OFFSET, (CtrlReg &
|
||||
~(XDCFG_MCTRL_PCAP_LPBK_MASK)));
|
||||
|
||||
/*
|
||||
* Set the QUARTER_PCAP_RATE_EN bit
|
||||
* so that the PCAP data is transmitted every 4 clock
|
||||
* cycles, this is required for encrypted data.
|
||||
*/
|
||||
XDcfg_SetControlRegister(InstancePtr,
|
||||
XDCFG_CTRL_PCAP_RATE_EN_MASK);
|
||||
}
|
||||
|
||||
XDcfg_InitiateDma(InstancePtr, (u32)SourcePtr,
|
||||
(u32)DestPtr, SrcWordLength, DestWordLength);
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
/** @} */
|
377
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.h
Normal file
377
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.h
Normal file
@ -0,0 +1,377 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdevcfg.h
|
||||
* @addtogroup devcfg_v3_7
|
||||
* @{
|
||||
* @details
|
||||
*
|
||||
* The is the main header file for the Device Configuration Interface of the Zynq
|
||||
* device. The device configuration interface has three main functionality.
|
||||
* 1. AXI-PCAP
|
||||
* 2. Security Policy
|
||||
* 3. XADC
|
||||
* This current version of the driver supports only the AXI-PCAP and Security
|
||||
* Policy blocks. There is a separate driver for XADC.
|
||||
*
|
||||
* AXI-PCAP is used for download/upload an encrypted or decrypted bitstream.
|
||||
* DMA embedded in the AXI PCAP provides the master interface to
|
||||
* the Device configuration block for any DMA transfers. The data transfer can
|
||||
* take place between the Tx/RxFIFOs of AXI-PCAP and memory (on chip
|
||||
* RAM/DDR/peripheral memory).
|
||||
*
|
||||
* The current driver only supports the downloading the FPGA bitstream and
|
||||
* readback of the decrypted image (sort of loopback).
|
||||
* The driver does not know what information needs to be written to the FPGA to
|
||||
* readback FPGA configuration register or memory data. The application above the
|
||||
* driver should take care of creating the data that needs to be downloaded to
|
||||
* the FPGA so that the bitstream can be readback.
|
||||
* This driver also does not support the reading of the internal registers of the
|
||||
* PCAP. The driver has no knowledge of the PCAP internals.
|
||||
*
|
||||
* <b> Initialization and Configuration </b>
|
||||
*
|
||||
* The device driver enables higher layer software (e.g., an application) to
|
||||
* communicate with the Device Configuration device.
|
||||
*
|
||||
* XDcfg_CfgInitialize() API is used to initialize the Device Configuration
|
||||
* Interface. The user needs to first call the XDcfg_LookupConfig() API which
|
||||
* returns the Configuration structure pointer which is passed as a parameter to
|
||||
* the XDcfg_CfgInitialize() API.
|
||||
*
|
||||
* <b>Interrupts</b>
|
||||
* The Driver implements an interrupt handler to support the interrupts provided
|
||||
* by this interface.
|
||||
*
|
||||
* <b> Threads </b>
|
||||
*
|
||||
* This driver is not thread safe. Any needs for threads or thread mutual
|
||||
* exclusion must be satisfied by the layer above this driver.
|
||||
*
|
||||
* <b> Asserts </b>
|
||||
*
|
||||
* Asserts are used within all Xilinx drivers to enforce constraints on argument
|
||||
* values. Asserts can be turned off on a system-wide basis by defining, at
|
||||
* compile time, the NDEBUG identifier. By default, asserts are turned on and it
|
||||
* is recommended that users leave asserts on during development.
|
||||
*
|
||||
* <b> Building the driver </b>
|
||||
*
|
||||
* The XDcfg driver is composed of several source files. This allows the user
|
||||
* to build and link only those parts of the driver that are necessary.
|
||||
*
|
||||
* <br><br>
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a hvm 02/07/11 First release
|
||||
* 2.00a nm 05/31/12 Updated the driver for CR 660835 so that input length for
|
||||
* source/destination to the XDcfg_InitiateDma, XDcfg_Transfer
|
||||
* APIs is words (32 bit) and not bytes.
|
||||
* Updated the notes for XDcfg_InitiateDma/XDcfg_Transfer APIs
|
||||
* to add information that 2 LSBs of the Source/Destination
|
||||
* address when equal to 2<>b01 indicate the last DMA command
|
||||
* of an overall transfer.
|
||||
* Destination Address passed to this API for secure transfers
|
||||
* instead of using 0xFFFFFFFF for CR 662197. This issue was
|
||||
* resulting in the failure of secure transfers of
|
||||
* non-bitstream images.
|
||||
* 2.01a nm 07/07/12 Updated the XDcfg_IntrClear function to directly
|
||||
* set the mask instead of oring it with the
|
||||
* value read from the interrupt status register
|
||||
* Added defines for the PS Version bits,
|
||||
* removed the FIFO Flush bits from the
|
||||
* Miscellaneous Control Reg.
|
||||
* Added XDcfg_GetPsVersion, XDcfg_SelectIcapInterface
|
||||
* and XDcfg_SelectPcapInterface APIs for CR 643295
|
||||
* The user has to call the XDcfg_SelectIcapInterface API
|
||||
* for the PL reconfiguration using AXI HwIcap.
|
||||
* Updated the XDcfg_Transfer API to clear the
|
||||
* QUARTER_PCAP_RATE_EN bit in the control register for
|
||||
* non secure writes for CR 675543.
|
||||
* 2.02a nm 01/31/13 Fixed CR# 679335.
|
||||
* Added Setting and Clearing the internal PCAP loopback.
|
||||
* Removed code for enabling/disabling AES engine as BootROM
|
||||
* locks down this setting.
|
||||
* Fixed CR# 681976.
|
||||
* Skip Checking the PCFG_INIT in case of non-secure DMA
|
||||
* loopback.
|
||||
* Fixed CR# 699558.
|
||||
* XDcfg_Transfer fails to transfer data in loopback mode.
|
||||
* Fixed CR# 701348.
|
||||
* Peripheral test fails with Running
|
||||
* DcfgSelfTestExample() in SECURE bootmode.
|
||||
* 2.03a nm 04/19/13 Fixed CR# 703728.
|
||||
* Updated the register definitions as per the latest TRM
|
||||
* version UG585 (v1.4) November 16, 2012.
|
||||
* 3.0 adk 10/12/13 Updated as per the New Tcl API's
|
||||
* 3.0 kpc 21/02/14 Added function prototype for XDcfg_ClearControlRegister
|
||||
* 3.2 sb 08/25/14 Fixed XDcfg_PcapReadback() function
|
||||
* updated driver code with != instead of ==,
|
||||
* while checking for Interrupt Status with DMA and
|
||||
* PCAP Done Mask
|
||||
* ((XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
* XDCFG_INT_STS_OFFSET) &
|
||||
* XDCFG_IXR_D_P_DONE_MASK) !=
|
||||
* XDCFG_IXR_D_P_DONE_MASK);
|
||||
* A new example has been added to read back the
|
||||
* configuration registers from the PL region.
|
||||
* xdevcfg_reg_readback_example.c
|
||||
* 3.3 sk 04/06/15 Modified XDcfg_ReadMultiBootConfig Macro CR# 851335.
|
||||
* ms 03/17/17 Added readme.txt file in examples folder for doxygen
|
||||
* generation.
|
||||
* ms 04/10/17 Modified filename tag in interrupt and polled examples
|
||||
* to include them in doxygen examples.
|
||||
* 3.5 ms 04/18/17 Modified tcl file to add suffix U for all macros
|
||||
* definitions of devcfg in xparameters.h
|
||||
* ms 08/07/17 Fixed compilation warnings in xdevcfg_sinit.c
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XDCFG_H /* prevent circular inclusions */
|
||||
#define XDCFG_H /* by using protection macros */
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xdevcfg_hw.h"
|
||||
#include "xstatus.h"
|
||||
#include "xil_assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/* Types of PCAP transfers */
|
||||
|
||||
#define XDCFG_NON_SECURE_PCAP_WRITE 1
|
||||
#define XDCFG_SECURE_PCAP_WRITE 2
|
||||
#define XDCFG_PCAP_READBACK 3
|
||||
#define XDCFG_CONCURRENT_SECURE_READ_WRITE 4
|
||||
#define XDCFG_CONCURRENT_NONSEC_READ_WRITE 5
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
/**
|
||||
* The handler data type allows the user to define a callback function to
|
||||
* respond to interrupt events in the system. This function is executed
|
||||
* in interrupt context, so amount of processing should be minimized.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed in by the upper
|
||||
* layer when setting the callback functions, and passed back to
|
||||
* the upper layer when the callback is invoked. Its type is
|
||||
* unimportant to the driver component, so it is a void pointer.
|
||||
* @param Status is the Interrupt status of the XDcfg device.
|
||||
*/
|
||||
typedef void (*XDcfg_IntrHandler) (void *CallBackRef, u32 Status);
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for the device.
|
||||
*/
|
||||
typedef struct {
|
||||
u16 DeviceId; /**< Unique ID of device */
|
||||
u32 BaseAddr; /**< Base address of the device */
|
||||
} XDcfg_Config;
|
||||
|
||||
/**
|
||||
* The XDcfg driver instance data.
|
||||
*/
|
||||
typedef struct {
|
||||
XDcfg_Config Config; /**< Hardware Configuration */
|
||||
u32 IsReady; /**< Device is initialized and ready */
|
||||
u32 IsStarted; /**< Device Configuration Interface
|
||||
* is running
|
||||
*/
|
||||
XDcfg_IntrHandler StatusHandler; /* Event handler function */
|
||||
void *CallBackRef; /* Callback reference for event handler */
|
||||
} XDcfg;
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Unlock the Device Config Interface block.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance of XDcfg driver.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XDcfg_Unlock(XDcfg* InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XDcfg_Unlock(InstancePtr) \
|
||||
XDcfg_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XDCFG_UNLOCK_OFFSET, XDCFG_UNLOCK_DATA)
|
||||
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the version number of the PS from the Miscellaneous Control Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance of XDcfg driver.
|
||||
*
|
||||
* @return Version of the PS.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XDcfg_GetPsVersion(XDcfg* InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XDcfg_GetPsVersion(InstancePtr) \
|
||||
((XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XDCFG_MCTRL_OFFSET)) & \
|
||||
XDCFG_MCTRL_PCAP_PS_VERSION_MASK) >> \
|
||||
XDCFG_MCTRL_PCAP_PS_VERSION_SHIFT
|
||||
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the multiboot config register value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance of XDcfg driver.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* u32 XDcfg_ReadMultiBootConfig(XDcfg* InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XDcfg_ReadMultiBootConfig(InstancePtr) \
|
||||
XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XDCFG_MULTIBOOT_ADDR_OFFSET)
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Selects ICAP interface for reconfiguration after the initial configuration
|
||||
* of the PL.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance of XDcfg driver.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XDcfg_SelectIcapInterface(XDcfg* InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XDcfg_SelectIcapInterface(InstancePtr) \
|
||||
XDcfg_WriteReg((InstancePtr)->Config.BaseAddr, XDCFG_CTRL_OFFSET, \
|
||||
((XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, XDCFG_CTRL_OFFSET)) \
|
||||
& ( ~XDCFG_CTRL_PCAP_PR_MASK)))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Selects PCAP interface for reconfiguration after the initial configuration
|
||||
* of the PL.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance of XDcfg driver.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XDcfg_SelectPcapInterface(XDcfg* InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XDcfg_SelectPcapInterface(InstancePtr) \
|
||||
XDcfg_WriteReg((InstancePtr)->Config.BaseAddr, XDCFG_CTRL_OFFSET, \
|
||||
((XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, XDCFG_CTRL_OFFSET)) \
|
||||
| XDCFG_CTRL_PCAP_PR_MASK))
|
||||
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*
|
||||
* Lookup configuration in xdevcfg_sinit.c.
|
||||
*/
|
||||
XDcfg_Config *XDcfg_LookupConfig(u16 DeviceId);
|
||||
|
||||
/*
|
||||
* Selftest function in xdevcfg_selftest.c
|
||||
*/
|
||||
int XDcfg_SelfTest(XDcfg *InstancePtr);
|
||||
|
||||
/*
|
||||
* Interface functions in xdevcfg.c
|
||||
*/
|
||||
int XDcfg_CfgInitialize(XDcfg *InstancePtr,
|
||||
XDcfg_Config *ConfigPtr, u32 EffectiveAddress);
|
||||
|
||||
void XDcfg_EnablePCAP(XDcfg *InstancePtr);
|
||||
|
||||
void XDcfg_DisablePCAP(XDcfg *InstancePtr);
|
||||
|
||||
void XDcfg_SetControlRegister(XDcfg *InstancePtr, u32 Mask);
|
||||
|
||||
void XDcfg_ClearControlRegister(XDcfg *InstancePtr, u32 Mask);
|
||||
|
||||
u32 XDcfg_GetControlRegister(XDcfg *InstancePtr);
|
||||
|
||||
void XDcfg_SetLockRegister(XDcfg *InstancePtr, u32 Data);
|
||||
|
||||
u32 XDcfg_GetLockRegister(XDcfg *InstancePtr);
|
||||
|
||||
void XDcfg_SetConfigRegister(XDcfg *InstancePtr, u32 Data);
|
||||
|
||||
u32 XDcfg_GetConfigRegister(XDcfg *InstancePtr);
|
||||
|
||||
void XDcfg_SetStatusRegister(XDcfg *InstancePtr, u32 Data);
|
||||
|
||||
u32 XDcfg_GetStatusRegister(XDcfg *InstancePtr);
|
||||
|
||||
void XDcfg_SetRomShadowRegister(XDcfg *InstancePtr, u32 Data);
|
||||
|
||||
u32 XDcfg_GetSoftwareIdRegister(XDcfg *InstancePtr);
|
||||
|
||||
void XDcfg_SetMiscControlRegister(XDcfg *InstancePtr, u32 Mask);
|
||||
|
||||
u32 XDcfg_GetMiscControlRegister(XDcfg *InstancePtr);
|
||||
|
||||
u32 XDcfg_IsDmaBusy(XDcfg *InstancePtr);
|
||||
|
||||
void XDcfg_InitiateDma(XDcfg *InstancePtr, u32 SourcePtr, u32 DestPtr,
|
||||
u32 SrcWordLength, u32 DestWordLength);
|
||||
|
||||
u32 XDcfg_Transfer(XDcfg *InstancePtr,
|
||||
void *SourcePtr, u32 SrcWordLength,
|
||||
void *DestPtr, u32 DestWordLength,
|
||||
u32 TransferType);
|
||||
|
||||
/*
|
||||
* Interrupt related function prototypes implemented in xdevcfg_intr.c
|
||||
*/
|
||||
void XDcfg_IntrEnable(XDcfg *InstancePtr, u32 Mask);
|
||||
|
||||
void XDcfg_IntrDisable(XDcfg *InstancePtr, u32 Mask);
|
||||
|
||||
u32 XDcfg_IntrGetEnabled(XDcfg *InstancePtr);
|
||||
|
||||
u32 XDcfg_IntrGetStatus(XDcfg *InstancePtr);
|
||||
|
||||
void XDcfg_IntrClear(XDcfg *InstancePtr, u32 Mask);
|
||||
|
||||
void XDcfg_InterruptHandler(XDcfg *InstancePtr);
|
||||
|
||||
void XDcfg_SetHandler(XDcfg *InstancePtr, void *CallBackFunc,
|
||||
void *CallBackRef);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
52
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_g.c
Normal file
52
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_g.c
Normal file
@ -0,0 +1,52 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdevcfg_g.c
|
||||
* @addtogroup devcfg_v3_7
|
||||
* @{
|
||||
*
|
||||
* This file contains a table that specifies the configuration of the Device
|
||||
* Configuration Interface device in the system. Each device should have an entry
|
||||
* in the table.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a hvm 02/07/11 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xdevcfg.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Prototypes ******************************/
|
||||
|
||||
/**
|
||||
* This table contains configuration information for each Device Config
|
||||
* Interface instance in the system.
|
||||
*/
|
||||
XDcfg_Config XDcfg_ConfigTable[1] = {
|
||||
{
|
||||
XPAR_XDCFG_0_DEVICE_ID,
|
||||
XPAR_XDCFG_0_BASEADDR,
|
||||
}
|
||||
};
|
||||
/** @} */
|
87
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.c
Normal file
87
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.c
Normal file
@ -0,0 +1,87 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdevcfg_hw.c
|
||||
* @addtogroup devcfg_v3_7
|
||||
* @{
|
||||
*
|
||||
* This file contains the implementation of the interface reset functionality
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 2.04a kpc 10/07/13 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xdevcfg_hw.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function perform the reset sequence to the given devcfg interface by
|
||||
* configuring the appropriate control bits in the devcfg specifc registers
|
||||
* the devcfg reset squence involves the following steps
|
||||
* Disable all the interuupts
|
||||
* Clear the status
|
||||
* Update relevant config registers with reset values
|
||||
* Disbale the looopback mode and pcap rate enable
|
||||
*
|
||||
* @param BaseAddress of the interface
|
||||
*
|
||||
* @return N/A
|
||||
*
|
||||
* @note
|
||||
* This function will not modify the slcr registers that are relavant for
|
||||
* devcfg controller
|
||||
******************************************************************************/
|
||||
void XDcfg_ResetHw(u32 BaseAddr)
|
||||
{
|
||||
u32 Regval = 0;
|
||||
|
||||
/* Mask the interrupts */
|
||||
XDcfg_WriteReg(BaseAddr, XDCFG_INT_MASK_OFFSET,
|
||||
XDCFG_IXR_ALL_MASK);
|
||||
/* Clear the interuupt status */
|
||||
Regval = XDcfg_ReadReg(BaseAddr, XDCFG_INT_STS_OFFSET);
|
||||
XDcfg_WriteReg(BaseAddr, XDCFG_INT_STS_OFFSET, Regval);
|
||||
/* Clear the source address register */
|
||||
XDcfg_WriteReg(BaseAddr, XDCFG_DMA_SRC_ADDR_OFFSET, 0x0);
|
||||
/* Clear the destination address register */
|
||||
XDcfg_WriteReg(BaseAddr, XDCFG_DMA_DEST_ADDR_OFFSET, 0x0);
|
||||
/* Clear the source length register */
|
||||
XDcfg_WriteReg(BaseAddr, XDCFG_DMA_SRC_LEN_OFFSET, 0x0);
|
||||
/* Clear the destination length register */
|
||||
XDcfg_WriteReg(BaseAddr, XDCFG_DMA_DEST_LEN_OFFSET, 0x0);
|
||||
/* Clear the loopback enable bit */
|
||||
Regval = XDcfg_ReadReg(BaseAddr, XDCFG_MCTRL_OFFSET);
|
||||
Regval = Regval & ~XDCFG_MCTRL_PCAP_LPBK_MASK;
|
||||
XDcfg_WriteReg(BaseAddr, XDCFG_MCTRL_OFFSET, Regval);
|
||||
/*Reset the configuration register to reset value */
|
||||
XDcfg_WriteReg(BaseAddr, XDCFG_CFG_OFFSET,
|
||||
XDCFG_CONFIG_RESET_VALUE);
|
||||
/*Disable the PCAP rate enable bit */
|
||||
Regval = XDcfg_ReadReg(BaseAddr, XDCFG_CTRL_OFFSET);
|
||||
Regval = Regval & ~XDCFG_CTRL_PCAP_RATE_EN_MASK;
|
||||
XDcfg_WriteReg(BaseAddr, XDCFG_CTRL_OFFSET, Regval);
|
||||
|
||||
}
|
||||
/** @} */
|
369
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.h
Normal file
369
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.h
Normal file
@ -0,0 +1,369 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdevcfg_hw.h
|
||||
* @addtogroup devcfg_v3_7
|
||||
* @{
|
||||
*
|
||||
* This file contains the hardware interface to the Device Config Interface.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a hvm 02/07/11 First release
|
||||
* 2.01a nm 08/01/12 Added defines for the PS Version bits,
|
||||
* removed the FIFO Flush bits from the
|
||||
* Miscellaneous Control Reg
|
||||
* 2.03a nm 04/19/13 Fixed CR# 703728.
|
||||
* Updated the register definitions as per the latest TRM
|
||||
* version UG585 (v1.4) November 16, 2012.
|
||||
* 2.04a kpc 10/07/13 Added function prototype.
|
||||
* 3.00a kpc 25/02/14 Corrected the XDCFG_BASE_ADDRESS macro value.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XDCFG_HW_H /* prevent circular inclusions */
|
||||
#define XDCFG_HW_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_io.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Register Map
|
||||
* Offsets of registers from the start of the device
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XDCFG_CTRL_OFFSET 0x00 /**< Control Register */
|
||||
#define XDCFG_LOCK_OFFSET 0x04 /**< Lock Register */
|
||||
#define XDCFG_CFG_OFFSET 0x08 /**< Configuration Register */
|
||||
#define XDCFG_INT_STS_OFFSET 0x0C /**< Interrupt Status Register */
|
||||
#define XDCFG_INT_MASK_OFFSET 0x10 /**< Interrupt Mask Register */
|
||||
#define XDCFG_STATUS_OFFSET 0x14 /**< Status Register */
|
||||
#define XDCFG_DMA_SRC_ADDR_OFFSET 0x18 /**< DMA Source Address Register */
|
||||
#define XDCFG_DMA_DEST_ADDR_OFFSET 0x1C /**< DMA Destination Address Reg */
|
||||
#define XDCFG_DMA_SRC_LEN_OFFSET 0x20 /**< DMA Source Transfer Length */
|
||||
#define XDCFG_DMA_DEST_LEN_OFFSET 0x24 /**< DMA Destination Transfer */
|
||||
#define XDCFG_ROM_SHADOW_OFFSET 0x28 /**< DMA ROM Shadow Register */
|
||||
#define XDCFG_MULTIBOOT_ADDR_OFFSET 0x2C /**< Multi BootAddress Pointer */
|
||||
#define XDCFG_SW_ID_OFFSET 0x30 /**< Software ID Register */
|
||||
#define XDCFG_UNLOCK_OFFSET 0x34 /**< Unlock Register */
|
||||
#define XDCFG_MCTRL_OFFSET 0x80 /**< Miscellaneous Control Reg */
|
||||
|
||||
/* @} */
|
||||
|
||||
/** @name Control Register Bit definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XDCFG_CTRL_FORCE_RST_MASK 0x80000000 /**< Force into
|
||||
* Secure Reset
|
||||
*/
|
||||
#define XDCFG_CTRL_PCFG_PROG_B_MASK 0x40000000 /**< Program signal to
|
||||
* Reset FPGA
|
||||
*/
|
||||
#define XDCFG_CTRL_PCFG_POR_CNT_4K_MASK 0x20000000 /**< Control PL POR timer */
|
||||
#define XDCFG_CTRL_PCAP_PR_MASK 0x08000000 /**< Enable PCAP for PR */
|
||||
#define XDCFG_CTRL_PCAP_MODE_MASK 0x04000000 /**< Enable PCAP */
|
||||
#define XDCFG_CTRL_PCAP_RATE_EN_MASK 0x02000000 /**< Enable PCAP send data
|
||||
* to FPGA every 4 PCAP
|
||||
* cycles
|
||||
*/
|
||||
#define XDCFG_CTRL_MULTIBOOT_EN_MASK 0x01000000 /**< Multiboot Enable */
|
||||
#define XDCFG_CTRL_JTAG_CHAIN_DIS_MASK 0x00800000 /**< JTAG Chain Disable */
|
||||
#define XDCFG_CTRL_USER_MODE_MASK 0x00008000 /**< User Mode Mask */
|
||||
#define XDCFG_CTRL_PCFG_AES_FUSE_MASK 0x00001000 /**< AES key source */
|
||||
#define XDCFG_CTRL_PCFG_AES_EN_MASK 0x00000E00 /**< AES Enable Mask */
|
||||
#define XDCFG_CTRL_SEU_EN_MASK 0x00000100 /**< SEU Enable Mask */
|
||||
#define XDCFG_CTRL_SEC_EN_MASK 0x00000080 /**< Secure/Non Secure
|
||||
* Status mask
|
||||
*/
|
||||
#define XDCFG_CTRL_SPNIDEN_MASK 0x00000040 /**< Secure Non Invasive
|
||||
* Debug Enable
|
||||
*/
|
||||
#define XDCFG_CTRL_SPIDEN_MASK 0x00000020 /**< Secure Invasive
|
||||
* Debug Enable
|
||||
*/
|
||||
#define XDCFG_CTRL_NIDEN_MASK 0x00000010 /**< Non-Invasive Debug
|
||||
* Enable
|
||||
*/
|
||||
#define XDCFG_CTRL_DBGEN_MASK 0x00000008 /**< Invasive Debug
|
||||
* Enable
|
||||
*/
|
||||
#define XDCFG_CTRL_DAP_EN_MASK 0x00000007 /**< DAP Enable Mask */
|
||||
|
||||
/* @} */
|
||||
|
||||
/** @name Lock register bit definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XDCFG_LOCK_AES_EFUSE_MASK 0x00000010 /**< Lock AES Efuse bit */
|
||||
#define XDCFG_LOCK_AES_EN_MASK 0x00000008 /**< Lock AES_EN update */
|
||||
#define XDCFG_LOCK_SEU_MASK 0x00000004 /**< Lock SEU_En update */
|
||||
#define XDCFG_LOCK_SEC_MASK 0x00000002 /**< Lock SEC_EN and
|
||||
* USER_MODE
|
||||
*/
|
||||
#define XDCFG_LOCK_DBG_MASK 0x00000001 /**< This bit locks
|
||||
* security config
|
||||
* including: DAP_En,
|
||||
* DBGEN,,
|
||||
* NIDEN, SPNIEN
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
/** @name Config Register Bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XDCFG_CFG_RFIFO_TH_MASK 0x00000C00 /**< Read FIFO
|
||||
* Threshold Mask
|
||||
*/
|
||||
#define XDCFG_CFG_WFIFO_TH_MASK 0x00000300 /**< Write FIFO Threshold
|
||||
* Mask
|
||||
*/
|
||||
#define XDCFG_CFG_RCLK_EDGE_MASK 0x00000080 /**< Read data active
|
||||
* clock edge
|
||||
*/
|
||||
#define XDCFG_CFG_WCLK_EDGE_MASK 0x00000040 /**< Write data active
|
||||
* clock edge
|
||||
*/
|
||||
#define XDCFG_CFG_DISABLE_SRC_INC_MASK 0x00000020 /**< Disable Source address
|
||||
* increment mask
|
||||
*/
|
||||
#define XDCFG_CFG_DISABLE_DST_INC_MASK 0x00000010 /**< Disable Destination
|
||||
* address increment
|
||||
* mask
|
||||
*/
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name Interrupt Status/Mask Register Bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XDCFG_IXR_PSS_GTS_USR_B_MASK 0x80000000 /**< Tri-state IO during
|
||||
* HIZ
|
||||
*/
|
||||
#define XDCFG_IXR_PSS_FST_CFG_B_MASK 0x40000000 /**< First configuration
|
||||
* done
|
||||
*/
|
||||
#define XDCFG_IXR_PSS_GPWRDWN_B_MASK 0x20000000 /**< Global power down */
|
||||
#define XDCFG_IXR_PSS_GTS_CFG_B_MASK 0x10000000 /**< Tri-state IO during
|
||||
* configuration
|
||||
*/
|
||||
#define XDCFG_IXR_PSS_CFG_RESET_B_MASK 0x08000000 /**< PL configuration
|
||||
* reset
|
||||
*/
|
||||
#define XDCFG_IXR_AXI_WTO_MASK 0x00800000 /**< AXI Write Address
|
||||
* or Data or response
|
||||
* timeout
|
||||
*/
|
||||
#define XDCFG_IXR_AXI_WERR_MASK 0x00400000 /**< AXI Write response
|
||||
* error
|
||||
*/
|
||||
#define XDCFG_IXR_AXI_RTO_MASK 0x00200000 /**< AXI Read Address or
|
||||
* response timeout
|
||||
*/
|
||||
#define XDCFG_IXR_AXI_RERR_MASK 0x00100000 /**< AXI Read response
|
||||
* error
|
||||
*/
|
||||
#define XDCFG_IXR_RX_FIFO_OV_MASK 0x00040000 /**< Rx FIFO Overflow */
|
||||
#define XDCFG_IXR_WR_FIFO_LVL_MASK 0x00020000 /**< Tx FIFO less than
|
||||
* threshold */
|
||||
#define XDCFG_IXR_RD_FIFO_LVL_MASK 0x00010000 /**< Rx FIFO greater than
|
||||
* threshold */
|
||||
#define XDCFG_IXR_DMA_CMD_ERR_MASK 0x00008000 /**< Illegal DMA command */
|
||||
#define XDCFG_IXR_DMA_Q_OV_MASK 0x00004000 /**< DMA command queue
|
||||
* overflow
|
||||
*/
|
||||
#define XDCFG_IXR_DMA_DONE_MASK 0x00002000 /**< DMA Command Done */
|
||||
#define XDCFG_IXR_D_P_DONE_MASK 0x00001000 /**< DMA and PCAP
|
||||
* transfers Done
|
||||
*/
|
||||
#define XDCFG_IXR_P2D_LEN_ERR_MASK 0x00000800 /**< PCAP to DMA transfer
|
||||
* length error
|
||||
*/
|
||||
#define XDCFG_IXR_PCFG_HMAC_ERR_MASK 0x00000040 /**< HMAC error mask */
|
||||
#define XDCFG_IXR_PCFG_SEU_ERR_MASK 0x00000020 /**< SEU Error mask */
|
||||
#define XDCFG_IXR_PCFG_POR_B_MASK 0x00000010 /**< FPGA POR mask */
|
||||
#define XDCFG_IXR_PCFG_CFG_RST_MASK 0x00000008 /**< FPGA Reset mask */
|
||||
#define XDCFG_IXR_PCFG_DONE_MASK 0x00000004 /**< Done Signal Mask */
|
||||
#define XDCFG_IXR_PCFG_INIT_PE_MASK 0x00000002 /**< Detect Positive edge
|
||||
* of Init Signal
|
||||
*/
|
||||
#define XDCFG_IXR_PCFG_INIT_NE_MASK 0x00000001 /**< Detect Negative edge
|
||||
* of Init Signal
|
||||
*/
|
||||
#define XDCFG_IXR_ERROR_FLAGS_MASK (XDCFG_IXR_AXI_WTO_MASK | \
|
||||
XDCFG_IXR_AXI_WERR_MASK | \
|
||||
XDCFG_IXR_AXI_RTO_MASK | \
|
||||
XDCFG_IXR_AXI_RERR_MASK | \
|
||||
XDCFG_IXR_RX_FIFO_OV_MASK | \
|
||||
XDCFG_IXR_DMA_CMD_ERR_MASK |\
|
||||
XDCFG_IXR_DMA_Q_OV_MASK | \
|
||||
XDCFG_IXR_P2D_LEN_ERR_MASK |\
|
||||
XDCFG_IXR_PCFG_HMAC_ERR_MASK)
|
||||
|
||||
|
||||
#define XDCFG_IXR_ALL_MASK 0x00F7F8EF
|
||||
|
||||
|
||||
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name Status Register Bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XDCFG_STATUS_DMA_CMD_Q_F_MASK 0x80000000 /**< DMA command
|
||||
* Queue full
|
||||
*/
|
||||
#define XDCFG_STATUS_DMA_CMD_Q_E_MASK 0x40000000 /**< DMA command
|
||||
* Queue empty
|
||||
*/
|
||||
#define XDCFG_STATUS_DMA_DONE_CNT_MASK 0x30000000 /**< Number of
|
||||
* completed DMA
|
||||
* transfers
|
||||
*/
|
||||
#define XDCFG_STATUS_RX_FIFO_LVL_MASK 0x01F000000 /**< Rx FIFO level */
|
||||
#define XDCFG_STATUS_TX_FIFO_LVL_MASK 0x0007F000 /**< Tx FIFO level */
|
||||
|
||||
#define XDCFG_STATUS_PSS_GTS_USR_B 0x00000800 /**< Tri-state IO
|
||||
* during HIZ
|
||||
*/
|
||||
#define XDCFG_STATUS_PSS_FST_CFG_B 0x00000400 /**< First PL config
|
||||
* done
|
||||
*/
|
||||
#define XDCFG_STATUS_PSS_GPWRDWN_B 0x00000200 /**< Global power down */
|
||||
#define XDCFG_STATUS_PSS_GTS_CFG_B 0x00000100 /**< Tri-state IO during
|
||||
* config
|
||||
*/
|
||||
#define XDCFG_STATUS_SECURE_RST_MASK 0x00000080 /**< Secure Reset
|
||||
* POR Status
|
||||
*/
|
||||
#define XDCFG_STATUS_ILLEGAL_APB_ACCESS_MASK 0x00000040 /**< Illegal APB
|
||||
* access
|
||||
*/
|
||||
#define XDCFG_STATUS_PSS_CFG_RESET_B 0x00000020 /**< PL config
|
||||
* reset status
|
||||
*/
|
||||
#define XDCFG_STATUS_PCFG_INIT_MASK 0x00000010 /**< FPGA Init
|
||||
* Status
|
||||
*/
|
||||
#define XDCFG_STATUS_EFUSE_BBRAM_KEY_DISABLE_MASK 0x00000008
|
||||
/**< BBRAM key
|
||||
* disable
|
||||
*/
|
||||
#define XDCFG_STATUS_EFUSE_SEC_EN_MASK 0x00000004 /**< Efuse Security
|
||||
* Enable Status
|
||||
*/
|
||||
#define XDCFG_STATUS_EFUSE_JTAG_DIS_MASK 0x00000002 /**< EFuse JTAG
|
||||
* Disable
|
||||
* status
|
||||
*/
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name DMA Source/Destination Transfer Length Register Bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XDCFG_DMA_LEN_MASK 0x7FFFFFF /**< Length Mask */
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
|
||||
/** @name Miscellaneous Control Register Bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XDCFG_MCTRL_PCAP_PS_VERSION_MASK 0xF0000000 /**< PS Version Mask */
|
||||
#define XDCFG_MCTRL_PCAP_PS_VERSION_SHIFT 28 /**< PS Version Shift */
|
||||
#define XDCFG_MCTRL_PCAP_LPBK_MASK 0x00000010 /**< PCAP loopback mask */
|
||||
/* @} */
|
||||
|
||||
/** @name FIFO Threshold Bit definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XDCFG_CFG_FIFO_QUARTER 0x0 /**< Quarter empty */
|
||||
#define XDCFG_CFG_FIFO_HALF 0x1 /**< Half empty */
|
||||
#define XDCFG_CFG_FIFO_3QUARTER 0x2 /**< 3/4 empty */
|
||||
#define XDCFG_CFG_FIFO_EMPTY 0x4 /**< Empty */
|
||||
/* @}*/
|
||||
|
||||
|
||||
/* Miscellaneous constant values */
|
||||
#define XDCFG_DMA_INVALID_ADDRESS 0xFFFFFFFF /**< Invalid DMA address */
|
||||
#define XDCFG_UNLOCK_DATA 0x757BDF0D /**< First APB access data*/
|
||||
#define XDCFG_BASE_ADDRESS 0xF8007000 /**< Device Config base
|
||||
* address
|
||||
*/
|
||||
#define XDCFG_CONFIG_RESET_VALUE 0x508 /**< Config reg reset value */
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given register.
|
||||
*
|
||||
* @param BaseAddr is the base address of the device
|
||||
* @param RegOffset is the register offset to be read
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note C-style signature:
|
||||
* u32 XDcfg_ReadReg(u32 BaseAddr, u32 RegOffset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XDcfg_ReadReg(BaseAddr, RegOffset) \
|
||||
Xil_In32((BaseAddr) + (RegOffset))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write to the given register.
|
||||
*
|
||||
* @param BaseAddr is the base address of the device
|
||||
* @param RegOffset is the register offset to be written
|
||||
* @param Data is the 32-bit value to write to the register
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XDcfg_WriteReg(u32 BaseAddr, u32 RegOffset, u32 Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XDcfg_WriteReg(BaseAddr, RegOffset, Data) \
|
||||
Xil_Out32((BaseAddr) + (RegOffset), (Data))
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
/*
|
||||
* Perform reset operation to the devcfg interface
|
||||
*/
|
||||
void XDcfg_ResetHw(u32 BaseAddr);
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
284
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_intr.c
Normal file
284
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_intr.c
Normal file
@ -0,0 +1,284 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdevcfg_intr.c
|
||||
* @addtogroup devcfg_v3_7
|
||||
* @{
|
||||
*
|
||||
* Contains the implementation of interrupt related functions of the XDcfg
|
||||
* driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a hvm 02/07/11 First release
|
||||
* 2.01a nm 07/07/12 Updated the XDcfg_IntrClear function to directly
|
||||
* set the mask instead of oring it with the
|
||||
* value read from the interrupt status register
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xdevcfg.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function enables the specified interrupts in the device.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param Mask is the bit-mask of the interrupts to be enabled.
|
||||
* Bit positions of 1 will be enabled. Bit positions of 0 will
|
||||
* keep the previous setting. This mask is formed by OR'ing
|
||||
* XDCFG_INT_* bits defined in xdevcfg_hw.h.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_IntrEnable(XDcfg *InstancePtr, u32 Mask)
|
||||
{
|
||||
u32 RegValue;
|
||||
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Enable the specified interrupts in the Interrupt Mask Register.
|
||||
*/
|
||||
RegValue = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_INT_MASK_OFFSET);
|
||||
RegValue &= ~(Mask & XDCFG_IXR_ALL_MASK);
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_INT_MASK_OFFSET,
|
||||
RegValue);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function disables the specified interrupts in the device.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param Mask is the bit-mask of the interrupts to be disabled.
|
||||
* Bit positions of 1 will be disabled. Bit positions of 0 will
|
||||
* keep the previous setting. This mask is formed by OR'ing
|
||||
* XDCFG_INT_* bits defined in xdevcfg_hw.h.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_IntrDisable(XDcfg *InstancePtr, u32 Mask)
|
||||
{
|
||||
u32 RegValue;
|
||||
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Disable the specified interrupts in the Interrupt Mask Register.
|
||||
*/
|
||||
RegValue = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_INT_MASK_OFFSET);
|
||||
RegValue |= (Mask & XDCFG_IXR_ALL_MASK);
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_INT_MASK_OFFSET,
|
||||
RegValue);
|
||||
}
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns the enabled interrupts read from the Interrupt Mask
|
||||
* Register. Use the XDCFG_INT_* constants defined in xdevcfg_hw.h
|
||||
* to interpret the returned value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return A 32-bit value representing the contents of the IMR.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XDcfg_IntrGetEnabled(XDcfg *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Return the value read from the Interrupt Mask Register.
|
||||
*/
|
||||
return (~ XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_INT_MASK_OFFSET));
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns the interrupt status read from Interrupt Status
|
||||
* Register. Use the XDCFG_INT_* constants defined in xdevcfg_hw.h
|
||||
* to interpret the returned value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return A 32-bit value representing the contents of the Interrupt
|
||||
* Status register.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XDcfg_IntrGetStatus(XDcfg *InstancePtr)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Return the value read from the Interrupt Status register.
|
||||
*/
|
||||
return XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_INT_STS_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function clears the specified interrupts in the Interrupt Status
|
||||
* Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
* @param Mask is the bit-mask of the interrupts to be cleared.
|
||||
* Bit positions of 1 will be cleared. Bit positions of 0 will not
|
||||
* change the previous interrupt status. This mask is formed by
|
||||
* OR'ing XDCFG_INT_* bits which are defined in xdevcfg_hw.h.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_IntrClear(XDcfg *InstancePtr, u32 Mask)
|
||||
{
|
||||
/*
|
||||
* Assert the arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_INT_STS_OFFSET,
|
||||
Mask);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* The interrupt handler for the Device Config Interface.
|
||||
*
|
||||
* Events are signaled to upper layer for proper handling.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void XDcfg_InterruptHandler(XDcfg *InstancePtr)
|
||||
{
|
||||
u32 IntrStatusReg;
|
||||
|
||||
/*
|
||||
* Assert validates the input arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the Interrupt status register.
|
||||
*/
|
||||
IntrStatusReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_INT_STS_OFFSET);
|
||||
|
||||
/*
|
||||
* Write the status back to clear the interrupts so that no
|
||||
* subsequent interrupts are missed while processing this interrupt.
|
||||
* This also does the DMA acknowledgment automatically.
|
||||
*/
|
||||
XDcfg_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XDCFG_INT_STS_OFFSET, IntrStatusReg);
|
||||
|
||||
/*
|
||||
* Signal application that there are events to handle.
|
||||
*/
|
||||
InstancePtr->StatusHandler(InstancePtr->CallBackRef,
|
||||
IntrStatusReg);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function sets the handler that will be called when an event (interrupt)
|
||||
* occurs that needs application's attention.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance
|
||||
* @param CallBackFunc is the address of the callback function.
|
||||
* @param CallBackRef is a user data item that will be passed to the
|
||||
* callback function when it is invoked.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XDcfg_SetHandler(XDcfg *InstancePtr, void *CallBackFunc,
|
||||
void *CallBackRef)
|
||||
{
|
||||
/*
|
||||
* Asserts validate the input arguments
|
||||
* CallBackRef not checked, no way to know what is valid
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(CallBackFunc != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
InstancePtr->StatusHandler = (XDcfg_IntrHandler) CallBackFunc;
|
||||
InstancePtr->CallBackRef = CallBackRef;
|
||||
}
|
||||
/** @} */
|
88
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_selftest.c
Normal file
88
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_selftest.c
Normal file
@ -0,0 +1,88 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdevcfg_selftest.c
|
||||
* @addtogroup devcfg_v3_7
|
||||
* @{
|
||||
*
|
||||
* Contains diagnostic self-test functions for the XDcfg driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a hvm 02/07/11 First release
|
||||
* 2.02a nm 02/27/13 Fixed CR# 701348.
|
||||
* Peripheral test fails with Running
|
||||
* DcfgSelfTestExample() in SECURE bootmode.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xdevcfg.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Run a self-test on the Device Configuration Interface. This test does a
|
||||
* control register write and reads back the same value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XDcfg instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if self-test was successful.
|
||||
* - XST_FAILURE if fails.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XDcfg_SelfTest(XDcfg *InstancePtr)
|
||||
{
|
||||
u32 OldCfgReg;
|
||||
u32 CfgReg;
|
||||
int Status = XST_SUCCESS;
|
||||
|
||||
/*
|
||||
* Assert to ensure the inputs are valid and the instance has been
|
||||
* initialized.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
OldCfgReg = XDcfg_GetControlRegister(InstancePtr);
|
||||
|
||||
XDcfg_SetControlRegister(InstancePtr, XDCFG_CTRL_NIDEN_MASK);
|
||||
|
||||
CfgReg = XDcfg_GetControlRegister(InstancePtr);
|
||||
|
||||
if ((CfgReg & XDCFG_CTRL_NIDEN_MASK) != XDCFG_CTRL_NIDEN_MASK) {
|
||||
|
||||
Status = XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore the original values of the register
|
||||
*/
|
||||
XDcfg_SetControlRegister(InstancePtr, OldCfgReg);
|
||||
|
||||
return Status;
|
||||
}
|
||||
/** @} */
|
68
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_sinit.c
Normal file
68
bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_sinit.c
Normal file
@ -0,0 +1,68 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdevcfg_sinit.c
|
||||
* @addtogroup devcfg_v3_7
|
||||
* @{
|
||||
*
|
||||
* This file contains method for static initialization (compile-time) of the
|
||||
* driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a hvm 02/07/11 First release
|
||||
* 3.5 ms 08/07/17 Fixed compilation warnings.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xdevcfg.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Lookup the device configuration based on the unique device ID. The table
|
||||
* contains the configuration info for each device in the system.
|
||||
*
|
||||
* @param DeviceId is the unique device ID of the device being looked up.
|
||||
*
|
||||
* @return A pointer to the configuration table entry corresponding to the
|
||||
* given device ID, or NULL if no match is found.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
XDcfg_Config *XDcfg_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
extern XDcfg_Config XDcfg_ConfigTable[];
|
||||
XDcfg_Config *CfgPtr = NULL;
|
||||
u32 Index;
|
||||
|
||||
for (Index = 0U; Index < XPAR_XDCFG_NUM_INSTANCES; Index++) {
|
||||
if (XDcfg_ConfigTable[Index].DeviceId == DeviceId) {
|
||||
CfgPtr = &XDcfg_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (CfgPtr);
|
||||
}
|
||||
/** @} */
|
41
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/Makefile
Normal file
41
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/Makefile
Normal file
@ -0,0 +1,41 @@
|
||||
DRIVER_LIB_VERSION = 1.0
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
CC_FLAGS = $(COMPILER_FLAGS)
|
||||
ECC_FLAGS = $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I$(INCLUDEDIR)
|
||||
|
||||
INCLUDEFILES:=*.h
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR), $(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
libs: $(OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
${COMPILER} $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) $< -o $@
|
||||
|
||||
.PHONY: include
|
||||
include: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf $(DEPFILES)
|
1961
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.c
Normal file
1961
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.c
Normal file
File diff suppressed because it is too large
Load Diff
329
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.h
Normal file
329
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.h
Normal file
@ -0,0 +1,329 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdmaps.h
|
||||
* @addtogroup dmaps_v2_8
|
||||
* @{
|
||||
* @details
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- ----------------------------------------------
|
||||
* 1.00 hbm 08/19/10 First Release
|
||||
* 1.01a nm 12/20/12 Added definition XDMAPS_CHANNELS_PER_DEV which specifies
|
||||
* the maximum number of channels.
|
||||
* Replaced the usage of XPAR_XDMAPS_CHANNELS_PER_DEV
|
||||
* with XDMAPS_CHANNELS_PER_DEV defined in xdmaps_hw.h.
|
||||
* Added the tcl file to automatically generate the
|
||||
* xparameters.h
|
||||
* 1.02a sg 05/16/12 Made changes for doxygen and moved some function
|
||||
* header from the xdmaps.h file to xdmaps.c file
|
||||
* Other cleanup for coding guidelines and CR 657109
|
||||
* and CR 657898
|
||||
* The xdmaps_example_no_intr.c example is removed
|
||||
* as it is using interrupts and is similar to
|
||||
* the interrupt example - CR 652477
|
||||
* 1.03a sg 07/16/2012 changed inline to __inline for CR665681
|
||||
* 1.04a nm 10/22/2012 Fixed CR# 681671.
|
||||
* 1.05a nm 04/15/2013 Fixed CR# 704396. Removed warnings when compiled
|
||||
* with -Wall and -Wextra option in bsp.
|
||||
* 05/01/2013 Fixed CR# 700189. Changed XDmaPs_BuildDmaProg()
|
||||
* function description.
|
||||
* Fixed CR# 704396. Removed unused variables
|
||||
* UseM2MByte & MemBurstLen from XDmaPs_BuildDmaProg()
|
||||
* function.
|
||||
* 1.07a asa 11/02/13. Made changes to fix compilation issues for iarcc.
|
||||
* Removed the PDBG prints. By default they were always
|
||||
* defined out and never used. The PDBG is non-standard for
|
||||
* Xilinx drivers and no other driver does something similar.
|
||||
* Since there is no easy way to fix compilation issues with
|
||||
* the IARCC compiler around PDBG, it is better to remove it.
|
||||
* Users can always use xil_printfs if they want to debug.
|
||||
* 2.0 adk 10/12/13 Updated as per the New Tcl API's
|
||||
* 2.01 kpc 08/23/14 Fixed the IAR compiler reported errors
|
||||
* 2.2 mus 08/12/16 Declared all inline functions in xdmaps.c as extern, to avoid
|
||||
* linker error for IAR compiler
|
||||
* 2.3 ms 01/23/17 Modified xil_printf statement in main function for all
|
||||
* examples to ensure that "Successfully ran" and "Failed"
|
||||
* strings are available in all examples. This is a fix
|
||||
* for CR-965028.
|
||||
* ms 03/17/17 Added readme.txt file in examples folder for doxygen
|
||||
* generation.
|
||||
* 2.4 adk 13/08/18 Fixed armcc compiler warnings in the driver CR-1008310.
|
||||
* 2.8 sk 05/18/21 Modify all inline functions declarations from extern inline
|
||||
* to static inline to avoid the linkage conflict for IAR compiler.
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef XDMAPS_H /* prevent circular inclusions */
|
||||
#define XDMAPS_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xparameters.h"
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xstatus.h"
|
||||
|
||||
#include "xdmaps_hw.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for the device.
|
||||
*/
|
||||
typedef struct {
|
||||
u16 DeviceId; /**< Unique ID of device */
|
||||
u32 BaseAddress; /**< Base address of device (IPIF) */
|
||||
} XDmaPs_Config;
|
||||
|
||||
|
||||
/** DMA channle control structure. It's for AXI bus transaction.
|
||||
* This struct will be translated into a 32-bit channel control register value.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int EndianSwapSize; /**< Endian swap size. */
|
||||
unsigned int DstCacheCtrl; /**< Destination cache control */
|
||||
unsigned int DstProtCtrl; /**< Destination protection control */
|
||||
unsigned int DstBurstLen; /**< Destination burst length */
|
||||
unsigned int DstBurstSize; /**< Destination burst size */
|
||||
unsigned int DstInc; /**< Destination incrementing or fixed
|
||||
* address */
|
||||
unsigned int SrcCacheCtrl; /**< Source cache control */
|
||||
unsigned int SrcProtCtrl; /**< Source protection control */
|
||||
unsigned int SrcBurstLen; /**< Source burst length */
|
||||
unsigned int SrcBurstSize; /**< Source burst size */
|
||||
unsigned int SrcInc; /**< Source incrementing or fixed
|
||||
* address */
|
||||
} XDmaPs_ChanCtrl;
|
||||
|
||||
/** DMA block descriptor stucture.
|
||||
*/
|
||||
typedef struct {
|
||||
u32 SrcAddr; /**< Source starting address */
|
||||
u32 DstAddr; /**< Destination starting address */
|
||||
unsigned int Length; /**< Number of bytes for the block */
|
||||
} XDmaPs_BD;
|
||||
|
||||
/**
|
||||
* A DMA command consisits of a channel control struct, a block descriptor,
|
||||
* a user defined program, a pointer pointing to generated DMA program, and
|
||||
* execution result.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
XDmaPs_ChanCtrl ChanCtrl; /**< Channel Control Struct */
|
||||
XDmaPs_BD BD; /**< Together with SgLength field,
|
||||
* it's a scatter-gather list.
|
||||
*/
|
||||
void *UserDmaProg; /**< If user wants the driver to
|
||||
* execute their own DMA program,
|
||||
* this field points to the DMA
|
||||
* program.
|
||||
*/
|
||||
int UserDmaProgLength; /**< The length of user defined
|
||||
* DMA program.
|
||||
*/
|
||||
|
||||
void *GeneratedDmaProg; /**< The DMA program genreated
|
||||
* by the driver. This field will be
|
||||
* set if a user invokes the DMA
|
||||
* program generation function. Or
|
||||
* the DMA command is finished and
|
||||
* a user informs the driver not to
|
||||
* release the program buffer.
|
||||
* This field has two purposes, one
|
||||
* is to ask the driver to generate
|
||||
* a DMA program while the DMAC is
|
||||
* performaning DMA transactions. The
|
||||
* other purpose is to debug the
|
||||
* driver.
|
||||
*/
|
||||
int GeneratedDmaProgLength; /**< The length of the DMA program
|
||||
* generated by the driver
|
||||
*/
|
||||
int DmaStatus; /**< 0 on success, otherwise error code
|
||||
*/
|
||||
u32 ChanFaultType; /**< Channel fault type in case of fault
|
||||
*/
|
||||
u32 ChanFaultPCAddr; /**< Channel fault PC address
|
||||
*/
|
||||
} XDmaPs_Cmd;
|
||||
|
||||
/**
|
||||
* It's the done handler a user can set for a channel
|
||||
*/
|
||||
typedef void (*XDmaPsDoneHandler) (unsigned int Channel,
|
||||
XDmaPs_Cmd *DmaCmd,
|
||||
void *CallbackRef);
|
||||
|
||||
/**
|
||||
* It's the fault handler a user can set for a channel
|
||||
*/
|
||||
typedef void (*XDmaPsFaultHandler) (unsigned int Channel,
|
||||
XDmaPs_Cmd *DmaCmd,
|
||||
void *CallbackRef);
|
||||
|
||||
#define XDMAPS_MAX_CHAN_BUFS 2
|
||||
#define XDMAPS_CHAN_BUF_LEN 128
|
||||
|
||||
/**
|
||||
* The XDmaPs_ProgBuf is the struct for a DMA program buffer.
|
||||
*/
|
||||
typedef struct {
|
||||
char Buf[XDMAPS_CHAN_BUF_LEN]; /**< The actual buffer the holds the
|
||||
* content */
|
||||
unsigned Len; /**< The actual length of the DMA
|
||||
* program in bytes. */
|
||||
int Allocated; /**< A tag indicating whether the
|
||||
* buffer is allocated or not */
|
||||
} XDmaPs_ProgBuf;
|
||||
|
||||
/**
|
||||
* The XDmaPs_ChannelData is a struct to book keep individual channel of
|
||||
* the DMAC.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned DevId; /**< Device id indicating which DMAC */
|
||||
unsigned ChanId; /**< Channel number of the DMAC */
|
||||
XDmaPs_ProgBuf ProgBufPool[XDMAPS_MAX_CHAN_BUFS]; /**< A pool of
|
||||
program buffers*/
|
||||
XDmaPsDoneHandler DoneHandler; /**< Done interrupt handler */
|
||||
void *DoneRef; /**< Done interrupt callback data */
|
||||
XDmaPs_Cmd *DmaCmdToHw; /**< DMA command being executed */
|
||||
XDmaPs_Cmd *DmaCmdFromHw; /**< DMA command that is finished.
|
||||
* This field is for debugging purpose
|
||||
*/
|
||||
int HoldDmaProg; /**< A tag indicating whether to hold the
|
||||
* DMA program after the DMA is done.
|
||||
*/
|
||||
|
||||
} XDmaPs_ChannelData;
|
||||
|
||||
/**
|
||||
* The XDmaPs driver instance data structure. A pointer to an instance data
|
||||
* structure is passed around by functions to refer to a specific driver
|
||||
* instance.
|
||||
*/
|
||||
typedef struct {
|
||||
XDmaPs_Config Config; /**< Configuration data structure */
|
||||
int IsReady; /**< Device is Ready */
|
||||
int CacheLength; /**< icache length */
|
||||
XDmaPsFaultHandler FaultHandler; /**< fault interrupt handler */
|
||||
void *FaultRef; /**< fault call back data */
|
||||
XDmaPs_ChannelData Chans[XDMAPS_CHANNELS_PER_DEV];
|
||||
/**<
|
||||
* channel data
|
||||
*/
|
||||
} XDmaPs;
|
||||
|
||||
/*
|
||||
* Functions implemented in xdmaps.c
|
||||
*/
|
||||
int XDmaPs_CfgInitialize(XDmaPs *InstPtr,
|
||||
XDmaPs_Config *Config,
|
||||
u32 EffectiveAddr);
|
||||
|
||||
int XDmaPs_Start(XDmaPs *InstPtr, unsigned int Channel,
|
||||
XDmaPs_Cmd *Cmd,
|
||||
int HoldDmaProg);
|
||||
|
||||
int XDmaPs_IsActive(XDmaPs *InstPtr, unsigned int Channel);
|
||||
int XDmaPs_GenDmaProg(XDmaPs *InstPtr, unsigned int Channel,
|
||||
XDmaPs_Cmd *Cmd);
|
||||
int XDmaPs_FreeDmaProg(XDmaPs *InstPtr, unsigned int Channel,
|
||||
XDmaPs_Cmd *Cmd);
|
||||
void XDmaPs_Print_DmaProg(XDmaPs_Cmd *Cmd);
|
||||
|
||||
|
||||
int XDmaPs_ResetManager(XDmaPs *InstPtr);
|
||||
int XDmaPs_ResetChannel(XDmaPs *InstPtr, unsigned int Channel);
|
||||
|
||||
|
||||
int XDmaPs_SetDoneHandler(XDmaPs *InstPtr,
|
||||
unsigned Channel,
|
||||
XDmaPsDoneHandler DoneHandler,
|
||||
void *CallbackRef);
|
||||
|
||||
int XDmaPs_SetFaultHandler(XDmaPs *InstPtr,
|
||||
XDmaPsFaultHandler FaultHandler,
|
||||
void *CallbackRef);
|
||||
|
||||
void XDmaPs_Print_DmaProg(XDmaPs_Cmd *Cmd);
|
||||
int XDmaPs_Instr_DMARMB(char *DmaProg);
|
||||
int XDmaPs_Instr_DMAWMB(char *DmaProg);
|
||||
|
||||
/**
|
||||
* To avoid linkage error,modify all inline functions from extern
|
||||
* inline to static inline for IAR compiler
|
||||
*/
|
||||
#ifdef __ICCARM__
|
||||
static INLINE int XDmaPs_Instr_DMAEND(char *DmaProg);
|
||||
static INLINE void XDmaPs_Memcpy4(char *Dst, char *Src);
|
||||
static INLINE int XDmaPs_Instr_DMAGO(char *DmaProg, unsigned int Cn,
|
||||
u32 Imm, unsigned int Ns);
|
||||
static INLINE int XDmaPs_Instr_DMALD(char *DmaProg);
|
||||
static INLINE int XDmaPs_Instr_DMALP(char *DmaProg, unsigned Lc,
|
||||
unsigned LoopIterations);
|
||||
static INLINE int XDmaPs_Instr_DMALPEND(char *DmaProg, char *BodyStart, unsigned Lc);
|
||||
static INLINE int XDmaPs_Instr_DMAMOV(char *DmaProg, unsigned Rd, u32 Imm);
|
||||
static INLINE int XDmaPs_Instr_DMANOP(char *DmaProg);
|
||||
static INLINE int XDmaPs_Instr_DMASEV(char *DmaProg, unsigned int EventNumber);
|
||||
static INLINE int XDmaPs_Instr_DMAST(char *DmaProg);
|
||||
static INLINE unsigned XDmaPs_ToEndianSwapSizeBits(unsigned int EndianSwapSize);
|
||||
static INLINE unsigned XDmaPs_ToBurstSizeBits(unsigned BurstSize);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Driver done interrupt service routines for the channels.
|
||||
* We need this done ISR mainly because the driver needs to release the
|
||||
* DMA program buffer. This is the one that connects the GIC
|
||||
*/
|
||||
void XDmaPs_DoneISR_0(XDmaPs *InstPtr);
|
||||
void XDmaPs_DoneISR_1(XDmaPs *InstPtr);
|
||||
void XDmaPs_DoneISR_2(XDmaPs *InstPtr);
|
||||
void XDmaPs_DoneISR_3(XDmaPs *InstPtr);
|
||||
void XDmaPs_DoneISR_4(XDmaPs *InstPtr);
|
||||
void XDmaPs_DoneISR_5(XDmaPs *InstPtr);
|
||||
void XDmaPs_DoneISR_6(XDmaPs *InstPtr);
|
||||
void XDmaPs_DoneISR_7(XDmaPs *InstPtr);
|
||||
|
||||
/**
|
||||
* Driver fault interrupt service routine
|
||||
*/
|
||||
void XDmaPs_FaultISR(XDmaPs *InstPtr);
|
||||
|
||||
|
||||
/*
|
||||
* Static loopup function implemented in xdmaps_sinit.c
|
||||
*/
|
||||
XDmaPs_Config *XDmaPs_LookupConfig(u16 DeviceId);
|
||||
|
||||
|
||||
/*
|
||||
* self-test functions in xdmaps_selftest.c
|
||||
*/
|
||||
int XDmaPs_SelfTest(XDmaPs *InstPtr);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
54
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_g.c
Normal file
54
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_g.c
Normal file
@ -0,0 +1,54 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdmaps_g.c
|
||||
* @addtogroup dmaps_v2_8
|
||||
* @{
|
||||
*
|
||||
* This file contains a configuration table where each entry is a configuration
|
||||
* structure for an XDmaPs device in the system.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- -----------------------------------------------
|
||||
* 1.00 hbm 08/19/2010 First Release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xparameters.h"
|
||||
#include "xdmaps.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Prototypes ******************************/
|
||||
|
||||
/**
|
||||
* Each XDmaPs device in the system has an entry in this table.
|
||||
*/
|
||||
XDmaPs_Config XDmaPs_ConfigTable[] = {
|
||||
{
|
||||
XPAR_XDMAPS_0_DEVICE_ID,
|
||||
XPAR_XDMAPS_0_BASEADDR,
|
||||
},
|
||||
};
|
||||
/** @} */
|
90
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.c
Normal file
90
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.c
Normal file
@ -0,0 +1,90 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdmaps_hw.c
|
||||
* @addtogroup dmaps_v2_8
|
||||
* @{
|
||||
*
|
||||
* This file contains the implementation of the interface reset functionality
|
||||
* for XDmaPs driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- ----------------------------------------------
|
||||
* 1.06a kpc 10/07/13 First release
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
#include "xdmaps_hw.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
#ifndef XDMAPS_MAX_WAIT
|
||||
#define XDMAPS_MAX_WAIT 4000
|
||||
#endif
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function perform the reset sequence to the given dmaps interface by
|
||||
* configuring the appropriate control bits in the dmaps specifc registers
|
||||
* the dmaps reset squence involves the following steps
|
||||
* Disable all the interuupts
|
||||
* Clear the pending interrupts
|
||||
* Kill all the active channel threads
|
||||
* Kill the manager thread
|
||||
*
|
||||
* @param BaseAddress of the interface
|
||||
*
|
||||
* @return N/A
|
||||
*
|
||||
* @note
|
||||
* This function will not modify the slcr registers that are relavant for
|
||||
* dmaps controller
|
||||
******************************************************************************/
|
||||
void XDmaPs_ResetHw(u32 BaseAddress)
|
||||
{
|
||||
u32 DbgInst;
|
||||
u32 WaitCount = 0;
|
||||
u32 ChanIndex;
|
||||
|
||||
/* Disable all the interrupts */
|
||||
XDmaPs_WriteReg(BaseAddress, XDMAPS_INTEN_OFFSET, 0x00);
|
||||
/* Clear the interrupts */
|
||||
XDmaPs_WriteReg(BaseAddress, XDMAPS_INTCLR_OFFSET, XDMAPS_INTCLR_ALL_MASK);
|
||||
/* Kill the dma channel threads */
|
||||
for (ChanIndex=0; ChanIndex < XDMAPS_CHANNELS_PER_DEV; ChanIndex++) {
|
||||
while ((XDmaPs_ReadReg(BaseAddress, XDMAPS_DBGSTATUS_OFFSET)
|
||||
& XDMAPS_DBGSTATUS_BUSY)
|
||||
&& (WaitCount < XDMAPS_MAX_WAIT))
|
||||
WaitCount++;
|
||||
|
||||
DbgInst = XDmaPs_DBGINST0(0, 0x01, ChanIndex, 1);
|
||||
XDmaPs_WriteReg(BaseAddress, XDMAPS_DBGINST0_OFFSET, DbgInst);
|
||||
XDmaPs_WriteReg(BaseAddress, XDMAPS_DBGINST1_OFFSET, 0x0);
|
||||
XDmaPs_WriteReg(BaseAddress, XDMAPS_DBGCMD_OFFSET, 0x0);
|
||||
}
|
||||
/* Kill the manager thread */
|
||||
DbgInst = XDmaPs_DBGINST0(0, 0x01, 0, 0);
|
||||
XDmaPs_WriteReg(BaseAddress, XDMAPS_DBGINST0_OFFSET, DbgInst);
|
||||
XDmaPs_WriteReg(BaseAddress, XDMAPS_DBGINST1_OFFSET, 0x0);
|
||||
XDmaPs_WriteReg(BaseAddress, XDMAPS_DBGCMD_OFFSET, 0x0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** @} */
|
267
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.h
Normal file
267
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.h
Normal file
@ -0,0 +1,267 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdmaps_hw.h
|
||||
* @addtogroup dmaps_v2_8
|
||||
* @{
|
||||
*
|
||||
* This header file contains the hardware interface of an XDmaPs device.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- ----------------------------------------------
|
||||
* 1.00a hbm 08/18/10 First Release
|
||||
* 1.01a nm 12/20/12 Added definition XDMAPS_CHANNELS_PER_DEV which specifies
|
||||
* the maximum number of channels.
|
||||
* Replaced the usage of XPAR_XDMAPS_CHANNELS_PER_DEV
|
||||
* with XDMAPS_CHANNELS_PER_DEV defined in xdmaps_hw.h
|
||||
* 1.02a sg 05/16/12 Made changes for doxygen
|
||||
* 1.06a kpc 07/10/13 Added function prototype
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef XDMAPS_HW_H /* prevent circular inclusions */
|
||||
#define XDMAPS_HW_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xil_io.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Register Map
|
||||
*
|
||||
* Register offsets for the DMAC.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XDMAPS_DS_OFFSET 0x000 /* DMA Status Register */
|
||||
#define XDMAPS_DPC_OFFSET 0x004 /* DMA Program Counter Rregister */
|
||||
#define XDMAPS_INTEN_OFFSET 0X020 /* DMA Interrupt Enable Register */
|
||||
#define XDMAPS_ES_OFFSET 0x024 /* DMA Event Status Register */
|
||||
#define XDMAPS_INTSTATUS_OFFSET 0x028 /* DMA Interrupt Status Register
|
||||
*/
|
||||
#define XDMAPS_INTCLR_OFFSET 0x02c /* DMA Interrupt Clear Register */
|
||||
#define XDMAPS_FSM_OFFSET 0x030 /* DMA Fault Status DMA Manager
|
||||
* Register
|
||||
*/
|
||||
#define XDMAPS_FSC_OFFSET 0x034 /* DMA Fault Status DMA Chanel Register
|
||||
*/
|
||||
#define XDMAPS_FTM_OFFSET 0x038 /* DMA Fault Type DMA Manager Register */
|
||||
|
||||
#define XDMAPS_FTC0_OFFSET 0x040 /* DMA Fault Type for DMA Channel 0 */
|
||||
/*
|
||||
* The offset for the rest of the FTC registers is calculated as
|
||||
* FTC0 + dev_chan_num * 4
|
||||
*/
|
||||
#define XDmaPs_FTCn_OFFSET(ch) (XDMAPS_FTC0_OFFSET + (ch) * 4)
|
||||
|
||||
#define XDMAPS_CS0_OFFSET 0x100 /* Channel Status for DMA Channel 0 */
|
||||
/*
|
||||
* The offset for the rest of the CS registers is calculated as
|
||||
* CS0 + * dev_chan_num * 0x08
|
||||
*/
|
||||
#define XDmaPs_CSn_OFFSET(ch) (XDMAPS_CS0_OFFSET + (ch) * 8)
|
||||
|
||||
#define XDMAPS_CPC0_OFFSET 0x104 /* Channel Program Counter for DMA
|
||||
* Channel 0
|
||||
*/
|
||||
/*
|
||||
* The offset for the rest of the CPC registers is calculated as
|
||||
* CPC0 + dev_chan_num * 0x08
|
||||
*/
|
||||
#define XDmaPs_CPCn_OFFSET(ch) (XDMAPS_CPC0_OFFSET + (ch) * 8)
|
||||
|
||||
#define XDMAPS_SA_0_OFFSET 0x400 /* Source Address Register for DMA
|
||||
* Channel 0
|
||||
*/
|
||||
/* The offset for the rest of the SA registers is calculated as
|
||||
* SA_0 + dev_chan_num * 0x20
|
||||
*/
|
||||
#define XDmaPs_SA_n_OFFSET(ch) (XDMAPS_SA_0_OFFSET + (ch) * 0x20)
|
||||
|
||||
#define XDMAPS_DA_0_OFFSET 0x404 /* Destination Address Register for
|
||||
* DMA Channel 0
|
||||
*/
|
||||
/* The offset for the rest of the DA registers is calculated as
|
||||
* DA_0 + dev_chan_num * 0x20
|
||||
*/
|
||||
#define XDmaPs_DA_n_OFFSET(ch) (XDMAPS_DA_0_OFFSET + (ch) * 0x20)
|
||||
|
||||
#define XDMAPS_CC_0_OFFSET 0x408 /* Channel Control Register for
|
||||
* DMA Channel 0
|
||||
*/
|
||||
/*
|
||||
* The offset for the rest of the CC registers is calculated as
|
||||
* CC_0 + dev_chan_num * 0x20
|
||||
*/
|
||||
#define XDmaPs_CC_n_OFFSET(ch) (XDMAPS_CC_0_OFFSET + (ch) * 0x20)
|
||||
|
||||
#define XDMAPS_LC0_0_OFFSET 0x40C /* Loop Counter 0 for DMA Channel 0 */
|
||||
/*
|
||||
* The offset for the rest of the LC0 registers is calculated as
|
||||
* LC_0 + dev_chan_num * 0x20
|
||||
*/
|
||||
#define XDmaPs_LC0_n_OFFSET(ch) (XDMAPS_LC0_0_OFFSET + (ch) * 0x20)
|
||||
#define XDMAPS_LC1_0_OFFSET 0x410 /* Loop Counter 1 for DMA Channel 0 */
|
||||
/*
|
||||
* The offset for the rest of the LC1 registers is calculated as
|
||||
* LC_0 + dev_chan_num * 0x20
|
||||
*/
|
||||
#define XDmaPs_LC1_n_OFFSET(ch) (XDMAPS_LC1_0_OFFSET + (ch) * 0x20)
|
||||
|
||||
#define XDMAPS_DBGSTATUS_OFFSET 0xD00 /* Debug Status Register */
|
||||
#define XDMAPS_DBGCMD_OFFSET 0xD04 /* Debug Command Register */
|
||||
#define XDMAPS_DBGINST0_OFFSET 0xD08 /* Debug Instruction 0 Register */
|
||||
#define XDMAPS_DBGINST1_OFFSET 0xD0C /* Debug Instruction 1 Register */
|
||||
|
||||
#define XDMAPS_CR0_OFFSET 0xE00 /* Configuration Register 0 */
|
||||
#define XDMAPS_CR1_OFFSET 0xE04 /* Configuration Register 1 */
|
||||
#define XDMAPS_CR2_OFFSET 0xE08 /* Configuration Register 2 */
|
||||
#define XDMAPS_CR3_OFFSET 0xE0C /* Configuration Register 3 */
|
||||
#define XDMAPS_CR4_OFFSET 0xE10 /* Configuration Register 4 */
|
||||
#define XDMAPS_CRDN_OFFSET 0xE14 /* Configuration Register Dn */
|
||||
|
||||
#define XDMAPS_PERIPH_ID_0_OFFSET 0xFE0 /* Peripheral Identification
|
||||
* Register 0
|
||||
*/
|
||||
#define XDMAPS_PERIPH_ID_1_OFFSET 0xFE4 /* Peripheral Identification
|
||||
* Register 1
|
||||
*/
|
||||
#define XDMAPS_PERIPH_ID_2_OFFSET 0xFE8 /* Peripheral Identification
|
||||
* Register 2
|
||||
*/
|
||||
#define XDMAPS_PERIPH_ID_3_OFFSET 0xFEC /* Peripheral Identification
|
||||
* Register 3
|
||||
*/
|
||||
#define XDMAPS_PCELL_ID_0_OFFSET 0xFF0 /* PrimeCell Identification
|
||||
* Register 0
|
||||
*/
|
||||
#define XDMAPS_PCELL_ID_1_OFFSET 0xFF4 /* PrimeCell Identification
|
||||
* Register 1
|
||||
*/
|
||||
#define XDMAPS_PCELL_ID_2_OFFSET 0xFF8 /* PrimeCell Identification
|
||||
* Register 2
|
||||
*/
|
||||
#define XDMAPS_PCELL_ID_3_OFFSET 0xFFC /* PrimeCell Identification
|
||||
* Register 3
|
||||
*/
|
||||
|
||||
/*
|
||||
* Some useful register masks
|
||||
*/
|
||||
#define XDMAPS_DS_DMA_STATUS 0x0F /* DMA status mask */
|
||||
#define XDMAPS_DS_DMA_STATUS_STOPPED 0x00 /* debug status busy mask */
|
||||
|
||||
#define XDMAPS_DBGSTATUS_BUSY 0x01 /* debug status busy mask */
|
||||
|
||||
#define XDMAPS_CS_ACTIVE_MASK 0x07 /* channel status active mask,
|
||||
* llast 3 bits of CS register
|
||||
*/
|
||||
|
||||
#define XDMAPS_CR1_I_CACHE_LEN_MASK 0x07 /* i_cache_len mask */
|
||||
|
||||
|
||||
/*
|
||||
* XDMAPS_DBGINST0 - constructs the word for the Debug Instruction-0 Register.
|
||||
* @b1: Instruction byte 1
|
||||
* @b0: Instruction byte 0
|
||||
* @ch: Channel number
|
||||
* @dbg_th: Debug thread encoding: 0 = DMA manager thread, 1 = DMA channel
|
||||
*/
|
||||
#define XDmaPs_DBGINST0(b1, b0, ch, dbg_th) \
|
||||
(((b1) << 24) | ((b0) << 16) | (((ch) & 0x7) << 8) | ((dbg_th & 0x1)))
|
||||
|
||||
/* @} */
|
||||
|
||||
/** @name Control Register
|
||||
*
|
||||
* The Control register (CR) controls the major functions of the device.
|
||||
*
|
||||
* Control Register Bit Definition
|
||||
*/
|
||||
|
||||
/* @}*/
|
||||
|
||||
|
||||
#define XDMAPS_CHANNELS_PER_DEV 8
|
||||
|
||||
|
||||
/** @name Mode Register
|
||||
*
|
||||
* The mode register (MR) defines the mode of transfer as well as the data
|
||||
* format. If this register is modified during transmission or reception,
|
||||
* data validity cannot be guaranteed.
|
||||
*
|
||||
* Mode Register Bit Definition
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name Interrupt Registers
|
||||
*
|
||||
* Interrupt control logic uses the interrupt enable register (IER) and the
|
||||
* interrupt disable register (IDR) to set the value of the bits in the
|
||||
* interrupt mask register (IMR). The IMR determines whether to pass an
|
||||
* interrupt to the interrupt status register (ISR).
|
||||
* Writing a 1 to IER Enbables an interrupt, writing a 1 to IDR disables an
|
||||
* interrupt. IMR and ISR are read only, and IER and IDR are write only.
|
||||
* Reading either IER or IDR returns 0x00.
|
||||
*
|
||||
* All four registers have the same bit definitions.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* @} */
|
||||
#define XDMAPS_INTCLR_ALL_MASK 0xFF
|
||||
|
||||
#define XDmaPs_ReadReg(BaseAddress, RegOffset) \
|
||||
Xil_In32((BaseAddress) + (RegOffset))
|
||||
|
||||
/***************************************************************************/
|
||||
/**
|
||||
* Write a DMAC register.
|
||||
*
|
||||
* @param BaseAddress contains the base address of the device.
|
||||
* @param RegOffset contains the offset from the base address of the device.
|
||||
* @param RegisterValue is the value to be written to the register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-Style signature:
|
||||
* void XDmaPs_WriteReg(u32 BaseAddress, int RegOffset,
|
||||
* u32 RegisterValue)
|
||||
******************************************************************************/
|
||||
#define XDmaPs_WriteReg(BaseAddress, RegOffset, RegisterValue) \
|
||||
Xil_Out32((BaseAddress) + (RegOffset), (RegisterValue))
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
/*
|
||||
* Perform reset operation to the dmaps interface
|
||||
*/
|
||||
void XDmaPs_ResetHw(u32 BaseAddr);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
84
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_selftest.c
Normal file
84
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_selftest.c
Normal file
@ -0,0 +1,84 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdmaps_selftest.c
|
||||
* @addtogroup dmaps_v2_8
|
||||
* @{
|
||||
*
|
||||
* This file contains the self-test functions for the XDmaPs driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------ -------- -----------------------------------------------
|
||||
* 1.00 hbm 03/29/2010 First Release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xdmaps.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function runs a self-test on the driver and hardware device. This self
|
||||
* test performs a local loopback and verifies data can be sent and received.
|
||||
*
|
||||
* The time for this test is proportional to the baud rate that has been set
|
||||
* prior to calling this function.
|
||||
*
|
||||
* The mode and control registers are restored before return.
|
||||
*
|
||||
* @param InstPtr is a pointer to the XDmaPs instance
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* - XST_SUCCESS if the test was successful
|
||||
* - XST_FAILURE if the test failed
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* This function can hang if the hardware is not functioning properly.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XDmaPs_SelfTest(XDmaPs *InstPtr)
|
||||
{
|
||||
u32 BaseAddr = InstPtr->Config.BaseAddress;
|
||||
int i;
|
||||
|
||||
if (XDmaPs_ReadReg(BaseAddr, XDMAPS_DBGSTATUS_OFFSET)
|
||||
& XDMAPS_DBGSTATUS_BUSY)
|
||||
return XST_FAILURE;
|
||||
|
||||
for (i = 0; i < XDMAPS_CHANNELS_PER_DEV; i++) {
|
||||
if (XDmaPs_ReadReg(BaseAddr,
|
||||
XDmaPs_CSn_OFFSET(i)))
|
||||
return XST_FAILURE;
|
||||
}
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
/** @} */
|
78
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_sinit.c
Normal file
78
bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_sinit.c
Normal file
@ -0,0 +1,78 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xdmaps_sinit.c
|
||||
* @addtogroup dmaps_v2_8
|
||||
* @{
|
||||
*
|
||||
* The implementation of the XDmaPs driver's static initialzation
|
||||
* functionality.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.00 hbm 08/13/10 First Release
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xparameters.h"
|
||||
#include "xdmaps.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
extern XDmaPs_Config XDmaPs_ConfigTable[];
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Looks up the device configuration based on the unique device ID. The table
|
||||
* contains the configuration info for each device in the system.
|
||||
*
|
||||
* @param DeviceId contains the ID of the device
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* A pointer to the configuration structure or NULL if the specified device
|
||||
* is not in the system.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* None.
|
||||
*
|
||||
******************************************************************************/
|
||||
XDmaPs_Config *XDmaPs_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
XDmaPs_Config *CfgPtr = NULL;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < XPAR_XDMAPS_NUM_INSTANCES; i++) {
|
||||
if (XDmaPs_ConfigTable[i].DeviceId == DeviceId) {
|
||||
CfgPtr = &XDmaPs_ConfigTable[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CfgPtr;
|
||||
}
|
||||
/** @} */
|
41
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/Makefile
Normal file
41
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/Makefile
Normal file
@ -0,0 +1,41 @@
|
||||
DRIVER_LIB_VERSION = 1.0
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
CC_FLAGS = $(COMPILER_FLAGS)
|
||||
ECC_FLAGS = $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I$(INCLUDEDIR)
|
||||
|
||||
INCLUDEFILES:=*.h
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR), $(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
libs: $(OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
${COMPILER} $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) $< -o $@
|
||||
|
||||
.PHONY: include
|
||||
include: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf $(DEPFILES)
|
487
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.c
Normal file
487
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.c
Normal file
@ -0,0 +1,487 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xemacps.c
|
||||
* @addtogroup emacps_v3_16
|
||||
* @{
|
||||
*
|
||||
* The XEmacPs driver. Functions in this file are the minimum required functions
|
||||
* for this driver. See xemacps.h for a detailed description of the driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.00a wsy 01/10/10 First release
|
||||
* 2.1 srt 07/15/14 Add support for Zynq Ultrascale Mp GEM specification and
|
||||
* 64-bit changes.
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.0 hk 02/20/15 Added support for jumbo frames. Increase AHB burst.
|
||||
* Disable extended mode. Perform all 64 bit changes under
|
||||
* check for arch64.
|
||||
* 3.1 hk 08/10/15 Update upper 32 bit tx and rx queue ptr registers
|
||||
* 3.5 hk 08/14/17 Update cache coherency information of the interface in
|
||||
* its config structure.
|
||||
* 3.8 hk 09/17/18 Cleanup stale comments.
|
||||
* 3.8 mus 11/05/18 Support 64 bit DMA addresses for Microblaze-X platform.
|
||||
* 3.10 hk 05/16/19 Clear status registers properly in reset
|
||||
* 3.11 sd 02/14/20 Add clock support
|
||||
*
|
||||
* </pre>
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xemacps.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
void XEmacPs_StubHandler(void); /* Default handler routine */
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Initialize a specific XEmacPs instance/driver. The initialization entails:
|
||||
* - Initialize fields of the XEmacPs instance structure
|
||||
* - Reset hardware and apply default options
|
||||
* - Configure the DMA channels
|
||||
*
|
||||
* The PHY is setup independently from the device. Use the MII or whatever other
|
||||
* interface may be present for setup.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param CfgPtr is the device configuration structure containing required
|
||||
* hardware build data.
|
||||
* @param EffectiveAddress is the base address of the device. If address
|
||||
* translation is not utilized, this parameter can be passed in using
|
||||
* CfgPtr->Config.BaseAddress to specify the physical base address.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if initialization was successful
|
||||
*
|
||||
******************************************************************************/
|
||||
LONG XEmacPs_CfgInitialize(XEmacPs *InstancePtr, XEmacPs_Config * CfgPtr,
|
||||
UINTPTR EffectiveAddress)
|
||||
{
|
||||
/* Verify arguments */
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(CfgPtr != NULL);
|
||||
|
||||
/* Set device base address and ID */
|
||||
InstancePtr->Config.DeviceId = CfgPtr->DeviceId;
|
||||
InstancePtr->Config.BaseAddress = EffectiveAddress;
|
||||
InstancePtr->Config.IsCacheCoherent = CfgPtr->IsCacheCoherent;
|
||||
#if defined (XCLOCKING)
|
||||
InstancePtr->Config.RefClk = CfgPtr->RefClk;
|
||||
#endif
|
||||
|
||||
InstancePtr->Config.S1GDiv0 = CfgPtr->S1GDiv0;
|
||||
InstancePtr->Config.S1GDiv1 = CfgPtr->S1GDiv1;
|
||||
InstancePtr->Config.S100MDiv0 = CfgPtr->S100MDiv0;
|
||||
InstancePtr->Config.S100MDiv1 = CfgPtr->S100MDiv1;
|
||||
InstancePtr->Config.S10MDiv0 = CfgPtr->S10MDiv0;
|
||||
InstancePtr->Config.S10MDiv1 = CfgPtr->S10MDiv1;
|
||||
|
||||
/* Set callbacks to an initial stub routine */
|
||||
InstancePtr->SendHandler = ((XEmacPs_Handler)((void*)XEmacPs_StubHandler));
|
||||
InstancePtr->RecvHandler = ((XEmacPs_Handler)(void*)XEmacPs_StubHandler);
|
||||
InstancePtr->ErrorHandler = ((XEmacPs_ErrHandler)(void*)XEmacPs_StubHandler);
|
||||
|
||||
/* Reset the hardware and set default options */
|
||||
InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
|
||||
XEmacPs_Reset(InstancePtr);
|
||||
|
||||
return (LONG)(XST_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Start the Ethernet controller as follows:
|
||||
* - Enable transmitter if XTE_TRANSMIT_ENABLE_OPTION is set
|
||||
* - Enable receiver if XTE_RECEIVER_ENABLE_OPTION is set
|
||||
* - Start the SG DMA send and receive channels and enable the device
|
||||
* interrupt
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
*
|
||||
* @return N/A
|
||||
*
|
||||
* @note
|
||||
* Hardware is configured with scatter-gather DMA, the driver expects to start
|
||||
* the scatter-gather channels and expects that the user has previously set up
|
||||
* the buffer descriptor lists.
|
||||
*
|
||||
* This function makes use of internal resources that are shared between the
|
||||
* Start, Stop, and Set/ClearOptions functions. So if one task might be setting
|
||||
* device options while another is trying to start the device, the user is
|
||||
* required to provide protection of this shared data (typically using a
|
||||
* semaphore).
|
||||
*
|
||||
* This function must not be preempted by an interrupt that may service the
|
||||
* device.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XEmacPs_Start(XEmacPs *InstancePtr)
|
||||
{
|
||||
u32 Reg;
|
||||
|
||||
/* Assert bad arguments and conditions */
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == (u32)XIL_COMPONENT_IS_READY);
|
||||
|
||||
#if defined (XCLOCKING)
|
||||
if (InstancePtr->IsStarted != (u32)XIL_COMPONENT_IS_STARTED) {
|
||||
Xil_ClockEnable(InstancePtr->Config.RefClk);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Start DMA */
|
||||
/* When starting the DMA channels, both transmit and receive sides
|
||||
* need an initialized BD list.
|
||||
*/
|
||||
if (InstancePtr->Version == 2) {
|
||||
Xil_AssertVoid(InstancePtr->RxBdRing.BaseBdAddr != 0);
|
||||
Xil_AssertVoid(InstancePtr->TxBdRing.BaseBdAddr != 0);
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_RXQBASE_OFFSET,
|
||||
InstancePtr->RxBdRing.BaseBdAddr);
|
||||
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_TXQBASE_OFFSET,
|
||||
InstancePtr->TxBdRing.BaseBdAddr);
|
||||
}
|
||||
|
||||
/* clear any existed int status */
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress, XEMACPS_ISR_OFFSET,
|
||||
XEMACPS_IXR_ALL_MASK);
|
||||
|
||||
/* Enable transmitter if not already enabled */
|
||||
if ((InstancePtr->Options & (u32)XEMACPS_TRANSMITTER_ENABLE_OPTION)!=0x00000000U) {
|
||||
Reg = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET);
|
||||
if ((!(Reg & XEMACPS_NWCTRL_TXEN_MASK))==TRUE) {
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET,
|
||||
Reg | (u32)XEMACPS_NWCTRL_TXEN_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable receiver if not already enabled */
|
||||
if ((InstancePtr->Options & XEMACPS_RECEIVER_ENABLE_OPTION) != 0x00000000U) {
|
||||
Reg = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET);
|
||||
if ((!(Reg & XEMACPS_NWCTRL_RXEN_MASK))==TRUE) {
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET,
|
||||
Reg | (u32)XEMACPS_NWCTRL_RXEN_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable TX and RX interrupts */
|
||||
XEmacPs_IntEnable(InstancePtr, (XEMACPS_IXR_TX_ERR_MASK |
|
||||
XEMACPS_IXR_RX_ERR_MASK | (u32)XEMACPS_IXR_FRAMERX_MASK |
|
||||
(u32)XEMACPS_IXR_TXCOMPL_MASK));
|
||||
|
||||
/* Enable TX Q1 Interrupts */
|
||||
if (InstancePtr->Version > 2)
|
||||
XEmacPs_IntQ1Enable(InstancePtr, XEMACPS_INTQ1_IXR_ALL_MASK);
|
||||
|
||||
/* Mark as started */
|
||||
InstancePtr->IsStarted = XIL_COMPONENT_IS_STARTED;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Gracefully stop the Ethernet MAC as follows:
|
||||
* - Disable all interrupts from this device
|
||||
* - Stop DMA channels
|
||||
* - Disable the tansmitter and receiver
|
||||
*
|
||||
* Device options currently in effect are not changed.
|
||||
*
|
||||
* This function will disable all interrupts. Default interrupts settings that
|
||||
* had been enabled will be restored when XEmacPs_Start() is called.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
*
|
||||
* @note
|
||||
* This function makes use of internal resources that are shared between the
|
||||
* Start, Stop, SetOptions, and ClearOptions functions. So if one task might be
|
||||
* setting device options while another is trying to start the device, the user
|
||||
* is required to provide protection of this shared data (typically using a
|
||||
* semaphore).
|
||||
*
|
||||
* Stopping the DMA channels causes this function to block until the DMA
|
||||
* operation is complete.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XEmacPs_Stop(XEmacPs *InstancePtr)
|
||||
{
|
||||
u32 Reg;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == (u32)XIL_COMPONENT_IS_READY);
|
||||
|
||||
/* Disable all interrupts */
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress, XEMACPS_IDR_OFFSET,
|
||||
XEMACPS_IXR_ALL_MASK);
|
||||
|
||||
/* Disable the receiver & transmitter */
|
||||
Reg = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET);
|
||||
Reg &= (u32)(~XEMACPS_NWCTRL_RXEN_MASK);
|
||||
Reg &= (u32)(~XEMACPS_NWCTRL_TXEN_MASK);
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET, Reg);
|
||||
|
||||
/* Mark as stopped */
|
||||
InstancePtr->IsStarted = 0U;
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockDisable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Perform a graceful reset of the Ethernet MAC. Resets the DMA channels, the
|
||||
* transmitter, and the receiver.
|
||||
*
|
||||
* Steps to reset
|
||||
* - Stops transmit and receive channels
|
||||
* - Stops DMA
|
||||
* - Configure transmit and receive buffer size to default
|
||||
* - Clear transmit and receive status register and counters
|
||||
* - Clear all interrupt sources
|
||||
* - Clear phy (if there is any previously detected) address
|
||||
* - Clear MAC addresses (1-4) as well as Type IDs and hash value
|
||||
*
|
||||
* All options are placed in their default state. Any frames in the
|
||||
* descriptor lists will remain in the lists. The side effect of doing
|
||||
* this is that after a reset and following a restart of the device, frames
|
||||
* were in the list before the reset may be transmitted or received.
|
||||
*
|
||||
* The upper layer software is responsible for re-configuring (if necessary)
|
||||
* and restarting the MAC after the reset. Note also that driver statistics
|
||||
* are not cleared on reset. It is up to the upper layer software to clear the
|
||||
* statistics if needed.
|
||||
*
|
||||
* When a reset is required, the driver notifies the upper layer software of
|
||||
* this need through the ErrorHandler callback and specific status codes.
|
||||
* The upper layer software is responsible for calling this Reset function
|
||||
* and then re-configuring the device.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XEmacPs_Reset(XEmacPs *InstancePtr)
|
||||
{
|
||||
u32 Reg;
|
||||
u8 i;
|
||||
s8 EmacPs_zero_MAC[6] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == (u32)XIL_COMPONENT_IS_READY);
|
||||
|
||||
/* Stop the device and reset hardware */
|
||||
XEmacPs_Stop(InstancePtr);
|
||||
InstancePtr->Options = XEMACPS_DEFAULT_OPTIONS;
|
||||
|
||||
InstancePtr->Version = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress, 0xFC);
|
||||
|
||||
InstancePtr->Version = (InstancePtr->Version >> 16) & 0xFFF;
|
||||
|
||||
InstancePtr->MaxMtuSize = XEMACPS_MTU;
|
||||
InstancePtr->MaxFrameSize = XEMACPS_MTU + XEMACPS_HDR_SIZE +
|
||||
XEMACPS_TRL_SIZE;
|
||||
InstancePtr->MaxVlanFrameSize = InstancePtr->MaxFrameSize +
|
||||
XEMACPS_HDR_VLAN_SIZE;
|
||||
InstancePtr->RxBufMask = XEMACPS_RXBUF_LEN_MASK;
|
||||
|
||||
/* Setup hardware with default values */
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET,
|
||||
(XEMACPS_NWCTRL_STATCLR_MASK |
|
||||
XEMACPS_NWCTRL_MDEN_MASK) &
|
||||
(u32)(~XEMACPS_NWCTRL_LOOPEN_MASK));
|
||||
|
||||
Reg = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCFG_OFFSET);
|
||||
Reg &= XEMACPS_NWCFG_MDCCLKDIV_MASK;
|
||||
|
||||
Reg = Reg | (u32)XEMACPS_NWCFG_100_MASK |
|
||||
(u32)XEMACPS_NWCFG_FDEN_MASK |
|
||||
(u32)XEMACPS_NWCFG_UCASTHASHEN_MASK;
|
||||
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCFG_OFFSET, Reg);
|
||||
if (InstancePtr->Version > 2) {
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress, XEMACPS_NWCFG_OFFSET,
|
||||
(XEmacPs_ReadReg(InstancePtr->Config.BaseAddress, XEMACPS_NWCFG_OFFSET) |
|
||||
XEMACPS_NWCFG_DWIDTH_64_MASK));
|
||||
}
|
||||
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_DMACR_OFFSET,
|
||||
(((((u32)XEMACPS_RX_BUF_SIZE / (u32)XEMACPS_RX_BUF_UNIT) +
|
||||
(((((u32)XEMACPS_RX_BUF_SIZE %
|
||||
(u32)XEMACPS_RX_BUF_UNIT))!=(u32)0) ? 1U : 0U)) <<
|
||||
(u32)(XEMACPS_DMACR_RXBUF_SHIFT)) &
|
||||
(u32)(XEMACPS_DMACR_RXBUF_MASK)) |
|
||||
(u32)XEMACPS_DMACR_RXSIZE_MASK |
|
||||
(u32)XEMACPS_DMACR_TXSIZE_MASK);
|
||||
|
||||
|
||||
if (InstancePtr->Version > 2) {
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress, XEMACPS_DMACR_OFFSET,
|
||||
(XEmacPs_ReadReg(InstancePtr->Config.BaseAddress, XEMACPS_DMACR_OFFSET) |
|
||||
#if defined(__aarch64__) || defined(__arch64__)
|
||||
(u32)XEMACPS_DMACR_ADDR_WIDTH_64 |
|
||||
#endif
|
||||
(u32)XEMACPS_DMACR_INCR16_AHB_BURST));
|
||||
}
|
||||
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_TXSR_OFFSET, XEMACPS_SR_ALL_MASK);
|
||||
|
||||
XEmacPs_SetQueuePtr(InstancePtr, 0, 0x00U, (u16)XEMACPS_SEND);
|
||||
if (InstancePtr->Version > 2)
|
||||
XEmacPs_SetQueuePtr(InstancePtr, 0, 0x01U, (u16)XEMACPS_SEND);
|
||||
XEmacPs_SetQueuePtr(InstancePtr, 0, 0x00U, (u16)XEMACPS_RECV);
|
||||
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_RXSR_OFFSET, XEMACPS_SR_ALL_MASK);
|
||||
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress, XEMACPS_IDR_OFFSET,
|
||||
XEMACPS_IXR_ALL_MASK);
|
||||
|
||||
Reg = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_ISR_OFFSET);
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress, XEMACPS_ISR_OFFSET,
|
||||
Reg);
|
||||
|
||||
XEmacPs_ClearHash(InstancePtr);
|
||||
|
||||
for (i = 1U; i < 5U; i++) {
|
||||
(void)XEmacPs_SetMacAddress(InstancePtr, EmacPs_zero_MAC, i);
|
||||
(void)XEmacPs_SetTypeIdCheck(InstancePtr, 0x00000000U, i);
|
||||
}
|
||||
|
||||
/* clear all counters */
|
||||
for (i = 0U; i < (u8)((XEMACPS_LAST_OFFSET - XEMACPS_OCTTXL_OFFSET) / 4U);
|
||||
i++) {
|
||||
(void)XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_OCTTXL_OFFSET + (u32)(((u32)i) * ((u32)4)));
|
||||
}
|
||||
|
||||
/* Disable the receiver */
|
||||
Reg = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET);
|
||||
Reg &= (u32)(~XEMACPS_NWCTRL_RXEN_MASK);
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET, Reg);
|
||||
|
||||
/* Sync default options with hardware but leave receiver and
|
||||
* transmitter disabled. They get enabled with XEmacPs_Start() if
|
||||
* XEMACPS_TRANSMITTER_ENABLE_OPTION and
|
||||
* XEMACPS_RECEIVER_ENABLE_OPTION are set.
|
||||
*/
|
||||
(void)XEmacPs_SetOptions(InstancePtr, InstancePtr->Options &
|
||||
~((u32)XEMACPS_TRANSMITTER_ENABLE_OPTION |
|
||||
(u32)XEMACPS_RECEIVER_ENABLE_OPTION));
|
||||
|
||||
(void)XEmacPs_ClearOptions(InstancePtr, ~InstancePtr->Options);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* This is a stub for the asynchronous callbacks. The stub is here in case the
|
||||
* upper layer forgot to set the handler(s). On initialization, all handlers are
|
||||
* set to this callback. It is considered an error for this handler to be
|
||||
* invoked.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XEmacPs_StubHandler(void)
|
||||
{
|
||||
Xil_AssertVoidAlways();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function sets the start address of the transmit/receive buffer queue.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param QPtr is the address of the Queue to be written
|
||||
* @param QueueNum is the Buffer Queue Index
|
||||
* @param Direction indicates Transmit/Receive
|
||||
*
|
||||
* @note
|
||||
* The buffer queue addresses has to be set before starting the transfer, so
|
||||
* this function has to be called in prior to XEmacPs_Start()
|
||||
*
|
||||
******************************************************************************/
|
||||
void XEmacPs_SetQueuePtr(XEmacPs *InstancePtr, UINTPTR QPtr, u8 QueueNum,
|
||||
u16 Direction)
|
||||
{
|
||||
/* Assert bad arguments and conditions */
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == (u32)XIL_COMPONENT_IS_READY);
|
||||
|
||||
/* If already started, then there is nothing to do */
|
||||
if (InstancePtr->IsStarted == (u32)XIL_COMPONENT_IS_STARTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (QueueNum == 0x00U) {
|
||||
if (Direction == XEMACPS_SEND) {
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_TXQBASE_OFFSET,
|
||||
(QPtr & ULONG64_LO_MASK));
|
||||
} else {
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_RXQBASE_OFFSET,
|
||||
(QPtr & ULONG64_LO_MASK));
|
||||
}
|
||||
}
|
||||
else {
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_TXQ1BASE_OFFSET,
|
||||
(QPtr & ULONG64_LO_MASK));
|
||||
}
|
||||
#ifdef __aarch64__
|
||||
if (Direction == XEMACPS_SEND) {
|
||||
/* Set the MSB of TX Queue start address */
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_MSBBUF_TXQBASE_OFFSET,
|
||||
(u32)((QPtr & ULONG64_HI_MASK) >> 32U));
|
||||
} else {
|
||||
/* Set the MSB of RX Queue start address */
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_MSBBUF_RXQBASE_OFFSET,
|
||||
(u32)((QPtr & ULONG64_HI_MASK) >> 32U));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/** @} */
|
843
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.h
Normal file
843
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.h
Normal file
@ -0,0 +1,843 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xemacps.h
|
||||
* @addtogroup emacps_v3_16
|
||||
* @{
|
||||
* @details
|
||||
*
|
||||
* The Xilinx Embedded Processor Block Ethernet driver.
|
||||
*
|
||||
* For a full description of XEMACPS features, please see the hardware spec.
|
||||
* This driver supports the following features:
|
||||
* - Memory mapped access to host interface registers
|
||||
* - Statistics counter registers for RMON/MIB
|
||||
* - API for interrupt driven frame transfers for hardware configured DMA
|
||||
* - Virtual memory support
|
||||
* - Unicast, broadcast, and multicast receive address filtering
|
||||
* - Full and half duplex operation
|
||||
* - Automatic PAD & FCS insertion and stripping
|
||||
* - Flow control
|
||||
* - Support up to four 48bit addresses
|
||||
* - Address checking for four specific 48bit addresses
|
||||
* - VLAN frame support
|
||||
* - Pause frame support
|
||||
* - Large frame support up to 1536 bytes
|
||||
* - Checksum offload
|
||||
*
|
||||
* <b>Driver Description</b>
|
||||
*
|
||||
* The device driver enables higher layer software (e.g., an application) to
|
||||
* communicate to the XEmacPs. The driver handles transmission and reception
|
||||
* of Ethernet frames, as well as configuration and control. No pre or post
|
||||
* processing of frame data is performed. The driver does not validate the
|
||||
* contents of an incoming frame in addition to what has already occurred in
|
||||
* hardware.
|
||||
* A single device driver can support multiple devices even when those devices
|
||||
* have significantly different configurations.
|
||||
*
|
||||
* <b>Initialization & Configuration</b>
|
||||
*
|
||||
* The XEmacPs_Config structure is used by the driver to configure itself.
|
||||
* This configuration structure is typically created by the tool-chain based
|
||||
* on hardware build properties.
|
||||
*
|
||||
* The driver instance can be initialized in
|
||||
*
|
||||
* - XEmacPs_CfgInitialize(InstancePtr, CfgPtr, EffectiveAddress): Uses a
|
||||
* configuration structure provided by the caller. If running in a system
|
||||
* with address translation, the provided virtual memory base address
|
||||
* replaces the physical address present in the configuration structure.
|
||||
*
|
||||
* The device supports DMA only as current development plan. No FIFO mode is
|
||||
* supported. The driver expects to start the DMA channels and expects that
|
||||
* the user has set up the buffer descriptor lists.
|
||||
*
|
||||
* <b>Interrupts and Asynchronous Callbacks</b>
|
||||
*
|
||||
* The driver has no dependencies on the interrupt controller. When an
|
||||
* interrupt occurs, the handler will perform a small amount of
|
||||
* housekeeping work, determine the source of the interrupt, and call the
|
||||
* appropriate callback function. All callbacks are registered by the user
|
||||
* level application.
|
||||
*
|
||||
* <b>Virtual Memory</b>
|
||||
*
|
||||
* All virtual to physical memory mappings must occur prior to accessing the
|
||||
* driver API.
|
||||
*
|
||||
* For DMA transactions, user buffers supplied to the driver must be in terms
|
||||
* of their physical address.
|
||||
*
|
||||
* <b>DMA</b>
|
||||
*
|
||||
* The DMA engine uses buffer descriptors (BDs) to describe Ethernet frames.
|
||||
* These BDs are typically chained together into a list the hardware follows
|
||||
* when transferring data in and out of the packet buffers. Each BD describes
|
||||
* a memory region containing either a full or partial Ethernet packet.
|
||||
*
|
||||
* Interrupt coalescing is not supported from this built-in DMA engine.
|
||||
*
|
||||
* This API requires the user to understand how the DMA operates. The
|
||||
* following paragraphs provide some explanation, but the user is encouraged
|
||||
* to read documentation in xemacps_bdring.h as well as study example code
|
||||
* that accompanies this driver.
|
||||
*
|
||||
* The API is designed to get BDs to and from the DMA engine in the most
|
||||
* efficient means possible. The first step is to establish a memory region
|
||||
* to contain all BDs for a specific channel. This is done with
|
||||
* XEmacPs_BdRingCreate(). This function sets up a BD ring that hardware will
|
||||
* follow as BDs are processed. The ring will consist of a user defined number
|
||||
* of BDs which will all be partially initialized. For example on the transmit
|
||||
* channel, the driver will initialize all BDs' so that they are configured
|
||||
* for transmit. The more fields that can be permanently setup at
|
||||
* initialization, then the fewer accesses will be needed to each BD while
|
||||
* the DMA engine is in operation resulting in better throughput and CPU
|
||||
* utilization. The best case initialization would require the user to set
|
||||
* only a frame buffer address and length prior to submitting the BD to the
|
||||
* engine.
|
||||
*
|
||||
* BDs move through the engine with the help of functions
|
||||
* XEmacPs_BdRingAlloc(), XEmacPs_BdRingToHw(), XEmacPs_BdRingFromHw(),
|
||||
* and XEmacPs_BdRingFree().
|
||||
* All these functions handle BDs that are in place. That is, there are no
|
||||
* copies of BDs kept anywhere and any BD the user interacts with is an actual
|
||||
* BD from the same ring hardware accesses.
|
||||
*
|
||||
* BDs in the ring go through a series of states as follows:
|
||||
* 1. Idle. The driver controls BDs in this state.
|
||||
* 2. The user has data to transfer. XEmacPs_BdRingAlloc() is called to
|
||||
* reserve BD(s). Once allocated, the user may setup the BD(s) with
|
||||
* frame buffer address, length, and other attributes. The user controls
|
||||
* BDs in this state.
|
||||
* 3. The user submits BDs to the DMA engine with XEmacPs_BdRingToHw. BDs
|
||||
* in this state are either waiting to be processed by hardware, are in
|
||||
* process, or have been processed. The DMA engine controls BDs in this
|
||||
* state.
|
||||
* 4. Processed BDs are retrieved with XEmacEpv_BdRingFromHw() by the
|
||||
* user. Once retrieved, the user can examine each BD for the outcome of
|
||||
* the DMA transfer. The user controls BDs in this state. After examining
|
||||
* the BDs the user calls XEmacPs_BdRingFree() which places the BDs back
|
||||
* into state 1.
|
||||
*
|
||||
* Each of the four BD accessor functions operate on a set of BDs. A set is
|
||||
* defined as a segment of the BD ring consisting of one or more BDs. The user
|
||||
* views the set as a pointer to the first BD along with the number of BDs for
|
||||
* that set. The set can be navigated by using macros XEmacPs_BdNext(). The
|
||||
* user must exercise extreme caution when changing BDs in a set as there is
|
||||
* nothing to prevent doing a mBdNext past the end of the set and modifying a
|
||||
* BD out of bounds.
|
||||
*
|
||||
* XEmacPs_BdRingAlloc() + XEmacPs_BdRingToHw(), as well as
|
||||
* XEmacPs_BdRingFromHw() + XEmacPs_BdRingFree() are designed to be used in
|
||||
* tandem. The same BD set retrieved with BdRingAlloc should be the same one
|
||||
* provided to hardware with BdRingToHw. Same goes with BdRingFromHw and
|
||||
* BdRIngFree.
|
||||
*
|
||||
* <b>Alignment & Data Cache Restrictions</b>
|
||||
*
|
||||
* Due to the design of the hardware, all RX buffers, BDs need to be 4-byte
|
||||
* aligned. Please reference xemacps_bd.h for cache related macros.
|
||||
*
|
||||
* DMA Tx:
|
||||
*
|
||||
* - If frame buffers exist in cached memory, then they must be flushed
|
||||
* prior to committing them to hardware.
|
||||
*
|
||||
* DMA Rx:
|
||||
*
|
||||
* - If frame buffers exist in cached memory, then the cache must be
|
||||
* invalidated for the memory region containing the frame prior to data
|
||||
* access
|
||||
*
|
||||
* Both cache invalidate/flush are taken care of in driver code.
|
||||
*
|
||||
* <b>Buffer Copying</b>
|
||||
*
|
||||
* The driver is designed for a zero-copy buffer scheme. That is, the driver
|
||||
* will not copy buffers. This avoids potential throughput bottlenecks within
|
||||
* the driver. If byte copying is required, then the transfer will take longer
|
||||
* to complete.
|
||||
*
|
||||
* <b>Checksum Offloading</b>
|
||||
*
|
||||
* The Embedded Processor Block Ethernet can be configured to perform IP, TCP
|
||||
* and UDP checksum offloading in both receive and transmit directions.
|
||||
*
|
||||
* IP packets contain a 16-bit checksum field, which is the 16-bit 1s
|
||||
* complement of the 1s complement sum of all 16-bit words in the header.
|
||||
* TCP and UDP packets contain a 16-bit checksum field, which is the 16-bit
|
||||
* 1s complement of the 1s complement sum of all 16-bit words in the header,
|
||||
* the data and a conceptual pseudo header.
|
||||
*
|
||||
* To calculate these checksums in software requires each byte of the packet
|
||||
* to be read. For TCP and UDP this can use a large amount of processing power.
|
||||
* Offloading the checksum calculation to hardware can result in significant
|
||||
* performance improvements.
|
||||
*
|
||||
* The transmit checksum offload is only available to use DMA in packet buffer
|
||||
* mode. This is because the complete frame to be transmitted must be read
|
||||
* into the packet buffer memory before the checksum can be calculated and
|
||||
* written to the header at the beginning of the frame.
|
||||
*
|
||||
* For IP, TCP or UDP receive checksum offload to be useful, the operating
|
||||
* system containing the protocol stack must be aware that this offload is
|
||||
* available so that it can make use of the fact that the hardware has verified
|
||||
* the checksum.
|
||||
*
|
||||
* When receive checksum offloading is enabled in the hardware, the IP header
|
||||
* checksum is checked, where the packet meets the following criteria:
|
||||
*
|
||||
* 1. If present, the VLAN header must be four octets long and the CFI bit
|
||||
* must not be set.
|
||||
* 2. Encapsulation must be RFC 894 Ethernet Type Encoding or RFC 1042 SNAP
|
||||
* encoding.
|
||||
* 3. IP v4 packet.
|
||||
* 4. IP header is of a valid length.
|
||||
* 5. Good IP header checksum.
|
||||
* 6. No IP fragmentation.
|
||||
* 7. TCP or UDP packet.
|
||||
*
|
||||
* When an IP, TCP or UDP frame is received, the receive buffer descriptor
|
||||
* gives an indication if the hardware was able to verify the checksums.
|
||||
* There is also an indication if the frame had SNAP encapsulation. These
|
||||
* indication bits will replace the type ID match indication bits when the
|
||||
* receive checksum offload is enabled.
|
||||
*
|
||||
* If any of the checksums are verified incorrect by the hardware, the packet
|
||||
* is discarded and the appropriate statistics counter incremented.
|
||||
*
|
||||
* <b>PHY Interfaces</b>
|
||||
*
|
||||
* RGMII 1.3 is the only interface supported.
|
||||
*
|
||||
* <b>Asserts</b>
|
||||
*
|
||||
* Asserts are used within all Xilinx drivers to enforce constraints on
|
||||
* parameters. Asserts can be turned off on a system-wide basis by defining,
|
||||
* at compile time, the NDEBUG identifier. By default, asserts are turned on
|
||||
* and it is recommended that users leave asserts on during development. For
|
||||
* deployment use -DNDEBUG compiler switch to remove assert code.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* Xilinx drivers are typically composed of two parts, one is the driver
|
||||
* and the other is the adapter. The driver is independent of OS and processor
|
||||
* and is intended to be highly portable. The adapter is OS-specific and
|
||||
* facilitates communication between the driver and an OS.
|
||||
* This driver is intended to be RTOS and processor independent. Any needs for
|
||||
* dynamic memory management, threads or thread mutual exclusion, or cache
|
||||
* control must be satisfied bythe layer above this driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.00a wsy 01/10/10 First release
|
||||
* 1.00a asa 11/21/11 The function XEmacPs_BdRingFromHwTx in file
|
||||
* xemacps_bdring.c is modified. Earlier it was checking for
|
||||
* "BdLimit"(passed argument) number of BDs for finding out
|
||||
* which BDs are successfully processed. Now one more check
|
||||
* is added. It looks for BDs till the current BD pointer
|
||||
* reaches HwTail. By doing this processing time is saved.
|
||||
* 1.00a asa 01/24/12 The function XEmacPs_BdRingFromHwTx in file
|
||||
* xemacps_bdring.c is modified. Now start of packet is
|
||||
* searched for returning the number of BDs processed.
|
||||
* 1.02a asa 11/05/12 Added a new API for deleting an entry from the HASH
|
||||
* registers. Added a new API to set the bust length.
|
||||
* Added some new hash-defines.
|
||||
* 1.03a asa 01/23/12 Fix for CR #692702 which updates error handling for
|
||||
* Rx errors. Under heavy Rx traffic, there will be a large
|
||||
* number of errors related to receive buffer not available.
|
||||
* Because of a HW bug (SI #692601), under such heavy errors,
|
||||
* the Rx data path can become unresponsive. To reduce the
|
||||
* probabilities for hitting this HW bug, the SW writes to
|
||||
* bit 18 to flush a packet from Rx DPRAM immediately. The
|
||||
* changes for it are done in the function
|
||||
* XEmacPs_IntrHandler.
|
||||
* 1.05a asa 09/23/13 Cache operations on BDs are not required and hence
|
||||
* removed. It is expected that all BDs are allocated in
|
||||
* from uncached area.
|
||||
* 1.06a asa 11/02/13 Changed the value for XEMACPS_RXBUF_LEN_MASK from 0x3fff
|
||||
* to 0x1fff. This fixes the CR#744902.
|
||||
* Made changes in example file xemacps_example.h to fix compilation
|
||||
* issues with iarcc compiler.
|
||||
* 2.0 adk 10/12/13 Updated as per the New Tcl API's
|
||||
* 2.1 adk 11/08/14 Fixed the CR#811288. Changes are made in the driver tcl file.
|
||||
* 2.1 bss 09/08/14 Modified driver tcl to fix CR#820349 to export phy
|
||||
* address in xparameters.h when GMII to RGMII converter
|
||||
* is present in hw.
|
||||
* 2.1 srt 07/15/14 Add support for Zynq Ultrascale Mp GEM specification and 64-bit
|
||||
* changes.
|
||||
* 2.2 adk 29/10/14 Fixed CR#827686 when PCS/PMA core is configured with
|
||||
* 1000BASE-X mode export proper values to the xparameters.h
|
||||
* file. Changes are made in the driver tcl file.
|
||||
* 3.0 adk 08/1/15 Don't include gem in peripheral test when gem is
|
||||
* configured with PCS/PMA Core. Changes are made in the
|
||||
* test app tcl(CR:827686).
|
||||
* 3.0 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.0 hk 03/18/15 Added support for jumbo frames. Increase AHB burst.
|
||||
* Disable extended mode. Perform all 64 bit changes under
|
||||
* check for arch64.
|
||||
* Remove "used bit set" from TX error interrupt masks.
|
||||
* 3.1 hk 07/27/15 Do not call error handler with '0' error code when
|
||||
* there is no error. CR# 869403
|
||||
* 08/10/15 Update upper 32 bit tx and rx queue ptr registers.
|
||||
* 3.2 hk 02/22/16 Added SGMII support for Zynq Ultrascale+ MPSoC.
|
||||
* 3.4 ms 01/23/17 Modified xil_printf statement in main function for all
|
||||
* examples to ensure that "Successfully ran" and "Failed"
|
||||
* strings are available in all examples. This is a fix
|
||||
* for CR-965028.
|
||||
* ms 03/17/17 Modified text file in examples folder for doxygen
|
||||
* generation.
|
||||
* ms 04/05/17 Added tabspace for return statements in functions of
|
||||
* xemacps_ieee1588_example.c for proper documentation
|
||||
* while generating doxygen.
|
||||
* 3.5 hk 08/14/17 Update cache coherency information of the interface in
|
||||
* its config structure.
|
||||
* 3.6 rb 09/08/17 HwCnt variable (in XEmacPs_BdRing structure) is
|
||||
* changed to volatile.
|
||||
* Add API XEmacPs_BdRingPtrReset() to reset pointers
|
||||
* 3.8 hk 07/19/18 Fixed CPP, GCC and doxygen warnings - CR-1006327
|
||||
* hk 09/17/18 Fix PTP interrupt masks and cleanup comments.
|
||||
* 3.9 hk 01/23/19 Add RX watermark support
|
||||
* 3.11 sd 02/14/20 Add clock support
|
||||
* 3.13 nsk 12/14/20 Updated the tcl to not to use the instance names.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef XEMACPS_H /* prevent circular inclusions */
|
||||
#define XEMACPS_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xstatus.h"
|
||||
#include "xemacps_hw.h"
|
||||
#include "xemacps_bd.h"
|
||||
#include "xemacps_bdring.h"
|
||||
#if defined (XCLOCKING)
|
||||
#include "xil_clocking.h"
|
||||
#endif
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
/*
|
||||
* Device information
|
||||
*/
|
||||
#define XEMACPS_DEVICE_NAME "xemacps"
|
||||
#define XEMACPS_DEVICE_DESC "Xilinx PS 10/100/1000 MAC"
|
||||
|
||||
|
||||
/** @name Configuration options
|
||||
*
|
||||
* Device configuration options. See the XEmacPs_SetOptions(),
|
||||
* XEmacPs_ClearOptions() and XEmacPs_GetOptions() for information on how to
|
||||
* use options.
|
||||
*
|
||||
* The default state of the options are noted and are what the device and
|
||||
* driver will be set to after calling XEmacPs_Reset() or
|
||||
* XEmacPs_Initialize().
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XEMACPS_PROMISC_OPTION 0x00000001U
|
||||
/**< Accept all incoming packets.
|
||||
* This option defaults to disabled (cleared) */
|
||||
|
||||
#define XEMACPS_FRAME1536_OPTION 0x00000002U
|
||||
/**< Frame larger than 1516 support for Tx & Rx.
|
||||
* This option defaults to disabled (cleared) */
|
||||
|
||||
#define XEMACPS_VLAN_OPTION 0x00000004U
|
||||
/**< VLAN Rx & Tx frame support.
|
||||
* This option defaults to disabled (cleared) */
|
||||
|
||||
#define XEMACPS_FLOW_CONTROL_OPTION 0x00000010U
|
||||
/**< Enable recognition of flow control frames on Rx
|
||||
* This option defaults to enabled (set) */
|
||||
|
||||
#define XEMACPS_FCS_STRIP_OPTION 0x00000020U
|
||||
/**< Strip FCS and PAD from incoming frames. Note: PAD from VLAN frames is not
|
||||
* stripped.
|
||||
* This option defaults to enabled (set) */
|
||||
|
||||
#define XEMACPS_FCS_INSERT_OPTION 0x00000040U
|
||||
/**< Generate FCS field and add PAD automatically for outgoing frames.
|
||||
* This option defaults to disabled (cleared) */
|
||||
|
||||
#define XEMACPS_LENTYPE_ERR_OPTION 0x00000080U
|
||||
/**< Enable Length/Type error checking for incoming frames. When this option is
|
||||
* set, the MAC will filter frames that have a mismatched type/length field
|
||||
* and if XEMACPS_REPORT_RXERR_OPTION is set, the user is notified when these
|
||||
* types of frames are encountered. When this option is cleared, the MAC will
|
||||
* allow these types of frames to be received.
|
||||
*
|
||||
* This option defaults to disabled (cleared) */
|
||||
|
||||
#define XEMACPS_TRANSMITTER_ENABLE_OPTION 0x00000100U
|
||||
/**< Enable the transmitter.
|
||||
* This option defaults to enabled (set) */
|
||||
|
||||
#define XEMACPS_RECEIVER_ENABLE_OPTION 0x00000200U
|
||||
/**< Enable the receiver
|
||||
* This option defaults to enabled (set) */
|
||||
|
||||
#define XEMACPS_BROADCAST_OPTION 0x00000400U
|
||||
/**< Allow reception of the broadcast address
|
||||
* This option defaults to enabled (set) */
|
||||
|
||||
#define XEMACPS_MULTICAST_OPTION 0x00000800U
|
||||
/**< Allows reception of multicast addresses programmed into hash
|
||||
* This option defaults to disabled (clear) */
|
||||
|
||||
#define XEMACPS_RX_CHKSUM_ENABLE_OPTION 0x00001000U
|
||||
/**< Enable the RX checksum offload
|
||||
* This option defaults to enabled (set) */
|
||||
|
||||
#define XEMACPS_TX_CHKSUM_ENABLE_OPTION 0x00002000U
|
||||
/**< Enable the TX checksum offload
|
||||
* This option defaults to enabled (set) */
|
||||
|
||||
#define XEMACPS_JUMBO_ENABLE_OPTION 0x00004000U
|
||||
#define XEMACPS_SGMII_ENABLE_OPTION 0x00008000U
|
||||
|
||||
#define XEMACPS_DEFAULT_OPTIONS \
|
||||
((u32)XEMACPS_FLOW_CONTROL_OPTION | \
|
||||
(u32)XEMACPS_FCS_INSERT_OPTION | \
|
||||
(u32)XEMACPS_FCS_STRIP_OPTION | \
|
||||
(u32)XEMACPS_BROADCAST_OPTION | \
|
||||
(u32)XEMACPS_LENTYPE_ERR_OPTION | \
|
||||
(u32)XEMACPS_TRANSMITTER_ENABLE_OPTION | \
|
||||
(u32)XEMACPS_RECEIVER_ENABLE_OPTION | \
|
||||
(u32)XEMACPS_RX_CHKSUM_ENABLE_OPTION | \
|
||||
(u32)XEMACPS_TX_CHKSUM_ENABLE_OPTION)
|
||||
|
||||
/**< Default options set when device is initialized or reset */
|
||||
/*@}*/
|
||||
|
||||
/** @name Callback identifiers
|
||||
*
|
||||
* These constants are used as parameters to XEmacPs_SetHandler()
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_HANDLER_DMASEND 1U
|
||||
#define XEMACPS_HANDLER_DMARECV 2U
|
||||
#define XEMACPS_HANDLER_ERROR 3U
|
||||
/*@}*/
|
||||
|
||||
/* Constants to determine the configuration of the hardware device. They are
|
||||
* used to allow the driver to verify it can operate with the hardware.
|
||||
*/
|
||||
#define XEMACPS_MDIO_DIV_DFT MDC_DIV_32 /**< Default MDIO clock divisor */
|
||||
|
||||
/* The next few constants help upper layers determine the size of memory
|
||||
* pools used for Ethernet buffers and descriptor lists.
|
||||
*/
|
||||
#define XEMACPS_MAC_ADDR_SIZE 6U /* size of Ethernet header */
|
||||
|
||||
#define XEMACPS_MTU 1500U /* max MTU size of Ethernet frame */
|
||||
#define XEMACPS_MTU_JUMBO 10240U /* max MTU size of jumbo frame */
|
||||
#define XEMACPS_HDR_SIZE 14U /* size of Ethernet header */
|
||||
#define XEMACPS_HDR_VLAN_SIZE 18U /* size of Ethernet header with VLAN */
|
||||
#define XEMACPS_TRL_SIZE 4U /* size of Ethernet trailer (FCS) */
|
||||
#define XEMACPS_MAX_FRAME_SIZE (XEMACPS_MTU + XEMACPS_HDR_SIZE + \
|
||||
XEMACPS_TRL_SIZE)
|
||||
#define XEMACPS_MAX_VLAN_FRAME_SIZE (XEMACPS_MTU + XEMACPS_HDR_SIZE + \
|
||||
XEMACPS_HDR_VLAN_SIZE + XEMACPS_TRL_SIZE)
|
||||
#define XEMACPS_MAX_VLAN_FRAME_SIZE_JUMBO (XEMACPS_MTU_JUMBO + XEMACPS_HDR_SIZE + \
|
||||
XEMACPS_HDR_VLAN_SIZE + XEMACPS_TRL_SIZE)
|
||||
|
||||
/* DMACR Bust length hash defines */
|
||||
|
||||
#define XEMACPS_SINGLE_BURST 0x00000001
|
||||
#define XEMACPS_4BYTE_BURST 0x00000004
|
||||
#define XEMACPS_8BYTE_BURST 0x00000008
|
||||
#define XEMACPS_16BYTE_BURST 0x00000010
|
||||
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
/** @name Typedefs for callback functions
|
||||
*
|
||||
* These callbacks are invoked in interrupt context.
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Callback invoked when frame(s) have been sent or received in interrupt
|
||||
* driven DMA mode. To set the send callback, invoke XEmacPs_SetHandler().
|
||||
*
|
||||
* @param CallBackRef is user data assigned when the callback was set.
|
||||
*
|
||||
* @note
|
||||
* See xemacps_hw.h for bitmasks definitions and the device hardware spec for
|
||||
* further information on their meaning.
|
||||
*
|
||||
*/
|
||||
typedef void (*XEmacPs_Handler) (void *CallBackRef);
|
||||
|
||||
/**
|
||||
* Callback when an asynchronous error occurs. To set this callback, invoke
|
||||
* XEmacPs_SetHandler() with XEMACPS_HANDLER_ERROR in the HandlerType
|
||||
* parameter.
|
||||
*
|
||||
* @param CallBackRef is user data assigned when the callback was set.
|
||||
* @param Direction defines either receive or transmit error(s) has occurred.
|
||||
* @param ErrorWord definition varies with Direction
|
||||
*
|
||||
*/
|
||||
typedef void (*XEmacPs_ErrHandler) (void *CallBackRef, u8 Direction,
|
||||
u32 ErrorWord);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for a device.
|
||||
*/
|
||||
typedef struct {
|
||||
u16 DeviceId; /**< Unique ID of device */
|
||||
UINTPTR BaseAddress;/**< Physical base address of IPIF registers */
|
||||
u8 IsCacheCoherent; /**< Applicable only to A53 in EL1 mode;
|
||||
* describes whether Cache Coherent or not */
|
||||
#if defined (XCLOCKING)
|
||||
u32 RefClk; /**< Input clock */
|
||||
#endif
|
||||
u16 S1GDiv0; /**< 1Gbps Clock Divider 0 */
|
||||
u8 S1GDiv1; /**< 1Gbps Clock Divider 1 */
|
||||
u16 S100MDiv0; /**< 100Mbps Clock Divider 0 */
|
||||
u8 S100MDiv1; /**< 100Mbps Clock Divider 1 */
|
||||
u16 S10MDiv0; /**< 10Mbps Clock Divider 0 */
|
||||
u8 S10MDiv1; /**< 10Mbps Clock Divider 1 */
|
||||
} XEmacPs_Config;
|
||||
|
||||
|
||||
/**
|
||||
* The XEmacPs driver instance data. The user is required to allocate a
|
||||
* structure of this type for every XEmacPs device in the system. A pointer
|
||||
* to a structure of this type is then passed to the driver API functions.
|
||||
*/
|
||||
typedef struct XEmacPs_Instance {
|
||||
XEmacPs_Config Config; /* Hardware configuration */
|
||||
u32 IsStarted; /* Device is currently started */
|
||||
u32 IsReady; /* Device is initialized and ready */
|
||||
u32 Options; /* Current options word */
|
||||
|
||||
XEmacPs_BdRing TxBdRing; /* Transmit BD ring */
|
||||
XEmacPs_BdRing RxBdRing; /* Receive BD ring */
|
||||
|
||||
XEmacPs_Handler SendHandler;
|
||||
XEmacPs_Handler RecvHandler;
|
||||
void *SendRef;
|
||||
void *RecvRef;
|
||||
|
||||
XEmacPs_ErrHandler ErrorHandler;
|
||||
void *ErrorRef;
|
||||
u32 Version;
|
||||
u32 RxBufMask;
|
||||
u32 MaxMtuSize;
|
||||
u32 MaxFrameSize;
|
||||
u32 MaxVlanFrameSize;
|
||||
|
||||
} XEmacPs;
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* Retrieve the Tx ring object. This object can be used in the various Ring
|
||||
* API functions.
|
||||
*
|
||||
* @param InstancePtr is the DMA channel to operate on.
|
||||
*
|
||||
* @return TxBdRing attribute
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* XEmacPs_BdRing XEmacPs_GetTxRing(XEmacPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_GetTxRing(InstancePtr) ((InstancePtr)->TxBdRing)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* Retrieve the Rx ring object. This object can be used in the various Ring
|
||||
* API functions.
|
||||
*
|
||||
* @param InstancePtr is the DMA channel to operate on.
|
||||
*
|
||||
* @return RxBdRing attribute
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* XEmacPs_BdRing XEmacPs_GetRxRing(XEmacPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_GetRxRing(InstancePtr) ((InstancePtr)->RxBdRing)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Enable interrupts specified in <i>Mask</i>. The corresponding interrupt for
|
||||
* each bit set to 1 in <i>Mask</i>, will be enabled.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param Mask contains a bit mask of interrupts to enable. The mask can
|
||||
* be formed using a set of bitwise or'd values.
|
||||
*
|
||||
* @note
|
||||
* The state of the transmitter and receiver are not modified by this function.
|
||||
* C-style signature
|
||||
* void XEmacPs_IntEnable(XEmacPs *InstancePtr, u32 Mask)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_IntEnable(InstancePtr, Mask) \
|
||||
XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
XEMACPS_IER_OFFSET, \
|
||||
((Mask) & XEMACPS_IXR_ALL_MASK));
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Disable interrupts specified in <i>Mask</i>. The corresponding interrupt for
|
||||
* each bit set to 1 in <i>Mask</i>, will be enabled.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param Mask contains a bit mask of interrupts to disable. The mask can
|
||||
* be formed using a set of bitwise or'd values.
|
||||
*
|
||||
* @note
|
||||
* The state of the transmitter and receiver are not modified by this function.
|
||||
* C-style signature
|
||||
* void XEmacPs_IntDisable(XEmacPs *InstancePtr, u32 Mask)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_IntDisable(InstancePtr, Mask) \
|
||||
XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
XEMACPS_IDR_OFFSET, \
|
||||
((Mask) & XEMACPS_IXR_ALL_MASK));
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Enable interrupts specified in <i>Mask</i>. The corresponding interrupt for
|
||||
* each bit set to 1 in <i>Mask</i>, will be enabled.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param Mask contains a bit mask of interrupts to enable. The mask can
|
||||
* be formed using a set of bitwise or'd values.
|
||||
*
|
||||
* @note
|
||||
* The state of the transmitter and receiver are not modified by this function.
|
||||
* C-style signature
|
||||
* void XEmacPs_IntQ1Enable(XEmacPs *InstancePtr, u32 Mask)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_IntQ1Enable(InstancePtr, Mask) \
|
||||
XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
XEMACPS_INTQ1_IER_OFFSET, \
|
||||
((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK));
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Disable interrupts specified in <i>Mask</i>. The corresponding interrupt for
|
||||
* each bit set to 1 in <i>Mask</i>, will be enabled.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param Mask contains a bit mask of interrupts to disable. The mask can
|
||||
* be formed using a set of bitwise or'd values.
|
||||
*
|
||||
* @note
|
||||
* The state of the transmitter and receiver are not modified by this function.
|
||||
* C-style signature
|
||||
* void XEmacPs_IntDisable(XEmacPs *InstancePtr, u32 Mask)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_IntQ1Disable(InstancePtr, Mask) \
|
||||
XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
XEMACPS_INTQ1_IDR_OFFSET, \
|
||||
((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK));
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro triggers trasmit circuit to send data currently in TX buffer(s).
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* Signature: void XEmacPs_Transmit(XEmacPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_Transmit(InstancePtr) \
|
||||
XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
XEMACPS_NWCTRL_OFFSET, \
|
||||
(XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
XEMACPS_NWCTRL_OFFSET) | XEMACPS_NWCTRL_STARTTX_MASK))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro determines if the device is configured with checksum offloading
|
||||
* on the receive channel
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* Boolean TRUE if the device is configured with checksum offloading, or
|
||||
* FALSE otherwise.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* Signature: u32 XEmacPs_IsRxCsum(XEmacPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_IsRxCsum(InstancePtr) \
|
||||
((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
XEMACPS_NWCFG_OFFSET) & XEMACPS_NWCFG_RXCHKSUMEN_MASK) != 0U \
|
||||
? TRUE : FALSE)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro determines if the device is configured with checksum offloading
|
||||
* on the transmit channel
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* Boolean TRUE if the device is configured with checksum offloading, or
|
||||
* FALSE otherwise.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* Signature: u32 XEmacPs_IsTxCsum(XEmacPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_IsTxCsum(InstancePtr) \
|
||||
((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
XEMACPS_DMACR_OFFSET) & XEMACPS_DMACR_TCPCKSUM_MASK) != 0U \
|
||||
? TRUE : FALSE)
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro sets RX watermark register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
|
||||
* @param High is the non-zero RX high watermark value. When SRAM fill level
|
||||
* is above this, a pause frame will be sent.
|
||||
* @param Low is the non-zero RX low watermark value. When SRAM fill level
|
||||
* is below this, a zero length pause frame will be sent IF the last
|
||||
* pause frame sent was non-zero.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* Signature: void XEmacPs_SetRXWatermark(XEmacPs *InstancePtr, u16 High,
|
||||
* u16 Low)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_SetRXWatermark(InstancePtr, High, Low) \
|
||||
XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
|
||||
XEMACPS_RXWATERMARK_OFFSET, \
|
||||
(High & XEMACPS_RXWM_HIGH_MASK) | \
|
||||
((Low << XEMACPS_RXWM_LOW_SHFT_MSK) & XEMACPS_RXWM_LOW_MASK) |)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro gets RX watermark register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
|
||||
*
|
||||
* @return RX watermark register value
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* Signature: void XEmacPs_GetRXWatermark(XEmacPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_GetRXWatermark(InstancePtr) \
|
||||
XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \
|
||||
XEMACPS_RXWATERMARK_OFFSET)
|
||||
/*
|
||||
* Initialization functions in xemacps.c
|
||||
*/
|
||||
LONG XEmacPs_CfgInitialize(XEmacPs *InstancePtr, XEmacPs_Config *CfgPtr,
|
||||
UINTPTR EffectiveAddress);
|
||||
void XEmacPs_Start(XEmacPs *InstancePtr);
|
||||
void XEmacPs_Stop(XEmacPs *InstancePtr);
|
||||
void XEmacPs_Reset(XEmacPs *InstancePtr);
|
||||
void XEmacPs_SetQueuePtr(XEmacPs *InstancePtr, UINTPTR QPtr, u8 QueueNum,
|
||||
u16 Direction);
|
||||
|
||||
/*
|
||||
* Lookup configuration in xemacps_sinit.c
|
||||
*/
|
||||
XEmacPs_Config *XEmacPs_LookupConfig(u16 DeviceId);
|
||||
|
||||
/*
|
||||
* Interrupt-related functions in xemacps_intr.c
|
||||
* DMA only and FIFO is not supported. This DMA does not support coalescing.
|
||||
*/
|
||||
LONG XEmacPs_SetHandler(XEmacPs *InstancePtr, u32 HandlerType,
|
||||
void *FuncPointer, void *CallBackRef);
|
||||
void XEmacPs_IntrHandler(void *XEmacPsPtr);
|
||||
|
||||
/*
|
||||
* MAC configuration/control functions in XEmacPs_control.c
|
||||
*/
|
||||
LONG XEmacPs_SetOptions(XEmacPs *InstancePtr, u32 Options);
|
||||
LONG XEmacPs_ClearOptions(XEmacPs *InstancePtr, u32 Options);
|
||||
u32 XEmacPs_GetOptions(XEmacPs *InstancePtr);
|
||||
|
||||
LONG XEmacPs_SetMacAddress(XEmacPs *InstancePtr, void *AddressPtr, u8 Index);
|
||||
LONG XEmacPs_DeleteHash(XEmacPs *InstancePtr, void *AddressPtr);
|
||||
void XEmacPs_GetMacAddress(XEmacPs *InstancePtr, void *AddressPtr, u8 Index);
|
||||
|
||||
LONG XEmacPs_SetHash(XEmacPs *InstancePtr, void *AddressPtr);
|
||||
void XEmacPs_ClearHash(XEmacPs *InstancePtr);
|
||||
void XEmacPs_GetHash(XEmacPs *InstancePtr, void *AddressPtr);
|
||||
|
||||
void XEmacPs_SetMdioDivisor(XEmacPs *InstancePtr,
|
||||
XEmacPs_MdcDiv Divisor);
|
||||
void XEmacPs_SetOperatingSpeed(XEmacPs *InstancePtr, u16 Speed);
|
||||
u16 XEmacPs_GetOperatingSpeed(XEmacPs *InstancePtr);
|
||||
LONG XEmacPs_PhyRead(XEmacPs *InstancePtr, u32 PhyAddress,
|
||||
u32 RegisterNum, u16 *PhyDataPtr);
|
||||
LONG XEmacPs_PhyWrite(XEmacPs *InstancePtr, u32 PhyAddress,
|
||||
u32 RegisterNum, u16 PhyData);
|
||||
LONG XEmacPs_SetTypeIdCheck(XEmacPs *InstancePtr, u32 Id_Check, u8 Index);
|
||||
|
||||
LONG XEmacPs_SendPausePacket(XEmacPs *InstancePtr);
|
||||
void XEmacPs_DMABLengthUpdate(XEmacPs *InstancePtr, s32 BLength);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
762
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bd.h
Normal file
762
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bd.h
Normal file
@ -0,0 +1,762 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xemacps_bd.h
|
||||
* @addtogroup emacps_v3_16
|
||||
* @{
|
||||
*
|
||||
* This header provides operations to manage buffer descriptors in support
|
||||
* of scatter-gather DMA.
|
||||
*
|
||||
* The API exported by this header defines abstracted macros that allow the
|
||||
* user to read/write specific BD fields.
|
||||
*
|
||||
* <b>Buffer Descriptors</b>
|
||||
*
|
||||
* A buffer descriptor (BD) defines a DMA transaction. The macros defined by
|
||||
* this header file allow access to most fields within a BD to tailor a DMA
|
||||
* transaction according to user and hardware requirements. See the hardware
|
||||
* IP DMA spec for more information on BD fields and how they affect transfers.
|
||||
*
|
||||
* The XEmacPs_Bd structure defines a BD. The organization of this structure
|
||||
* is driven mainly by the hardware for use in scatter-gather DMA transfers.
|
||||
*
|
||||
* <b>Performance</b>
|
||||
*
|
||||
* Limiting I/O to BDs can improve overall performance of the DMA channel.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.00a wsy 01/10/10 First release
|
||||
* 2.1 srt 07/15/14 Add support for Zynq Ultrascale MP GEM specification
|
||||
* and 64-bit changes.
|
||||
* 3.0 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.0 hk 02/20/15 Added support for jumbo frames.
|
||||
* Disable extended mode. Perform all 64 bit changes under
|
||||
* check for arch64.
|
||||
* 3.2 hk 11/18/15 Change BD typedef and number of words.
|
||||
* 3.8 hk 08/18/18 Remove duplicate definition of XEmacPs_BdSetLength
|
||||
* 3.8 mus 11/05/18 Support 64 bit DMA addresses for Microblaze-X platform.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* ***************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XEMACPS_BD_H /* prevent circular inclusions */
|
||||
#define XEMACPS_BD_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
#ifdef __aarch64__
|
||||
/* Minimum BD alignment */
|
||||
#define XEMACPS_DMABD_MINIMUM_ALIGNMENT 64U
|
||||
#define XEMACPS_BD_NUM_WORDS 4U
|
||||
#else
|
||||
/* Minimum BD alignment */
|
||||
#define XEMACPS_DMABD_MINIMUM_ALIGNMENT 4U
|
||||
#define XEMACPS_BD_NUM_WORDS 2U
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The XEmacPs_Bd is the type for buffer descriptors (BDs).
|
||||
*/
|
||||
typedef u32 XEmacPs_Bd[XEMACPS_BD_NUM_WORDS];
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Zero out BD fields
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @return Nothing
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdClear(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdClear(BdPtr) \
|
||||
memset((BdPtr), 0, sizeof(XEmacPs_Bd))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given Buffer Descriptor word.
|
||||
*
|
||||
* @param BaseAddress is the base address of the BD to read
|
||||
* @param Offset is the word offset to be read
|
||||
*
|
||||
* @return The 32-bit value of the field
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XEmacPs_BdRead(UINTPTR BaseAddress, UINTPTR Offset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdRead(BaseAddress, Offset) \
|
||||
(*(u32 *)((UINTPTR)((void*)(BaseAddress)) + (u32)(Offset)))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write the given Buffer Descriptor word.
|
||||
*
|
||||
* @param BaseAddress is the base address of the BD to write
|
||||
* @param Offset is the word offset to be written
|
||||
* @param Data is the 32-bit value to write to the field
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdWrite(UINTPTR BaseAddress, UINTPTR Offset, UINTPTR Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdWrite(BaseAddress, Offset, Data) \
|
||||
(*(u32 *)((UINTPTR)(void*)(BaseAddress) + (u32)(Offset)) = (u32)(Data))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Set the BD's Address field (word 0).
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
* @param Addr is the value to write to BD's status field.
|
||||
*
|
||||
* @note :
|
||||
*
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdSetAddressTx(XEmacPs_Bd* BdPtr, UINTPTR Addr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined(__aarch64__) || defined(__arch64__)
|
||||
#define XEmacPs_BdSetAddressTx(BdPtr, Addr) \
|
||||
XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET, \
|
||||
(u32)((Addr) & ULONG64_LO_MASK)); \
|
||||
XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_HI_OFFSET, \
|
||||
(u32)(((Addr) & ULONG64_HI_MASK) >> 32U));
|
||||
#else
|
||||
#define XEmacPs_BdSetAddressTx(BdPtr, Addr) \
|
||||
XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET, (u32)(Addr))
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Set the BD's Address field (word 0).
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
* @param Addr is the value to write to BD's status field.
|
||||
*
|
||||
* @note : Due to some bits are mixed within receive BD's address field,
|
||||
* read-modify-write is performed.
|
||||
*
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdSetAddressRx(XEmacPs_Bd* BdPtr, UINTPTR Addr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifdef __aarch64__
|
||||
#define XEmacPs_BdSetAddressRx(BdPtr, Addr) \
|
||||
XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET, \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) & \
|
||||
~XEMACPS_RXBUF_ADD_MASK) | ((u32)((Addr) & ULONG64_LO_MASK)))); \
|
||||
XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_HI_OFFSET, \
|
||||
(u32)(((Addr) & ULONG64_HI_MASK) >> 32U));
|
||||
#else
|
||||
#define XEmacPs_BdSetAddressRx(BdPtr, Addr) \
|
||||
XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET, \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) & \
|
||||
~XEMACPS_RXBUF_ADD_MASK) | (UINTPTR)(Addr)))
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Set the BD's Status field (word 1).
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
* @param Data is the value to write to BD's status field.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdSetStatus(XEmacPs_Bd* BdPtr, UINTPTR Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdSetStatus(BdPtr, Data) \
|
||||
XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET, \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) | (Data))
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Retrieve the BD's Packet DMA transfer status word (word 1).
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @return Status word
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XEmacPs_BdGetStatus(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
* Due to the BD bit layout differences in transmit and receive. User's
|
||||
* caution is required.
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdGetStatus(BdPtr) \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Get the address (bits 0..31) of the BD's buffer address (word 0)
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdGetBufAddr(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined(__aarch64__) || defined(__arch64__)
|
||||
#define XEmacPs_BdGetBufAddr(BdPtr) \
|
||||
(XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) | \
|
||||
(XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_HI_OFFSET)) << 32U)
|
||||
#else
|
||||
#define XEmacPs_BdGetBufAddr(BdPtr) \
|
||||
(XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET))
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Set transfer length in bytes for the given BD. The length must be set each
|
||||
* time a BD is submitted to hardware.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
* @param LenBytes is the number of bytes to transfer.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdSetLength(XEmacPs_Bd* BdPtr, u32 LenBytes)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdSetLength(BdPtr, LenBytes) \
|
||||
XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET, \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
~XEMACPS_TXBUF_LEN_MASK) | (LenBytes)))
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Retrieve the BD length field.
|
||||
*
|
||||
* For Tx channels, the returned value is the same as that written with
|
||||
* XEmacPs_BdSetLength().
|
||||
*
|
||||
* For Rx channels, the returned value is the size of the received packet.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @return Length field processed by hardware or set by
|
||||
* XEmacPs_BdSetLength().
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdGetLength(XEmacPs_Bd* BdPtr)
|
||||
* XEAMCPS_RXBUF_LEN_MASK is same as XEMACPS_TXBUF_LEN_MASK.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdGetLength(BdPtr) \
|
||||
(XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_RXBUF_LEN_MASK)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Retrieve the RX frame size.
|
||||
*
|
||||
* The returned value is the size of the received packet.
|
||||
* This API supports jumbo frame sizes if enabled.
|
||||
*
|
||||
* @param InstancePtr is the pointer to XEmacps instance
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @return Length field processed by hardware or set by
|
||||
* XEmacPs_BdSetLength().
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_GetRxFrameSize(XEmacPs* InstancePtr, XEmacPs_Bd* BdPtr)
|
||||
* RxBufMask is dependent on whether jumbo is enabled or not.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_GetRxFrameSize(InstancePtr, BdPtr) \
|
||||
(XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
(InstancePtr)->RxBufMask)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Test whether the given BD has been marked as the last BD of a packet.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @return TRUE if BD represents the "Last" BD of a packet, FALSE otherwise
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsLast(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsLast(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_RXBUF_EOF_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Tell the DMA engine that the given transmit BD marks the end of the current
|
||||
* packet to be processed.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdSetLast(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdSetLast(BdPtr) \
|
||||
(XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET, \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) | \
|
||||
XEMACPS_TXBUF_LAST_MASK))
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Tell the DMA engine that the current packet does not end with the given
|
||||
* BD.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdClearLast(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdClearLast(BdPtr) \
|
||||
(XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET, \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
~XEMACPS_TXBUF_LAST_MASK))
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Set this bit to mark the last descriptor in the receive buffer descriptor
|
||||
* list.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdSetRxWrap(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*#define XEmacPs_BdSetRxWrap(BdPtr) \
|
||||
(XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET, \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) | \
|
||||
XEMACPS_RXBUF_WRAP_MASK))
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine the wrap bit of the receive BD which indicates end of the
|
||||
* BD list.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u8 XEmacPs_BdIsRxWrap(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsRxWrap(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) & \
|
||||
XEMACPS_RXBUF_WRAP_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Sets this bit to mark the last descriptor in the transmit buffer
|
||||
* descriptor list.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdSetTxWrap(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*#define XEmacPs_BdSetTxWrap(BdPtr) \
|
||||
(XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET, \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) | \
|
||||
XEMACPS_TXBUF_WRAP_MASK))
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine the wrap bit of the transmit BD which indicates end of the
|
||||
* BD list.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u8 XEmacPs_BdGetTxWrap(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsTxWrap(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_TXBUF_WRAP_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* Must clear this bit to enable the MAC to write data to the receive
|
||||
* buffer. Hardware sets this bit once it has successfully written a frame to
|
||||
* memory. Once set, software has to clear the bit before the buffer can be
|
||||
* used again. This macro clear the new bit of the receive BD.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdClearRxNew(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdClearRxNew(BdPtr) \
|
||||
(XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET, \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) & \
|
||||
~XEMACPS_RXBUF_NEW_MASK))
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine the new bit of the receive BD.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsRxNew(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsRxNew(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) & \
|
||||
XEMACPS_RXBUF_NEW_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Software sets this bit to disable the buffer to be read by the hardware.
|
||||
* Hardware sets this bit for the first buffer of a frame once it has been
|
||||
* successfully transmitted. This macro sets this bit of transmit BD to avoid
|
||||
* confusion.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdSetTxUsed(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdSetTxUsed(BdPtr) \
|
||||
(XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET, \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) | \
|
||||
XEMACPS_TXBUF_USED_MASK))
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Software clears this bit to enable the buffer to be read by the hardware.
|
||||
* Hardware sets this bit for the first buffer of a frame once it has been
|
||||
* successfully transmitted. This macro clears this bit of transmit BD.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_BdClearTxUsed(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdClearTxUsed(BdPtr) \
|
||||
(XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET, \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
~XEMACPS_TXBUF_USED_MASK))
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine the used bit of the transmit BD.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsTxUsed(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsTxUsed(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_TXBUF_USED_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine if a frame fails to be transmitted due to too many retries.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsTxRetry(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsTxRetry(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_TXBUF_RETRY_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine if a frame fails to be transmitted due to data can not be
|
||||
* feteched in time or buffers are exhausted.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsTxUrun(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsTxUrun(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_TXBUF_URUN_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine if a frame fails to be transmitted due to buffer is exhausted
|
||||
* mid-frame.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsTxExh(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsTxExh(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_TXBUF_EXH_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Sets this bit, no CRC will be appended to the current frame. This control
|
||||
* bit must be set for the first buffer in a frame and will be ignored for
|
||||
* the subsequent buffers of a frame.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* This bit must be clear when using the transmit checksum generation offload,
|
||||
* otherwise checksum generation and substitution will not occur.
|
||||
*
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdSetTxNoCRC(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdSetTxNoCRC(BdPtr) \
|
||||
(XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET, \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) | \
|
||||
XEMACPS_TXBUF_NOCRC_MASK))
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Clear this bit, CRC will be appended to the current frame. This control
|
||||
* bit must be set for the first buffer in a frame and will be ignored for
|
||||
* the subsequent buffers of a frame.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* This bit must be clear when using the transmit checksum generation offload,
|
||||
* otherwise checksum generation and substitution will not occur.
|
||||
*
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdClearTxNoCRC(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdClearTxNoCRC(BdPtr) \
|
||||
(XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET, \
|
||||
XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
~XEMACPS_TXBUF_NOCRC_MASK))
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine the broadcast bit of the receive BD.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsRxBcast(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsRxBcast(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_RXBUF_BCAST_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine the multicast hash bit of the receive BD.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsRxMultiHash(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsRxMultiHash(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_RXBUF_MULTIHASH_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine the unicast hash bit of the receive BD.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsRxUniHash(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsRxUniHash(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_RXBUF_UNIHASH_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine if the received frame is a VLAN Tagged frame.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsRxVlan(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsRxVlan(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_RXBUF_VLAN_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine if the received frame has Type ID of 8100h and null VLAN
|
||||
* identifier(Priority tag).
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsRxPri(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsRxPri(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_RXBUF_PRI_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine if the received frame's Concatenation Format Indicator (CFI) of
|
||||
* the frames VLANTCI field was set.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdIsRxCFI(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsRxCFI(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_RXBUF_CFI_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine the End Of Frame (EOF) bit of the receive BD.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdGetRxEOF(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsRxEOF(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_RXBUF_EOF_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Determine the Start Of Frame (SOF) bit of the receive BD.
|
||||
*
|
||||
* @param BdPtr is the BD pointer to operate on
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* UINTPTR XEmacPs_BdGetRxSOF(XEmacPs_Bd* BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdIsRxSOF(BdPtr) \
|
||||
((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) & \
|
||||
XEMACPS_RXBUF_SOF_MASK)!=0U ? TRUE : FALSE)
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
1090
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.c
Normal file
1090
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.c
Normal file
File diff suppressed because it is too large
Load Diff
215
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.h
Normal file
215
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.h
Normal file
@ -0,0 +1,215 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xemacps_bdring.h
|
||||
* @addtogroup emacps_v3_16
|
||||
* @{
|
||||
*
|
||||
* The Xiline EmacPs Buffer Descriptor ring driver. This is part of EmacPs
|
||||
* DMA functionalities.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.00a wsy 01/10/10 First release
|
||||
* 2.1 srt 07/15/14 Add support for Zynq Ultrascale Mp architecture.
|
||||
* 3.0 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.6 rb 09/08/17 HwCnt variable (in XEmacPs_BdRing structure) is
|
||||
* changed to volatile.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef XEMACPS_BDRING_H /* prevent curcular inclusions */
|
||||
#define XEMACPS_BDRING_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/** This is an internal structure used to maintain the DMA list */
|
||||
typedef struct {
|
||||
UINTPTR PhysBaseAddr;/**< Physical address of 1st BD in list */
|
||||
UINTPTR BaseBdAddr; /**< Virtual address of 1st BD in list */
|
||||
UINTPTR HighBdAddr; /**< Virtual address of last BD in the list */
|
||||
u32 Length; /**< Total size of ring in bytes */
|
||||
u32 RunState; /**< Flag to indicate DMA is started */
|
||||
u32 Separation; /**< Number of bytes between the starting address
|
||||
of adjacent BDs */
|
||||
XEmacPs_Bd *FreeHead;
|
||||
/**< First BD in the free group */
|
||||
XEmacPs_Bd *PreHead;/**< First BD in the pre-work group */
|
||||
XEmacPs_Bd *HwHead; /**< First BD in the work group */
|
||||
XEmacPs_Bd *HwTail; /**< Last BD in the work group */
|
||||
XEmacPs_Bd *PostHead;
|
||||
/**< First BD in the post-work group */
|
||||
XEmacPs_Bd *BdaRestart;
|
||||
/**< BDA to load when channel is started */
|
||||
|
||||
volatile u32 HwCnt; /**< Number of BDs in work group */
|
||||
u32 PreCnt; /**< Number of BDs in pre-work group */
|
||||
u32 FreeCnt; /**< Number of allocatable BDs in the free group */
|
||||
u32 PostCnt; /**< Number of BDs in post-work group */
|
||||
u32 AllCnt; /**< Total Number of BDs for channel */
|
||||
} XEmacPs_BdRing;
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Use this macro at initialization time to determine how many BDs will fit
|
||||
* in a BD list within the given memory constraints.
|
||||
*
|
||||
* The results of this macro can be provided to XEmacPs_BdRingCreate().
|
||||
*
|
||||
* @param Alignment specifies what byte alignment the BDs must fall on and
|
||||
* must be a power of 2 to get an accurate calculation (32, 64, 128,...)
|
||||
* @param Bytes is the number of bytes to be used to store BDs.
|
||||
*
|
||||
* @return Number of BDs that can fit in the given memory area
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XEmacPs_BdRingCntCalc(u32 Alignment, u32 Bytes)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XEmacPs_BdRingCntCalc(Alignment, Bytes) \
|
||||
(u32)((Bytes) / (sizeof(XEmacPs_Bd)))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Use this macro at initialization time to determine how many bytes of memory
|
||||
* is required to contain a given number of BDs at a given alignment.
|
||||
*
|
||||
* @param Alignment specifies what byte alignment the BDs must fall on. This
|
||||
* parameter must be a power of 2 to get an accurate calculation (32, 64,
|
||||
* 128,...)
|
||||
* @param NumBd is the number of BDs to calculate memory size requirements for
|
||||
*
|
||||
* @return The number of bytes of memory required to create a BD list with the
|
||||
* given memory constraints.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XEmacPs_BdRingMemCalc(u32 Alignment, u32 NumBd)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XEmacPs_BdRingMemCalc(Alignment, NumBd) \
|
||||
(u32)(sizeof(XEmacPs_Bd) * (NumBd))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* Return the total number of BDs allocated by this channel with
|
||||
* XEmacPs_BdRingCreate().
|
||||
*
|
||||
* @param RingPtr is the DMA channel to operate on.
|
||||
*
|
||||
* @return The total number of BDs allocated for this channel.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XEmacPs_BdRingGetCnt(XEmacPs_BdRing* RingPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdRingGetCnt(RingPtr) ((RingPtr)->AllCnt)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* Return the number of BDs allocatable with XEmacPs_BdRingAlloc() for pre-
|
||||
* processing.
|
||||
*
|
||||
* @param RingPtr is the DMA channel to operate on.
|
||||
*
|
||||
* @return The number of BDs currently allocatable.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XEmacPs_BdRingGetFreeCnt(XEmacPs_BdRing* RingPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdRingGetFreeCnt(RingPtr) ((RingPtr)->FreeCnt)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* Return the next BD from BdPtr in a list.
|
||||
*
|
||||
* @param RingPtr is the DMA channel to operate on.
|
||||
* @param BdPtr is the BD to operate on.
|
||||
*
|
||||
* @return The next BD in the list relative to the BdPtr parameter.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* XEmacPs_Bd *XEmacPs_BdRingNext(XEmacPs_BdRing* RingPtr,
|
||||
* XEmacPs_Bd *BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdRingNext(RingPtr, BdPtr) \
|
||||
(((UINTPTR)((void *)(BdPtr)) >= (RingPtr)->HighBdAddr) ? \
|
||||
(XEmacPs_Bd*)((void*)(RingPtr)->BaseBdAddr) : \
|
||||
(XEmacPs_Bd*)((UINTPTR)((void *)(BdPtr)) + (RingPtr)->Separation))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* Return the previous BD from BdPtr in the list.
|
||||
*
|
||||
* @param RingPtr is the DMA channel to operate on.
|
||||
* @param BdPtr is the BD to operate on
|
||||
*
|
||||
* @return The previous BD in the list relative to the BdPtr parameter.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* XEmacPs_Bd *XEmacPs_BdRingPrev(XEmacPs_BdRing* RingPtr,
|
||||
* XEmacPs_Bd *BdPtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_BdRingPrev(RingPtr, BdPtr) \
|
||||
(((UINTPTR)(BdPtr) <= (RingPtr)->BaseBdAddr) ? \
|
||||
(XEmacPs_Bd*)(RingPtr)->HighBdAddr : \
|
||||
(XEmacPs_Bd*)((UINTPTR)(BdPtr) - (RingPtr)->Separation))
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*
|
||||
* Scatter gather DMA related functions in xemacps_bdring.c
|
||||
*/
|
||||
LONG XEmacPs_BdRingCreate(XEmacPs_BdRing * RingPtr, UINTPTR PhysAddr,
|
||||
UINTPTR VirtAddr, u32 Alignment, u32 BdCount);
|
||||
LONG XEmacPs_BdRingClone(XEmacPs_BdRing * RingPtr, XEmacPs_Bd * SrcBdPtr,
|
||||
u8 Direction);
|
||||
LONG XEmacPs_BdRingAlloc(XEmacPs_BdRing * RingPtr, u32 NumBd,
|
||||
XEmacPs_Bd ** BdSetPtr);
|
||||
LONG XEmacPs_BdRingUnAlloc(XEmacPs_BdRing * RingPtr, u32 NumBd,
|
||||
XEmacPs_Bd * BdSetPtr);
|
||||
LONG XEmacPs_BdRingToHw(XEmacPs_BdRing * RingPtr, u32 NumBd,
|
||||
XEmacPs_Bd * BdSetPtr);
|
||||
LONG XEmacPs_BdRingFree(XEmacPs_BdRing * RingPtr, u32 NumBd,
|
||||
XEmacPs_Bd * BdSetPtr);
|
||||
u32 XEmacPs_BdRingFromHwTx(XEmacPs_BdRing * RingPtr, u32 BdLimit,
|
||||
XEmacPs_Bd ** BdSetPtr);
|
||||
u32 XEmacPs_BdRingFromHwRx(XEmacPs_BdRing * RingPtr, u32 BdLimit,
|
||||
XEmacPs_Bd ** BdSetPtr);
|
||||
LONG XEmacPs_BdRingCheck(XEmacPs_BdRing * RingPtr, u8 Direction);
|
||||
|
||||
void XEmacPs_BdRingPtrReset(XEmacPs_BdRing * RingPtr, void *virtaddrloc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* end of protection macros */
|
||||
/** @} */
|
1133
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_control.c
Normal file
1133
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_control.c
Normal file
File diff suppressed because it is too large
Load Diff
87
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_g.c
Normal file
87
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_g.c
Normal file
@ -0,0 +1,87 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xemacps_g.c
|
||||
* @addtogroup emacps_v3_16
|
||||
* @{
|
||||
*
|
||||
* This file contains a configuration table that specifies the configuration of
|
||||
* ethernet devices in the system.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.00a wsy 01/10/10 First release
|
||||
* 2.00 hk 22/01/14 Added check for picking second instance
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* This configuration table contains entries that are modified at runtime by the
|
||||
* driver. This table reflects only the hardware configuration of the device.
|
||||
* This emac configuration table contains software information in addition to
|
||||
* hardware configuration.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xemacps.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Prototypes ******************************/
|
||||
|
||||
/*
|
||||
* The configuration table for emacps device
|
||||
*/
|
||||
|
||||
XEmacPs_Config XEmacPs_ConfigTable[XPAR_XEMACPS_NUM_INSTANCES] = {
|
||||
{
|
||||
(u16)XPAR_XEMACPS_0_DEVICE_ID, /* Device ID */
|
||||
(UINTPTR)XPAR_XEMACPS_0_BASEADDR, /* Device base address */
|
||||
(u16)XPAR_XEMACPS_0_IS_CACHE_COHERENT, /* Cache Coherency */
|
||||
#if defined (XCLOCKING)
|
||||
(u32)XPAR_XEMACPS_0_ENET_CLK_FREQ_HZ,
|
||||
#endif
|
||||
(u16)XPAR_XEMACPS_0_ENET_SLCR_1000Mbps_DIV0,
|
||||
(u8)XPAR_XEMACPS_0_ENET_SLCR_1000Mbps_DIV1,
|
||||
(u16)XPAR_XEMACPS_0_ENET_SLCR_100Mbps_DIV0,
|
||||
(u8)XPAR_XEMACPS_0_ENET_SLCR_100Mbps_DIV1,
|
||||
(u16)XPAR_XEMACPS_0_ENET_SLCR_10Mbps_DIV0,
|
||||
(u8)XPAR_XEMACPS_0_ENET_SLCR_10Mbps_DIV1
|
||||
},
|
||||
#ifdef XPAR_XEMACPS_1_DEVICE_ID
|
||||
{
|
||||
(u16)XPAR_XEMACPS_1_DEVICE_ID, /* Device ID */
|
||||
(UINTPTR)XPAR_XEMACPS_1_BASEADDR, /* Device base address */
|
||||
(u16)XPAR_XEMACPS_1_IS_CACHE_COHERENT, /* Cache coherency */
|
||||
#if defined (XCLOCKING)
|
||||
(u32)XPAR_XEMACPS_1_ENET_CLK_FREQ_HZ,
|
||||
#endif
|
||||
(u16)XPAR_XEMACPS_1_ENET_SLCR_1000Mbps_DIV0,
|
||||
(u8)XPAR_XEMACPS_1_ENET_SLCR_1000Mbps_DIV1,
|
||||
(u16)XPAR_XEMACPS_1_ENET_SLCR_100Mbps_DIV0,
|
||||
(u8)XPAR_XEMACPS_1_ENET_SLCR_100Mbps_DIV1,
|
||||
(u16)XPAR_XEMACPS_1_ENET_SLCR_10Mbps_DIV0,
|
||||
(u8)XPAR_XEMACPS_1_ENET_SLCR_10Mbps_DIV1
|
||||
}
|
||||
#endif
|
||||
};
|
||||
/** @} */
|
97
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.c
Normal file
97
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.c
Normal file
@ -0,0 +1,97 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xemacps_hw.c
|
||||
* @addtogroup emacps_v3_16
|
||||
* @{
|
||||
*
|
||||
* This file contains the implementation of the ethernet interface reset sequence
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.05a kpc 28/06/13 First release
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xemacps_hw.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function perform the reset sequence to the given emacps interface by
|
||||
* configuring the appropriate control bits in the emacps specific registers.
|
||||
* the emacps reset sequence involves the following steps
|
||||
* Disable all the interuupts
|
||||
* Clear the status registers
|
||||
* Disable Rx and Tx engines
|
||||
* Update the Tx and Rx descriptor queue registers with reset values
|
||||
* Update the other relevant control registers with reset value
|
||||
*
|
||||
* @param BaseAddr of the interface
|
||||
*
|
||||
* @return N/A
|
||||
*
|
||||
* @note
|
||||
* This function will not modify the slcr registers that are relevant for
|
||||
* emacps controller
|
||||
******************************************************************************/
|
||||
void XEmacPs_ResetHw(u32 BaseAddr)
|
||||
{
|
||||
u32 RegVal;
|
||||
|
||||
/* Disable the interrupts */
|
||||
XEmacPs_WriteReg(BaseAddr,XEMACPS_IDR_OFFSET,0x0U);
|
||||
|
||||
/* Stop transmission,disable loopback and Stop tx and Rx engines */
|
||||
RegVal = XEmacPs_ReadReg(BaseAddr,XEMACPS_NWCTRL_OFFSET);
|
||||
RegVal &= ~((u32)XEMACPS_NWCTRL_TXEN_MASK|
|
||||
(u32)XEMACPS_NWCTRL_RXEN_MASK|
|
||||
(u32)XEMACPS_NWCTRL_HALTTX_MASK|
|
||||
(u32)XEMACPS_NWCTRL_LOOPEN_MASK);
|
||||
/* Clear the statistic registers, flush the packets in DPRAM*/
|
||||
RegVal |= (XEMACPS_NWCTRL_STATCLR_MASK|
|
||||
XEMACPS_NWCTRL_FLUSH_DPRAM_MASK);
|
||||
XEmacPs_WriteReg(BaseAddr,XEMACPS_NWCTRL_OFFSET,RegVal);
|
||||
/* Clear the interrupt status */
|
||||
XEmacPs_WriteReg(BaseAddr,XEMACPS_ISR_OFFSET,XEMACPS_IXR_ALL_MASK);
|
||||
/* Clear the tx status */
|
||||
XEmacPs_WriteReg(BaseAddr,XEMACPS_TXSR_OFFSET,(XEMACPS_TXSR_ERROR_MASK|
|
||||
(u32)XEMACPS_TXSR_TXCOMPL_MASK|
|
||||
(u32)XEMACPS_TXSR_TXGO_MASK));
|
||||
/* Clear the rx status */
|
||||
XEmacPs_WriteReg(BaseAddr,XEMACPS_RXSR_OFFSET,
|
||||
XEMACPS_RXSR_FRAMERX_MASK);
|
||||
/* Clear the tx base address */
|
||||
XEmacPs_WriteReg(BaseAddr,XEMACPS_TXQBASE_OFFSET,0x0U);
|
||||
/* Clear the rx base address */
|
||||
XEmacPs_WriteReg(BaseAddr,XEMACPS_RXQBASE_OFFSET,0x0U);
|
||||
/* Update the network config register with reset value */
|
||||
XEmacPs_WriteReg(BaseAddr,XEMACPS_NWCFG_OFFSET,XEMACPS_NWCFG_RESET_MASK);
|
||||
/* Update the hash address registers with reset value */
|
||||
XEmacPs_WriteReg(BaseAddr,XEMACPS_HASHL_OFFSET,0x0U);
|
||||
XEmacPs_WriteReg(BaseAddr,XEMACPS_HASHH_OFFSET,0x0U);
|
||||
}
|
||||
/** @} */
|
664
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.h
Normal file
664
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.h
Normal file
@ -0,0 +1,664 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xemacps_hw.h
|
||||
* @addtogroup emacps_v3_16
|
||||
* @{
|
||||
*
|
||||
* This header file contains identifiers and low-level driver functions (or
|
||||
* macros) that can be used to access the PS Ethernet MAC (XEmacPs) device.
|
||||
* High-level driver functions are defined in xemacps.h.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.00a wsy 01/10/10 First release.
|
||||
* 1.02a asa 11/05/12 Added hash defines for DMACR burst length configuration.
|
||||
* 1.05a kpc 28/06/13 Added XEmacPs_ResetHw function prototype
|
||||
* 1.06a asa 11/02/13 Changed the value for XEMACPS_RXBUF_LEN_MASK from 0x3fff
|
||||
* to 0x1fff. This fixes the CR#744902.
|
||||
* 2.1 srt 07/15/14 Add support for Zynq Ultrascale Mp GEM specification.
|
||||
* 3.0 kvn 12/16/14 Changed name of XEMACPS_NWCFG_LENGTHERRDSCRD_MASK to
|
||||
* XEMACPS_NWCFG_LENERRDSCRD_MASK as it exceeds 31 characters.
|
||||
* 3.0 kpc 1/23/15 Corrected the extended descriptor macro values.
|
||||
* 3.0 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.0 hk 03/18/15 Added support for jumbo frames.
|
||||
* Remove "used bit set" from TX error interrupt masks.
|
||||
* 3.1 hk 08/10/15 Update upper 32 bit tx and rx queue ptr register offsets.
|
||||
* 3.2 hk 02/22/16 Added SGMII support for Zynq Ultrascale+ MPSoC.
|
||||
* 3.8 hk 09/17/18 Fix PTP interrupt masks.
|
||||
* 3.9 hk 01/23/19 Add RX watermark support
|
||||
* 3.10 hk 05/16/19 Clear status registers properly in reset
|
||||
* 3.18 sne 01/11/23 Add PCS control and status registers information.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef XEMACPS_HW_H /* prevent circular inclusions */
|
||||
#define XEMACPS_HW_H /* by using protection macros */
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xil_io.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
#define XEMACPS_MAX_MAC_ADDR 4U /**< Maxmum number of mac address
|
||||
supported */
|
||||
#define XEMACPS_MAX_TYPE_ID 4U /**< Maxmum number of type id supported */
|
||||
|
||||
#ifdef __aarch64__
|
||||
#define XEMACPS_BD_ALIGNMENT 64U /**< Minimum buffer descriptor alignment
|
||||
on the local bus */
|
||||
#else
|
||||
|
||||
#define XEMACPS_BD_ALIGNMENT 4U /**< Minimum buffer descriptor alignment
|
||||
on the local bus */
|
||||
#endif
|
||||
#define XEMACPS_RX_BUF_ALIGNMENT 4U /**< Minimum buffer alignment when using
|
||||
options that impose alignment
|
||||
restrictions on the buffer data on
|
||||
the local bus */
|
||||
|
||||
/** @name Direction identifiers
|
||||
*
|
||||
* These are used by several functions and callbacks that need
|
||||
* to specify whether an operation specifies a send or receive channel.
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_SEND 1U /**< send direction */
|
||||
#define XEMACPS_RECV 2U /**< receive direction */
|
||||
/*@}*/
|
||||
|
||||
/** @name MDC clock division
|
||||
* currently supporting 8, 16, 32, 48, 64, 96, 128, 224.
|
||||
* @{
|
||||
*/
|
||||
typedef enum { MDC_DIV_8 = 0U, MDC_DIV_16, MDC_DIV_32, MDC_DIV_48,
|
||||
MDC_DIV_64, MDC_DIV_96, MDC_DIV_128, MDC_DIV_224
|
||||
} XEmacPs_MdcDiv;
|
||||
|
||||
/*@}*/
|
||||
|
||||
#define XEMACPS_RX_BUF_SIZE 1536U /**< Specify the receive buffer size in
|
||||
bytes, 64, 128, ... 10240 */
|
||||
#define XEMACPS_RX_BUF_SIZE_JUMBO 10240U
|
||||
|
||||
#define XEMACPS_RX_BUF_UNIT 64U /**< Number of receive buffer bytes as a
|
||||
unit, this is HW setup */
|
||||
|
||||
#define XEMACPS_MAX_RXBD 128U /**< Size of RX buffer descriptor queues */
|
||||
#define XEMACPS_MAX_TXBD 128U /**< Size of TX buffer descriptor queues */
|
||||
|
||||
#define XEMACPS_MAX_HASH_BITS 64U /**< Maximum value for hash bits. 2**6 */
|
||||
|
||||
/* Register offset definitions. Unless otherwise noted, register access is
|
||||
* 32 bit. Names are self explained here.
|
||||
*/
|
||||
|
||||
#define XEMACPS_NWCTRL_OFFSET 0x00000000U /**< Network Control reg */
|
||||
#define XEMACPS_NWCFG_OFFSET 0x00000004U /**< Network Config reg */
|
||||
#define XEMACPS_NWSR_OFFSET 0x00000008U /**< Network Status reg */
|
||||
|
||||
#define XEMACPS_DMACR_OFFSET 0x00000010U /**< DMA Control reg */
|
||||
#define XEMACPS_TXSR_OFFSET 0x00000014U /**< TX Status reg */
|
||||
#define XEMACPS_RXQBASE_OFFSET 0x00000018U /**< RX Q Base address reg */
|
||||
#define XEMACPS_TXQBASE_OFFSET 0x0000001CU /**< TX Q Base address reg */
|
||||
#define XEMACPS_RXSR_OFFSET 0x00000020U /**< RX Status reg */
|
||||
|
||||
#define XEMACPS_ISR_OFFSET 0x00000024U /**< Interrupt Status reg */
|
||||
#define XEMACPS_IER_OFFSET 0x00000028U /**< Interrupt Enable reg */
|
||||
#define XEMACPS_IDR_OFFSET 0x0000002CU /**< Interrupt Disable reg */
|
||||
#define XEMACPS_IMR_OFFSET 0x00000030U /**< Interrupt Mask reg */
|
||||
|
||||
#define XEMACPS_PHYMNTNC_OFFSET 0x00000034U /**< Phy Maintaince reg */
|
||||
#define XEMACPS_RXPAUSE_OFFSET 0x00000038U /**< RX Pause Time reg */
|
||||
#define XEMACPS_TXPAUSE_OFFSET 0x0000003CU /**< TX Pause Time reg */
|
||||
|
||||
#define XEMACPS_JUMBOMAXLEN_OFFSET 0x00000048U /**< Jumbo max length reg */
|
||||
|
||||
#define XEMACPS_RXWATERMARK_OFFSET 0x0000007CU /**< RX watermark reg */
|
||||
|
||||
#define XEMACPS_HASHL_OFFSET 0x00000080U /**< Hash Low address reg */
|
||||
#define XEMACPS_HASHH_OFFSET 0x00000084U /**< Hash High address reg */
|
||||
|
||||
#define XEMACPS_LADDR1L_OFFSET 0x00000088U /**< Specific1 addr low reg */
|
||||
#define XEMACPS_LADDR1H_OFFSET 0x0000008CU /**< Specific1 addr high reg */
|
||||
#define XEMACPS_LADDR2L_OFFSET 0x00000090U /**< Specific2 addr low reg */
|
||||
#define XEMACPS_LADDR2H_OFFSET 0x00000094U /**< Specific2 addr high reg */
|
||||
#define XEMACPS_LADDR3L_OFFSET 0x00000098U /**< Specific3 addr low reg */
|
||||
#define XEMACPS_LADDR3H_OFFSET 0x0000009CU /**< Specific3 addr high reg */
|
||||
#define XEMACPS_LADDR4L_OFFSET 0x000000A0U /**< Specific4 addr low reg */
|
||||
#define XEMACPS_LADDR4H_OFFSET 0x000000A4U /**< Specific4 addr high reg */
|
||||
|
||||
#define XEMACPS_MATCH1_OFFSET 0x000000A8U /**< Type ID1 Match reg */
|
||||
#define XEMACPS_MATCH2_OFFSET 0x000000ACU /**< Type ID2 Match reg */
|
||||
#define XEMACPS_MATCH3_OFFSET 0x000000B0U /**< Type ID3 Match reg */
|
||||
#define XEMACPS_MATCH4_OFFSET 0x000000B4U /**< Type ID4 Match reg */
|
||||
|
||||
#define XEMACPS_STRETCH_OFFSET 0x000000BCU /**< IPG Stretch reg */
|
||||
|
||||
#define XEMACPS_OCTTXL_OFFSET 0x00000100U /**< Octects transmitted Low
|
||||
reg */
|
||||
#define XEMACPS_OCTTXH_OFFSET 0x00000104U /**< Octects transmitted High
|
||||
reg */
|
||||
|
||||
#define XEMACPS_TXCNT_OFFSET 0x00000108U /**< Error-free Frmaes
|
||||
transmitted counter */
|
||||
#define XEMACPS_TXBCCNT_OFFSET 0x0000010CU /**< Error-free Broadcast
|
||||
Frames counter*/
|
||||
#define XEMACPS_TXMCCNT_OFFSET 0x00000110U /**< Error-free Multicast
|
||||
Frame counter */
|
||||
#define XEMACPS_TXPAUSECNT_OFFSET 0x00000114U /**< Pause Frames Transmitted
|
||||
Counter */
|
||||
#define XEMACPS_TX64CNT_OFFSET 0x00000118U /**< Error-free 64 byte Frames
|
||||
Transmitted counter */
|
||||
#define XEMACPS_TX65CNT_OFFSET 0x0000011CU /**< Error-free 65-127 byte
|
||||
Frames Transmitted
|
||||
counter */
|
||||
#define XEMACPS_TX128CNT_OFFSET 0x00000120U /**< Error-free 128-255 byte
|
||||
Frames Transmitted
|
||||
counter*/
|
||||
#define XEMACPS_TX256CNT_OFFSET 0x00000124U /**< Error-free 256-511 byte
|
||||
Frames transmitted
|
||||
counter */
|
||||
#define XEMACPS_TX512CNT_OFFSET 0x00000128U /**< Error-free 512-1023 byte
|
||||
Frames transmitted
|
||||
counter */
|
||||
#define XEMACPS_TX1024CNT_OFFSET 0x0000012CU /**< Error-free 1024-1518 byte
|
||||
Frames transmitted
|
||||
counter */
|
||||
#define XEMACPS_TX1519CNT_OFFSET 0x00000130U /**< Error-free larger than
|
||||
1519 byte Frames
|
||||
transmitted counter */
|
||||
#define XEMACPS_TXURUNCNT_OFFSET 0x00000134U /**< TX under run error
|
||||
counter */
|
||||
|
||||
#define XEMACPS_SNGLCOLLCNT_OFFSET 0x00000138U /**< Single Collision Frame
|
||||
Counter */
|
||||
#define XEMACPS_MULTICOLLCNT_OFFSET 0x0000013CU /**< Multiple Collision Frame
|
||||
Counter */
|
||||
#define XEMACPS_EXCESSCOLLCNT_OFFSET 0x00000140U /**< Excessive Collision Frame
|
||||
Counter */
|
||||
#define XEMACPS_LATECOLLCNT_OFFSET 0x00000144U /**< Late Collision Frame
|
||||
Counter */
|
||||
#define XEMACPS_TXDEFERCNT_OFFSET 0x00000148U /**< Deferred Transmission
|
||||
Frame Counter */
|
||||
#define XEMACPS_TXCSENSECNT_OFFSET 0x0000014CU /**< Transmit Carrier Sense
|
||||
Error Counter */
|
||||
|
||||
#define XEMACPS_OCTRXL_OFFSET 0x00000150U /**< Octects Received register
|
||||
Low */
|
||||
#define XEMACPS_OCTRXH_OFFSET 0x00000154U /**< Octects Received register
|
||||
High */
|
||||
|
||||
#define XEMACPS_RXCNT_OFFSET 0x00000158U /**< Error-free Frames
|
||||
Received Counter */
|
||||
#define XEMACPS_RXBROADCNT_OFFSET 0x0000015CU /**< Error-free Broadcast
|
||||
Frames Received Counter */
|
||||
#define XEMACPS_RXMULTICNT_OFFSET 0x00000160U /**< Error-free Multicast
|
||||
Frames Received Counter */
|
||||
#define XEMACPS_RXPAUSECNT_OFFSET 0x00000164U /**< Pause Frames
|
||||
Received Counter */
|
||||
#define XEMACPS_RX64CNT_OFFSET 0x00000168U /**< Error-free 64 byte Frames
|
||||
Received Counter */
|
||||
#define XEMACPS_RX65CNT_OFFSET 0x0000016CU /**< Error-free 65-127 byte
|
||||
Frames Received Counter */
|
||||
#define XEMACPS_RX128CNT_OFFSET 0x00000170U /**< Error-free 128-255 byte
|
||||
Frames Received Counter */
|
||||
#define XEMACPS_RX256CNT_OFFSET 0x00000174U /**< Error-free 256-512 byte
|
||||
Frames Received Counter */
|
||||
#define XEMACPS_RX512CNT_OFFSET 0x00000178U /**< Error-free 512-1023 byte
|
||||
Frames Received Counter */
|
||||
#define XEMACPS_RX1024CNT_OFFSET 0x0000017CU /**< Error-free 1024-1518 byte
|
||||
Frames Received Counter */
|
||||
#define XEMACPS_RX1519CNT_OFFSET 0x00000180U /**< Error-free 1519-max byte
|
||||
Frames Received Counter */
|
||||
#define XEMACPS_RXUNDRCNT_OFFSET 0x00000184U /**< Undersize Frames Received
|
||||
Counter */
|
||||
#define XEMACPS_RXOVRCNT_OFFSET 0x00000188U /**< Oversize Frames Received
|
||||
Counter */
|
||||
#define XEMACPS_RXJABCNT_OFFSET 0x0000018CU /**< Jabbers Received
|
||||
Counter */
|
||||
#define XEMACPS_RXFCSCNT_OFFSET 0x00000190U /**< Frame Check Sequence
|
||||
Error Counter */
|
||||
#define XEMACPS_RXLENGTHCNT_OFFSET 0x00000194U /**< Length Field Error
|
||||
Counter */
|
||||
#define XEMACPS_RXSYMBCNT_OFFSET 0x00000198U /**< Symbol Error Counter */
|
||||
#define XEMACPS_RXALIGNCNT_OFFSET 0x0000019CU /**< Alignment Error Counter */
|
||||
#define XEMACPS_RXRESERRCNT_OFFSET 0x000001A0U /**< Receive Resource Error
|
||||
Counter */
|
||||
#define XEMACPS_RXORCNT_OFFSET 0x000001A4U /**< Receive Overrun Counter */
|
||||
#define XEMACPS_RXIPCCNT_OFFSET 0x000001A8U /**< IP header Checksum Error
|
||||
Counter */
|
||||
#define XEMACPS_RXTCPCCNT_OFFSET 0x000001ACU /**< TCP Checksum Error
|
||||
Counter */
|
||||
#define XEMACPS_RXUDPCCNT_OFFSET 0x000001B0U /**< UDP Checksum Error
|
||||
Counter */
|
||||
#define XEMACPS_LAST_OFFSET 0x000001B4U /**< Last statistic counter
|
||||
offset, for clearing */
|
||||
|
||||
#define XEMACPS_1588_SEC_OFFSET 0x000001D0U /**< 1588 second counter */
|
||||
#define XEMACPS_1588_NANOSEC_OFFSET 0x000001D4U /**< 1588 nanosecond counter */
|
||||
#define XEMACPS_1588_ADJ_OFFSET 0x000001D8U /**< 1588 nanosecond
|
||||
adjustment counter */
|
||||
#define XEMACPS_1588_INC_OFFSET 0x000001DCU /**< 1588 nanosecond
|
||||
increment counter */
|
||||
#define XEMACPS_PTP_TXSEC_OFFSET 0x000001E0U /**< 1588 PTP transmit second
|
||||
counter */
|
||||
#define XEMACPS_PTP_TXNANOSEC_OFFSET 0x000001E4U /**< 1588 PTP transmit
|
||||
nanosecond counter */
|
||||
#define XEMACPS_PTP_RXSEC_OFFSET 0x000001E8U /**< 1588 PTP receive second
|
||||
counter */
|
||||
#define XEMACPS_PTP_RXNANOSEC_OFFSET 0x000001ECU /**< 1588 PTP receive
|
||||
nanosecond counter */
|
||||
#define XEMACPS_PTPP_TXSEC_OFFSET 0x000001F0U /**< 1588 PTP peer transmit
|
||||
second counter */
|
||||
#define XEMACPS_PTPP_TXNANOSEC_OFFSET 0x000001F4U /**< 1588 PTP peer transmit
|
||||
nanosecond counter */
|
||||
#define XEMACPS_PTPP_RXSEC_OFFSET 0x000001F8U /**< 1588 PTP peer receive
|
||||
second counter */
|
||||
#define XEMACPS_PTPP_RXNANOSEC_OFFSET 0x000001FCU /**< 1588 PTP peer receive
|
||||
nanosecond counter */
|
||||
#define XEMACPS_PCS_CONTROL_OFFSET 0x00000200U /** PCS control register */
|
||||
#define XEMACPS_PCS_STATUS_OFFSET 0x00000204U /** PCS status register */
|
||||
|
||||
#define XEMACPS_INTQ1_STS_OFFSET 0x00000400U /**< Interrupt Q1 Status
|
||||
reg */
|
||||
#define XEMACPS_TXQ1BASE_OFFSET 0x00000440U /**< TX Q1 Base address
|
||||
reg */
|
||||
#define XEMACPS_RXQ1BASE_OFFSET 0x00000480U /**< RX Q1 Base address
|
||||
reg */
|
||||
#define XEMACPS_MSBBUF_TXQBASE_OFFSET 0x000004C8U /**< MSB Buffer TX Q Base
|
||||
reg */
|
||||
#define XEMACPS_MSBBUF_RXQBASE_OFFSET 0x000004D4U /**< MSB Buffer RX Q Base
|
||||
reg */
|
||||
#define XEMACPS_INTQ1_IER_OFFSET 0x00000600U /**< Interrupt Q1 Enable
|
||||
reg */
|
||||
#define XEMACPS_INTQ1_IDR_OFFSET 0x00000620U /**< Interrupt Q1 Disable
|
||||
reg */
|
||||
#define XEMACPS_INTQ1_IMR_OFFSET 0x00000640U /**< Interrupt Q1 Mask
|
||||
reg */
|
||||
|
||||
/* Define some bit positions for registers. */
|
||||
|
||||
/** @name network control register bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_NWCTRL_FLUSH_DPRAM_MASK 0x00040000U /**< Flush a packet from
|
||||
Rx SRAM */
|
||||
#define XEMACPS_NWCTRL_ZEROPAUSETX_MASK 0x00000800U /**< Transmit zero quantum
|
||||
pause frame */
|
||||
#define XEMACPS_NWCTRL_PAUSETX_MASK 0x00000800U /**< Transmit pause frame */
|
||||
#define XEMACPS_NWCTRL_HALTTX_MASK 0x00000400U /**< Halt transmission
|
||||
after current frame */
|
||||
#define XEMACPS_NWCTRL_STARTTX_MASK 0x00000200U /**< Start tx (tx_go) */
|
||||
|
||||
#define XEMACPS_NWCTRL_STATWEN_MASK 0x00000080U /**< Enable writing to
|
||||
stat counters */
|
||||
#define XEMACPS_NWCTRL_STATINC_MASK 0x00000040U /**< Increment statistic
|
||||
registers */
|
||||
#define XEMACPS_NWCTRL_STATCLR_MASK 0x00000020U /**< Clear statistic
|
||||
registers */
|
||||
#define XEMACPS_NWCTRL_MDEN_MASK 0x00000010U /**< Enable MDIO port */
|
||||
#define XEMACPS_NWCTRL_TXEN_MASK 0x00000008U /**< Enable transmit */
|
||||
#define XEMACPS_NWCTRL_RXEN_MASK 0x00000004U /**< Enable receive */
|
||||
#define XEMACPS_NWCTRL_LOOPEN_MASK 0x00000002U /**< local loopback */
|
||||
/*@}*/
|
||||
|
||||
/** @name network configuration register bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_NWCFG_BADPREAMBEN_MASK 0x20000000U /**< disable rejection of
|
||||
non-standard preamble */
|
||||
#define XEMACPS_NWCFG_IPDSTRETCH_MASK 0x10000000U /**< enable transmit IPG */
|
||||
#define XEMACPS_NWCFG_SGMIIEN_MASK 0x08000000U /**< SGMII Enable */
|
||||
#define XEMACPS_NWCFG_FCSIGNORE_MASK 0x04000000U /**< disable rejection of
|
||||
FCS error */
|
||||
#define XEMACPS_NWCFG_HDRXEN_MASK 0x02000000U /**< RX half duplex */
|
||||
#define XEMACPS_NWCFG_RXCHKSUMEN_MASK 0x01000000U /**< enable RX checksum
|
||||
offload */
|
||||
#define XEMACPS_NWCFG_PAUSECOPYDI_MASK 0x00800000U /**< Do not copy pause
|
||||
Frames to memory */
|
||||
#define XEMACPS_NWCFG_DWIDTH_64_MASK 0x00200000U /**< 64 bit Data bus width */
|
||||
#define XEMACPS_NWCFG_MDC_SHIFT_MASK 18U /**< shift bits for MDC */
|
||||
#define XEMACPS_NWCFG_MDCCLKDIV_MASK 0x001C0000U /**< MDC Mask PCLK divisor */
|
||||
#define XEMACPS_NWCFG_FCSREM_MASK 0x00020000U /**< Discard FCS from
|
||||
received frames */
|
||||
#define XEMACPS_NWCFG_LENERRDSCRD_MASK 0x00010000U
|
||||
/**< RX length error discard */
|
||||
#define XEMACPS_NWCFG_RXOFFS_MASK 0x0000C000U /**< RX buffer offset */
|
||||
#define XEMACPS_NWCFG_PAUSEEN_MASK 0x00002000U /**< Enable pause RX */
|
||||
#define XEMACPS_NWCFG_RETRYTESTEN_MASK 0x00001000U /**< Retry test */
|
||||
#define XEMACPS_NWCFG_XTADDMACHEN_MASK 0x00000200U
|
||||
/**< External address match enable */
|
||||
#define XEMACPS_NWCFG_PCSSEL_MASK 0x00000800U /**< PCS Select */
|
||||
#define XEMACPS_NWCFG_1000_MASK 0x00000400U /**< 1000 Mbps */
|
||||
#define XEMACPS_NWCFG_1536RXEN_MASK 0x00000100U /**< Enable 1536 byte
|
||||
frames reception */
|
||||
#define XEMACPS_NWCFG_UCASTHASHEN_MASK 0x00000080U /**< Receive unicast hash
|
||||
frames */
|
||||
#define XEMACPS_NWCFG_MCASTHASHEN_MASK 0x00000040U /**< Receive multicast hash
|
||||
frames */
|
||||
#define XEMACPS_NWCFG_BCASTDI_MASK 0x00000020U /**< Do not receive
|
||||
broadcast frames */
|
||||
#define XEMACPS_NWCFG_COPYALLEN_MASK 0x00000010U /**< Copy all frames */
|
||||
#define XEMACPS_NWCFG_JUMBO_MASK 0x00000008U /**< Jumbo frames */
|
||||
#define XEMACPS_NWCFG_NVLANDISC_MASK 0x00000004U /**< Receive only VLAN
|
||||
frames */
|
||||
#define XEMACPS_NWCFG_FDEN_MASK 0x00000002U/**< full duplex */
|
||||
#define XEMACPS_NWCFG_100_MASK 0x00000001U /**< 100 Mbps */
|
||||
#define XEMACPS_NWCFG_RESET_MASK 0x00080000U/**< reset value */
|
||||
/*@}*/
|
||||
|
||||
/** @name network status register bit definitaions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_NWSR_MDIOIDLE_MASK 0x00000004U /**< PHY management idle */
|
||||
#define XEMACPS_NWSR_MDIO_MASK 0x00000002U /**< Status of mdio_in */
|
||||
/*@}*/
|
||||
|
||||
|
||||
/** @name MAC address register word 1 mask
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_LADDR_MACH_MASK 0x0000FFFFU /**< Address bits[47:32]
|
||||
bit[31:0] are in BOTTOM */
|
||||
/*@}*/
|
||||
|
||||
|
||||
/** @name DMA control register bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_DMACR_ADDR_WIDTH_64 0x40000000U /**< 64 bit address bus */
|
||||
#define XEMACPS_DMACR_TXEXTEND_MASK 0x20000000U /**< Tx Extended desc mode */
|
||||
#define XEMACPS_DMACR_RXEXTEND_MASK 0x10000000U /**< Rx Extended desc mode */
|
||||
#define XEMACPS_DMACR_RXBUF_MASK 0x00FF0000U /**< Mask bit for RX buffer
|
||||
size */
|
||||
#define XEMACPS_DMACR_RXBUF_SHIFT 16U /**< Shift bit for RX buffer
|
||||
size */
|
||||
#define XEMACPS_DMACR_TCPCKSUM_MASK 0x00000800U /**< enable/disable TX
|
||||
checksum offload */
|
||||
#define XEMACPS_DMACR_TXSIZE_MASK 0x00000400U /**< TX buffer memory size */
|
||||
#define XEMACPS_DMACR_RXSIZE_MASK 0x00000300U /**< RX buffer memory size */
|
||||
#define XEMACPS_DMACR_ENDIAN_MASK 0x00000080U /**< endian configuration */
|
||||
#define XEMACPS_DMACR_BLENGTH_MASK 0x0000001FU /**< buffer burst length */
|
||||
#define XEMACPS_DMACR_SINGLE_AHB_BURST 0x00000001U /**< single AHB bursts */
|
||||
#define XEMACPS_DMACR_INCR4_AHB_BURST 0x00000004U /**< 4 bytes AHB bursts */
|
||||
#define XEMACPS_DMACR_INCR8_AHB_BURST 0x00000008U /**< 8 bytes AHB bursts */
|
||||
#define XEMACPS_DMACR_INCR16_AHB_BURST 0x00000010U /**< 16 bytes AHB bursts */
|
||||
/*@}*/
|
||||
|
||||
/** @name transmit status register bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_TXSR_HRESPNOK_MASK 0x00000100U /**< Transmit hresp not OK */
|
||||
#define XEMACPS_TXSR_URUN_MASK 0x00000040U /**< Transmit underrun */
|
||||
#define XEMACPS_TXSR_TXCOMPL_MASK 0x00000020U /**< Transmit completed OK */
|
||||
#define XEMACPS_TXSR_BUFEXH_MASK 0x00000010U /**< Transmit buffs exhausted
|
||||
mid frame */
|
||||
#define XEMACPS_TXSR_TXGO_MASK 0x00000008U /**< Status of go flag */
|
||||
#define XEMACPS_TXSR_RXOVR_MASK 0x00000004U /**< Retry limit exceeded */
|
||||
#define XEMACPS_TXSR_FRAMERX_MASK 0x00000002U /**< Collision tx frame */
|
||||
#define XEMACPS_TXSR_USEDREAD_MASK 0x00000001U /**< TX buffer used bit set */
|
||||
|
||||
#define XEMACPS_TXSR_ERROR_MASK ((u32)XEMACPS_TXSR_HRESPNOK_MASK | \
|
||||
(u32)XEMACPS_TXSR_URUN_MASK | \
|
||||
(u32)XEMACPS_TXSR_BUFEXH_MASK | \
|
||||
(u32)XEMACPS_TXSR_RXOVR_MASK | \
|
||||
(u32)XEMACPS_TXSR_FRAMERX_MASK | \
|
||||
(u32)XEMACPS_TXSR_USEDREAD_MASK)
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name receive status register bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_RXSR_HRESPNOK_MASK 0x00000008U /**< Receive hresp not OK */
|
||||
#define XEMACPS_RXSR_RXOVR_MASK 0x00000004U /**< Receive overrun */
|
||||
#define XEMACPS_RXSR_FRAMERX_MASK 0x00000002U /**< Frame received OK */
|
||||
#define XEMACPS_RXSR_BUFFNA_MASK 0x00000001U /**< RX buffer used bit set */
|
||||
|
||||
#define XEMACPS_RXSR_ERROR_MASK ((u32)XEMACPS_RXSR_HRESPNOK_MASK | \
|
||||
(u32)XEMACPS_RXSR_RXOVR_MASK | \
|
||||
(u32)XEMACPS_RXSR_BUFFNA_MASK)
|
||||
|
||||
#define XEMACPS_SR_ALL_MASK 0xFFFFFFFFU /**< Mask for full register */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name PCS control register bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_PCS_CON_AUTO_NEG_MASK 0x00001000U /**< Auto-negotiation */
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name PCS status register bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_PCS_STATUS_LINK_STATUS_MASK 0x00000004U /**< Link status */
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name Interrupt Q1 status register bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_INTQ1SR_TXCOMPL_MASK 0x00000080U /**< Transmit completed OK */
|
||||
#define XEMACPS_INTQ1SR_TXERR_MASK 0x00000040U /**< Transmit AMBA Error */
|
||||
|
||||
#define XEMACPS_INTQ1_IXR_ALL_MASK ((u32)XEMACPS_INTQ1SR_TXCOMPL_MASK | \
|
||||
(u32)XEMACPS_INTQ1SR_TXERR_MASK)
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name interrupts bit definitions
|
||||
* Bits definitions are same in XEMACPS_ISR_OFFSET,
|
||||
* XEMACPS_IER_OFFSET, XEMACPS_IDR_OFFSET, and XEMACPS_IMR_OFFSET
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_IXR_PTPPSTX_MASK 0x02000000U /**< PTP Pdelay_resp TXed */
|
||||
#define XEMACPS_IXR_PTPPDRTX_MASK 0x01000000U /**< PTP Pdelay_req TXed */
|
||||
#define XEMACPS_IXR_PTPPSRX_MASK 0x00800000U /**< PTP Pdelay_resp RXed */
|
||||
#define XEMACPS_IXR_PTPPDRRX_MASK 0x00400000U /**< PTP Pdelay_req RXed */
|
||||
|
||||
#define XEMACPS_IXR_PTPSTX_MASK 0x00200000U /**< PTP Sync TXed */
|
||||
#define XEMACPS_IXR_PTPDRTX_MASK 0x00100000U /**< PTP Delay_req TXed */
|
||||
#define XEMACPS_IXR_PTPSRX_MASK 0x00080000U /**< PTP Sync RXed */
|
||||
#define XEMACPS_IXR_PTPDRRX_MASK 0x00040000U /**< PTP Delay_req RXed */
|
||||
|
||||
#define XEMACPS_IXR_PAUSETX_MASK 0x00004000U /**< Pause frame transmitted */
|
||||
#define XEMACPS_IXR_PAUSEZERO_MASK 0x00002000U /**< Pause time has reached
|
||||
zero */
|
||||
#define XEMACPS_IXR_PAUSENZERO_MASK 0x00001000U /**< Pause frame received */
|
||||
#define XEMACPS_IXR_HRESPNOK_MASK 0x00000800U /**< hresp not ok */
|
||||
#define XEMACPS_IXR_RXOVR_MASK 0x00000400U /**< Receive overrun occurred */
|
||||
#define XEMACPS_IXR_TXCOMPL_MASK 0x00000080U /**< Frame transmitted ok */
|
||||
#define XEMACPS_IXR_TXEXH_MASK 0x00000040U /**< Transmit err occurred or
|
||||
no buffers*/
|
||||
#define XEMACPS_IXR_RETRY_MASK 0x00000020U /**< Retry limit exceeded */
|
||||
#define XEMACPS_IXR_URUN_MASK 0x00000010U /**< Transmit underrun */
|
||||
#define XEMACPS_IXR_TXUSED_MASK 0x00000008U /**< Tx buffer used bit read */
|
||||
#define XEMACPS_IXR_RXUSED_MASK 0x00000004U /**< Rx buffer used bit read */
|
||||
#define XEMACPS_IXR_FRAMERX_MASK 0x00000002U /**< Frame received ok */
|
||||
#define XEMACPS_IXR_MGMNT_MASK 0x00000001U /**< PHY management complete */
|
||||
#define XEMACPS_IXR_ALL_MASK 0x00007FFFU /**< Everything! */
|
||||
|
||||
#define XEMACPS_IXR_TX_ERR_MASK ((u32)XEMACPS_IXR_TXEXH_MASK | \
|
||||
(u32)XEMACPS_IXR_RETRY_MASK | \
|
||||
(u32)XEMACPS_IXR_URUN_MASK)
|
||||
|
||||
|
||||
#define XEMACPS_IXR_RX_ERR_MASK ((u32)XEMACPS_IXR_HRESPNOK_MASK | \
|
||||
(u32)XEMACPS_IXR_RXUSED_MASK | \
|
||||
(u32)XEMACPS_IXR_RXOVR_MASK)
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** @name PHY Maintenance bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_PHYMNTNC_OP_MASK 0x40020000U /**< operation mask bits */
|
||||
#define XEMACPS_PHYMNTNC_OP_R_MASK 0x20000000U /**< read operation */
|
||||
#define XEMACPS_PHYMNTNC_OP_W_MASK 0x10000000U /**< write operation */
|
||||
#define XEMACPS_PHYMNTNC_ADDR_MASK 0x0F800000U /**< Address bits */
|
||||
#define XEMACPS_PHYMNTNC_REG_MASK 0x007C0000U /**< register bits */
|
||||
#define XEMACPS_PHYMNTNC_DATA_MASK 0x00000FFFU /**< data bits */
|
||||
#define XEMACPS_PHYMNTNC_PHAD_SHFT_MSK 23U /**< Shift bits for PHYAD */
|
||||
#define XEMACPS_PHYMNTNC_PREG_SHFT_MSK 18U /**< Shift bits for PHREG */
|
||||
/*@}*/
|
||||
|
||||
/** @name RX watermark bit definitions
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_RXWM_HIGH_MASK 0x0000FFFFU /**< RXWM high mask */
|
||||
#define XEMACPS_RXWM_LOW_MASK 0xFFFF0000U /**< RXWM low mask */
|
||||
#define XEMACPS_RXWM_LOW_SHFT_MSK 16U /**< Shift for RXWM low */
|
||||
/*@}*/
|
||||
|
||||
/* Transmit buffer descriptor status words offset
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_BD_ADDR_OFFSET 0x00000000U /**< word 0/addr of BDs */
|
||||
#define XEMACPS_BD_STAT_OFFSET 0x00000004U /**< word 1/status of BDs */
|
||||
#define XEMACPS_BD_ADDR_HI_OFFSET 0x00000008U /**< word 2/addr of BDs */
|
||||
|
||||
/*
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Transmit buffer descriptor status words bit positions.
|
||||
* Transmit buffer descriptor consists of two 32-bit registers,
|
||||
* the first - word0 contains a 32-bit address pointing to the location of
|
||||
* the transmit data.
|
||||
* The following register - word1, consists of various information to control
|
||||
* the XEmacPs transmit process. After transmit, this is updated with status
|
||||
* information, whether the frame was transmitted OK or why it had failed.
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_TXBUF_USED_MASK 0x80000000U /**< Used bit. */
|
||||
#define XEMACPS_TXBUF_WRAP_MASK 0x40000000U /**< Wrap bit, last descriptor */
|
||||
#define XEMACPS_TXBUF_RETRY_MASK 0x20000000U /**< Retry limit exceeded */
|
||||
#define XEMACPS_TXBUF_URUN_MASK 0x10000000U /**< Transmit underrun occurred */
|
||||
#define XEMACPS_TXBUF_EXH_MASK 0x08000000U /**< Buffers exhausted */
|
||||
#define XEMACPS_TXBUF_TCP_MASK 0x04000000U /**< Late collision. */
|
||||
#define XEMACPS_TXBUF_NOCRC_MASK 0x00010000U /**< No CRC */
|
||||
#define XEMACPS_TXBUF_LAST_MASK 0x00008000U /**< Last buffer */
|
||||
#define XEMACPS_TXBUF_LEN_MASK 0x00003FFFU /**< Mask for length field */
|
||||
/*
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Receive buffer descriptor status words bit positions.
|
||||
* Receive buffer descriptor consists of two 32-bit registers,
|
||||
* the first - word0 contains a 32-bit word aligned address pointing to the
|
||||
* address of the buffer. The lower two bits make up the wrap bit indicating
|
||||
* the last descriptor and the ownership bit to indicate it has been used by
|
||||
* the XEmacPs.
|
||||
* The following register - word1, contains status information regarding why
|
||||
* the frame was received (the filter match condition) as well as other
|
||||
* useful info.
|
||||
* @{
|
||||
*/
|
||||
#define XEMACPS_RXBUF_BCAST_MASK 0x80000000U /**< Broadcast frame */
|
||||
#define XEMACPS_RXBUF_MULTIHASH_MASK 0x40000000U /**< Multicast hashed frame */
|
||||
#define XEMACPS_RXBUF_UNIHASH_MASK 0x20000000U /**< Unicast hashed frame */
|
||||
#define XEMACPS_RXBUF_EXH_MASK 0x08000000U /**< buffer exhausted */
|
||||
#define XEMACPS_RXBUF_AMATCH_MASK 0x06000000U /**< Specific address
|
||||
matched */
|
||||
#define XEMACPS_RXBUF_IDFOUND_MASK 0x01000000U /**< Type ID matched */
|
||||
#define XEMACPS_RXBUF_IDMATCH_MASK 0x00C00000U /**< ID matched mask */
|
||||
#define XEMACPS_RXBUF_VLAN_MASK 0x00200000U /**< VLAN tagged */
|
||||
#define XEMACPS_RXBUF_PRI_MASK 0x00100000U /**< Priority tagged */
|
||||
#define XEMACPS_RXBUF_VPRI_MASK 0x000E0000U /**< Vlan priority */
|
||||
#define XEMACPS_RXBUF_CFI_MASK 0x00010000U /**< CFI frame */
|
||||
#define XEMACPS_RXBUF_EOF_MASK 0x00008000U /**< End of frame. */
|
||||
#define XEMACPS_RXBUF_SOF_MASK 0x00004000U /**< Start of frame. */
|
||||
#define XEMACPS_RXBUF_LEN_MASK 0x00001FFFU /**< Mask for length field */
|
||||
#define XEMACPS_RXBUF_LEN_JUMBO_MASK 0x00003FFFU /**< Mask for jumbo length */
|
||||
|
||||
#define XEMACPS_RXBUF_WRAP_MASK 0x00000002U /**< Wrap bit, last BD */
|
||||
#define XEMACPS_RXBUF_NEW_MASK 0x00000001U /**< Used bit.. */
|
||||
#define XEMACPS_RXBUF_ADD_MASK 0xFFFFFFFCU /**< Mask for address */
|
||||
/*
|
||||
* @}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define appropriate I/O access method to memory mapped I/O or other
|
||||
* interface if necessary.
|
||||
*/
|
||||
|
||||
#define XEmacPs_In32 Xil_In32
|
||||
#define XEmacPs_Out32 Xil_Out32
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given register.
|
||||
*
|
||||
* @param BaseAddress is the base address of the device
|
||||
* @param RegOffset is the register offset to be read
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XEmacPs_ReadReg(u32 BaseAddress, u32 RegOffset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_ReadReg(BaseAddress, RegOffset) \
|
||||
XEmacPs_In32((BaseAddress) + (u32)(RegOffset))
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write the given register.
|
||||
*
|
||||
* @param BaseAddress is the base address of the device
|
||||
* @param RegOffset is the register offset to be written
|
||||
* @param Data is the 32-bit value to write to the register
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XEmacPs_WriteReg(u32 BaseAddress, u32 RegOffset,
|
||||
* u32 Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XEmacPs_WriteReg(BaseAddress, RegOffset, Data) \
|
||||
XEmacPs_Out32((BaseAddress) + (u32)(RegOffset), (u32)(Data))
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
/*
|
||||
* Perform reset operation to the emacps interface
|
||||
*/
|
||||
void XEmacPs_ResetHw(u32 BaseAddr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
242
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_intr.c
Normal file
242
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_intr.c
Normal file
@ -0,0 +1,242 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xemacps_intr.c
|
||||
* @addtogroup emacps_v3_16
|
||||
* @{
|
||||
*
|
||||
* Functions in this file implement general purpose interrupt processing related
|
||||
* functionality. See xemacps.h for a detailed description of the driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.00a wsy 01/10/10 First release
|
||||
* 1.03a asa 01/24/13 Fix for CR #692702 which updates error handling for
|
||||
* Rx errors. Under heavy Rx traffic, there will be a large
|
||||
* number of errors related to receive buffer not available.
|
||||
* Because of a HW bug (SI #692601), under such heavy errors,
|
||||
* the Rx data path can become unresponsive. To reduce the
|
||||
* probabilities for hitting this HW bug, the SW writes to
|
||||
* bit 18 to flush a packet from Rx DPRAM immediately. The
|
||||
* changes for it are done in the function
|
||||
* XEmacPs_IntrHandler.
|
||||
* 2.1 srt 07/15/14 Add support for Zynq Ultrascale Mp GEM specification
|
||||
* and 64-bit changes.
|
||||
* 3.0 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.1 hk 07/27/15 Do not call error handler with '0' error code when
|
||||
* there is no error. CR# 869403
|
||||
* </pre>
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xemacps.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Install an asynchronous handler function for the given HandlerType:
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param HandlerType indicates what interrupt handler type is.
|
||||
* XEMACPS_HANDLER_DMASEND, XEMACPS_HANDLER_DMARECV and
|
||||
* XEMACPS_HANDLER_ERROR.
|
||||
* @param FuncPointer is the pointer to the callback function
|
||||
* @param CallBackRef is the upper layer callback reference passed back when
|
||||
* when the callback function is invoked.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* None.
|
||||
*
|
||||
* @note
|
||||
* There is no assert on the CallBackRef since the driver doesn't know what
|
||||
* it is.
|
||||
*
|
||||
*****************************************************************************/
|
||||
LONG XEmacPs_SetHandler(XEmacPs *InstancePtr, u32 HandlerType,
|
||||
void *FuncPointer, void *CallBackRef)
|
||||
{
|
||||
LONG Status;
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(FuncPointer != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == (u32)XIL_COMPONENT_IS_READY);
|
||||
|
||||
switch (HandlerType) {
|
||||
case XEMACPS_HANDLER_DMASEND:
|
||||
Status = (LONG)(XST_SUCCESS);
|
||||
InstancePtr->SendHandler = ((XEmacPs_Handler)(void *)FuncPointer);
|
||||
InstancePtr->SendRef = CallBackRef;
|
||||
break;
|
||||
case XEMACPS_HANDLER_DMARECV:
|
||||
Status = (LONG)(XST_SUCCESS);
|
||||
InstancePtr->RecvHandler = ((XEmacPs_Handler)(void *)FuncPointer);
|
||||
InstancePtr->RecvRef = CallBackRef;
|
||||
break;
|
||||
case XEMACPS_HANDLER_ERROR:
|
||||
Status = (LONG)(XST_SUCCESS);
|
||||
InstancePtr->ErrorHandler = ((XEmacPs_ErrHandler)(void *)FuncPointer);
|
||||
InstancePtr->ErrorRef = CallBackRef;
|
||||
break;
|
||||
default:
|
||||
Status = (LONG)(XST_INVALID_PARAM);
|
||||
break;
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Master interrupt handler for EMAC driver. This routine will query the
|
||||
* status of the device, bump statistics, and invoke user callbacks.
|
||||
*
|
||||
* This routine must be connected to an interrupt controller using OS/BSP
|
||||
* specific methods.
|
||||
*
|
||||
* @param XEmacPsPtr is a pointer to the XEMACPS instance that has caused the
|
||||
* interrupt.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XEmacPs_IntrHandler(void *XEmacPsPtr)
|
||||
{
|
||||
u32 RegISR;
|
||||
u32 RegSR;
|
||||
u32 RegCtrl;
|
||||
u32 RegQ1ISR = 0U;
|
||||
XEmacPs *InstancePtr = (XEmacPs *) XEmacPsPtr;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == (u32)XIL_COMPONENT_IS_READY);
|
||||
|
||||
/* This ISR will try to handle as many interrupts as it can in a single
|
||||
* call. However, in most of the places where the user's error handler
|
||||
* is called, this ISR exits because it is expected that the user will
|
||||
* reset the device in nearly all instances.
|
||||
*/
|
||||
RegISR = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_ISR_OFFSET);
|
||||
|
||||
/* Read Transmit Q1 ISR */
|
||||
|
||||
if (InstancePtr->Version > 2)
|
||||
RegQ1ISR = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_INTQ1_STS_OFFSET);
|
||||
|
||||
/* Clear the interrupt status register */
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress, XEMACPS_ISR_OFFSET,
|
||||
RegISR);
|
||||
|
||||
/* Receive complete interrupt */
|
||||
if ((RegISR & XEMACPS_IXR_FRAMERX_MASK) != 0x00000000U) {
|
||||
/* Clear RX status register RX complete indication but preserve
|
||||
* error bits if there is any */
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_RXSR_OFFSET,
|
||||
((u32)XEMACPS_RXSR_FRAMERX_MASK |
|
||||
(u32)XEMACPS_RXSR_BUFFNA_MASK));
|
||||
InstancePtr->RecvHandler(InstancePtr->RecvRef);
|
||||
}
|
||||
|
||||
/* Transmit Q1 complete interrupt */
|
||||
if ((InstancePtr->Version > 2) &&
|
||||
((RegQ1ISR & XEMACPS_INTQ1SR_TXCOMPL_MASK) != 0x00000000U)) {
|
||||
/* Clear TX status register TX complete indication but preserve
|
||||
* error bits if there is any */
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_INTQ1_STS_OFFSET,
|
||||
XEMACPS_INTQ1SR_TXCOMPL_MASK);
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_TXSR_OFFSET,
|
||||
((u32)XEMACPS_TXSR_TXCOMPL_MASK |
|
||||
(u32)XEMACPS_TXSR_USEDREAD_MASK));
|
||||
InstancePtr->SendHandler(InstancePtr->SendRef);
|
||||
}
|
||||
|
||||
/* Transmit complete interrupt */
|
||||
if ((RegISR & XEMACPS_IXR_TXCOMPL_MASK) != 0x00000000U) {
|
||||
/* Clear TX status register TX complete indication but preserve
|
||||
* error bits if there is any */
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_TXSR_OFFSET,
|
||||
((u32)XEMACPS_TXSR_TXCOMPL_MASK |
|
||||
(u32)XEMACPS_TXSR_USEDREAD_MASK));
|
||||
InstancePtr->SendHandler(InstancePtr->SendRef);
|
||||
}
|
||||
|
||||
/* Receive error conditions interrupt */
|
||||
if ((RegISR & XEMACPS_IXR_RX_ERR_MASK) != 0x00000000U) {
|
||||
/* Clear RX status register */
|
||||
RegSR = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_RXSR_OFFSET);
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_RXSR_OFFSET, RegSR);
|
||||
|
||||
/* Fix for CR # 692702. Write to bit 18 of net_ctrl
|
||||
* register to flush a packet out of Rx SRAM upon
|
||||
* an error for receive buffer not available. */
|
||||
if ((RegISR & XEMACPS_IXR_RXUSED_MASK) != 0x00000000U) {
|
||||
RegCtrl =
|
||||
XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET);
|
||||
RegCtrl |= (u32)XEMACPS_NWCTRL_FLUSH_DPRAM_MASK;
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_NWCTRL_OFFSET, RegCtrl);
|
||||
}
|
||||
|
||||
if(RegSR != 0) {
|
||||
InstancePtr->ErrorHandler(InstancePtr->ErrorRef,
|
||||
XEMACPS_RECV, RegSR);
|
||||
}
|
||||
}
|
||||
|
||||
/* When XEMACPS_IXR_TXCOMPL_MASK is flagged, XEMACPS_IXR_TXUSED_MASK
|
||||
* will be asserted the same time.
|
||||
* Have to distinguish this bit to handle the real error condition.
|
||||
*/
|
||||
/* Transmit Q1 error conditions interrupt */
|
||||
if ((InstancePtr->Version > 2) &&
|
||||
((RegQ1ISR & XEMACPS_INTQ1SR_TXERR_MASK) != 0x00000000U) &&
|
||||
((RegQ1ISR & XEMACPS_INTQ1SR_TXCOMPL_MASK) != 0x00000000U)) {
|
||||
/* Clear Interrupt Q1 status register */
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_INTQ1_STS_OFFSET, RegQ1ISR);
|
||||
InstancePtr->ErrorHandler(InstancePtr->ErrorRef, XEMACPS_SEND,
|
||||
RegQ1ISR);
|
||||
}
|
||||
|
||||
/* Transmit error conditions interrupt */
|
||||
if (((RegISR & XEMACPS_IXR_TX_ERR_MASK) != 0x00000000U) &&
|
||||
(!(RegISR & XEMACPS_IXR_TXCOMPL_MASK) != 0x00000000U)) {
|
||||
/* Clear TX status register */
|
||||
RegSR = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_TXSR_OFFSET);
|
||||
XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XEMACPS_TXSR_OFFSET, RegSR);
|
||||
InstancePtr->ErrorHandler(InstancePtr->ErrorRef, XEMACPS_SEND,
|
||||
RegSR);
|
||||
}
|
||||
|
||||
}
|
||||
/** @} */
|
71
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_sinit.c
Normal file
71
bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_sinit.c
Normal file
@ -0,0 +1,71 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xemacps_sinit.c
|
||||
* @addtogroup emacps_v3_16
|
||||
* @{
|
||||
*
|
||||
* This file contains lookup method by device ID when success, it returns
|
||||
* pointer to config table to be used to initialize the device.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.00a wsy 01/10/10 New
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xemacps.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/*************************** Variable Definitions *****************************/
|
||||
extern XEmacPs_Config XEmacPs_ConfigTable[XPAR_XEMACPS_NUM_INSTANCES];
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Lookup the device configuration based on the unique device ID. The table
|
||||
* contains the configuration info for each device in the system.
|
||||
*
|
||||
* @param DeviceId is the unique device ID of the device being looked up.
|
||||
*
|
||||
* @return
|
||||
* A pointer to the configuration table entry corresponding to the given
|
||||
* device ID, or NULL if no match is found.
|
||||
*
|
||||
******************************************************************************/
|
||||
XEmacPs_Config *XEmacPs_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
XEmacPs_Config *CfgPtr = NULL;
|
||||
u32 i;
|
||||
|
||||
for (i = 0U; i < (u32)XPAR_XEMACPS_NUM_INSTANCES; i++) {
|
||||
if (XEmacPs_ConfigTable[i].DeviceId == DeviceId) {
|
||||
CfgPtr = &XEmacPs_ConfigTable[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (XEmacPs_Config *)(CfgPtr);
|
||||
}
|
||||
/** @} */
|
39
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/Makefile
Normal file
39
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/Makefile
Normal file
@ -0,0 +1,39 @@
|
||||
DRIVER_LIB_VERSION = 1.0
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
CC_FLAGS = $(COMPILER_FLAGS)
|
||||
ECC_FLAGS = $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I$(INCLUDEDIR)
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR), $(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
libs: $(OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
${COMPILER} $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) $< -o $@
|
||||
|
||||
.PHONY: include
|
||||
include: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf $(DEPFILES)
|
820
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.c
Normal file
820
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.c
Normal file
@ -0,0 +1,820 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xgpiops.c
|
||||
* @addtogroup gpiops Overview
|
||||
* @{
|
||||
*
|
||||
* The XGpioPs driver. Functions in this file are the minimum required functions
|
||||
* for this driver. See xgpiops.h for a detailed description of the driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.00a sv 01/15/10 First Release
|
||||
* 1.01a sv 04/15/12 Removed the APIs XGpioPs_SetMode, XGpioPs_SetModePin
|
||||
* XGpioPs_GetMode, XGpioPs_GetModePin as they are not
|
||||
* relevant to Zynq device. The interrupts are disabled
|
||||
* for output pins on all banks during initialization.
|
||||
* 2.1 hk 04/29/14 Use Input data register DATA_RO for read. CR# 771667.
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.1 kvn 04/13/15 Add support for Zynq Ultrascale+ MP. CR# 856980.
|
||||
* 3.1 aru 07/13/18 Resolved doxygen reported warnings. CR# 1006331.
|
||||
* 3.4 aru 08/17/18 Resolved MISRA-C mandatory violations. CR# 1007751
|
||||
* 3.5 sne 03/01/19 Fixes violations according to MISRAC-2012
|
||||
* in safety mode and modified the code such as
|
||||
* Use of mixed mode arithmetic,Declared the pointer param
|
||||
* as Pointer to const,Casting operation to a pointer,
|
||||
* Literal value requires a U suffix.
|
||||
* 3.5 sne 03/13/19 Added Versal support.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xgpiops.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
void StubHandler(void *CallBackRef, u32 Bank, u32 Status); /**< Stub handler */
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function initializes a XGpioPs instance/driver.
|
||||
* All members of the XGpioPs instance structure are initialized and
|
||||
* StubHandlers are assigned to the Bank Status Handlers.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param ConfigPtr points to the XGpioPs device configuration structure.
|
||||
* @param EffectiveAddr is the device base address in the virtual memory
|
||||
* address space. If the address translation is not used then the
|
||||
* physical address should be passed.
|
||||
* Unexpected errors may occur if the address mapping is changed
|
||||
* after this function is invoked.
|
||||
*
|
||||
* @return XST_SUCCESS always.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XGpioPs_CfgInitialize(XGpioPs *InstancePtr, const XGpioPs_Config *ConfigPtr,
|
||||
u32 EffectiveAddr)
|
||||
{
|
||||
s32 Status = (s32)0;
|
||||
u8 i;
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(ConfigPtr != NULL);
|
||||
Xil_AssertNonvoid(EffectiveAddr != (u32)0);
|
||||
/*
|
||||
* Set some default values for instance data, don't indicate the device
|
||||
* is ready to use until everything has been initialized successfully.
|
||||
*/
|
||||
InstancePtr->IsReady = 0U;
|
||||
InstancePtr->GpioConfig.BaseAddr = EffectiveAddr;
|
||||
InstancePtr->GpioConfig.DeviceId = ConfigPtr->DeviceId;
|
||||
InstancePtr->Handler = (XGpioPs_Handler)StubHandler;
|
||||
InstancePtr->Platform = XGetPlatform_Info();
|
||||
|
||||
/* Initialize the Bank data based on platform */
|
||||
if (InstancePtr->Platform == (u32)XPLAT_ZYNQ_ULTRA_MP) {
|
||||
/*
|
||||
* Max pins in the ZynqMP GPIO device
|
||||
* 0 - 25, Bank 0
|
||||
* 26 - 51, Bank 1
|
||||
* 52 - 77, Bank 2
|
||||
* 78 - 109, Bank 3
|
||||
* 110 - 141, Bank 4
|
||||
* 142 - 173, Bank 5
|
||||
*/
|
||||
InstancePtr->MaxPinNum = (u32)174;
|
||||
InstancePtr->MaxBanks = (u8)6;
|
||||
}
|
||||
else if (InstancePtr->Platform == (u32)XPLAT_VERSAL)
|
||||
{
|
||||
if(InstancePtr->PmcGpio == (u32)FALSE)
|
||||
{
|
||||
/* Max pins in the PS_GPIO devices
|
||||
* 0 -25, Bank 0
|
||||
* 26-57, Bank 3
|
||||
*/
|
||||
InstancePtr->MaxPinNum = (u32)58;
|
||||
InstancePtr->MaxBanks = (u8)4;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Max pins in the PMC_GPIO devices
|
||||
* 0 - 25,Bank 0
|
||||
* 26 - 51,Bank 1
|
||||
* 52 - 83,Bank 3
|
||||
* 84 - 115, Bank 4
|
||||
*/
|
||||
InstancePtr->MaxPinNum = (u32)116;
|
||||
InstancePtr->MaxBanks = (u8)5;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Max pins in the GPIO device
|
||||
* 0 - 31, Bank 0
|
||||
* 32 - 53, Bank 1
|
||||
* 54 - 85, Bank 2
|
||||
* 86 - 117, Bank 3
|
||||
*/
|
||||
InstancePtr->MaxPinNum = (u32)118;
|
||||
InstancePtr->MaxBanks = (u8)4;
|
||||
}
|
||||
|
||||
/*
|
||||
* By default, interrupts are not masked in GPIO. Disable
|
||||
* interrupts for all pins in all the 4 banks.
|
||||
*/
|
||||
for (i=(u8)0U;i<InstancePtr->MaxBanks;i++) {
|
||||
if (InstancePtr->Platform == XPLAT_VERSAL){
|
||||
if(InstancePtr->PmcGpio == (u32)FALSE)
|
||||
{
|
||||
if((i== (u8)XGPIOPS_ONE)||(i== (u8)XGPIOPS_TWO))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(i) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTDIS_OFFSET, 0xFFFFFFFFU);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(i==(u32)XGPIOPS_TWO)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(i) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTDIS_OFFSET, 0xFFFFFFFFU);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(i) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTDIS_OFFSET, 0xFFFFFFFFU);
|
||||
}
|
||||
}
|
||||
|
||||
/* Indicate the component is now ready to use. */
|
||||
InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the Data register of the specified GPIO bank.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
*
|
||||
* @return Current value of the Data register.
|
||||
*
|
||||
* @note This function is used for reading the state of all the GPIO pins
|
||||
* of specified bank.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XGpioPs_Read(const XGpioPs *InstancePtr, u8 Bank)
|
||||
{
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertNonvoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertNonvoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
return XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_DATA_BANK_OFFSET) +
|
||||
XGPIOPS_DATA_RO_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read Data from the specified pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number for which the data has to be read.
|
||||
*
|
||||
* @return Current value of the Pin (0 or 1).
|
||||
*
|
||||
* @note This function is used for reading the state of the specified
|
||||
* GPIO pin.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XGpioPs_ReadPin(const XGpioPs *InstancePtr, u32 Pin)
|
||||
{
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Pin < InstancePtr->MaxPinNum);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
return (XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_DATA_BANK_OFFSET) +
|
||||
XGPIOPS_DATA_RO_OFFSET) >> (u32)PinNumber) & (u32)1;
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write to the Data register of the specified GPIO bank.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
* @param Data is the value to be written to the Data register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This function is used for writing to all the GPIO pins of
|
||||
* the bank. The previous state of the pins is not maintained.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_Write(const XGpioPs *InstancePtr, u8 Bank, u32 Data)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertVoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertVoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_DATA_BANK_OFFSET) +
|
||||
XGPIOPS_DATA_OFFSET, Data);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write data to the specified pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number to which the Data is to be written.
|
||||
* @param Data is the data to be written to the specified pin (0 or 1).
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This function does a masked write to the specified pin of
|
||||
* the specified GPIO bank. The previous state of other pins
|
||||
* is maintained.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_WritePin(const XGpioPs *InstancePtr, u32 Pin, u32 Data)
|
||||
{
|
||||
u32 RegOffset;
|
||||
u32 Value;
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
u32 DataVar = Data;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Pin < InstancePtr->MaxPinNum);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
if (PinNumber > 15U) {
|
||||
/* There are only 16 data bits in bit maskable register. */
|
||||
PinNumber -= (u8)16;
|
||||
RegOffset = XGPIOPS_DATA_MSW_OFFSET;
|
||||
} else {
|
||||
RegOffset = XGPIOPS_DATA_LSW_OFFSET;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the 32 bit value to be written to the Mask/Data register where
|
||||
* the upper 16 bits is the mask and lower 16 bits is the data.
|
||||
*/
|
||||
DataVar &= (u32)0x01;
|
||||
Value = ~((u32)1 << (PinNumber + 16U)) & ((DataVar << PinNumber) | 0xFFFF0000U);
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_DATA_MASK_OFFSET) +
|
||||
RegOffset, Value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Set the Direction of the pins of the specified GPIO Bank.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
* @param Direction is the 32 bit mask of the Pin direction to be set for
|
||||
* all the pins in the Bank. Bits with 0 are set to Input mode,
|
||||
* bits with 1 are set to Output Mode.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This function is used for setting the direction of all the pins
|
||||
* in the specified bank. The previous state of the pins is
|
||||
* not maintained.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_SetDirection(const XGpioPs *InstancePtr, u8 Bank, u32 Direction)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertVoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertVoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_DIRM_OFFSET, Direction);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Set the Direction of the specified pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number to which the Data is to be written.
|
||||
* @param Direction is the direction to be set for the specified pin.
|
||||
* Valid values are 0 for Input Direction, 1 for Output Direction.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_SetDirectionPin(const XGpioPs *InstancePtr, u32 Pin, u32 Direction)
|
||||
{
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
u32 DirModeReg;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Pin < InstancePtr->MaxPinNum);
|
||||
Xil_AssertVoid(Direction <= (u32)1);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
DirModeReg = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_DIRM_OFFSET);
|
||||
|
||||
if (Direction!=(u32)0) { /* Output Direction */
|
||||
DirModeReg |= ((u32)1 << (u32)PinNumber);
|
||||
} else { /* Input Direction */
|
||||
DirModeReg &= ~ ((u32)1 << (u32)PinNumber);
|
||||
}
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_DIRM_OFFSET, DirModeReg);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the Direction of the pins of the specified GPIO Bank.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
*
|
||||
* @return Returns a 32 bit mask of the Direction register. Bits with 0 are
|
||||
* in Input mode, bits with 1 are in Output Mode.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XGpioPs_GetDirection(const XGpioPs *InstancePtr, u8 Bank)
|
||||
{
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertNonvoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertNonvoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
return XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_DIRM_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the Direction of the specified pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number for which the Direction is to be
|
||||
* retrieved.
|
||||
*
|
||||
* @return Direction of the specified pin.
|
||||
* - 0 for Input Direction
|
||||
* - 1 for Output Direction
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XGpioPs_GetDirectionPin(const XGpioPs *InstancePtr, u32 Pin)
|
||||
{
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Pin < InstancePtr->MaxPinNum);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
return (XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_DIRM_OFFSET) >> (u32)PinNumber) & (u32)1;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Set the Output Enable of the pins of the specified GPIO Bank.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
* @param OpEnable is the 32 bit mask of the Output Enables to be set for
|
||||
* all the pins in the Bank. The Output Enable of bits with 0 are
|
||||
* disabled, the Output Enable of bits with 1 are enabled.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This function is used for setting the Output Enables of all the
|
||||
* pins in the specified bank. The previous state of the Output
|
||||
* Enables is not maintained.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_SetOutputEnable(const XGpioPs *InstancePtr, u8 Bank, u32 OpEnable)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertVoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertVoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_OUTEN_OFFSET, OpEnable);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Set the Output Enable of the specified pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number to which the Data is to be written.
|
||||
* @param OpEnable specifies whether the Output Enable for the specified
|
||||
* pin should be enabled.
|
||||
* Valid values are 0 for Disabling Output Enable,
|
||||
* 1 for Enabling Output Enable.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_SetOutputEnablePin(const XGpioPs *InstancePtr, u32 Pin, u32 OpEnable)
|
||||
{
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
u32 OpEnableReg;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Pin < InstancePtr->MaxPinNum);
|
||||
Xil_AssertVoid(OpEnable <= (u32)1);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
OpEnableReg = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_OUTEN_OFFSET);
|
||||
|
||||
if (OpEnable != (u32)0) { /* Enable Output Enable */
|
||||
OpEnableReg |= ((u32)1 << (u32)PinNumber);
|
||||
} else { /* Disable Output Enable */
|
||||
OpEnableReg &= ~ ((u32)1 << (u32)PinNumber);
|
||||
}
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_OUTEN_OFFSET, OpEnableReg);
|
||||
}
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the Output Enable status of the pins of the specified GPIO Bank.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
*
|
||||
* @return Returns a a 32 bit mask of the Output Enable register.
|
||||
* Bits with 0 are in Disabled state, bits with 1 are in
|
||||
* Enabled State.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XGpioPs_GetOutputEnable(const XGpioPs *InstancePtr, u8 Bank)
|
||||
{
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertNonvoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertNonvoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
return XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_OUTEN_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the Output Enable status of the specified pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number for which the Output Enable status is to
|
||||
* be retrieved.
|
||||
*
|
||||
* @return Output Enable of the specified pin.
|
||||
* - 0 if Output Enable is disabled for this pin
|
||||
* - 1 if Output Enable is enabled for this pin
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XGpioPs_GetOutputEnablePin(const XGpioPs *InstancePtr, u32 Pin)
|
||||
{
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Pin < InstancePtr->MaxPinNum);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
return (XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_OUTEN_OFFSET) >> (u32)PinNumber) & (u32)1;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the Bank number and the Pin number in the Bank, for the given PinNumber
|
||||
* in the GPIO device.
|
||||
*
|
||||
* @param PinNumber is the Pin number in the GPIO device.
|
||||
* @param BankNumber returns the Bank in which this GPIO pin is present.
|
||||
* Valid values are 0 to XGPIOPS_MAX_BANKS - 1.
|
||||
* @param PinNumberInBank returns the Pin Number within the Bank.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifdef versal
|
||||
void XGpioPs_GetBankPin(const XGpioPs *InstancePtr,u8 PinNumber, u8 *BankNumber, u8 *PinNumberInBank)
|
||||
#else
|
||||
void XGpioPs_GetBankPin(u8 PinNumber, u8 *BankNumber, u8 *PinNumberInBank)
|
||||
#endif
|
||||
{
|
||||
u32 XGpioPsPinTable[6] = {0};
|
||||
#ifdef versal
|
||||
u8 i=(u8)0;
|
||||
#endif
|
||||
u32 Platform = XGetPlatform_Info();
|
||||
|
||||
if (Platform == (u32)XPLAT_ZYNQ_ULTRA_MP) {
|
||||
/*
|
||||
* This structure defines the mapping of the pin numbers to the banks when
|
||||
* the driver APIs are used for working on the individual pins.
|
||||
*/
|
||||
|
||||
XGpioPsPinTable[0] = (u32)25; /* 0 - 25, Bank 0 */
|
||||
XGpioPsPinTable[1] = (u32)51; /* 26 - 51, Bank 1 */
|
||||
XGpioPsPinTable[2] = (u32)77; /* 52 - 77, Bank 2 */
|
||||
XGpioPsPinTable[3] = (u32)109; /* 78 - 109, Bank 3 */
|
||||
XGpioPsPinTable[4] = (u32)141; /* 110 - 141, Bank 4 */
|
||||
XGpioPsPinTable[5] = (u32)173; /* 142 - 173 Bank 5 */
|
||||
|
||||
*BankNumber = 0U;
|
||||
while (*BankNumber < XGPIOPS_SIX) {
|
||||
if (PinNumber <= XGpioPsPinTable[*BankNumber]) {
|
||||
break;
|
||||
}
|
||||
(*BankNumber)++;
|
||||
}
|
||||
}
|
||||
#ifdef versal
|
||||
else if(Platform == XPLAT_VERSAL)
|
||||
{
|
||||
if(InstancePtr->PmcGpio == (u32)(FALSE))
|
||||
{
|
||||
XGpioPsPinTable[0] = (u32)25; /* 0 - 25, Bank 0 */
|
||||
XGpioPsPinTable[1] = (u32)57; /* 26 - 57, Bank 3 */
|
||||
*BankNumber =0U;
|
||||
if(PinNumber <= XGpioPsPinTable[*BankNumber])
|
||||
{
|
||||
*BankNumber = (u8)XGPIOPS_ZERO;
|
||||
}
|
||||
else
|
||||
{
|
||||
*BankNumber = (u8)XGPIOPS_THREE;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
XGpioPsPinTable[0] = (u32)25; /* 0 - 25, Bank 0 */
|
||||
XGpioPsPinTable[1] = (u32)51; /* 26 - 51, Bank 1 */
|
||||
XGpioPsPinTable[2] = (u32)83; /* 52 - 83, Bank 3 */
|
||||
XGpioPsPinTable[3] = (u32)115; /*84 - 115, Bank 4 */
|
||||
|
||||
*BankNumber =0U;
|
||||
while(i < XGPIOPS_FOUR)
|
||||
{
|
||||
if(i <= (u8)XGPIOPS_ONE)
|
||||
{
|
||||
if (PinNumber <= XGpioPsPinTable[i])
|
||||
{
|
||||
*BankNumber = (u8)i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PinNumber <= XGpioPsPinTable[i])
|
||||
{
|
||||
*BankNumber = (u8)i+1U;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
XGpioPsPinTable[0] = (u32)31; /* 0 - 31, Bank 0 */
|
||||
XGpioPsPinTable[1] = (u32)53; /* 32 - 53, Bank 1 */
|
||||
XGpioPsPinTable[2] = (u32)85; /* 54 - 85, Bank 2 */
|
||||
XGpioPsPinTable[3] = (u32)117; /* 86 - 117 Bank 3 */
|
||||
|
||||
*BankNumber = 0U;
|
||||
while (*BankNumber < XGPIOPS_FOUR) {
|
||||
if (PinNumber <= XGpioPsPinTable[*BankNumber]) {
|
||||
break;
|
||||
}
|
||||
(*BankNumber)++;
|
||||
}
|
||||
}
|
||||
if (*BankNumber == (u8)0) {
|
||||
*PinNumberInBank = PinNumber;
|
||||
}
|
||||
|
||||
#ifdef versal
|
||||
else if(Platform == XPLAT_VERSAL)
|
||||
{
|
||||
if(InstancePtr->PmcGpio == (u32)(FALSE))
|
||||
{
|
||||
*PinNumberInBank = (u8)((u32)PinNumber - (XGpioPsPinTable[0] + (u32)1));
|
||||
}
|
||||
else {
|
||||
if((*BankNumber ==(u8)XGPIOPS_THREE) || (*BankNumber ==(u8)XGPIOPS_FOUR))
|
||||
{
|
||||
*PinNumberInBank = (u8)((u32)PinNumber %
|
||||
(XGpioPsPinTable[*BankNumber - (u8)XGPIOPS_TWO] + (u32)1));
|
||||
}
|
||||
else
|
||||
{
|
||||
*PinNumberInBank = (u8)((u32)PinNumber %
|
||||
(XGpioPsPinTable[*BankNumber - (u8)1] + (u32)1));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
else {
|
||||
*PinNumberInBank = (u8)((u32)PinNumber %
|
||||
(XGpioPsPinTable[*BankNumber - (u8)1] + (u32)1));
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This is a stub for the status callback. The stub is here in case the upper
|
||||
* layers do not set the handler.
|
||||
*
|
||||
* @param CallBackRef is a pointer to the upper layer callback reference
|
||||
* @param Bank is the GPIO Bank in which an interrupt occurred.
|
||||
* @param Status is the Interrupt status of the GPIO bank.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void StubHandler(void *CallBackRef, u32 Bank, u32 Status)
|
||||
{
|
||||
(void) CallBackRef;
|
||||
(void) Bank;
|
||||
(void) Status;
|
||||
|
||||
Xil_AssertVoidAlways();
|
||||
}
|
||||
/** @} */
|
299
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.h
Normal file
299
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.h
Normal file
@ -0,0 +1,299 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xgpiops.h
|
||||
* @addtogroup gpiops Overview
|
||||
* @{
|
||||
* @details
|
||||
*
|
||||
* The Xilinx PS GPIO driver. This driver supports the Xilinx PS GPIO
|
||||
* Controller.
|
||||
*
|
||||
* The GPIO Controller supports the following features:
|
||||
* - 6 banks
|
||||
* - Masked writes (There are no masked reads)
|
||||
* - Bypass mode
|
||||
* - Configurable Interrupts (Level/Edge)
|
||||
*
|
||||
* This driver is intended to be RTOS and processor independent. Any needs for
|
||||
* dynamic memory management, threads or thread mutual exclusion, virtual
|
||||
* memory, or cache control must be satisfied by the layer above this driver.
|
||||
*
|
||||
* Here is GPIO Bank and Pin mapping information for different platforms.
|
||||
* Zynq:
|
||||
* PS GPIO contain 4 banks and 118 pins
|
||||
* Bank 0 MIO pins 0 - 31
|
||||
* Bank 1 MIO pins 32 - 53
|
||||
* Bank 2 MIO pins 54 - 85
|
||||
* Bank 3 EMIO signals 86 - 117
|
||||
*
|
||||
* Zynq Ultrascale+ MP:
|
||||
* PS GPIO contain 6 banks and 174 pins
|
||||
* Bank 0 MIO pins 0 - 25
|
||||
* Bank 1 MIO pins 26 - 51
|
||||
* Bank 2 MIO pins 52 - 77
|
||||
* Bank 3 EMIO signals 78 - 109
|
||||
* Bank 4 EMIO signals 110 - 141
|
||||
* Bank 5 EMIO signals 142 - 173
|
||||
|
||||
* Versal: Two GPIOPS instances PMC GPIO and PS GPIO
|
||||
* PMC GPIO contain 4 banks and 116 pins
|
||||
* Bank 0 MIO pins 0 - 25
|
||||
* Bank 1 MIO pins 26 - 51
|
||||
* Bank 3 EMIO signals 52 - 83
|
||||
* Bank 4 EMIO signals 84 - 115
|
||||
* PS GPIO contains 2 banks and 58 pins
|
||||
* Bank 0 MIO pins 0 - 25
|
||||
* Bank 3 EMIO signals 26-57
|
||||
*
|
||||
* This driver supports all the features listed above, if applicable.
|
||||
*
|
||||
* <b>Driver Description</b>
|
||||
*
|
||||
* The device driver enables higher layer software (e.g., an application) to
|
||||
* communicate to the GPIO.
|
||||
*
|
||||
* <b>Interrupts</b>
|
||||
*
|
||||
* The driver provides interrupt management functions and an interrupt handler.
|
||||
* Users of this driver need to provide callback functions. An interrupt handler
|
||||
* example is available with the driver.
|
||||
*
|
||||
* <b>Threads</b>
|
||||
*
|
||||
* This driver is not thread safe. Any needs for threads or thread mutual
|
||||
* exclusion must be satisfied by the layer above this driver.
|
||||
*
|
||||
* <b>Asserts</b>
|
||||
*
|
||||
* Asserts are used within all Xilinx drivers to enforce constraints on argument
|
||||
* values. Asserts can be turned off on a system-wide basis by defining, at
|
||||
* compile time, the NDEBUG identifier. By default, asserts are turned on and it
|
||||
* is recommended that users leave asserts on during development.
|
||||
*
|
||||
* <b>Building the driver</b>
|
||||
*
|
||||
* The XGpioPs driver is composed of several source files. This allows the user
|
||||
* to build and link only those parts of the driver that are necessary.
|
||||
* <br><br>
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.00a sv 01/15/10 First Release
|
||||
* 1.01a sv 04/15/12 Removed the APIs XGpioPs_SetMode, XGpioPs_SetModePin
|
||||
* XGpioPs_GetMode, XGpioPs_GetModePin as they are not
|
||||
* relevant to Zynq device.The interrupts are disabled
|
||||
* for output pins on all banks during initialization.
|
||||
* 1.02a hk 08/22/13 Added low level reset API
|
||||
* 2.1 hk 04/29/14 Use Input data register DATA_RO for read. CR# 771667.
|
||||
* 2.2 sk 10/13/14 Used Pin number in Bank instead of pin number
|
||||
* passed to APIs. CR# 822636
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.1 kvn 04/13/15 Add support for Zynq Ultrascale+ MP. CR# 856980.
|
||||
* ms 03/17/17 Added readme.txt file in examples folder for doxygen
|
||||
* generation.
|
||||
* ms 04/05/17 Added tabspace for return statements in functions of
|
||||
* gpiops examples for proper documentation while
|
||||
* generating doxygen.
|
||||
* 3.3 ms 04/17/17 Added notes about gpio input and output pin description
|
||||
* for zcu102 and zc702 boards in polled and interrupt
|
||||
* example, configured Interrupt pin to input pin for
|
||||
* proper functioning of interrupt example.
|
||||
* 3.4 aru 08/17/18 Resolved MISRA-C mandatory violations. CR# 1007751
|
||||
* 3.5 sne 03/01/19 Fixes violations according to MISRAC-2012
|
||||
* in safety mode and modified the code such as
|
||||
* Use of mixed mode arithmetic,Declared the pointer param
|
||||
* as Pointer to const,Casting operation to a pointer,
|
||||
* Literal value requires a U suffix.
|
||||
* 3.5 sne 03/14/19 Added Versal support.
|
||||
* 3.6 mus 04/05/19 Replaced XPLAT_versal macro with XPLAT_VERSAL, to be in
|
||||
* sync with standalone BSP
|
||||
* 3.6 sne 06/12/19 Fixed IAR compiler warning.
|
||||
* 3.6 sne 08/14/19 Added interrupt handler support on versal.
|
||||
* 3.7 sne 12/04/19 Reverted versal examples support.
|
||||
* 3.8 sne 08/28/20 Modify Makefile to support parallel make execution.
|
||||
* 3.8 sne 09/17/20 Added description for Versal PS and PMC GPIO pins.
|
||||
* 3.9 sne 03/15/21 Fixed MISRA-C violations.
|
||||
* 3.11 sg 02/23/23 Update bank and pin mapping information.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XGPIOPS_H /* prevent circular inclusions */
|
||||
#define XGPIOPS_H /**< by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xgpiops_hw.h"
|
||||
#include "xplatform_info.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Interrupt types
|
||||
* @{
|
||||
* The following constants define the interrupt types that can be set for each
|
||||
* GPIO pin.
|
||||
*/
|
||||
#define XGPIOPS_IRQ_TYPE_EDGE_RISING 0x00U /**< Interrupt on Rising edge */
|
||||
#define XGPIOPS_IRQ_TYPE_EDGE_FALLING 0x01U /**< Interrupt Falling edge */
|
||||
#define XGPIOPS_IRQ_TYPE_EDGE_BOTH 0x02U /**< Interrupt on both edges */
|
||||
#define XGPIOPS_IRQ_TYPE_LEVEL_HIGH 0x03U /**< Interrupt on high level */
|
||||
#define XGPIOPS_IRQ_TYPE_LEVEL_LOW 0x04U /**< Interrupt on low level */
|
||||
/** @}*/
|
||||
|
||||
#define XGPIOPS_BANK_MAX_PINS (u32)32 /**< Max pins in a GPIO bank */
|
||||
#define XGPIOPS_BANK0 0x00U /**< GPIO Bank 0 */
|
||||
#define XGPIOPS_BANK1 0x01U /**< GPIO Bank 1 */
|
||||
#define XGPIOPS_BANK2 0x02U /**< GPIO Bank 2 */
|
||||
#define XGPIOPS_BANK3 0x03U /**< GPIO Bank 3 */
|
||||
#define XGPIOPS_BANK4 0x04U /**< GPIO Bank 4 */
|
||||
#define XGPIOPS_BANK5 0x05U /**< GPIO Bank 5 */
|
||||
|
||||
#define XGPIOPS_MAX_BANKS_ZYNQMP 0x06U /**< Max banks in a
|
||||
* Zynq Ultrascale+ MP GPIO device
|
||||
*/
|
||||
#define XGPIOPS_MAX_BANKS 0x04U /**< Max banks in a Zynq GPIO device */
|
||||
|
||||
#define XGPIOPS_DEVICE_MAX_PIN_NUM_ZYNQMP (u32)174 /**< Max pins in the
|
||||
* Zynq Ultrascale+ MP GPIO device
|
||||
* 0 - 25, Bank 0
|
||||
* 26 - 51, Bank 1
|
||||
* 52 - 77, Bank 2
|
||||
* 78 - 109, Bank 3
|
||||
* 110 - 141, Bank 4
|
||||
* 142 - 173, Bank 5
|
||||
*/
|
||||
#define XGPIOPS_DEVICE_MAX_PIN_NUM (u32)118 /**< Max pins in the Zynq GPIO device
|
||||
* 0 - 31, Bank 0
|
||||
* 32 - 53, Bank 1
|
||||
* 54 - 85, Bank 2
|
||||
* 86 - 117, Bank 3
|
||||
*/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This handler data type allows the user to define a callback function to
|
||||
* handle the interrupts for the GPIO device. The application using this
|
||||
* driver is expected to define a handler of this type, to support interrupt
|
||||
* driven mode. The handler executes in an interrupt context such that minimal
|
||||
* processing should be performed.
|
||||
*
|
||||
* @param CallBackRef is a callback reference passed in by the upper layer
|
||||
* when setting the callback functions for a GPIO bank. It is
|
||||
* passed back to the upper layer when the callback is invoked. Its
|
||||
* type is not important to the driver component, so it is a void
|
||||
* pointer.
|
||||
* @param Bank is the bank for which the interrupt status has changed.
|
||||
* @param Status is the Interrupt status of the GPIO bank.
|
||||
*
|
||||
*****************************************************************************/
|
||||
typedef void (*XGpioPs_Handler) (void *CallBackRef, u32 Bank, u32 Status);
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for a device.
|
||||
*/
|
||||
typedef struct {
|
||||
u16 DeviceId; /**< Unique ID of device */
|
||||
UINTPTR BaseAddr; /**< Register base address */
|
||||
} XGpioPs_Config;
|
||||
|
||||
/**
|
||||
* The XGpioPs driver instance data. The user is required to allocate a
|
||||
* variable of this type for the GPIO device in the system. A pointer
|
||||
* to a variable of this type is then passed to the driver API functions.
|
||||
*/
|
||||
typedef struct {
|
||||
XGpioPs_Config GpioConfig; /**< Device configuration */
|
||||
u32 IsReady; /**< Device is initialized and ready */
|
||||
XGpioPs_Handler Handler; /**< Status handlers for all banks */
|
||||
void *CallBackRef; /**< Callback ref for bank handlers */
|
||||
u32 Platform; /**< Platform data */
|
||||
u32 MaxPinNum; /**< Max pins in the GPIO device */
|
||||
u8 MaxBanks; /**< Max banks in a GPIO device */
|
||||
u32 PmcGpio; /**< Flag for accessing PS GPIO for versal*/
|
||||
} XGpioPs;
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
extern XGpioPs_Config XGpioPs_ConfigTable[];
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/* Functions in xgpiops.c */
|
||||
s32 XGpioPs_CfgInitialize(XGpioPs *InstancePtr, const XGpioPs_Config *ConfigPtr,
|
||||
u32 EffectiveAddr);
|
||||
|
||||
/* Bank APIs in xgpiops.c */
|
||||
u32 XGpioPs_Read(const XGpioPs *InstancePtr, u8 Bank);
|
||||
void XGpioPs_Write(const XGpioPs *InstancePtr, u8 Bank, u32 Data);
|
||||
void XGpioPs_SetDirection(const XGpioPs *InstancePtr, u8 Bank, u32 Direction);
|
||||
u32 XGpioPs_GetDirection(const XGpioPs *InstancePtr, u8 Bank);
|
||||
void XGpioPs_SetOutputEnable(const XGpioPs *InstancePtr, u8 Bank, u32 OpEnable);
|
||||
u32 XGpioPs_GetOutputEnable(const XGpioPs *InstancePtr, u8 Bank);
|
||||
#ifdef versal
|
||||
void XGpioPs_GetBankPin(const XGpioPs *InstancePtr,u8 PinNumber,u8 *BankNumber, u8 *PinNumberInBank);
|
||||
#else
|
||||
void XGpioPs_GetBankPin(u8 PinNumber,u8 *BankNumber, u8 *PinNumberInBank);
|
||||
#endif
|
||||
|
||||
/* Pin APIs in xgpiops.c */
|
||||
u32 XGpioPs_ReadPin(const XGpioPs *InstancePtr, u32 Pin);
|
||||
void XGpioPs_WritePin(const XGpioPs *InstancePtr, u32 Pin, u32 Data);
|
||||
void XGpioPs_SetDirectionPin(const XGpioPs *InstancePtr, u32 Pin, u32 Direction);
|
||||
u32 XGpioPs_GetDirectionPin(const XGpioPs *InstancePtr, u32 Pin);
|
||||
void XGpioPs_SetOutputEnablePin(const XGpioPs *InstancePtr, u32 Pin, u32 OpEnable);
|
||||
u32 XGpioPs_GetOutputEnablePin(const XGpioPs *InstancePtr, u32 Pin);
|
||||
|
||||
/* Diagnostic functions in xgpiops_selftest.c */
|
||||
s32 XGpioPs_SelfTest(const XGpioPs *InstancePtr);
|
||||
|
||||
/* Functions in xgpiops_intr.c */
|
||||
/* Bank APIs in xgpiops_intr.c */
|
||||
void XGpioPs_IntrEnable(const XGpioPs *InstancePtr, u8 Bank, u32 Mask);
|
||||
void XGpioPs_IntrDisable(const XGpioPs *InstancePtr, u8 Bank, u32 Mask);
|
||||
u32 XGpioPs_IntrGetEnabled(const XGpioPs *InstancePtr, u8 Bank);
|
||||
u32 XGpioPs_IntrGetStatus(const XGpioPs *InstancePtr, u8 Bank);
|
||||
void XGpioPs_IntrClear(const XGpioPs *InstancePtr, u8 Bank, u32 Mask);
|
||||
void XGpioPs_SetIntrType(const XGpioPs *InstancePtr, u8 Bank, u32 IntrType,
|
||||
u32 IntrPolarity, u32 IntrOnAny);
|
||||
void XGpioPs_GetIntrType(const XGpioPs *InstancePtr, u8 Bank, u32 *IntrType,
|
||||
u32 *IntrPolarity, u32 *IntrOnAny);
|
||||
void XGpioPs_SetCallbackHandler(XGpioPs *InstancePtr, void *CallBackRef,
|
||||
XGpioPs_Handler FuncPointer);
|
||||
void XGpioPs_IntrHandler(const XGpioPs *InstancePtr);
|
||||
|
||||
/* Pin APIs in xgpiops_intr.c */
|
||||
void XGpioPs_SetIntrTypePin(const XGpioPs *InstancePtr, u32 Pin, u8 IrqType);
|
||||
u8 XGpioPs_GetIntrTypePin(const XGpioPs *InstancePtr, u32 Pin);
|
||||
|
||||
void XGpioPs_IntrEnablePin(const XGpioPs *InstancePtr, u32 Pin);
|
||||
void XGpioPs_IntrDisablePin(const XGpioPs *InstancePtr, u32 Pin);
|
||||
u32 XGpioPs_IntrGetEnabledPin(const XGpioPs *InstancePtr, u32 Pin);
|
||||
u32 XGpioPs_IntrGetStatusPin(const XGpioPs *InstancePtr, u32 Pin);
|
||||
void XGpioPs_IntrClearPin(const XGpioPs *InstancePtr, u32 Pin);
|
||||
|
||||
/* Functions in xgpiops_sinit.c */
|
||||
XGpioPs_Config *XGpioPs_LookupConfig(u16 DeviceId);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
53
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_g.c
Normal file
53
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_g.c
Normal file
@ -0,0 +1,53 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xgpiops_g.c
|
||||
* @addtogroup gpiops Overview
|
||||
* @{
|
||||
*
|
||||
* This file contains a configuration table that specifies the configuration
|
||||
* of GPIO devices in the system.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.00a sv 01/15/10 First Release
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xgpiops.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Prototypes ******************************/
|
||||
|
||||
/**
|
||||
* This table contains configuration information for each GPIO device
|
||||
* in the system.
|
||||
*/
|
||||
XGpioPs_Config XGpioPs_ConfigTable[XPAR_XGPIOPS_NUM_INSTANCES] = {
|
||||
{
|
||||
(u16)XPAR_XGPIOPS_0_DEVICE_ID, /* Unique ID of device */
|
||||
(u32)XPAR_XGPIOPS_0_BASEADDR /* Base address of device */
|
||||
}
|
||||
};
|
||||
/** @} */
|
241
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.c
Normal file
241
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.c
Normal file
@ -0,0 +1,241 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2013 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xgpiops_hw.c
|
||||
* @addtogroup gpiops Overview
|
||||
* @{
|
||||
*
|
||||
* This file contains low level GPIO functions.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.02a hk 08/22/13 First Release
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.1 kvn 04/13/15 Add support for Zynq Ultrascale+ MP. CR# 856980.
|
||||
* 3.5 sne 03/01/19 Fixes violations according to MISRAC-2012
|
||||
* in safety mode and modified the code such as
|
||||
* Use of mixed mode arithmetic,Declared the pointer param
|
||||
* as Pointer to const,Casting operation to a pointer,
|
||||
* Literal value requires a U suffix.
|
||||
* 3.5 sne 03/14/19 Added versal support.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xgpiops_hw.h"
|
||||
#include "xgpiops.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function resets the GPIO module by writing reset values to
|
||||
* all registers
|
||||
*
|
||||
* @param BaseAddress address of GPIO module
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XGpioPs_ResetHw(UINTPTR BaseAddress)
|
||||
{
|
||||
u32 BankCount;
|
||||
u32 Platform,MaxBanks;
|
||||
|
||||
Platform = XGetPlatform_Info();
|
||||
if (Platform == (u32)XPLAT_ZYNQ_ULTRA_MP) {
|
||||
MaxBanks = (u32)6;
|
||||
}
|
||||
else if(Platform == (u32)XPLAT_VERSAL)
|
||||
{
|
||||
if (BaseAddress == (u32)XGPIOPS_PS_GPIO_BASEADDR)
|
||||
{
|
||||
MaxBanks = (u32)4;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaxBanks = (u32)5;
|
||||
}
|
||||
}
|
||||
else {
|
||||
MaxBanks = (u32)4;
|
||||
}
|
||||
|
||||
if (Platform == (u32)XPLAT_VERSAL)
|
||||
{
|
||||
/* Write reset values to all mask data registers */
|
||||
for(BankCount = 3U; BankCount < (u32)MaxBanks; BankCount++) {
|
||||
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_DATA_MASK_OFFSET) +
|
||||
XGPIOPS_DATA_LSW_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_DATA_MASK_OFFSET) +
|
||||
XGPIOPS_DATA_MSW_OFFSET), 0x0U);
|
||||
}
|
||||
/* Write reset values to all output data registers */
|
||||
for(BankCount = 3U; BankCount < (u32)MaxBanks; BankCount++) {
|
||||
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_DATA_BANK_OFFSET) +
|
||||
XGPIOPS_DATA_OFFSET), 0x0U);
|
||||
}
|
||||
|
||||
/* Reset all registers of all GPIO banks */
|
||||
for(BankCount = 0U; BankCount < (u32)MaxBanks; BankCount++) {
|
||||
|
||||
|
||||
if((BaseAddress == (u32)XGPIOPS_PS_GPIO_BASEADDR) && ((BankCount == (u32)XGPIOPS_ONE) ||(BankCount == (u32)XGPIOPS_TWO)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((BaseAddress != (u32)XGPIOPS_PS_GPIO_BASEADDR) && (BankCount == (u32)XGPIOPS_ONE))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_DIRM_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_OUTEN_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTMASK_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTEN_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTDIS_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTSTS_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTPOL_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTANY_OFFSET), 0x0U);
|
||||
|
||||
}
|
||||
|
||||
/* Bank 0 Int type */
|
||||
XGpioPs_WriteReg(BaseAddress, XGPIOPS_INTTYPE_OFFSET,
|
||||
XGPIOPS_INTTYPE_BANK0_RESET);
|
||||
/* Bank 1 Int type */
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((u32)XGPIOPS_REG_MASK_OFFSET + (u32)XGPIOPS_INTTYPE_OFFSET),
|
||||
XGPIOPS_INTTYPE_BANK1_RESET);
|
||||
/* Bank 3 Int type */
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
(((u32)3 * XGPIOPS_REG_MASK_OFFSET) + (u32)XGPIOPS_INTTYPE_OFFSET),
|
||||
XGPIOPS_INTTYPE_BANK3_RESET);
|
||||
/* Bank 4 Int type */
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
(((u32)4 * XGPIOPS_REG_MASK_OFFSET) + (u32)XGPIOPS_INTTYPE_OFFSET),
|
||||
XGPIOPS_INTTYPE_BANK4_RESET);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Write reset values to all mask data registers */
|
||||
for(BankCount = 2U; BankCount < (u32)MaxBanks; BankCount++) {
|
||||
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_DATA_MASK_OFFSET) +
|
||||
XGPIOPS_DATA_LSW_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_DATA_MASK_OFFSET) +
|
||||
XGPIOPS_DATA_MSW_OFFSET), 0x0U);
|
||||
}
|
||||
/* Write reset values to all output data registers */
|
||||
for(BankCount = 2U; BankCount < (u32)MaxBanks; BankCount++) {
|
||||
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_DATA_BANK_OFFSET) +
|
||||
XGPIOPS_DATA_OFFSET), 0x0U);
|
||||
}
|
||||
/* Reset all registers of all GPIO banks */
|
||||
for(BankCount = 0U; BankCount < (u32)MaxBanks; BankCount++) {
|
||||
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_DIRM_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_OUTEN_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTMASK_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTEN_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTDIS_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTSTS_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTPOL_OFFSET), 0x0U);
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((BankCount * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTANY_OFFSET), 0x0U);
|
||||
}
|
||||
/* Bank 0 Int type */
|
||||
XGpioPs_WriteReg(BaseAddress, XGPIOPS_INTTYPE_OFFSET,
|
||||
XGPIOPS_INTTYPE_BANK0_RESET);
|
||||
/* Bank 1 Int type */
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
((u32)XGPIOPS_REG_MASK_OFFSET + (u32)XGPIOPS_INTTYPE_OFFSET),
|
||||
XGPIOPS_INTTYPE_BANK1_RESET);
|
||||
/* Bank 2 Int type */
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
(((u32)2 * XGPIOPS_REG_MASK_OFFSET) + (u32)XGPIOPS_INTTYPE_OFFSET),
|
||||
XGPIOPS_INTTYPE_BANK2_RESET);
|
||||
/* Bank 3 Int type */
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
(((u32)3 * XGPIOPS_REG_MASK_OFFSET) + (u32)XGPIOPS_INTTYPE_OFFSET),
|
||||
XGPIOPS_INTTYPE_BANK3_RESET);
|
||||
|
||||
if (Platform == (u32)XPLAT_ZYNQ_ULTRA_MP) {
|
||||
/* Bank 4 Int type */
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
(((u32)4 * XGPIOPS_REG_MASK_OFFSET) + (u32)XGPIOPS_INTTYPE_OFFSET),
|
||||
XGPIOPS_INTTYPE_BANK4_RESET);
|
||||
/* Bank 5 Int type */
|
||||
XGpioPs_WriteReg(BaseAddress,
|
||||
(((u32)5 * XGPIOPS_REG_MASK_OFFSET) + (u32)XGPIOPS_INTTYPE_OFFSET),
|
||||
XGPIOPS_INTTYPE_BANK5_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/** @} */
|
147
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.h
Normal file
147
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.h
Normal file
@ -0,0 +1,147 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xgpiops_hw.h
|
||||
* @addtogroup gpiops Overview
|
||||
* @{
|
||||
*
|
||||
* This header file contains the identifiers and basic driver functions (or
|
||||
* macros) that can be used to access the device. Other driver functions
|
||||
* are defined in xgpiops.h.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------
|
||||
* 1.00a sv 01/15/10 First Release
|
||||
* 1.02a hk 08/22/13 Added low level reset API function prototype and
|
||||
* related constant definitions
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.1 kvn 04/13/15 Corrected reset values of banks.
|
||||
* 3.5 sne 03/14/19 Added versal support.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XGPIOPS_HW_H /* prevent circular inclusions */
|
||||
#define XGPIOPS_HW_H /**< by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xil_io.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Register offsets for the GPIO. Each register is 32 bits.
|
||||
* @{
|
||||
*/
|
||||
#define XGPIOPS_DATA_LSW_OFFSET 0x00000000U /**< Mask and Data Register LSW, WO */
|
||||
#define XGPIOPS_DATA_MSW_OFFSET 0x00000004U /**< Mask and Data Register MSW, WO */
|
||||
#define XGPIOPS_DATA_OFFSET 0x00000040U /**< Data Register, RW */
|
||||
#define XGPIOPS_DATA_RO_OFFSET 0x00000060U /**< Data Register - Input, RO */
|
||||
#define XGPIOPS_DIRM_OFFSET 0x00000204U /**< Direction Mode Register, RW */
|
||||
#define XGPIOPS_OUTEN_OFFSET 0x00000208U /**< Output Enable Register, RW */
|
||||
#define XGPIOPS_INTMASK_OFFSET 0x0000020CU /**< Interrupt Mask Register, RO */
|
||||
#define XGPIOPS_INTEN_OFFSET 0x00000210U /**< Interrupt Enable Register, WO */
|
||||
#define XGPIOPS_INTDIS_OFFSET 0x00000214U /**< Interrupt Disable Register, WO*/
|
||||
#define XGPIOPS_INTSTS_OFFSET 0x00000218U /**< Interrupt Status Register, RO */
|
||||
#define XGPIOPS_INTTYPE_OFFSET 0x0000021CU /**< Interrupt Type Register, RW */
|
||||
#define XGPIOPS_INTPOL_OFFSET 0x00000220U /**< Interrupt Polarity Register, RW */
|
||||
#define XGPIOPS_INTANY_OFFSET 0x00000224U /**< Interrupt On Any Register, RW */
|
||||
/** @} */
|
||||
|
||||
/** @name Register offsets for each Bank.
|
||||
* @{
|
||||
*/
|
||||
#define XGPIOPS_DATA_MASK_OFFSET 0x00000008U /**< Data/Mask Registers offset */
|
||||
#define XGPIOPS_DATA_BANK_OFFSET 0x00000004U /**< Data Registers offset */
|
||||
#define XGPIOPS_REG_MASK_OFFSET 0x00000040U /**< Registers offset */
|
||||
/** @} */
|
||||
|
||||
/* For backwards compatibility */
|
||||
#define XGPIOPS_BYPM_MASK_OFFSET (u32)0x40 /**< Mask for backward support */
|
||||
|
||||
/** @name Interrupt type reset values for each bank
|
||||
* @{
|
||||
*/
|
||||
#ifdef XPAR_PSU_GPIO_0_BASEADDR
|
||||
#define XGPIOPS_INTTYPE_BANK0_RESET 0x03FFFFFFU /**< Resets specific to Zynq Ultrascale+ MP */
|
||||
#define XGPIOPS_INTTYPE_BANK1_RESET 0x03FFFFFFU /**< Resets specific to Zynq Ultrascale+ MP */
|
||||
#define XGPIOPS_INTTYPE_BANK2_RESET 0x03FFFFFFU /**< Resets specific to Zynq Ultrascale+ MP */
|
||||
#else
|
||||
#define XGPIOPS_INTTYPE_BANK0_RESET 0xFFFFFFFFU /**< Resets specific to Zynq */
|
||||
#define XGPIOPS_INTTYPE_BANK1_RESET 0x003FFFFFU /**< Resets specific to Zynq */
|
||||
#define XGPIOPS_INTTYPE_BANK2_RESET 0xFFFFFFFFU /**< Resets specific to Zynq */
|
||||
#endif
|
||||
|
||||
#define XGPIOPS_INTTYPE_BANK3_RESET 0xFFFFFFFFU /**< Reset common to both platforms */
|
||||
#define XGPIOPS_INTTYPE_BANK4_RESET 0xFFFFFFFFU /**< Resets specific to Zynq Ultrascale+ MP */
|
||||
#define XGPIOPS_INTTYPE_BANK5_RESET 0xFFFFFFFFU /**< Resets specific to Zynq Ultrascale+ MP */
|
||||
/** @} */
|
||||
#define XGPIOPS_PS_GPIO_BASEADDR 0xFF0B0000U /**< Flag for Base Address for PS_GPIO in Versal */
|
||||
#define XGPIOPS_ZERO 0U /**< Flag for 0 Value */
|
||||
#define XGPIOPS_ONE 1U /**< Flag for 1 Value */
|
||||
#define XGPIOPS_TWO 2U /**< Flag for 2 Value */
|
||||
#define XGPIOPS_THREE 3U /**< Flag for 3 Value */
|
||||
#define XGPIOPS_FOUR 4U /**< Flag for 4 Value */
|
||||
#define XGPIOPS_SIX 6U /**< Flag for 6 Value */
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro reads the given register.
|
||||
*
|
||||
* @param BaseAddr is the base address of the device.
|
||||
* @param RegOffset is the register offset to be read.
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XGpioPs_ReadReg(BaseAddr, RegOffset) \
|
||||
Xil_In32((BaseAddr) + (u32)(RegOffset))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This macro writes to the given register.
|
||||
*
|
||||
* @param BaseAddr is the base address of the device.
|
||||
* @param RegOffset is the offset of the register to be written.
|
||||
* @param Data is the 32-bit value to write to the register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XGpioPs_WriteReg(BaseAddr, RegOffset, Data) \
|
||||
Xil_Out32((BaseAddr) + (u32)(RegOffset), (u32)(Data))
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
void XGpioPs_ResetHw(UINTPTR BaseAddress);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* XGPIOPS_HW_H */
|
||||
/** @} */
|
767
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_intr.c
Normal file
767
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_intr.c
Normal file
@ -0,0 +1,767 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xgpiops_intr.c
|
||||
* @addtogroup gpiops Overview
|
||||
* @{
|
||||
*
|
||||
* This file contains functions related to GPIO interrupt handling.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.00a sv 01/18/10 First Release
|
||||
* 2.2 sk 10/13/14 Used Pin number in Bank instead of pin number
|
||||
* passed to API's. CR# 822636
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.1 kvn 04/13/15 Add support for Zynq Ultrascale+ MP. CR# 856980.
|
||||
* 3.1 aru 07/13/18 Ressolved doxygen reported warnings. CR# 1006331.
|
||||
* 3.4 aru 08/09/18 Ressolved cppcheck warnings.
|
||||
* 3.4 aru 08/17/18 Resolved MISRA-C mandatory violations. CR# 1007751
|
||||
* 3.5 sne 03/01/19 Fixes violations according to MISRAC-2012
|
||||
* in safety mode and modified the code such as
|
||||
* Use of mixed mode arithmetic,Declared the pointer param
|
||||
* as Pointer to const,Casting operation to a pointer,
|
||||
* Literal value requires a U suffix.
|
||||
* 3.5 sne 03/14/19 Added Versal support.
|
||||
* 3.5 sne 03/20/19 Fixed multiple interrupts problem CR#1024556.
|
||||
* 3.6 sne 06/12/19 Fixed IAR compiler warning.
|
||||
* 3.6 sne 08/14/19 Added interrupt handler support on versal.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xgpiops.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function enables the interrupts for the specified pins in the specified
|
||||
* bank.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
* @param Mask is the bit mask of the pins for which interrupts are to
|
||||
* be enabled. Bit positions of 1 will be enabled. Bit positions
|
||||
* of 0 will keep the previous setting.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_IntrEnable(const XGpioPs *InstancePtr, u8 Bank, u32 Mask)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertVoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertVoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTEN_OFFSET, Mask);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function enables the interrupt for the specified pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number for which the interrupt is to be enabled.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_IntrEnablePin(const XGpioPs *InstancePtr, u32 Pin)
|
||||
{
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
u32 IntrReg;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Pin < InstancePtr->MaxPinNum);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
IntrReg = ((u32)1 << (u32)PinNumber);
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTEN_OFFSET, IntrReg);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function disables the interrupts for the specified pins in the specified
|
||||
* bank.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
* @param Mask is the bit mask of the pins for which interrupts are
|
||||
* to be disabled. Bit positions of 1 will be disabled. Bit
|
||||
* positions of 0 will keep the previous setting.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_IntrDisable(const XGpioPs *InstancePtr, u8 Bank, u32 Mask)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertVoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertVoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTDIS_OFFSET, Mask);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function disables the interrupts for the specified pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number for which the interrupt is to be disabled.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_IntrDisablePin(const XGpioPs *InstancePtr, u32 Pin)
|
||||
{
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
u32 IntrReg;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Pin < InstancePtr->MaxPinNum);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
IntrReg = ((u32)1 << (u32)PinNumber);
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTDIS_OFFSET, IntrReg);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns the interrupt enable status for a bank.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
*
|
||||
* @return Enabled interrupt(s) in a 32-bit format. Bit positions with 1
|
||||
* indicate that the interrupt for that pin is enabled, bit
|
||||
* positions with 0 indicate that the interrupt for that pin is
|
||||
* disabled.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XGpioPs_IntrGetEnabled(const XGpioPs *InstancePtr, u8 Bank)
|
||||
{
|
||||
u32 IntrMask;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertNonvoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertNonvoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
IntrMask = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTMASK_OFFSET);
|
||||
return (~IntrMask);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns whether interrupts are enabled for the specified pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number for which the interrupt enable status
|
||||
* is to be known.
|
||||
*
|
||||
* @return
|
||||
* - TRUE if the interrupt is enabled.
|
||||
* - FALSE if the interrupt is disabled.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XGpioPs_IntrGetEnabledPin(const XGpioPs *InstancePtr, u32 Pin)
|
||||
{
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
u32 IntrReg;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Pin < InstancePtr->MaxPinNum);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
IntrReg = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTMASK_OFFSET);
|
||||
|
||||
return (((IntrReg & ((u32)1 << PinNumber)) != (u32)0)? (u32)FALSE : (u32)TRUE);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns interrupt status read from Interrupt Status Register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
*
|
||||
* @return The value read from Interrupt Status Register.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XGpioPs_IntrGetStatus(const XGpioPs *InstancePtr, u8 Bank)
|
||||
{
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertNonvoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertNonvoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
return XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTSTS_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns interrupt enable status of the specified pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number for which the interrupt enable status
|
||||
* is to be known.
|
||||
*
|
||||
* @return
|
||||
* - TRUE if the interrupt has occurred.
|
||||
* - FALSE if the interrupt has not occurred.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u32 XGpioPs_IntrGetStatusPin(const XGpioPs *InstancePtr, u32 Pin)
|
||||
{
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
u32 IntrReg;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Pin < InstancePtr->MaxPinNum);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
IntrReg = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTSTS_OFFSET);
|
||||
|
||||
return (((IntrReg & ((u32)1 << PinNumber)) != (u32)0)? (u32)TRUE : (u32)FALSE);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function clears pending interrupt(s) with the provided mask. This
|
||||
* function should be called after the software has serviced the interrupts
|
||||
* that are pending.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
* @param Mask is the mask of the interrupts to be cleared. Bit positions
|
||||
* of 1 will be cleared. Bit positions of 0 will not change the
|
||||
* previous interrupt status.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_IntrClear(const XGpioPs *InstancePtr, u8 Bank, u32 Mask)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertVoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertVoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Clear the currently pending interrupts. */
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTSTS_OFFSET, Mask);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function clears the specified pending interrupt. This function should be
|
||||
* called after the software has serviced the interrupts that are pending.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param Pin is the pin number for which the interrupt status is to be
|
||||
* cleared.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_IntrClearPin(const XGpioPs *InstancePtr, u32 Pin)
|
||||
{
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
u32 IntrReg;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Pin < InstancePtr->MaxPinNum);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
/* Clear the specified pending interrupts. */
|
||||
IntrReg = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTSTS_OFFSET);
|
||||
|
||||
IntrReg &= ((u32)1 << PinNumber);
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTSTS_OFFSET, IntrReg);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is used for setting the Interrupt Type, Interrupt Polarity and
|
||||
* Interrupt On Any for the specified GPIO Bank pins.
|
||||
*
|
||||
* @param InstancePtr is a pointer to an XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
* @param IntrType is the 32 bit mask of the interrupt type.
|
||||
* 0 means Level Sensitive and 1 means Edge Sensitive.
|
||||
* @param IntrPolarity is the 32 bit mask of the interrupt polarity.
|
||||
* 0 means Active Low or Falling Edge and 1 means Active High or
|
||||
* Rising Edge.
|
||||
* @param IntrOnAny is the 32 bit mask of the interrupt trigger for
|
||||
* edge triggered interrupts. 0 means trigger on single edge using
|
||||
* the configured interrupt polarity and 1 means trigger on both
|
||||
* edges.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This function is used for setting the interrupt related
|
||||
* properties of all the pins in the specified bank. The previous
|
||||
* state of the pins is not maintained.
|
||||
* To change the Interrupt properties of a single GPIO pin, use the
|
||||
* function XGpioPs_SetPinIntrType().
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_SetIntrType(const XGpioPs *InstancePtr, u8 Bank, u32 IntrType,
|
||||
u32 IntrPolarity, u32 IntrOnAny)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertVoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertVoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTTYPE_OFFSET, IntrType);
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTPOL_OFFSET, IntrPolarity);
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTANY_OFFSET, IntrOnAny);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is used for getting the Interrupt Type, Interrupt Polarity and
|
||||
* Interrupt On Any for the specified GPIO Bank pins.
|
||||
*
|
||||
* @param InstancePtr is a pointer to an XGpioPs instance.
|
||||
* @param Bank is the bank number of the GPIO to operate on.
|
||||
* @param IntrType returns the 32 bit mask of the interrupt type.
|
||||
* 0 means Level Sensitive and 1 means Edge Sensitive.
|
||||
* @param IntrPolarity returns the 32 bit mask of the interrupt
|
||||
* polarity. 0 means Active Low or Falling Edge and 1 means
|
||||
* Active High or Rising Edge.
|
||||
* @param IntrOnAny returns the 32 bit mask of the interrupt trigger for
|
||||
* edge triggered interrupts. 0 means trigger on single edge using
|
||||
* the configured interrupt polarity and 1 means trigger on both
|
||||
* edges.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_GetIntrType(const XGpioPs *InstancePtr, u8 Bank, u32 *IntrType,
|
||||
u32 *IntrPolarity, u32 *IntrOnAny)
|
||||
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Bank < InstancePtr->MaxBanks);
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
Xil_AssertVoid(Bank != XGPIOPS_TWO);
|
||||
} else {
|
||||
Xil_AssertVoid((Bank !=XGPIOPS_ONE) && (Bank !=XGPIOPS_TWO));
|
||||
}
|
||||
#endif
|
||||
|
||||
*IntrType = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTTYPE_OFFSET);
|
||||
|
||||
*IntrPolarity = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTPOL_OFFSET);
|
||||
|
||||
*IntrOnAny = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTANY_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is used for setting the IRQ Type of a single GPIO pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to an XGpioPs instance.
|
||||
* @param Pin is the pin number whose IRQ type is to be set.
|
||||
* @param IrqType is the IRQ type for GPIO Pin. Use XGPIOPS_IRQ_TYPE_*
|
||||
* defined in xgpiops.h to specify the IRQ type.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void XGpioPs_SetIntrTypePin(const XGpioPs *InstancePtr, u32 Pin, u8 IrqType)
|
||||
{
|
||||
u32 IntrTypeReg;
|
||||
u32 IntrPolReg;
|
||||
u32 IntrOnAnyReg;
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertVoid(Pin < InstancePtr->MaxPinNum);
|
||||
Xil_AssertVoid(IrqType <= XGPIOPS_IRQ_TYPE_LEVEL_LOW);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
IntrTypeReg = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTTYPE_OFFSET);
|
||||
|
||||
IntrPolReg = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTPOL_OFFSET);
|
||||
|
||||
IntrOnAnyReg = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTANY_OFFSET);
|
||||
|
||||
switch (IrqType) {
|
||||
case XGPIOPS_IRQ_TYPE_EDGE_RISING:
|
||||
IntrTypeReg |= ((u32)1 << (u32)PinNumber);
|
||||
IntrPolReg |= ((u32)1 << (u32)PinNumber);
|
||||
IntrOnAnyReg &= ~((u32)1 << (u32)PinNumber);
|
||||
break;
|
||||
case XGPIOPS_IRQ_TYPE_EDGE_FALLING:
|
||||
IntrTypeReg |= ((u32)1 << (u32)PinNumber);
|
||||
IntrPolReg &= ~((u32)1 << (u32)PinNumber);
|
||||
IntrOnAnyReg &= ~((u32)1 << (u32)PinNumber);
|
||||
break;
|
||||
case XGPIOPS_IRQ_TYPE_EDGE_BOTH:
|
||||
IntrTypeReg |= ((u32)1 << (u32)PinNumber);
|
||||
IntrOnAnyReg |= ((u32)1 << (u32)PinNumber);
|
||||
break;
|
||||
case XGPIOPS_IRQ_TYPE_LEVEL_HIGH:
|
||||
IntrTypeReg &= ~((u32)1 << (u32)PinNumber);
|
||||
IntrPolReg |= ((u32)1 << (u32)PinNumber);
|
||||
break;
|
||||
case XGPIOPS_IRQ_TYPE_LEVEL_LOW:
|
||||
IntrTypeReg &= ~((u32)1 << (u32)PinNumber);
|
||||
IntrPolReg &= ~((u32)1 << (u32)PinNumber);
|
||||
break;
|
||||
default:
|
||||
/**< Default statement is added for MISRA C compliance. */
|
||||
break;
|
||||
}
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTTYPE_OFFSET, IntrTypeReg);
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTPOL_OFFSET, IntrPolReg);
|
||||
|
||||
XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTANY_OFFSET, IntrOnAnyReg);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns the IRQ Type of a given GPIO pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to an XGpioPs instance.
|
||||
* @param Pin is the pin number whose IRQ type is to be obtained.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note Use XGPIOPS_IRQ_TYPE_* defined in xgpiops.h for the IRQ type
|
||||
* returned by this function.
|
||||
*
|
||||
*****************************************************************************/
|
||||
u8 XGpioPs_GetIntrTypePin(const XGpioPs *InstancePtr, u32 Pin)
|
||||
{
|
||||
u32 IntrType;
|
||||
u32 IntrPol;
|
||||
u32 IntrOnAny;
|
||||
u8 Bank;
|
||||
u8 PinNumber;
|
||||
u8 IrqType;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Pin < InstancePtr->MaxPinNum);
|
||||
|
||||
/* Get the Bank number and Pin number within the bank. */
|
||||
#ifdef versal
|
||||
XGpioPs_GetBankPin(InstancePtr,(u8)Pin, &Bank, &PinNumber);
|
||||
#else
|
||||
XGpioPs_GetBankPin((u8)Pin, &Bank, &PinNumber);
|
||||
#endif
|
||||
|
||||
IntrType = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTTYPE_OFFSET) & ((u32)1 << PinNumber);
|
||||
|
||||
if (IntrType == ((u32)1 << PinNumber)) {
|
||||
|
||||
IntrOnAny = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTANY_OFFSET) & ((u32)1 << PinNumber);
|
||||
|
||||
IntrPol = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTPOL_OFFSET) & ((u32)1 << PinNumber);
|
||||
|
||||
|
||||
if (IntrOnAny == ((u32)1 << PinNumber)) {
|
||||
IrqType = XGPIOPS_IRQ_TYPE_EDGE_BOTH;
|
||||
} else if (IntrPol == ((u32)1 << PinNumber)) {
|
||||
IrqType = XGPIOPS_IRQ_TYPE_EDGE_RISING;
|
||||
} else {
|
||||
IrqType = XGPIOPS_IRQ_TYPE_EDGE_FALLING;
|
||||
}
|
||||
} else {
|
||||
|
||||
IntrPol = XGpioPs_ReadReg(InstancePtr->GpioConfig.BaseAddr,
|
||||
((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) +
|
||||
XGPIOPS_INTPOL_OFFSET) & ((u32)1 << PinNumber);
|
||||
|
||||
if (IntrPol == ((u32)1 << PinNumber)) {
|
||||
IrqType = XGPIOPS_IRQ_TYPE_LEVEL_HIGH;
|
||||
} else {
|
||||
IrqType = XGPIOPS_IRQ_TYPE_LEVEL_LOW;
|
||||
}
|
||||
}
|
||||
|
||||
return IrqType;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function sets the status callback function. The callback function is
|
||||
* called by the XGpioPs_IntrHandler when an interrupt occurs.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
* @param CallBackRef is the upper layer callback reference passed back
|
||||
* when the callback function is invoked.
|
||||
* @param FuncPointer is the pointer to the callback function.
|
||||
*
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note The handler is called within interrupt context, so it should do
|
||||
* its work quickly and queue potentially time-consuming work to a
|
||||
* task-level thread.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XGpioPs_SetCallbackHandler(XGpioPs *InstancePtr, void *CallBackRef,
|
||||
XGpioPs_Handler FuncPointer)
|
||||
{
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(FuncPointer != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
InstancePtr->Handler = FuncPointer;
|
||||
InstancePtr->CallBackRef = CallBackRef;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is the interrupt handler for GPIO interrupts.It checks the
|
||||
* interrupt status registers of all the banks to determine the actual bank in
|
||||
* which an interrupt has been triggered. It then calls the upper layer callback
|
||||
* handler set by the function XGpioPs_SetBankHandler(). The callback is called
|
||||
* when an interrupt
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note This function does not save and restore the processor context
|
||||
* such that the user must provide this processing.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XGpioPs_IntrHandler(const XGpioPs *InstancePtr)
|
||||
{
|
||||
u8 Bank;
|
||||
u32 IntrStatus;
|
||||
u32 IntrEnabled;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
for (Bank = 0U; Bank < InstancePtr->MaxBanks; Bank++) {
|
||||
#ifdef versal
|
||||
if(InstancePtr->PmcGpio == (u32)TRUE) {
|
||||
if(Bank == XGPIOPS_TWO) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if((Bank == XGPIOPS_ONE) || (Bank == XGPIOPS_TWO)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
IntrStatus = XGpioPs_IntrGetStatus(InstancePtr, Bank);
|
||||
IntrEnabled = XGpioPs_IntrGetEnabled(InstancePtr,Bank);
|
||||
if ((IntrStatus & IntrEnabled) != (u32)0) {
|
||||
XGpioPs_IntrClear(InstancePtr, Bank,
|
||||
(IntrStatus & IntrEnabled));
|
||||
InstancePtr->Handler(InstancePtr->
|
||||
CallBackRef, Bank,
|
||||
(IntrStatus & IntrEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
/** @} */
|
113
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_selftest.c
Normal file
113
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_selftest.c
Normal file
@ -0,0 +1,113 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xgpiops_selftest.c
|
||||
* @addtogroup gpiops Overview
|
||||
* @{
|
||||
*
|
||||
* This file contains a diagnostic self-test function for the XGpioPs driver.
|
||||
*
|
||||
* Read xgpiops.h file for more information.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.00a sv 01/18/10 First Release
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.5 sne 03/01/19 Fixes violations according to MISRAC-2012
|
||||
* in safety mode and modified the code such as
|
||||
* Use of mixed mode arithmetic,Declared the pointer param
|
||||
* as Pointer to const,Casting operation to a pointer,
|
||||
* Literal value requires a U suffix.
|
||||
* </pre>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************** Include Files ********************************/
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xgpiops.h"
|
||||
|
||||
/************************** Constant Definitions ****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions ******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions ********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
|
||||
/************************** Function Prototypes *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function runs a self-test on the GPIO driver/device. This function
|
||||
* does a register read/write test on some of the Interrupt Registers.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XGpioPs instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if the self-test passed.
|
||||
* - XST_FAILURE otherwise.
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XGpioPs_SelfTest(const XGpioPs *InstancePtr)
|
||||
{
|
||||
s32 Status = (s32)0;
|
||||
u32 IntrEnabled;
|
||||
u32 CurrentIntrType = 0U;
|
||||
u32 CurrentIntrPolarity = 0U;
|
||||
u32 CurrentIntrOnAny = 0U;
|
||||
u32 IntrType = 0U;
|
||||
u32 IntrPolarity = 0U;
|
||||
u32 IntrOnAny = 0U;
|
||||
u32 IntrTestValue = 0x22U;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/* Disable the Interrupts for Bank 0 . */
|
||||
IntrEnabled = XGpioPs_IntrGetEnabled(InstancePtr, XGPIOPS_BANK0);
|
||||
XGpioPs_IntrDisable(InstancePtr, XGPIOPS_BANK0, IntrEnabled);
|
||||
|
||||
/*
|
||||
* Get the Current Interrupt properties for Bank 0.
|
||||
* Set them to a known value, read it back and compare.
|
||||
*/
|
||||
XGpioPs_GetIntrType(InstancePtr, XGPIOPS_BANK0, &CurrentIntrType,
|
||||
&CurrentIntrPolarity, &CurrentIntrOnAny);
|
||||
|
||||
XGpioPs_SetIntrType(InstancePtr, XGPIOPS_BANK0, IntrTestValue,
|
||||
IntrTestValue, IntrTestValue);
|
||||
|
||||
XGpioPs_GetIntrType(InstancePtr, XGPIOPS_BANK0, &IntrType,
|
||||
&IntrPolarity, &IntrOnAny);
|
||||
|
||||
if ((IntrType != IntrTestValue) && (IntrPolarity != IntrTestValue) &&
|
||||
(IntrOnAny != IntrTestValue)) {
|
||||
|
||||
Status = (s32)XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore the contents of all the interrupt registers modified in this
|
||||
* test.
|
||||
*/
|
||||
XGpioPs_SetIntrType(InstancePtr, XGPIOPS_BANK0, CurrentIntrType,
|
||||
CurrentIntrPolarity, CurrentIntrOnAny);
|
||||
|
||||
XGpioPs_IntrEnable(InstancePtr, XGPIOPS_BANK0, IntrEnabled);
|
||||
|
||||
return Status;
|
||||
}
|
||||
/** @} */
|
74
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_sinit.c
Normal file
74
bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_sinit.c
Normal file
@ -0,0 +1,74 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xgpiops_sinit.c
|
||||
* @addtogroup gpiops Overview
|
||||
* @{
|
||||
*
|
||||
* This file contains the implementation of the XGpioPs driver's static
|
||||
* initialization functionality.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.00a sv 01/15/10 First Release
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xgpiops.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function looks for the device configuration based on the unique device
|
||||
* ID. The table XGpioPs_ConfigTable[] contains the configuration information
|
||||
* for each device in the system.
|
||||
*
|
||||
* @param DeviceId is the unique device ID of the device being looked up.
|
||||
*
|
||||
* @return A pointer to the configuration table entry corresponding to the
|
||||
* given device ID, or NULL if no match is found.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
XGpioPs_Config *XGpioPs_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
XGpioPs_Config *CfgPtr = NULL;
|
||||
u32 Index;
|
||||
|
||||
for (Index = 0U; Index < (u32)XPAR_XGPIOPS_NUM_INSTANCES; Index++) {
|
||||
if (XGpioPs_ConfigTable[Index].DeviceId == DeviceId) {
|
||||
CfgPtr = &XGpioPs_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (XGpioPs_Config *)CfgPtr;
|
||||
}
|
||||
/** @} */
|
39
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/Makefile
Normal file
39
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/Makefile
Normal file
@ -0,0 +1,39 @@
|
||||
DRIVER_LIB_VERSION = 1.0
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
CC_FLAGS = $(COMPILER_FLAGS)
|
||||
ECC_FLAGS = $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I$(INCLUDEDIR)
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR), $(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
libs: $(OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
${COMPILER} $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) $< -o $@
|
||||
|
||||
.PHONY: include
|
||||
include: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf $(DEPFILES)
|
1603
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.c
Normal file
1603
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.c
Normal file
File diff suppressed because it is too large
Load Diff
788
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.h
Normal file
788
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.h
Normal file
@ -0,0 +1,788 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xqspips.h
|
||||
* @addtogroup qspips_v3_10
|
||||
* @{
|
||||
* @details
|
||||
*
|
||||
* This file contains the implementation of the XQspiPs driver. It supports only
|
||||
* master mode. User documentation for the driver functions is contained in this
|
||||
* file in the form of comment blocks at the front of each function.
|
||||
*
|
||||
* A QSPI device connects to an QSPI bus through a 4-wire serial interface.
|
||||
* The QSPI bus is a full-duplex, synchronous bus that facilitates communication
|
||||
* between one master and one slave. The device is always full-duplex,
|
||||
* which means that for every byte sent, one is received, and vice-versa.
|
||||
* The master controls the clock, so it can regulate when it wants to
|
||||
* send or receive data. The slave is under control of the master, it must
|
||||
* respond quickly since it has no control of the clock and must send/receive
|
||||
* data as fast or as slow as the master does.
|
||||
*
|
||||
* <b> Linear Mode </b>
|
||||
* The Linear Quad-SPI Controller extends the existing Quad-SPI Controller<65>s
|
||||
* functionality by adding a linear addressing scheme that allows the SPI flash
|
||||
* memory subsystem to behave like a typical ROM device. The new feature hides
|
||||
* the normal SPI protocol from a master reading from the SPI flash memory. The
|
||||
* feature improves both the user friendliness and the overall read memory
|
||||
* throughput over that of the current Quad-SPI Controller by lessening the
|
||||
* amount of software overheads required and by the use of the faster AXI
|
||||
* interface.
|
||||
*
|
||||
* <b>Initialization & Configuration</b>
|
||||
*
|
||||
* The XQspiPs_Config structure is used by the driver to configure itself. This
|
||||
* configuration structure is typically created by the tool-chain based on HW
|
||||
* build properties.
|
||||
*
|
||||
* To support multiple runtime loading and initialization strategies employed by
|
||||
* various operating systems, the driver instance can be initialized in the
|
||||
* following way:
|
||||
* - XQspiPs_LookupConfig(DeviceId) - Use the device identifier to find
|
||||
* static configuration structure defined in xqspips_g.c. This is setup
|
||||
* by the tools. For some operating systems the config structure will be
|
||||
* initialized by the software and this call is not needed.
|
||||
* - XQspiPs_CfgInitialize(InstancePtr, CfgPtr, EffectiveAddr) - Uses a
|
||||
* configuration structure provided by the caller. If running in a system
|
||||
* with address translation, the provided virtual memory base address
|
||||
* replaces the physical address present in the configuration structure.
|
||||
*
|
||||
* <b>Multiple Masters</b>
|
||||
*
|
||||
* More than one master can exist, but arbitration is the responsibility of
|
||||
* the higher layer software. The device driver does not perform any type of
|
||||
* arbitration.
|
||||
*
|
||||
* <b>Modes of Operation</b>
|
||||
*
|
||||
* There are four modes to perform a data transfer and the selection of a mode
|
||||
* is based on Chip Select(CS) and Start. These two options individually, can
|
||||
* be controlled either by software(Manual) or hardware(Auto).
|
||||
* - Auto CS: Chip select is automatically asserted as soon as the first word
|
||||
* is written into the TXFIFO and de asserted when the TXFIFO becomes
|
||||
* empty
|
||||
* - Manual CS: Software must assert and de assert CS.
|
||||
* - Auto Start: Data transmission starts as soon as there is data in the
|
||||
* TXFIFO and stalls when the TXFIFO is empty
|
||||
* - Manual Start: Software must start data transmission at the beginning of
|
||||
* the transaction or whenever the TXFIFO has become empty
|
||||
*
|
||||
* The preferred combination is Manual CS and Auto Start.
|
||||
* In this combination, the software asserts CS before loading any data into
|
||||
* TXFIFO. In Auto Start mode, whenever data is in TXFIFO, controller sends it
|
||||
* out until TXFIFO becomes empty. The software reads the RXFIFO whenever the
|
||||
* data is available. If no further data, software disables CS.
|
||||
*
|
||||
* Risks/challenges of other combinations:
|
||||
* - Manual CS and Manual Start: Manual Start bit should be set after each
|
||||
* TXFIFO write otherwise there could be a race condition where the TXFIFO
|
||||
* becomes empty before the new word is written. In that case the
|
||||
* transmission stops.
|
||||
* - Auto CS with Manual or Auto Start: It is very difficult for software to
|
||||
* keep the TXFIFO filled. Whenever the TXFIFO runs empty, CS is de asserted.
|
||||
* This results in a single transaction to be split into multiple pieces each
|
||||
* with its own chip select. This will result in garbage data to be sent.
|
||||
*
|
||||
* <b>Interrupts</b>
|
||||
*
|
||||
* The user must connect the interrupt handler of the driver,
|
||||
* XQspiPs_InterruptHandler, to an interrupt system such that it will be
|
||||
* called when an interrupt occurs. This function does not save and restore
|
||||
* the processor context such that the user must provide this processing.
|
||||
*
|
||||
* The driver handles the following interrupts:
|
||||
* - Data Transmit Register/FIFO Underflow
|
||||
* - Data Receive Register/FIFO Not Empty
|
||||
* - Data Transmit Register/FIFO Overwater
|
||||
* - Data Receive Register/FIFO Overrun
|
||||
*
|
||||
* The Data Transmit Register/FIFO Overwater interrupt -- indicates that the
|
||||
* QSPI device has transmitted the data available to transmit, and now its data
|
||||
* register and FIFO is ready to accept more data. The driver uses this
|
||||
* interrupt to indicate progress while sending data. The driver may have
|
||||
* more data to send, in which case the data transmit register and FIFO is
|
||||
* filled for subsequent transmission. When this interrupt arrives and all
|
||||
* the data has been sent, the driver invokes the status callback with a
|
||||
* value of XST_SPI_TRANSFER_DONE to inform the upper layer software that
|
||||
* all data has been sent.
|
||||
*
|
||||
* The Data Transmit Register/FIFO Underflow interrupt -- indicates that,
|
||||
* as slave, the QSPI device was required to transmit but there was no data
|
||||
* available to transmit in the transmit register (or FIFO). This may not
|
||||
* be an error if the master is not expecting data. But in the case where
|
||||
* the master is expecting data, this serves as a notification of such a
|
||||
* condition. The driver reports this condition to the upper layer
|
||||
* software through the status handler.
|
||||
*
|
||||
* The Data Receive Register/FIFO Overrun interrupt -- indicates that the QSPI
|
||||
* device received data and subsequently dropped the data because the data
|
||||
* receive register and FIFO was full. The driver reports this condition to the
|
||||
* upper layer software through the status handler. This likely indicates a
|
||||
* problem with the higher layer protocol, or a problem with the slave
|
||||
* performance.
|
||||
*
|
||||
*
|
||||
* <b>Polled Operation</b>
|
||||
*
|
||||
* Transfer in polled mode is supported through a separate interface function
|
||||
* XQspiPs_PolledTransfer(). Unlike the transfer function in the interrupt mode,
|
||||
* this function blocks until all data has been sent/received.
|
||||
*
|
||||
* <b>Device Busy</b>
|
||||
*
|
||||
* Some operations are disallowed when the device is busy. The driver tracks
|
||||
* whether a device is busy. The device is considered busy when a data transfer
|
||||
* request is outstanding, and is considered not busy only when that transfer
|
||||
* completes (or is aborted with a mode fault error).
|
||||
*
|
||||
* <b>Device Configuration</b>
|
||||
*
|
||||
* The device can be configured in various ways during the FPGA implementation
|
||||
* process. Configuration parameters are stored in the xqspips_g.c file or
|
||||
* passed in via XQspiPs_CfgInitialize(). A table is defined where each entry
|
||||
* contains configuration information for an QSPI device, including the base
|
||||
* address for the device.
|
||||
*
|
||||
* <b>RTOS Independence</b>
|
||||
*
|
||||
* This driver is intended to be RTOS and processor independent. It works with
|
||||
* physical addresses only. Any needs for dynamic memory management, threads or
|
||||
* thread mutual exclusion, virtual memory, or cache control must be satisfied
|
||||
* by the layer above this driver.
|
||||
*
|
||||
* NOTE: This driver was always tested with endianness set to little-endian.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00a sdm 11/25/10 First release, based on the PS SPI driver...
|
||||
* 1.01a sdm 11/22/11 Added TCL file for generating QSPI parameters
|
||||
* in xparameters.h
|
||||
* 2.00a kka 07/25/12 Added a few register defines for CR 670297
|
||||
* Removed code related to mode fault for CR 671468
|
||||
* The XQspiPs_SetSlaveSelect has been modified to remove
|
||||
* the argument of the slave select as the QSPI controller
|
||||
* only supports one slave.
|
||||
* XQspiPs_GetSlaveSelect API has been removed
|
||||
* Added a flag ShiftReadData to the instance structure
|
||||
*. and is used in the XQspiPs_GetReadData API.
|
||||
* The ShiftReadData Flag indicates whether the data
|
||||
* read from the Rx FIFO needs to be shifted
|
||||
* in cases where the data is less than 4 bytes
|
||||
* Removed the selection for the following options:
|
||||
* Master mode (XQSPIPS_MASTER_OPTION) and
|
||||
* Flash interface mode (XQSPIPS_FLASH_MODE_OPTION) option
|
||||
* as the QSPI driver supports the Master mode
|
||||
* and Flash Interface mode and doesnot support
|
||||
* Slave mode or the legacy mode.
|
||||
* Modified the XQspiPs_PolledTransfer and XQspiPs_Transfer
|
||||
* APIs so that the last argument (IsInst) specifying whether
|
||||
* it is instruction or data has been removed. The first byte
|
||||
* in the SendBufPtr argument of these APIs specify the
|
||||
* instruction to be sent to the Flash Device.
|
||||
* This version of the driver fixes CRs 670197/663787/
|
||||
* 670297/671468.
|
||||
* Added the option for setting the Holdb_dr bit in the
|
||||
* configuration options, XQSPIPS_HOLD_B_DRIVE_OPTION
|
||||
* is the option to be used for setting this bit in the
|
||||
* configuration register.
|
||||
* The XQspiPs_PolledTransfer function has been updated
|
||||
* to fill the data to fifo depth.
|
||||
* 2.01a sg 02/03/13 Added flash opcodes for DUAL_IO_READ,QUAD_IO_READ.
|
||||
* Added macros for Set/Get Rx Watermark. Changed QSPI
|
||||
* Enable/Disable macro argument from BaseAddress to
|
||||
* Instance Pointer. Added DelayNss argument to SetDelays
|
||||
* and GetDelays API's.
|
||||
* Created macros XQspiPs_IsManualStart and
|
||||
* XQspiPs_IsManualChipSelect.
|
||||
* Changed QSPI transfer logic for polled and interrupt
|
||||
* modes to be based on filled tx fifo count and receive
|
||||
* based on it. RXNEMPTY interrupt is not used.
|
||||
* Added assertions to XQspiPs_LqspiRead function.
|
||||
* SetDelays and GetDelays API's include DelayNss parameter.
|
||||
* Added defines for DelayNss,Rx Watermark,Interrupts
|
||||
* which need write to clear. Removed Read zeros mask from
|
||||
* LQSPI Config register. Renamed Fixed burst error to
|
||||
* data FSM error in LQSPI Status register.
|
||||
*
|
||||
* 2.02a hk 05/07/13 Added ConnectionMode to config structure.
|
||||
* Corresponds to C_QSPI_MODE - 0:Single, 1:Stacked, 2:Parallel
|
||||
* Added enable and disable to the XQspiPs_LqspiRead() function
|
||||
* Removed XQspi_Reset() in Set_Options() function when
|
||||
* LQSPI_MODE_OPTION is set.
|
||||
* Added instructions for bank selection, die erase and
|
||||
* flag status register to the flash instruction table
|
||||
* Handling for instructions not in flash instruction
|
||||
* table added. Checking for Tx FIFO empty when switching from
|
||||
* TXD1/2/3 to TXD0 added. If WRSR instruction is sent with
|
||||
* byte count 3 (spansion), instruction size and TXD register
|
||||
* changed accordingly. CR# 712502 and 703869.
|
||||
* Added prefix to constant definitions for ConnectionMode
|
||||
* Added (\#ifdef linear base address) in the Linear read function.
|
||||
* Changed XPAR_XQSPIPS_0_LINEAR_BASEADDR to
|
||||
* XPAR_PS7_QSPI_LINEAR_0_S_AXI_BASEADDR in
|
||||
* XQspiPs_LqspiRead function. Fix for CR#718141.
|
||||
*
|
||||
* 2.03a hk 09/17/13 Modified polled and interrupt transfers to make use of
|
||||
* thresholds. This is to improve performance.
|
||||
* Added API's for QSPI reset and
|
||||
* linear mode initialization for boot.
|
||||
* Added RX and TX threshold reset to one in XQspiPs_Abort.
|
||||
* Added RX threshold reset(1) after transfer in polled and
|
||||
* interrupt transfers. Made changes to make sure threshold
|
||||
* change is done only when no transfer is in progress.
|
||||
* Updated linear init API for parallel and stacked modes.
|
||||
* CR#737760.
|
||||
* 3.1 hk 08/13/14 When writing to the configuration register, set/reset
|
||||
* required bits leaving reserved bits untouched. CR# 796813.
|
||||
* 3.2 sk 02/05/15 Add SLCR reset in abort function as a workaround because
|
||||
* controller does not update FIFO status flags as expected
|
||||
* when thresholds are used.
|
||||
* 3.3 sk 11/07/15 Modified the API prototypes according to MISRAC standards
|
||||
* to remove compilation warnings. CR# 868893.
|
||||
* ms 03/17/17 Added readme.txt file in examples folder for doxygen
|
||||
* generation.
|
||||
* ms 04/05/17 Modified Comment lines in functions of qspips
|
||||
* examples to recognize it as documentation block
|
||||
* and modified filename tag in
|
||||
* xqspips_dual_flash_stack_lqspi_example.c to include it in
|
||||
* doxygen examples.
|
||||
* 3.4 nsk 31/07/17 Added QSPI_BUS_WIDTH parameter in xparameters.h file
|
||||
* 3.5 tjs 08/21/18 Fixed compilation warnings for the ARMCC.
|
||||
* 3.5 tjs 07/16/18 Added support for low density ISSI flash parts.
|
||||
* 3.6 akm 03/28/19 Fixed memory leak issue while reading from qspi.(CR#1016357)
|
||||
* 3.6 akm 04/15/19 Modified FlashQuadEnable, FlashWrie and FlashErase APIs,
|
||||
* to wait for the on going operation to complete before
|
||||
* performing the next operation.
|
||||
* 3.6 akm 04/15/19 Modified the mask in XQspiPs_GetReadData() API to retrieve
|
||||
* configuration register values of both the Flashes in dual
|
||||
* parellel connection.
|
||||
* 3.7 akm 11/19/19 Fixed Coverity unused value warning in XQspiPs_PolledTransfer()
|
||||
* and XQspiPs_Transfer() APIs.
|
||||
* 3.7 akm 03/19/20 Modified XQspiPs_PolledTransfer(), XQspiPs_Transfer() and
|
||||
* XQspiPs_InterruptHandler() APIs to fill TX FIFO with valid
|
||||
* data when RX buffer is not NULL.
|
||||
* 3.8 akm 09/02/20 Updated the Makefile to support parallel make execution.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XQSPIPS_H /* prevent circular inclusions */
|
||||
#define XQSPIPS_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xqspips_hw.h"
|
||||
#include <string.h>
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Configuration options
|
||||
*
|
||||
* The following options are supported to enable/disable certain features of
|
||||
* an QSPI device. Each of the options is a bit mask, so more than one may be
|
||||
* specified.
|
||||
*
|
||||
*
|
||||
* The <b>Active Low Clock option</b> configures the device's clock polarity.
|
||||
* Setting this option means the clock is active low and the SCK signal idles
|
||||
* high. By default, the clock is active high and SCK idles low.
|
||||
*
|
||||
* The <b>Clock Phase option</b> configures the QSPI device for one of two
|
||||
* transfer formats. A clock phase of 0, the default, means data is valid on
|
||||
* the first SCK edge (rising or falling) after the slave select (SS) signal
|
||||
* has been asserted. A clock phase of 1 means data is valid on the second SCK
|
||||
* edge (rising or falling) after SS has been asserted.
|
||||
*
|
||||
*
|
||||
* The <b>QSPI Force Slave Select option</b> is used to enable manual control of
|
||||
* the slave select signal.
|
||||
* 0: The SPI_SS signal is controlled by the QSPI controller during
|
||||
* transfers. (Default)
|
||||
* 1: The SPI_SS signal is forced active (driven low) regardless of any
|
||||
* transfers in progress.
|
||||
*
|
||||
* NOTE: The driver will handle setting and clearing the Slave Select when
|
||||
* the user sets the "FORCE_SSELECT_OPTION". Using this option will allow the
|
||||
* QSPI clock to be set to a faster speed. If the QSPI clock is too fast, the
|
||||
* processor cannot empty and refill the FIFOs before the TX FIFO is empty
|
||||
* When the QSPI hardware is controlling the Slave Select signals, this
|
||||
* will cause slave to be de-selected and terminate the transfer.
|
||||
*
|
||||
* The <b>Manual Start option</b> is used to enable manual control of
|
||||
* the Start command to perform data transfer.
|
||||
* 0: The Start command is controlled by the QSPI controller during
|
||||
* transfers(Default). Data transmission starts as soon as there is data in
|
||||
* the TXFIFO and stalls when the TXFIFO is empty
|
||||
* 1: The Start command must be issued by software to perform data transfer.
|
||||
* Bit 15 of Configuration register is used to issue Start command. This bit
|
||||
* must be set whenever TXFIFO is filled with new data.
|
||||
*
|
||||
* NOTE: The driver will set the Manual Start Enable bit in Configuration
|
||||
* Register, if Manual Start option is selected. Software will issue
|
||||
* Manual Start command whenever TXFIFO is filled with data. When there is
|
||||
* no further data, driver will clear the Manual Start Enable bit.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_CLK_ACTIVE_LOW_OPTION 0x2 /**< Active Low Clock option */
|
||||
#define XQSPIPS_CLK_PHASE_1_OPTION 0x4 /**< Clock Phase one option */
|
||||
#define XQSPIPS_FORCE_SSELECT_OPTION 0x10 /**< Force Slave Select */
|
||||
#define XQSPIPS_MANUAL_START_OPTION 0x20 /**< Manual Start enable */
|
||||
#define XQSPIPS_LQSPI_MODE_OPTION 0x80 /**< Linear QPSI mode */
|
||||
#define XQSPIPS_HOLD_B_DRIVE_OPTION 0x100 /**< Drive HOLD_B Pin */
|
||||
/*@}*/
|
||||
|
||||
|
||||
/** @name QSPI Clock Prescaler options
|
||||
* The QSPI Clock Prescaler Configuration bits are used to program master mode
|
||||
* bit rate. The bit rate can be programmed in divide-by-two decrements from
|
||||
* pclk/2 to pclk/256.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_CLK_PRESCALE_2 0x00 /**< PCLK/2 Prescaler */
|
||||
#define XQSPIPS_CLK_PRESCALE_4 0x01 /**< PCLK/4 Prescaler */
|
||||
#define XQSPIPS_CLK_PRESCALE_8 0x02 /**< PCLK/8 Prescaler */
|
||||
#define XQSPIPS_CLK_PRESCALE_16 0x03 /**< PCLK/16 Prescaler */
|
||||
#define XQSPIPS_CLK_PRESCALE_32 0x04 /**< PCLK/32 Prescaler */
|
||||
#define XQSPIPS_CLK_PRESCALE_64 0x05 /**< PCLK/64 Prescaler */
|
||||
#define XQSPIPS_CLK_PRESCALE_128 0x06 /**< PCLK/128 Prescaler */
|
||||
#define XQSPIPS_CLK_PRESCALE_256 0x07 /**< PCLK/256 Prescaler */
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/** @name Callback events
|
||||
*
|
||||
* These constants specify the handler events that are passed to
|
||||
* a handler from the driver. These constants are not bit masks such that
|
||||
* only one will be passed at a time to the handler.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_EVENT_TRANSFER_DONE 2 /**< Transfer done */
|
||||
#define XQSPIPS_EVENT_TRANSMIT_UNDERRUN 3 /**< TX FIFO empty */
|
||||
#define XQSPIPS_EVENT_RECEIVE_OVERRUN 4 /**< Receive data loss because
|
||||
* RX FIFO full
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
/** @name Flash commands
|
||||
*
|
||||
* The following constants define most of the commands supported by flash
|
||||
* devices. Users can add more commands supported by the flash devices
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_FLASH_OPCODE_WRSR 0x01 /* Write status register */
|
||||
#define XQSPIPS_FLASH_OPCODE_PP 0x02 /* Page program */
|
||||
#define XQSPIPS_FLASH_OPCODE_NORM_READ 0x03 /* Normal read data bytes */
|
||||
#define XQSPIPS_FLASH_OPCODE_WRDS 0x04 /* Write disable */
|
||||
#define XQSPIPS_FLASH_OPCODE_RDSR1 0x05 /* Read status register 1 */
|
||||
#define XQSPIPS_FLASH_OPCODE_WREN 0x06 /* Write enable */
|
||||
#define XQSPIPS_FLASH_OPCODE_FAST_READ 0x0B /* Fast read data bytes */
|
||||
#define XQSPIPS_FLASH_OPCODE_BE_4K 0x20 /* Erase 4KiB block */
|
||||
#define XQSPIPS_FLASH_OPCODE_RDSR2 0x35 /* Read status register 2 */
|
||||
#define XQSPIPS_FLASH_OPCODE_DUAL_READ 0x3B /* Dual read data bytes */
|
||||
#define XQSPIPS_FLASH_OPCODE_BE_32K 0x52 /* Erase 32KiB block */
|
||||
#define XQSPIPS_FLASH_OPCODE_QUAD_READ 0x6B /* Quad read data bytes */
|
||||
#define XQSPIPS_FLASH_OPCODE_ERASE_SUS 0x75 /* Erase suspend */
|
||||
#define XQSPIPS_FLASH_OPCODE_ERASE_RES 0x7A /* Erase resume */
|
||||
#define XQSPIPS_FLASH_OPCODE_RDID 0x9F /* Read JEDEC ID */
|
||||
#define XQSPIPS_FLASH_OPCODE_BE 0xC7 /* Erase whole flash block */
|
||||
#define XQSPIPS_FLASH_OPCODE_SE 0xD8 /* Sector erase (usually 64KB)*/
|
||||
#define XQSPIPS_FLASH_OPCODE_DUAL_IO_READ 0xBB /* Read data using Dual I/O */
|
||||
#define XQSPIPS_FLASH_OPCODE_QUAD_IO_READ 0xEB /* Read data using Quad I/O */
|
||||
#define XQSPIPS_FLASH_OPCODE_BRWR 0x17 /* Bank Register Write */
|
||||
#define XQSPIPS_FLASH_OPCODE_BRRD 0x16 /* Bank Register Read */
|
||||
/* Extende Address Register Write - Micron's equivalent of Bank Register */
|
||||
#define XQSPIPS_FLASH_OPCODE_EARWR 0xC5
|
||||
/* Extende Address Register Read - Micron's equivalent of Bank Register */
|
||||
#define XQSPIPS_FLASH_OPCODE_EARRD 0xC8
|
||||
#define XQSPIPS_FLASH_OPCODE_DIE_ERASE 0xC4
|
||||
#define XQSPIPS_FLASH_OPCODE_READ_FLAG_SR 0x70
|
||||
#define XQSPIPS_FLASH_OPCODE_CLEAR_FLAG_SR 0x50
|
||||
#define XQSPIPS_FLASH_OPCODE_READ_LOCK_REG 0xE8 /* Lock Reg Read */
|
||||
#define XQSPIPS_FLASH_OPCODE_WRITE_LOCK_REG 0xE5 /* Lock Reg Write */
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** @name Instruction size
|
||||
*
|
||||
* The following constants define numbers 1 to 4.
|
||||
* Used to identify whether TXD0,1,2 or 3 is to be used.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_SIZE_ONE 1
|
||||
#define XQSPIPS_SIZE_TWO 2
|
||||
#define XQSPIPS_SIZE_THREE 3
|
||||
#define XQSPIPS_SIZE_FOUR 4
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** @name ConnectionMode
|
||||
*
|
||||
* The following constants are the possible values of ConnectionMode in
|
||||
* Config structure.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_CONNECTION_MODE_SINGLE 0
|
||||
#define XQSPIPS_CONNECTION_MODE_STACKED 1
|
||||
#define XQSPIPS_CONNECTION_MODE_PARALLEL 2
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** @name FIFO threshold value
|
||||
*
|
||||
* This is the Rx FIFO threshold (in words) that was found to be most
|
||||
* optimal in terms of performance
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_RXFIFO_THRESHOLD_OPT 32
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
/**
|
||||
* The handler data type allows the user to define a callback function to
|
||||
* handle the asynchronous processing for the QSPI device. The application
|
||||
* using this driver is expected to define a handler of this type to support
|
||||
* interrupt driven mode. The handler executes in an interrupt context, so
|
||||
* only minimal processing should be performed.
|
||||
*
|
||||
* @param CallBackRef is the callback reference passed in by the upper
|
||||
* layer when setting the callback functions, and passed back to
|
||||
* the upper layer when the callback is invoked. Its type is
|
||||
* not important to the driver, so it is a void pointer.
|
||||
* @param StatusEvent holds one or more status events that have occurred.
|
||||
* See the XQspiPs_SetStatusHandler() for details on the status
|
||||
* events that can be passed in the callback.
|
||||
* @param ByteCount indicates how many bytes of data were successfully
|
||||
* transferred. This may be less than the number of bytes
|
||||
* requested if the status event indicates an error.
|
||||
*/
|
||||
typedef void (*XQspiPs_StatusHandler) (void *CallBackRef, u32 StatusEvent,
|
||||
unsigned ByteCount);
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for the device.
|
||||
*/
|
||||
typedef struct {
|
||||
u16 DeviceId; /**< Unique ID of device */
|
||||
u32 BaseAddress; /**< Base address of the device */
|
||||
u32 InputClockHz; /**< Input clock frequency */
|
||||
u8 ConnectionMode; /**< Single, Stacked and Parallel mode */
|
||||
} XQspiPs_Config;
|
||||
|
||||
/**
|
||||
* The XQspiPs driver instance data. The user is required to allocate a
|
||||
* variable of this type for every QSPI device in the system. A pointer
|
||||
* to a variable of this type is then passed to the driver API functions.
|
||||
*/
|
||||
typedef struct {
|
||||
XQspiPs_Config Config; /**< Configuration structure */
|
||||
u32 IsReady; /**< Device is initialized and ready */
|
||||
|
||||
u8 *SendBufferPtr; /**< Buffer to send (state) */
|
||||
u8 *RecvBufferPtr; /**< Buffer to receive (state) */
|
||||
int RequestedBytes; /**< Number of bytes to transfer (state) */
|
||||
int RemainingBytes; /**< Number of bytes left to transfer(state) */
|
||||
u32 IsBusy; /**< A transfer is in progress (state) */
|
||||
XQspiPs_StatusHandler StatusHandler;
|
||||
void *StatusRef; /**< Callback reference for status handler */
|
||||
u32 ShiftReadData; /**< Flag to indicate whether the data
|
||||
* read from the Rx FIFO needs to be shifted
|
||||
* in cases where the data is less than 4
|
||||
* bytes
|
||||
*/
|
||||
} XQspiPs;
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/****************************************************************************/
|
||||
/*
|
||||
*
|
||||
* Check in OptionsTable if Manual Start Option is enabled or disabled.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
*
|
||||
* @return
|
||||
* - TRUE if option is set
|
||||
* - FALSE if option is not set
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* u8 XQspiPs_IsManualStart(XQspiPs *InstancePtr);
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_IsManualStart(InstancePtr) \
|
||||
((XQspiPs_GetOptions(InstancePtr) & \
|
||||
XQSPIPS_MANUAL_START_OPTION) ? TRUE : FALSE)
|
||||
|
||||
/****************************************************************************/
|
||||
/*
|
||||
*
|
||||
* Check in OptionsTable if Manual Chip Select Option is enabled or disabled.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSpiPs instance.
|
||||
*
|
||||
* @return
|
||||
* - TRUE if option is set
|
||||
* - FALSE if option is not set
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* u8 XQspiPs_IsManualChipSelect(XQspiPs *InstancePtr);
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_IsManualChipSelect(InstancePtr) \
|
||||
((XQspiPs_GetOptions(InstancePtr) & \
|
||||
XQSPIPS_FORCE_SSELECT_OPTION) ? TRUE : FALSE)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Set the contents of the slave idle count register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
* @param RegisterValue is the value to be written, valid values are
|
||||
* 0-255.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* void XQspiPs_SetSlaveIdle(XQspiPs *InstancePtr,
|
||||
* u32 RegisterValue)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_SetSlaveIdle(InstancePtr, RegisterValue) \
|
||||
XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \
|
||||
XQSPIPS_SICR_OFFSET, (RegisterValue))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the contents of the slave idle count register. Use the XQSPIPS_SICR_*
|
||||
* constants defined in xqspips_hw.h to interpret the bit-mask returned.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
*
|
||||
* @return An 8-bit value representing Slave Idle Count.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* u32 XQspiPs_GetSlaveIdle(XQspiPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_GetSlaveIdle(InstancePtr) \
|
||||
XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + \
|
||||
XQSPIPS_SICR_OFFSET)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Set the contents of the transmit FIFO watermark register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
* @param RegisterValue is the value to be written, valid values are 1-63.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* void XQspiPs_SetTXWatermark(XQspiPs *InstancePtr,
|
||||
* u32 RegisterValue)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_SetTXWatermark(InstancePtr, RegisterValue) \
|
||||
XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \
|
||||
XQSPIPS_TXWR_OFFSET, (RegisterValue))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the contents of the transmit FIFO watermark register.
|
||||
* Valid values are in the range 1-63.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
*
|
||||
* @return A 6-bit value representing Tx Watermark level.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* u32 XQspiPs_GetTXWatermark(XQspiPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_GetTXWatermark(InstancePtr) \
|
||||
XQspiPs_In32((InstancePtr->Config.BaseAddress) + XQSPIPS_TXWR_OFFSET)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Set the contents of the receive FIFO watermark register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
* @param RegisterValue is the value to be written, valid values are 1-63.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* void XQspiPs_SetRXWatermark(XQspiPs *InstancePtr,
|
||||
* u32 RegisterValue)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_SetRXWatermark(InstancePtr, RegisterValue) \
|
||||
XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \
|
||||
XQSPIPS_RXWR_OFFSET, (RegisterValue))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the contents of the receive FIFO watermark register.
|
||||
* Valid values are in the range 1-63.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
*
|
||||
* @return A 6-bit value representing Rx Watermark level.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* u32 XQspiPs_GetRXWatermark(XQspiPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_GetRXWatermark(InstancePtr) \
|
||||
XQspiPs_In32((InstancePtr->Config.BaseAddress) + XQSPIPS_RXWR_OFFSET)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Enable the device and uninhibit master transactions.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* void XQspiPs_Enable(XQspiPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_Enable(InstancePtr) \
|
||||
XQspiPs_Out32((InstancePtr->Config.BaseAddress) + XQSPIPS_ER_OFFSET, \
|
||||
XQSPIPS_ER_ENABLE_MASK)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Disable the device.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* void XQspiPs_Disable(XQspiPs *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_Disable(InstancePtr) \
|
||||
XQspiPs_Out32((InstancePtr->Config.BaseAddress) + XQSPIPS_ER_OFFSET, 0)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Set the contents of the Linear QSPI Configuration register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
* @param RegisterValue is the value to be written to the Linear QSPI
|
||||
* configuration register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* void XQspiPs_SetLqspiConfigReg(XQspiPs *InstancePtr,
|
||||
* u32 RegisterValue)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_SetLqspiConfigReg(InstancePtr, RegisterValue) \
|
||||
XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \
|
||||
XQSPIPS_LQSPI_CR_OFFSET, (RegisterValue))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the contents of the Linear QSPI Configuration register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
*
|
||||
* @return A 32-bit value representing the contents of the LQSPI Config
|
||||
* register.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* u32 XQspiPs_GetLqspiConfigReg(u32 *InstancePtr)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XQspiPs_GetLqspiConfigReg(InstancePtr) \
|
||||
XQspiPs_In32((InstancePtr->Config.BaseAddress) + \
|
||||
XQSPIPS_LQSPI_CR_OFFSET)
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*
|
||||
* Initialization function, implemented in xqspips_sinit.c
|
||||
*/
|
||||
XQspiPs_Config *XQspiPs_LookupConfig(u16 DeviceId);
|
||||
|
||||
/*
|
||||
* Functions implemented in xqspips.c
|
||||
*/
|
||||
int XQspiPs_CfgInitialize(XQspiPs *InstancePtr, XQspiPs_Config *Config,
|
||||
u32 EffectiveAddr);
|
||||
void XQspiPs_Reset(XQspiPs *InstancePtr);
|
||||
void XQspiPs_Abort(XQspiPs *InstancePtr);
|
||||
|
||||
s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr,
|
||||
u32 ByteCount);
|
||||
s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr,
|
||||
u8 *RecvBufPtr, u32 ByteCount);
|
||||
int XQspiPs_LqspiRead(XQspiPs *InstancePtr, u8 *RecvBufPtr,
|
||||
u32 Address, unsigned ByteCount);
|
||||
|
||||
int XQspiPs_SetSlaveSelect(XQspiPs *InstancePtr);
|
||||
|
||||
void XQspiPs_SetStatusHandler(XQspiPs *InstancePtr, void *CallBackRef,
|
||||
XQspiPs_StatusHandler FuncPtr);
|
||||
void XQspiPs_InterruptHandler(void *InstancePtr);
|
||||
|
||||
/*
|
||||
* Functions for selftest, in xqspips_selftest.c
|
||||
*/
|
||||
int XQspiPs_SelfTest(XQspiPs *InstancePtr);
|
||||
|
||||
/*
|
||||
* Functions for options, in xqspips_options.c
|
||||
*/
|
||||
s32 XQspiPs_SetOptions(XQspiPs *InstancePtr, u32 Options);
|
||||
u32 XQspiPs_GetOptions(XQspiPs *InstancePtr);
|
||||
|
||||
s32 XQspiPs_SetClkPrescaler(XQspiPs *InstancePtr, u8 Prescaler);
|
||||
u8 XQspiPs_GetClkPrescaler(XQspiPs *InstancePtr);
|
||||
|
||||
int XQspiPs_SetDelays(XQspiPs *InstancePtr, u8 DelayNss, u8 DelayBtwn,
|
||||
u8 DelayAfter, u8 DelayInit);
|
||||
void XQspiPs_GetDelays(XQspiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn,
|
||||
u8 *DelayAfter, u8 *DelayInit);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
57
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_g.c
Normal file
57
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_g.c
Normal file
@ -0,0 +1,57 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xqspips_g.c
|
||||
* @addtogroup qspips_v3_10
|
||||
* @{
|
||||
*
|
||||
* This file contains a configuration table that specifies the configuration of
|
||||
* QSPI devices in the system.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00 sdm 11/25/10 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xqspips.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
|
||||
/************************** Variable Prototypes ******************************/
|
||||
|
||||
/**
|
||||
* This table contains configuration information for each QSPI device
|
||||
* in the system.
|
||||
*/
|
||||
XQspiPs_Config XQspiPs_ConfigTable[XPAR_XQSPIPS_NUM_INSTANCES] = {
|
||||
{
|
||||
XPAR_XQSPIPS_0_DEVICE_ID, /* Device ID for instance */
|
||||
XPAR_XQSPIPS_0_BASEADDR, /* Device base address */
|
||||
XPAR_XQSPIPS_0_QSPI_CLK_FREQ_HZ,
|
||||
XPAR_XQSPIPS_0_QSPI_MODE
|
||||
},
|
||||
};
|
||||
/** @} */
|
198
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.c
Normal file
198
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.c
Normal file
@ -0,0 +1,198 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xqspips_hw.c
|
||||
* @addtogroup qspips_v3_10
|
||||
* @{
|
||||
*
|
||||
* Contains low level functions, primarily reset related.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 2.03a hk 09/17/13 First release
|
||||
* 3.1 hk 06/19/14 When writing to the configuration register, set/reset
|
||||
* required bits leaving reserved bits untouched. CR# 796813.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xqspips_hw.h"
|
||||
#include "xqspips.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Pre-scaler value for divided by 4
|
||||
*
|
||||
* Pre-scaler value for divided by 4
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_CR_PRESC_DIV_BY_4 0x01
|
||||
/* @} */
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Resets QSPI by disabling the device and bringing it to reset state through
|
||||
* register writes.
|
||||
*
|
||||
* @param BaseAddress
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XQspiPs_ResetHw(u32 BaseAddress)
|
||||
{
|
||||
u32 ConfigReg;
|
||||
|
||||
/*
|
||||
* Disable interrupts
|
||||
*/
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_IDR_OFFSET,
|
||||
XQSPIPS_IXR_DISABLE_ALL);
|
||||
|
||||
/*
|
||||
* Disable device
|
||||
*/
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_ER_OFFSET,
|
||||
0);
|
||||
|
||||
/*
|
||||
* De-assert slave select lines.
|
||||
*/
|
||||
ConfigReg = XQspiPs_ReadReg(BaseAddress, XQSPIPS_CR_OFFSET);
|
||||
ConfigReg |= (XQSPIPS_CR_SSCTRL_MASK | XQSPIPS_CR_SSFORCE_MASK);
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_CR_OFFSET, ConfigReg);
|
||||
|
||||
/*
|
||||
* Write default value to RX and TX threshold registers
|
||||
* RX threshold should be set to 1 here because the corresponding
|
||||
* status bit is used next to clear the RXFIFO
|
||||
*/
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_TXWR_OFFSET,
|
||||
(XQSPIPS_TXWR_RESET_VALUE & XQSPIPS_TXWR_MASK));
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_RXWR_OFFSET,
|
||||
(XQSPIPS_RXWR_RESET_VALUE & XQSPIPS_RXWR_MASK));
|
||||
|
||||
/*
|
||||
* Clear RXFIFO
|
||||
*/
|
||||
while ((XQspiPs_ReadReg(BaseAddress,XQSPIPS_SR_OFFSET) &
|
||||
XQSPIPS_IXR_RXNEMPTY_MASK) != 0) {
|
||||
XQspiPs_ReadReg(BaseAddress, XQSPIPS_RXD_OFFSET);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear status register by reading register and
|
||||
* writing 1 to clear the write to clear bits
|
||||
*/
|
||||
XQspiPs_ReadReg(BaseAddress, XQSPIPS_SR_OFFSET);
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_SR_OFFSET,
|
||||
XQSPIPS_IXR_WR_TO_CLR_MASK);
|
||||
|
||||
/*
|
||||
* Write default value to configuration register
|
||||
*/
|
||||
ConfigReg = XQspiPs_ReadReg(BaseAddress, XQSPIPS_CR_OFFSET);
|
||||
ConfigReg |= XQSPIPS_CR_RESET_MASK_SET;
|
||||
ConfigReg &= ~XQSPIPS_CR_RESET_MASK_CLR;
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_CR_OFFSET, ConfigReg);
|
||||
|
||||
/*
|
||||
* De-select linear mode
|
||||
*/
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_LQSPI_CR_OFFSET,
|
||||
0x0);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Initializes QSPI to Linear mode with default QSPI boot settings.
|
||||
*
|
||||
* @param BaseAddress
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XQspiPs_LinearInit(u32 BaseAddress)
|
||||
{
|
||||
u32 BaudRateDiv;
|
||||
u32 LinearCfg;
|
||||
u32 ConfigReg;
|
||||
|
||||
/*
|
||||
* Baud rate divisor for dividing by 4. Value of CR bits [5:3]
|
||||
* should be set to 0x001; hence shift the value and use the mask.
|
||||
*/
|
||||
BaudRateDiv = ( (XQSPIPS_CR_PRESC_DIV_BY_4) <<
|
||||
XQSPIPS_CR_PRESC_SHIFT) & XQSPIPS_CR_PRESC_MASK;
|
||||
/*
|
||||
* Write configuration register with default values, slave selected &
|
||||
* pre-scaler value for divide by 4
|
||||
*/
|
||||
ConfigReg = XQspiPs_ReadReg(BaseAddress, XQSPIPS_CR_OFFSET);
|
||||
ConfigReg |= (XQSPIPS_CR_RESET_MASK_SET | BaudRateDiv);
|
||||
ConfigReg &= ~(XQSPIPS_CR_RESET_MASK_CLR | XQSPIPS_CR_SSCTRL_MASK);
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_CR_OFFSET, ConfigReg);
|
||||
|
||||
/*
|
||||
* Write linear configuration register with default value -
|
||||
* enable linear mode and use fast read.
|
||||
*/
|
||||
|
||||
if(XPAR_XQSPIPS_0_QSPI_MODE == XQSPIPS_CONNECTION_MODE_SINGLE){
|
||||
|
||||
LinearCfg = XQSPIPS_LQSPI_CR_RST_STATE;
|
||||
|
||||
}else if(XPAR_XQSPIPS_0_QSPI_MODE ==
|
||||
XQSPIPS_CONNECTION_MODE_STACKED){
|
||||
|
||||
LinearCfg = XQSPIPS_LQSPI_CR_RST_STATE |
|
||||
XQSPIPS_LQSPI_CR_TWO_MEM_MASK;
|
||||
|
||||
}else if(XPAR_XQSPIPS_0_QSPI_MODE ==
|
||||
XQSPIPS_CONNECTION_MODE_PARALLEL){
|
||||
|
||||
LinearCfg = XQSPIPS_LQSPI_CR_RST_STATE |
|
||||
XQSPIPS_LQSPI_CR_TWO_MEM_MASK |
|
||||
XQSPIPS_LQSPI_CR_SEP_BUS_MASK;
|
||||
|
||||
}
|
||||
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_LQSPI_CR_OFFSET,
|
||||
LinearCfg);
|
||||
|
||||
/*
|
||||
* Enable device
|
||||
*/
|
||||
XQspiPs_WriteReg(BaseAddress, XQSPIPS_ER_OFFSET,
|
||||
XQSPIPS_ER_ENABLE_MASK);
|
||||
|
||||
}
|
||||
/** @} */
|
399
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.h
Normal file
399
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.h
Normal file
@ -0,0 +1,399 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xqspips_hw.h
|
||||
* @addtogroup qspips_v3_10
|
||||
* @{
|
||||
*
|
||||
* This header file contains the identifiers and basic HW access driver
|
||||
* functions (or macros) that can be used to access the device. Other driver
|
||||
* functions are defined in xqspips.h.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00 sdm 11/25/10 First release
|
||||
* 2.00a ka 07/25/12 Added a few register defines for CR 670297
|
||||
* and removed some defines of reserved fields for
|
||||
* CR 671468
|
||||
* Added define XQSPIPS_CR_HOLD_B_MASK for Holdb_dr
|
||||
* bit in Configuration register.
|
||||
* 2.01a sg 02/03/13 Added defines for DelayNss,Rx Watermark,Interrupts
|
||||
* which need write to clear. Removed Read zeros mask from
|
||||
* LQSPI Config register.
|
||||
* 2.03a hk 08/22/13 Added prototypes of API's for QSPI reset and
|
||||
* linear mode initialization for boot. Added related
|
||||
* constant definitions.
|
||||
* 3.1 hk 08/13/14 Changed definition of CR reset value masks to set/reset
|
||||
* required bits leaving reserved bits untouched. CR# 796813.
|
||||
* 3.2 sk 02/05/15 Add SLCR reset in abort function as a workaround because
|
||||
* controller does not update FIFO status flags as expected
|
||||
* when thresholds are used.
|
||||
* 3.6 akm 03/28/19 Fixed memory leak issue while reading from qspi.(CR#1016357)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XQSPIPS_HW_H /* prevent circular inclusions */
|
||||
#define XQSPIPS_HW_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xil_io.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Register Map
|
||||
*
|
||||
* Register offsets from the base address of an QSPI device.
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_CR_OFFSET 0x00 /**< Configuration Register */
|
||||
#define XQSPIPS_SR_OFFSET 0x04 /**< Interrupt Status */
|
||||
#define XQSPIPS_IER_OFFSET 0x08 /**< Interrupt Enable */
|
||||
#define XQSPIPS_IDR_OFFSET 0x0c /**< Interrupt Disable */
|
||||
#define XQSPIPS_IMR_OFFSET 0x10 /**< Interrupt Enabled Mask */
|
||||
#define XQSPIPS_ER_OFFSET 0x14 /**< Enable/Disable Register */
|
||||
#define XQSPIPS_DR_OFFSET 0x18 /**< Delay Register */
|
||||
#define XQSPIPS_TXD_00_OFFSET 0x1C /**< Transmit 4-byte inst/data */
|
||||
#define XQSPIPS_RXD_OFFSET 0x20 /**< Data Receive Register */
|
||||
#define XQSPIPS_SICR_OFFSET 0x24 /**< Slave Idle Count */
|
||||
#define XQSPIPS_TXWR_OFFSET 0x28 /**< Transmit FIFO Watermark */
|
||||
#define XQSPIPS_RXWR_OFFSET 0x2C /**< Receive FIFO Watermark */
|
||||
#define XQSPIPS_GPIO_OFFSET 0x30 /**< GPIO Register */
|
||||
#define XQSPIPS_LPBK_DLY_ADJ_OFFSET 0x38 /**< Loopback Delay Adjust Reg */
|
||||
#define XQSPIPS_TXD_01_OFFSET 0x80 /**< Transmit 1-byte inst */
|
||||
#define XQSPIPS_TXD_10_OFFSET 0x84 /**< Transmit 2-byte inst */
|
||||
#define XQSPIPS_TXD_11_OFFSET 0x88 /**< Transmit 3-byte inst */
|
||||
#define XQSPIPS_LQSPI_CR_OFFSET 0xA0 /**< Linear QSPI config register */
|
||||
#define XQSPIPS_LQSPI_SR_OFFSET 0xA4 /**< Linear QSPI status register */
|
||||
#define XQSPIPS_MOD_ID_OFFSET 0xFC /**< Module ID register */
|
||||
|
||||
/* @} */
|
||||
|
||||
/** @name Configuration Register
|
||||
*
|
||||
* This register contains various control bits that
|
||||
* affect the operation of the QSPI device. Read/Write.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XQSPIPS_CR_IFMODE_MASK 0x80000000 /**< Flash mem interface mode */
|
||||
#define XQSPIPS_CR_ENDIAN_MASK 0x04000000 /**< Tx/Rx FIFO endianness */
|
||||
#define XQSPIPS_CR_MANSTRT_MASK 0x00010000 /**< Manual Transmission Start */
|
||||
#define XQSPIPS_CR_MANSTRTEN_MASK 0x00008000 /**< Manual Transmission Start
|
||||
Enable */
|
||||
#define XQSPIPS_CR_SSFORCE_MASK 0x00004000 /**< Force Slave Select */
|
||||
#define XQSPIPS_CR_SSCTRL_MASK 0x00000400 /**< Slave Select Decode */
|
||||
#define XQSPIPS_CR_SSCTRL_SHIFT 10 /**< Slave Select Decode shift */
|
||||
#define XQSPIPS_CR_DATA_SZ_MASK 0x000000C0 /**< Size of word to be
|
||||
transferred */
|
||||
#define XQSPIPS_CR_PRESC_MASK 0x00000038 /**< Prescaler Setting */
|
||||
#define XQSPIPS_CR_PRESC_SHIFT 3 /**< Prescaler shift */
|
||||
#define XQSPIPS_CR_PRESC_MAXIMUM 0x07 /**< Prescaler maximum value */
|
||||
|
||||
#define XQSPIPS_CR_CPHA_MASK 0x00000004 /**< Phase Configuration */
|
||||
#define XQSPIPS_CR_CPOL_MASK 0x00000002 /**< Polarity Configuration */
|
||||
|
||||
#define XQSPIPS_CR_MSTREN_MASK 0x00000001 /**< Master Mode Enable */
|
||||
|
||||
#define XQSPIPS_CR_HOLD_B_MASK 0x00080000 /**< HOLD_B Pin Drive Enable */
|
||||
|
||||
#define XQSPIPS_CR_REF_CLK_MASK 0x00000100 /**< Ref clk bit - should be 0 */
|
||||
|
||||
/* Deselect the Slave select line and set the transfer size to 32 at reset */
|
||||
#define XQSPIPS_CR_RESET_MASK_SET XQSPIPS_CR_IFMODE_MASK | \
|
||||
XQSPIPS_CR_SSCTRL_MASK | \
|
||||
XQSPIPS_CR_DATA_SZ_MASK | \
|
||||
XQSPIPS_CR_MSTREN_MASK | \
|
||||
XQSPIPS_CR_SSFORCE_MASK | \
|
||||
XQSPIPS_CR_HOLD_B_MASK
|
||||
#define XQSPIPS_CR_RESET_MASK_CLR XQSPIPS_CR_CPOL_MASK | \
|
||||
XQSPIPS_CR_CPHA_MASK | \
|
||||
XQSPIPS_CR_PRESC_MASK | \
|
||||
XQSPIPS_CR_MANSTRTEN_MASK | \
|
||||
XQSPIPS_CR_MANSTRT_MASK | \
|
||||
XQSPIPS_CR_ENDIAN_MASK | \
|
||||
XQSPIPS_CR_REF_CLK_MASK
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name QSPI Interrupt Registers
|
||||
*
|
||||
* <b>QSPI Status Register</b>
|
||||
*
|
||||
* This register holds the interrupt status flags for an QSPI device. Some
|
||||
* of the flags are level triggered, which means that they are set as long
|
||||
* as the interrupt condition exists. Other flags are edge triggered,
|
||||
* which means they are set once the interrupt condition occurs and remain
|
||||
* set until they are cleared by software. The interrupts are cleared by
|
||||
* writing a '1' to the interrupt bit position in the Status Register.
|
||||
* Read/Write.
|
||||
*
|
||||
* <b>QSPI Interrupt Enable Register</b>
|
||||
*
|
||||
* This register is used to enable chosen interrupts for an QSPI device.
|
||||
* Writing a '1' to a bit in this register sets the corresponding bit in the
|
||||
* QSPI Interrupt Mask register. Write only.
|
||||
*
|
||||
* <b>QSPI Interrupt Disable Register </b>
|
||||
*
|
||||
* This register is used to disable chosen interrupts for an QSPI device.
|
||||
* Writing a '1' to a bit in this register clears the corresponding bit in the
|
||||
* QSPI Interrupt Mask register. Write only.
|
||||
*
|
||||
* <b>QSPI Interrupt Mask Register</b>
|
||||
*
|
||||
* This register shows the enabled/disabled interrupts of an QSPI device.
|
||||
* Read only.
|
||||
*
|
||||
* All four registers have the same bit definitions. They are only defined once
|
||||
* for each of the Interrupt Enable Register, Interrupt Disable Register,
|
||||
* Interrupt Mask Register, and Channel Interrupt Status Register
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XQSPIPS_IXR_TXUF_MASK 0x00000040 /**< QSPI Tx FIFO Underflow */
|
||||
#define XQSPIPS_IXR_RXFULL_MASK 0x00000020 /**< QSPI Rx FIFO Full */
|
||||
#define XQSPIPS_IXR_RXNEMPTY_MASK 0x00000010 /**< QSPI Rx FIFO Not Empty */
|
||||
#define XQSPIPS_IXR_TXFULL_MASK 0x00000008 /**< QSPI Tx FIFO Full */
|
||||
#define XQSPIPS_IXR_TXOW_MASK 0x00000004 /**< QSPI Tx FIFO Overwater */
|
||||
#define XQSPIPS_IXR_RXOVR_MASK 0x00000001 /**< QSPI Rx FIFO Overrun */
|
||||
#define XQSPIPS_IXR_DFLT_MASK 0x00000025 /**< QSPI default interrupts
|
||||
mask */
|
||||
#define XQSPIPS_IXR_WR_TO_CLR_MASK 0x00000041 /**< Interrupts which
|
||||
need write to clear */
|
||||
#define XQSPIPS_ISR_RESET_STATE 0x00000004 /**< Default to tx/rx empty */
|
||||
#define XQSPIPS_IXR_DISABLE_ALL 0x0000007D /**< Disable all interrupts */
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name Enable Register
|
||||
*
|
||||
* This register is used to enable or disable an QSPI device.
|
||||
* Read/Write
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_ER_ENABLE_MASK 0x00000001 /**< QSPI Enable Bit Mask */
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name Delay Register
|
||||
*
|
||||
* This register is used to program timing delays in
|
||||
* slave mode. Read/Write
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_DR_NSS_MASK 0xFF000000 /**< Delay to de-assert slave select
|
||||
between two words mask */
|
||||
#define XQSPIPS_DR_NSS_SHIFT 24 /**< Delay to de-assert slave select
|
||||
between two words shift */
|
||||
#define XQSPIPS_DR_BTWN_MASK 0x00FF0000 /**< Delay Between Transfers
|
||||
mask */
|
||||
#define XQSPIPS_DR_BTWN_SHIFT 16 /**< Delay Between Transfers shift */
|
||||
#define XQSPIPS_DR_AFTER_MASK 0x0000FF00 /**< Delay After Transfers mask */
|
||||
#define XQSPIPS_DR_AFTER_SHIFT 8 /**< Delay After Transfers shift */
|
||||
#define XQSPIPS_DR_INIT_MASK 0x000000FF /**< Delay Initially mask */
|
||||
/* @} */
|
||||
|
||||
/** @name Slave Idle Count Registers
|
||||
*
|
||||
* This register defines the number of pclk cycles the slave waits for a the
|
||||
* QSPI clock to become stable in quiescent state before it can detect the start
|
||||
* of the next transfer in CPHA = 1 mode.
|
||||
* Read/Write
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_SICR_MASK 0x000000FF /**< Slave Idle Count Mask */
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name Transmit FIFO Watermark Register
|
||||
*
|
||||
* This register defines the watermark setting for the Transmit FIFO.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_TXWR_MASK 0x0000003F /**< Transmit Watermark Mask */
|
||||
#define XQSPIPS_TXWR_RESET_VALUE 0x00000001 /**< Transmit Watermark
|
||||
* register reset value */
|
||||
|
||||
/* @} */
|
||||
|
||||
/** @name Receive FIFO Watermark Register
|
||||
*
|
||||
* This register defines the watermark setting for the Receive FIFO.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_RXWR_MASK 0x0000003F /**< Receive Watermark Mask */
|
||||
#define XQSPIPS_RXWR_RESET_VALUE 0x00000001 /**< Receive Watermark
|
||||
* register reset value */
|
||||
|
||||
/* @} */
|
||||
|
||||
/** @name FIFO Depth
|
||||
*
|
||||
* This macro provides the depth of transmit FIFO and receive FIFO.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_FIFO_DEPTH 63 /**< FIFO depth (words) */
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name Linear QSPI Configuration Register
|
||||
*
|
||||
* This register contains various control bits that
|
||||
* affect the operation of the Linear QSPI controller. Read/Write.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_LQSPI_CR_LINEAR_MASK 0x80000000 /**< LQSPI mode enable */
|
||||
#define XQSPIPS_LQSPI_CR_TWO_MEM_MASK 0x40000000 /**< Both memories or one */
|
||||
#define XQSPIPS_LQSPI_CR_SEP_BUS_MASK 0x20000000 /**< Separate memory bus */
|
||||
#define XQSPIPS_LQSPI_CR_U_PAGE_MASK 0x10000000 /**< Upper memory page */
|
||||
#define XQSPIPS_LQSPI_CR_MODE_EN_MASK 0x02000000 /**< Enable mode bits */
|
||||
#define XQSPIPS_LQSPI_CR_MODE_ON_MASK 0x01000000 /**< Mode on */
|
||||
#define XQSPIPS_LQSPI_CR_MODE_BITS_MASK 0x00FF0000 /**< Mode value for dual I/O
|
||||
or quad I/O */
|
||||
#define XQSPIPS_LQSPI_CR_DUMMY_MASK 0x00000700 /**< Number of dummy bytes
|
||||
between addr and return
|
||||
read data */
|
||||
#define XQSPIPS_LQSPI_CR_INST_MASK 0x000000FF /**< Read instr code */
|
||||
#define XQSPIPS_LQSPI_CR_RST_STATE 0x8000016B /**< Default CR value */
|
||||
/* @} */
|
||||
|
||||
/** @name Linear QSPI Status Register
|
||||
*
|
||||
* This register contains various status bits of the Linear QSPI controller.
|
||||
* Read/Write.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define XQSPIPS_LQSPI_SR_D_FSM_ERR_MASK 0x00000004 /**< AXI Data FSM Error
|
||||
received */
|
||||
#define XQSPIPS_LQSPI_SR_WR_RECVD_MASK 0x00000002 /**< AXI write command
|
||||
received */
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name Loopback Delay Adjust Register
|
||||
*
|
||||
* This register contains various bit masks of Loopback Delay Adjust Register.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XQSPIPS_LPBK_DLY_ADJ_USE_LPBK_MASK 0x00000020 /**< Loopback Bit */
|
||||
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name SLCR Register
|
||||
*
|
||||
* Register offsets from SLCR base address.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define SLCR_LOCK 0x00000004 /**< SLCR Write Protection Lock */
|
||||
#define SLCR_UNLOCK 0x00000008 /**< SLCR Write Protection Unlock */
|
||||
#define LQSPI_RST_CTRL 0x00000230 /**< Quad SPI Software Reset Control */
|
||||
#define SLCR_LOCKSTA 0x0000000C /**< SLCR Write Protection status */
|
||||
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name SLCR Register
|
||||
*
|
||||
* Bit Masks of above SLCR Registers .
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef XPAR_XSLCR_0_BASEADDR
|
||||
#define XPAR_XSLCR_0_BASEADDR 0xF8000000
|
||||
#endif
|
||||
#define SLCR_LOCK_MASK 0x767B /**< Write Protection Lock mask*/
|
||||
#define SLCR_UNLOCK_MASK 0xDF0D /**< SLCR Write Protection Unlock */
|
||||
#define LQSPI_RST_CTRL_MASK 0x3 /**< Quad SPI Software Reset Control */
|
||||
|
||||
/* @} */
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
#define XQspiPs_In32 Xil_In32
|
||||
#define XQspiPs_Out32 Xil_Out32
|
||||
#define XQSPIPS_DUMMY_TX_DATA 0xFFFFFFFF
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* Read a register.
|
||||
*
|
||||
* @param BaseAddress contains the base address of the device.
|
||||
* @param RegOffset contains the offset from the 1st register of the
|
||||
* device to the target register.
|
||||
*
|
||||
* @return The value read from the register.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* u32 XQspiPs_ReadReg(u32 BaseAddress. int RegOffset)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XQspiPs_ReadReg(BaseAddress, RegOffset) \
|
||||
XQspiPs_In32((BaseAddress) + (RegOffset))
|
||||
|
||||
/***************************************************************************/
|
||||
/**
|
||||
* Write to a register.
|
||||
*
|
||||
* @param BaseAddress contains the base address of the device.
|
||||
* @param RegOffset contains the offset from the 1st register of the
|
||||
* device to target register.
|
||||
* @param RegisterValue is the value to be written to the register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-Style signature:
|
||||
* void XQspiPs_WriteReg(u32 BaseAddress, int RegOffset,
|
||||
* u32 RegisterValue)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XQspiPs_WriteReg(BaseAddress, RegOffset, RegisterValue) \
|
||||
XQspiPs_Out32((BaseAddress) + (RegOffset), (RegisterValue))
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*
|
||||
* Functions implemented in xqspips_hw.c
|
||||
*/
|
||||
void XQspiPs_ResetHw(u32 BaseAddress);
|
||||
void XQspiPs_LinearInit(u32 BaseAddress);
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
404
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_options.c
Normal file
404
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_options.c
Normal file
@ -0,0 +1,404 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xqspips_options.c
|
||||
* @addtogroup qspips_v3_10
|
||||
* @{
|
||||
*
|
||||
* Contains functions for the configuration of the XQspiPs driver component.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00 sdm 11/25/10 First release
|
||||
* 2.00a kka 07/25/12 Removed the selection for the following options:
|
||||
* Master mode (XQSPIPS_MASTER_OPTION) and
|
||||
* Flash interface mode (XQSPIPS_FLASH_MODE_OPTION) option
|
||||
* as the QSPI driver supports the Master mode
|
||||
* and Flash Interface mode. The driver doesnot support
|
||||
* Slave mode or the legacy mode.
|
||||
* Added the option for setting the Holdb_dr bit in the
|
||||
* configuration options, XQSPIPS_HOLD_B_DRIVE_OPTION
|
||||
* is the option to be used for setting this bit in the
|
||||
* configuration register.
|
||||
* 2.01a sg 02/03/13 SetDelays and GetDelays API's include DelayNss parameter.
|
||||
*
|
||||
* 2.02a hk 26/03/13 Removed XQspi_Reset() in Set_Options() function when
|
||||
* LQSPI_MODE_OPTION is set. Moved Enable() to XQpsiPs_LqspiRead().
|
||||
* 3.3 sk 11/07/15 Modified the API prototypes according to MISRAC standards
|
||||
* to remove compilation warnings. CR# 868893.
|
||||
*</pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xqspips.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/*
|
||||
* Create the table of options which are processed to get/set the device
|
||||
* options. These options are table driven to allow easy maintenance and
|
||||
* expansion of the options.
|
||||
*/
|
||||
typedef struct {
|
||||
u32 Option;
|
||||
u32 Mask;
|
||||
} OptionsMap;
|
||||
|
||||
static OptionsMap OptionsTable[] = {
|
||||
{XQSPIPS_CLK_ACTIVE_LOW_OPTION, XQSPIPS_CR_CPOL_MASK},
|
||||
{XQSPIPS_CLK_PHASE_1_OPTION, XQSPIPS_CR_CPHA_MASK},
|
||||
{XQSPIPS_FORCE_SSELECT_OPTION, XQSPIPS_CR_SSFORCE_MASK},
|
||||
{XQSPIPS_MANUAL_START_OPTION, XQSPIPS_CR_MANSTRTEN_MASK},
|
||||
{XQSPIPS_HOLD_B_DRIVE_OPTION, XQSPIPS_CR_HOLD_B_MASK},
|
||||
};
|
||||
|
||||
#define XQSPIPS_NUM_OPTIONS (sizeof(OptionsTable) / sizeof(OptionsMap))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function sets the options for the QSPI device driver. The options control
|
||||
* how the device behaves relative to the QSPI bus. The device must be idle
|
||||
* rather than busy transferring data before setting these device options.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
* @param Options contains the specified options to be set. This is a bit
|
||||
* mask where a 1 means to turn the option on, and a 0 means to
|
||||
* turn the option off. One or more bit values may be contained in
|
||||
* the mask. See the bit definitions named XQSPIPS_*_OPTIONS in
|
||||
* the file xqspips.h.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if options are successfully set.
|
||||
* - XST_DEVICE_BUSY if the device is currently transferring data.
|
||||
* The transfer must complete or be aborted before setting options.
|
||||
*
|
||||
* @note
|
||||
* This function is not thread-safe.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XQspiPs_SetOptions(XQspiPs *InstancePtr, u32 Options)
|
||||
{
|
||||
u32 ConfigReg;
|
||||
unsigned int Index;
|
||||
u32 QspiOptions;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Do not allow to modify the Control Register while a transfer is in
|
||||
* progress. Not thread-safe.
|
||||
*/
|
||||
if (InstancePtr->IsBusy) {
|
||||
return XST_DEVICE_BUSY;
|
||||
}
|
||||
|
||||
QspiOptions = Options & XQSPIPS_LQSPI_MODE_OPTION;
|
||||
Options &= ~XQSPIPS_LQSPI_MODE_OPTION;
|
||||
|
||||
ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_CR_OFFSET);
|
||||
|
||||
/*
|
||||
* Loop through the options table, turning the option on or off
|
||||
* depending on whether the bit is set in the incoming options flag.
|
||||
*/
|
||||
for (Index = 0; Index < XQSPIPS_NUM_OPTIONS; Index++) {
|
||||
if (Options & OptionsTable[Index].Option) {
|
||||
/* Turn it on */
|
||||
ConfigReg |= OptionsTable[Index].Mask;
|
||||
} else {
|
||||
/* Turn it off */
|
||||
ConfigReg &= ~(OptionsTable[Index].Mask);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now write the control register. Leave it to the upper layers
|
||||
* to restart the device.
|
||||
*/
|
||||
XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPS_CR_OFFSET,
|
||||
ConfigReg);
|
||||
|
||||
/*
|
||||
* Check for the LQSPI configuration options.
|
||||
*/
|
||||
ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_LQSPI_CR_OFFSET);
|
||||
|
||||
|
||||
if (QspiOptions & XQSPIPS_LQSPI_MODE_OPTION) {
|
||||
XQspiPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_LQSPI_CR_OFFSET,
|
||||
XQSPIPS_LQSPI_CR_RST_STATE);
|
||||
XQspiPs_SetSlaveSelect(InstancePtr);
|
||||
} else {
|
||||
ConfigReg &= ~XQSPIPS_LQSPI_CR_LINEAR_MASK;
|
||||
XQspiPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_LQSPI_CR_OFFSET, ConfigReg);
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function gets the options for the QSPI device. The options control how
|
||||
* the device behaves relative to the QSPI bus.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* Options contains the specified options currently set. This is a bit value
|
||||
* where a 1 means the option is on, and a 0 means the option is off.
|
||||
* See the bit definitions named XQSPIPS_*_OPTIONS in file xqspips.h.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
u32 XQspiPs_GetOptions(XQspiPs *InstancePtr)
|
||||
{
|
||||
u32 OptionsFlag = 0;
|
||||
u32 ConfigReg;
|
||||
unsigned int Index;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Get the current options from QSPI configuration register.
|
||||
*/
|
||||
ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_CR_OFFSET);
|
||||
|
||||
/*
|
||||
* Loop through the options table to grab options
|
||||
*/
|
||||
for (Index = 0; Index < XQSPIPS_NUM_OPTIONS; Index++) {
|
||||
if (ConfigReg & OptionsTable[Index].Mask) {
|
||||
OptionsFlag |= OptionsTable[Index].Option;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for the LQSPI configuration options.
|
||||
*/
|
||||
ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_LQSPI_CR_OFFSET);
|
||||
|
||||
if ((ConfigReg & XQSPIPS_LQSPI_CR_LINEAR_MASK) != 0) {
|
||||
OptionsFlag |= XQSPIPS_LQSPI_MODE_OPTION;
|
||||
}
|
||||
|
||||
return OptionsFlag;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function sets the clock prescaler for an QSPI device. The device
|
||||
* must be idle rather than busy transferring data before setting these device
|
||||
* options.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
* @param Prescaler is the value that determine how much the clock should
|
||||
* be divided by. Use the XQSPIPS_CLK_PRESCALE_* constants defined
|
||||
* in xqspips.h for this setting.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if options are successfully set.
|
||||
* - XST_DEVICE_BUSY if the device is currently transferring data.
|
||||
* The transfer must complete or be aborted before setting options.
|
||||
*
|
||||
* @note
|
||||
* This function is not thread-safe.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XQspiPs_SetClkPrescaler(XQspiPs *InstancePtr, u8 Prescaler)
|
||||
{
|
||||
u32 ConfigReg;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
Xil_AssertNonvoid(Prescaler <= XQSPIPS_CR_PRESC_MAXIMUM);
|
||||
|
||||
/*
|
||||
* Do not allow the slave select to change while a transfer is in
|
||||
* progress. Not thread-safe.
|
||||
*/
|
||||
if (InstancePtr->IsBusy) {
|
||||
return XST_DEVICE_BUSY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the configuration register, mask out the interesting bits, and set
|
||||
* them with the shifted value passed into the function. Write the
|
||||
* results back to the configuration register.
|
||||
*/
|
||||
ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_CR_OFFSET);
|
||||
|
||||
ConfigReg &= ~XQSPIPS_CR_PRESC_MASK;
|
||||
ConfigReg |= (u32) (Prescaler & XQSPIPS_CR_PRESC_MAXIMUM) <<
|
||||
XQSPIPS_CR_PRESC_SHIFT;
|
||||
|
||||
XQspiPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_CR_OFFSET,
|
||||
ConfigReg);
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function gets the clock prescaler of an QSPI device.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
*
|
||||
* @return The prescaler value.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
u8 XQspiPs_GetClkPrescaler(XQspiPs *InstancePtr)
|
||||
{
|
||||
u32 ConfigReg;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_CR_OFFSET);
|
||||
|
||||
ConfigReg &= XQSPIPS_CR_PRESC_MASK;
|
||||
|
||||
return (u8)(ConfigReg >> XQSPIPS_CR_PRESC_SHIFT);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function sets the delay register for the QSPI device driver.
|
||||
* The delay register controls the Delay Between Transfers, Delay After
|
||||
* Transfers, and the Delay Initially. The default value is 0x0. The range of
|
||||
* each delay value is 0-255.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
* @param DelayNss is the delay to de-assert slave select between
|
||||
* two word transfers.
|
||||
* @param DelayBtwn is the delay between one Slave Select being
|
||||
* de-activated and the activation of another slave. The delay is
|
||||
* the number of master clock periods given by DelayBtwn + 2.
|
||||
* @param DelayAfter define the delay between the last bit of the current
|
||||
* byte transfer and the first bit of the next byte transfer.
|
||||
* The delay in number of master clock periods is given as:
|
||||
* CHPA=0:DelayInit+DelayAfter+3
|
||||
* CHPA=1:DelayAfter+1
|
||||
* @param DelayInit is the delay between asserting the slave select signal
|
||||
* and the first bit transfer. The delay int number of master clock
|
||||
* periods is DelayInit+1.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if delays are successfully set.
|
||||
* - XST_DEVICE_BUSY if the device is currently transferring data.
|
||||
* The transfer must complete or be aborted before setting options.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XQspiPs_SetDelays(XQspiPs *InstancePtr, u8 DelayNss, u8 DelayBtwn,
|
||||
u8 DelayAfter, u8 DelayInit)
|
||||
{
|
||||
u32 DelayRegister;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Do not allow the delays to change while a transfer is in
|
||||
* progress. Not thread-safe.
|
||||
*/
|
||||
if (InstancePtr->IsBusy) {
|
||||
return XST_DEVICE_BUSY;
|
||||
}
|
||||
|
||||
/* Shift, Mask and OR the values to build the register settings */
|
||||
DelayRegister = (u32) DelayNss << XQSPIPS_DR_NSS_SHIFT;
|
||||
DelayRegister |= (u32) DelayBtwn << XQSPIPS_DR_BTWN_SHIFT;
|
||||
DelayRegister |= (u32) DelayAfter << XQSPIPS_DR_AFTER_SHIFT;
|
||||
DelayRegister |= (u32) DelayInit;
|
||||
|
||||
XQspiPs_WriteReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_DR_OFFSET, DelayRegister);
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function gets the delay settings for an QSPI device.
|
||||
* The delay register controls the Delay Between Transfers, Delay After
|
||||
* Transfers, and the Delay Initially. The default value is 0x0.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
* @param DelayNss is a pointer to the Delay to de-assert slave select
|
||||
* between two word transfers.
|
||||
* @param DelayBtwn is a pointer to the Delay Between transfers value.
|
||||
* This is a return parameter.
|
||||
* @param DelayAfter is a pointer to the Delay After transfer value.
|
||||
* This is a return parameter.
|
||||
* @param DelayInit is a pointer to the Delay Initially value. This is
|
||||
* a return parameter.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XQspiPs_GetDelays(XQspiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn,
|
||||
u8 *DelayAfter, u8 *DelayInit)
|
||||
{
|
||||
u32 DelayRegister;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
DelayRegister = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XQSPIPS_DR_OFFSET);
|
||||
|
||||
*DelayInit = (u8)(DelayRegister & XQSPIPS_DR_INIT_MASK);
|
||||
|
||||
*DelayAfter = (u8)((DelayRegister & XQSPIPS_DR_AFTER_MASK) >>
|
||||
XQSPIPS_DR_AFTER_SHIFT);
|
||||
|
||||
*DelayBtwn = (u8)((DelayRegister & XQSPIPS_DR_BTWN_MASK) >>
|
||||
XQSPIPS_DR_BTWN_SHIFT);
|
||||
|
||||
*DelayNss = (u8)((DelayRegister & XQSPIPS_DR_NSS_MASK) >>
|
||||
XQSPIPS_DR_NSS_SHIFT);
|
||||
}
|
||||
/** @} */
|
113
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_selftest.c
Normal file
113
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_selftest.c
Normal file
@ -0,0 +1,113 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xqspips_selftest.c
|
||||
* @addtogroup qspips_v3_10
|
||||
* @{
|
||||
*
|
||||
* This file contains the implementation of selftest function for the QSPI
|
||||
* device.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00 sdm 11/25/10 First release
|
||||
* 2.01a sg 02/03/13 Delay Register test is added with DelayNss parameter.
|
||||
* 3.1 hk 06/19/14 Remove checks for CR and ISR register values as they are
|
||||
* reset in the previous step.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xqspips.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Runs a self-test on the driver/device. The self-test is destructive in that
|
||||
* a reset of the device is performed in order to check the reset values of
|
||||
* the registers and to get the device into a known state.
|
||||
*
|
||||
* Upon successful return from the self-test, the device is reset.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XQspiPs instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful
|
||||
* - XST_REGISTER_ERROR indicates a register did not read or write
|
||||
* correctly.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int XQspiPs_SelfTest(XQspiPs *InstancePtr)
|
||||
{
|
||||
int Status;
|
||||
u8 DelayTestNss;
|
||||
u8 DelayTestBtwn;
|
||||
u8 DelayTestAfter;
|
||||
u8 DelayTestInit;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Reset the QSPI device to leave it in a known good state
|
||||
*/
|
||||
XQspiPs_Reset(InstancePtr);
|
||||
|
||||
DelayTestNss = 0x5A;
|
||||
DelayTestBtwn = 0xA5;
|
||||
DelayTestAfter = 0xAA;
|
||||
DelayTestInit = 0x55;
|
||||
|
||||
/*
|
||||
* Write and read the delay register, just to be sure there is some
|
||||
* hardware out there.
|
||||
*/
|
||||
Status = XQspiPs_SetDelays(InstancePtr, DelayTestNss, DelayTestBtwn,
|
||||
DelayTestAfter, DelayTestInit);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
XQspiPs_GetDelays(InstancePtr, &DelayTestNss, &DelayTestBtwn,
|
||||
&DelayTestAfter, &DelayTestInit);
|
||||
if ((0x5A != DelayTestNss) || (0xA5 != DelayTestBtwn) ||
|
||||
(0xAA != DelayTestAfter) || (0x55 != DelayTestInit)) {
|
||||
return XST_REGISTER_ERROR;
|
||||
}
|
||||
|
||||
Status = XQspiPs_SetDelays(InstancePtr, 0, 0, 0, 0);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the QSPI device to leave it in a known good state
|
||||
*/
|
||||
XQspiPs_Reset(InstancePtr);
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
||||
/** @} */
|
74
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_sinit.c
Normal file
74
bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_sinit.c
Normal file
@ -0,0 +1,74 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xqspips_sinit.c
|
||||
* @addtogroup qspips_v3_10
|
||||
* @{
|
||||
*
|
||||
* The implementation of the XQspiPs component's static initialization
|
||||
* functionality.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00 sdm 11/25/10 First release
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xqspips.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
extern XQspiPs_Config XQspiPs_ConfigTable[];
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Looks up the device configuration based on the unique device ID. A table
|
||||
* contains the configuration info for each device in the system.
|
||||
*
|
||||
* @param DeviceId contains the ID of the device to look up the
|
||||
* configuration for.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* A pointer to the configuration found or NULL if the specified device ID was
|
||||
* not found. See xqspips.h for the definition of XQspiPs_Config.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
XQspiPs_Config *XQspiPs_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
XQspiPs_Config *CfgPtr = NULL;
|
||||
int Index;
|
||||
|
||||
for (Index = 0; Index < XPAR_XQSPIPS_NUM_INSTANCES; Index++) {
|
||||
if (XQspiPs_ConfigTable[Index].DeviceId == DeviceId) {
|
||||
CfgPtr = &XQspiPs_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return CfgPtr;
|
||||
}
|
||||
/** @} */
|
39
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/Makefile
Normal file
39
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/Makefile
Normal file
@ -0,0 +1,39 @@
|
||||
DRIVER_LIB_VERSION = 1.0
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
CC_FLAGS = $(COMPILER_FLAGS)
|
||||
ECC_FLAGS = $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I$(INCLUDEDIR)
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR), $(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
libs: $(OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
${COMPILER} $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) $< -o $@
|
||||
|
||||
.PHONY: include
|
||||
include: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf ${DEPFILES}
|
1504
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic.c
Normal file
1504
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic.c
Normal file
File diff suppressed because it is too large
Load Diff
689
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic.h
Normal file
689
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic.h
Normal file
@ -0,0 +1,689 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscugic.h
|
||||
* @addtogroup scugic Overview
|
||||
* @{
|
||||
* @details
|
||||
*
|
||||
* The generic interrupt controller driver component.
|
||||
*
|
||||
* The interrupt controller driver uses the idea of priority for the various
|
||||
* handlers. Priority is an integer within the range of 1 and 31 inclusive with
|
||||
* default of 1 being the highest priority interrupt source. The priorities
|
||||
* of the various sources can be dynamically altered as needed through
|
||||
* hardware configuration.
|
||||
*
|
||||
* The generic interrupt controller supports the following
|
||||
* features:
|
||||
*
|
||||
* - specific individual interrupt enabling/disabling
|
||||
* - specific individual interrupt acknowledging
|
||||
* - attaching specific callback function to handle interrupt source
|
||||
* - assigning desired priority to interrupt source if default is not
|
||||
* acceptable.
|
||||
*
|
||||
* Details about connecting the interrupt handler of the driver are contained
|
||||
* in the source file specific to interrupt processing, xscugic_intr.c.
|
||||
*
|
||||
* This driver is intended to be RTOS and processor independent. It works with
|
||||
* physical addresses only. Any needs for dynamic memory management, threads
|
||||
* or thread mutual exclusion, virtual memory, or cache control must be
|
||||
* satisfied by the layer above this driver.
|
||||
*
|
||||
* <b>Interrupt Vector Tables</b>
|
||||
*
|
||||
* The device ID of the interrupt controller device is used by the driver as a
|
||||
* direct index into the configuration data table. The user should populate the
|
||||
* vector table with handlers and callbacks at run-time using the
|
||||
* XScuGic_Connect() and XScuGic_Disconnect() functions.
|
||||
*
|
||||
* Each vector table entry corresponds to a device that can generate an
|
||||
* interrupt. Each entry contains an interrupt handler function and an
|
||||
* argument to be passed to the handler when an interrupt occurs. The
|
||||
* user must use XScuGic_Connect() when the interrupt handler takes an
|
||||
* argument other than the base address.
|
||||
*
|
||||
* <b>Nested Interrupts Processing</b>
|
||||
*
|
||||
* Nested interrupts are not supported by this driver.
|
||||
*
|
||||
* NOTE:
|
||||
* The generic interrupt controller is not a part of the snoop control unit
|
||||
* as indicated by the prefix "scu" in the name of the driver.
|
||||
* It is an independent module in APU.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- ---------------------------------------------------------
|
||||
* 1.00a drg 01/19/00 First release
|
||||
* 1.01a sdm 11/09/11 The XScuGic and XScuGic_Config structures have changed.
|
||||
* The HandlerTable (of type XScuGic_VectorTableEntry) is
|
||||
* moved to XScuGic_Config structure from XScuGic structure.
|
||||
*
|
||||
* The "Config" entry in XScuGic structure is made as
|
||||
* pointer for better efficiency.
|
||||
*
|
||||
* A new file named as xscugic_hw.c is now added. It is
|
||||
* to implement low level driver routines without using
|
||||
* any xscugic instance pointer. They are useful when the
|
||||
* user wants to use xscugic through device id or
|
||||
* base address. The driver routines provided are explained
|
||||
* below.
|
||||
* XScuGic_DeviceInitialize that takes device id as
|
||||
* argument and initializes the device (without calling
|
||||
* XScuGic_CfgInitialize).
|
||||
* XScuGic_DeviceInterruptHandler that takes device id
|
||||
* as argument and calls appropriate handlers from the
|
||||
* HandlerTable.
|
||||
* XScuGic_RegisterHandler that registers a new handler
|
||||
* by taking xscugic hardware base address as argument.
|
||||
* LookupConfigByBaseAddress is used to return the
|
||||
* corresponding config structure from XScuGic_ConfigTable
|
||||
* based on the scugic base address passed.
|
||||
* 1.02a sdm 12/20/11 Removed AckBeforeService from the XScuGic_Config
|
||||
* structure.
|
||||
* 1.03a srt 02/27/13 Moved Offset calculation macros from *.c and *_hw.c to
|
||||
* *_hw.h
|
||||
* Added APIs
|
||||
* - XScuGic_SetPriTrigTypeByDistAddr()
|
||||
* - XScuGic_GetPriTrigTypeByDistAddr()
|
||||
* (CR 702687)
|
||||
* Added support to direct interrupts to the appropriate CPU. Earlier
|
||||
* interrupts were directed to CPU1 (hard coded). Now depending
|
||||
* upon the CPU selected by the user (xparameters.h), interrupts
|
||||
* will be directed to the relevant CPU. This fixes CR 699688.
|
||||
* 1.04a hk 05/04/13 Assigned EffectiveAddr to CpuBaseAddress in
|
||||
* XScuGic_CfgInitialize. Fix for CR#704400 to remove warnings.
|
||||
* Moved functions XScuGic_SetPriTrigTypeByDistAddr and
|
||||
* XScuGic_GetPriTrigTypeByDistAddr to xscugic_hw.c.
|
||||
* This is fix for CR#705621.
|
||||
* 1.05a hk 06/26/13 Modified tcl to export external interrupts correctly to
|
||||
* xparameters.h. Fix for CR's 690505, 708928 & 719359.
|
||||
* 2.0 adk 12/10/13 Updated as per the New Tcl API's
|
||||
* 2.1 adk 25/04/14 Fixed the CR:789373 changes are made in the driver tcl file.
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.2 asa 02/29/16 Modified DistributorInit function for Zynq AMP case. The
|
||||
* distributor is left uninitialized for Zynq AMP. It is assumed
|
||||
* that the distributor will be initialized by Linux master. However
|
||||
* for CortexR5 case, the earlier code is left unchanged where the
|
||||
* the interrupt processor target registers in the distributor is
|
||||
* initialized with the corresponding CPU ID on which the application
|
||||
* built over the scugic driver runs.
|
||||
* These changes fix CR#937243.
|
||||
*
|
||||
* 3.4 asa 04/07/16 Created a new static function DoDistributorInit to simplify
|
||||
* the flow and avoid code duplication. Changes are made for
|
||||
* USE_AMP use case for R5. In a scenario (in R5 split mode) when
|
||||
* one R5 is operating with A53 in open amp config and other
|
||||
* R5 running baremetal app, the existing code
|
||||
* had the potential to stop the whole AMP solution to work (if
|
||||
* for some reason the R5 running the baremetal app tasked to
|
||||
* initialize the Distributor hangs or crashes before initializing).
|
||||
* Changes are made so that the R5 under AMP first checks if
|
||||
* the distributor is enabled or not and if not, it does the
|
||||
* standard Distributor initialization.
|
||||
* This fixes the CR#952962.
|
||||
* 3.6 ms 01/23/17 Modified xil_printf statement in main function for all
|
||||
* examples to ensure that "Successfully ran" and "Failed"
|
||||
* strings are available in all examples. This is a fix
|
||||
* for CR-965028.
|
||||
* kvn 02/17/17 Add support for changing GIC CPU master at run time.
|
||||
* kvn 02/28/17 Make the CpuId as static variable and Added new
|
||||
* XScugiC_GetCpuId to access CpuId.
|
||||
* ms 03/17/17 Added readme.txt file in examples folder for doxygen
|
||||
* generation.
|
||||
* 3.7 ms 04/11/17 Modified tcl file to add suffix U for all macro
|
||||
* definitions of scugic in xparameters.h
|
||||
* 3.8 mus 07/05/17 Updated scugic.tcl to add support for interrupts connected
|
||||
* through util_reduced_vector IP(OR gate)
|
||||
* mus 07/05/17 Updated xdefine_zynq_canonical_xpars proc to initialize
|
||||
* the HandlerTable in XScuGic_ConfigTable to 0, it removes
|
||||
* the compilation warning in xscugic_g.c. Fix for CR#978736.
|
||||
* mus 07/25/17 Updated xdefine_gic_params proc to export correct canonical
|
||||
* definitions for pl to ps interrupts.Fix for CR#980534
|
||||
* 3.9 mus 02/21/18 Added new API's XScuGic_UnmapAllInterruptsFromCpu and
|
||||
* XScuGic_InterruptUnmapFromCpu, These API's can be used
|
||||
* by applications to unmap specific/all interrupts from
|
||||
* target CPU.
|
||||
* 3.10 aru 08/23/18 Resolved MISRA-C:2012 compliance mandatory violations
|
||||
* 4.0 mus 11/22/18 Fixed bugs in software interrupt generation through
|
||||
* XScuGic_SoftwareIntr API
|
||||
* 4.1 asa 03/30/19 Made changes not to direct each interrupt to all
|
||||
* available CPUs by default. This was breaking AMP
|
||||
* behavior. Instead every time an interrupt enable
|
||||
* request is received, the interrupt was mapped to
|
||||
* the respective CPU. There were several other changes
|
||||
* made to implement this. This set of changes was to
|
||||
* fix CR-1024716.
|
||||
* 4.1 mus 06/19/19 Added API's XScuGic_MarkCoreAsleep and
|
||||
* XScuGic_MarkCoreAwake to mark processor core as
|
||||
* asleep or awake. Fix for CR#1027220.
|
||||
* 4.5 asa 03/07/21 Included a header file xil_spinlock.h to ensure that
|
||||
* GIC driver can use newly introduced spinlock
|
||||
* functionality.
|
||||
* 4.6 sk 08/05/21 Fix scugic misrac violations.
|
||||
* 4.7 dp 11/22/21 Added new API XScuGic_IsInitialized() to check and return
|
||||
* the GIC initialization status.
|
||||
* 5.0 mus 22/02/22 Add support for VERSAL NET
|
||||
* adk 04/18/22 Replace infinite while loops in the examples with
|
||||
* Xil_WaitForEventSet() API.
|
||||
* dp 04/25/22 Correct Trigger index calculation in macro
|
||||
* XScuGic_Get_Rdist_Int_Trigger_Index
|
||||
* 5.0 dp 11/07/22 Add macros for accessing the GIC Binary Point and
|
||||
* Running Priority registers of Cortex-R52.
|
||||
* 5.1 mus 02/13/23 Updated XScuGic_CfgInitialize, XScuGic_Enable and
|
||||
* XScuGic_Disable to support interrupts on each core
|
||||
* of all CortexA78/CortexR52 clusters in VERSAL NET SoC.
|
||||
* While at it, modified interrupt routing logic to make
|
||||
* use of CPU affinity register instead of XPAR_CPU_ID macro.
|
||||
* Also, XScuGic_CfgInitialize has been updated to find
|
||||
* redistributor base address of core on which API is
|
||||
* executed, redistributor address will be stored in newly
|
||||
* added member of XScuGic data structure "RedistBaseAddr".
|
||||
* It fixes CR#1150432.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef XSCUGIC_H /* prevent circular inclusions */
|
||||
#define XSCUGIC_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xil_io.h"
|
||||
#include "xscugic_hw.h"
|
||||
#include "xil_exception.h"
|
||||
#include "xil_spinlock.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
#define EFUSE_STATUS_OFFSET 0x10
|
||||
#define EFUSE_STATUS_CPU_MASK 0x80
|
||||
|
||||
#if !defined (ARMR5) && !defined (__aarch64__) && !defined (ARMA53_32)
|
||||
#define ARMA9
|
||||
#endif
|
||||
|
||||
#define XSCUGIC500_DCTLR_ARE_NS_ENABLE 0x20
|
||||
#define XSCUGIC500_DCTLR_ARE_S_ENABLE 0x10
|
||||
|
||||
#if defined (VERSAL_NET)
|
||||
#define XSCUGIC_CLUSTERID_MASK 0xF0U
|
||||
#define XSCUGIC_COREID_MASK 0xFU
|
||||
#define XSCUGIC_CLUSTERID_SHIFT 4U
|
||||
#define XSCUGIC_COREID_SHIFT 0U
|
||||
|
||||
#define XSCUGIC_SGI1R_AFFINITY1_SHIFT 16U
|
||||
#define XSCUGIC_SGI1R_AFFINITY2_SHIFT 32U
|
||||
|
||||
#define XSCUGIC_IROUTER_AFFINITY1_SHIFT 8U
|
||||
#define XSCUGIC_IROUTER_AFFINITY2_SHIFT 16U
|
||||
|
||||
#define XSCUGIC_IROUTER_IRM_MASK 0x80000000U
|
||||
#endif
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/* The following data type defines each entry in an interrupt vector table.
|
||||
* The callback reference is the base address of the interrupting device
|
||||
* for the low level driver and an instance pointer for the high level driver.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Xil_InterruptHandler Handler;
|
||||
void *CallBackRef;
|
||||
} XScuGic_VectorTableEntry;
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for the device.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
u16 DeviceId; /**< Unique ID of device */
|
||||
u32 CpuBaseAddress; /**< CPU Interface Register base address */
|
||||
u32 DistBaseAddress; /**< Distributor Register base address */
|
||||
XScuGic_VectorTableEntry HandlerTable[XSCUGIC_MAX_NUM_INTR_INPUTS];/**<
|
||||
Vector table of interrupt handlers */
|
||||
} XScuGic_Config;
|
||||
|
||||
/**
|
||||
* The XScuGic driver instance data. The user is required to allocate a
|
||||
* variable of this type for every intc device in the system. A pointer
|
||||
* to a variable of this type is then passed to the driver API functions.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
XScuGic_Config *Config; /**< Configuration table entry */
|
||||
#if defined (GICv3)
|
||||
UINTPTR RedistBaseAddr;
|
||||
#endif
|
||||
u32 IsReady; /**< Device is initialized and ready */
|
||||
u32 UnhandledInterrupts; /**< Intc Statistics */
|
||||
} XScuGic;
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write the given CPU Interface register
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param RegOffset is the register offset to be written
|
||||
* @param Data is the 32-bit value to write to the register
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XScuGic_CPUWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_CPUWriteReg(InstancePtr, RegOffset, Data) \
|
||||
(XScuGic_WriteReg(((InstancePtr)->Config->CpuBaseAddress), (RegOffset), \
|
||||
((u32)(Data))))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given CPU Interface register
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param RegOffset is the register offset to be read
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XScuGic_CPUReadReg(XScuGic *InstancePtr, u32 RegOffset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_CPUReadReg(InstancePtr, RegOffset) \
|
||||
(XScuGic_ReadReg(((InstancePtr)->Config->CpuBaseAddress), (RegOffset)))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write the given Distributor Interface register
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param RegOffset is the register offset to be written
|
||||
* @param Data is the 32-bit value to write to the register
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_DistWriteReg(InstancePtr, RegOffset, Data) \
|
||||
(XScuGic_WriteReg(((InstancePtr)->Config->DistBaseAddress), (RegOffset), \
|
||||
((u32)(Data))))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given Distributor Interface register
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param RegOffset is the register offset to be read
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_DistReadReg(InstancePtr, RegOffset) \
|
||||
(XScuGic_ReadReg(((InstancePtr)->Config->DistBaseAddress), (RegOffset)))
|
||||
|
||||
#if defined (GICv3)
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write the given ReDistributor Interface register
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param RegOffset is the register offset to be written
|
||||
* @param Data is the 32-bit value to write to the register
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_ReDistWriteReg(InstancePtr, RegOffset, Data) \
|
||||
(XScuGic_WriteReg(InstancePtr->RedistBaseAddr, RegOffset, (u32)Data))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given ReDistributor Interface register
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param RegOffset is the register offset to be read
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_ReDistReadReg(InstancePtr, RegOffset) \
|
||||
(XScuGic_ReadReg(InstancePtr->RedistBaseAddr, RegOffset))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write the given ReDistributor SGI PPI Interface register
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param RegOffset is the register offset to be written
|
||||
* @param Data is the 32-bit value to write to the register
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_ReDistSGIPPIWriteReg(InstancePtr, RegOffset, Data) \
|
||||
(XScuGic_WriteReg(InstancePtr->RedistBaseAddr + \
|
||||
XSCUGIC_RDIST_SGI_PPI_OFFSET, (RegOffset), ((u32)(Data))))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given ReDistributor SGI PPI Interface register
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param RegOffset is the register offset to be read
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_ReDistSGIPPIReadReg(InstancePtr, RegOffset) \
|
||||
(XScuGic_ReadReg(InstancePtr->RedistBaseAddr + XSCUGIC_RDIST_SGI_PPI_OFFSET, \
|
||||
RegOffset))
|
||||
|
||||
#if defined(ARMR52)
|
||||
#define XREG_ICC_SRE_EL1 "p15, 0, %0, c12, c12, 5"
|
||||
#define XREG_ICC_IGRPEN0_EL1 "p15, 0, %0, c12, c12, 6"
|
||||
#define XREG_ICC_IGRPEN1_EL1 "p15, 0, %0, c12, c12, 7"
|
||||
#define XREG_ICC_SGI0R_EL1 "p15, 2, %0, %1, c12"
|
||||
#define XREG_ICC_SGI1R_EL1 "p15, 0, %0, %1, c12"
|
||||
#define XREG_ICC_PMR_EL1 "p15, 0, %0, c4, c6, 0"
|
||||
#define XREG_ICC_IAR0_EL1 "p15, 0, %0, c12, c8, 0"
|
||||
#define XREG_ICC_EOIR0_EL1 "p15, 0, %0, c12, c8, 1"
|
||||
#define XREG_IMP_CBAR "p15, 1, %0, c15, c3, 0"
|
||||
#define XREG_ICC_BPR0_EL1 "p15, 0, %0, c12, c8, 3"
|
||||
#define XREG_ICC_RPR_EL1 "p15, 0, %0, c12, c11, 3"
|
||||
#else
|
||||
#define XREG_ICC_SRE_EL1 "S3_0_C12_C12_5"
|
||||
#define XREG_ICC_SRE_EL3 "S3_6_C12_C12_5"
|
||||
#define XREG_ICC_IGRPEN0_EL1 "S3_0_C12_C12_6"
|
||||
#define XREG_ICC_IGRPEN1_EL1 "S3_0_C12_C12_7"
|
||||
#define XREG_ICC_IGRPEN1_EL3 "S3_6_C12_C12_7"
|
||||
#define XREG_ICC_SGI0R_EL1 "S3_0_C12_C11_7"
|
||||
#define XREG_ICC_SGI1R_EL1 "S3_0_C12_C11_5"
|
||||
#define XREG_ICC_PMR_EL1 "S3_0_C4_C6_0"
|
||||
#define XREG_ICC_IAR0_EL1 "S3_0_C12_C8_0"
|
||||
#define XREG_ICC_IAR1_EL1 "S3_0_C12_C12_0"
|
||||
#define XREG_ICC_EOIR0_EL1 "S3_0_C12_C8_1"
|
||||
#define XREG_ICC_EOIR1_EL1 "S3_0_C12_C12_1"
|
||||
#endif
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This function enables system register interface for GIC CPU Interface
|
||||
*
|
||||
* @param value to be written
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined (__aarch64__)
|
||||
#define XScuGic_Enable_SystemReg_CPU_Interface_EL3() mtcpnotoken(XREG_ICC_SRE_EL3, 0xF);
|
||||
#define XScuGic_Enable_SystemReg_CPU_Interface_EL1() mtcpnotoken(XREG_ICC_SRE_EL1, 0xF);
|
||||
#elif defined (ARMR52)
|
||||
#define XScuGic_Enable_SystemReg_CPU_Interface_EL1() mtcp(XREG_ICC_SRE_EL1, 0xF);
|
||||
#endif
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This function enables Grou0 interrupts
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined(ARMR52)
|
||||
#define XScuGic_Enable_Group0_Interrupts() mtcp(XREG_ICC_IGRPEN0_EL1,0x1);
|
||||
#else
|
||||
#define XScuGic_Enable_Group0_Interrupts() mtcpnotoken(XREG_ICC_IGRPEN0_EL1,0x1);
|
||||
#endif
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This function enables Group1 interrupts
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined (ARMR52)
|
||||
|
||||
#define XScuGic_Enable_Group1_Interrupts() \
|
||||
mtcp (XREG_ICC_IGRPEN1_EL1, 0x1 | mfcp(XREG_ICC_IGRPEN1_EL1) );
|
||||
#elif EL1_NONSECURE
|
||||
#define XScuGic_Enable_Group1_Interrupts() \
|
||||
mtcpnotoken(XREG_ICC_IGRPEN1_EL1, 0x1 | mfcpnotoken(XREG_ICC_IGRPEN1_EL1) );
|
||||
#else
|
||||
#define XScuGic_Enable_Group1_Interrupts() \
|
||||
mtcpnotoken(XREG_ICC_IGRPEN1_EL3, 0x1 | mfcpnotoken(XREG_ICC_IGRPEN1_EL3) );
|
||||
#endif
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This function writes to ICC_SGI0R_EL1
|
||||
*
|
||||
* @param value to be written
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined(ARMR52)
|
||||
#define XScuGic_WriteICC_SGI0R_EL1(val) mtcp2(XREG_ICC_SGI0R_EL1,val)
|
||||
#else
|
||||
#define XScuGic_WriteICC_SGI0R_EL1(val) mtcpnotoken(XREG_ICC_SGI0R_EL1,val)
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This function writes to ICC_SGI1R_EL1
|
||||
*
|
||||
* @param value to be written
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined(ARMR52)
|
||||
#define XScuGic_WriteICC_SGI1R_EL1(val) mtcp2(XREG_ICC_SGI1R_EL1,val)
|
||||
#else
|
||||
#define XScuGic_WriteICC_SGI1R_EL1(val) mtcpnotoken(XREG_ICC_SGI1R_EL1,val)
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This function reads ICC_SGI1R_EL1 register
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return Value of ICC_SGI1R_EL1 register
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined (ARMR52)
|
||||
#define XScuGic_ReadICC_SGI1R_EL1() mfcp(XREG_ICC_SGI1R_EL1)
|
||||
#else
|
||||
#define XScuGic_ReadICC_SGI1R_EL1() mfcpnotoken(XREG_ICC_SGI1R_EL1)
|
||||
#endif
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This function sets interrupt priority filter
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined (ARMR52)
|
||||
#define XScuGic_set_priority_filter(val) mtcp(XREG_ICC_PMR_EL1, val)
|
||||
#else
|
||||
#define XScuGic_set_priority_filter(val) mtcpnotoken(XREG_ICC_PMR_EL1, val)
|
||||
#endif
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This function returns interrupt id of highest priority pending interrupt
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined(ARMR52)
|
||||
#define XScuGic_get_IntID() mfcp(XREG_ICC_IAR0_EL1)
|
||||
#elif EL3
|
||||
#define XScuGic_get_IntID() mfcpnotoken(XREG_ICC_IAR0_EL1)
|
||||
#else
|
||||
#define XScuGic_get_IntID() mfcpnotoken(XREG_ICC_IAR1_EL1)
|
||||
#endif
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This function acks the interrupt
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if defined(ARMR52)
|
||||
#define XScuGic_ack_Int(val) mtcp(XREG_ICC_EOIR0_EL1,val)
|
||||
#elif EL3
|
||||
#define XScuGic_ack_Int(val) mtcpnotoken(XREG_ICC_EOIR0_EL1,val)
|
||||
#else
|
||||
#define XScuGic_ack_Int(val) mtcpnotoken(XREG_ICC_EOIR1_EL1,val)
|
||||
#endif
|
||||
/****************************************************************************/
|
||||
/**
|
||||
* This macro returns bit position for the specific interrupt's trigger type
|
||||
* configuration within GICR_ICFGR0/GICR_ICFGR1 register
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_Get_Rdist_Int_Trigger_Index(IntrId) ((Int_Id%16) * 2U)
|
||||
#endif
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*
|
||||
* Required functions in xscugic.c
|
||||
*/
|
||||
|
||||
s32 XScuGic_Connect(XScuGic *InstancePtr, u32 Int_Id,
|
||||
Xil_InterruptHandler Handler, void *CallBackRef);
|
||||
void XScuGic_Disconnect(XScuGic *InstancePtr, u32 Int_Id);
|
||||
|
||||
void XScuGic_Enable(XScuGic *InstancePtr, u32 Int_Id);
|
||||
void XScuGic_Disable(XScuGic *InstancePtr, u32 Int_Id);
|
||||
|
||||
s32 XScuGic_CfgInitialize(XScuGic *InstancePtr, XScuGic_Config *ConfigPtr,
|
||||
u32 EffectiveAddr);
|
||||
|
||||
s32 XScuGic_SoftwareIntr(XScuGic *InstancePtr, u32 Int_Id, u32 Cpu_Identifier);
|
||||
|
||||
void XScuGic_GetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
|
||||
u8 *Priority, u8 *Trigger);
|
||||
void XScuGic_SetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
|
||||
u8 Priority, u8 Trigger);
|
||||
void XScuGic_InterruptMaptoCpu(XScuGic *InstancePtr, u8 Cpu_Identifier, u32 Int_Id);
|
||||
void XScuGic_InterruptUnmapFromCpu(XScuGic *InstancePtr, u8 Cpu_Identifier, u32 Int_Id);
|
||||
void XScuGic_UnmapAllInterruptsFromCpu(XScuGic *InstancePtr, u8 Cpu_Identifier);
|
||||
void XScuGic_Stop(XScuGic *InstancePtr);
|
||||
void XScuGic_SetCpuID(u32 CpuCoreId);
|
||||
u32 XScuGic_GetCpuID(void);
|
||||
u8 XScuGic_IsInitialized(u32 DeviceId);
|
||||
/*
|
||||
* Initialization functions in xscugic_sinit.c
|
||||
*/
|
||||
XScuGic_Config *XScuGic_LookupConfig(u16 DeviceId);
|
||||
XScuGic_Config *XScuGic_LookupConfigBaseAddr(UINTPTR BaseAddress);
|
||||
|
||||
/*
|
||||
* Interrupt functions in xscugic_intr.c
|
||||
*/
|
||||
void XScuGic_InterruptHandler(XScuGic *InstancePtr);
|
||||
|
||||
/*
|
||||
* Self-test functions in xscugic_selftest.c
|
||||
*/
|
||||
s32 XScuGic_SelfTest(XScuGic *InstancePtr);
|
||||
|
||||
#if defined (GICv3)
|
||||
void XScuGic_MarkCoreAsleep(XScuGic *InstancePtr);
|
||||
void XScuGic_MarkCoreAwake(XScuGic *InstancePtr);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
73
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_g.c
Normal file
73
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_g.c
Normal file
@ -0,0 +1,73 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscugic_g.c
|
||||
* @addtogroup scugic Overview
|
||||
* @{
|
||||
*
|
||||
* This file contains a configuration table that specifies the configuration of
|
||||
* interrupt controller devices in the system.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.00a drg 01/19/10 First release
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.10 mus 07/17/18 Updated file to fix the various coding style issues
|
||||
* reported by checkpatch. It fixes CR#1006344.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* This configuration table contains entries that are modified at runtime by the
|
||||
* driver. This table reflects only the hardware configuration of the device.
|
||||
* This Intc configuration table contains software information in addition to
|
||||
* hardware configuration.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xscugic.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Prototypes ******************************/
|
||||
|
||||
/**
|
||||
* This table contains configuration information for each GIC device
|
||||
* in the system. The XScuGic driver must know when to acknowledge the
|
||||
* interrupt. The entry which specifies this as a bit mask where each bit
|
||||
* corresponds to a specific interrupt. A bit set indicates to ACK it
|
||||
* before servicing it. Generally, acknowledge before service is used when
|
||||
* the interrupt signal is edge-sensitive, and after when the signal is
|
||||
* level-sensitive.
|
||||
*
|
||||
* Refer to the XScuGic_Config data structure in xscugic.h for details on how
|
||||
* this table should be initialized.
|
||||
*/
|
||||
XScuGic_Config XScuGic_ConfigTable[XPAR_XSCUGIC_NUM_INSTANCES] = {
|
||||
{
|
||||
(u16)XPAR_SCUGIC_0_DEVICE_ID, /* Unique ID of device */
|
||||
(u32)XPAR_SCUGIC_0_CPU_BASEADDR, /* CPU Interface base address */
|
||||
(u32)XPAR_SCUGIC_0_DIST_BASEADDR, /* Distributor base address */
|
||||
{{0}} /**< Initialize the HandlerTable to 0 */
|
||||
}
|
||||
};
|
||||
/** @} */
|
1079
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_hw.c
Normal file
1079
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_hw.c
Normal file
File diff suppressed because it is too large
Load Diff
753
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_hw.h
Normal file
753
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_hw.h
Normal file
@ -0,0 +1,753 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscugic_hw.h
|
||||
* @addtogroup scugic Overview
|
||||
* @{
|
||||
*
|
||||
* This header file contains identifiers and HW access functions (or
|
||||
* macros) that can be used to access the device. The user should refer to the
|
||||
* hardware device specification for more details of the device operation.
|
||||
* The driver functions/APIs are defined in xscugic.h.
|
||||
*
|
||||
* This GIC device has two parts, a distributor and CPU interface(s). Each part
|
||||
* has separate register definition sections.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------------
|
||||
* 1.00a drg 01/19/10 First release
|
||||
* 1.01a sdm 11/09/11 "xil_exception.h" added as include.
|
||||
* Macros XScuGic_EnableIntr and XScuGic_DisableIntr are
|
||||
* added to enable or disable interrupts based on
|
||||
* Distributor Register base address. Normally users use
|
||||
* XScuGic instance and call XScuGic_Enable or
|
||||
* XScuGic_Disable to enable/disable interrupts. These
|
||||
* new macros are provided when user does not want to
|
||||
* use an instance pointer but still wants to enable or
|
||||
* disable interrupts.
|
||||
* Function prototypes for functions (present in newly
|
||||
* added file xscugic_hw.c) are added.
|
||||
* 1.03a srt 02/27/13 Moved Offset calculation macros from *_hw.c (CR
|
||||
* 702687).
|
||||
* 1.04a hk 05/04/13 Fix for CR#705621. Moved function prototypes
|
||||
* XScuGic_SetPriTrigTypeByDistAddr and
|
||||
* XScuGic_GetPriTrigTypeByDistAddr here from xscugic.h
|
||||
* 3.0 pkp 12/09/14 changed XSCUGIC_MAX_NUM_INTR_INPUTS for
|
||||
* Zynq Ultrascale Mp
|
||||
* 3.0 kvn 02/13/14 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.2 pkp 11/09/15 Corrected the interrupt processsor target mask value
|
||||
* for CPU interface 2 i.e. XSCUGIC_SPI_CPU2_MASK
|
||||
* 3.9 mus 02/21/18 Added new API's XScuGic_InterruptUnmapFromCpuByDistAddr
|
||||
* and XScuGic_UnmapAllInterruptsFromCpuByDistAddr, These
|
||||
* API's can be used by applications to unmap specific/all
|
||||
* interrupts from target CPU. It fixes CR#992490.
|
||||
* 3.10 aru 08/23/18 Resolved MISRA-C:2012 compliance mandatory violations
|
||||
* 4.1 asa 03/30/19 Removed macros for XScuGic_EnableIntr, and
|
||||
* XScuGic_DisableIntr. These are now C functions. This
|
||||
* change was to fix CR-1024716.
|
||||
* 4.1 mus 06/12/19 Updated XSCUGIC_MAX_NUM_INTR_INPUTS for Versal.
|
||||
* 4.6 sk 06/07/21 Delete the commented macro code to fix the MISRA-C warning.
|
||||
* 4.6 sk 08/05/21 Fix Scugic Misrac violations.
|
||||
* 4.7 sk 12/10/21 Update XSCUGIC_SPI_INT_ID_START macro from signed to unsigned
|
||||
* to fix misrac violation.
|
||||
* 4.7 mus 03/17/22 GICv3 coupled with A72 has different redistributor for
|
||||
* each core, and each redistributor has different address,
|
||||
* Updated #define for re-distributor address to have correct
|
||||
* value based on the cpu number. It fixes CR#1126156.
|
||||
* 5.0 mus 22/02/22 Added support for VERSAL NET
|
||||
* 5.1 mus 02/13/23 Added #defines required for logic to find redistributor
|
||||
* based address for specific CPU core. Also, added new macro
|
||||
* XScuGic_ReadReg64 to read 64 bit value from specific address.
|
||||
* 5.1 mus 02/15/23 Added support for VERSAL_NET APU and RPU GIC.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef XSCUGIC_HW_H /* prevent circular inclusions */
|
||||
#define XSCUGIC_HW_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xil_io.h"
|
||||
#include "xil_exception.h"
|
||||
#include "bspconfig.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
#if (defined (versal) && !defined(ARMR5)) || defined (ARMR52)
|
||||
#define GICv3
|
||||
#endif
|
||||
|
||||
#if defined (VERSAL_NET) && ! defined (ARMR52)
|
||||
#define GIC600
|
||||
#endif
|
||||
|
||||
#if defined (VERSAL_NET)
|
||||
#if defined (ARMR52)
|
||||
#define XSCUGIC_NUM_OF_CORES_PER_CLUSTER 2U
|
||||
#else
|
||||
#define XSCUGIC_NUM_OF_CORES_PER_CLUSTER 4U
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The maximum number of interrupts supported by the hardware.
|
||||
*/
|
||||
#ifdef PLATFORM_ZYNQ
|
||||
#define XSCUGIC_MAX_NUM_INTR_INPUTS 95U /* Maximum number of interrupt defined by Zynq */
|
||||
#elif defined (VERSAL_NET)
|
||||
#define XSCUGIC_MAX_NUM_INTR_INPUTS 256U /* Maximum number of interrupt sources in VERSAL NET */
|
||||
#elif defined (versal)
|
||||
#define XSCUGIC_MAX_NUM_INTR_INPUTS 192U
|
||||
#else
|
||||
#define XSCUGIC_MAX_NUM_INTR_INPUTS 195U /* Maximum number of interrupt defined by Zynq Ultrascale Mp */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* First Interrupt Id for SPI interrupts.
|
||||
*/
|
||||
#define XSCUGIC_SPI_INT_ID_START 0x20U
|
||||
/*
|
||||
* The maximum priority value that can be used in the GIC.
|
||||
*/
|
||||
#define XSCUGIC_MAX_INTR_PRIO_VAL 248U
|
||||
#define XSCUGIC_INTR_PRIO_MASK 0x000000F8U
|
||||
|
||||
/** @name Distributor Interface Register Map
|
||||
*
|
||||
* Define the offsets from the base address for all Distributor registers of
|
||||
* the interrupt controller, some registers may be reserved in the hardware
|
||||
* device.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_DIST_EN_OFFSET 0x00000000U /**< Distributor Enable
|
||||
Register */
|
||||
#define XSCUGIC_IC_TYPE_OFFSET 0x00000004U /**< Interrupt Controller
|
||||
Type Register */
|
||||
#define XSCUGIC_DIST_IDENT_OFFSET 0x00000008U /**< Implementor ID
|
||||
Register */
|
||||
#define XSCUGIC_SECURITY_OFFSET 0x00000080U /**< Interrupt Security
|
||||
Register */
|
||||
#define XSCUGIC_ENABLE_SET_OFFSET 0x00000100U /**< Enable Set
|
||||
Register */
|
||||
#define XSCUGIC_DISABLE_OFFSET 0x00000180U /**< Enable Clear Register */
|
||||
#define XSCUGIC_PENDING_SET_OFFSET 0x00000200U /**< Pending Set
|
||||
Register */
|
||||
#define XSCUGIC_PENDING_CLR_OFFSET 0x00000280U /**< Pending Clear
|
||||
Register */
|
||||
#define XSCUGIC_ACTIVE_OFFSET 0x00000300U /**< Active Status Register */
|
||||
#define XSCUGIC_PRIORITY_OFFSET 0x00000400U /**< Priority Level Register */
|
||||
#define XSCUGIC_SPI_TARGET_OFFSET 0x00000800U /**< SPI Target
|
||||
Register 0x800-0x8FB */
|
||||
#define XSCUGIC_INT_CFG_OFFSET 0x00000C00U /**< Interrupt Configuration
|
||||
Register 0xC00-0xCFC */
|
||||
#define XSCUGIC_PPI_STAT_OFFSET 0x00000D00U /**< PPI Status Register */
|
||||
#define XSCUGIC_SPI_STAT_OFFSET 0x00000D04U /**< SPI Status Register
|
||||
0xd04-0xd7C */
|
||||
#define XSCUGIC_AHB_CONFIG_OFFSET 0x00000D80U /**< AHB Configuration
|
||||
Register */
|
||||
#define XSCUGIC_SFI_TRIG_OFFSET 0x00000F00U /**< Software Triggered
|
||||
Interrupt Register */
|
||||
#define XSCUGIC_PERPHID_OFFSET 0x00000FD0U /**< Peripheral ID Reg */
|
||||
#if defined (GICv3)
|
||||
#define XSCUGIC_PCELLID_OFFSET 0x0000FFF0U /**< Pcell ID Register */
|
||||
#else
|
||||
#define XSCUGIC_PCELLID_OFFSET 0x00000FF0U /**< Pcell ID Register */
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/** @name Distributor Enable Register
|
||||
* Controls if the distributor response to external interrupt inputs.
|
||||
* @{
|
||||
*/
|
||||
#if defined (GICv3)
|
||||
#define XSCUGIC_EN_INT_MASK 0x00000003U /**< Interrupt In Enable */
|
||||
#else
|
||||
#define XSCUGIC_EN_INT_MASK 0x00000001U /**< Interrupt In Enable */
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/** @name Interrupt Controller Type Register
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_LSPI_MASK 0x0000F800U /**< Number of Lockable
|
||||
Shared Peripheral
|
||||
Interrupts*/
|
||||
#define XSCUGIC_DOMAIN_MASK 0x00000400U /**< Number os Security domains*/
|
||||
#define XSCUGIC_CPU_NUM_MASK 0x000000E0U /**< Number of CPU Interfaces */
|
||||
#define XSCUGIC_NUM_INT_MASK 0x0000001FU /**< Number of Interrupt IDs */
|
||||
/* @} */
|
||||
|
||||
/** @name Implementor ID Register
|
||||
* Implementor and revision information.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_REV_MASK 0x00FFF000U /**< Revision Number */
|
||||
#define XSCUGIC_IMPL_MASK 0x00000FFFU /**< Implementor */
|
||||
/* @} */
|
||||
|
||||
/** @name Interrupt Security Registers
|
||||
* Each bit controls the security level of an interrupt, either secure or non
|
||||
* secure. These registers can only be accessed using secure read and write.
|
||||
* There are registers for each of the CPU interfaces at offset 0x080. A
|
||||
* register set for the SPI interrupts is available to all CPU interfaces.
|
||||
* There are up to 32 of these registers staring at location 0x084.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_INT_NS_MASK 0x00000001U /**< Each bit corresponds to an
|
||||
INT_ID */
|
||||
/* @} */
|
||||
|
||||
/** @name Enable Set Register
|
||||
* Each bit controls the enabling of an interrupt, a 0 is disabled, a 1 is
|
||||
* enabled. Writing a 0 has no effect. Use the ENABLE_CLR register to set a
|
||||
* bit to 0.
|
||||
* There are registers for each of the CPU interfaces at offset 0x100. With up
|
||||
* to 8 registers aliased to the same address. A register set for the SPI
|
||||
* interrupts is available to all CPU interfaces.
|
||||
* There are up to 32 of these registers staring at location 0x104.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_INT_EN_MASK 0x00000001U /**< Each bit corresponds to an
|
||||
INT_ID */
|
||||
/* @} */
|
||||
|
||||
/** @name Enable Clear Register
|
||||
* Each bit controls the disabling of an interrupt, a 0 is disabled, a 1 is
|
||||
* enabled. Writing a 0 has no effect. Writing a 1 disables an interrupt and
|
||||
* sets the corresponding bit to 0.
|
||||
* There are registers for each of the CPU interfaces at offset 0x180. With up
|
||||
* to 8 registers aliased to the same address.
|
||||
* A register set for the SPI interrupts is available to all CPU interfaces.
|
||||
* There are up to 32 of these registers staring at location 0x184.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_INT_CLR_MASK 0x00000001U /**< Each bit corresponds to an
|
||||
INT_ID */
|
||||
/* @} */
|
||||
|
||||
/** @name Pending Set Register
|
||||
* Each bit controls the Pending or Active and Pending state of an interrupt, a
|
||||
* 0 is not pending, a 1 is pending. Writing a 0 has no effect. Writing a 1 sets
|
||||
* an interrupt to the pending state.
|
||||
* There are registers for each of the CPU interfaces at offset 0x200. With up
|
||||
* to 8 registers aliased to the same address.
|
||||
* A register set for the SPI interrupts is available to all CPU interfaces.
|
||||
* There are up to 32 of these registers staring at location 0x204.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_PEND_SET_MASK 0x00000001U /**< Each bit corresponds to an
|
||||
INT_ID */
|
||||
/* @} */
|
||||
|
||||
/** @name Pending Clear Register
|
||||
* Each bit can clear the Pending or Active and Pending state of an interrupt, a
|
||||
* 0 is not pending, a 1 is pending. Writing a 0 has no effect. Writing a 1
|
||||
* clears the pending state of an interrupt.
|
||||
* There are registers for each of the CPU interfaces at offset 0x280. With up
|
||||
* to 8 registers aliased to the same address.
|
||||
* A register set for the SPI interrupts is available to all CPU interfaces.
|
||||
* There are up to 32 of these registers staring at location 0x284.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_PEND_CLR_MASK 0x00000001U /**< Each bit corresponds to an
|
||||
INT_ID */
|
||||
/* @} */
|
||||
|
||||
/** @name Active Status Register
|
||||
* Each bit provides the Active status of an interrupt, a
|
||||
* 0 is not Active, a 1 is Active. This is a read only register.
|
||||
* There are registers for each of the CPU interfaces at offset 0x300. With up
|
||||
* to 8 registers aliased to each address.
|
||||
* A register set for the SPI interrupts is available to all CPU interfaces.
|
||||
* There are up to 32 of these registers staring at location 0x380.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_ACTIVE_MASK 0x00000001U /**< Each bit corresponds to an
|
||||
INT_ID */
|
||||
/* @} */
|
||||
|
||||
/** @name Priority Level Register
|
||||
* Each byte in a Priority Level Register sets the priority level of an
|
||||
* interrupt. Reading the register provides the priority level of an interrupt.
|
||||
* There are registers for each of the CPU interfaces at offset 0x400 through
|
||||
* 0x41C. With up to 8 registers aliased to each address.
|
||||
* 0 is highest priority, 0xFF is lowest.
|
||||
* A register set for the SPI interrupts is available to all CPU interfaces.
|
||||
* There are up to 255 of these registers staring at location 0x420.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_PRIORITY_MASK 0x000000FFU /**< Each Byte corresponds to an
|
||||
INT_ID */
|
||||
#define XSCUGIC_PRIORITY_MAX 0x000000FFU /**< Highest value of a priority
|
||||
actually the lowest priority*/
|
||||
/* @} */
|
||||
|
||||
/** @name SPI Target Register 0x800-0x8FB
|
||||
* Each byte references a separate SPI and programs which of the up to 8 CPU
|
||||
* interfaces are sent a Pending interrupt.
|
||||
* There are registers for each of the CPU interfaces at offset 0x800 through
|
||||
* 0x81C. With up to 8 registers aliased to each address.
|
||||
* A register set for the SPI interrupts is available to all CPU interfaces.
|
||||
* There are up to 255 of these registers staring at location 0x820.
|
||||
*
|
||||
* This driver does not support multiple CPU interfaces. These are included
|
||||
* for complete documentation.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_SPI_CPU7_MASK 0x00000080U /**< CPU 7 Mask*/
|
||||
#define XSCUGIC_SPI_CPU6_MASK 0x00000040U /**< CPU 6 Mask*/
|
||||
#define XSCUGIC_SPI_CPU5_MASK 0x00000020U /**< CPU 5 Mask*/
|
||||
#define XSCUGIC_SPI_CPU4_MASK 0x00000010U /**< CPU 4 Mask*/
|
||||
#define XSCUGIC_SPI_CPU3_MASK 0x00000008U /**< CPU 3 Mask*/
|
||||
#define XSCUGIC_SPI_CPU2_MASK 0x00000004U /**< CPU 2 Mask*/
|
||||
#define XSCUGIC_SPI_CPU1_MASK 0x00000002U /**< CPU 1 Mask*/
|
||||
#define XSCUGIC_SPI_CPU0_MASK 0x00000001U /**< CPU 0 Mask*/
|
||||
/* @} */
|
||||
|
||||
/** @name Interrupt Configuration Register 0xC00-0xCFC
|
||||
* The interrupt configuration registers program an SFI to be active HIGH level
|
||||
* sensitive or rising edge sensitive.
|
||||
* Each bit pair describes the configuration for an INT_ID.
|
||||
* SFI Read Only b10 always
|
||||
* PPI Read Only depending on how the PPIs are configured.
|
||||
* b01 Active HIGH level sensitive
|
||||
* b11 Rising edge sensitive
|
||||
* SPI LSB is read only.
|
||||
* b01 Active HIGH level sensitive
|
||||
* b11 Rising edge sensitive/
|
||||
* There are registers for each of the CPU interfaces at offset 0xC00 through
|
||||
* 0xC04. With up to 8 registers aliased to each address.
|
||||
* A register set for the SPI interrupts is available to all CPU interfaces.
|
||||
* There are up to 255 of these registers staring at location 0xC08.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_INT_CFG_MASK 0x00000003U /**< */
|
||||
/* @} */
|
||||
|
||||
/** @name PPI Status Register
|
||||
* Enables an external AMBA master to access the status of the PPI inputs.
|
||||
* A CPU can only read the status of its local PPI signals and cannot read the
|
||||
* status for other CPUs.
|
||||
* This register is aliased for each CPU interface.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_PPI_C15_MASK 0x00008000U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C14_MASK 0x00004000U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C13_MASK 0x00002000U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C12_MASK 0x00001000U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C11_MASK 0x00000800U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C10_MASK 0x00000400U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C09_MASK 0x00000200U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C08_MASK 0x00000100U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C07_MASK 0x00000080U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C06_MASK 0x00000040U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C05_MASK 0x00000020U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C04_MASK 0x00000010U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C03_MASK 0x00000008U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C02_MASK 0x00000004U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C01_MASK 0x00000002U /**< PPI Status */
|
||||
#define XSCUGIC_PPI_C00_MASK 0x00000001U /**< PPI Status */
|
||||
/* @} */
|
||||
|
||||
/** @name SPI Status Register 0xd04-0xd7C
|
||||
* Enables an external AMBA master to access the status of the SPI inputs.
|
||||
* There are up to 63 registers if the maximum number of SPI inputs are
|
||||
* configured.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_SPI_N_MASK 0x00000001U /**< Each bit corresponds to an SPI
|
||||
input */
|
||||
/* @} */
|
||||
|
||||
/** @name AHB Configuration Register
|
||||
* Provides the status of the CFGBIGEND input signal and allows the endianness
|
||||
* of the GIC to be set.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_AHB_END_MASK 0x00000004U /**< 0-GIC uses little Endian,
|
||||
1-GIC uses Big Endian */
|
||||
#define XSCUGIC_AHB_ENDOVR_MASK 0x00000002U /**< 0-Uses CFGBIGEND control,
|
||||
1-use the AHB_END bit */
|
||||
#define XSCUGIC_AHB_TIE_OFF_MASK 0x00000001U /**< State of CFGBIGEND */
|
||||
|
||||
/* @} */
|
||||
|
||||
/** @name Software Triggered Interrupt Register
|
||||
* Controls issuing of software interrupts.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_SFI_SELFTRIG_MASK 0x02010000U
|
||||
#define XSCUGIC_SFI_TRIG_TRGFILT_MASK 0x03000000U /**< Target List filter
|
||||
b00-Use the target List
|
||||
b01-All CPUs except requester
|
||||
b10-To Requester
|
||||
b11-reserved */
|
||||
#define XSCUGIC_SFI_TRIG_CPU_MASK 0x00FF0000U /**< CPU Target list */
|
||||
#define XSCUGIC_SFI_TRIG_SATT_MASK 0x00008000U /**< 0= Use a secure interrupt */
|
||||
#define XSCUGIC_SFI_TRIG_INTID_MASK 0x0000000FU /**< Set to the INTID
|
||||
signaled to the CPU*/
|
||||
/* @} */
|
||||
|
||||
/** @name CPU Interface Register Map
|
||||
*
|
||||
* Define the offsets from the base address for all CPU registers of the
|
||||
* interrupt controller, some registers may be reserved in the hardware device.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_CONTROL_OFFSET 0x00000000U /**< CPU Interface Control
|
||||
Register */
|
||||
#define XSCUGIC_CPU_PRIOR_OFFSET 0x00000004U /**< Priority Mask Reg */
|
||||
#define XSCUGIC_BIN_PT_OFFSET 0x00000008U /**< Binary Point Register */
|
||||
#define XSCUGIC_INT_ACK_OFFSET 0x0000000CU /**< Interrupt ACK Reg */
|
||||
#define XSCUGIC_EOI_OFFSET 0x00000010U /**< End of Interrupt Reg */
|
||||
#define XSCUGIC_RUN_PRIOR_OFFSET 0x00000014U /**< Running Priority Reg */
|
||||
#define XSCUGIC_HI_PEND_OFFSET 0x00000018U /**< Highest Pending Interrupt
|
||||
Register */
|
||||
#define XSCUGIC_ALIAS_BIN_PT_OFFSET 0x0000001CU /**< Aliased non-Secure
|
||||
Binary Point Register */
|
||||
|
||||
/**< 0x00000020 to 0x00000FBC are reserved and should not be read or written
|
||||
* to. */
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name Control Register
|
||||
* CPU Interface Control register definitions
|
||||
* All bits are defined here although some are not available in the non-secure
|
||||
* mode.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUGIC_CNTR_SBPR_MASK 0x00000010U /**< Secure Binary Pointer,
|
||||
0=separate registers,
|
||||
1=both use bin_pt_s */
|
||||
#define XSCUGIC_CNTR_FIQEN_MASK 0x00000008U /**< Use nFIQ_C for secure
|
||||
interrupts,
|
||||
0= use IRQ for both,
|
||||
1=Use FIQ for secure, IRQ for non*/
|
||||
#define XSCUGIC_CNTR_ACKCTL_MASK 0x00000004U /**< Ack control for secure or non secure */
|
||||
#define XSCUGIC_CNTR_EN_NS_MASK 0x00000002U /**< Non Secure enable */
|
||||
#define XSCUGIC_CNTR_EN_S_MASK 0x00000001U /**< Secure enable, 0=Disabled, 1=Enabled */
|
||||
/* @} */
|
||||
|
||||
|
||||
/** @name Binary Point Register
|
||||
* Binary Point register definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSCUGIC_BIN_PT_MASK 0x00000007U /**< Binary point mask value
|
||||
Value Secure Non-secure
|
||||
b000 0xFE 0xFF
|
||||
b001 0xFC 0xFE
|
||||
b010 0xF8 0xFC
|
||||
b011 0xF0 0xF8
|
||||
b100 0xE0 0xF0
|
||||
b101 0xC0 0xE0
|
||||
b110 0x80 0xC0
|
||||
b111 0x00 0x80
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
/** @name Interrupt Acknowledge Register
|
||||
* Interrupt Acknowledge register definitions
|
||||
* Identifies the current Pending interrupt, and the CPU ID for software
|
||||
* interrupts.
|
||||
*/
|
||||
#define XSCUGIC_ACK_INTID_MASK 0x000003FFU /**< Interrupt ID */
|
||||
#define XSCUGIC_CPUID_MASK 0x00000C00U /**< CPU ID */
|
||||
/* @} */
|
||||
|
||||
/** @name End of Interrupt Register
|
||||
* End of Interrupt register definitions
|
||||
* Allows the CPU to signal the GIC when it completes an interrupt service
|
||||
* routine.
|
||||
*/
|
||||
#define XSCUGIC_EOI_INTID_MASK 0x000003FFU /**< Interrupt ID */
|
||||
|
||||
/* @} */
|
||||
|
||||
/** @name Running Priority Register
|
||||
* Running Priority register definitions
|
||||
* Identifies the interrupt priority level of the highest priority active
|
||||
* interrupt.
|
||||
*/
|
||||
#define XSCUGIC_RUN_PRIORITY_MASK 0x000000FFU /**< Interrupt Priority */
|
||||
/* @} */
|
||||
|
||||
#if defined (GICv3)
|
||||
#define XSCUGIC_IROUTER_BASE_OFFSET 0x6000U
|
||||
#endif
|
||||
/*
|
||||
* Highest Pending Interrupt register definitions
|
||||
* Identifies the interrupt priority of the highest priority pending interrupt
|
||||
*/
|
||||
#define XSCUGIC_PEND_INTID_MASK 0x000003FFU /**< Pending Interrupt ID */
|
||||
/* @} */
|
||||
#if defined (GICv3)
|
||||
/** @name ReDistributor Interface Register Map
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#if defined (VERSAL_NET) && ! defined (ARMR52)
|
||||
#define XSCUGIC_RDIST_START_ADDR 0xE2060000U
|
||||
#define XSCUGIC_RDIST_END_ADDR 0xE2260000U
|
||||
#elif defined (ARMR52)
|
||||
#define XSCUGIC_RDIST_START_ADDR 0xE2100000U
|
||||
#define XSCUGIC_RDIST_END_ADDR 0xE2130000U
|
||||
#else
|
||||
#define XSCUGIC_RDIST_START_ADDR 0xF9080000U
|
||||
#define XSCUGIC_RDIST_END_ADDR 0xF90B0000U
|
||||
#endif
|
||||
#define XSCUGIC_RDIST_OFFSET 0x20000U /* offset between consecutive redistributors */
|
||||
#define XSCUGIC_RDIST_SGI_PPI_OFFSET 0x10000U /* offset between control redistributor and SGI/PPI redistributor */
|
||||
#define XSCUGIC_GICR_TYPER_AFFINITY_SHIFT 32U
|
||||
#define XSCUGIC_GICR_TYPER_AFFINITY_MASK 0xFFFFFFFF00000000UL
|
||||
|
||||
#define XSCUGIC_RDIST_ISENABLE_OFFSET 0x100U
|
||||
#define XSCUGIC_RDIST_IPRIORITYR_OFFSET 0x400U
|
||||
#define XSCUGIC_RDIST_IGROUPR_OFFSET 0x80U
|
||||
#define XSCUGIC_RDIST_GRPMODR_OFFSET 0xD00U
|
||||
#define XSCUGIC_RDIST_INT_CONFIG_OFFSET 0xC00U
|
||||
#define XSCUGIC_RDIST_TYPER_OFFSET 0x8U
|
||||
#define XSCUGIC_RDIST_WAKER_OFFSET 0x14U
|
||||
#define XSCUGIC_SGIR_EL1_INITID_SHIFT 24U
|
||||
|
||||
#if defined (GIC600)
|
||||
#define XSCUGIC_RDIST_PWRR_OFFSET 0x24U
|
||||
#endif
|
||||
/*
|
||||
* GICR_IGROUPR register definitions
|
||||
*/
|
||||
#if (defined(ARMR52) || EL3)
|
||||
#define XSCUGIC_DEFAULT_SECURITY 0x0U
|
||||
#else
|
||||
#define XSCUGIC_DEFAULT_SECURITY 0xFFFFFFFFU
|
||||
#endif
|
||||
/*
|
||||
* GICR_WAKER register definitions
|
||||
*/
|
||||
#define XSCUGIC_RDIST_WAKER_LOW_POWER_STATE_MASK 0x7
|
||||
#define XSCUGIC_RDIST_PWRR_RDPD_MASK 0x1U
|
||||
#endif
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the Interrupt Configuration Register offset for an interrupt id.
|
||||
*
|
||||
* @param InterruptID is the interrupt number.
|
||||
*
|
||||
* @return The 32-bit value of the offset
|
||||
*
|
||||
* @note
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSCUGIC_INT_CFG_OFFSET_CALC(InterruptID) \
|
||||
((u32)XSCUGIC_INT_CFG_OFFSET + (((InterruptID)/16U) * 4U))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the Interrupt Priority Register offset for an interrupt id.
|
||||
*
|
||||
* @param InterruptID is the interrupt number.
|
||||
*
|
||||
* @return The 32-bit value of the offset
|
||||
*
|
||||
* @note
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSCUGIC_PRIORITY_OFFSET_CALC(InterruptID) \
|
||||
((u32)XSCUGIC_PRIORITY_OFFSET + (((InterruptID)/4U) * 4U))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the Interrupt Routing Register offset for an interrupt id.
|
||||
*
|
||||
* @param InterruptID is the interrupt number.
|
||||
*
|
||||
* @return The 32-bit value of the offset
|
||||
*
|
||||
* @note
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSCUGIC_IROUTER_OFFSET_CALC(InterruptID) \
|
||||
((u32)XSCUGIC_IROUTER_BASE_OFFSET + (InterruptID * 8))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the SPI Target Register offset for an interrupt id.
|
||||
*
|
||||
* @param InterruptID is the interrupt number.
|
||||
*
|
||||
* @return The 32-bit value of the offset
|
||||
*
|
||||
* @note
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSCUGIC_SPI_TARGET_OFFSET_CALC(InterruptID) \
|
||||
((u32)XSCUGIC_SPI_TARGET_OFFSET + (((InterruptID)/4U) * 4U))
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the SPI Target Register offset for an interrupt id.
|
||||
*
|
||||
* @param InterruptID is the interrupt number.
|
||||
*
|
||||
* @return The 32-bit value of the offset
|
||||
*
|
||||
* @note
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSCUGIC_SECURITY_TARGET_OFFSET_CALC(InterruptID) \
|
||||
((u32)XSCUGIC_SECURITY_OFFSET + (((InterruptID)/32U)*4U))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the Re-distributor Interrupt configuration register offset
|
||||
*
|
||||
* @param InterruptID is the interrupt number.
|
||||
*
|
||||
* @return The 32-bit value of the offset
|
||||
*
|
||||
* @note
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSCUGIC_RDIST_INT_CONFIG_OFFSET_CALC(InterruptID) \
|
||||
((u32)XSCUGIC_RDIST_INT_CONFIG_OFFSET + ((InterruptID /16)*4))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the Re-distributor Interrupt Priority register offset
|
||||
*
|
||||
* @param InterruptID is the interrupt number.
|
||||
*
|
||||
* @return The 32-bit value of the offset
|
||||
*
|
||||
* @note
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSCUGIC_RDIST_INT_PRIORITY_OFFSET_CALC(InterruptID) \
|
||||
((u32)XSCUGIC_RDIST_IPRIORITYR_OFFSET + (InterruptID * 4))
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the Interrupt Clear-Enable Register offset for an interrupt ID
|
||||
*
|
||||
* @param Register is the register offset for the clear/enable bank.
|
||||
* @param InterruptID is the interrupt number.
|
||||
*
|
||||
* @return The 32-bit value of the offset
|
||||
*
|
||||
* @note
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XSCUGIC_EN_DIS_OFFSET_CALC(Register, InterruptID) \
|
||||
((Register) + (((InterruptID)/32U) * 4U))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given Intc register.
|
||||
*
|
||||
* @param BaseAddress is the base address of the device.
|
||||
* @param RegOffset is the register offset to be read
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XScuGic_ReadReg(u32 BaseAddress, u32 RegOffset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_ReadReg(BaseAddress, RegOffset) \
|
||||
(Xil_In32((BaseAddress) + (RegOffset)))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given Intc register.
|
||||
*
|
||||
* @param BaseAddress is the base address of the device.
|
||||
* @param RegOffset is the register offset to be read
|
||||
*
|
||||
* @return The 64-bit value of the register
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* u32 XScuGic_ReadReg64(UINTPTR BaseAddress, u32 RegOffset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_ReadReg64(BaseAddress, RegOffset) \
|
||||
(Xil_In64((BaseAddress) + (RegOffset)))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write the given Intc register.
|
||||
*
|
||||
* @param BaseAddress is the base address of the device.
|
||||
* @param RegOffset is the register offset to be written
|
||||
* @param Data is the 32-bit value to write to the register
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note
|
||||
* C-style signature:
|
||||
* void XScuGic_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuGic_WriteReg(BaseAddress, RegOffset, Data) \
|
||||
(Xil_Out32(((BaseAddress) + (RegOffset)), ((u32)(Data))))
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
void XScuGic_DeviceInterruptHandler(void *DeviceId);
|
||||
s32 XScuGic_DeviceInitialize(u32 DeviceId);
|
||||
void XScuGic_RegisterHandler(u32 BaseAddress, s32 InterruptID,
|
||||
Xil_InterruptHandler IntrHandler, void *CallBackRef);
|
||||
void XScuGic_SetPriTrigTypeByDistAddr(u32 DistBaseAddress, u32 Int_Id,
|
||||
u8 Priority, u8 Trigger);
|
||||
void XScuGic_GetPriTrigTypeByDistAddr(u32 DistBaseAddress, u32 Int_Id,
|
||||
u8 *Priority, u8 *Trigger);
|
||||
void XScuGic_InterruptMapFromCpuByDistAddr(u32 DistBaseAddress,
|
||||
u8 Cpu_Id, u32 Int_Id);
|
||||
void XScuGic_InterruptUnmapFromCpuByDistAddr(u32 DistBaseAddress,
|
||||
u8 Cpu_Id, u32 Int_Id);
|
||||
void XScuGic_UnmapAllInterruptsFromCpuByDistAddr(u32 DistBaseAddress,
|
||||
u8 Cpu_Id);
|
||||
void XScuGic_EnableIntr (u32 DistBaseAddress, u32 Int_Id);
|
||||
void XScuGic_DisableIntr (u32 DistBaseAddress, u32 Int_Id);
|
||||
#if defined(GICv3)
|
||||
UINTPTR XScuGic_GetRedistBaseAddr(void);
|
||||
#endif
|
||||
/************************** Variable Definitions *****************************/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
164
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_intr.c
Normal file
164
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_intr.c
Normal file
@ -0,0 +1,164 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscugic_intr.c
|
||||
* @addtogroup scugic Overview
|
||||
* @{
|
||||
*
|
||||
* This file contains the interrupt processing for the driver for the Xilinx
|
||||
* Interrupt Controller. The interrupt processing is partitioned separately such
|
||||
* that users are not required to use the provided interrupt processing. This
|
||||
* file requires other files of the driver to be linked in also.
|
||||
*
|
||||
* The interrupt handler, XScuGic_InterruptHandler, uses an input argument which
|
||||
* is an instance pointer to an interrupt controller driver such that multiple
|
||||
* interrupt controllers can be supported. This handler requires the calling
|
||||
* function to pass it the appropriate argument, so another level of indirection
|
||||
* may be required.
|
||||
*
|
||||
* The interrupt processing may be used by connecting the interrupt handler to
|
||||
* the interrupt system. The handler does not save and restore the processor
|
||||
* context but only handles the processing of the Interrupt Controller. The user
|
||||
* is encouraged to supply their own interrupt handler when performance tuning is
|
||||
* deemed necessary.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- ---------------------------------------------------------
|
||||
* 1.00a drg 01/19/10 First release
|
||||
* 1.01a sdm 11/09/11 XScuGic_InterruptHandler has changed correspondingly
|
||||
* since the HandlerTable has now moved to XScuGic_Config.
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.10 mus 07/17/18 Updated XScuGic_InterruptHandler to fix array overrun
|
||||
* reported by coverity tool. It fixes CR#1006344.
|
||||
* 3.10 mus 07/17/18 Updated file to fix the various coding style issues
|
||||
* reported by checkpatch. It fixes CR#1006344.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* This driver assumes that the context of the processor has been saved prior to
|
||||
* the calling of the Interrupt Controller interrupt handler and then restored
|
||||
* after the handler returns. This requires either the running RTOS to save the
|
||||
* state of the machine or that a wrapper be used as the destination of the
|
||||
* interrupt vector to save the state of the processor and restore the state
|
||||
* after the interrupt handler returns.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xscugic.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* This function is the primary interrupt handler for the driver. It must be
|
||||
* connected to the interrupt source such that it is called when an interrupt of
|
||||
* the interrupt controller is active. It will resolve which interrupts are
|
||||
* active and enabled and call the appropriate interrupt handler. It uses
|
||||
* the Interrupt Type information to determine when to acknowledge the interrupt.
|
||||
* Highest priority interrupts are serviced first.
|
||||
*
|
||||
* This function assumes that an interrupt vector table has been previously
|
||||
* initialized. It does not verify that entries in the table are valid before
|
||||
* calling an interrupt handler.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuGic instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XScuGic_InterruptHandler(XScuGic *InstancePtr)
|
||||
{
|
||||
|
||||
u32 InterruptID;
|
||||
#if !defined (GICv3)
|
||||
u32 IntIDFull;
|
||||
#endif
|
||||
XScuGic_VectorTableEntry *TablePtr;
|
||||
|
||||
/* Assert that the pointer to the instance is valid
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
|
||||
/*
|
||||
* Read the int_ack register to identify the highest priority
|
||||
* interrupt ID and make sure it is valid. Reading Int_Ack will
|
||||
* clear the interrupt in the GIC.
|
||||
*/
|
||||
#if defined (GICv3)
|
||||
InterruptID = XScuGic_get_IntID();
|
||||
#else
|
||||
IntIDFull = XScuGic_CPUReadReg(InstancePtr, XSCUGIC_INT_ACK_OFFSET);
|
||||
InterruptID = IntIDFull & XSCUGIC_ACK_INTID_MASK;
|
||||
#endif
|
||||
if (XSCUGIC_MAX_NUM_INTR_INPUTS <= InterruptID) {
|
||||
goto IntrExit;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interrupt is shared, do some locking here if
|
||||
* there are multiple processors.
|
||||
*/
|
||||
/*
|
||||
* If pre-eption is required:
|
||||
* Re-enable pre-emption by setting the CPSR I bit for non-secure ,
|
||||
* interrupts or the F bit for secure interrupts
|
||||
*/
|
||||
|
||||
/*
|
||||
* If we need to change security domains, issue a SMC
|
||||
* instruction here.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Execute the ISR. Jump into the Interrupt service routine
|
||||
* based on the IRQSource. A software trigger is cleared by
|
||||
*.the ACK.
|
||||
*/
|
||||
TablePtr = &(InstancePtr->Config->HandlerTable[InterruptID]);
|
||||
if (TablePtr != NULL) {
|
||||
TablePtr->Handler(TablePtr->CallBackRef);
|
||||
}
|
||||
|
||||
IntrExit:
|
||||
/*
|
||||
* Write to the EOI register, we are all done here.
|
||||
* Let this function return, the boot code will restore the stack.
|
||||
*/
|
||||
#if defined (GICv3)
|
||||
XScuGic_ack_Int(InterruptID);
|
||||
|
||||
#else
|
||||
XScuGic_CPUWriteReg(InstancePtr, XSCUGIC_EOI_OFFSET, IntIDFull);
|
||||
#endif
|
||||
/*
|
||||
* Return from the interrupt. Change security domains
|
||||
* could happen here.
|
||||
*/
|
||||
}
|
||||
/** @} */
|
93
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_selftest.c
Normal file
93
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_selftest.c
Normal file
@ -0,0 +1,93 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscugic_selftest.c
|
||||
* @addtogroup scugic Overview
|
||||
* @{
|
||||
*
|
||||
* Contains diagnostic self-test functions for the XScuGic driver.
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -----------------------------------------------
|
||||
* 1.00a drg 01/19/10 First release
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.10 mus 07/17/18 Updated file to fix the various coding style issues
|
||||
* reported by checkpatch. It fixes CR#1006344.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xscugic.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
#define XSCUGIC_PCELL_ID 0xB105F00DU
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Run a self-test on the driver/device. This test reads the ID registers and
|
||||
* compares them.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuGic instance.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* -XST_SUCCESS if self-test is successful.
|
||||
* -XST_FAILURE if the self-test is not successful.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XScuGic_SelfTest(XScuGic *InstancePtr)
|
||||
{
|
||||
u32 RegValue1 = 0U;
|
||||
u32 Index;
|
||||
s32 Status;
|
||||
|
||||
/*
|
||||
* Assert the arguments
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the ID registers.
|
||||
*/
|
||||
for (Index = 0U; Index <= 3U; Index++) {
|
||||
RegValue1 |= XScuGic_DistReadReg(InstancePtr,
|
||||
((u32)XSCUGIC_PCELLID_OFFSET + (Index * 4U))) <<
|
||||
(Index * 8U);
|
||||
}
|
||||
|
||||
if (XSCUGIC_PCELL_ID != RegValue1) {
|
||||
Status = XST_FAILURE;
|
||||
} else {
|
||||
Status = XST_SUCCESS;
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
/** @} */
|
95
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_sinit.c
Normal file
95
bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_sinit.c
Normal file
@ -0,0 +1,95 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscugic_sinit.c
|
||||
* @addtogroup scugic Overview
|
||||
* @{
|
||||
*
|
||||
* Contains static init functions for the XScuGic driver for the Interrupt
|
||||
* Controller. See xscugic.h for a detailed description of the driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- --------------------------------------------------------
|
||||
* 1.00a drg 01/19/10 First release
|
||||
* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
|
||||
* 3.10 mus 07/17/18 Updated file to fix the various coding style issues
|
||||
* reported by checkpatch. It fixes CR#1006344.
|
||||
* 4.6 sk 08/05/21 Remove XScuGic_Config variable definition to fix
|
||||
* misrac violation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_assert.h"
|
||||
#include "xparameters.h"
|
||||
#include "xscugic.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Looks up the device configuration based on the unique device ID. A table
|
||||
* contains the configuration info for each device in the system.
|
||||
*
|
||||
* @param DeviceId is the unique identifier for a device.
|
||||
*
|
||||
* @return A pointer to the XScuGic configuration structure for the
|
||||
* specified device, or NULL if the device was not found.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
XScuGic_Config *XScuGic_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
XScuGic_Config *CfgPtr = NULL;
|
||||
u32 Index;
|
||||
|
||||
for (Index = 0U; Index < (u32)XPAR_SCUGIC_NUM_INSTANCES; Index++) {
|
||||
if (XScuGic_ConfigTable[Index].DeviceId == DeviceId) {
|
||||
CfgPtr = &XScuGic_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (XScuGic_Config *)CfgPtr;
|
||||
}
|
||||
|
||||
XScuGic_Config *XScuGic_LookupConfigBaseAddr(UINTPTR BaseAddress)
|
||||
{
|
||||
XScuGic_Config *CfgPtr = NULL;
|
||||
u32 Index;
|
||||
|
||||
for (Index = 0U; Index < (u32)XPAR_SCUGIC_NUM_INSTANCES; Index++) {
|
||||
if (XScuGic_ConfigTable[Index].DistBaseAddress == BaseAddress) {
|
||||
CfgPtr = &XScuGic_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (XScuGic_Config *)CfgPtr;
|
||||
}
|
||||
/** @} */
|
39
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/Makefile
Normal file
39
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/Makefile
Normal file
@ -0,0 +1,39 @@
|
||||
DRIVER_LIB_VERSION = 1.0
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
CC_FLAGS = $(COMPILER_FLAGS)
|
||||
ECC_FLAGS = $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I$(INCLUDEDIR)
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR), $(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
libs: $(OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
${COMPILER} $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) $< -o $@
|
||||
|
||||
.PHONY: include
|
||||
include: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf ${DEPFILES}
|
264
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.c
Normal file
264
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.c
Normal file
@ -0,0 +1,264 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscutimer.c
|
||||
* @addtogroup scutimer_v2_4
|
||||
* @{
|
||||
*
|
||||
* Contains the implementation of interface functions of the SCU Timer driver.
|
||||
* See xscutimer.h for a description of the driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a nm 03/10/10 First release
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xscutimer.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Initialize a specific timer instance/driver. This function must be called
|
||||
* before other functions of the driver are called.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
* @param ConfigPtr points to the XScuTimer configuration structure.
|
||||
* @param EffectiveAddress is the base address for the device. It could be
|
||||
* a virtual address if address translation is supported in the
|
||||
* system, otherwise it is the physical address.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if initialization was successful.
|
||||
* - XST_DEVICE_IS_STARTED if the device has already been started.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XScuTimer_CfgInitialize(XScuTimer *InstancePtr,
|
||||
XScuTimer_Config *ConfigPtr, u32 EffectiveAddress)
|
||||
{
|
||||
s32 Status;
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(ConfigPtr != NULL);
|
||||
|
||||
/*
|
||||
* If the device is started, disallow the initialize and return a
|
||||
* status indicating it is started. This allows the user to stop the
|
||||
* device and reinitialize, but prevents a user from inadvertently
|
||||
* initializing.
|
||||
*/
|
||||
if (InstancePtr->IsStarted != XIL_COMPONENT_IS_STARTED) {
|
||||
/*
|
||||
* Copy configuration into the instance structure.
|
||||
*/
|
||||
InstancePtr->Config.DeviceId = ConfigPtr->DeviceId;
|
||||
|
||||
/*
|
||||
* Save the base address pointer such that the registers of the block
|
||||
* can be accessed and indicate it has not been started yet.
|
||||
*/
|
||||
InstancePtr->Config.BaseAddr = EffectiveAddress;
|
||||
|
||||
InstancePtr->IsStarted = (u32)0;
|
||||
|
||||
/*
|
||||
* Indicate the instance is ready to use, successfully initialized.
|
||||
*/
|
||||
InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
|
||||
#ifdef XIL_INTERRUPT
|
||||
InstancePtr->Config.IntrId = ConfigPtr->IntrId;
|
||||
InstancePtr->Config.IntrParent = ConfigPtr->IntrParent;
|
||||
#endif
|
||||
|
||||
Status =(s32)XST_SUCCESS;
|
||||
}
|
||||
else {
|
||||
Status = (s32)XST_DEVICE_IS_STARTED;
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Start the timer.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XScuTimer_Start(XScuTimer *InstancePtr)
|
||||
{
|
||||
u32 Register;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the contents of the Control register.
|
||||
*/
|
||||
Register = XScuTimer_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUTIMER_CONTROL_OFFSET);
|
||||
|
||||
/*
|
||||
* Set the 'timer enable' bit in the register.
|
||||
*/
|
||||
Register |= XSCUTIMER_CONTROL_ENABLE_MASK;
|
||||
|
||||
/*
|
||||
* Update the Control register with the new value.
|
||||
*/
|
||||
XScuTimer_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUTIMER_CONTROL_OFFSET, Register);
|
||||
|
||||
/*
|
||||
* Indicate that the device is started.
|
||||
*/
|
||||
InstancePtr->IsStarted = XIL_COMPONENT_IS_STARTED;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Stop the timer.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XScuTimer_Stop(XScuTimer *InstancePtr)
|
||||
{
|
||||
u32 Register;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the contents of the Control register.
|
||||
*/
|
||||
Register = XScuTimer_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUTIMER_CONTROL_OFFSET);
|
||||
|
||||
/*
|
||||
* Clear the 'timer enable' bit in the register.
|
||||
*/
|
||||
Register &= (u32)(~XSCUTIMER_CONTROL_ENABLE_MASK);
|
||||
|
||||
/*
|
||||
* Update the Control register with the new value.
|
||||
*/
|
||||
XScuTimer_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUTIMER_CONTROL_OFFSET, Register);
|
||||
|
||||
/*
|
||||
* Indicate that the device is stopped.
|
||||
*/
|
||||
InstancePtr->IsStarted = (u32)0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function sets the prescaler bits in the timer control register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
* @param PrescalerValue is a 8 bit value that sets the prescaler to use.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
****************************************************************************/
|
||||
void XScuTimer_SetPrescaler(XScuTimer *InstancePtr, u8 PrescalerValue)
|
||||
{
|
||||
u32 ControlReg;
|
||||
|
||||
/*
|
||||
* Assert to validate input arguments.
|
||||
*/
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
/*
|
||||
* Read the Timer control register.
|
||||
*/
|
||||
ControlReg = XScuTimer_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUTIMER_CONTROL_OFFSET);
|
||||
|
||||
/*
|
||||
* Clear all of the prescaler control bits in the register.
|
||||
*/
|
||||
ControlReg &= (u32)(~XSCUTIMER_CONTROL_PRESCALER_MASK);
|
||||
|
||||
/*
|
||||
* Set the prescaler value.
|
||||
*/
|
||||
ControlReg |= (((u32)PrescalerValue) << XSCUTIMER_CONTROL_PRESCALER_SHIFT);
|
||||
|
||||
/*
|
||||
* Write the register with the new values.
|
||||
*/
|
||||
XScuTimer_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUTIMER_CONTROL_OFFSET, ControlReg);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function returns the current prescaler value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return The prescaler value.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
****************************************************************************/
|
||||
u8 XScuTimer_GetPrescaler(XScuTimer *InstancePtr)
|
||||
{
|
||||
u32 ControlReg;
|
||||
|
||||
/*
|
||||
* Assert to validate input arguments.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the Timer control register.
|
||||
*/
|
||||
ControlReg = XScuTimer_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUTIMER_CONTROL_OFFSET);
|
||||
ControlReg &= XSCUTIMER_CONTROL_PRESCALER_MASK;
|
||||
|
||||
return (u8)(ControlReg >> XSCUTIMER_CONTROL_PRESCALER_SHIFT);
|
||||
}
|
||||
/** @} */
|
350
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.h
Normal file
350
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.h
Normal file
@ -0,0 +1,350 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscutimer.h
|
||||
* @addtogroup scutimer_v2_4
|
||||
* @{
|
||||
* @details
|
||||
*
|
||||
* The timer driver supports the Cortex A9 private timer.
|
||||
*
|
||||
* The timer driver supports the following features:
|
||||
* - Normal mode and Auto reload mode
|
||||
* - Interrupts (Interrupt handler is not provided in this driver. Application
|
||||
* has to register it's own handler)
|
||||
*
|
||||
* <b> Initialization and Configuration </b>
|
||||
*
|
||||
* The device driver enables higher layer software (e.g., an application) to
|
||||
* communicate with the Timer.
|
||||
*
|
||||
* XScuTimer_CfgInitialize() API is used to initialize the Timer. The
|
||||
* user needs to first call the XScuTimer_LookupConfig() API which returns
|
||||
* the Configuration structure pointer which is passed as a parameter to
|
||||
* the XScuTimer_CfgInitialize() API.
|
||||
*
|
||||
* <b> Interrupts </b>
|
||||
*
|
||||
* The Timer hardware supports interrupts.
|
||||
*
|
||||
* This driver does not provide a Interrupt Service Routine (ISR) for the device.
|
||||
* It is the responsibility of the application to provide one if needed. Refer to
|
||||
* the interrupt example provided with this driver for details on using the
|
||||
* Timer in interrupt mode.
|
||||
*
|
||||
* <b> Virtual Memory </b>
|
||||
*
|
||||
* This driver supports Virtual Memory. The RTOS is responsible for calculating
|
||||
* the correct device base address in Virtual Memory space.
|
||||
*
|
||||
* <b> Threads </b>
|
||||
*
|
||||
* This driver is not thread safe. Any needs for threads or thread mutual
|
||||
* exclusion must be satisfied by the layer above this driver.
|
||||
*
|
||||
* <b> Asserts </b>
|
||||
*
|
||||
* Asserts are used within all Xilinx drivers to enforce constraints on argument
|
||||
* values. Asserts can be turned off on a system-wide basis by defining, at
|
||||
* compile time, the NDEBUG identifier. By default, asserts are turned on and it
|
||||
* is recommended that users leave asserts on during development.
|
||||
*
|
||||
* <b> Building the driver </b>
|
||||
*
|
||||
* The XScuTimer driver is composed of several source files. This allows the user
|
||||
* to build and link only those parts of the driver that are necessary.
|
||||
*
|
||||
* <br><br>
|
||||
*
|
||||
* NOTE:
|
||||
* The timer is not a part of the snoop control unit as indicated by the
|
||||
* prefix "scu" in the name of the driver.
|
||||
* It is an independent module in APU.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a nm 03/10/10 First release
|
||||
* 1.02a sg 07/17/12 Included xil_assert.h for CR 667947. This is an issue
|
||||
* when the xstatus.h in the common driver overwrites
|
||||
* the xstatus.h of the standalone BSP during the
|
||||
* libgen.
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* ms 03/17/17 Added readme.txt file in examples folder for doxygen
|
||||
* generation.
|
||||
* 2.3 mus 08/31/20 Updated makefile to support parallel make and
|
||||
* incremental builds, it would help to reduce compilation
|
||||
* time.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XSCUTIMER_H /* prevent circular inclusions */
|
||||
#define XSCUTIMER_H /* by using protection macros */
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xscutimer_hw.h"
|
||||
#include "bspconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for the device.
|
||||
*/
|
||||
typedef struct {
|
||||
u16 DeviceId; /**< Unique ID of device */
|
||||
u32 BaseAddr; /**< Base address of the device */
|
||||
#ifdef XIL_INTERRUPT
|
||||
u32 IntrId;
|
||||
UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] Parent base address */
|
||||
#endif
|
||||
} XScuTimer_Config;
|
||||
|
||||
/**
|
||||
* The XScuTimer driver instance data. The user is required to allocate a
|
||||
* variable of this type for every timer device in the system.
|
||||
* A pointer to a variable of this type is then passed to the driver API
|
||||
* functions.
|
||||
*/
|
||||
typedef struct {
|
||||
XScuTimer_Config Config; /**< Hardware Configuration */
|
||||
u32 IsReady; /**< Device is initialized and ready */
|
||||
u32 IsStarted; /**< Device timer is running */
|
||||
} XScuTimer;
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Check if the timer has expired.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return
|
||||
* - TRUE if the timer has expired.
|
||||
* - FALSE if the timer has not expired.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* int XScuTimer_IsExpired(XScuTimer *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_IsExpired(InstancePtr) \
|
||||
((XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_ISR_OFFSET) & \
|
||||
XSCUTIMER_ISR_EVENT_FLAG_MASK) == \
|
||||
XSCUTIMER_ISR_EVENT_FLAG_MASK)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Re-start the timer. This macro will read the timer load register
|
||||
* and writes the same value to load register to update the counter register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_RestartTimer(XScuTimer *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_RestartTimer(InstancePtr) \
|
||||
XScuTimer_LoadTimer((InstancePtr), \
|
||||
XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_LOAD_OFFSET))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write to the timer load register. This will also update the
|
||||
* timer counter register with the new value. This macro can be used to
|
||||
* change the time-out value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
* @param Value is the count to be loaded in to the load register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_LoadTimer(XScuTimer *InstancePtr, u32 Value)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_LoadTimer(InstancePtr, Value) \
|
||||
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_LOAD_OFFSET, (Value))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Returns the current timer counter register value. It can be called at any
|
||||
* time.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return Contents of the timer counter register.
|
||||
*
|
||||
* @note C-style signature:
|
||||
u32 XScuTimer_GetCounterValue(XScuTimer *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_GetCounterValue(InstancePtr) \
|
||||
XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_COUNTER_OFFSET)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Enable auto-reload mode.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_EnableAutoReload(XScuTimer *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_EnableAutoReload(InstancePtr) \
|
||||
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_CONTROL_OFFSET, \
|
||||
(XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_CONTROL_OFFSET) | \
|
||||
XSCUTIMER_CONTROL_AUTO_RELOAD_MASK))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Disable auto-reload mode.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_DisableAutoReload(XScuTimer *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_DisableAutoReload(InstancePtr) \
|
||||
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_CONTROL_OFFSET, \
|
||||
(XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_CONTROL_OFFSET) & \
|
||||
~(XSCUTIMER_CONTROL_AUTO_RELOAD_MASK)))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Enable the Timer interrupt.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_EnableInterrupt(XScuTimer *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_EnableInterrupt(InstancePtr) \
|
||||
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_CONTROL_OFFSET, \
|
||||
(XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_CONTROL_OFFSET) | \
|
||||
XSCUTIMER_CONTROL_IRQ_ENABLE_MASK))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Disable the Timer interrupt.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_DisableInterrupt(XScuTimer *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_DisableInterrupt(InstancePtr) \
|
||||
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_CONTROL_OFFSET, \
|
||||
(XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_CONTROL_OFFSET) & \
|
||||
~(XSCUTIMER_CONTROL_IRQ_ENABLE_MASK)))
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function reads the interrupt status.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_GetInterruptStatus(XScuTimer *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_GetInterruptStatus(InstancePtr) \
|
||||
XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_ISR_OFFSET)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function clears the interrupt status.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_ClearInterruptStatus(XScuTimer *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_ClearInterruptStatus(InstancePtr) \
|
||||
XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUTIMER_ISR_OFFSET, XSCUTIMER_ISR_EVENT_FLAG_MASK)
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*
|
||||
* Lookup configuration in xscutimer_sinit.c
|
||||
*/
|
||||
XScuTimer_Config *XScuTimer_LookupConfig(u16 DeviceId);
|
||||
|
||||
/*
|
||||
* Selftest function in xscutimer_selftest.c
|
||||
*/
|
||||
s32 XScuTimer_SelfTest(XScuTimer *InstancePtr);
|
||||
|
||||
/*
|
||||
* Interface functions in xscutimer.c
|
||||
*/
|
||||
s32 XScuTimer_CfgInitialize(XScuTimer *InstancePtr,
|
||||
XScuTimer_Config *ConfigPtr, u32 EffectiveAddress);
|
||||
void XScuTimer_Start(XScuTimer *InstancePtr);
|
||||
void XScuTimer_Stop(XScuTimer *InstancePtr);
|
||||
void XScuTimer_SetPrescaler(XScuTimer *InstancePtr, u8 PrescalerValue);
|
||||
u8 XScuTimer_GetPrescaler(XScuTimer *InstancePtr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
52
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_g.c
Normal file
52
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_g.c
Normal file
@ -0,0 +1,52 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscutimer_g.c
|
||||
* @addtogroup scutimer_v2_4
|
||||
* @{
|
||||
*
|
||||
* This file contains a table that specifies the configuration of the SCU
|
||||
* Timer in the system.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a nm 03/10/10 First release
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xscutimer.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Prototypes ******************************/
|
||||
|
||||
/**
|
||||
* This table contains configuration information for each timer
|
||||
* device in the system.
|
||||
*/
|
||||
XScuTimer_Config XScuTimer_ConfigTable[XPAR_XSCUTIMER_NUM_INSTANCES] = {
|
||||
{
|
||||
(u16)XPAR_XSCUTIMER_0_DEVICE_ID,
|
||||
(u32)XPAR_XSCUTIMER_0_BASEADDR
|
||||
}
|
||||
};
|
||||
/** @} */
|
261
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_hw.h
Normal file
261
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_hw.h
Normal file
@ -0,0 +1,261 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscutimer_hw.h
|
||||
* @addtogroup scutimer_v2_4
|
||||
* @{
|
||||
*
|
||||
* This file contains the hardware interface to the Timer.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a nm 03/10/10 First release
|
||||
* 1.01a sdm 02/02/12 Added low level macros to read/write load, counter, control
|
||||
* and interrupt registers
|
||||
* 1.02a sg 07/17/12 Included xil_assert.h for CR 667947. This is an issue
|
||||
* when the xstatus.h in the common driver overwrites
|
||||
* the xstatus.h of the standalone BSP during the
|
||||
* libgen.
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XSCUTIMER_HW_H /* prevent circular inclusions */
|
||||
#define XSCUTIMER_HW_H /* by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include "xil_types.h"
|
||||
#include "xil_io.h"
|
||||
#include "xil_assert.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Register Map
|
||||
* Offsets of registers from the start of the device
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSCUTIMER_LOAD_OFFSET 0x00U /**< Timer Load Register */
|
||||
#define XSCUTIMER_COUNTER_OFFSET 0x04U /**< Timer Counter Register */
|
||||
#define XSCUTIMER_CONTROL_OFFSET 0x08U /**< Timer Control Register */
|
||||
#define XSCUTIMER_ISR_OFFSET 0x0CU /**< Timer Interrupt
|
||||
Status Register */
|
||||
/* @} */
|
||||
|
||||
/** @name Timer Control register
|
||||
* This register bits control the prescaler, Intr enable,
|
||||
* auto-reload and timer enable.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSCUTIMER_CONTROL_PRESCALER_MASK 0x0000FF00U /**< Prescaler */
|
||||
#define XSCUTIMER_CONTROL_PRESCALER_SHIFT 8U
|
||||
#define XSCUTIMER_CONTROL_IRQ_ENABLE_MASK 0x00000004U /**< Intr enable */
|
||||
#define XSCUTIMER_CONTROL_AUTO_RELOAD_MASK 0x00000002U /**< Auto-reload */
|
||||
#define XSCUTIMER_CONTROL_ENABLE_MASK 0x00000001U /**< Timer enable */
|
||||
/* @} */
|
||||
|
||||
/** @name Interrupt Status register
|
||||
* This register indicates the Timer counter register has reached zero.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSCUTIMER_ISR_EVENT_FLAG_MASK 0x00000001U /**< Event flag */
|
||||
/*@}*/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write to the timer load register. This will also update the
|
||||
* timer counter register with the new value. This macro can be used to
|
||||
* change the time-out value.
|
||||
*
|
||||
* @param BaseAddr is the base address of the scu timer.
|
||||
* @param Value is the count to be loaded in to the load register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_SetLoadReg(u32 BaseAddr, u32 Value)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_SetLoadReg(BaseAddr, Value) \
|
||||
XScuTimer_WriteReg(BaseAddr, XSCUTIMER_LOAD_OFFSET, (Value))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Returns the current timer load register value.
|
||||
*
|
||||
* @param BaseAddr is the base address of the scu timer.
|
||||
*
|
||||
* @return Contents of the timer load register.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* u32 XScuTimer_GetLoadReg(u32 BaseAddr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_GetLoadReg(BaseAddr) \
|
||||
XScuTimer_ReadReg(BaseAddr, XSCUTIMER_LOAD_OFFSET)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write to the timer counter register.
|
||||
*
|
||||
* @param BaseAddr is the base address of the scu timer.
|
||||
* @param Value is the count to be loaded in to the counter register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_SetCounterReg(u32 BaseAddr, u32 Value)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_SetCounterReg(BaseAddr, Value) \
|
||||
XScuTimer_WriteReg(BaseAddr, XSCUTIMER_COUNTER_OFFSET, (Value))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Returns the current timer counter register value.
|
||||
*
|
||||
* @param BaseAddr is the base address of the scu timer.
|
||||
*
|
||||
* @return Contents of the timer counter register.
|
||||
*
|
||||
* @note C-style signature:
|
||||
u32 XScuTimer_GetCounterReg(u32 BaseAddr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_GetCounterReg(BaseAddr) \
|
||||
XScuTimer_ReadReg(BaseAddr, XSCUTIMER_COUNTER_OFFSET)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write to the timer load register. This will also update the
|
||||
* timer counter register with the new value. This macro can be used to
|
||||
* change the time-out value.
|
||||
*
|
||||
* @param BaseAddr is the base address of the scu timer.
|
||||
* @param Value is the count to be loaded in to the load register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_SetControlReg(u32 BaseAddr, u32 Value)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_SetControlReg(BaseAddr, Value) \
|
||||
XScuTimer_WriteReg(BaseAddr, XSCUTIMER_CONTROL_OFFSET, (Value))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Returns the current timer load register value.
|
||||
*
|
||||
* @param BaseAddr is the base address of the scu timer.
|
||||
*
|
||||
* @return Contents of the timer load register.
|
||||
*
|
||||
* @note C-style signature:
|
||||
u32 XScuTimer_GetControlReg(u32 BaseAddr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_GetControlReg(BaseAddr) \
|
||||
XScuTimer_ReadReg(BaseAddr, XSCUTIMER_CONTROL_OFFSET)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write to the timer counter register.
|
||||
*
|
||||
* @param BaseAddr is the base address of the scu timer.
|
||||
* @param Value is the count to be loaded in to the counter register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_SetIntrReg(u32 BaseAddr, u32 Value)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_SetIntrReg(BaseAddr, Value) \
|
||||
XScuTimer_WriteReg(BaseAddr, XSCUTIMER_ISR_OFFSET, (Value))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Returns the current timer counter register value.
|
||||
*
|
||||
* @param BaseAddr is the base address of the scu timer.
|
||||
*
|
||||
* @return Contents of the timer counter register.
|
||||
*
|
||||
* @note C-style signature:
|
||||
u32 XScuTimer_GetIntrReg(u32 BaseAddr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuTimer_GetIntrReg(BaseAddr) \
|
||||
XScuTimer_ReadReg(BaseAddr, XSCUTIMER_ISR_OFFSET)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read from the given Timer register.
|
||||
*
|
||||
* @param BaseAddr is the base address of the device
|
||||
* @param RegOffset is the register offset to be read
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note C-style signature:
|
||||
* u32 XScuTimer_ReadReg(u32 BaseAddr, u32 RegOffset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuTimer_ReadReg(BaseAddr, RegOffset) \
|
||||
Xil_In32((BaseAddr) + (RegOffset))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write to the given Timer register.
|
||||
*
|
||||
* @param BaseAddr is the base address of the device
|
||||
* @param RegOffset is the register offset to be written
|
||||
* @param Data is the 32-bit value to write to the register
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuTimer_WriteReg(u32 BaseAddr, u32 RegOffset, u32 Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuTimer_WriteReg(BaseAddr, RegOffset, Data) \
|
||||
Xil_Out32((BaseAddr) + (RegOffset), (Data))
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
113
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_selftest.c
Normal file
113
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_selftest.c
Normal file
@ -0,0 +1,113 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscutimer_selftest.c
|
||||
* @addtogroup scutimer_v2_4
|
||||
* @{
|
||||
*
|
||||
* Contains diagnostic self-test functions for the XScuTimer driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a nm 03/10/10 First release
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xscutimer.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
#define XSCUTIMER_SELFTEST_VALUE 0xA55AF00FU
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Run a self-test on the timer. This test clears the timer enable bit in
|
||||
* the control register, writes to the timer load register and verifies the
|
||||
* value read back matches the value written and restores the control register
|
||||
* and the timer load register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuTimer instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if self-test was successful.
|
||||
* - XST_FAILURE if self test was not successful.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XScuTimer_SelfTest(XScuTimer *InstancePtr)
|
||||
{
|
||||
u32 Register;
|
||||
u32 CtrlOrig;
|
||||
u32 LoadOrig;
|
||||
s32 Status;
|
||||
|
||||
/*
|
||||
* Assert to ensure the inputs are valid and the instance has been
|
||||
* initialized.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Save the contents of the Control Register and stop the timer.
|
||||
*/
|
||||
CtrlOrig = XScuTimer_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUTIMER_CONTROL_OFFSET);
|
||||
Register = CtrlOrig & (u32)(~XSCUTIMER_CONTROL_ENABLE_MASK);
|
||||
XScuTimer_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUTIMER_CONTROL_OFFSET, Register);
|
||||
|
||||
/*
|
||||
* Save the contents of the Load Register.
|
||||
* Load a new test value in the Load Register, read it back and
|
||||
* compare it with the written value.
|
||||
*/
|
||||
LoadOrig = XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr,
|
||||
XSCUTIMER_LOAD_OFFSET);
|
||||
XScuTimer_LoadTimer(InstancePtr, XSCUTIMER_SELFTEST_VALUE);
|
||||
Register = XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr,
|
||||
XSCUTIMER_LOAD_OFFSET);
|
||||
|
||||
/*
|
||||
* Restore the contents of the Load Register and Control Register.
|
||||
*/
|
||||
XScuTimer_LoadTimer(InstancePtr, LoadOrig);
|
||||
XScuTimer_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUTIMER_CONTROL_OFFSET, CtrlOrig);
|
||||
|
||||
/*
|
||||
* Return a Failure if the contents of the Load Register do not
|
||||
* match with the value written to it.
|
||||
*/
|
||||
if (Register != XSCUTIMER_SELFTEST_VALUE) {
|
||||
Status = (s32)XST_FAILURE;
|
||||
}
|
||||
else {
|
||||
Status = (s32)XST_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
/** @} */
|
70
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_sinit.c
Normal file
70
bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_sinit.c
Normal file
@ -0,0 +1,70 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscutimer_sinit.c
|
||||
* @addtogroup scutimer_v2_4
|
||||
* @{
|
||||
*
|
||||
* This file contains method for static initialization (compile-time) of the
|
||||
* driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a nm 03/10/10 First release
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xscutimer.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Variable Definitions ****************************/
|
||||
extern XScuTimer_Config XScuTimer_ConfigTable[XPAR_XSCUTIMER_NUM_INSTANCES];
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Lookup the device configuration based on the unique device ID. The table
|
||||
* contains the configuration info for each device in the system.
|
||||
*
|
||||
* @param DeviceId is the unique device ID of the device being looked up.
|
||||
*
|
||||
* @return A pointer to the configuration table entry corresponding to the
|
||||
* given device ID, or NULL if no match is found.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
XScuTimer_Config *XScuTimer_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
XScuTimer_Config *CfgPtr = NULL;
|
||||
u32 Index;
|
||||
|
||||
for (Index = 0U; Index < XPAR_XSCUTIMER_NUM_INSTANCES; Index++) {
|
||||
if (XScuTimer_ConfigTable[Index].DeviceId == DeviceId) {
|
||||
CfgPtr = &XScuTimer_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (XScuTimer_Config *)CfgPtr;
|
||||
}
|
||||
/** @} */
|
39
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/Makefile
Normal file
39
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/Makefile
Normal file
@ -0,0 +1,39 @@
|
||||
DRIVER_LIB_VERSION = 1.0
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
CC_FLAGS = $(COMPILER_FLAGS)
|
||||
ECC_FLAGS = $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I$(INCLUDEDIR)
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR), $(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
libs: $(OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
${COMPILER} $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) $< -o $@
|
||||
|
||||
.PHONY: include
|
||||
include: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf ${DEPFILES}
|
191
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.c
Normal file
191
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.c
Normal file
@ -0,0 +1,191 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscuwdt.c
|
||||
* @addtogroup scuwdt_v2_4
|
||||
* @{
|
||||
*
|
||||
* Contains the implementation of interface functions of the XScuWdt driver.
|
||||
* See xscuwdt.h for a description of the driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a sdm 01/15/10 First release
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xscuwdt.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Initialize a specific watchdog timer instance/driver. This function
|
||||
* must be called before other functions of the driver are called.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
* @param ConfigPtr is the config structure.
|
||||
* @param EffectiveAddress is the base address for the device. It could be
|
||||
* a virtual address if address translation is supported in the
|
||||
* system, otherwise it is the physical address.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if initialization was successful.
|
||||
* - XST_DEVICE_IS_STARTED if the device has already been started.
|
||||
*
|
||||
* @note This function enables the watchdog mode.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XScuWdt_CfgInitialize(XScuWdt *InstancePtr,
|
||||
XScuWdt_Config *ConfigPtr, u32 EffectiveAddress)
|
||||
{
|
||||
s32 CfgStatus;
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(ConfigPtr != NULL);
|
||||
Xil_AssertNonvoid(EffectiveAddress != 0x00U);
|
||||
|
||||
/*
|
||||
* If the device is started, disallow the initialize and return a
|
||||
* status indicating it is started. This allows the user to stop the
|
||||
* device and reinitialize, but prevents a user from inadvertently
|
||||
* initializing.
|
||||
*/
|
||||
if (InstancePtr->IsStarted == XIL_COMPONENT_IS_STARTED) {
|
||||
CfgStatus = (s32)XST_DEVICE_IS_STARTED;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Copy configuration into instance.
|
||||
*/
|
||||
InstancePtr->Config.DeviceId = ConfigPtr->DeviceId;
|
||||
|
||||
/*
|
||||
* Save the base address pointer such that the registers of the block
|
||||
* can be accessed and indicate it has not been started yet.
|
||||
*/
|
||||
InstancePtr->Config.BaseAddr = EffectiveAddress;
|
||||
InstancePtr->IsStarted = 0U;
|
||||
|
||||
/*
|
||||
* Put the watchdog timer in Watchdog mode.
|
||||
*/
|
||||
XScuWdt_SetWdMode(InstancePtr);
|
||||
|
||||
/*
|
||||
* Indicate the instance is ready to use, successfully initialized.
|
||||
*/
|
||||
InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
|
||||
|
||||
CfgStatus =(s32)XST_SUCCESS;
|
||||
}
|
||||
return CfgStatus;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Start the watchdog counter of the device.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note User needs to select the appropriate mode (watchdog/timer)
|
||||
* before using this API.
|
||||
* See XScuWdt_SetWdMode/XScuWdt_SetTimerMode macros in
|
||||
* xscuwdt.h.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XScuWdt_Start(XScuWdt *InstancePtr)
|
||||
{
|
||||
u32 Register;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the contents of the Control register.
|
||||
*/
|
||||
Register = XScuWdt_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUWDT_CONTROL_OFFSET);
|
||||
|
||||
/*
|
||||
* Set the 'watchdog enable' bit in the register.
|
||||
*/
|
||||
Register |= XSCUWDT_CONTROL_WD_ENABLE_MASK;
|
||||
|
||||
/*
|
||||
* Update the Control register with the new value.
|
||||
*/
|
||||
XScuWdt_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUWDT_CONTROL_OFFSET, Register);
|
||||
|
||||
/*
|
||||
* Indicate that the device is started.
|
||||
*/
|
||||
InstancePtr->IsStarted = XIL_COMPONENT_IS_STARTED;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Stop the watchdog timer.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
void XScuWdt_Stop(XScuWdt *InstancePtr)
|
||||
{
|
||||
u32 Register;
|
||||
|
||||
Xil_AssertVoid(InstancePtr != NULL);
|
||||
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Read the contents of the Control register.
|
||||
*/
|
||||
Register = XScuWdt_ReadReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUWDT_CONTROL_OFFSET);
|
||||
|
||||
/*
|
||||
* Clear the 'watchdog enable' bit in the register.
|
||||
*/
|
||||
Register &= (~(u32)XSCUWDT_CONTROL_WD_ENABLE_MASK);
|
||||
|
||||
/*
|
||||
* Update the Control register with the new value.
|
||||
*/
|
||||
XScuWdt_WriteReg(InstancePtr->Config.BaseAddr,
|
||||
XSCUWDT_CONTROL_OFFSET, Register);
|
||||
|
||||
/*
|
||||
* Indicate that the device is stopped.
|
||||
*/
|
||||
InstancePtr->IsStarted = 0U;
|
||||
}
|
||||
/** @} */
|
365
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.h
Normal file
365
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.h
Normal file
@ -0,0 +1,365 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscuwdt.h
|
||||
* @addtogroup scuwdt_v2_4
|
||||
* @{
|
||||
* @details
|
||||
*
|
||||
* The Xilinx SCU watchdog timer driver (XScuWdt) supports the Xilinx SCU private
|
||||
* watchdog timer hardware.
|
||||
*
|
||||
* The XScuWdt driver supports the following features:
|
||||
* - Watchdog mode
|
||||
* - Timer mode
|
||||
* - Auto reload (timer mode only)
|
||||
*
|
||||
* The watchdog counter register is a down counter and starts decrementing when
|
||||
* the watchdog is started.
|
||||
* In watchdog mode, when the counter reaches 0, the Reset flag is set in the
|
||||
* Reset status register and the WDRESETREQ pin is asserted, causing a system
|
||||
* reset. The Reset flag is not reset by normal processor reset and is cleared
|
||||
* when written with a value of 1. This enables the user to differentiate a
|
||||
* normal reset and a reset caused by watchdog time-out. The user needs to call
|
||||
* XScuWdt_RestartWdt() periodically, to avoid the watchdog from being timed-out.
|
||||
*
|
||||
* The IsWdtExpired function can be used to check if the watchdog was the cause
|
||||
* of the last reset. In this situation, call Initialize then call IsWdtExpired.
|
||||
* If the result is true, watchdog timeout caused the last system reset. The
|
||||
* application then needs to clear the Reset flag.
|
||||
*
|
||||
* In timer mode, when the counter reaches 0, the Event flag is set in the
|
||||
* Interrupt status register and if interrupts are enabled, interrupt ID 30 is
|
||||
* set as pending in the interrupt distributor. The IsTimerExpired function
|
||||
* is used to check if the watchdog counter has decremented to 0 in timer mode.
|
||||
* If auto-reload mode is enabled, the Counter register is automatically reloaded
|
||||
* from the Load register.
|
||||
*
|
||||
* <b> Initialization and Configuration </b>
|
||||
*
|
||||
* The device driver enables higher layer software (e.g., an application) to
|
||||
* communicate with the Watchdog Timer.
|
||||
*
|
||||
* XScuWdt_CfgInitialize() API is used to initialize the Watchdog Timer. The
|
||||
* user needs to first call the XScuWdt_LookupConfig() API which returns
|
||||
* the Configuration structure pointer which is passed as a parameter to
|
||||
* the XScuWdt_CfgInitialize() API.
|
||||
*
|
||||
* <b>Interrupts</b>
|
||||
*
|
||||
* The SCU Watchdog Timer supports interrupts in Timer mode.
|
||||
*
|
||||
* This driver does not provide a Interrupt Service Routine (ISR) for the device.
|
||||
* It is the responsibility of the application to provide one if needed. Refer to
|
||||
* the interrupt example provided with this driver for details on using the
|
||||
* Timer in interrupt mode.
|
||||
*
|
||||
* <b> Virtual Memory </b>
|
||||
*
|
||||
* This driver supports Virtual Memory. The RTOS is responsible for calculating
|
||||
* the correct device base address in Virtual Memory space.
|
||||
*
|
||||
* <b> Threads </b>
|
||||
*
|
||||
* This driver is not thread safe. Any needs for threads or thread mutual
|
||||
* exclusion must be satisfied by the layer above this driver.
|
||||
*
|
||||
* <b> Asserts </b>
|
||||
*
|
||||
* Asserts are used within all Xilinx drivers to enforce constraints on argument
|
||||
* values. Asserts can be turned off on a system-wide basis by defining, at
|
||||
* compile time, the NDEBUG identifier. By default, asserts are turned on and it
|
||||
* is recommended that users leave asserts on during development.
|
||||
*
|
||||
* <b> Building the driver </b>
|
||||
*
|
||||
* The XScuWdt driver is composed of several source files. This allows the user
|
||||
* to build and link only those parts of the driver that are necessary.
|
||||
*
|
||||
* <br><br>
|
||||
*
|
||||
* NOTE:
|
||||
* The watchdog timer is not a part of the snoop control unit as indicated
|
||||
* by the prefix "scu" in the name of the driver.
|
||||
* It is an independent module in APU.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a sdm 01/15/10 First release
|
||||
* 1.02a sg 07/17/12 Included xil_assert.h for CR 667947. This is an issue
|
||||
* when the xstatus.h in the common driver overwrites
|
||||
* the xstatus.h of the standalone BSP during the
|
||||
* libgen.
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* ms 03/17/17 Added readme.txt file in examples folder for doxygen
|
||||
* generation.
|
||||
* 2.3 mus 08/31/20 Updated makefile to support parallel make and
|
||||
* incremental builds. It would help to reduce compilaton
|
||||
* time.
|
||||
* 2.3 sne 09/16/20 Fixed MISRA-C violations.
|
||||
* 2.4 sne 02/04/21 Fixed Doxygen warnings.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XSCUWDT_H /**< prevent circular inclusions */
|
||||
#define XSCUWDT_H /**< by using protection macros */
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xscuwdt_hw.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for the device.
|
||||
*/
|
||||
typedef struct {
|
||||
u16 DeviceId; /**< Unique ID of device */
|
||||
u32 BaseAddr; /**< Base address of the device */
|
||||
} XScuWdt_Config;
|
||||
|
||||
/**
|
||||
* The XScuWdt driver instance data. The user is required to allocate a
|
||||
* variable of this type for every watchdog/timer device in the system.
|
||||
* A pointer to a variable of this type is then passed to the driver API
|
||||
* functions.
|
||||
*/
|
||||
typedef struct {
|
||||
XScuWdt_Config Config;/**< Hardware Configuration */
|
||||
u32 IsReady; /**< Device is initialized and ready */
|
||||
u32 IsStarted; /**< Device watchdog timer is running */
|
||||
} XScuWdt;
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
extern XScuWdt_Config XScuWdt_ConfigTable[];
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is used to check if the watchdog has timed-out and the last
|
||||
* reset was caused by the watchdog reset.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
*
|
||||
* @return
|
||||
* - TRUE if the watchdog has expired.
|
||||
* - FALSE if the watchdog has not expired.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* int XScuWdt_IsWdtExpired(XScuWdt *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuWdt_IsWdtExpired(InstancePtr) \
|
||||
((XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUWDT_RST_STS_OFFSET) & \
|
||||
XSCUWDT_RST_STS_RESET_FLAG_MASK) == XSCUWDT_RST_STS_RESET_FLAG_MASK)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is used to check if the watchdog counter has reached 0 in timer
|
||||
* mode.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
*
|
||||
* @return
|
||||
* - TRUE if the watchdog has expired.
|
||||
* - FALSE if the watchdog has not expired.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* int XScuWdt_IsTimerExpired(XScuWdt *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuWdt_IsTimerExpired(InstancePtr) \
|
||||
((XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUWDT_ISR_OFFSET) & \
|
||||
XSCUWDT_ISR_EVENT_FLAG_MASK) == XSCUWDT_ISR_EVENT_FLAG_MASK)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Re-start the watchdog timer. This macro will read the watchdog load register
|
||||
* and write the same value to load register to update the counter register.
|
||||
* An application needs to call this function periodically to keep the watchdog
|
||||
* from asserting the WDRESETREQ reset request output pin.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuWdt_RestartWdt(XScuWdt *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuWdt_RestartWdt(InstancePtr) \
|
||||
XScuWdt_LoadWdt((InstancePtr), \
|
||||
(XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUWDT_LOAD_OFFSET)))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write to the watchdog timer load register. This will also update the
|
||||
* watchdog counter register with the new value. This macro can be used to
|
||||
* change the time-out value.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
* @param Value is the value to be written to the Watchdog Load register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuWdt_LoadWdt(XScuWdt *InstancePtr, u32 Value)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuWdt_LoadWdt(InstancePtr, Value) \
|
||||
XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUWDT_LOAD_OFFSET, (Value))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Put the watchdog timer in Watchdog mode by setting the WD mode bit of the
|
||||
* Watchdog control register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuWdt_SetWdMode(XScuWdt *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuWdt_SetWdMode(InstancePtr) \
|
||||
XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUWDT_CONTROL_OFFSET, \
|
||||
(XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUWDT_CONTROL_OFFSET) | \
|
||||
(XSCUWDT_CONTROL_WD_MODE_MASK)))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Put the watchdog timer in Timer mode by writing 0x12345678 and 0x87654321
|
||||
* successively to the Watchdog Disable Register.
|
||||
* The software must write 0x12345678 and 0x87654321 successively to the
|
||||
* Watchdog Disable Register so that the watchdog mode bit in the Watchdog
|
||||
* Control Register is set to zero.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuWdt_SetTimerMode(XScuWdt *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuWdt_SetTimerMode(InstancePtr) \
|
||||
{ \
|
||||
XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUWDT_DISABLE_OFFSET, \
|
||||
XSCUWDT_DISABLE_VALUE1); \
|
||||
XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUWDT_DISABLE_OFFSET, \
|
||||
XSCUWDT_DISABLE_VALUE2); \
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Get the contents of the watchdog control register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
*
|
||||
* @return Contents of the watchdog control register.
|
||||
*
|
||||
* @note C-style signature:
|
||||
u32 XScuWdt_GetControlReg(XScuWdt *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuWdt_GetControlReg(InstancePtr) \
|
||||
XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUWDT_CONTROL_OFFSET)
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write to the watchdog control register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
* @param ControlReg is the value to be written to the watchdog control
|
||||
* register.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
void XScuWdt_SetControlReg(XScuWdt *InstancePtr, u32 ControlReg)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuWdt_SetControlReg(InstancePtr, ControlReg) \
|
||||
XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \
|
||||
XSCUWDT_CONTROL_OFFSET, (ControlReg))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Enable auto-reload mode.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuWdt_EnableAutoReload(XScuWdt *InstancePtr)
|
||||
*
|
||||
******************************************************************************/
|
||||
#define XScuWdt_EnableAutoReload(InstancePtr) \
|
||||
XScuWdt_SetControlReg((InstancePtr), \
|
||||
(XScuWdt_GetControlReg(InstancePtr) | \
|
||||
XSCUWDT_CONTROL_AUTO_RELOAD_MASK))
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*
|
||||
* Lookup configuration in xscuwdt_sinit.c.
|
||||
*/
|
||||
XScuWdt_Config *XScuWdt_LookupConfig(u16 DeviceId);
|
||||
|
||||
/*
|
||||
* Selftest function in xscuwdt_selftest.c
|
||||
*/
|
||||
s32 XScuWdt_SelfTest(XScuWdt *InstancePtr);
|
||||
|
||||
/*
|
||||
* Interface functions in xscuwdt.c
|
||||
*/
|
||||
s32 XScuWdt_CfgInitialize(XScuWdt *InstancePtr,
|
||||
XScuWdt_Config *ConfigPtr, u32 EffectiveAddress);
|
||||
|
||||
void XScuWdt_Start(XScuWdt *InstancePtr);
|
||||
|
||||
void XScuWdt_Stop(XScuWdt *InstancePtr);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
53
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_g.c
Normal file
53
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_g.c
Normal file
@ -0,0 +1,53 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscuwdt_g.c
|
||||
* @addtogroup scuwdt_v2_4
|
||||
* @{
|
||||
*
|
||||
* This file contains a table that specifies the configuration of the SCU
|
||||
* watchdog timer devices in the system. Each device should have an entry
|
||||
* in the table.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a sdm 01/15/10 First release
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xscuwdt.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Prototypes ******************************/
|
||||
|
||||
/**
|
||||
* This table contains configuration information for each watchdog timer
|
||||
* device in the system.
|
||||
*/
|
||||
XScuWdt_Config XScuWdt_ConfigTable[XPAR_XSCUWDT_NUM_INSTANCES] = {
|
||||
{
|
||||
(u16)XPAR_SCUWDT_0_DEVICE_ID,
|
||||
(u32)XPAR_SCUWDT_0_BASEADDR
|
||||
}
|
||||
};
|
||||
/** @} */
|
156
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_hw.h
Normal file
156
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_hw.h
Normal file
@ -0,0 +1,156 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscuwdt_hw.h
|
||||
* @addtogroup scuwdt_v2_4
|
||||
* @{
|
||||
*
|
||||
* This file contains the hardware interface to the Xilinx SCU private Watch Dog
|
||||
* Timer (XSCUWDT).
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a sdm 01/15/10 First release
|
||||
* 1.01a bss 02/27/12 Updated the register offsets to start at 0x0 instead
|
||||
* of 0x20 as the base address obtained from the tools
|
||||
* starts at 0x20.
|
||||
* 1.02a sg 07/17/12 Included xil_assert.h for CR 667947. This is an issue
|
||||
* when the xstatus.h in the common driver overwrites
|
||||
* the xstatus.h of the standalone BSP during the
|
||||
* libgen.
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef XSCUWDT_HW_H /**< prevent circular inclusions */
|
||||
#define XSCUWDT_HW_H /**< by using protection macros */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "xil_io.h"
|
||||
#include "xil_assert.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/** @name Register Map
|
||||
* Offsets of registers from the start of the device. The WDT registers start at
|
||||
* an offset 0x20
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSCUWDT_LOAD_OFFSET 0x00U /**< Watchdog Load Register */
|
||||
#define XSCUWDT_COUNTER_OFFSET 0x04U /**< Watchdog Counter Register */
|
||||
#define XSCUWDT_CONTROL_OFFSET 0x08U /**< Watchdog Control Register */
|
||||
#define XSCUWDT_ISR_OFFSET 0x0CU /**< Watchdog Interrupt Status Register */
|
||||
#define XSCUWDT_RST_STS_OFFSET 0x10U /**< Watchdog Reset Status Register */
|
||||
#define XSCUWDT_DISABLE_OFFSET 0x14U /**< Watchdog Disable Register */
|
||||
/* @} */
|
||||
|
||||
/** @name Watchdog Control register
|
||||
* This register bits control the prescaler, WD/Timer mode, Intr enable,
|
||||
* auto-reload, watchdog enable.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSCUWDT_CONTROL_PRESCALER_MASK 0x0000FF00U /**< Prescaler */
|
||||
#define XSCUWDT_CONTROL_PRESCALER_SHIFT 8U
|
||||
#define XSCUWDT_CONTROL_WD_MODE_MASK 0x00000008U /**< Watchdog/Timer mode */
|
||||
#define XSCUWDT_CONTROL_IT_ENABLE_MASK 0x00000004U /**< Intr enable (in
|
||||
timer mode) */
|
||||
#define XSCUWDT_CONTROL_AUTO_RELOAD_MASK 0x00000002U /**< Auto-reload (in
|
||||
timer mode) */
|
||||
#define XSCUWDT_CONTROL_WD_ENABLE_MASK 0x00000001U /**< Watchdog enable */
|
||||
/* @} */
|
||||
|
||||
/** @name Interrupt Status register
|
||||
* This register indicates the Counter register has reached zero in Counter
|
||||
* mode.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSCUWDT_ISR_EVENT_FLAG_MASK 0x00000001U /**< Event flag */
|
||||
/*@}*/
|
||||
|
||||
/** @name Reset Status register
|
||||
* This register indicates the Counter register has reached zero in Watchdog
|
||||
* mode and a reset request is sent.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSCUWDT_RST_STS_RESET_FLAG_MASK 0x00000001U /**< Time out occurred */
|
||||
/*@}*/
|
||||
|
||||
/** @name Disable register
|
||||
* This register is used to switch from watchdog mode to timer mode.
|
||||
* The software must write 0x12345678 and 0x87654321 successively to the
|
||||
* Watchdog Disable Register so that the watchdog mode bit in the Watchdog
|
||||
* Control Register is set to zero.
|
||||
* @{
|
||||
*/
|
||||
#define XSCUWDT_DISABLE_VALUE1 0x12345678U /**< Watchdog mode disable
|
||||
value 1 */
|
||||
#define XSCUWDT_DISABLE_VALUE2 0x87654321U /**< Watchdog mode disable
|
||||
value 2 */
|
||||
/*@}*/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Read the given register.
|
||||
*
|
||||
* @param BaseAddr is the base address of the device
|
||||
* @param RegOffset is the register offset to be read
|
||||
*
|
||||
* @return The 32-bit value of the register
|
||||
*
|
||||
* @note C-style signature:
|
||||
* u32 XScuWdt_ReadReg(u32 BaseAddr, u32 RegOffset)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuWdt_ReadReg(BaseAddr, RegOffset) \
|
||||
Xil_In32((BaseAddr) + ((u32)RegOffset))
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Write the given register.
|
||||
*
|
||||
* @param BaseAddr is the base address of the device
|
||||
* @param RegOffset is the register offset to be written
|
||||
* @param Data is the 32-bit value to write to the register
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
* @note C-style signature:
|
||||
* void XScuWdt_WriteReg(u32 BaseAddr, u32 RegOffset, u32 Data)
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define XScuWdt_WriteReg(BaseAddr, RegOffset, Data) \
|
||||
Xil_Out32((BaseAddr) + ((u32)RegOffset), ((u32)Data))
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of protection macro */
|
||||
/** @} */
|
105
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_selftest.c
Normal file
105
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_selftest.c
Normal file
@ -0,0 +1,105 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscuwdt_selftest.c
|
||||
* @addtogroup scuwdt_v2_4
|
||||
* @{
|
||||
*
|
||||
* Contains diagnostic self-test functions for the XScuWdt driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a sdm 01/15/10 First release
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xscuwdt.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Run a self-test on the WDT. This test stops the watchdog, writes a value to
|
||||
* the watchdog load register, starts the watchdog and verifies that the value
|
||||
* read from the counter register is less that the value written to the load
|
||||
* register. It then restores the control register and the watchdog load
|
||||
* register.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XScuWdt instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if self-test was successful.
|
||||
* - XST_FAILURE if the WDT is not decrementing.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XScuWdt_SelfTest(XScuWdt *InstancePtr)
|
||||
{
|
||||
s32 SelfTestStatus;
|
||||
u32 Register;
|
||||
u32 CtrlOrig;
|
||||
u32 LoadOrig;
|
||||
|
||||
/*
|
||||
* Assert to ensure the inputs are valid and the instance has been
|
||||
* initialized.
|
||||
*/
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* Stop the watchdog timer.
|
||||
*/
|
||||
CtrlOrig = XScuWdt_GetControlReg(InstancePtr);
|
||||
XScuWdt_SetControlReg(InstancePtr,
|
||||
CtrlOrig & (~(u32)XSCUWDT_CONTROL_WD_ENABLE_MASK));
|
||||
|
||||
LoadOrig = XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr,
|
||||
XSCUWDT_LOAD_OFFSET);
|
||||
XScuWdt_LoadWdt(InstancePtr, 0xFFFFFFFFU);
|
||||
|
||||
/*
|
||||
* Start the watchdog timer and check if the watchdog counter is
|
||||
* decrementing.
|
||||
*/
|
||||
XScuWdt_SetControlReg(InstancePtr,
|
||||
CtrlOrig | (u32)XSCUWDT_CONTROL_WD_ENABLE_MASK);
|
||||
|
||||
Register = XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr,
|
||||
XSCUWDT_COUNTER_OFFSET);
|
||||
|
||||
XScuWdt_LoadWdt(InstancePtr, LoadOrig);
|
||||
XScuWdt_SetControlReg(InstancePtr, CtrlOrig);
|
||||
|
||||
if (Register == 0xFFFFFFFFU) {
|
||||
SelfTestStatus = (s32)XST_FAILURE;
|
||||
}
|
||||
else {
|
||||
SelfTestStatus = (s32)XST_SUCCESS;
|
||||
}
|
||||
|
||||
return SelfTestStatus;
|
||||
}
|
||||
/** @} */
|
66
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_sinit.c
Normal file
66
bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_sinit.c
Normal file
@ -0,0 +1,66 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xscuwdt_sinit.c
|
||||
* @addtogroup scuwdt_v2_4
|
||||
* @{
|
||||
*
|
||||
* This file contains method for static initialization (compile-time) of the
|
||||
* driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- ---------------------------------------------
|
||||
* 1.00a sdm 01/15/10 First release
|
||||
* 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xscuwdt.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Lookup the device configuration based on the unique device ID. The table
|
||||
* contains the configuration info for each device in the system.
|
||||
*
|
||||
* @param DeviceId is the unique device ID of the device being looked up.
|
||||
*
|
||||
* @return A pointer to the configuration table entry corresponding to the
|
||||
* given device ID, or NULL if no match is found.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
XScuWdt_Config *XScuWdt_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
XScuWdt_Config *CfgPtr = NULL;
|
||||
u32 Index;
|
||||
|
||||
for (Index = 0U; Index < (u32)XPAR_XSCUWDT_NUM_INSTANCES; Index++) {
|
||||
if (XScuWdt_ConfigTable[Index].DeviceId == DeviceId) {
|
||||
CfgPtr = &XScuWdt_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (XScuWdt_Config *)CfgPtr;
|
||||
}
|
||||
/** @} */
|
39
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/Makefile
Normal file
39
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/Makefile
Normal file
@ -0,0 +1,39 @@
|
||||
DRIVER_LIB_VERSION = 1.0
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
CC_FLAGS = $(COMPILER_FLAGS)
|
||||
ECC_FLAGS = $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I$(INCLUDEDIR)
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR), $(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
libs: $(OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
${COMPILER} $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) $< -o $@
|
||||
|
||||
.PHONY: include
|
||||
include: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf $(DEPFILES)
|
548
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.c
Normal file
548
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.c
Normal file
@ -0,0 +1,548 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsdps.c
|
||||
* @addtogroup sdps Overview
|
||||
* @{
|
||||
*
|
||||
* Contains the interface functions of the XSdPs driver.
|
||||
* See xsdps.h for a detailed description of the device and driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00a hk/sg 10/17/13 Initial release
|
||||
* 2.0 hk 12/13/13 Added check for arm to use sleep.h and its API's
|
||||
* 2.1 hk 04/18/14 Add sleep for microblaze designs. CR# 781117.
|
||||
* 2.2 hk 07/28/14 Make changes to enable use of data cache.
|
||||
* 2.3 sk 09/23/14 Send command for relative card address
|
||||
* when re-initialization is done.CR# 819614.
|
||||
* Use XSdPs_Change_ClkFreq API whenever changing
|
||||
* clock.CR# 816586.
|
||||
* 2.4 sk 12/04/14 Added support for micro SD without
|
||||
* WP/CD. CR# 810655.
|
||||
* Checked for DAT Inhibit mask instead of CMD
|
||||
* Inhibit mask in Cmd Transfer API.
|
||||
* Added Support for SD Card v1.0
|
||||
* 2.5 sg 07/09/15 Added SD 3.0 features
|
||||
* kvn 07/15/15 Modified the code according to MISRAC-2012.
|
||||
* 2.6 sk 10/12/15 Added support for SD card v1.0 CR# 840601.
|
||||
* 2.7 sk 11/24/15 Considered the slot type befoe checking CD/WP pins.
|
||||
* sk 12/10/15 Added support for MMC cards.
|
||||
* sk 02/16/16 Corrected the Tuning logic.
|
||||
* sk 03/01/16 Removed Bus Width check for eMMC. CR# 938311.
|
||||
* 2.8 sk 05/03/16 Standard Speed for SD to 19MHz in ZynqMPSoC. CR#951024
|
||||
* 3.0 sk 06/09/16 Added support for mkfs to calculate sector count.
|
||||
* sk 07/16/16 Added support for UHS modes.
|
||||
* sk 07/07/16 Used usleep API for both arm and microblaze.
|
||||
* sk 07/16/16 Added Tap delays accordingly to different SD/eMMC
|
||||
* operating modes.
|
||||
* 3.1 mi 09/07/16 Removed compilation warnings with extra compiler flags.
|
||||
* sk 10/13/16 Reduced the delay during power cycle to 1ms as per spec
|
||||
* sk 10/19/16 Used emmc_hwreset pin to reset eMMC.
|
||||
* sk 11/07/16 Enable Rst_n bit in ext_csd reg if not enabled.
|
||||
* 3.2 sk 11/30/16 Modified the voltage switching sequence as per spec.
|
||||
* sk 02/01/17 Added HSD and DDR mode support for eMMC.
|
||||
* vns 02/09/17 Added ARMA53_32 support for ZynqMP CR#968397
|
||||
* sk 03/20/17 Add support for EL1 non-secure mode.
|
||||
* 3.3 mn 05/17/17 Add support for 64bit DMA addressing
|
||||
* mn 07/17/17 Add support for running SD at 200MHz
|
||||
* mn 07/26/17 Fixed compilation warnings
|
||||
* mn 08/07/17 Modify driver to support 64-bit DMA in arm64 only
|
||||
* mn 08/17/17 Added CCI support for A53 and disabled data cache
|
||||
* operations when it is enabled.
|
||||
* mn 08/22/17 Updated for Word Access System support
|
||||
* mn 09/06/17 Resolved compilation errors with IAR toolchain
|
||||
* mn 09/26/17 Added UHS_MODE_ENABLE macro to enable UHS mode
|
||||
* 3.4 mn 10/17/17 Use different commands for single and multi block
|
||||
* transfers
|
||||
* mn 03/02/18 Move UHS macro check to SD card initialization routine
|
||||
* 3.5 mn 04/18/18 Resolve compilation warnings for sdps driver
|
||||
* 3.6 mn 07/06/18 Fix Cppcheck and Doxygen warnings for sdps driver
|
||||
* mn 08/01/18 Add support for using 64Bit DMA with 32-Bit Processor
|
||||
* mn 08/01/18 Add cache invalidation call before returning from
|
||||
* ReadPolled API
|
||||
* mn 08/14/18 Resolve compilation warnings for ARMCC toolchain
|
||||
* mn 10/01/18 Change Expected Response for CMD3 to R1 for MMC
|
||||
* mus 11/05/18 Support 64 bit DMA addresses for Microblaze-X platform.
|
||||
* 3.7 mn 02/01/19 Add support for idling of SDIO
|
||||
* aru 03/12/19 Modified the code according to MISRAC-2012.
|
||||
* 3.8 mn 04/12/19 Modified TapDelay code for supporting ZynqMP and Versal
|
||||
* mn 09/17/19 Modified ADMA handling API for 32bit and 64bit addresses
|
||||
* 3.9 sd 02/07/20 Added clock support
|
||||
* mn 03/03/20 Restructured the code for more readability and modularity
|
||||
* mn 03/30/20 Return XST_DEVICE_IS_STARTED when host is already started
|
||||
* mn 03/30/20 Move Clock enabling before checking for Host already started
|
||||
* 3.10 mn 06/05/20 Check Transfer completion separately from XSdPs_Read and
|
||||
* XSdPs_Write APIs
|
||||
* mn 06/05/20 Modified code for SD Non-Blocking Read support
|
||||
* 3.14 sk 10/22/21 Add support for Erase feature.
|
||||
* mn 11/28/21 Fix MISRA-C violations.
|
||||
* sk 01/10/22 Add support to read slot_type parameter.
|
||||
* 4.0 sk 02/25/22 Add support for eMMC5.1.
|
||||
* sk 04/07/22 Add support to read custom tap delay values from design
|
||||
* for SD/eMMC.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include "xsdps_core.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* Initializes a specific XSdPs instance such that the driver is ready to use.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
* @param ConfigPtr is a reference to a structure containing information
|
||||
* about a specific SD device. This function initializes an
|
||||
* InstancePtr object for a specific device specified by the
|
||||
* contents of Config.
|
||||
* @param EffectiveAddr is the device base address in the virtual memory
|
||||
* address space. The caller is responsible for keeping the address
|
||||
* mapping from EffectiveAddr to the device physical base address
|
||||
* unchanged once this function is invoked. Unexpected errors may
|
||||
* occur if the address mapping changes after this function is
|
||||
* called. If address translation is not used, use
|
||||
* ConfigPtr->Config.BaseAddress for this device.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_DEVICE_IS_STARTED if the device is already started.
|
||||
* It must be stopped to re-initialize.
|
||||
*
|
||||
* @note This function initializes the host controller.
|
||||
* Initial clock of 400KHz is set.
|
||||
* Voltage of 3.3V is selected as that is supported by host.
|
||||
* Interrupts status is enabled and signal disabled by default.
|
||||
* Default data direction is card to host and
|
||||
* 32 bit ADMA2 is selected. Default Block size is 512 bytes.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_CfgInitialize(XSdPs *InstancePtr, XSdPs_Config *ConfigPtr,
|
||||
u32 EffectiveAddr)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(ConfigPtr != NULL);
|
||||
|
||||
#if defined (XCLOCKING)
|
||||
InstancePtr->Config.RefClk = ConfigPtr->RefClk;
|
||||
Xil_ClockEnable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
/* If this API is getting called twice, return value accordingly */
|
||||
if (InstancePtr->IsReady == XIL_COMPONENT_IS_READY) {
|
||||
Status = (s32)XST_DEVICE_IS_STARTED;
|
||||
goto RETURN_PATH ;
|
||||
}
|
||||
|
||||
/* Set some default values. */
|
||||
InstancePtr->Config.DeviceId = ConfigPtr->DeviceId;
|
||||
InstancePtr->Config.BaseAddress = EffectiveAddr;
|
||||
InstancePtr->Config.InputClockHz = ConfigPtr->InputClockHz;
|
||||
InstancePtr->Config.CardDetect = ConfigPtr->CardDetect;
|
||||
InstancePtr->Config.WriteProtect = ConfigPtr->WriteProtect;
|
||||
InstancePtr->Config.BusWidth = ConfigPtr->BusWidth;
|
||||
InstancePtr->Config.BankNumber = ConfigPtr->BankNumber;
|
||||
InstancePtr->Config.HasEMIO = ConfigPtr->HasEMIO;
|
||||
InstancePtr->Config.SlotType = ConfigPtr->SlotType;
|
||||
InstancePtr->Config.IsCacheCoherent = ConfigPtr->IsCacheCoherent;
|
||||
InstancePtr->Config.ITapDly_SDR_Clk50 = ConfigPtr->ITapDly_SDR_Clk50;
|
||||
InstancePtr->Config.OTapDly_SDR_Clk50 = ConfigPtr->OTapDly_SDR_Clk50;
|
||||
InstancePtr->Config.ITapDly_DDR_Clk50 = ConfigPtr->ITapDly_DDR_Clk50;
|
||||
InstancePtr->Config.OTapDly_DDR_Clk50 = ConfigPtr->OTapDly_DDR_Clk50;
|
||||
InstancePtr->Config.OTapDly_SDR_Clk100 = ConfigPtr->OTapDly_SDR_Clk100;
|
||||
InstancePtr->Config.OTapDly_SDR_Clk200 = ConfigPtr->OTapDly_SDR_Clk200;
|
||||
InstancePtr->SectorCount = 0U;
|
||||
InstancePtr->Mode = XSDPS_DEFAULT_SPEED_MODE;
|
||||
InstancePtr->OTapDelay = 0U;
|
||||
InstancePtr->ITapDelay = 0U;
|
||||
InstancePtr->Dma64BitAddr = 0U;
|
||||
InstancePtr->SlcrBaseAddr = XPS_SYS_CTRL_BASEADDR;
|
||||
InstancePtr->IsBusy = FALSE;
|
||||
InstancePtr->BlkSize = 0U;
|
||||
InstancePtr->IsTuningDone = 0U;
|
||||
|
||||
/* Host Controller version is read. */
|
||||
InstancePtr->HC_Version =
|
||||
(u8)(XSdPs_ReadReg16(InstancePtr->Config.BaseAddress,
|
||||
XSDPS_HOST_CTRL_VER_OFFSET) & XSDPS_HC_SPEC_VER_MASK);
|
||||
|
||||
/*
|
||||
* Read capabilities register and update it in Instance pointer.
|
||||
* It is sufficient to read this once on power on.
|
||||
*/
|
||||
InstancePtr->Host_Caps = XSdPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XSDPS_CAPS_OFFSET);
|
||||
|
||||
/* Reset the SD bus lines */
|
||||
Status = XSdPs_ResetConfig(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH ;
|
||||
}
|
||||
|
||||
/* Configure the SD Host Controller */
|
||||
XSdPs_HostConfig(InstancePtr);
|
||||
|
||||
InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
|
||||
|
||||
RETURN_PATH:
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockDisable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* Initialize Card with Identification mode sequence
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if initialization was successful
|
||||
* - XST_FAILURE if failure - could be because
|
||||
* a) SD is already initialized
|
||||
* b) There is no card inserted
|
||||
* c) One of the steps (commands) in the
|
||||
* initialization cycle failed
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_CardInitialize(XSdPs *InstancePtr)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/* Default settings */
|
||||
InstancePtr->BusWidth = XSDPS_1_BIT_WIDTH;
|
||||
InstancePtr->CardType = XSDPS_CARD_SD;
|
||||
InstancePtr->Switch1v8 = 0U;
|
||||
InstancePtr->BusSpeed = XSDPS_CLK_400_KHZ;
|
||||
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockEnable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
|
||||
/* Change the clock frequency to 400 KHz */
|
||||
Status = XSdPs_Change_ClkFreq(InstancePtr, InstancePtr->BusSpeed);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH ;
|
||||
}
|
||||
|
||||
/* Identify the Card whether it is SD, MMC or eMMC */
|
||||
Status = XSdPs_IdentifyCard(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Initialize the identified card */
|
||||
if (InstancePtr->CardType == XSDPS_CARD_SD) {
|
||||
Status = XSdPs_SdCardInitialize(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
} else {
|
||||
Status = XSdPs_MmcCardInitialize(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_PATH:
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockDisable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief
|
||||
* This function performs SD read in polled mode.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param Arg is the address passed by the user that is to be sent as
|
||||
* argument along with the command.
|
||||
* @param BlkCnt - Block count passed by the user.
|
||||
* @param Buff - Pointer to the data buffer for a DMA transfer.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if initialization was successful
|
||||
* - XST_FAILURE if failure - could be because another transfer
|
||||
* is in progress or command or data inhibit is set
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_ReadPolled(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
if (InstancePtr->IsBusy == TRUE) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockEnable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
|
||||
/* Setup the Read Transfer */
|
||||
Status = XSdPs_SetupTransfer(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Read from the card */
|
||||
Status = XSdPs_Read(InstancePtr, Arg, BlkCnt, Buff);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Check for transfer done */
|
||||
Status = XSdps_CheckTransferDone(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
if (InstancePtr->Config.IsCacheCoherent == 0U) {
|
||||
Xil_DCacheInvalidateRange((INTPTR)Buff,
|
||||
((INTPTR)BlkCnt * (INTPTR)InstancePtr->BlkSize));
|
||||
}
|
||||
|
||||
RETURN_PATH:
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockDisable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief
|
||||
* This function performs SD write in polled mode.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param Arg is the address passed by the user that is to be sent as
|
||||
* argument along with the command.
|
||||
* @param BlkCnt - Block count passed by the user.
|
||||
* @param Buff - Pointer to the data buffer for a DMA transfer.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if initialization was successful
|
||||
* - XST_FAILURE if failure - could be because another transfer
|
||||
* is in progress or command or data inhibit is set
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_WritePolled(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
if (InstancePtr->IsBusy == TRUE) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockEnable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
|
||||
/* Setup the Write Transfer */
|
||||
Status = XSdPs_SetupTransfer(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Write to the card */
|
||||
Status = XSdPs_Write(InstancePtr, Arg, BlkCnt, Buff);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Check for transfer done */
|
||||
Status = XSdps_CheckTransferDone(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
RETURN_PATH:
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockDisable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* API to idle the SDIO Interface
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Idle(XSdPs *InstancePtr)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockEnable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
|
||||
/* Check if the bus is idle */
|
||||
Status = XSdPs_CheckBusIdle(InstancePtr, XSDPS_PSR_INHIBIT_CMD_MASK
|
||||
| XSDPS_PSR_INHIBIT_DAT_MASK
|
||||
| XSDPS_PSR_DAT_ACTIVE_MASK);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH ;
|
||||
}
|
||||
|
||||
/* Disable the Bus Power */
|
||||
XSdPs_DisableBusPower(InstancePtr);
|
||||
|
||||
/* Reset Command and Data Lines */
|
||||
Status = XSdPs_Reset(InstancePtr, XSDPS_SWRST_ALL_MASK);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH ;
|
||||
}
|
||||
|
||||
Status = XST_SUCCESS;
|
||||
|
||||
RETURN_PATH:
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockDisable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
return Status;
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief
|
||||
* This function performs Erase operation on the given address range.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param StartAddr is the address of the first write block to be erased.
|
||||
* @param EndAddr is the address of the last write block of the continuous
|
||||
* range to be erased.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if erase is successful
|
||||
* - XST_FAILURE if failure - could be because another transfer
|
||||
* is in progress or card not present or erase operation failure.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Erase(XSdPs *InstancePtr, u32 StartAddr, u32 EndAddr)
|
||||
{
|
||||
s32 Status;
|
||||
u16 CardCC;
|
||||
u32 PresentStateReg;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockEnable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
|
||||
if (InstancePtr->IsBusy == TRUE) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
if ((InstancePtr->HC_Version != XSDPS_HC_SPEC_V3) ||
|
||||
((InstancePtr->Host_Caps & XSDPS_CAPS_SLOT_TYPE_MASK)
|
||||
!= XSDPS_CAPS_EMB_SLOT)) {
|
||||
if(InstancePtr->Config.CardDetect != 0U) {
|
||||
/* Check status to ensure card is present */
|
||||
PresentStateReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress,
|
||||
XSDPS_PRES_STATE_OFFSET);
|
||||
if ((PresentStateReg & XSDPS_PSR_CARD_INSRT_MASK) == 0x0U) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for CCC */
|
||||
CardCC = (u16)((InstancePtr->CardSpecData[2] & CSD_CCC_MASK) >> CSD_CCC_SHIFT);
|
||||
if ((CardCC & CSD_CCC_CLASS5_MASK) == 0U) {
|
||||
Status = XST_SUCCESS;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
InstancePtr->TransferMode = XSDPS_TM_DAT_DIR_SEL_MASK;
|
||||
|
||||
Status = XSdPs_SetStartAddr(InstancePtr, StartAddr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
Status = XSdPs_SetEndAddr(InstancePtr, EndAddr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
Status = XSdPs_SendErase(InstancePtr);
|
||||
|
||||
RETURN_PATH:
|
||||
#if defined (XCLOCKING)
|
||||
Xil_ClockDisable(InstancePtr->Config.RefClk);
|
||||
#endif
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/** @} */
|
389
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.h
Normal file
389
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.h
Normal file
@ -0,0 +1,389 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsdps.h
|
||||
* @addtogroup sdps Overview
|
||||
* @{
|
||||
* @details
|
||||
*
|
||||
* This section explains the implementation of the XSdPs driver.
|
||||
* See xsdps.h for a detailed description of the device and driver.
|
||||
*
|
||||
* This driver is used initialize read from and write to the SD card.
|
||||
* Features such as switching bus width to 4-bit and switching to high speed,
|
||||
* changing clock frequency, block size etc. are supported.
|
||||
* SD 2.0 uses 1/4 bus width and speeds of 25/50KHz. Initialization, however
|
||||
* is done using 1-bit bus width and 400KHz clock frequency.
|
||||
* SD commands are classified as broadcast and addressed. Commands can be
|
||||
* those with response only (using only command line) or
|
||||
* response + data (using command and data lines).
|
||||
* Only one command can be sent at a time. During a data transfer however,
|
||||
* when dsta lines are in use, certain commands (which use only the command
|
||||
* line) can be sent, most often to obtain status.
|
||||
* This driver does not support multi card slots at present.
|
||||
*
|
||||
* <b>Initialization & Configuration</b>
|
||||
*
|
||||
* This includes initialization on the host controller side to select
|
||||
* clock frequency, bus power and default transfer related parameters.
|
||||
* The default voltage is 3.3V.
|
||||
* On the SD card side, the initialization and identification state diagram is
|
||||
* implemented. This resets the card, gives it a unique address/ID and
|
||||
* identifies key card related specifications.
|
||||
*
|
||||
* <b>Data transfer</b>
|
||||
*
|
||||
* The SD card is put in transfer state to read from or write to it.
|
||||
* The default block size is 512 bytes and if supported,
|
||||
* default bus width is 4-bit and bus speed is High speed.
|
||||
* The read and write functions are implemented in polled mode using ADMA2.
|
||||
*
|
||||
* At any point, when key parameters such as block size or
|
||||
* clock/speed or bus width are modified, this driver takes care of
|
||||
* maintaining the same selection on host and card.
|
||||
* All error bits in host controller are monitored by the driver and in the
|
||||
* event one of them is set, driver will clear the interrupt status and
|
||||
* communicate failure to the upper layer.
|
||||
*
|
||||
* <b>File system use</b>
|
||||
*
|
||||
* This driver can be used with xilffs library to read and write files to SD.
|
||||
* (Please refer to procedure in diskio.c). The file system read/write example
|
||||
* in polled mode can used for reference.
|
||||
*
|
||||
* There is no example for using SD driver without file system at present.
|
||||
* However, the driver can be used without the file system. The glue layer
|
||||
* in filesystem can be used as reference for the same. The block count
|
||||
* passed to the read/write function in one call is limited by the ADMA2
|
||||
* descriptor table and hence care will have to be taken to call read/write
|
||||
* API's in a loop for large file sizes.
|
||||
*
|
||||
* Interrupt mode is not supported because it offers no improvement when used
|
||||
* with file system.
|
||||
*
|
||||
* <b>eMMC support</b>
|
||||
*
|
||||
* SD driver supports SD and eMMC based on the "enable MMC" parameter in SDK.
|
||||
* The features of eMMC supported by the driver will depend on those supported
|
||||
* by the host controller. The current driver supports read/write on eMMC card
|
||||
* using 4-bit and high speed mode currently.
|
||||
*
|
||||
* Features not supported include - card write protect, password setting,
|
||||
* lock/unlock, interrupts, SDMA mode, programmed I/O mode and
|
||||
* 64-bit addressed ADMA2, erase/pre-erase commands.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00a hk/sg 10/17/13 Initial release
|
||||
* 2.0 hk 03/07/14 Version number revised.
|
||||
* 2.1 hk 04/18/14 Increase sleep for eMMC switch command.
|
||||
* Add sleep for microblaze designs. CR# 781117.
|
||||
* 2.2 hk 07/28/14 Make changes to enable use of data cache.
|
||||
* 2.3 sk 09/23/14 Send command for relative card address
|
||||
* when re-initialization is done.CR# 819614.
|
||||
* Use XSdPs_Change_ClkFreq API whenever changing
|
||||
* clock.CR# 816586.
|
||||
* 2.4 sk 12/04/14 Added support for micro SD without
|
||||
* WP/CD. CR# 810655.
|
||||
* Checked for DAT Inhibit mask instead of CMD
|
||||
* Inhibit mask in Cmd Transfer API.
|
||||
* Added Support for SD Card v1.0
|
||||
* 2.5 sg 07/09/15 Added SD 3.0 features
|
||||
* kvn 07/15/15 Modified the code according to MISRAC-2012.
|
||||
* 2.6 sk 10/12/15 Added support for SD card v1.0 CR# 840601.
|
||||
* 2.7 sk 11/24/15 Considered the slot type befoe checking CD/WP pins.
|
||||
* sk 12/10/15 Added support for MMC cards.
|
||||
* 01/08/16 Added workaround for issue in auto tuning mode
|
||||
* of SDR50, SDR104 and HS200.
|
||||
* sk 02/16/16 Corrected the Tuning logic.
|
||||
* sk 03/01/16 Removed Bus Width check for eMMC. CR# 938311.
|
||||
* 2.8 sk 04/20/16 Added new workaround for auto tuning.
|
||||
* 05/03/16 Standard Speed for SD to 19MHz in ZynqMPSoC. CR#951024
|
||||
* 3.0 sk 06/09/16 Added support for mkfs to calculate sector count.
|
||||
* sk 07/16/16 Added support for UHS modes.
|
||||
* sk 07/07/16 Used usleep API for both arm and microblaze.
|
||||
* sk 07/16/16 Added Tap delays accordingly to different SD/eMMC
|
||||
* operating modes.
|
||||
* sk 08/13/16 Removed sleep.h from xsdps.h as a temporary fix for
|
||||
* CR#956899.
|
||||
* 3.1 mi 09/07/16 Removed compilation warnings with extra compiler flags.
|
||||
* sk 10/13/16 Reduced the delay during power cycle to 1ms as per spec
|
||||
* sk 10/19/16 Used emmc_hwreset pin to reset eMMC.
|
||||
* sk 11/07/16 Enable Rst_n bit in ext_csd reg if not enabled.
|
||||
* sk 11/16/16 Issue DLL reset at 31 iteration to load new zero value.
|
||||
* 3.2 sk 11/30/16 Modified the voltage switching sequence as per spec.
|
||||
* sk 02/01/17 Added HSD and DDR mode support for eMMC.
|
||||
* sk 02/01/17 Consider bus width parameter from design for switching
|
||||
* vns 02/09/17 Added ARMA53_32 support for ZynqMP CR#968397
|
||||
* sk 03/20/17 Add support for EL1 non-secure mode.
|
||||
* 3.3 mn 05/17/17 Add support for 64bit DMA addressing
|
||||
* mn 08/07/17 Modify driver to support 64-bit DMA in arm64 only
|
||||
* mn 08/17/17 Enabled CCI support for A53 by adding cache coherency
|
||||
* information.
|
||||
* mn 09/06/17 Resolved compilation errors with IAR toolchain
|
||||
* 3.6 mn 08/01/18 Add support for using 64Bit DMA with 32-Bit Processor
|
||||
* 3.7 mn 02/01/19 Add support for idling of SDIO
|
||||
* 3.8 mn 04/12/19 Modified TapDelay code for supporting ZynqMP and Versal
|
||||
* mn 09/17/19 Modified ADMA handling API for 32bit and 64bit addresses
|
||||
* 3.9 mn 03/03/20 Restructured the code for more readability and modularity
|
||||
* mn 03/16/20 Move XSdPs_Select_Card API to User APIs
|
||||
* 3.10 mn 06/05/20 Check Transfer completion separately from XSdPs_Read and
|
||||
* XSdPs_Write APIs
|
||||
* mn 06/05/20 Modified code for SD Non-Blocking Read support
|
||||
* 3.11 sk 12/01/20 Tap programming sequence updates like disable OTAPEN
|
||||
* always, write zero to tap register for zero tap value.
|
||||
* sk 12/07/20 Fix eMMC DDR52 mode write/read issue.
|
||||
* sk 12/17/20 Removed checking platform specific SD macros and used
|
||||
* Baseaddress instead.
|
||||
* 3.12 sk 01/28/21 Added support for non-blocking write.
|
||||
* sk 02/12/21 Fix the issue in reading CID and CSD.
|
||||
* sk 04/08/21 Fixed doxygen warnings in all source files.
|
||||
* sk 05/25/21 Fix the compilation issue in Cortex-A72 + EL1_NS by
|
||||
* removing the DLL reset logic (Dead code for Versal).
|
||||
* 3.13 sk 08/10/21 Limit the SD operating frequency to 19MHz for Versal.
|
||||
* 3.14 sk 10/22/21 Add support for Erase feature.
|
||||
* sk 11/29/21 Fix compilation warnings reported with "-Wundef" flag.
|
||||
* sk 01/10/22 Add support to read slot_type parameter.
|
||||
* 4.0 sk 02/25/22 Add support for eMMC5.1.
|
||||
* sk 04/07/22 Add support to read custom tap delay values from design
|
||||
* for SD/eMMC.
|
||||
* sk 06/03/22 Fix issue in internal clock divider calculation logic.
|
||||
* 4.1 sk 11/10/22 Add SD/eMMC Tap delay support for Versal Net.
|
||||
* 4.1 sa 01/03/23 Report error if Transfer size is greater than 2MB.
|
||||
* 4.1 sa 12/19/22 Enable eMMC HS400 mode for Versal Net.
|
||||
* sa 01/25/23 Use instance structure to store DMA descriptor tables.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef SDPS_H_
|
||||
#define SDPS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "xil_printf.h"
|
||||
#include "xil_cache.h"
|
||||
#include "xstatus.h"
|
||||
#include "xsdps_hw.h"
|
||||
#include "xplatform_info.h"
|
||||
#include "sleep.h"
|
||||
#include <string.h>
|
||||
#if defined (XCLOCKING)
|
||||
#include "xil_clocking.h"
|
||||
#endif
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
#define XSDPS_CT_ERROR 0x2L /**< Command timeout flag */
|
||||
#define MAX_TUNING_COUNT 40U /**< Maximum Tuning count */
|
||||
#define MAX_TIMEOUT 0x1FFFFFFFU /**< Maximum Timeout */
|
||||
#define XSDPS_CMD8_VOL_PATTERN 0x1AAU /**< CMD8 voltage pattern */
|
||||
#define XSDPS_RESPOCR_READY 0x80000000U /**< Ready response */
|
||||
#define XSDPS_ACMD41_HCS 0x40000000U /**< High Capacity Support */
|
||||
#define XSDPS_ACMD41_3V3 0x00300000U /**< 3.3 voltage support */
|
||||
#define XSDPS_CMD1_HIGH_VOL 0x00FF8000U /**< CMD1 for High voltage */
|
||||
#define XSDPS_CMD1_DUAL_VOL 0x00FF8010U /**< CMD1 for Dual voltage */
|
||||
#define HIGH_SPEED_SUPPORT 0x2U /**< High Speed support */
|
||||
#define UHS_SDR12_SUPPORT 0x1U /**< SDR12 support */
|
||||
#define UHS_SDR25_SUPPORT 0x2U /**< SDR25 support */
|
||||
#define UHS_SDR50_SUPPORT 0x4U /**< SDR50 support */
|
||||
#define UHS_SDR104_SUPPORT 0x8U /**< SDR104 support */
|
||||
#define UHS_DDR50_SUPPORT 0x10U /**< DDR50 support */
|
||||
#define WIDTH_4_BIT_SUPPORT 0x4U /**< 4-bit width support */
|
||||
#define SD_CLK_25_MHZ 25000000U /**< 25MHz clock */
|
||||
#define SD_CLK_19_MHZ 19000000U /**< 19MHz clock */
|
||||
#define SD_CLK_26_MHZ 26000000U /**< 26MHz clock */
|
||||
#define EXT_CSD_DEVICE_TYPE_BYTE 196U /**< CSD Device Type byte number */
|
||||
#define EXT_CSD_SEC_COUNT_BYTE1 212U /**< CSD Sector count byte 1 */
|
||||
#define EXT_CSD_SEC_COUNT_BYTE2 213U /**< CSD Sector count byte 2 */
|
||||
#define EXT_CSD_SEC_COUNT_BYTE3 214U /**< CSD Sector count byte 3 */
|
||||
#define EXT_CSD_SEC_COUNT_BYTE4 215U /**< CSD Sector count byte 4 */
|
||||
#define EXT_CSD_DEVICE_TYPE_HIGH_SPEED 0x2U /**< CSD Device type HS */
|
||||
#define EXT_CSD_DEVICE_TYPE_DDR_1V8_HIGH_SPEED 0x4U /**< CSD Dev type DDR 1.8v speed */
|
||||
#define EXT_CSD_DEVICE_TYPE_DDR_1V2_HIGH_SPEED 0x8U /**< CSD Dev type DDR 1.2v speed */
|
||||
#define EXT_CSD_DEVICE_TYPE_SDR_1V8_HS200 0x10U /**< CSD SDR 1.8v HS200 */
|
||||
#define EXT_CSD_DEVICE_TYPE_SDR_1V2_HS200 0x20U /**< CSD SDR 1.2v HS200 */
|
||||
#define EXT_CSD_DEVICE_TYPE_DDR_1V8_HS400 0x40U /**< CSD SDR 1.8v HS400 */
|
||||
#define EXT_CSD_DEVICE_TYPE_DDR_1V2_HS400 0x80U /**< CSD SDR 1.2v HS400 */
|
||||
#define CSD_SPEC_VER_3 0x3U /**< CSD card spec ver 3 */
|
||||
#define SCR_SPEC_VER_3 0x80U /**< SCR spec ver 3 */
|
||||
#define ADDRESS_BEYOND_32BIT 0x100000000U /**< Macro used for beyond 32-bit addr */
|
||||
|
||||
#define XSDPS_ZYNQMP_SD0_BASE 0xFF160000U /**< ZynqMP SD0 Baseaddress */
|
||||
#define XSDPS_ZYNQMP_SD1_BASE 0xFF170000U /**< ZynqMP SD1 Baseaddress */
|
||||
#define XSDPS_VERSAL_SD0_BASE 0xF1040000U /**< Versal SD0 Baseaddress */
|
||||
#define XSDPS_VERSAL_SD1_BASE 0xF1050000U /**< Versal SD1 Baseaddress */
|
||||
|
||||
/** @name Block size mask for 512 bytes
|
||||
*
|
||||
* Block size mask for 512 bytes - This is the default block size.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define XSDPS_BLK_SIZE_512_MASK 0x200U /**< Blk Size 512 */
|
||||
|
||||
/** @} */
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/**
|
||||
* This typedef contains configuration information for the device.
|
||||
*/
|
||||
typedef struct {
|
||||
u16 DeviceId; /**< Unique ID of device */
|
||||
u32 BaseAddress; /**< Base address of the device */
|
||||
u32 InputClockHz; /**< Input clock frequency */
|
||||
u32 CardDetect; /**< Card Detect */
|
||||
u32 WriteProtect; /**< Write Protect */
|
||||
u32 BusWidth; /**< Bus Width */
|
||||
u32 BankNumber; /**< MIO Bank selection for SD */
|
||||
u32 HasEMIO; /**< If SD is connected to EMIO */
|
||||
u8 SlotType; /**< Slot type */
|
||||
u8 IsCacheCoherent; /**< If SD is Cache Coherent or not */
|
||||
#if defined (XCLOCKING)
|
||||
u32 RefClk; /**< Input clocks */
|
||||
#endif
|
||||
u32 ITapDly_SDR_Clk50; /**< Input Tap delay for HSD/SDR25 modes */
|
||||
u32 OTapDly_SDR_Clk50; /**< Output Tap delay for HSD/SDR25 modes */
|
||||
u32 ITapDly_DDR_Clk50; /**< Input Tap delay for DDR50 modes */
|
||||
u32 OTapDly_DDR_Clk50; /**< Output Tap delay for DDR50 modes */
|
||||
u32 OTapDly_SDR_Clk100; /**< Input Tap delay for SDR50 modes */
|
||||
u32 OTapDly_SDR_Clk200; /**< Input Tap delay for SDR104/HS200 modes */
|
||||
} XSdPs_Config;
|
||||
|
||||
/**
|
||||
* ADMA2 32-Bit descriptor table
|
||||
*/
|
||||
typedef struct {
|
||||
u16 Attribute; /**< Attributes of descriptor */
|
||||
u16 Length; /**< Length of current dma transfer */
|
||||
u32 Address; /**< Address of current dma transfer */
|
||||
#ifdef __ICCARM__
|
||||
#pragma data_alignment = 32
|
||||
} XSdPs_Adma2Descriptor32;
|
||||
#else
|
||||
} __attribute__((__packed__))XSdPs_Adma2Descriptor32;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ADMA2 64-Bit descriptor table
|
||||
*/
|
||||
typedef struct {
|
||||
u16 Attribute; /**< Attributes of descriptor */
|
||||
u16 Length; /**< Length of current dma transfer */
|
||||
u64 Address; /**< Address of current dma transfer */
|
||||
#ifdef __ICCARM__
|
||||
#pragma data_alignment = 32
|
||||
} XSdPs_Adma2Descriptor64;
|
||||
#else
|
||||
} __attribute__((__packed__))XSdPs_Adma2Descriptor64;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The XSdPs driver instance data. The user is required to allocate a
|
||||
* variable of this type for every SD device in the system. A pointer
|
||||
* to a variable of this type is then passed to the driver API functions.
|
||||
*/
|
||||
typedef struct {
|
||||
XSdPs_Config Config; /**< Configuration structure */
|
||||
u32 IsReady; /**< Device is initialized and ready */
|
||||
u32 Host_Caps; /**< Capabilities of host controller */
|
||||
u32 Host_CapsExt; /**< Extended Capabilities */
|
||||
u32 HCS; /**< High capacity support in card */
|
||||
u8 CardType; /**< Type of card - SD/MMC/eMMC */
|
||||
u8 Card_Version; /**< Card version */
|
||||
u8 HC_Version; /**< Host controller version */
|
||||
u8 BusWidth; /**< Current operating bus width */
|
||||
u32 BusSpeed; /**< Current operating bus speed */
|
||||
u8 Switch1v8; /**< 1.8V Switch support */
|
||||
u32 CardID[4]; /**< Card ID Register */
|
||||
u32 RelCardAddr; /**< Relative Card Address */
|
||||
u32 CardSpecData[4]; /**< Card Specific Data Register */
|
||||
u32 SectorCount; /**< Sector Count */
|
||||
u32 SdCardConfig; /**< Sd Card Configuration Register */
|
||||
u32 Mode; /**< Bus Speed Mode */
|
||||
u32 OTapDelay; /**< Output Tap Delay */
|
||||
u32 ITapDelay; /**< Input Tap Delay */
|
||||
u64 Dma64BitAddr; /**< 64 Bit DMA Address */
|
||||
u16 TransferMode; /**< Transfer Mode */
|
||||
u32 SlcrBaseAddr; /**< SLCR base address*/
|
||||
u8 IsBusy; /**< Busy Flag*/
|
||||
u32 BlkSize; /**< Block Size*/
|
||||
u8 IsTuningDone; /**< Flag to indicate HS200 tuning complete */
|
||||
#ifdef __ICCARM__
|
||||
#pragma data_alignment = 32
|
||||
XSdPs_Adma2Descriptor32 Adma2_DescrTbl32[32];
|
||||
XSdPs_Adma2Descriptor64 Adma2_DescrTbl64[32];
|
||||
#else
|
||||
XSdPs_Adma2Descriptor32 Adma2_DescrTbl32[32] __attribute__ ((aligned(32)));
|
||||
XSdPs_Adma2Descriptor64 Adma2_DescrTbl64[32] __attribute__ ((aligned(32)));
|
||||
#endif
|
||||
} XSdPs;
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/**
|
||||
* @name SD High Speed mode configuration options
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* User configuration option to enable or disable SD HS mode.
|
||||
* By default SD HS mode is disabled for Versal and enabled for
|
||||
* other platforms.
|
||||
*/
|
||||
#ifdef versal
|
||||
#define SD_HS_MODE_ENABLE 0
|
||||
#else
|
||||
#define SD_HS_MODE_ENABLE 1
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Enable eMMC HS400 mode for Versal Net platform
|
||||
*/
|
||||
#define ENABLE_HS400_MODE
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
XSdPs_Config *XSdPs_LookupConfig(u16 DeviceId);
|
||||
s32 XSdPs_CfgInitialize(XSdPs *InstancePtr, XSdPs_Config *ConfigPtr,
|
||||
u32 EffectiveAddr);
|
||||
s32 XSdPs_CardInitialize(XSdPs *InstancePtr);
|
||||
s32 XSdPs_ReadPolled(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff);
|
||||
s32 XSdPs_WritePolled(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff);
|
||||
s32 XSdPs_Idle(XSdPs *InstancePtr);
|
||||
|
||||
s32 XSdPs_Change_BusSpeed(XSdPs *InstancePtr);
|
||||
s32 XSdPs_Change_ClkFreq(XSdPs *InstancePtr, u32 SelFreq);
|
||||
s32 XSdPs_Pullup(XSdPs *InstancePtr);
|
||||
s32 XSdPs_Get_BusWidth(XSdPs *InstancePtr, u8 *ReadBuff);
|
||||
s32 XSdPs_Change_BusWidth(XSdPs *InstancePtr);
|
||||
s32 XSdPs_Get_BusSpeed(XSdPs *InstancePtr, u8 *ReadBuff);
|
||||
s32 XSdPs_Get_Mmc_ExtCsd(XSdPs *InstancePtr, u8 *ReadBuff);
|
||||
s32 XSdPs_Set_Mmc_ExtCsd(XSdPs *InstancePtr, u32 Arg);
|
||||
s32 XSdPs_SetBlkSize(XSdPs *InstancePtr, u16 BlkSize);
|
||||
s32 XSdPs_Get_Status(XSdPs *InstancePtr, u8 *SdStatReg);
|
||||
s32 XSdPs_Select_Card(XSdPs *InstancePtr);
|
||||
s32 XSdPs_StartReadTransfer(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff);
|
||||
s32 XSdPs_CheckReadTransfer(XSdPs *InstancePtr);
|
||||
s32 XSdPs_StartWriteTransfer(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff);
|
||||
s32 XSdPs_CheckWriteTransfer(XSdPs *InstancePtr);
|
||||
s32 XSdPs_Erase(XSdPs *InstancePtr, u32 StartAddr, u32 EndAddr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SD_H_ */
|
||||
/** @} */
|
1782
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_card.c
Normal file
1782
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_card.c
Normal file
File diff suppressed because it is too large
Load Diff
127
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_core.h
Normal file
127
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_core.h
Normal file
@ -0,0 +1,127 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsdps_core.h
|
||||
* @addtogroup sdps Overview
|
||||
* @{
|
||||
*
|
||||
* The xsdps_core.h header file contains the identifiers and basic HW access driver
|
||||
* functions (or macros) that can be used to access the device. Other driver
|
||||
* functions are defined in xsdps.h.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 3.9 mn 03/03/20 Restructured the code for more readability and modularity
|
||||
* mn 03/16/20 Move XSdPs_Select_Card API to User APIs
|
||||
* 3.12 sk 01/28/21 Added support for non-blocking write.
|
||||
* 3.14 sk 10/22/21 Add support for Erase feature.
|
||||
* mn 11/28/21 Fix MISRA-C violations.
|
||||
* 4.0 sk 02/25/22 Add support for eMMC5.1.
|
||||
* 4.1 sa 01/06/23 Include xil_util.h in this file.
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/** @cond INTERNAL */
|
||||
#ifndef SDPS_INCLUDE_H_
|
||||
#define SDPS_INCLUDE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "xsdps.h"
|
||||
#if defined (__aarch64__)
|
||||
#include "xil_smc.h"
|
||||
#endif
|
||||
|
||||
#include "xil_util.h"
|
||||
|
||||
s32 XSdPs_SdCardInitialize(XSdPs *InstancePtr);
|
||||
s32 XSdPs_MmcCardInitialize(XSdPs *InstancePtr);
|
||||
s32 XSdPs_IdentifyCard(XSdPs *InstancePtr);
|
||||
s32 XSdPs_CmdTransfer(XSdPs *InstancePtr, u32 Cmd, u32 Arg, u32 BlkCnt);
|
||||
s32 XSdPs_SetupTransfer(XSdPs *InstancePtr);
|
||||
s32 XSdPs_Read(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff);
|
||||
s32 XSdPs_Write(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff);
|
||||
s32 XSdPs_CheckTransferComplete(XSdPs *InstancePtr);
|
||||
void XSdPs_Identify_UhsMode(XSdPs *InstancePtr, u8 *ReadBuff);
|
||||
s32 XSdPs_DllReset(XSdPs *InstancePtr);
|
||||
s32 XSdPs_Switch_Voltage(XSdPs *InstancePtr);
|
||||
void XSdPs_SetupADMA2DescTbl64Bit(XSdPs *InstancePtr, u32 BlkCnt);
|
||||
void XSdPs_SetupADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff);
|
||||
void XSdPs_DllRstCtrl(XSdPs *InstancePtr, u8 EnRst);
|
||||
void XSdPs_ConfigTapDelay(XSdPs *InstancePtr);
|
||||
s32 XSdPs_Execute_Tuning(XSdPs *InstancePtr);
|
||||
void XSdPs_Setup32ADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff);
|
||||
void XSdPs_Setup64ADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff);
|
||||
u32 XSdPs_FrameCmd(XSdPs *InstancePtr, u32 Cmd);
|
||||
void XSdPs_SetTapDelay(XSdPs *InstancePtr);
|
||||
s32 XSdPs_CheckResetDone(XSdPs *InstancePtr, u8 Value);
|
||||
s32 XSdPs_CheckVoltage18(XSdPs *InstancePtr);
|
||||
s32 XSdPs_SetupCmd(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt);
|
||||
void XSdPs_SetExecTuning(XSdPs *InstancePtr);
|
||||
s32 XSdPs_CheckCardDetect(XSdPs *InstancePtr);
|
||||
s32 XSdPs_CardReset(XSdPs *InstancePtr);
|
||||
s32 XSdPs_CardIfCond(XSdPs *InstancePtr);
|
||||
s32 XSdPs_CardOpCond(XSdPs *InstancePtr);
|
||||
s32 XSdPs_GetCardId(XSdPs *InstancePtr);
|
||||
s32 XSdPs_GetCsd(XSdPs *InstancePtr);
|
||||
s32 XSdPs_CardSetVoltage18(XSdPs *InstancePtr);
|
||||
s32 XSdPs_SdModeInit(XSdPs *InstancePtr);
|
||||
s32 XSdPs_SdCardEnum(XSdPs *InstancePtr);
|
||||
s32 XSdPs_MmcCardEnum(XSdPs *InstancePtr);
|
||||
s32 XSdPs_MmcModeInit(XSdPs *InstancePtr);
|
||||
s32 XSdPs_EmmcModeInit(XSdPs *InstancePtr);
|
||||
s32 XSdPs_ResetConfig(XSdPs *InstancePtr);
|
||||
void XSdPs_HostConfig(XSdPs *InstancePtr);
|
||||
s32 XSdPs_Reset(XSdPs *InstancePtr, u8 Value);
|
||||
void XSdPs_DisableBusPower(XSdPs *InstancePtr);
|
||||
void XSdPs_EnableBusPower(XSdPs *InstancePtr);
|
||||
s32 XSdPs_CheckBusIdle(XSdPs *InstancePtr, u32 Value);
|
||||
s32 XSdPs_CheckBusHigh(XSdPs *InstancePtr);
|
||||
s32 XSdPs_SetupVoltageSwitch(XSdPs *InstancePtr);
|
||||
s32 XSdPs_AutoTuning(XSdPs *InstancePtr);
|
||||
s32 XSdPs_SetClock(XSdPs *InstancePtr, u32 SelFreq);
|
||||
u32 XSdPs_CalcClock(XSdPs *InstancePtr, u32 SelFreq);
|
||||
s32 XSdPs_EnableClock(XSdPs *InstancePtr, u16 ClockReg);
|
||||
s32 XSdps_CheckTransferDone(XSdPs *InstancePtr);
|
||||
s32 XSdPs_Change_SdBusSpeed(XSdPs *InstancePtr);
|
||||
s32 XSdPs_Change_MmcBusSpeed(XSdPs *InstancePtr);
|
||||
s32 XSdPs_CalcBusSpeed(XSdPs *InstancePtr, u32 *Arg);
|
||||
void XSdPs_SetupReadDma(XSdPs *InstancePtr, u16 BlkCnt, u16 BlkSize, u8 *Buff);
|
||||
void XSdPs_SetupWriteDma(XSdPs *InstancePtr, u16 BlkCnt, u16 BlkSize, const u8 *Buff);
|
||||
s32 XSdPs_SetVoltage18(XSdPs *InstancePtr);
|
||||
s32 XSdPs_SendCmd(XSdPs *InstancePtr, u32 Cmd);
|
||||
void XSdPs_IdentifyEmmcMode(XSdPs *InstancePtr, const u8 *ExtCsd);
|
||||
s32 XSdPs_CheckEmmcTiming(XSdPs *InstancePtr, u8 *ExtCsd);
|
||||
void XSdPs_ConfigPower(XSdPs *InstancePtr);
|
||||
void XSdPs_ConfigDma(XSdPs *InstancePtr);
|
||||
void XSdPs_ConfigInterrupt(XSdPs *InstancePtr);
|
||||
s32 XSdPs_SendErase(XSdPs *InstancePtr);
|
||||
s32 XSdPs_SetEndAddr(XSdPs *InstancePtr, u32 EndAddr);
|
||||
s32 XSdPs_SetStartAddr(XSdPs *InstancePtr, u32 StartAddr);
|
||||
#ifdef VERSAL_NET
|
||||
u32 XSdPs_Select_HS400(XSdPs *InstancePtr);
|
||||
#endif
|
||||
|
||||
#if defined (__aarch64__) && (EL1_NONSECURE == 1)
|
||||
void XSdps_Smc(XSdPs *InstancePtr, u32 RegOffset, u32 Mask, u32 Val);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/** @endcond */
|
||||
/** @} */
|
60
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_g.c
Normal file
60
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_g.c
Normal file
@ -0,0 +1,60 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsdps_g.c
|
||||
* @addtogroup sdps Overview
|
||||
* @{
|
||||
*
|
||||
* The xsdps_g.c file contains a configuration table that specifies the
|
||||
* configuration of SD devices in the system.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00a hk/sg 10/17/13 Initial release
|
||||
* 3.6 mn 07/06/18 Add initialization macros in sdps
|
||||
* mn 07/13/18 Add initializer macro for HasEMIO
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#include "xparameters.h"
|
||||
#include "xsdps.h"
|
||||
|
||||
/**
|
||||
* The configuration table for devices
|
||||
*/
|
||||
|
||||
XSdPs_Config XSdPs_ConfigTable[] =
|
||||
{
|
||||
{
|
||||
XPAR_XSDPS_0_DEVICE_ID,
|
||||
XPAR_XSDPS_0_BASEADDR,
|
||||
XPAR_XSDPS_0_SDIO_CLK_FREQ_HZ,
|
||||
XPAR_XSDPS_0_HAS_CD,
|
||||
XPAR_XSDPS_0_HAS_WP,
|
||||
XPAR_XSDPS_0_BUS_WIDTH,
|
||||
XPAR_XSDPS_0_MIO_BANK,
|
||||
XPAR_XSDPS_0_HAS_EMIO,
|
||||
XPAR_XSDPS_0_SLOT_TYPE,
|
||||
XPAR_XSDPS_0_IS_CACHE_COHERENT,
|
||||
XPAR_XSDPS_0_CLK_50_SDR_ITAP_DLY,
|
||||
XPAR_XSDPS_0_CLK_50_SDR_OTAP_DLY,
|
||||
XPAR_XSDPS_0_CLK_50_DDR_ITAP_DLY,
|
||||
XPAR_XSDPS_0_CLK_50_DDR_OTAP_DLY,
|
||||
XPAR_XSDPS_0_CLK_100_SDR_OTAP_DLY,
|
||||
XPAR_XSDPS_0_CLK_200_SDR_OTAP_DLY
|
||||
}
|
||||
};
|
||||
/** @} */
|
1795
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_host.c
Normal file
1795
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_host.c
Normal file
File diff suppressed because it is too large
Load Diff
1507
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_hw.h
Normal file
1507
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_hw.h
Normal file
File diff suppressed because it is too large
Load Diff
901
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_options.c
Normal file
901
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_options.c
Normal file
@ -0,0 +1,901 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsdps_options.c
|
||||
* @addtogroup sdps Overview
|
||||
* @{
|
||||
*
|
||||
* The xsdps_options.c file ontains APIs for changing the various options in host and card.
|
||||
* See xsdps.h for a detailed description of the device and driver.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00a hk/sg 10/17/13 Initial release
|
||||
* 2.1 hk 04/18/14 Increase sleep for eMMC switch command.
|
||||
* Add sleep for microblaze designs. CR# 781117.
|
||||
* 2.3 sk 09/23/14 Use XSdPs_Change_ClkFreq API whenever changing
|
||||
* clock.CR# 816586.
|
||||
* 2.5 sg 07/09/15 Added SD 3.0 features
|
||||
* kvn 07/15/15 Modified the code according to MISRAC-2012.
|
||||
* 2.7 sk 01/08/16 Added workaround for issue in auto tuning mode
|
||||
* of SDR50, SDR104 and HS200.
|
||||
* sk 02/16/16 Corrected the Tuning logic.
|
||||
* sk 03/02/16 Configured the Tap Delay values for eMMC HS200 mode.
|
||||
* 2.8 sk 04/20/16 Added new workaround for auto tuning.
|
||||
* 3.0 sk 07/07/16 Used usleep API for both arm and microblaze.
|
||||
* sk 07/16/16 Added support for UHS modes.
|
||||
* sk 07/16/16 Added Tap delays accordingly to different SD/eMMC
|
||||
* operating modes.
|
||||
* 3.1 mi 09/07/16 Removed compilation warnings with extra compiler flags.
|
||||
* sk 11/07/16 Enable Rst_n bit in ext_csd reg if not enabled.
|
||||
* sk 11/16/16 Issue DLL reset at 31 iteration to load new zero value.
|
||||
* 3.2 sk 02/01/17 Added HSD and DDR mode support for eMMC.
|
||||
* sk 02/01/17 Consider bus width parameter from design for switching
|
||||
* vns 02/09/17 Added ARMA53_32 support for ZynqMP CR#968397
|
||||
* vns 03/13/17 Fixed MISRAC mandatory violation
|
||||
* sk 03/20/17 Add support for EL1 non-secure mode.
|
||||
* 3.3 mn 07/25/17 Removed SD0_OTAPDLYENA and SD1_OTAPDLYENA bits
|
||||
* mn 08/07/17 Properly set OTAPDLY value by clearing previous bit
|
||||
* settings
|
||||
* mn 08/17/17 Added CCI support for A53 and disabled data cache
|
||||
* operations when it is enabled.
|
||||
* mn 08/22/17 Updated for Word Access System support
|
||||
* 3.4 mn 01/22/18 Separated out SDR104 and HS200 clock defines
|
||||
* 3.6 mn 07/06/18 Fix Cppcheck warnings for sdps driver
|
||||
* 3.7 aru 03/12/19 Modified the code according to MISRAC-2012.
|
||||
* mn 03/27/19 Disable calls to dll_reset API for versal SPP Platforms
|
||||
* 3.8 mn 04/12/19 Modified TapDelay code for supporting ZynqMP and Versal
|
||||
* mn 05/21/19 Set correct tap delays for Versal
|
||||
* mn 05/21/19 Disable DLL Reset code for Versal
|
||||
* mn 08/29/19 Add call to Cache Invalidation API in XSdPs_Get_BusWidth
|
||||
* 3.9 mn 03/03/20 Restructured the code for more readability and modularity
|
||||
* mn 03/16/20 Move XSdPs_Select_Card API to User APIs
|
||||
* 3.10 mn 06/05/20 Modified code for SD Non-Blocking Read support
|
||||
* 3.12 sk 01/28/21 Added support for non-blocking write.
|
||||
* 3.14 mn 11/28/21 Fix MISRA-C violations.
|
||||
* 4.0 sk 02/25/22 Add support for eMMC5.1.
|
||||
* 4.1 sk 11/10/22 Add SD/eMMC Tap delay support for Versal Net.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include "xsdps_core.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* API to change clock freq to given value.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
* @param SelFreq - Clock frequency in Hz.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
* @note This API will change clock frequency to the value less than
|
||||
* or equal to the given value using the permissible dividors.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Change_ClkFreq(XSdPs *InstancePtr, u32 SelFreq)
|
||||
{
|
||||
s32 Status;
|
||||
#ifdef VERSAL_NET
|
||||
u32 Reg;
|
||||
#endif
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
#ifndef VERSAL_NET
|
||||
if (InstancePtr->HC_Version == XSDPS_HC_SPEC_V3) {
|
||||
/* Program the Tap delays */
|
||||
XSdPs_SetTapDelay(InstancePtr);
|
||||
}
|
||||
#else
|
||||
if (InstancePtr->CardType == XSDPS_CARD_SD) {
|
||||
XSdPs_SetTapDelay(InstancePtr);
|
||||
} else {
|
||||
Reg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, XSDPS_PHYCTRLREG1_OFFSET);
|
||||
Reg &= ~(XSDPS_PHYREG1_STROBE_SEL_MASK | XSDPS_PHYREG1_OTAP_DLY_MASK |
|
||||
XSDPS_PHYREG1_OTAP_EN_MASK | XSDPS_PHYREG1_ITAP_EN_MASK |
|
||||
XSDPS_PHYREG1_ITAP_DLY_MASK);
|
||||
if (InstancePtr->OTapDelay != 0U) {
|
||||
Reg |= (InstancePtr->OTapDelay << XSDPS_PHYREG1_OTAP_DLY_SHIFT);
|
||||
Reg |= XSDPS_PHYREG1_OTAP_EN_MASK;
|
||||
}
|
||||
|
||||
Reg |= XSDPS_PHYREG1_ITAP_CHGWIN_MASK;
|
||||
XSdPs_WriteReg(InstancePtr->Config.BaseAddress, XSDPS_PHYCTRLREG1_OFFSET, Reg);
|
||||
if (InstancePtr->ITapDelay != 0U) {
|
||||
Reg |= (InstancePtr->ITapDelay << XSDPS_PHYREG1_ITAP_DLY_SHIFT);
|
||||
Reg |= XSDPS_PHYREG1_ITAP_EN_MASK;
|
||||
}
|
||||
|
||||
Reg &= ~XSDPS_PHYREG1_ITAP_CHGWIN_MASK;
|
||||
if (InstancePtr->Mode == XSDPS_HS400_MODE)
|
||||
Reg |= (PHY_STRB_SEL_SIG | PHY_STRB_SEL_SIG) << XSDPS_PHYREG1_STROBE_SEL_SHIFT;
|
||||
|
||||
XSdPs_WriteReg(InstancePtr->Config.BaseAddress, XSDPS_PHYCTRLREG1_OFFSET, Reg);
|
||||
}
|
||||
#endif
|
||||
|
||||
Status = XSdPs_SetClock(InstancePtr, SelFreq);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief
|
||||
* Update Block size for read/write operations.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param BlkSize - Block size passed by the user.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_SetBlkSize(XSdPs *InstancePtr, u16 BlkSize)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Status = XSdPs_CheckBusIdle(InstancePtr, (XSDPS_PSR_INHIBIT_CMD_MASK
|
||||
| XSDPS_PSR_INHIBIT_DAT_MASK
|
||||
| XSDPS_PSR_WR_ACTIVE_MASK
|
||||
| XSDPS_PSR_RD_ACTIVE_MASK));
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH ;
|
||||
}
|
||||
|
||||
/* Send block write command */
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, CMD16, BlkSize, 0U);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Set block size to the value passed */
|
||||
XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, XSDPS_BLK_SIZE_OFFSET,
|
||||
BlkSize & XSDPS_BLK_SIZE_MASK);
|
||||
|
||||
InstancePtr->BlkSize = BlkSize;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* API to get bus width support by card.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
* @param ReadBuff - buffer to store SCR register returned by card.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if fail.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Get_BusWidth(XSdPs *InstancePtr, u8 *ReadBuff)
|
||||
{
|
||||
s32 Status;
|
||||
u16 BlkCnt;
|
||||
u16 BlkSize;
|
||||
s32 LoopCnt;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
for (LoopCnt = 0; LoopCnt < 8; LoopCnt++) {
|
||||
ReadBuff[LoopCnt] = 0U;
|
||||
}
|
||||
|
||||
/* Send block write command */
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, CMD55,
|
||||
InstancePtr->RelCardAddr, 0U);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
BlkCnt = XSDPS_SCR_BLKCNT;
|
||||
BlkSize = XSDPS_SCR_BLKSIZE;
|
||||
|
||||
XSdPs_SetupReadDma(InstancePtr, BlkCnt, BlkSize, ReadBuff);
|
||||
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, ACMD51, 0U, BlkCnt);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Check for transfer done */
|
||||
Status = XSdps_CheckTransferDone(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
if (InstancePtr->Config.IsCacheCoherent == 0U) {
|
||||
Xil_DCacheInvalidateRange((INTPTR)ReadBuff,
|
||||
((INTPTR)BlkCnt * (INTPTR)BlkSize));
|
||||
}
|
||||
|
||||
Status = XST_SUCCESS;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* API to set bus width to 4-bit in card and host
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if fail.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Change_BusWidth(XSdPs *InstancePtr)
|
||||
{
|
||||
s32 Status;
|
||||
u32 StatusReg;
|
||||
u32 Arg;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/*
|
||||
* check for bus width for 3.0 controller and return if
|
||||
* bus width is <4
|
||||
*/
|
||||
if ((InstancePtr->HC_Version == XSDPS_HC_SPEC_V3) &&
|
||||
(InstancePtr->Config.BusWidth < XSDPS_WIDTH_4)) {
|
||||
Status = XST_SUCCESS;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
if (InstancePtr->CardType == XSDPS_CARD_SD) {
|
||||
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, CMD55, InstancePtr->RelCardAddr,
|
||||
0U);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, ACMD6, (u32)InstancePtr->BusWidth, 0U);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
} else {
|
||||
if (InstancePtr->BusWidth == XSDPS_8_BIT_WIDTH) {
|
||||
if ((InstancePtr->Mode == XSDPS_DDR52_MODE) ||
|
||||
(InstancePtr->Mode == XSDPS_HS400_MODE)) {
|
||||
Arg = XSDPS_MMC_DDR_8_BIT_BUS_ARG;
|
||||
} else {
|
||||
Arg = XSDPS_MMC_8_BIT_BUS_ARG;
|
||||
}
|
||||
} else {
|
||||
if (InstancePtr->Mode == XSDPS_DDR52_MODE) {
|
||||
Arg = XSDPS_MMC_DDR_4_BIT_BUS_ARG;
|
||||
} else {
|
||||
Arg = XSDPS_MMC_4_BIT_BUS_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
Status = XSdPs_Set_Mmc_ExtCsd(InstancePtr, Arg);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
}
|
||||
|
||||
usleep(XSDPS_MMC_DELAY_FOR_SWITCH);
|
||||
|
||||
StatusReg = XSdPs_ReadReg8(InstancePtr->Config.BaseAddress,
|
||||
XSDPS_HOST_CTRL1_OFFSET);
|
||||
|
||||
/* Width setting in controller */
|
||||
if (InstancePtr->BusWidth == XSDPS_8_BIT_WIDTH) {
|
||||
StatusReg |= XSDPS_HC_EXT_BUS_WIDTH;
|
||||
} else {
|
||||
StatusReg |= XSDPS_HC_WIDTH_MASK;
|
||||
}
|
||||
|
||||
XSdPs_WriteReg8(InstancePtr->Config.BaseAddress,
|
||||
XSDPS_HOST_CTRL1_OFFSET,
|
||||
(u8)StatusReg);
|
||||
|
||||
if (InstancePtr->Mode == XSDPS_DDR52_MODE) {
|
||||
StatusReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress,
|
||||
XSDPS_HOST_CTRL2_OFFSET);
|
||||
StatusReg &= (~(u32)XSDPS_HC2_UHS_MODE_MASK);
|
||||
StatusReg |= InstancePtr->Mode;
|
||||
XSdPs_WriteReg16(InstancePtr->Config.BaseAddress,
|
||||
XSDPS_HOST_CTRL2_OFFSET, (u16)StatusReg);
|
||||
}
|
||||
|
||||
Status = XST_SUCCESS;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* API to get bus speed supported by card.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
* @param ReadBuff - buffer to store function group support data
|
||||
* returned by card.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if fail.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Get_BusSpeed(XSdPs *InstancePtr, u8 *ReadBuff)
|
||||
{
|
||||
s32 Status;
|
||||
u32 Arg;
|
||||
u16 BlkCnt;
|
||||
u16 BlkSize;
|
||||
s32 LoopCnt;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
for (LoopCnt = 0; LoopCnt < 64; LoopCnt++) {
|
||||
ReadBuff[LoopCnt] = 0U;
|
||||
}
|
||||
|
||||
BlkCnt = XSDPS_SWITCH_CMD_BLKCNT;
|
||||
BlkSize = XSDPS_SWITCH_CMD_BLKSIZE;
|
||||
|
||||
XSdPs_SetupReadDma(InstancePtr, BlkCnt, BlkSize, ReadBuff);
|
||||
|
||||
Arg = XSDPS_SWITCH_CMD_HS_GET;
|
||||
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, CMD6, Arg, 1U);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Check for transfer done */
|
||||
Status = XSdps_CheckTransferDone(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
if (InstancePtr->Config.IsCacheCoherent == 0U) {
|
||||
Xil_DCacheInvalidateRange((INTPTR)ReadBuff,
|
||||
((INTPTR)BlkCnt * (INTPTR)BlkSize));
|
||||
}
|
||||
|
||||
Status = XST_SUCCESS;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* API to get SD card status information.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
* @param SdStatReg - buffer to store status data returned by card.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if fail.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Get_Status(XSdPs *InstancePtr, u8 *SdStatReg)
|
||||
{
|
||||
s32 Status;
|
||||
u16 BlkCnt;
|
||||
u16 BlkSize;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/* Send block write command */
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, CMD55,
|
||||
InstancePtr->RelCardAddr, 0U);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
BlkCnt = XSDPS_SD_STATUS_BLKCNT;
|
||||
BlkSize = XSDPS_SD_STATUS_BLKSIZE;
|
||||
|
||||
XSdPs_SetupReadDma(InstancePtr, BlkCnt, BlkSize, SdStatReg);
|
||||
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, ACMD13, 0U, BlkCnt);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Check for transfer done */
|
||||
Status = XSdps_CheckTransferDone(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
if (InstancePtr->Config.IsCacheCoherent == 0U) {
|
||||
Xil_DCacheInvalidateRange((INTPTR)SdStatReg,
|
||||
((INTPTR)BlkCnt * (INTPTR)BlkSize));
|
||||
}
|
||||
|
||||
Status = XST_SUCCESS;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* API to set high speed in card and host. Changes clock in host accordingly.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if fail.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Change_BusSpeed(XSdPs *InstancePtr)
|
||||
{
|
||||
s32 Status;
|
||||
u32 StatusReg;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
if (InstancePtr->CardType == XSDPS_CARD_SD) {
|
||||
Status = XSdPs_Change_SdBusSpeed(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
} else {
|
||||
Status = XSdPs_Change_MmcBusSpeed(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
}
|
||||
|
||||
Status = XSdPs_Change_ClkFreq(InstancePtr, InstancePtr->BusSpeed);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
if ((InstancePtr->Mode == XSDPS_HS400_MODE) ||
|
||||
(InstancePtr->Mode == XSDPS_HS200_MODE) ||
|
||||
(InstancePtr->Mode == XSDPS_UHS_SPEED_MODE_SDR104) ||
|
||||
(InstancePtr->Mode == XSDPS_UHS_SPEED_MODE_SDR50)) {
|
||||
Status = XSdPs_Execute_Tuning(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
}
|
||||
|
||||
usleep(XSDPS_MMC_DELAY_FOR_SWITCH);
|
||||
|
||||
StatusReg = (u32)XSdPs_ReadReg8(InstancePtr->Config.BaseAddress,
|
||||
XSDPS_HOST_CTRL1_OFFSET);
|
||||
StatusReg |= XSDPS_HC_SPEED_MASK;
|
||||
XSdPs_WriteReg8(InstancePtr->Config.BaseAddress,
|
||||
XSDPS_HOST_CTRL1_OFFSET, (u8)StatusReg);
|
||||
|
||||
#ifdef VERSAL_NET
|
||||
if (InstancePtr->Mode == XSDPS_HS400_MODE) {
|
||||
InstancePtr->IsTuningDone = 1U;
|
||||
Status = XSdPs_Select_HS400(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Status = XST_SUCCESS;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* API to get EXT_CSD register of eMMC.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
* @param ReadBuff - buffer to store EXT_CSD
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if fail.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Get_Mmc_ExtCsd(XSdPs *InstancePtr, u8 *ReadBuff)
|
||||
{
|
||||
s32 Status;
|
||||
u32 Arg = 0U;
|
||||
u16 BlkCnt;
|
||||
u16 BlkSize;
|
||||
s32 LoopCnt;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
for (LoopCnt = 0; LoopCnt < 512; LoopCnt++) {
|
||||
ReadBuff[LoopCnt] = 0U;
|
||||
}
|
||||
|
||||
BlkCnt = XSDPS_EXT_CSD_CMD_BLKCNT;
|
||||
BlkSize = XSDPS_EXT_CSD_CMD_BLKSIZE;
|
||||
|
||||
XSdPs_SetupReadDma(InstancePtr, BlkCnt, BlkSize, ReadBuff);
|
||||
|
||||
/* Send SEND_EXT_CSD command */
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, CMD8, Arg, 1U);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Check for transfer done */
|
||||
Status = XSdps_CheckTransferDone(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
if (InstancePtr->Config.IsCacheCoherent == 0U) {
|
||||
Xil_DCacheInvalidateRange((INTPTR)ReadBuff,
|
||||
((INTPTR)BlkCnt * (INTPTR)BlkSize));
|
||||
}
|
||||
|
||||
Status = XST_SUCCESS;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* API to write EXT_CSD register of eMMC.
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
* @param Arg is the argument to be sent along with the command
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if fail.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Set_Mmc_ExtCsd(XSdPs *InstancePtr, u32 Arg)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, CMD6, Arg, 0U);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Check for transfer done */
|
||||
Status = XSdps_CheckTransferDone(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
Status = XST_SUCCESS;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* API to send pullup command to card before using DAT line 3(using 4-bit bus)
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if fail.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Pullup(XSdPs *InstancePtr)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, CMD55,
|
||||
InstancePtr->RelCardAddr, 0U);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, ACMD42, 0U, 0U);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
Status = XST_SUCCESS;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* Selects card and sets default block size
|
||||
*
|
||||
*
|
||||
* @param InstancePtr is a pointer to the XSdPs instance.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if successful.
|
||||
* - XST_FAILURE if fail.
|
||||
* - XSDPS_CT_ERROR if Command Transfer fail.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_Select_Card (XSdPs *InstancePtr)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
/* Send CMD7 - Select card */
|
||||
Status = XSdPs_CmdTransfer(InstancePtr, CMD7,
|
||||
InstancePtr->RelCardAddr, 0U);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief
|
||||
* This function performs SD read in polled mode.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param Arg is the address passed by the user that is to be sent as
|
||||
* argument along with the command.
|
||||
* @param BlkCnt - Block count passed by the user.
|
||||
* @param Buff - Pointer to the data buffer for a DMA transfer.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if Transfer initialization was successful
|
||||
* - XST_FAILURE if failure - could be because another transfer
|
||||
* is in progress or command or data inhibit is set
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_StartReadTransfer(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
if (InstancePtr->IsBusy == TRUE) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Setup the Read Transfer */
|
||||
Status = XSdPs_SetupTransfer(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Read from the card */
|
||||
Status = XSdPs_Read(InstancePtr, Arg, BlkCnt, Buff);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
}
|
||||
|
||||
InstancePtr->IsBusy = TRUE;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief
|
||||
* This function start SD write transfer.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
* @param Arg is the address passed by the user that is to be sent as
|
||||
* argument along with the command.
|
||||
* @param BlkCnt - Block count passed by the user.
|
||||
* @param Buff - Pointer to the data buffer for a DMA transfer.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if Transfer initialization was successful
|
||||
* - XST_FAILURE if failure - could be because another transfer
|
||||
* is in progress or command or data inhibit is set
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_StartWriteTransfer(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
if (InstancePtr->IsBusy == TRUE) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* Setup the Write Transfer */
|
||||
Status = XSdPs_SetupTransfer(InstancePtr);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto RETURN_PATH;
|
||||
}
|
||||
|
||||
/* write to the card */
|
||||
Status = XSdPs_Write(InstancePtr, Arg, BlkCnt, Buff);
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
}
|
||||
|
||||
InstancePtr->IsBusy = TRUE;
|
||||
|
||||
RETURN_PATH:
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief
|
||||
* This function is used to check if the transfer is completed successfully.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if transfer was successful
|
||||
* - XST_FAILURE if failure
|
||||
* - XST_DEVICE_BUSY - if the transfer is still in progress
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_CheckReadTransfer(XSdPs *InstancePtr)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Status = XSdPs_CheckTransferComplete(InstancePtr);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief
|
||||
* This function is used to check for the write transfer completed.
|
||||
*
|
||||
* @param InstancePtr is a pointer to the instance to be worked on.
|
||||
*
|
||||
* @return
|
||||
* - XST_SUCCESS if transfer was successful
|
||||
* - XST_FAILURE if failure
|
||||
* - XST_DEVICE_BUSY - if the transfer is still in progress
|
||||
*
|
||||
******************************************************************************/
|
||||
s32 XSdPs_CheckWriteTransfer(XSdPs *InstancePtr)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
Xil_AssertNonvoid(InstancePtr != NULL);
|
||||
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
|
||||
|
||||
Status = XSdPs_CheckTransferComplete(InstancePtr);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/** @} */
|
79
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_sinit.c
Normal file
79
bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_sinit.c
Normal file
@ -0,0 +1,79 @@
|
||||
/******************************************************************************
|
||||
* Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xsdps_sinit.c
|
||||
* @addtogroup sdps Overview
|
||||
* @{
|
||||
*
|
||||
* The implementation of the XSdPs component's static initialization
|
||||
* functionality.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00a hk/sg 10/17/13 Initial release
|
||||
* kvn 07/15/15 Modified the code according to MISRAC-2012.
|
||||
* 3.7 aru 03/12/19 Modified the code according to MISRAC-2012.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include "xstatus.h"
|
||||
#include "xsdps.h"
|
||||
#include "xparameters.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
/**
|
||||
* XSdPs Configuration Table
|
||||
*/
|
||||
extern XSdPs_Config XSdPs_ConfigTable[XPAR_XSDPS_NUM_INSTANCES];
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @brief
|
||||
* Looks up the device configuration based on the unique device ID. A table
|
||||
* contains the configuration info for each device in the system.
|
||||
*
|
||||
* @param DeviceId contains the ID of the device to look up the
|
||||
* configuration for.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* A pointer to the configuration found or NULL if the specified device ID was
|
||||
* not found. See xsdps.h for the definition of XSdPs_Config.
|
||||
*
|
||||
* @note None.
|
||||
*
|
||||
******************************************************************************/
|
||||
XSdPs_Config *XSdPs_LookupConfig(u16 DeviceId)
|
||||
{
|
||||
XSdPs_Config *CfgPtr = NULL;
|
||||
u32 Index;
|
||||
|
||||
for (Index = 0U; Index < (u32)XPAR_XSDPS_NUM_INSTANCES; Index++) {
|
||||
if (XSdPs_ConfigTable[Index].DeviceId == DeviceId) {
|
||||
CfgPtr = &XSdPs_ConfigTable[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (XSdPs_Config *)CfgPtr;
|
||||
}
|
||||
/** @} */
|
83
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/Makefile
Normal file
83
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/Makefile
Normal file
@ -0,0 +1,83 @@
|
||||
###############################################################################
|
||||
# Copyright (c) 2011 - 2020 Xilinx, Inc. All rights reserved.
|
||||
# SPDX-License-Identifier: MIT
|
||||
###############################################################################
|
||||
DRIVER_LIB_VERSION = v1.0
|
||||
|
||||
include config.make
|
||||
|
||||
CC=$(COMPILER)
|
||||
AR=$(ARCHIVER)
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
EXTRA_COMPILER_FLAGS=
|
||||
LIB=libxil.a
|
||||
|
||||
CC_FLAGS = $(subst -pg, -DPROFILING, $(COMPILER_FLAGS))
|
||||
ECC_FLAGS = $(subst -pg, -DPROFILING, $(EXTRA_COMPILER_FLAGS))
|
||||
|
||||
ifeq (($(notdir $(CC))) , arm-xilinx-eabi-gcc)
|
||||
ECC_FLAGS += -nostartfiles\
|
||||
-march=armv7-a \
|
||||
-mfloat-abi=soft \
|
||||
-mfpu=neon
|
||||
endif
|
||||
|
||||
ifeq (($(notdir $(CC))) , arm-none-eabi-gcc)
|
||||
ECC_FLAGS += -nostartfiles
|
||||
endif
|
||||
|
||||
RELEASEDIR=../../../lib/
|
||||
INCLUDEDIR=../../../include/
|
||||
INCLUDES=-I./. -I${INCLUDEDIR}
|
||||
|
||||
SRCFILES:=$(wildcard *.c)
|
||||
|
||||
ASSEMBLY_SRCFILES:=$(wildcard *.S)
|
||||
|
||||
OBJECTS = $(addprefix $(RELEASEDIR),$(addsuffix .o, $(basename $(wildcard *.c))))
|
||||
|
||||
ASSEMBLY_OBJECTS = $(addprefix $(RELEASEDIR),$(addsuffix .o, $(basename $(wildcard *.S))))
|
||||
|
||||
INCLUDEFILES=*.h
|
||||
|
||||
libs: $(LIBS)
|
||||
|
||||
standalone_libs: $(OBJECTS) $(ASSEMBLY_OBJECTS)
|
||||
|
||||
DEPFILES := $(SRCFILES:%.c=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(DEPFILES))
|
||||
|
||||
ASSEMBLY_DEPFILES := $(ASSEMBLY_SRCFILES:%.S=$(RELEASEDIR)%.d)
|
||||
|
||||
include $(wildcard $(ASSEMBLY_DEPFILES))
|
||||
|
||||
include $(wildcard ../../../../dep.mk)
|
||||
|
||||
$(RELEASEDIR)%.o: %.S
|
||||
$(CC) $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) -o $@ $<
|
||||
|
||||
$(RELEASEDIR)%.o: %.c
|
||||
$(CC) $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $(DEPENDENCY_FLAGS) -o $@ $<
|
||||
|
||||
profile_libs:
|
||||
$(MAKE) -C profile COMPILER_FLAGS="$(COMPILER_FLAGS)" EXTRA_COMPILER_FLAGS="$(EXTRA_COMPILER_FLAGS)" COMPILER="$(CC)" ARCHIVER="$(AR)" libs
|
||||
|
||||
.PHONY: include
|
||||
include: standalone_includes profile_includes
|
||||
|
||||
standalone_includes: $(addprefix $(INCLUDEDIR),$(wildcard *.h))
|
||||
|
||||
$(INCLUDEDIR)%.h: %.h
|
||||
$(CP) $< $@
|
||||
|
||||
profile_includes:
|
||||
$(MAKE) -C profile COMPILER_FLAGS="$(COMPILER_FLAGS)" EXTRA_COMPILER_FLAGS="$(EXTRA_COMPILER_FLAGS)" COMPILER="$(CC)" ARCHIVER="$(AR)" include
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS}
|
||||
rm -rf ${ASSEMBLY_OBJECTS}
|
||||
rm -rf $(DEPFILES)
|
||||
rm -rf $(ASSEMBLY_DEPFILES)
|
||||
$(MAKE) -C profile COMPILER_FLAGS="$(COMPILER_FLAGS)" EXTRA_COMPILER_FLAGS="$(EXTRA_COMPILER_FLAGS)" COMPILER="$(CC)" ARCHIVER="$(AR)" clean
|
18
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/_exit.c
Normal file
18
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/_exit.c
Normal file
@ -0,0 +1,18 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include <unistd.h>
|
||||
#include "xil_types.h"
|
||||
|
||||
/* _exit - Simple implementation. Does not return.
|
||||
*/
|
||||
__attribute__((weak)) void _exit (sint32 status)
|
||||
{
|
||||
(void)status;
|
||||
while (1) {
|
||||
;
|
||||
}
|
||||
}
|
32
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/_open.c
Normal file
32
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/_open.c
Normal file
@ -0,0 +1,32 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef UNDEFINE_FILE_OPS
|
||||
#include <errno.h>
|
||||
#include "xil_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) s32 _open(const char8 *buf, s32 flags, s32 mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* _open -- open a file descriptor. We don't have a filesystem, so
|
||||
* we return an error.
|
||||
*/
|
||||
__attribute__((weak)) s32 _open(const char8 *buf, s32 flags, s32 mode)
|
||||
{
|
||||
(void)buf;
|
||||
(void)flags;
|
||||
(void)mode;
|
||||
errno = EIO;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
43
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/_sbrk.c
Normal file
43
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/_sbrk.c
Normal file
@ -0,0 +1,43 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "xil_types.h"
|
||||
|
||||
extern u8 _heap_start[];
|
||||
extern u8 _heap_end[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) caddr_t _sbrk ( s32 incr );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) caddr_t _sbrk ( s32 incr )
|
||||
{
|
||||
static u8 *heap = NULL;
|
||||
u8 *prev_heap;
|
||||
static u8 *HeapEndPtr = (u8 *)&_heap_end;
|
||||
caddr_t Status;
|
||||
|
||||
if (heap == NULL) {
|
||||
heap = (u8 *)&_heap_start;
|
||||
}
|
||||
prev_heap = heap;
|
||||
|
||||
if (((heap + incr) <= HeapEndPtr) && (prev_heap != NULL)) {
|
||||
heap += incr;
|
||||
Status = (caddr_t) ((void *)prev_heap);
|
||||
} else {
|
||||
Status = (caddr_t) -1;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
16
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/abort.c
Normal file
16
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/abort.c
Normal file
@ -0,0 +1,16 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2020 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
* abort -- go out via exit...
|
||||
*/
|
||||
__attribute__((weak)) void abort(void)
|
||||
{
|
||||
_exit(1);
|
||||
}
|
176
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/asm_vectors.S
Normal file
176
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/asm_vectors.S
Normal file
@ -0,0 +1,176 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file asm_vectors.S
|
||||
*
|
||||
* This file contains the initial vector table for the Cortex A9 processor
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------- -------- ---------------------------------------------------
|
||||
* 1.00a ecm/sdm 10/20/09 Initial version
|
||||
* 3.05a sdm 02/02/12 Save lr when profiling is enabled
|
||||
* 3.10a srt 04/18/13 Implemented ARM Erratas. Please refer to file
|
||||
* 'xil_errata.h' for errata description
|
||||
* 4.00a pkp 22/01/14 Modified return addresses for interrupt
|
||||
* handlers (DataAbortHandler and SVCHandler)
|
||||
* to fix CR#767251
|
||||
* 5.1 pkp 05/13/15 Saved the addresses of instruction causing data
|
||||
* abort and prefetch abort into DataAbortAddr and
|
||||
* PrefetchAbortAddr for further use to fix CR#854523
|
||||
* 5.4 pkp 12/03/15 Added handler for undefined exception
|
||||
* 6.8 mus 04/27/18 Removed __ARM_NEON__ flag definition. Now,
|
||||
* saving/restoring of of HW floating point register
|
||||
* would be done through newly introduced flag
|
||||
* FPU_HARD_FLOAT_ABI_ENABLED. This new flag will be
|
||||
* configured based on the -mfpu-abi option in extra
|
||||
* compiler flags.
|
||||
* </pre>
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* None.
|
||||
*
|
||||
******************************************************************************/
|
||||
#include "xil_errata.h"
|
||||
#include "bspconfig.h"
|
||||
|
||||
.org 0
|
||||
.text
|
||||
|
||||
.globl _vector_table
|
||||
|
||||
.section .vectors
|
||||
_vector_table:
|
||||
B _boot
|
||||
B Undefined
|
||||
B SVCHandler
|
||||
B PrefetchAbortHandler
|
||||
B DataAbortHandler
|
||||
NOP /* Placeholder for address exception vector*/
|
||||
B IRQHandler
|
||||
B FIQHandler
|
||||
|
||||
|
||||
IRQHandler: /* IRQ vector handler */
|
||||
|
||||
stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code*/
|
||||
#if FPU_HARD_FLOAT_ABI_ENABLED
|
||||
vpush {d0-d7}
|
||||
vpush {d16-d31}
|
||||
vmrs r1, FPSCR
|
||||
push {r1}
|
||||
vmrs r1, FPEXC
|
||||
push {r1}
|
||||
#endif
|
||||
|
||||
#ifdef PROFILING
|
||||
ldr r2, =prof_pc
|
||||
subs r3, lr, #0
|
||||
str r3, [r2]
|
||||
#endif
|
||||
|
||||
bl IRQInterrupt /* IRQ vector */
|
||||
|
||||
#if FPU_HARD_FLOAT_ABI_ENABLED
|
||||
pop {r1}
|
||||
vmsr FPEXC, r1
|
||||
pop {r1}
|
||||
vmsr FPSCR, r1
|
||||
vpop {d16-d31}
|
||||
vpop {d0-d7}
|
||||
#endif
|
||||
ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
|
||||
|
||||
|
||||
subs pc, lr, #4 /* adjust return */
|
||||
|
||||
|
||||
FIQHandler: /* FIQ vector handler */
|
||||
stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
|
||||
#if FPU_HARD_FLOAT_ABI_ENABLED
|
||||
vpush {d0-d7}
|
||||
vpush {d16-d31}
|
||||
vmrs r1, FPSCR
|
||||
push {r1}
|
||||
vmrs r1, FPEXC
|
||||
push {r1}
|
||||
#endif
|
||||
|
||||
FIQLoop:
|
||||
bl FIQInterrupt /* FIQ vector */
|
||||
|
||||
#if FPU_HARD_FLOAT_ABI_ENABLED
|
||||
pop {r1}
|
||||
vmsr FPEXC, r1
|
||||
pop {r1}
|
||||
vmsr FPSCR, r1
|
||||
vpop {d16-d31}
|
||||
vpop {d0-d7}
|
||||
#endif
|
||||
ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
|
||||
subs pc, lr, #4 /* adjust return */
|
||||
|
||||
|
||||
Undefined: /* Undefined handler */
|
||||
stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
|
||||
ldr r0, =UndefinedExceptionAddr
|
||||
sub r1, lr, #4
|
||||
str r1, [r0] /* Store address of instruction causing undefined exception */
|
||||
|
||||
bl UndefinedException /* UndefinedException: call C function here */
|
||||
ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
|
||||
movs pc, lr
|
||||
|
||||
SVCHandler: /* SWI handler */
|
||||
stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
|
||||
|
||||
tst r0, #0x20 /* check the T bit */
|
||||
ldrneh r0, [lr,#-2] /* Thumb mode */
|
||||
bicne r0, r0, #0xff00 /* Thumb mode */
|
||||
ldreq r0, [lr,#-4] /* ARM mode */
|
||||
biceq r0, r0, #0xff000000 /* ARM mode */
|
||||
|
||||
bl SWInterrupt /* SWInterrupt: call C function here */
|
||||
|
||||
ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
|
||||
|
||||
movs pc, lr /*return to the next instruction after the SWI instruction */
|
||||
|
||||
|
||||
DataAbortHandler: /* Data Abort handler */
|
||||
#ifdef CONFIG_ARM_ERRATA_775420
|
||||
dsb
|
||||
#endif
|
||||
stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
|
||||
ldr r0, =DataAbortAddr
|
||||
sub r1, lr, #8
|
||||
str r1, [r0] /* Stores instruction causing data abort */
|
||||
|
||||
bl DataAbortInterrupt /*DataAbortInterrupt :call C function here */
|
||||
|
||||
ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
|
||||
|
||||
subs pc, lr, #8 /* points to the instruction that caused the Data Abort exception */
|
||||
|
||||
PrefetchAbortHandler: /* Prefetch Abort handler */
|
||||
#ifdef CONFIG_ARM_ERRATA_775420
|
||||
dsb
|
||||
#endif
|
||||
stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
|
||||
ldr r0, =PrefetchAbortAddr
|
||||
sub r1, lr, #4
|
||||
str r1, [r0] /* Stores instruction causing prefetch abort */
|
||||
|
||||
bl PrefetchAbortInterrupt /* PrefetchAbortInterrupt: call C function here */
|
||||
|
||||
ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
|
||||
|
||||
subs pc, lr, #4 /* points to the instruction that caused the Prefetch Abort exception */
|
||||
|
||||
.end
|
463
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/boot.S
Normal file
463
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/boot.S
Normal file
@ -0,0 +1,463 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2010 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file boot.S
|
||||
*
|
||||
* @addtogroup a9_boot_code Cortex A9 Processor Boot Code
|
||||
* @{
|
||||
* <h2> boot.S </h2>
|
||||
* The boot code performs minimum configuration which is required for an
|
||||
* application to run starting from processor reset state of the processor. Below is a
|
||||
* sequence illustrating what all configuration is performed before control
|
||||
* reaches to main function.
|
||||
*
|
||||
* 1. Program vector table base for exception handling
|
||||
* 2. Invalidate instruction cache, data cache and TLBs
|
||||
* 3. Program stack pointer for various modes (IRQ, FIQ, supervisor, undefine,
|
||||
* abort, system)
|
||||
* 4. Configure MMU with short descriptor translation table format and program
|
||||
* base address of translation table
|
||||
* 5. Enable data cache, instruction cache and MMU
|
||||
* 6. Enable Floating point unit
|
||||
* 7. Transfer control to _start which clears BSS sections, initializes
|
||||
* global timer and runs global constructor before jumping to main
|
||||
* application
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------- -------- ---------------------------------------------------
|
||||
* 1.00a ecm/sdm 10/20/09 Initial version
|
||||
* 3.06a sgd 05/15/12 Updated L2CC Auxiliary and Tag RAM Latency control
|
||||
* register settings.
|
||||
* 3.06a asa 06/17/12 Modified the TTBR settings and L2 Cache auxiliary
|
||||
* register settings.
|
||||
* 3.07a asa 07/16/12 Modified the L2 Cache controller settings to improve
|
||||
* performance. Changed the property of the ".boot"
|
||||
* section.
|
||||
* 3.07a sgd 08/21/12 Modified the L2 Cache controller and cp15 Aux Control
|
||||
* Register settings
|
||||
* 3.09a sgd 02/06/13 Updated SLCR l2c Ram Control register to a
|
||||
* value of 0x00020202. Fix for CR 697094 (SI#687034).
|
||||
* 3.10a srt 04/18/13 Implemented ARM Erratas. Please refer to file
|
||||
* 'xil_errata.h' for errata description
|
||||
* 4.2 pkp 06/19/14 Enabled asynchronous abort exception
|
||||
* 5.0 pkp 16/15/14 Modified initialization code to enable scu after
|
||||
* MMU is enabled
|
||||
* 5.1 pkp 05/13/15 Changed the initialization order so to first invalidate
|
||||
* caches and TLB, enable MMU and caches, then enable SMP
|
||||
* bit in ACTLR. L2Cache invalidation and enabling of L2Cache
|
||||
* is done later.
|
||||
* 5.4 asa 12/6/15 Added code to initialize SPSR for all relevant modes.
|
||||
* 6.0 mus 08/04/16 Added code to detect zynq-7000 base silicon configuration and
|
||||
* attempt to enable dual core behavior on single cpu zynq-7000s
|
||||
* devices is prevented from corrupting system behavior.
|
||||
* 6.0 mus 08/24/16 Check CPU core before putting cpu1 to reset for single core
|
||||
* zynq-7000s devices
|
||||
* 7.6 mus 09/02/21 SCU invalidation should be done only from primary CPU, so
|
||||
* skipping it when USE_AMP is set to 1. It fixes CR#1109723
|
||||
* 7.7 asa 01/06/22 Removed Cortex-A9 errata handling for errata
|
||||
* 742230 and 743622. These do not apply to
|
||||
* Cortex-A9 revision r3p0 being used in Zynq
|
||||
* platforms.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* None.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "xparameters.h"
|
||||
#include "xil_errata.h"
|
||||
|
||||
.globl MMUTable
|
||||
.global _prestart
|
||||
.global _boot
|
||||
.global __stack
|
||||
.global __irq_stack
|
||||
.global __supervisor_stack
|
||||
.global __abort_stack
|
||||
.global __fiq_stack
|
||||
.global __undef_stack
|
||||
.global _vector_table
|
||||
|
||||
.set PSS_L2CC_BASE_ADDR, 0xF8F02000
|
||||
.set PSS_SLCR_BASE_ADDR, 0xF8000000
|
||||
|
||||
.set RESERVED, 0x0fffff00
|
||||
.set TblBase , MMUTable
|
||||
.set LRemap, 0xFE00000F /* set the base address of the peripheral block as not shared */
|
||||
.set L2CCWay, (PSS_L2CC_BASE_ADDR + 0x077C) /*(PSS_L2CC_BASE_ADDR + PSS_L2CC_CACHE_INVLD_WAY_OFFSET)*/
|
||||
.set L2CCSync, (PSS_L2CC_BASE_ADDR + 0x0730) /*(PSS_L2CC_BASE_ADDR + PSS_L2CC_CACHE_SYNC_OFFSET)*/
|
||||
.set L2CCCrtl, (PSS_L2CC_BASE_ADDR + 0x0100) /*(PSS_L2CC_BASE_ADDR + PSS_L2CC_CNTRL_OFFSET)*/
|
||||
.set L2CCAuxCrtl, (PSS_L2CC_BASE_ADDR + 0x0104) /*(PSS_L2CC_BASE_ADDR + XPSS_L2CC_AUX_CNTRL_OFFSET)*/
|
||||
.set L2CCTAGLatReg, (PSS_L2CC_BASE_ADDR + 0x0108) /*(PSS_L2CC_BASE_ADDR + XPSS_L2CC_TAG_RAM_CNTRL_OFFSET)*/
|
||||
.set L2CCDataLatReg, (PSS_L2CC_BASE_ADDR + 0x010C) /*(PSS_L2CC_BASE_ADDR + XPSS_L2CC_DATA_RAM_CNTRL_OFFSET)*/
|
||||
.set L2CCIntClear, (PSS_L2CC_BASE_ADDR + 0x0220) /*(PSS_L2CC_BASE_ADDR + XPSS_L2CC_IAR_OFFSET)*/
|
||||
.set L2CCIntRaw, (PSS_L2CC_BASE_ADDR + 0x021C) /*(PSS_L2CC_BASE_ADDR + XPSS_L2CC_ISR_OFFSET)*/
|
||||
|
||||
.set SLCRlockReg, (PSS_SLCR_BASE_ADDR + 0x04) /*(PSS_SLCR_BASE_ADDR + XPSS_SLCR_LOCK_OFFSET)*/
|
||||
.set SLCRUnlockReg, (PSS_SLCR_BASE_ADDR + 0x08) /*(PSS_SLCR_BASE_ADDR + XPSS_SLCR_UNLOCK_OFFSET)*/
|
||||
.set SLCRL2cRamReg, (PSS_SLCR_BASE_ADDR + 0xA1C) /*(PSS_SLCR_BASE_ADDR + XPSS_SLCR_L2C_RAM_OFFSET)*/
|
||||
.set SLCRCPURSTReg, (0xF8000000 + 0x244) /*(XPS_SYS_CTRL_BASEADDR + A9_CPU_RST_CTRL_OFFSET)*/
|
||||
.set EFUSEStaus, (0xF800D000 + 0x10) /*(XPS_EFUSE_BASEADDR + EFUSE_STATUS_OFFSET)*/
|
||||
|
||||
/* workaround for simulation not working when L1 D and I caches,MMU and L2 cache enabled - DT568997 */
|
||||
.if SIM_MODE == 1
|
||||
.set CRValMmuCac, 0b00000000000000 /* Disable IDC, and MMU */
|
||||
.else
|
||||
.set CRValMmuCac, 0b01000000000101 /* Enable IDC, and MMU */
|
||||
.endif
|
||||
|
||||
.set CRValHiVectorAddr, 0b10000000000000 /* Set the Vector address to high, 0xFFFF0000 */
|
||||
|
||||
.set L2CCAuxControl, 0x72360000 /* Enable all prefetching, Cache replacement policy, Parity enable,
|
||||
Event monitor bus enable and Way Size (64 KB) */
|
||||
.set L2CCControl, 0x01 /* Enable L2CC */
|
||||
.set L2CCTAGLatency, 0x0111 /* latency for TAG RAM */
|
||||
.set L2CCDataLatency, 0x0121 /* latency for DATA RAM */
|
||||
|
||||
.set SLCRlockKey, 0x767B /* SLCR lock key */
|
||||
.set SLCRUnlockKey, 0xDF0D /* SLCR unlock key */
|
||||
.set SLCRL2cRamConfig, 0x00020202 /* SLCR L2C ram configuration */
|
||||
|
||||
/* Stack Pointer locations for boot code */
|
||||
.set Undef_stack, __undef_stack
|
||||
.set FIQ_stack, __fiq_stack
|
||||
.set Abort_stack, __abort_stack
|
||||
.set SPV_stack, __supervisor_stack
|
||||
.set IRQ_stack, __irq_stack
|
||||
.set SYS_stack, __stack
|
||||
|
||||
.set vector_base, _vector_table
|
||||
|
||||
.set FPEXC_EN, 0x40000000 /* FPU enable bit, (1 << 30) */
|
||||
|
||||
.section .boot,"ax"
|
||||
|
||||
|
||||
/* this initializes the various processor modes */
|
||||
|
||||
_prestart:
|
||||
_boot:
|
||||
|
||||
#if XPAR_CPU_ID==0
|
||||
/* only allow cpu0 through */
|
||||
mrc p15,0,r1,c0,c0,5
|
||||
and r1, r1, #0xf
|
||||
cmp r1, #0
|
||||
beq CheckEFUSE
|
||||
EndlessLoop0:
|
||||
wfe
|
||||
b EndlessLoop0
|
||||
|
||||
CheckEFUSE:
|
||||
ldr r0,=EFUSEStaus
|
||||
ldr r1,[r0] /* Read eFuse setting */
|
||||
ands r1,r1,#0x80 /* Check whether device is having single core */
|
||||
beq OKToRun
|
||||
|
||||
/* single core device, reset cpu1 */
|
||||
ldr r0,=SLCRUnlockReg /* Load SLCR base address base + unlock register */
|
||||
ldr r1,=SLCRUnlockKey /* set unlock key */
|
||||
str r1, [r0] /* Unlock SLCR */
|
||||
|
||||
ldr r0,=SLCRCPURSTReg
|
||||
ldr r1,[r0] /* Read CPU Software Reset Control register */
|
||||
orr r1,r1,#0x22
|
||||
str r1,[r0] /* Reset CPU1 */
|
||||
|
||||
ldr r0,=SLCRlockReg /* Load SLCR base address base + lock register */
|
||||
ldr r1,=SLCRlockKey /* set lock key */
|
||||
str r1, [r0] /* lock SLCR */
|
||||
|
||||
#elif XPAR_CPU_ID==1
|
||||
/* only allow cpu1 through */
|
||||
mrc p15,0,r1,c0,c0,5
|
||||
and r1, r1, #0xf
|
||||
cmp r1, #1
|
||||
beq CheckEFUSE1
|
||||
b EndlessLoop1
|
||||
|
||||
CheckEFUSE1:
|
||||
ldr r0,=EFUSEStaus
|
||||
ldr r1,[r0] /* Read eFuse setting */
|
||||
ands r1,r1,#0x80 /* Check whether device is having single core */
|
||||
beq OKToRun
|
||||
EndlessLoop1:
|
||||
wfe
|
||||
b EndlessLoop1
|
||||
#endif
|
||||
|
||||
OKToRun:
|
||||
mrc p15, 0, r0, c0, c0, 0 /* Get the revision */
|
||||
and r5, r0, #0x00f00000
|
||||
and r6, r0, #0x0000000f
|
||||
orr r6, r6, r5, lsr #20-4
|
||||
|
||||
/* set VBAR to the _vector_table address in linker script */
|
||||
ldr r0, =vector_base
|
||||
mcr p15, 0, r0, c12, c0, 0
|
||||
|
||||
/*invalidate scu*/
|
||||
#if USE_AMP!=1
|
||||
ldr r7, =0xf8f0000c
|
||||
ldr r6, =0xffff
|
||||
str r6, [r7]
|
||||
#endif
|
||||
|
||||
/* Invalidate caches and TLBs */
|
||||
mov r0,#0 /* r0 = 0 */
|
||||
mcr p15, 0, r0, c8, c7, 0 /* invalidate TLBs */
|
||||
mcr p15, 0, r0, c7, c5, 0 /* invalidate icache */
|
||||
mcr p15, 0, r0, c7, c5, 6 /* Invalidate branch predictor array */
|
||||
bl invalidate_dcache /* invalidate dcache */
|
||||
|
||||
/* Disable MMU, if enabled */
|
||||
mrc p15, 0, r0, c1, c0, 0 /* read CP15 register 1 */
|
||||
bic r0, r0, #0x1 /* clear bit 0 */
|
||||
mcr p15, 0, r0, c1, c0, 0 /* write value back */
|
||||
|
||||
#ifdef SHAREABLE_DDR
|
||||
/* Mark the entire DDR memory as shareable */
|
||||
ldr r3, =0x3ff /* 1024 entries to cover 1G DDR */
|
||||
ldr r0, =TblBase /* MMU Table address in memory */
|
||||
ldr r2, =0x15de6 /* S=b1 TEX=b101 AP=b11, Domain=b1111, C=b0, B=b1 */
|
||||
shareable_loop:
|
||||
str r2, [r0] /* write the entry to MMU table */
|
||||
add r0, r0, #0x4 /* next entry in the table */
|
||||
add r2, r2, #0x100000 /* next section */
|
||||
subs r3, r3, #1
|
||||
bge shareable_loop /* loop till 1G is covered */
|
||||
#endif
|
||||
|
||||
mrs r0, cpsr /* get the current PSR */
|
||||
mvn r1, #0x1f /* set up the irq stack pointer */
|
||||
and r2, r1, r0
|
||||
orr r2, r2, #0x12 /* IRQ mode */
|
||||
msr cpsr, r2
|
||||
ldr r13,=IRQ_stack /* IRQ stack pointer */
|
||||
bic r2, r2, #(0x1 << 9) /* Set EE bit to little-endian */
|
||||
msr spsr_fsxc,r2
|
||||
|
||||
mrs r0, cpsr /* get the current PSR */
|
||||
mvn r1, #0x1f /* set up the supervisor stack pointer */
|
||||
and r2, r1, r0
|
||||
orr r2, r2, #0x13 /* supervisor mode */
|
||||
msr cpsr, r2
|
||||
ldr r13,=SPV_stack /* Supervisor stack pointer */
|
||||
bic r2, r2, #(0x1 << 9) /* Set EE bit to little-endian */
|
||||
msr spsr_fsxc,r2
|
||||
|
||||
mrs r0, cpsr /* get the current PSR */
|
||||
mvn r1, #0x1f /* set up the Abort stack pointer */
|
||||
and r2, r1, r0
|
||||
orr r2, r2, #0x17 /* Abort mode */
|
||||
msr cpsr, r2
|
||||
ldr r13,=Abort_stack /* Abort stack pointer */
|
||||
bic r2, r2, #(0x1 << 9) /* Set EE bit to little-endian */
|
||||
msr spsr_fsxc,r2
|
||||
|
||||
mrs r0, cpsr /* get the current PSR */
|
||||
mvn r1, #0x1f /* set up the FIQ stack pointer */
|
||||
and r2, r1, r0
|
||||
orr r2, r2, #0x11 /* FIQ mode */
|
||||
msr cpsr, r2
|
||||
ldr r13,=FIQ_stack /* FIQ stack pointer */
|
||||
bic r2, r2, #(0x1 << 9) /* Set EE bit to little-endian */
|
||||
msr spsr_fsxc,r2
|
||||
|
||||
mrs r0, cpsr /* get the current PSR */
|
||||
mvn r1, #0x1f /* set up the Undefine stack pointer */
|
||||
and r2, r1, r0
|
||||
orr r2, r2, #0x1b /* Undefine mode */
|
||||
msr cpsr, r2
|
||||
ldr r13,=Undef_stack /* Undefine stack pointer */
|
||||
bic r2, r2, #(0x1 << 9) /* Set EE bit to little-endian */
|
||||
msr spsr_fsxc,r2
|
||||
|
||||
mrs r0, cpsr /* get the current PSR */
|
||||
mvn r1, #0x1f /* set up the system stack pointer */
|
||||
and r2, r1, r0
|
||||
orr r2, r2, #0x1F /* SYS mode */
|
||||
msr cpsr, r2
|
||||
ldr r13,=SYS_stack /* SYS stack pointer */
|
||||
|
||||
/*set scu enable bit in scu*/
|
||||
ldr r7, =0xf8f00000
|
||||
ldr r0, [r7]
|
||||
orr r0, r0, #0x1
|
||||
str r0, [r7]
|
||||
|
||||
/* enable MMU and cache */
|
||||
|
||||
ldr r0,=TblBase /* Load MMU translation table base */
|
||||
orr r0, r0, #0x5B /* Outer-cacheable, WB */
|
||||
mcr 15, 0, r0, c2, c0, 0 /* TTB0 */
|
||||
|
||||
mvn r0,#0 /* Load MMU domains -- all ones=manager */
|
||||
mcr p15,0,r0,c3,c0,0
|
||||
|
||||
/* Enable mmu, icahce and dcache */
|
||||
ldr r0,=CRValMmuCac
|
||||
mcr p15,0,r0,c1,c0,0 /* Enable cache and MMU */
|
||||
dsb /* dsb allow the MMU to start up */
|
||||
isb /* isb flush prefetch buffer */
|
||||
|
||||
/* Write to ACTLR */
|
||||
mrc p15, 0, r0, c1, c0, 1 /* Read ACTLR*/
|
||||
orr r0, r0, #(0x01 << 6) /* set SMP bit */
|
||||
orr r0, r0, #(0x01 ) /* Cache/TLB maintenance broadcast */
|
||||
mcr p15, 0, r0, c1, c0, 1 /* Write ACTLR*/
|
||||
|
||||
/* Invalidate L2 Cache and enable L2 Cache*/
|
||||
/* For AMP, assume running on CPU1. Don't initialize L2 Cache (up to Linux) */
|
||||
#if USE_AMP!=1
|
||||
ldr r0,=L2CCCrtl /* Load L2CC base address base + control register */
|
||||
mov r1, #0 /* force the disable bit */
|
||||
str r1, [r0] /* disable the L2 Caches */
|
||||
|
||||
ldr r0,=L2CCAuxCrtl /* Load L2CC base address base + Aux control register */
|
||||
ldr r1,[r0] /* read the register */
|
||||
ldr r2,=L2CCAuxControl /* set the default bits */
|
||||
orr r1,r1,r2
|
||||
str r1, [r0] /* store the Aux Control Register */
|
||||
|
||||
ldr r0,=L2CCTAGLatReg /* Load L2CC base address base + TAG Latency address */
|
||||
ldr r1,=L2CCTAGLatency /* set the latencies for the TAG*/
|
||||
str r1, [r0] /* store the TAG Latency register Register */
|
||||
|
||||
ldr r0,=L2CCDataLatReg /* Load L2CC base address base + Data Latency address */
|
||||
ldr r1,=L2CCDataLatency /* set the latencies for the Data*/
|
||||
str r1, [r0] /* store the Data Latency register Register */
|
||||
|
||||
ldr r0,=L2CCWay /* Load L2CC base address base + way register*/
|
||||
ldr r2, =0xFFFF
|
||||
str r2, [r0] /* force invalidate */
|
||||
|
||||
ldr r0,=L2CCSync /* need to poll 0x730, PSS_L2CC_CACHE_SYNC_OFFSET */
|
||||
/* Load L2CC base address base + sync register*/
|
||||
/* poll for completion */
|
||||
Sync: ldr r1, [r0]
|
||||
cmp r1, #0
|
||||
bne Sync
|
||||
|
||||
ldr r0,=L2CCIntRaw /* clear pending interrupts */
|
||||
ldr r1,[r0]
|
||||
ldr r0,=L2CCIntClear
|
||||
str r1,[r0]
|
||||
|
||||
ldr r0,=SLCRUnlockReg /* Load SLCR base address base + unlock register */
|
||||
ldr r1,=SLCRUnlockKey /* set unlock key */
|
||||
str r1, [r0] /* Unlock SLCR */
|
||||
|
||||
ldr r0,=SLCRL2cRamReg /* Load SLCR base address base + l2c Ram Control register */
|
||||
ldr r1,=SLCRL2cRamConfig /* set the configuration value */
|
||||
str r1, [r0] /* store the L2c Ram Control Register */
|
||||
|
||||
ldr r0,=SLCRlockReg /* Load SLCR base address base + lock register */
|
||||
ldr r1,=SLCRlockKey /* set lock key */
|
||||
str r1, [r0] /* lock SLCR */
|
||||
|
||||
ldr r0,=L2CCCrtl /* Load L2CC base address base + control register */
|
||||
ldr r1,[r0] /* read the register */
|
||||
mov r2, #L2CCControl /* set the enable bit */
|
||||
orr r1,r1,r2
|
||||
str r1, [r0] /* enable the L2 Caches */
|
||||
#endif
|
||||
|
||||
mov r0, r0
|
||||
mrc p15, 0, r1, c1, c0, 2 /* read cp access control register (CACR) into r1 */
|
||||
orr r1, r1, #(0xf << 20) /* enable full access for p10 & p11 */
|
||||
mcr p15, 0, r1, c1, c0, 2 /* write back into CACR */
|
||||
|
||||
/* enable vfp */
|
||||
fmrx r1, FPEXC /* read the exception register */
|
||||
orr r1,r1, #FPEXC_EN /* set VFP enable bit, leave the others in orig state */
|
||||
fmxr FPEXC, r1 /* write back the exception register */
|
||||
|
||||
mrc p15,0,r0,c1,c0,0 /* flow prediction enable */
|
||||
orr r0, r0, #(0x01 << 11) /* #0x8000 */
|
||||
mcr p15,0,r0,c1,c0,0
|
||||
|
||||
mrc p15,0,r0,c1,c0,1 /* read Auxiliary Control Register */
|
||||
orr r0, r0, #(0x1 << 2) /* enable Dside prefetch */
|
||||
orr r0, r0, #(0x1 << 1) /* enable L2 Prefetch hint */
|
||||
mcr p15,0,r0,c1,c0,1 /* write Auxiliary Control Register */
|
||||
|
||||
mrs r0, cpsr /* get the current PSR */
|
||||
bic r0, r0, #0x100 /* enable asynchronous abort exception */
|
||||
msr cpsr_xsf, r0
|
||||
|
||||
|
||||
b _start /* jump to C startup code */
|
||||
and r0, r0, r0 /* no op */
|
||||
|
||||
.Ldone: b .Ldone /* Paranoia: we should never get here */
|
||||
|
||||
|
||||
/*
|
||||
*************************************************************************
|
||||
*
|
||||
* invalidate_dcache - invalidate the entire d-cache by set/way
|
||||
*
|
||||
* Note: for Cortex-A9, there is no cp instruction for invalidating
|
||||
* the whole D-cache. Need to invalidate each line.
|
||||
*
|
||||
*************************************************************************
|
||||
*/
|
||||
invalidate_dcache:
|
||||
mrc p15, 1, r0, c0, c0, 1 /* read CLIDR */
|
||||
ands r3, r0, #0x7000000
|
||||
mov r3, r3, lsr #23 /* cache level value (naturally aligned) */
|
||||
beq finished
|
||||
mov r10, #0 /* start with level 0 */
|
||||
loop1:
|
||||
add r2, r10, r10, lsr #1 /* work out 3xcachelevel */
|
||||
mov r1, r0, lsr r2 /* bottom 3 bits are the Cache type for this level */
|
||||
and r1, r1, #7 /* get those 3 bits alone */
|
||||
cmp r1, #2
|
||||
blt skip /* no cache or only instruction cache at this level */
|
||||
mcr p15, 2, r10, c0, c0, 0 /* write the Cache Size selection register */
|
||||
isb /* isb to sync the change to the CacheSizeID reg */
|
||||
mrc p15, 1, r1, c0, c0, 0 /* reads current Cache Size ID register */
|
||||
and r2, r1, #7 /* extract the line length field */
|
||||
add r2, r2, #4 /* add 4 for the line length offset (log2 16 bytes) */
|
||||
ldr r4, =0x3ff
|
||||
ands r4, r4, r1, lsr #3 /* r4 is the max number on the way size (right aligned) */
|
||||
clz r5, r4 /* r5 is the bit position of the way size increment */
|
||||
ldr r7, =0x7fff
|
||||
ands r7, r7, r1, lsr #13 /* r7 is the max number of the index size (right aligned) */
|
||||
loop2:
|
||||
mov r9, r4 /* r9 working copy of the max way size (right aligned) */
|
||||
loop3:
|
||||
orr r11, r10, r9, lsl r5 /* factor in the way number and cache number into r11 */
|
||||
orr r11, r11, r7, lsl r2 /* factor in the index number */
|
||||
mcr p15, 0, r11, c7, c6, 2 /* invalidate by set/way */
|
||||
subs r9, r9, #1 /* decrement the way number */
|
||||
bge loop3
|
||||
subs r7, r7, #1 /* decrement the index */
|
||||
bge loop2
|
||||
skip:
|
||||
add r10, r10, #2 /* increment the cache number */
|
||||
cmp r3, r10
|
||||
bgt loop1
|
||||
|
||||
finished:
|
||||
mov r10, #0 /* switch back to cache level 0 */
|
||||
mcr p15, 2, r10, c0, c0, 0 /* select current cache level in cssr */
|
||||
dsb
|
||||
isb
|
||||
|
||||
bx lr
|
||||
|
||||
.end
|
||||
/**
|
||||
* @} End of "addtogroup a9_boot_code".
|
||||
*/
|
27
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/close.c
Normal file
27
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/close.c
Normal file
@ -0,0 +1,27 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef UNDEFINE_FILE_OPS
|
||||
#include "xil_types.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) s32 _close(s32 fd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* close -- We don't need to do anything, but pretend we did.
|
||||
*/
|
||||
|
||||
__attribute__((weak)) s32 _close(s32 fd)
|
||||
{
|
||||
(void)fd;
|
||||
return (0);
|
||||
}
|
||||
#endif
|
8
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/config.make
Normal file
8
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/config.make
Normal file
@ -0,0 +1,8 @@
|
||||
#/******************************************************************************
|
||||
#* Copyright (c) 2021 Xilinx, Inc. All rights reserved.
|
||||
#* SPDX-License-Identifier: MIT
|
||||
#******************************************************************************/
|
||||
|
||||
LIBSOURCES = *.c *.S
|
||||
PROFILE_ARCH_OBJS = profile_mcount_arm.o
|
||||
LIBS = standalone_libs
|
31
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/cpputest_time.c
Normal file
31
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/cpputest_time.c
Normal file
@ -0,0 +1,31 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2019 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef UNDEFINE_FILE_OPS
|
||||
#include <errno.h>
|
||||
#include "xil_types.h"
|
||||
#include <time.h>
|
||||
struct tms* tms;
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) clock_t _times(struct tms* tms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) clock_t _times(struct tms* tms)
|
||||
{
|
||||
(void)tms;
|
||||
|
||||
errno = EIO;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
53
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/cpu_init.S
Normal file
53
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/cpu_init.S
Normal file
@ -0,0 +1,53 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file cpu_init.S
|
||||
*
|
||||
* This file contains CPU specific initialization. Invoked from main CRT
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ------- -------- ---------------------------------------------------
|
||||
* 1.00a ecm/sdm 10/20/09 Initial version
|
||||
* 3.04a sdm 01/02/12 Updated to clear cp15 regs with unknown reset values
|
||||
* 5.0 pkp 12/16/14 removed incorrect initialization of TLB lockdown
|
||||
* register to fix CR#830580
|
||||
* </pre>
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* None.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
.text
|
||||
.global __cpu_init
|
||||
.align 2
|
||||
__cpu_init:
|
||||
|
||||
/* Clear cp15 regs with unknown reset values */
|
||||
mov r0, #0x0
|
||||
mcr p15, 0, r0, c5, c0, 0 /* DFSR */
|
||||
mcr p15, 0, r0, c5, c0, 1 /* IFSR */
|
||||
mcr p15, 0, r0, c6, c0, 0 /* DFAR */
|
||||
mcr p15, 0, r0, c6, c0, 2 /* IFAR */
|
||||
mcr p15, 0, r0, c9, c13, 2 /* PMXEVCNTR */
|
||||
mcr p15, 0, r0, c13, c0, 2 /* TPIDRURW */
|
||||
mcr p15, 0, r0, c13, c0, 3 /* TPIDRURO */
|
||||
|
||||
/* Reset and start Cycle Counter */
|
||||
mov r2, #0x80000000 /* clear overflow */
|
||||
mcr p15, 0, r2, c9, c12, 3
|
||||
mov r2, #0xd /* D, C, E */
|
||||
mcr p15, 0, r2, c9, c12, 0
|
||||
mov r2, #0x80000000 /* enable cycle counter */
|
||||
mcr p15, 0, r2, c9, c12, 1
|
||||
|
||||
bx lr
|
||||
|
||||
.end
|
29
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/errno.c
Normal file
29
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/errno.c
Normal file
@ -0,0 +1,29 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/* The errno variable is stored in the reentrancy structure. This
|
||||
function returns its address for use by the macro errno defined in
|
||||
errno.h. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <reent.h>
|
||||
#include "xil_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) sint32 * __errno (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) sint32 *
|
||||
__errno (void)
|
||||
{
|
||||
return &_REENT->_errno;
|
||||
}
|
22
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/fcntl.c
Normal file
22
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/fcntl.c
Normal file
@ -0,0 +1,22 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "xil_types.h"
|
||||
|
||||
__attribute__((weak)) sint32 fcntl (sint32 fd, sint32 cmd, LONG arg);
|
||||
|
||||
/*
|
||||
* fcntl -- Manipulate a file descriptor.
|
||||
* We don't have a filesystem, so we do nothing.
|
||||
*/
|
||||
__attribute__((weak)) sint32 fcntl (sint32 fd, sint32 cmd, LONG arg)
|
||||
{
|
||||
(void)fd;
|
||||
(void)cmd;
|
||||
(void)arg;
|
||||
return 0;
|
||||
}
|
28
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/fstat.c
Normal file
28
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/fstat.c
Normal file
@ -0,0 +1,28 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include "xil_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) s32 _fstat(s32 fd, struct stat *buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* fstat -- Since we have no file system, we just return an error.
|
||||
*/
|
||||
__attribute__((weak)) s32 _fstat(s32 fd, struct stat *buf)
|
||||
{
|
||||
(void)fd;
|
||||
buf->st_mode = S_IFCHR; /* Always pretend to be a tty */
|
||||
|
||||
return (0);
|
||||
}
|
26
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/getentropy.c
Normal file
26
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/getentropy.c
Normal file
@ -0,0 +1,26 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "xil_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) sint32 getentropy(void *buffer, sint32 length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) sint32 getentropy(void *buffer, sint32 length)
|
||||
{
|
||||
(void)buffer;
|
||||
(void)length;
|
||||
|
||||
return 0;
|
||||
}
|
30
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/getpid.c
Normal file
30
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/getpid.c
Normal file
@ -0,0 +1,30 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include "xil_types.h"
|
||||
/*
|
||||
* getpid -- only one process, so just return 1.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) s32 _getpid(void);
|
||||
__attribute__((weak)) s32 getpid(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) s32 getpid(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
__attribute__((weak)) s32 _getpid(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
18
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/inbyte.c
Normal file
18
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/inbyte.c
Normal file
@ -0,0 +1,18 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2021 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
#include "xparameters.h"
|
||||
#include "xuartps_hw.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
char inbyte(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
char inbyte(void) {
|
||||
return XUartPs_RecvByte(STDIN_BASEADDRESS);
|
||||
}
|
34
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/isatty.c
Normal file
34
bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/isatty.c
Normal file
@ -0,0 +1,34 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2009 - 2022 Xilinx, Inc. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
******************************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "xil_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) sint32 _isatty(sint32 fd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* isatty -- returns 1 if connected to a terminal device,
|
||||
* returns 0 if not. Since we're hooked up to a
|
||||
* serial port, we'll say yes _AND return a 1.
|
||||
*/
|
||||
__attribute__((weak)) sint32 isatty(sint32 fd)
|
||||
{
|
||||
(void)fd;
|
||||
return (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) sint32 _isatty(sint32 fd)
|
||||
{
|
||||
(void)fd;
|
||||
return (1);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user