Software Drivers

xdevcfg.c File Reference

#include "xdevcfg.h"

Functions

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)

Detailed Description

This file contains the implementation of the interface functions for XDcfg driver. Refer to the header file xdevcfg.h for more detailed information.

 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
 

Function Documentation

int XDcfg_CfgInitialize ( XDcfg InstancePtr,
XDcfg_Config ConfigPtr,
u32  EffectiveAddress 
)

Initialize the Device Config Interface driver. This function must be called before other functions of the driver are called.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
ConfigPtr is the config structure.
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.
Returns:
  • 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
void XDcfg_ClearControlRegister ( XDcfg InstancePtr,
u32  Mask 
)

The function Clears the specified bit positions of the Control Register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Mask is the 32 bit value which holds the bit positions to be cleared.
Returns:
None.
Note:
None.
void XDcfg_DisablePCAP ( XDcfg InstancePtr  ) 

The functions disables the PCAP interface by clearing the PCAP mode bit in the control register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Returns:
None.
Note:
None.
void XDcfg_EnablePCAP ( XDcfg InstancePtr  ) 

The functions enables the PCAP interface by setting the PCAP mode bit in the control register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Returns:
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.
u32 XDcfg_GetConfigRegister ( XDcfg InstancePtr  ) 

The function reads the contents of the Configuration Register with the given value.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Returns:
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_GetControlRegister ( XDcfg InstancePtr  ) 

The function reads the contents of the Control Register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Returns:
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_GetLockRegister ( XDcfg InstancePtr  ) 

The function reads the contents of the Lock Register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Returns:
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_GetMiscControlRegister ( XDcfg InstancePtr  ) 

The function reads the contents of the Miscellaneous Control Register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Returns:
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_GetSoftwareIdRegister ( XDcfg InstancePtr  ) 

The function reads the contents of the Software ID Register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Returns:
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_GetStatusRegister ( XDcfg InstancePtr  ) 

The function reads the contents of the Status Register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Returns:
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.
void XDcfg_InitiateDma ( XDcfg InstancePtr,
u32  SourcePtr,
u32  DestPtr,
u32  SrcWordLength,
u32  DestWordLength 
)

This function initiates the DMA transfer.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
SourcePtr contains a pointer to the source memory where the data is to be transferred from.
SrcWordLength is the number of words (32 bit) to be transferred for the source transfer.
DestPtr contains a pointer to the destination memory where the data is to be transferred to.
DestWordLength is the number of words (32 bit) to be transferred for the Destination transfer.
Returns:
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.

u32 XDcfg_IsDmaBusy ( XDcfg InstancePtr  ) 

This function checks if DMA command queue is full.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Returns:
XST_SUCCESS is the DMA is busy XST_FAILURE if the DMA is idle
Note:
The DMA queue has a depth of two.
void XDcfg_SetConfigRegister ( XDcfg InstancePtr,
u32  Data 
)

The function sets the contents of the Configuration Register with the given value.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Data is the 32 bit data to be written to the Register.
Returns:
None.
Note:
None.
void XDcfg_SetControlRegister ( XDcfg InstancePtr,
u32  Mask 
)

The function sets the contents of the Control Register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Mask is the 32 bit mask data to be written to the Register. The mask definitions are defined in the xdevcfg_hw.h file.
Returns:
None.
Note:
None.
void XDcfg_SetLockRegister ( XDcfg InstancePtr,
u32  Data 
)

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.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Data is the 32 bit data to be written to the Register.
Returns:
None.
Note:
None.
void XDcfg_SetMiscControlRegister ( XDcfg InstancePtr,
u32  Mask 
)

The function sets the bit mask for the feature in Miscellaneous Control Register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Mask is the bit-mask of the feature to be set.
Returns:
None.
Note:
None
void XDcfg_SetRomShadowRegister ( XDcfg InstancePtr,
u32  Data 
)

The function sets the contents of the ROM Shadow Control Register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Data is the 32 bit data to be written to the Register.
Returns:
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_SetStatusRegister ( XDcfg InstancePtr,
u32  Data 
)

The function sets the contents of the Status Register.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
Data is the 32 bit data to be written to the Register.
Returns:
None.
Note:
None.
u32 XDcfg_Transfer ( XDcfg InstancePtr,
void *  SourcePtr,
u32  SrcWordLength,
void *  DestPtr,
u32  DestWordLength,
u32  TransferType 
)

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.

Parameters:
InstancePtr is a pointer to the XDcfg instance.
SourcePtr contains a pointer to the source memory where the data is to be transferred from.
SrcWordLength is the number of words (32 bit) to be transferred for the source transfer.
DestPtr contains a pointer to the destination memory where the data is to be transferred to.
DestWordLength is the number of words (32 bit) to be transferred for the Destination transfer.
TransferType contains the type of PCAP transfer being requested. The definitions can be found in the xdevcfg.h file.
Returns:
  • 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.