diff --git a/bsp_z7/ps7_cortexa9_0/README.md b/bsp_z7/ps7_cortexa9_0/README.md new file mode 100644 index 0000000..b5e7492 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/README.md @@ -0,0 +1,11 @@ +This is based on the bsp of the zynq_fsbl in https://github.com/Xilinx/embeddedsw/tree/xilinx_v2024.1/lib/sw_apps/zynq_fsbl + +It is generated/collected by xilinx's build system when building the fsbl. + +Currently, version xilinx_v2024.1 is used. + +We use our own CMakeLists.txt located in the subfolders of `libsrc` to select which files to include in our bsp. + +Xilinx exports CMakeLists.txt files for some of their folders as well, which we remove to avoid confusion. + +Additionally, drivers from https://github.com/Xilinx/embeddedsw/tree/xilinx_v2024.1/XilinxProcessorIPLib/drivers are added as needed. \ No newline at end of file diff --git a/bsp_z7/ps7_cortexa9_0/include/diskio.h b/bsp_z7/ps7_cortexa9_0/include/diskio.h index 1c2b4a4..acfa0f0 100644 --- a/bsp_z7/ps7_cortexa9_0/include/diskio.h +++ b/bsp_z7/ps7_cortexa9_0/include/diskio.h @@ -9,8 +9,8 @@ extern "C" { #endif -#define USE_WRITE 1 /* 1: Enable disk_write function */ -#define USE_IOCTL 1 /* 1: Enable disk_ioctl function */ +#define USE_WRITE 1 /**< 1: Enable disk_write function */ +#define USE_IOCTL 1 /**< 1: Enable disk_ioctl function */ #include "ff.h" #include "xil_types.h" @@ -20,11 +20,11 @@ typedef BYTE DSTATUS; /* Results of Disk Functions */ typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ + RES_OK = 0, /**< 0: Successful */ + RES_ERROR, /**< 1: R/W Error */ + RES_WRPRT, /**< 2: Write Protected */ + RES_NOTRDY, /**< 3: Not Ready */ + RES_PARERR /**< 4: Invalid Parameter */ } DRESULT; @@ -41,40 +41,40 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); /* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01U /* Drive not initialized */ -#define STA_NODISK 0x02U /* No medium in the drive */ -#define STA_PROTECT 0x04U /* Write protected */ +#define STA_NOINIT 0x01U /**< Drive not initialized */ +#define STA_NODISK 0x02U /**< No medium in the drive */ +#define STA_PROTECT 0x04U /**< Write protected */ /* Command code for disk_ioctrl fucntion */ /* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0U /* Complete pending write process (needed at FF_FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1U /* Get media size (needed at FF_USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2U /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */ -#define GET_BLOCK_SIZE 3U /* Get erase block size (needed at FF_USE_MKFS == 1) */ -#define CTRL_TRIM 4U /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */ +#define CTRL_SYNC 0U /**< Complete pending write process (needed at FF_FS_READONLY == 0) */ +#define GET_SECTOR_COUNT 1U /**< Get media size (needed at FF_USE_MKFS == 1) */ +#define GET_SECTOR_SIZE 2U /**< Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */ +#define GET_BLOCK_SIZE 3U /**< Get erase block size (needed at FF_USE_MKFS == 1) */ +#define CTRL_TRIM 4U /**< Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */ /* Generic command (Not used by FatFs) */ -#define CTRL_POWER 5U /* Get/Set power status */ -#define CTRL_LOCK 6U /* Lock/Unlock media removal */ -#define CTRL_EJECT 7U /* Eject media */ -#define CTRL_FORMAT 8U /* Create physical format on the media */ +#define CTRL_POWER 5U /**< Get/Set power status */ +#define CTRL_LOCK 6U /**< Lock/Unlock media removal */ +#define CTRL_EJECT 7U /**< Eject media */ +#define CTRL_FORMAT 8U /**< Create physical format on the media */ /* MMC/SDC specific ioctl command */ -#define MMC_GET_TYPE 10U /* Get card type */ -#define MMC_GET_CSD 11U /* Get CSD */ -#define MMC_GET_CID 12U /* Get CID */ -#define MMC_GET_OCR 13U /* Get OCR */ -#define MMC_GET_SDSTAT 14U /* Get SD status */ -#define ISDIO_READ 55 /* Read data form SD iSDIO register */ -#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ -#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ +#define MMC_GET_TYPE 10U /**< Get card type */ +#define MMC_GET_CSD 11U /**< Get CSD */ +#define MMC_GET_CID 12U /**< Get CID */ +#define MMC_GET_OCR 13U /**< Get OCR */ +#define MMC_GET_SDSTAT 14U /**< Get SD status */ +#define ISDIO_READ 55 /**< Read data form SD iSDIO register */ +#define ISDIO_WRITE 56 /**< Write data to SD iSDIO register */ +#define ISDIO_MRITE 57 /**< Masked write data to SD iSDIO register */ /* ATA/CF specific ioctl command */ -#define ATA_GET_REV 20U /* Get F/W revision */ -#define ATA_GET_MODEL 21U /* Get model name */ -#define ATA_GET_SN 22U /* Get serial number */ +#define ATA_GET_REV 20U /**< Get F/W revision */ +#define ATA_GET_MODEL 21U /**< Get model name */ +#define ATA_GET_SN 22U /**< Get serial number */ #ifdef __cplusplus } diff --git a/bsp_z7/ps7_cortexa9_0/include/ff.h b/bsp_z7/ps7_cortexa9_0/include/ff.h index 6f522f9..0a0e086 100644 --- a/bsp_z7/ps7_cortexa9_0/include/ff.h +++ b/bsp_z7/ps7_cortexa9_0/include/ff.h @@ -26,8 +26,8 @@ extern "C" { #endif -#include "xil_types.h" #include "ffconf.h" /* FatFs configuration options */ +#include "xilffs.h" #if FF_DEFINED != FFCONF_DEF #error Wrong configuration file (ffconf.h). @@ -355,7 +355,7 @@ int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ -/* Some API fucntions are implemented as macro */ +/* Some API functions are implemented as macro */ #define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize)) #define f_error(fp) ((fp)->err) diff --git a/bsp_z7/ps7_cortexa9_0/include/ffconf.h b/bsp_z7/ps7_cortexa9_0/include/ffconf.h index 007d807..5a1bbe3 100644 --- a/bsp_z7/ps7_cortexa9_0/include/ffconf.h +++ b/bsp_z7/ps7_cortexa9_0/include/ffconf.h @@ -8,7 +8,11 @@ extern "C" { #endif +#ifdef SDT +#include "xilffs_config.h" +#else #include "xparameters.h" +#endif /*---------------------------------------------------------------------------/ / Function Configurations @@ -34,7 +38,7 @@ extern "C" { / 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1. / 3: f_lseek() function is removed in addition to 2. */ - +#ifdef FILE_SYSTEM_USE_STRFUNC #if FILE_SYSTEM_USE_STRFUNC == 0 #define FF_USE_STRFUNC 0 /* 0:Disable */ #elif FILE_SYSTEM_USE_STRFUNC == 1 @@ -42,6 +46,9 @@ extern "C" { #elif FILE_SYSTEM_USE_STRFUNC == 2 #define FF_USE_STRFUNC 2 /* 2:Enable */ #endif +#else +#define FF_USE_STRFUNC 0 /* 0:Disable */ +#endif /* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf(). / / 0: Disable string functions. @@ -87,7 +94,6 @@ extern "C" { /* This option switches f_forward() function. (0:Disable or 1:Enable) */ -#define FF_USE_STRFUNC 0 #define FF_PRINT_LLI 1 #define FF_PRINT_FLOAT 1 #define FF_STRF_ENCODE 3 @@ -187,7 +193,7 @@ extern "C" { / the file names to read. The maximum possible length of the read file name depends / on character encoding. When LFN is not enabled, these options have no effect. */ - +#ifdef FILE_SYSTEM_SET_FS_RPATH #if FILE_SYSTEM_SET_FS_RPATH == 0 #define FF_FS_RPATH 0U #elif FILE_SYSTEM_SET_FS_RPATH == 1 @@ -195,6 +201,9 @@ extern "C" { #elif FILE_SYSTEM_SET_FS_RPATH == 2 #define FF_FS_RPATH 2U #endif +#else +#define FF_FS_RPATH 0U +#endif /* This option configures support for relative path. / / 0: Disable relative path and remove related functions. diff --git a/bsp_z7/ps7_cortexa9_0/include/pm_api_version.h b/bsp_z7/ps7_cortexa9_0/include/pm_api_version.h new file mode 100644 index 0000000..5498048 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/include/pm_api_version.h @@ -0,0 +1,268 @@ +/****************************************************************************** +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +/*****************************************************************************/ +/** + * @file pm_api_version.h + * + * @addtogroup xpm_versal_apis XilPM APIs + *****************************************************************************/ + + +#ifndef PM_API_VERSION_H_ +#define PM_API_VERSION_H_ + +/*****************************************************************************/ +/** + * @section EEMI_API_DETAIL XilPM EEMI API Version Detail + * + * This section provides details of EEMI API version and it's history for PM APIs of XilPM library. + * + * | NAME | ID | Platform | Version| Description | + * |----------------------------|-------|---------------|:------:|---------------------------------------------------------------------------| + * | PM_GET_API_VERSION | 0x1 | Both | 1 | The API is used to request the version number of the API | + * | PM_SET_CONFIGURATION | 0x2 | ZynqMP | 1 | The API is used to configure the power management framework | + * | ^ | ^ | ^ | ^ | Note: Deprecated in Versal but supported in ZynqMP | + * | PM_GET_NODE_STATUS | 0x3 | Both | 1 | The API is used to obtain information about current status of a device | + * | PM_GET_OP_CHARACTERISTIC | 0x4 | Both | 2 | V1 - The API is used to get operating characteristics of a device | + * | ^ | ^ | ^ | ^ | V2 - Added support of bitmask functionality, user can check the supported\n "type" first before performing the actual functionality | + * | PM_REGISTER_NOTIFIER | 0x5 | Both | 2 | V1 - The API is used to register a subsystem to be notified about the\n device event | + * | ^ | ^ | ^ | ^ | V2 - Added support of event management functionality | + * | ^ | ^ | ^ | ^ | Note: V2 is supported in Versal but ZynqMP supports only V1 | + * | PM_REQUEST_SUSPEND | 0x6 | Both | 1 | The API is used to send suspend request to another subsystem | + * | PM_SELF_SUSPEND | 0x7 | Both | 3 | V1 - The API is used to suspend a child subsystem | + * | ^ | ^ | ^ | ^ | V2 - Added support of cpu idle functionality during force powerdown | + * | ^ | ^ | ^ | ^ | V3 - Added support of CPU off state | + * | ^ | ^ | ^ | ^ | Note: V3 is supported in Versal and Versal NET but ZynqMP supports only V1| + * | PM_FORCE_POWERDOWN | 0x8 | Both | 2 | V1 - The API is used to Powerdown other processor or node | + * | ^ | ^ | ^ | ^ | V2 - Added support of cpu idle functionality during force powerdown | + * | ^ | ^ | ^ | ^ | Note: V2 is supported in Versal but ZynqMP supports only V1 | + * | PM_ABORT_SUSPEND | 0x9 | Both | 1 | The API is used by a subsystem to abort suspend of a child subsystem | + * | PM_REQUEST_WAKEUP | 0xA | Both | 1 | The API is used to start-up and wake-up a child subsystem | + * | PM_SET_WAKEUP_SOURCE | 0xB | Both | 1 | The API is used to set wakeup source | + * | PM_SYSTEM_SHUTDOWN | 0xC | Both | 1 | The API is used to shutdown or restart the system | + * | PM_REQUEST_NODE | 0xD | Both | 2 | V1 - The API is used to request the usage of a device | + * | ^ | ^ | ^ | ^ | V2 - Added support of security policy handling during request device | + * | ^ | ^ | ^ | ^ | Note: V2 is supported in Versal but ZynqMP supports only V1 | + * | PM_RELEASE_NODE | 0xE | Both | 2 | V1 - The API is used to release the usage of a device | + * | ^ | ^ | ^ | ^ | V2 - Added support of security policy handling during request device | + * | ^ | ^ | ^ | ^ | Note: V2 is supported in Versal but ZynqMP supports only V1 | + * | PM_SET_REQUIREMENT | 0xF | Both | 1 | The API is used to announce a change in requirement for a specific slave\n node which is currently in use | + * | PM_SET_MAX_LATENCY | 0x10 | Both | 1 | The API is used to set maximum allowed latency for the device | + * | PM_RESET_ASSERT | 0x11 | Both | 1 | The API is used to reset or de-reset a device | + * | PM_RESET_GET_STATUS | 0x12 | Both | 1 | The API is used to read the device reset state | + * | PM_MMIO_WRITE | 0x13 | ZynqMP | 1 | The API is used to write a value into a register | + * | ^ | ^ | ^ | ^ | Note: Deprecated in Versal but supported in ZynqMP | + * | PM_MMIO_READ | 0x14 | ZynqMP | 1 | The API is used to read a value from a register | + * | ^ | ^ | ^ | ^ | Note: Deprecated in Versal but supported in ZynqMP | + * | PM_INIT_FINALIZE | 0x15 | Both | 1 | The API is used to initialize subsystem and release unused devices | + * | PM_GET_CHIPID | 0x18 | Both | 1 | The API is used to request the version and ID code of a chip | + * | PM_PINCTRL_REQUEST | 0x1C | Both | 1 | The API is used to request the pin | + * | PM_PINCTRL_RELEASE | 0x1D | Both | 1 | The API is used to release the pin | + * | PM_PINCTRL_GET_FUNCTION | 0x1E | Both | 1 | The API is used to read the pin function | + * | PM_PINCTRL_SET_FUNCTION | 0x1F | Both | 1 | The API is used to set the pin function | + * | PM_PINCTRL_CONFIG_PARAM_GET| 0x20 | Both | 1 | The API is used to read the pin parameter value | + * | PM_PINCTRL_CONFIG_PARAM_SET| 0x21 | Both | 2 | V1 - The API is used to set the pin parameter value | + * | ^ | ^ | ^ | ^ | V2 - Added support of MIO tri-state controlling functionality | + * | ^ | ^ | ^ | ^ | Note: V2 is supported in ZynqMP but Versal supports only V1 | + * | PM_IOCTL | 0x22 | Both | 3 | V1 - The API is used to perform driver-like IOCTL functions on shared\n system devices | + * | ^ | ^ | ^ | ^ | V2 - Added support of bitmask functionality, user can check the supported\n ID first before performing the actual functionality | + * | ^ | ^ | ^ | ^ | V3 - Add support of zeroization of AIE data and program memory separately | + * | ^ | ^ | ^ | ^ | Note: V3 is supported in Versal but ZynqMP supports only V2 | + * | PM_QUERY_DATA | 0x23 | Both | 2 | V1 - The API is used to query information about the platform resources | + * | ^ | ^ | ^ | ^ | V2 - Added support of bitmask functionality, user can check the supported\n ID first before performing the actual functionality | + * | PM_CLOCK_ENABLE | 0x24 | Both | 1 | The API is used to enable the clock | + * | PM_CLOCK_DISABLE | 0x25 | Both | 1 | The API is used to disable the clock | + * | PM_CLOCK_GETSTATE | 0x26 | Both | 1 | The API is used to read the clock state | + * | PM_CLOCK_SETDIVIDER | 0x27 | Both | 1 | The API is used to set the divider value of the clock | + * | PM_CLOCK_GETDIVIDER | 0x28 | Both | 1 | The API is used to read the clock divider | + * | PM_CLOCK_SETPARENT | 0x2B | Both | 1 | The API is used to set the parent of the clock | + * | PM_CLOCK_GETPARENT | 0x2C | Both | 1 | The API is used to read the clock parent | + * | PM_PLL_SET_PARAM | 0x30 | Both | 1 | The API is used to set the parameter of PLL clock | + * | PM_PLL_GET_PARAM | 0x31 | Both | 1 | The API is used to read the parameter of PLL clock | + * | PM_PLL_SET_MODE | 0x32 | Both | 1 | The API is used to set the mode of PLL clock | + * | PM_PLL_GET_MODE | 0x33 | Both | 1 | The API is used to read the mode of PLL clock | + * | PM_REGISTER_ACCESS | 0x34 | ZynqMP | 1 | The API is used for register read/write access data | + * | ^ | ^ | ^ | ^ | Note: Deprecated in Versal but supported in ZynqMP | + * | PM_EFUSE_ACCESS | 0x35 | ZynqMP | 1 | The API is used to provide access to efuse memory | + * | ^ | ^ | ^ | ^ | Note: Deprecated in Versal but supported in ZynqMP | + * | PM_FEATURE_CHECK | 0x3F | Both | 2 | V1 - The API is used to return supported version of the given API | + * | ^ | ^ | ^ | ^ | V2 - Added support of bitmask payload functionality | + * + *****************************************************************************/ + +/*****************************************************************************/ +/** + * @section IOCTL_ID_DETAIL XilPM IOCTL IDs Detail + * + * This section provides the details of the IOCTL IDs which are supported across the different platforms and their brief descriptions. + * + * | Name | ID | Platform | Description | + * |------------------------------------|-------|---------------|---------------------------------------| + * | IOCTL_GET_RPU_OPER_MODE | 0 | Both | Get RPU mode | + * | IOCTL_SET_RPU_OPER_MODE | 1 | Both | Set RPU mode | + * | IOCTL_RPU_BOOT_ADDR_CONFIG | 2 | Both | RPU boot address config | + * | IOCTL_TCM_COMB_CONFIG | 3 | Both | TCM config | + * | IOCTL_SET_TAPDELAY_BYPASS | 4 | Both | TAP delay bypass | + * | IOCTL_SD_DLL_RESET | 6 | Both | SD DLL reset | + * | IOCTL_SET_SD_TAPDELAY | 7 | Both | SD TAP delay | + * | IOCTL_SET_PLL_FRAC_MODE | 8 | Both | Set PLL frac mode | + * | IOCTL_GET_PLL_FRAC_MODE | 9 | Both | Get PLL frac mode | + * | IOCTL_SET_PLL_FRAC_DATA | 10 | Both | Set PLL frac data | + * | IOCTL_GET_PLL_FRAC_DATA | 11 | Both | Get PLL frac data | + * | IOCTL_WRITE_GGS | 12 | Both | Write GGS | + * | IOCTL_READ_GGS | 13 | Both | Read GGS | + * | IOCTL_WRITE_PGGS | 14 | Both | Write PGGS | + * | IOCTL_READ_PGGS | 15 | Both | Read PGGS | + * | IOCTL_ULPI_RESET | 16 | ZynqMP | ULPI reset | + * | IOCTL_SET_BOOT_HEALTH_STATUS | 17 | Both | Set boot status | + * | IOCTL_AFI | 18 | ZynqMP | AFI | + * | IOCTL_OSPI_MUX_SELECT | 21 | Versal | OSPI mux select | + * | IOCTL_USB_SET_STATE | 22 | Versal | USB set state | + * | IOCTL_GET_LAST_RESET_REASON | 23 | Versal | Get last reset reason | + * | IOCTL_AIE_ISR_CLEAR | 24 | Versal | AIE ISR clear | + * | IOCTL_REGISTER_SGI | 25 | None | Register SGI to ATF | + * | IOCTL_SET_FEATURE_CONFIG | 26 | ZynqMP | Set runtime feature config | + * | IOCTL_GET_FEATURE_CONFIG | 27 | ZynqMP | Get runtime feature config | + * | IOCTL_READ_REG | 28 | Versal | Read a 32-bit register | + * | IOCTL_MASK_WRITE_REG | 29 | Versal | RMW a 32-bit register | + * | IOCTL_SET_SD_CONFIG | 30 | ZynqMP | Set SD config register value | + * | IOCTL_SET_GEM_CONFIG | 31 | ZynqMP | Set GEM config register value | + * | IOCTL_SET_USB_CONFIG | 32 | ZynqMP | Set USB config register value | + * | IOCTL_AIE_OPS | 33 | Versal | AIE1/AIEML Run Time Operations | + * | IOCTL_GET_QOS | 34 | Versal | Get Device QoS value | + * | IOCTL_GET_APU_OPER_MODE | 35 | Versal | Get APU operation mode | + * | IOCTL_SET_APU_OPER_MODE | 36 | Versal | Set APU operation mode | + * | IOCTL_PREPARE_DDR_SHUTDOWN | 37 | Versal | Prepare DDR for shut down | + * | IOCTL_GET_SSIT_TEMP | 38 | Versal | Get secondary SLR min/max temperature | + * + *****************************************************************************/ + +/*****************************************************************************/ +/** + * @section QUERY_ID_DETAIL XilPM QUERY IDs Detail + * + * This section provides the details of the QUERY IDs which are supported across the different platforms and their brief descriptions. + * + * | Name | ID | Platform | Description | + * |--------------------------------------------|-------|---------------|---------------------------------------| + * | XPM_QID_INVALID | 0 | Both | Invalid Query ID | + * | XPM_QID_CLOCK_GET_NAME | 1 | Both | Get clock name | + * | XPM_QID_CLOCK_GET_TOPOLOGY | 2 | Both | Get clock topology | + * | XPM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS | 3 | Both | Get clock fixedfactor parameter | + * | XPM_QID_CLOCK_GET_MUXSOURCES | 4 | Both | Get clock mux sources | + * | XPM_QID_CLOCK_GET_ATTRIBUTES | 5 | Both | Get clock attributes | + * | XPM_QID_PINCTRL_GET_NUM_PINS | 6 | Both | Get total pins | + * | XPM_QID_PINCTRL_GET_NUM_FUNCTIONS | 7 | Both | Get total pin functions | + * | XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS | 8 | Both | Get total pin function groups | + * | XPM_QID_PINCTRL_GET_FUNCTION_NAME | 9 | Both | Get pin function name | + * | XPM_QID_PINCTRL_GET_FUNCTION_GROUPS | 10 | Both | Get pin function groups | + * | XPM_QID_PINCTRL_GET_PIN_GROUPS | 11 | Both | Get pin groups | + * | XPM_QID_CLOCK_GET_NUM_CLOCKS | 12 | Both | Get number of clocks | + * | XPM_QID_CLOCK_GET_MAX_DIVISOR | 13 | Both | Get max clock divisor | + * | XPM_QID_PLD_GET_PARENT | 14 | Versal | Get PLD parent | + * | XPM_QID_PINCTRL_GET_ATTRIBUTES | 15 | Versal | Get pin attributes | + * + *****************************************************************************/ + + +/*****************************************************************************/ +/** + * @section GET_OP_CHAR_DETAIL XilPM GET_OP_CHAR IDs Detail + * + * This section provides the details of the GET_OP_CHAR IDs which are supported across the different platforms and their brief descriptions. + * + * | Name | ID | Platform | Description | + * |------------------------------------|-------|---------------|-----------------------------------------------| + * | PM_OPCHAR_TYPE_POWER | 1 | ZynqMP | Operating characteristic ID power | + * | PM_OPCHAR_TYPE_TEMP | 2 | Versal | Operating characteristic ID temperature | + * | PM_OPCHAR_TYPE_LATENCY | 3 | Both | Operating characteristic ID latency | + * + *****************************************************************************/ + + +/** + * PM API IDs + */ +typedef enum { + PM_API_MIN, /**< 0x0 */ + PM_GET_API_VERSION, /**< 0x1 */ + PM_SET_CONFIGURATION, /**< 0x2 */ + PM_GET_NODE_STATUS, /**< 0x3 */ + PM_GET_OP_CHARACTERISTIC, /**< 0x4 */ + PM_REGISTER_NOTIFIER, /**< 0x5 */ + PM_REQUEST_SUSPEND, /**< 0x6 */ + PM_SELF_SUSPEND, /**< 0x7 */ + PM_FORCE_POWERDOWN, /**< 0x8 */ + PM_ABORT_SUSPEND, /**< 0x9 */ + PM_REQUEST_WAKEUP, /**< 0xA */ + PM_SET_WAKEUP_SOURCE, /**< 0xB */ + PM_SYSTEM_SHUTDOWN, /**< 0xC */ + PM_REQUEST_NODE, /**< 0xD */ + PM_RELEASE_NODE, /**< 0xE */ + PM_SET_REQUIREMENT, /**< 0xF */ + PM_SET_MAX_LATENCY, /**< 0x10 */ + PM_RESET_ASSERT, /**< 0x11 */ + PM_RESET_GET_STATUS, /**< 0x12 */ + PM_MMIO_WRITE, /**< 0x13 */ + PM_MMIO_READ, /**< 0x14 */ + PM_INIT_FINALIZE, /**< 0x15 */ + PM_FPGA_LOAD, /**< 0x16 */ + PM_FPGA_GET_STATUS, /**< 0x17 */ + PM_GET_CHIPID, /**< 0x18 */ + PM_SECURE_RSA_AES, /**< 0x19 */ + PM_SECURE_SHA, /**< 0x1A */ + PM_SECURE_RSA, /**< 0x1B */ + PM_PINCTRL_REQUEST, /**< 0x1C */ + PM_PINCTRL_RELEASE, /**< 0x1D */ + PM_PINCTRL_GET_FUNCTION, /**< 0x1E */ + PM_PINCTRL_SET_FUNCTION, /**< 0x1F */ + PM_PINCTRL_CONFIG_PARAM_GET, /**< 0x20 */ + PM_PINCTRL_CONFIG_PARAM_SET, /**< 0x21 */ + PM_IOCTL, /**< 0x22 */ + PM_QUERY_DATA, /**< 0x23 */ + PM_CLOCK_ENABLE, /**< 0x24 */ + PM_CLOCK_DISABLE, /**< 0x25 */ + PM_CLOCK_GETSTATE, /**< 0x26 */ + PM_CLOCK_SETDIVIDER, /**< 0x27 */ + PM_CLOCK_GETDIVIDER, /**< 0x28 */ + PM_CLOCK_SETRATE, /**< 0x29 */ + /* PM_CLOCK_GETRATE API is deprecated */ + PM_RESERVE_ID, /**< 0x2A */ + PM_CLOCK_SETPARENT, /**< 0x2B */ + PM_CLOCK_GETPARENT, /**< 0x2C */ + PM_SECURE_IMAGE, /**< 0x2D */ + PM_FPGA_READ, /**< 0x2E */ + PM_SECURE_AES, /**< 0x2F */ + PM_PLL_SET_PARAMETER, /**< 0x30 */ + PM_PLL_GET_PARAMETER, /**< 0x31 */ + PM_PLL_SET_MODE, /**< 0x32 */ + PM_PLL_GET_MODE, /**< 0x33 */ + PM_REGISTER_ACCESS, /**< 0x34 */ + PM_EFUSE_ACCESS, /**< 0x35 */ + PM_ADD_SUBSYSTEM, /**< 0x36 */ + PM_DESTROY_SUBSYSTEM, /**< 0x37 */ + PM_DESCRIBE_NODES, /**< 0x38 */ + PM_ADD_NODE, /**< 0x39 */ + PM_ADD_NODE_PARENT, /**< 0x3A */ + PM_ADD_NODE_NAME, /**< 0x3B */ + PM_ADD_REQUIREMENT, /**< 0x3C */ + PM_SET_CURRENT_SUBSYSTEM, /**< 0x3D */ + PM_INIT_NODE, /**< 0x3E */ + PM_FEATURE_CHECK, /**< 0x3F */ + PM_ISO_CONTROL, /**< 0x40 */ + PM_ACTIVATE_SUBSYSTEM, /**< 0x41 */ + PM_SET_NODE_ACCESS, /**< 0x42 */ + PM_BISR, /**< 0x43 */ + PM_APPLY_TRIM, /**< 0x44 */ + PM_NOC_CLOCK_ENABLE, /**< 0x45 */ + PM_IF_NOC_CLOCK_ENABLE, /**< 0x46 */ + PM_FORCE_HOUSECLEAN, /**< 0x47 */ + PM_FPGA_GET_VERSION, /**< 0x48 */ + PM_FPGA_GET_FEATURE_LIST, /**< 0x49 */ + PM_API_MAX /**< 0x4A */ +} XPm_ApiId; + +#endif /* PM_API_VERSION_H_ */ diff --git a/bsp_z7/ps7_cortexa9_0/include/print.c b/bsp_z7/ps7_cortexa9_0/include/print.c index e8ac3d4..cb66494 100644 --- a/bsp_z7/ps7_cortexa9_0/include/print.c +++ b/bsp_z7/ps7_cortexa9_0/include/print.c @@ -12,19 +12,22 @@ * the new terms are clearly indicated on the first page of each file where * they apply. * - */ + *****************************************************************************/ +/***************************** Include Files *********************************/ -/* - * print -- do a raw print of a string - */ #include "xil_printf.h" +/*****************************************************************************/ +/** +* print -- do a raw print of a string +* +******************************************************************************/ void print(const char8 *ptr) { #if defined (__aarch64__) && (HYP_GUEST == 1) && (EL1_NONSECURE == 1) && defined (XEN_USE_PV_CONSOLE) XPVXenConsole_Write(ptr); #else -#ifdef STDOUT_BASEADDRESS +#if defined(STDOUT_BASEADDRESS) || defined(SDT) while (*ptr != (char8)0) { outbyte (*ptr); ptr++; diff --git a/bsp_z7/ps7_cortexa9_0/include/sleep.h b/bsp_z7/ps7_cortexa9_0/include/sleep.h index 3c9c788..c41750f 100644 --- a/bsp_z7/ps7_cortexa9_0/include/sleep.h +++ b/bsp_z7/ps7_cortexa9_0/include/sleep.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (c) 2014 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2014 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -30,7 +31,8 @@ * 8.0 sk 03/17/22 Modify sleep_MB parameter type from unsigned int to * u32 and usleep_MB parameter type from unsigned long to * ULONG to fix misra_c_2012_rule_4_6 violation. -* +* 9.0 ml 03/03/23 Add description to fix doxygen warnings. +* 9.1 mus 10/24/23 Add support for RISC-V. * * ******************************************************************************/ @@ -87,6 +89,7 @@ extern "C" { (timeout>0) ? 0 : -1; \ } ) +/************************** Function Prototypes ******************************/ void usleep(ULONG useconds); void sleep(u32 seconds); void usleep_R5(ULONG useconds); @@ -97,6 +100,10 @@ int usleep_A53(unsigned long useconds); unsigned sleep_A53(unsigned int seconds); int usleep_A9(unsigned long useconds); unsigned sleep_A9(unsigned int seconds); +void sleep_riscv(u32 seconds); +void usleep_riscv(ULONG useconds); + +/*****************************************************************************/ #ifdef __cplusplus } diff --git a/bsp_z7/ps7_cortexa9_0/include/xadcps.h b/bsp_z7/ps7_cortexa9_0/include/xadcps.h index 980f394..f73ff96 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xadcps.h +++ b/bsp_z7/ps7_cortexa9_0/include/xadcps.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xadcps.h -* @addtogroup xadcps_v2_6 +* @addtogroup Overview * @{ * @details * @@ -157,6 +158,8 @@ * 2.6 aad 11/02/20 Fix MISRAC Mandatory and Advisory errors. * aad 12/17/20 Added missing function declarations and removed * functions with no definitions. +* 2.7 cog 07/24/23 Added support for SDT flow +* * * * @@ -300,7 +303,11 @@ extern "C" { * device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddress; /**< Device base address */ } XAdcPs_Config; @@ -472,7 +479,11 @@ typedef struct { /** * Functions in xadcps_sinit.c */ +#ifndef SDT XAdcPs_Config *XAdcPs_LookupConfig(u16 DeviceId); +#else +XAdcPs_Config *XAdcPs_LookupConfig(u32 BaseAddress); +#endif /** * Functions in xadcps.c diff --git a/bsp_z7/ps7_cortexa9_0/include/xadcps_hw.h b/bsp_z7/ps7_cortexa9_0/include/xadcps_hw.h index 51cc7c5..1477617 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xadcps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xadcps_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xadcps_hw.h -* @addtogroup xadcps_v2_6 +* @addtogroup Overview * @{ * * This header file contains identifiers and basic driver functions (or diff --git a/bsp_z7/ps7_cortexa9_0/include/xcortexa9.h b/bsp_z7/ps7_cortexa9_0/include/xcortexa9.h new file mode 100644 index 0000000..65a9db0 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/include/xcortexa9.h @@ -0,0 +1,18 @@ +/****************************************************************************** +* Copyright (c) 2021-2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ +#ifndef XIL_XCORTEXA9_H_ /* prevent circular inclusions */ +#define XIL_XCORTEXA9_H_ /* by using protection macros */ + +/***************************** Include Files ********************************/ + +#include "xil_types.h" + +/**************************** Type Definitions ******************************/ +typedef struct { + u32 CpuFreq; +} XCortexa9_Config; + +#endif /* XIL_XCORTEXA9_H_ */ diff --git a/bsp_z7/ps7_cortexa9_0/include/xcortexa9_config.h b/bsp_z7/ps7_cortexa9_0/include/xcortexa9_config.h new file mode 100644 index 0000000..1a774f1 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/include/xcortexa9_config.h @@ -0,0 +1,18 @@ +/****************************************************************************** +* Copyright (c) 2021-2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ +#ifndef XIL_XCORTEXA9_CONFIG_H_ /* prevent circular inclusions */ +#define XIL_XCORTEXA9_CONFIG_H_ /* by using protection macros */ + +/***************************** Include Files ********************************/ + +#include "xcortexa9.h" + +/************************** Variable Definitions ****************************/ +extern XCortexa9_Config XCortexa9_ConfigTable; + +/***************** Macros (Inline Functions) Definitions ********************/ +#define XGet_CpuFreq() XCortexa9_ConfigTable.CpuFreq +#endif /* XIL_XCORTEXA9_CONFIG_H_ */ diff --git a/bsp_z7/ps7_cortexa9_0/include/xcpu_cortexa9.h b/bsp_z7/ps7_cortexa9_0/include/xcpu_cortexa9.h index 3c23a5f..f6b3728 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xcpu_cortexa9.h +++ b/bsp_z7/ps7_cortexa9_0/include/xcpu_cortexa9.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xcpu_cortexa9.h -* @addtogroup cpu_cortexa9_v2_11 +* @addtogroup cpu_cortexa9 Overview * @{ * @details * diff --git a/bsp_z7/ps7_cortexa9_0/include/xdebug.h b/bsp_z7/ps7_cortexa9_0/include/xdebug.h index 8e6b3ef..74bfdb0 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xdebug.h +++ b/bsp_z7/ps7_cortexa9_0/include/xdebug.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2002 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -61,13 +61,13 @@ int printf(const char *format, ...); #else /* defined(DEBUG) && !defined(NDEBUG) */ -#define xdbg_stmnt(x) +#define xdbg_stmnt(x) /**< Debug statement */ /* See VxWorks comments above */ #if defined(XENV_VXWORKS) && defined(_WRS_GNU_VAR_MACROS) #define xdbg_printf(type, args...) #else /* ANSI Syntax */ -#define xdbg_printf(...) +#define xdbg_printf(...) /**< Debug printf */ #endif #endif /* defined(DEBUG) && !defined(NDEBUG) */ diff --git a/bsp_z7/ps7_cortexa9_0/include/xdevcfg.h b/bsp_z7/ps7_cortexa9_0/include/xdevcfg.h index e567699..694e3b3 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xdevcfg.h +++ b/bsp_z7/ps7_cortexa9_0/include/xdevcfg.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdevcfg.h -* @addtogroup devcfg_v3_7 +* @addtogroup devcfg Overview * @{ * @details * @@ -133,6 +134,7 @@ * 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 +* 3.8 Nava 06/21/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -178,8 +180,18 @@ typedef void (*XDcfg_IntrHandler) (void *CallBackRef, u32 Status); * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddr; /**< Base address of the device */ +#ifdef SDT + u32 IntrId; /** Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ +#endif } XDcfg_Config; /** @@ -210,7 +222,7 @@ typedef struct { *****************************************************************************/ #define XDcfg_Unlock(InstancePtr) \ XDcfg_WriteReg((InstancePtr)->Config.BaseAddr, \ - XDCFG_UNLOCK_OFFSET, XDCFG_UNLOCK_DATA) + XDCFG_UNLOCK_OFFSET, XDCFG_UNLOCK_DATA) @@ -230,8 +242,8 @@ typedef struct { #define XDcfg_GetPsVersion(InstancePtr) \ ((XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, \ XDCFG_MCTRL_OFFSET)) & \ - XDCFG_MCTRL_PCAP_PS_VERSION_MASK) >> \ - XDCFG_MCTRL_PCAP_PS_VERSION_SHIFT + XDCFG_MCTRL_PCAP_PS_VERSION_MASK) >> \ + XDCFG_MCTRL_PCAP_PS_VERSION_SHIFT @@ -250,7 +262,7 @@ typedef struct { *****************************************************************************/ #define XDcfg_ReadMultiBootConfig(InstancePtr) \ XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, \ - XDCFG_MULTIBOOT_ADDR_OFFSET) + XDCFG_MULTIBOOT_ADDR_OFFSET) /****************************************************************************/ @@ -269,8 +281,8 @@ typedef struct { *****************************************************************************/ #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))) + ((XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, XDCFG_CTRL_OFFSET)) \ + & ( ~XDCFG_CTRL_PCAP_PR_MASK))) /****************************************************************************/ /** @@ -288,8 +300,8 @@ typedef struct { *****************************************************************************/ #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)) + ((XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, XDCFG_CTRL_OFFSET)) \ + | XDCFG_CTRL_PCAP_PR_MASK)) @@ -298,7 +310,11 @@ typedef struct { /* * Lookup configuration in xdevcfg_sinit.c. */ +#ifndef SDT XDcfg_Config *XDcfg_LookupConfig(u16 DeviceId); +#else +XDcfg_Config *XDcfg_LookupConfig(UINTPTR BaseAddress); +#endif /* * Selftest function in xdevcfg_selftest.c @@ -309,7 +325,7 @@ int XDcfg_SelfTest(XDcfg *InstancePtr); * Interface functions in xdevcfg.c */ int XDcfg_CfgInitialize(XDcfg *InstancePtr, - XDcfg_Config *ConfigPtr, u32 EffectiveAddress); + XDcfg_Config *ConfigPtr, u32 EffectiveAddress); void XDcfg_EnablePCAP(XDcfg *InstancePtr); @@ -344,12 +360,12 @@ u32 XDcfg_GetMiscControlRegister(XDcfg *InstancePtr); u32 XDcfg_IsDmaBusy(XDcfg *InstancePtr); void XDcfg_InitiateDma(XDcfg *InstancePtr, u32 SourcePtr, u32 DestPtr, - u32 SrcWordLength, u32 DestWordLength); + u32 SrcWordLength, u32 DestWordLength); u32 XDcfg_Transfer(XDcfg *InstancePtr, - void *SourcePtr, u32 SrcWordLength, - void *DestPtr, u32 DestWordLength, - u32 TransferType); + void *SourcePtr, u32 SrcWordLength, + void *DestPtr, u32 DestWordLength, + u32 TransferType); /* * Interrupt related function prototypes implemented in xdevcfg_intr.c @@ -367,7 +383,7 @@ void XDcfg_IntrClear(XDcfg *InstancePtr, u32 Mask); void XDcfg_InterruptHandler(XDcfg *InstancePtr); void XDcfg_SetHandler(XDcfg *InstancePtr, void *CallBackFunc, - void *CallBackRef); + void *CallBackRef); #ifdef __cplusplus } diff --git a/bsp_z7/ps7_cortexa9_0/include/xdevcfg_hw.h b/bsp_z7/ps7_cortexa9_0/include/xdevcfg_hw.h index 1b7d881..3db7835 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xdevcfg_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xdevcfg_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdevcfg_hw.h -* @addtogroup devcfg_v3_7 +* @addtogroup devcfg Overview * @{ * * This file contains the hardware interface to the Device Config Interface. @@ -26,6 +27,7 @@ * 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. +* 3.8 Nava 06/21/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -210,14 +212,14 @@ extern "C" { * 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) + 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 @@ -266,9 +268,9 @@ extern "C" { * Status */ #define XDCFG_STATUS_EFUSE_BBRAM_KEY_DISABLE_MASK 0x00000008 - /**< BBRAM key - * disable - */ +/**< BBRAM key + * disable + */ #define XDCFG_STATUS_EFUSE_SEC_EN_MASK 0x00000004 /**< Efuse Security * Enable Status */ diff --git a/bsp_z7/ps7_cortexa9_0/include/xdmaps.h b/bsp_z7/ps7_cortexa9_0/include/xdmaps.h index 179c840..4b98640 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xdmaps.h +++ b/bsp_z7/ps7_cortexa9_0/include/xdmaps.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdmaps.h -* @addtogroup dmaps_v2_8 +* @addtogroup dmaps Overview * @{ * @details * @@ -60,6 +61,7 @@ * 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. +* 2.9 aj 11/07/23 Added support for system device tree * * *****************************************************************************/ @@ -88,8 +90,19 @@ extern "C" { * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddress; /**< Base address of device (IPIF) */ + +#ifdef SDT + u32 IntrId[9]; /** Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ +#endif } XDmaPs_Config; @@ -169,15 +182,15 @@ typedef struct { * It's the done handler a user can set for a channel */ typedef void (*XDmaPsDoneHandler) (unsigned int Channel, - XDmaPs_Cmd *DmaCmd, - void *CallbackRef); + 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); + XDmaPs_Cmd *DmaCmd, + void *CallbackRef); #define XDMAPS_MAX_CHAN_BUFS 2 #define XDMAPS_CHAN_BUF_LEN 128 @@ -236,18 +249,18 @@ typedef struct { * Functions implemented in xdmaps.c */ int XDmaPs_CfgInitialize(XDmaPs *InstPtr, - XDmaPs_Config *Config, - u32 EffectiveAddr); + XDmaPs_Config *Config, + u32 EffectiveAddr); int XDmaPs_Start(XDmaPs *InstPtr, unsigned int Channel, - XDmaPs_Cmd *Cmd, - int HoldDmaProg); + XDmaPs_Cmd *Cmd, + int HoldDmaProg); int XDmaPs_IsActive(XDmaPs *InstPtr, unsigned int Channel); int XDmaPs_GenDmaProg(XDmaPs *InstPtr, unsigned int Channel, - XDmaPs_Cmd *Cmd); + XDmaPs_Cmd *Cmd); int XDmaPs_FreeDmaProg(XDmaPs *InstPtr, unsigned int Channel, - XDmaPs_Cmd *Cmd); + XDmaPs_Cmd *Cmd); void XDmaPs_Print_DmaProg(XDmaPs_Cmd *Cmd); @@ -256,13 +269,13 @@ int XDmaPs_ResetChannel(XDmaPs *InstPtr, unsigned int Channel); int XDmaPs_SetDoneHandler(XDmaPs *InstPtr, - unsigned Channel, - XDmaPsDoneHandler DoneHandler, - void *CallbackRef); + unsigned Channel, + XDmaPsDoneHandler DoneHandler, + void *CallbackRef); int XDmaPs_SetFaultHandler(XDmaPs *InstPtr, - XDmaPsFaultHandler FaultHandler, - void *CallbackRef); + XDmaPsFaultHandler FaultHandler, + void *CallbackRef); void XDmaPs_Print_DmaProg(XDmaPs_Cmd *Cmd); int XDmaPs_Instr_DMARMB(char *DmaProg); @@ -276,10 +289,10 @@ int XDmaPs_Instr_DMAWMB(char *DmaProg); 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); + 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); + 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); @@ -312,7 +325,12 @@ void XDmaPs_FaultISR(XDmaPs *InstPtr); /* * Static loopup function implemented in xdmaps_sinit.c */ +#ifndef SDT XDmaPs_Config *XDmaPs_LookupConfig(u16 DeviceId); +#else +XDmaPs_Config *XDmaPs_LookupConfig(UINTPTR BaseAddress); +u32 XDmaPs_GetDrvIndex(XDmaPs *InstancePtr, UINTPTR BaseAddress); +#endif /* diff --git a/bsp_z7/ps7_cortexa9_0/include/xdmaps_hw.h b/bsp_z7/ps7_cortexa9_0/include/xdmaps_hw.h index d039278..32c2c91 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xdmaps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xdmaps_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdmaps_hw.h -* @addtogroup dmaps_v2_8 +* @addtogroup dmaps Overview * @{ * * This header file contains the hardware interface of an XDmaPs device. @@ -233,7 +234,7 @@ extern "C" { #define XDMAPS_INTCLR_ALL_MASK 0xFF #define XDmaPs_ReadReg(BaseAddress, RegOffset) \ - Xil_In32((BaseAddress) + (RegOffset)) + Xil_In32((BaseAddress) + (RegOffset)) /***************************************************************************/ /** @@ -251,7 +252,7 @@ extern "C" { * u32 RegisterValue) ******************************************************************************/ #define XDmaPs_WriteReg(BaseAddress, RegOffset, RegisterValue) \ - Xil_Out32((BaseAddress) + (RegOffset), (RegisterValue)) + Xil_Out32((BaseAddress) + (RegOffset), (RegisterValue)) /************************** Variable Definitions *****************************/ /************************** Function Prototypes *****************************/ diff --git a/bsp_z7/ps7_cortexa9_0/include/xemacps.h b/bsp_z7/ps7_cortexa9_0/include/xemacps.h index ac3e7a7..564d926 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xemacps.h +++ b/bsp_z7/ps7_cortexa9_0/include/xemacps.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps.h -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * @details * @@ -417,15 +418,15 @@ extern "C" { #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) + ((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 */ /*@}*/ @@ -456,11 +457,11 @@ extern "C" { #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) + XEMACPS_TRL_SIZE) #define XEMACPS_MAX_VLAN_FRAME_SIZE (XEMACPS_MTU + XEMACPS_HDR_SIZE + \ - XEMACPS_HDR_VLAN_SIZE + XEMACPS_TRL_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) + XEMACPS_HDR_VLAN_SIZE + XEMACPS_TRL_SIZE) /* DMACR Bust length hash defines */ @@ -500,7 +501,7 @@ typedef void (*XEmacPs_Handler) (void *CallBackRef); * */ typedef void (*XEmacPs_ErrHandler) (void *CallBackRef, u8 Direction, - u32 ErrorWord); + u32 ErrorWord); /*@}*/ @@ -508,12 +509,25 @@ typedef void (*XEmacPs_ErrHandler) (void *CallBackRef, u8 Direction, * This typedef contains configuration information for a device. */ typedef struct { +#ifdef SDT + char *Name; /**< Unique name of the device */ +#else u16 DeviceId; /**< Unique ID of device */ +#endif 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) +#ifdef SDT + u16 IntrId; + UINTPTR IntrParent; +#endif +#if defined (XCLOCKING) || defined (SDT) u32 RefClk; /**< Input clock */ +#endif +#ifdef SDT + char *PhyType; /**< PhyType indicates which type of PHY interface is + * used (MII, GMII, RGMII, etc. + */ #endif u16 S1GDiv0; /**< 1Gbps Clock Divider 0 */ u8 S1GDiv1; /**< 1Gbps Clock Divider 1 */ @@ -606,8 +620,8 @@ typedef struct XEmacPs_Instance { *****************************************************************************/ #define XEmacPs_IntEnable(InstancePtr, Mask) \ XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_IER_OFFSET, \ - ((Mask) & XEMACPS_IXR_ALL_MASK)); + XEMACPS_IER_OFFSET, \ + ((Mask) & XEMACPS_IXR_ALL_MASK)); /****************************************************************************/ /** @@ -627,8 +641,8 @@ typedef struct XEmacPs_Instance { *****************************************************************************/ #define XEmacPs_IntDisable(InstancePtr, Mask) \ XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_IDR_OFFSET, \ - ((Mask) & XEMACPS_IXR_ALL_MASK)); + XEMACPS_IDR_OFFSET, \ + ((Mask) & XEMACPS_IXR_ALL_MASK)); /****************************************************************************/ /** @@ -648,8 +662,8 @@ typedef struct XEmacPs_Instance { *****************************************************************************/ #define XEmacPs_IntQ1Enable(InstancePtr, Mask) \ XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_INTQ1_IER_OFFSET, \ - ((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK)); + XEMACPS_INTQ1_IER_OFFSET, \ + ((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK)); /****************************************************************************/ /** @@ -669,8 +683,8 @@ typedef struct XEmacPs_Instance { *****************************************************************************/ #define XEmacPs_IntQ1Disable(InstancePtr, Mask) \ XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_INTQ1_IDR_OFFSET, \ - ((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK)); + XEMACPS_INTQ1_IDR_OFFSET, \ + ((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK)); /****************************************************************************/ /** @@ -687,10 +701,10 @@ typedef struct XEmacPs_Instance { * *****************************************************************************/ #define XEmacPs_Transmit(InstancePtr) \ - XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_NWCTRL_OFFSET, \ - (XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_NWCTRL_OFFSET) | XEMACPS_NWCTRL_STARTTX_MASK)) + XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_NWCTRL_OFFSET, \ + (XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_NWCTRL_OFFSET) | XEMACPS_NWCTRL_STARTTX_MASK)) /****************************************************************************/ /** @@ -711,9 +725,9 @@ typedef struct XEmacPs_Instance { * *****************************************************************************/ #define XEmacPs_IsRxCsum(InstancePtr) \ - ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_NWCFG_OFFSET) & XEMACPS_NWCFG_RXCHKSUMEN_MASK) != 0U \ - ? TRUE : FALSE) + ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_NWCFG_OFFSET) & XEMACPS_NWCFG_RXCHKSUMEN_MASK) != 0U \ + ? TRUE : FALSE) /****************************************************************************/ /** @@ -734,9 +748,9 @@ typedef struct XEmacPs_Instance { * *****************************************************************************/ #define XEmacPs_IsTxCsum(InstancePtr) \ - ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_DMACR_OFFSET) & XEMACPS_DMACR_TCPCKSUM_MASK) != 0U \ - ? TRUE : FALSE) + ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_DMACR_OFFSET) & XEMACPS_DMACR_TCPCKSUM_MASK) != 0U \ + ? TRUE : FALSE) /************************** Function Prototypes *****************************/ @@ -761,10 +775,10 @@ typedef struct XEmacPs_Instance { * *****************************************************************************/ #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) |) + XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_RXWATERMARK_OFFSET, \ + (High & XEMACPS_RXWM_HIGH_MASK) | \ + ((Low << XEMACPS_RXWM_LOW_SHFT_MSK) & XEMACPS_RXWM_LOW_MASK) |) /****************************************************************************/ /** @@ -781,8 +795,8 @@ typedef struct XEmacPs_Instance { * *****************************************************************************/ #define XEmacPs_GetRXWatermark(InstancePtr) \ - XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_RXWATERMARK_OFFSET) + XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_RXWATERMARK_OFFSET) /* * Initialization functions in xemacps.c */ @@ -797,7 +811,12 @@ void XEmacPs_SetQueuePtr(XEmacPs *InstancePtr, UINTPTR QPtr, u8 QueueNum, /* * Lookup configuration in xemacps_sinit.c */ + +#ifndef SDT XEmacPs_Config *XEmacPs_LookupConfig(u16 DeviceId); +#else +XEmacPs_Config *XEmacPs_LookupConfig(UINTPTR BaseAddress); +#endif /* * Interrupt-related functions in xemacps_intr.c @@ -823,7 +842,7 @@ void XEmacPs_ClearHash(XEmacPs *InstancePtr); void XEmacPs_GetHash(XEmacPs *InstancePtr, void *AddressPtr); void XEmacPs_SetMdioDivisor(XEmacPs *InstancePtr, - XEmacPs_MdcDiv Divisor); + XEmacPs_MdcDiv Divisor); void XEmacPs_SetOperatingSpeed(XEmacPs *InstancePtr, u16 Speed); u16 XEmacPs_GetOperatingSpeed(XEmacPs *InstancePtr); LONG XEmacPs_PhyRead(XEmacPs *InstancePtr, u32 PhyAddress, diff --git a/bsp_z7/ps7_cortexa9_0/include/xemacps_bd.h b/bsp_z7/ps7_cortexa9_0/include/xemacps_bd.h index aff79ff..4641553 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xemacps_bd.h +++ b/bsp_z7/ps7_cortexa9_0/include/xemacps_bd.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps_bd.h -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * This header provides operations to manage buffer descriptors in support @@ -45,6 +46,7 @@ * 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. + * 3.9 aj 22/03/24 Add mask for XEmaPs_BdGetBufAddr * * * @@ -239,11 +241,11 @@ typedef u32 XEmacPs_Bd[XEMACPS_BD_NUM_WORDS]; *****************************************************************************/ #if defined(__aarch64__) || defined(__arch64__) #define XEmacPs_BdGetBufAddr(BdPtr) \ - (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) | \ + ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) & XEMACPS_RXBUF_ADD_MASK) | \ (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_HI_OFFSET)) << 32U) #else #define XEmacPs_BdGetBufAddr(BdPtr) \ - (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET)) + (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) & XEMACPS_RXBUF_ADD_MASK) #endif /*****************************************************************************/ diff --git a/bsp_z7/ps7_cortexa9_0/include/xemacps_bdring.h b/bsp_z7/ps7_cortexa9_0/include/xemacps_bdring.h index f5653db..017669d 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xemacps_bdring.h +++ b/bsp_z7/ps7_cortexa9_0/include/xemacps_bdring.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps_bdring.h -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * The Xiline EmacPs Buffer Descriptor ring driver. This is part of EmacPs diff --git a/bsp_z7/ps7_cortexa9_0/include/xemacps_hw.h b/bsp_z7/ps7_cortexa9_0/include/xemacps_hw.h index 59fe1ec..765411d 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xemacps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xemacps_hw.h @@ -8,7 +8,7 @@ /** * * @file xemacps_hw.h -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * This header file contains identifiers and low-level driver functions (or diff --git a/bsp_z7/ps7_cortexa9_0/include/xgpiops.h b/bsp_z7/ps7_cortexa9_0/include/xgpiops.h index 8b1d89f..cce171a 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xgpiops.h +++ b/bsp_z7/ps7_cortexa9_0/include/xgpiops.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -124,6 +124,11 @@ * 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. +* 3.12 gm 07/11/23 Added SDT support. +* 3.13 gm 03/15/24 Remove const of XGpioPs InstancePtr from function proto +* type of XGpioPs_IntrEnable, XGpioPs_IntrDisable, +* XGpioPs_IntrEnablePin and XGpioPs_IntrDisablePin +* to add multi-core interrupt support. * * * @@ -167,6 +172,7 @@ extern "C" { * Zynq Ultrascale+ MP GPIO device */ #define XGPIOPS_MAX_BANKS 0x04U /**< Max banks in a Zynq GPIO device */ +#define XGPIOPS_MAX_BANKS_CNT 0x06U /**< Max banks number of all platforms */ #define XGPIOPS_DEVICE_MAX_PIN_NUM_ZYNQMP (u32)174 /**< Max pins in the * Zynq Ultrascale+ MP GPIO device @@ -209,8 +215,18 @@ typedef void (*XGpioPs_Handler) (void *CallBackRef, u32 Bank, u32 Status); * This typedef contains configuration information for a device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif UINTPTR BaseAddr; /**< Register base address */ +#ifdef SDT + u16 IntrId; /** Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ +#endif } XGpioPs_Config; /** @@ -227,6 +243,7 @@ typedef struct { 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*/ + u32 CoreIntrMask[XGPIOPS_MAX_BANKS_CNT]; /**< Interrupt mask per core */ } XGpioPs; /************************** Variable Definitions *****************************/ @@ -262,12 +279,12 @@ void XGpioPs_SetOutputEnablePin(const XGpioPs *InstancePtr, u32 Pin, u32 OpEnabl u32 XGpioPs_GetOutputEnablePin(const XGpioPs *InstancePtr, u32 Pin); /* Diagnostic functions in xgpiops_selftest.c */ -s32 XGpioPs_SelfTest(const XGpioPs *InstancePtr); +s32 XGpioPs_SelfTest(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); +void XGpioPs_IntrEnable(XGpioPs *InstancePtr, u8 Bank, u32 Mask); +void XGpioPs_IntrDisable(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); @@ -283,14 +300,18 @@ void XGpioPs_IntrHandler(const XGpioPs *InstancePtr); 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); +void XGpioPs_IntrEnablePin(XGpioPs *InstancePtr, u32 Pin); +void XGpioPs_IntrDisablePin(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 */ +#ifndef SDT XGpioPs_Config *XGpioPs_LookupConfig(u16 DeviceId); +#else +XGpioPs_Config *XGpioPs_LookupConfig(u32 BaseAddress); +#endif #ifdef __cplusplus } #endif diff --git a/bsp_z7/ps7_cortexa9_0/include/xgpiops_hw.h b/bsp_z7/ps7_cortexa9_0/include/xgpiops_hw.h index d291abb..3248dc2 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xgpiops_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xgpiops_hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ diff --git a/bsp_z7/ps7_cortexa9_0/include/xil_cache.h b/bsp_z7/ps7_cortexa9_0/include/xil_cache.h index 75cd6f6..7c94568 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xil_cache.h +++ b/bsp_z7/ps7_cortexa9_0/include/xil_cache.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (c) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -26,6 +27,7 @@ * 3.04a sdm 01/02/12 Remove redundant dsb/dmb instructions in cache maintenance * APIs. * 6.8 aru 09/06/18 Removed compilation warnings for ARMCC toolchain. +* 9.0 ml 03/03/23 Updated function prototypes. * * ******************************************************************************/ diff --git a/bsp_z7/ps7_cortexa9_0/include/xil_cryptoalginfo.h b/bsp_z7/ps7_cortexa9_0/include/xil_cryptoalginfo.h new file mode 100644 index 0000000..df95b88 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/include/xil_cryptoalginfo.h @@ -0,0 +1,50 @@ +/******************************************************************************/ +/** +* Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +/****************************************************************************/ +/** +* @file xil_cryptoalginfo.h +* @{ +* @details +* +* Crypto algotithm information structure declaration. +* +*
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- -------- -------- ----------------------------------------------- +* 9.0 mmd 07/04/23 First release. +*+* +*****************************************************************************/ +#ifndef XIL_CRYPTOALGINFO_H +#define XIL_CRYPTOALGINFO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************** Include Files *********************************/ +#include "xil_types.h" + +/**************************** Type Definitions *******************************/ +typedef enum _Xil_CryptoAlgNistStatus { + NOT_APPLICABLE = 0x00, + NIST_COMPLIANT = 0x11, + NIST_NON_COMPLIANT = 0xFE, +} Xil_CryptoAlgNistStatus; + +typedef struct _Xil_CryptoAlgInfo { + u32 Version; + Xil_CryptoAlgNistStatus NistStatus; +} Xil_CryptoAlgInfo; + +#ifdef __cplusplus +} +#endif + +#endif /* XIL_CRYPTOALGINFO_H */ diff --git a/bsp_z7/ps7_cortexa9_0/include/xil_exception.h b/bsp_z7/ps7_cortexa9_0/include/xil_exception.h index 3a5bb29..b517983 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xil_exception.h +++ b/bsp_z7/ps7_cortexa9_0/include/xil_exception.h @@ -75,8 +75,10 @@ #include "xil_types.h" #include "xpseudo_asm.h" #include "bspconfig.h" +#ifndef SDT #include "xparameters.h" #include "xdebug.h" +#endif #ifdef __cplusplus extern "C" { @@ -228,7 +230,7 @@ extern "C" { /* * XIL_EXCEPTION_ID_INT is defined for all Xilinx processors. */ -#if (defined (versal) && !defined(ARMR5) && EL3) || defined(ARMR52) +#if (defined (versal) && !defined(ARMR5) && EL3) #define XIL_EXCEPTION_ID_INT XIL_EXCEPTION_ID_FIQ_INT #else #define XIL_EXCEPTION_ID_INT XIL_EXCEPTION_ID_IRQ_INT @@ -267,7 +269,7 @@ extern XExc_VectorTableEntry XExc_VectorTable[]; * C-Style signature: void Xil_ExceptionEnableMask(Mask) * ******************************************************************************/ -#if (defined (versal) && !defined(ARMR5) && EL3) || defined(ARMR52) +#if (defined (versal) && !defined(ARMR5) && EL3) /* * Cortexa72 processor in versal is coupled with GIC-500, and GIC-500 supports * only FIQ at EL3. Hence, tweaking this macro to always enable FIQ @@ -295,7 +297,7 @@ extern XExc_VectorTableEntry XExc_VectorTable[]; * @note None. * ******************************************************************************/ -#if (defined (versal) && !defined(ARMR5) && EL3) || defined(ARMR52) +#if (defined (versal) && !defined(ARMR5) && EL3) #define Xil_ExceptionEnable() \ Xil_ExceptionEnableMask(XIL_EXCEPTION_FIQ) #else @@ -315,7 +317,7 @@ extern XExc_VectorTableEntry XExc_VectorTable[]; * C-Style signature: Xil_ExceptionDisableMask(Mask) * ******************************************************************************/ -#if (defined (versal) && !defined(ARMR5) && EL3) || defined(ARMR52) +#if (defined (versal) && !defined(ARMR5) && EL3) /* * Cortexa72 processor in versal is coupled with GIC-500, and GIC-500 supports * only FIQ at EL3. Hence, tweaking this macro to always disable FIQ diff --git a/bsp_z7/ps7_cortexa9_0/include/xil_io.h b/bsp_z7/ps7_cortexa9_0/include/xil_io.h index 853ef6b..382bc87 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xil_io.h +++ b/bsp_z7/ps7_cortexa9_0/include/xil_io.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (c) 2014 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2014 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -32,12 +33,12 @@ * 7.50 dp 02/12/21 Fix compilation error in Xil_EndianSwap32() that occur * when -Werror=conversion compiler flag is enabled * 7.5 mus 05/17/21 Update the functions with comments. It fixes CR#1067739. -* +* 9.0 ml 03/03/23 Add description and remove comments to fix doxygen warnings. * ******************************************************************************/ -#ifndef XIL_IO_H /* prevent circular inclusions */ -#define XIL_IO_H /* by using protection macros */ +#ifndef XIL_IO_H /**< prevent circular inclusions */ +#define XIL_IO_H /**< by using protection macros */ #ifdef __cplusplus extern "C" { @@ -63,25 +64,25 @@ extern u32 XStl_RegUpdate(u32 RegAddr, u32 RegVal); /***************** Macros (Inline Functions) Definitions *********************/ #if defined __GNUC__ #if defined (__MICROBLAZE__) -# define INST_SYNC mbar(0) -# define DATA_SYNC mbar(1) +# define INST_SYNC mbar(0) /**< Instruction Synchronization Barrier */ +# define DATA_SYNC mbar(1) /**< Data Synchronization Barrier */ # else -# define SYNCHRONIZE_IO dmb() -# define INST_SYNC isb() -# define DATA_SYNC dsb() +# define SYNCHRONIZE_IO dmb() /**< Data Memory Barrier */ +# define INST_SYNC isb() /**< Instruction Synchronization Barrier */ +# define DATA_SYNC dsb() /**< Data Synchronization Barrier */ # endif #else -# define SYNCHRONIZE_IO -# define INST_SYNC -# define DATA_SYNC -# define INST_SYNC -# define DATA_SYNC +# define SYNCHRONIZE_IO /**< Data Memory Barrier */ +# define INST_SYNC /**< Instruction Synchronization Barrier */ +# define DATA_SYNC /**< Data Synchronization Barrier */ +# define INST_SYNC /**< Instruction Synchronization Barrier */ +# define DATA_SYNC /**< Data Synchronization Barrier */ #endif #if defined (__GNUC__) || defined (__ICCARM__) || defined (__MICROBLAZE__) -#define INLINE inline +#define INLINE inline /**< static inline keyword */ #else -#define INLINE __inline +#define INLINE __inline /**
+ * MODIFICATION HISTORY: + * + * Ver Who Date Changes + * ----- ---- -------- ------------------------------------------------------- + * 5.2 ht 10/10/23 Added code for versioning of library. + * + *+ * + *@note + *****************************************************************************/ +#ifndef XILFFS_H +#define XILFFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************** Include Files *********************************/ +#include "xil_util.h" +#include "xil_io.h" +#include "xil_types.h" + +/************************** Constant Definitions *****************************/ +/* Library version info */ +#define XILFFS_MAJOR_VERSION 5U +#define XILFFS_MINOR_VERSION 2U + +/****************** Macros (Inline Functions) Definitions *********************/ + +/*****************************************************************************/ +/** + * + * @brief This function returns the version number of xilffs library. + * + * @return 32-bit version number + * +******************************************************************************/ +static __attribute__((always_inline)) INLINE +u32 Xilffs_GetLibVersion(void) +{ + return (XIL_BUILD_VERSION(XILFFS_MAJOR_VERSION, XILFFS_MINOR_VERSION)); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* XILFFS_H */ diff --git a/bsp_z7/ps7_cortexa9_0/include/xparameters.h b/bsp_z7/ps7_cortexa9_0/include/xparameters.h index f032659..511b0f2 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xparameters.h +++ b/bsp_z7/ps7_cortexa9_0/include/xparameters.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (c) 2021 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ #ifndef XPARAMETERS_H /* prevent circular inclusions */ @@ -7,7 +8,6 @@ /* Definition for CPU ID */ #define XPAR_CPU_ID 0U -//#define USE_AMP 0U TODO having this to 0 breaks xil_cache /* Definitions for peripheral PS7_CORTEXA9_0 */ #define XPAR_PS7_CORTEXA9_0_CPU_CLK_FREQ_HZ 666666687 @@ -23,17 +23,8 @@ #include "xparameters_ps.h" -// Default is for Zedboard -#ifndef ZYNQ_USE_UART0 -#define STDIN_BASEADDRESS XPS_UART1_BASEADDR -#define STDIN_INT_NR XPAR_XUARTPS_1_INTR -#define STDOUT_BASEADDRESS XPS_UART1_BASEADDR -#else -#define STDIN_BASEADDRESS XPS_UART0_BASEADDR -#define STDIN_INT_NR XPAR_XUARTPS_0_INTR -#define STDOUT_BASEADDRESS XPS_UART0_BASEADDR -#endif - +#define STDIN_BASEADDRESS 0xE0001000 +#define STDOUT_BASEADDRESS 0xE0001000 /******************************************************************/ @@ -357,6 +348,7 @@ #define XPAR_PS7_SD_0_CLK_50_DDR_OTAP_DLY 0 #define XPAR_PS7_SD_0_CLK_100_SDR_OTAP_DLY 0 #define XPAR_PS7_SD_0_CLK_200_SDR_OTAP_DLY 0 +#define XPAR_PS7_SD_0_CLK_200_DDR_OTAP_DLY 0 /******************************************************************/ @@ -380,6 +372,7 @@ #define XPAR_XSDPS_0_CLK_50_DDR_OTAP_DLY 0 #define XPAR_XSDPS_0_CLK_100_SDR_OTAP_DLY 0 #define XPAR_XSDPS_0_CLK_200_SDR_OTAP_DLY 0 +#define XPAR_XSDPS_0_CLK_200_DDR_OTAP_DLY 0 /******************************************************************/ @@ -428,8 +421,8 @@ /* Definitions for peripheral PS7_UART_1 */ #define XPAR_PS7_UART_1_DEVICE_ID 0 -#define XPAR_PS7_UART_1_BASEADDR 0xE0001000 -#define XPAR_PS7_UART_1_HIGHADDR 0xE0001FFF +#define XPAR_PS7_UART_1_BASEADDR 0xE0000000 +#define XPAR_PS7_UART_1_HIGHADDR 0xE0000FFF #define XPAR_PS7_UART_1_UART_CLK_FREQ_HZ 50000000 #define XPAR_PS7_UART_1_HAS_MODEM 0 @@ -438,8 +431,8 @@ /* Canonical definitions for peripheral PS7_UART_1 */ #define XPAR_XUARTPS_0_DEVICE_ID XPAR_PS7_UART_1_DEVICE_ID -#define XPAR_XUARTPS_0_BASEADDR 0xE0001000 -#define XPAR_XUARTPS_0_HIGHADDR 0xE0001FFF +#define XPAR_XUARTPS_0_BASEADDR 0xE0000000 +#define XPAR_XUARTPS_0_HIGHADDR 0xE0000FFF #define XPAR_XUARTPS_0_UART_CLK_FREQ_HZ 50000000 #define XPAR_XUARTPS_0_HAS_MODEM 0 diff --git a/bsp_z7/ps7_cortexa9_0/include/xplatform_info.c b/bsp_z7/ps7_cortexa9_0/include/xplatform_info.c index 83692d8..bdb7c6a 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xplatform_info.c +++ b/bsp_z7/ps7_cortexa9_0/include/xplatform_info.c @@ -43,6 +43,9 @@ * reported with "-Wundef" flag CR#1111453 * 8.1 mus 02/13/23 Added new API's XGetCoreId and XGetClusterId. As of now * they are supported only for VERSAL_NET APU and RPU. +* 9.0 mus 03/28/23 Added new API XGetBootStatus for VERSAL_NET. It can be +* used to identify type of boot (cold/warm). +* 9.0 mus 07/27/23 Updated XGetCoreId API to support A9, R5 and A53 processor. * * ******************************************************************************/ @@ -102,17 +105,17 @@ u32 XGet_Zynq_UltraMp_Platform_info(void) { #if defined (__aarch64__) && (EL1_NONSECURE == 1) XSmc_OutVar reg; - /* + /* * This SMC call will return, - * idcode - upper 32 bits of reg.Arg0 - * version - lower 32 bits of reg.Arg1 + * idcode - upper 32 bits of reg.Arg0 + * version - lower 32 bits of reg.Arg1 */ - reg = Xil_Smc(GET_CHIPID_SMC_FID,0,0, 0, 0, 0, 0, 0); + reg = Xil_Smc(GET_CHIPID_SMC_FID, 0, 0, 0, 0, 0, 0, 0); return (u32)((reg.Arg1 >> XPLAT_INFO_SHIFT) & XPLAT_INFO_MASK); #else u32 reg; reg = ((Xil_In32(XPLAT_PS_VERSION_ADDRESS) >> XPLAT_INFO_SHIFT ) - & XPLAT_INFO_MASK); + & XPLAT_INFO_MASK); return reg; #endif } @@ -130,24 +133,71 @@ u32 XGet_Zynq_UltraMp_Platform_info(void) u32 XGetPSVersion_Info(void) { #if defined (__aarch64__) && (EL1_NONSECURE == 1) - /* - * This SMC call will return, - * idcode - upper 32 bits of reg.Arg0 - * version - lower 32 bits of reg.Arg1 - */ - XSmc_OutVar reg; - reg = Xil_Smc(GET_CHIPID_SMC_FID,0,0, 0, 0, 0, 0, 0); - return (u32)((reg.Arg1 & XPS_VERSION_INFO_MASK) >> - XPS_VERSION_INFO_SHIFT); + /* + * This SMC call will return, + * idcode - upper 32 bits of reg.Arg0 + * version - lower 32 bits of reg.Arg1 + */ + XSmc_OutVar reg; + reg = Xil_Smc(GET_CHIPID_SMC_FID, 0, 0, 0, 0, 0, 0, 0); + return (u32)((reg.Arg1 & XPS_VERSION_INFO_MASK) >> + XPS_VERSION_INFO_SHIFT); #else u32 reg; reg = (Xil_In32(XPLAT_PS_VERSION_ADDRESS) - & XPS_VERSION_INFO_MASK); + & XPS_VERSION_INFO_MASK); return (reg >> XPS_VERSION_INFO_SHIFT); #endif } #endif +#if ! defined(__microblaze__) && ! defined(__riscv) +/*****************************************************************************/ +/** +* +* @brief This API is used to provide infomation about core id of the +* CPU core from which it is executed. +* +* @return Core id of the core on which API is executed. +* +******************************************************************************/ +u8 XGetCoreId(void) +{ + UINTPTR CoreId; + +#if (defined (__aarch64__) && ! defined (VERSAL_NET)) + /* CortexA53 and CortexA72 */ + CoreId = (mfcp(MPIDR_EL1) & XREG_MPIDR_MASK); + CoreId = ((CoreId & XREG_MPIDR_AFFINITY0_MASK) >> \ + XREG_MPIDR_AFFINITY0_SHIFT); +#elif (defined (__aarch64__) && defined (VERSAL_NET)) + /* CortexA78 */ + CoreId = (mfcp(MPIDR_EL1) & XREG_MPIDR_MASK); + CoreId = ((CoreId & XREG_MPIDR_AFFINITY0_MASK) >> \ + XREG_MPIDR_AFFINITY0_SHIFT); +#else + /* CortexA9, CortexR5 and CortexR52 */ +#ifdef __GNUC__ + CoreId = (mfcp(XREG_CP15_MULTI_PROC_AFFINITY) & XREG_MPIDR_MASK); +#elif defined (__ICCARM__) + mfcp(XREG_CP15_MULTI_PROC_AFFINITY, CoreId); + CoreId &= XREG_MPIDR_MASK; +#else + { + register u32 C15Reg __asm(XREG_CP15_MULTI_PROC_AFFINITY); + CoreId = C15Reg; + } + CoreId &= XREG_MPIDR_MASK; +#endif + + CoreId = ((CoreId & XREG_MPIDR_AFFINITY0_MASK) >> \ + XREG_MPIDR_AFFINITY0_SHIFT); +#endif + + return (u8)CoreId; +} +#endif + #if (defined (__aarch64__) && defined (VERSAL_NET)) || defined (ARMR52) /*****************************************************************************/ /** @@ -165,11 +215,11 @@ u8 XGetClusterId(void) #if defined (ARMR52) ClusterId = (mfcp(XREG_CP15_MULTI_PROC_AFFINITY) & XREG_MPIDR_MASK); ClusterId = ((ClusterId & XREG_MPIDR_AFFINITY1_MASK) >> \ - XREG_MPIDR_AFFINITY1_SHIFT); + XREG_MPIDR_AFFINITY1_SHIFT); #else ClusterId = (mfcp(MPIDR_EL1) & XREG_MPIDR_MASK); ClusterId = ((ClusterId & XREG_MPIDR_AFFINITY2_MASK) >> \ - XREG_MPIDR_AFFINITY2_SHIFT); + XREG_MPIDR_AFFINITY2_SHIFT); #endif return (u8)ClusterId; @@ -178,27 +228,38 @@ u8 XGetClusterId(void) /*****************************************************************************/ /** * -* @brief This API is used to provide infomation about core id of the -* CPU core from which it is executed. +* @brief This API returns boot status of core from which it is executed. +* 0th bit of CORE_X_PWRDWN/RPU_PCIL_X_PWRDWN register indicates boot type. * -* @return Core id of the core on which API is executed. +* @return - 0 for cold boot +* - 1 for warm boot * ******************************************************************************/ -u8 XGetCoreId(void) +u8 XGetBootStatus(void) { - u64 CoreId; + u32 Status; + UINTPTR Addr; -#if defined (ARMR52) - CoreId = (mfcp(XREG_CP15_MULTI_PROC_AFFINITY) & XREG_MPIDR_MASK); - CoreId = ((CoreId & XREG_MPIDR_AFFINITY0_MASK) >> \ - XREG_MPIDR_AFFINITY0_SHIFT); +#if (__aarch64__) + u8 CpuNum; + + CpuNum = XGetClusterId(); + CpuNum *= XPS_NUM_OF_CORES_PER_CLUSTER; + CpuNum += XGetCoreId(); + + Addr = XPS_CORE_X_PWRDWN_BASEADDR + (CpuNum * XPS_CORE_X_PWRDWN_OFFSET); + Status = Xil_In32(Addr); + + return (Status & XPS_CORE_X_PWRDWN_EN_MASK); #else - CoreId = (mfcp(MPIDR_EL1) & XREG_MPIDR_MASK); - CoreId = ((CoreId & XREG_MPIDR_AFFINITY1_MASK) >> \ - XREG_MPIDR_AFFINITY1_SHIFT); + Addr = (XPS_RPU_PCIL_CLUSTER_OFFSET * XGetClusterId()) + XPS_RPU_PCIL_A0_PWRDWN; + Addr += (XGetCoreId() * XPS_RPU_PCIL_CORE_OFFSET); + + Status = Xil_In32(Addr); + + return (Status & XPS_RPU_PCIL_X_PWRDWN_EN_MASK); #endif - return (u8)CoreId; } #endif diff --git a/bsp_z7/ps7_cortexa9_0/include/xplatform_info.h b/bsp_z7/ps7_cortexa9_0/include/xplatform_info.h index 3e5df15..251a697 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xplatform_info.h +++ b/bsp_z7/ps7_cortexa9_0/include/xplatform_info.h @@ -36,6 +36,11 @@ * misra_c_2012_rule_10_4 violation. * 8.1 mus 02/13/23 Added new API's XGetCoreId and XGetClusterId. As of now * they are supported only for VERSAL_NET APU and RPU. +* 9.0 mus 03/28/23 Added new API XGetBootStatus for VERSAL_NET. It can be +* used to identify type of boot (cold/warm). +* 9.0 mus 07/27/23 Updated XGetCoreId API to support A9, R5 and A53 processor +* 9.0 ml 09/14/23 Added U to numerical to fix MISRA-C violation for Rule +* 10.1 and 10.4 * * ******************************************************************************/ @@ -60,12 +65,12 @@ extern "C" { #define XPAR_PMC_TAP_BASEADDR 0xF11A0000U #define XPAR_PMC_TAP_VERSION_OFFSET 0x00000004U #define XPLAT_PS_VERSION_ADDRESS (XPAR_PMC_TAP_BASEADDR + \ - XPAR_PMC_TAP_VERSION_OFFSET) + XPAR_PMC_TAP_VERSION_OFFSET) #else #define XPAR_CSU_BASEADDR 0xFFCA0000U #define XPAR_CSU_VER_OFFSET 0x00000044U #define XPLAT_PS_VERSION_ADDRESS (XPAR_CSU_BASEADDR + \ - XPAR_CSU_VER_OFFSET) + XPAR_CSU_VER_OFFSET) #endif #define XPLAT_ZYNQ_ULTRA_MP_SILICON 0x0 #define XPLAT_ZYNQ_ULTRA_MP 0x1 @@ -84,11 +89,37 @@ extern "C" { #define XPS_VERSION_INFO_SHIFT 0x8U #define XPLAT_INFO_SHIFT 0x18U #else -#define XPS_VERSION_INFO_MASK (0xF) +#define XPS_VERSION_INFO_MASK 0xFU #define XPS_VERSION_INFO_SHIFT 0x0U #define XPLAT_INFO_SHIFT 0xCU #endif +#if defined (VERSAL_NET) +#if defined (ARMR52) +#define XPS_NUM_OF_CORES_PER_CLUSTER 2U +#define XPS_RPU_PCIL_A0_PWRDWN 0xEB4200C0U +/* + * Offset between RPU_PCIL_X_PWRDWN registers of consecutive + * CPU cores in given cluster + */ +#define XPS_RPU_PCIL_CORE_OFFSET 0x100U + +/* + * Offset between RPU_PCIL_A0_PWRDWN registers of 2 clusters + */ +#define XPS_RPU_PCIL_CLUSTER_OFFSET 0x1000U +#define XPS_RPU_PCIL_X_PWRDWN_EN_MASK 1U +#else +#define XPS_NUM_OF_CORES_PER_CLUSTER 4U +#define XPS_CORE_X_PWRDWN_BASEADDR 0xECB10000U +/* + * Offset between CORE_X_PWRDWN registers of consecutive + * CPU cores + */ +#define XPS_CORE_X_PWRDWN_OFFSET 48U +#define XPS_CORE_X_PWRDWN_EN_MASK 1U +#endif +#endif /**************************** Type Definitions *******************************/ /** *@endcond @@ -97,6 +128,9 @@ extern "C" { u32 XGetPlatform_Info(void); +#if ! defined(__microblaze__) && ! defined(__riscv) +u8 XGetCoreId(void); +#endif #if defined (ARMR5) || defined (__aarch64__) || defined (ARMA53_32) || defined (PSU_PMU) || defined (versal) u32 XGetPSVersion_Info(void); @@ -109,6 +143,7 @@ u32 XGet_Zynq_UltraMp_Platform_info(void); #if (defined (__aarch64__) && defined (VERSAL_NET)) || defined (ARMR52) u8 XGetClusterId(void); u8 XGetCoreId(void); +u8 XGetBootStatus(void); #endif /************************** Function Prototypes ******************************/ diff --git a/bsp_z7/ps7_cortexa9_0/include/xpm_init.h b/bsp_z7/ps7_cortexa9_0/include/xpm_init.h new file mode 100644 index 0000000..f2856be --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/include/xpm_init.h @@ -0,0 +1,46 @@ +/****************************************************************************** +*Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +*SPDX-License-Identifier: MIT +******************************************************************************/ + +/*****************************************************************************/ +/** +* +* @file xpm_init.h +* @addtogroup xpm_init xpm_init APIs +*
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- -------- -------- ----------------------------------------------- +* 1.0 gm 14/06/23 Initial release. +*+******************************************************************************/ + +#ifndef XPM_INIT_H +#define XPM_INIT_H + +/************************** Constant Definitions *****************************/ + +#if defined (XPM_SUPPORT) +#ifdef VERSAL_NET +#define MAX_NODE_COUNT 38 +#elif defined(versal) +#define MAX_NODE_COUNT 33 +#endif + +/**************************** Type Definitions *******************************/ + +typedef struct { + UINTPTR BaseAddress; + UINTPTR NodeId; + UINTPTR ResetId; +} XpmNodeInfo; + +/************************** Function Prototypes ******************************/ + +UINTPTR XpmGetNodeId(UINTPTR BaseAddress); +UINTPTR XpmGetResetId(UINTPTR BaseAddress); + +#endif +#endif diff --git a/bsp_z7/ps7_cortexa9_0/include/xpseudo_asm_gcc.h b/bsp_z7/ps7_cortexa9_0/include/xpseudo_asm_gcc.h index b8517d3..5721b4c 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xpseudo_asm_gcc.h +++ b/bsp_z7/ps7_cortexa9_0/include/xpseudo_asm_gcc.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (c) 2014 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -23,6 +23,7 @@ * 7.2 dp 04/30/20 Added clobber "cc" to mtcpsr for aarch32 processors * 8.0 mus 02/24/22 Added macro mfcpnotoken and mtcpnotoken. * 8.1 asa 02/13/23 Create macros to read ESR, FAR and ELR registers. +* 9.1 ml 11/15/23 Fix compilation errors reported with -std=c2x compiler flag * * ******************************************************************************/ @@ -56,9 +57,9 @@ extern "C" { #if defined (__aarch64__) /* pseudo assembler instructions */ #define mfcpsr() ({u32 rval = 0U; \ - asm volatile("mrs %0, DAIF" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, DAIF" : "=r" (rval));\ + rval;\ + }) #define mtcpsr(v) __asm__ __volatile__ ("msr DAIF, %0" : : "r" (v)) @@ -68,12 +69,10 @@ extern "C" { #define cpsief() //__asm__ __volatile__("cpsie f\n") #define cpsidf() //__asm__ __volatile__("cpsid f\n") - - #define mtgpr(rn, v) /*__asm__ __volatile__(\ "mov r" stringify(rn) ", %0 \n"\ : : "r" (v)\ - )*/ +)*/ #define mfgpr(rn) /*({u32 rval; \ __asm__ __volatile__(\ @@ -81,7 +80,7 @@ extern "C" { : "=r" (rval)\ );\ rval;\ - })*/ +})*/ /* memory synchronization operations */ @@ -94,47 +93,45 @@ extern "C" { /* Data Memory Barrier */ #define dmb() __asm__ __volatile__("dmb sy") - /* Memory Operations */ #define ldr(adr) ({u64 rval; \ - __asm__ __volatile__(\ - "ldr %0,[%1]"\ - : "=r" (rval) : "r" (adr)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "ldr %0,[%1]"\ + : "=r" (rval) : "r" (adr)\ + );\ + rval;\ + }) #if (EL3 == 1) #define mfelrel3() ({u64 rval = 0U; \ - asm volatile("mrs %0, ELR_EL3" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, ELR_EL3" : "=r" (rval));\ + rval;\ + }) #define mfesrel3() ({u64 rval = 0U; \ - asm volatile("mrs %0, ESR_EL3" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, ESR_EL3" : "=r" (rval));\ + rval;\ + }) #define mffarel3() ({u64 rval = 0U; \ - asm volatile("mrs %0, FAR_EL3" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, FAR_EL3" : "=r" (rval));\ + rval;\ + }) #else #define mfelrel1() ({u64 rval = 0U; \ - asm volatile("mrs %0, ELR_EL1" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, ELR_EL1" : "=r" (rval));\ + rval;\ + }) #define mfesrel1() ({u64 rval = 0U; \ - asm volatile("mrs %0, ESR_EL1" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, ESR_EL1" : "=r" (rval));\ + rval;\ + }) #define mffarel1() ({u64 rval = 0U; \ - asm volatile("mrs %0, FAR_EL1" : "=r" (rval));\ - rval;\ - }) - + __asm volatile("mrs %0, FAR_EL1" : "=r" (rval));\ + rval;\ + }) #endif @@ -144,17 +141,17 @@ extern "C" { /* pseudo assembler instructions */ #define mfcpsr() ({u32 rval = 0U; \ - __asm__ __volatile__(\ - "mrs %0, cpsr\n"\ - : "=r" (rval)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "mrs %0, cpsr\n"\ + : "=r" (rval)\ + );\ + rval;\ + }) #define mtcpsr(v) __asm__ __volatile__(\ - "msr cpsr,%0\n"\ - : : "r" (v) : "cc" \ - ) + "msr cpsr,%0\n"\ + : : "r" (v) : "cc" \ + ) #define cpsiei() __asm__ __volatile__("cpsie i\n") #define cpsidi() __asm__ __volatile__("cpsid i\n") @@ -162,20 +159,18 @@ extern "C" { #define cpsief() __asm__ __volatile__("cpsie f\n") #define cpsidf() __asm__ __volatile__("cpsid f\n") - - #define mtgpr(rn, v) __asm__ __volatile__(\ - "mov r" stringify(rn) ", %0 \n"\ - : : "r" (v)\ - ) + "mov r" stringify(rn) ", %0 \n"\ + : : "r" (v)\ + ) #define mfgpr(rn) ({u32 rval; \ - __asm__ __volatile__(\ - "mov %0,r" stringify(rn) "\n"\ - : "=r" (rval)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "mov %0,r" stringify(rn) "\n"\ + : "=r" (rval)\ + );\ + rval;\ + }) /* memory synchronization operations */ @@ -188,44 +183,43 @@ extern "C" { /* Data Memory Barrier */ #define dmb() __asm__ __volatile__ ("dmb" : : : "memory") - /* Memory Operations */ #define ldr(adr) ({u32 rval; \ - __asm__ __volatile__(\ - "ldr %0,[%1]"\ - : "=r" (rval) : "r" (adr)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "ldr %0,[%1]"\ + : "=r" (rval) : "r" (adr)\ + );\ + rval;\ + }) #endif #define ldrb(adr) ({u8 rval; \ - __asm__ __volatile__(\ - "ldrb %0,[%1]"\ - : "=r" (rval) : "r" (adr)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "ldrb %0,[%1]"\ + : "=r" (rval) : "r" (adr)\ + );\ + rval;\ + }) #define strw(adr, val) __asm__ __volatile__(\ - "str %0,[%1]\n"\ - : : "r" (val), "r" (adr)\ - ) + "str %0,[%1]\n"\ + : : "r" (val), "r" (adr)\ + ) #define strb(adr, val) __asm__ __volatile__(\ - "strb %0,[%1]\n"\ - : : "r" (val), "r" (adr)\ - ) + "strb %0,[%1]\n"\ + : : "r" (val), "r" (adr)\ + ) /* Count leading zeroes (clz) */ #define clz(arg) ({u8 rval; \ - __asm__ __volatile__(\ - "clz %0,%1"\ - : "=r" (rval) : "r" (arg)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "clz %0,%1"\ + : "=r" (rval) : "r" (arg)\ + );\ + rval;\ + }) #if defined (__aarch64__) #define mtcpdc(reg,val) __asm__ __volatile__("dc " #reg ",%0" : : "r" (val)) @@ -236,14 +230,14 @@ extern "C" { #define mtcpat(reg,val) __asm__ __volatile__("at " #reg ",%0" : : "r" (val)) /* CP15 operations */ #define mfcp(reg) ({u64 rval = 0U;\ - __asm__ __volatile__("mrs %0, " #reg : "=r" (rval));\ - rval;\ - }) + __asm__ __volatile__("mrs %0, " #reg : "=r" (rval));\ + rval;\ + }) #define mfcpnotoken(reg) ({u64 rval = 0U;\ - __asm__ __volatile__("mrs %0, " reg : "=r" (rval));\ - rval;\ - }) + __asm__ __volatile__("mrs %0, " reg : "=r" (rval));\ + rval;\ + }) #define mtcp(reg,val) __asm__ __volatile__("msr " #reg ",%0" : : "r" (val)) #define mtcpnotoken(reg,val) __asm__ __volatile__("msr " reg ",%0" : : "r" (val)) @@ -251,22 +245,22 @@ extern "C" { #else /* CP15 operations */ #define mtcp(rn, v) __asm__ __volatile__(\ - "mcr " rn "\n"\ - : : "r" (v)\ - ); + "mcr " rn "\n"\ + : : "r" (v)\ + ); #define mfcp(rn) ({u32 rval = 0U; \ - __asm__ __volatile__(\ - "mrc " rn "\n"\ - : "=r" (rval)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "mrc " rn "\n"\ + : "=r" (rval)\ + );\ + rval;\ + }) #define mtcp2(rn, v) __asm__ __volatile__(\ - "mcrr " rn "\n"\ - : : "r" (v), "r" (0)\ - ); + "mcrr " rn "\n"\ + : : "r" (v), "r" (0)\ + ); #endif diff --git a/bsp_z7/ps7_cortexa9_0/include/xqspips.h b/bsp_z7/ps7_cortexa9_0/include/xqspips.h index d7bae80..11540d1 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xqspips.h +++ b/bsp_z7/ps7_cortexa9_0/include/xqspips.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xqspips.h -* @addtogroup qspips_v3_10 +* @addtogroup qspips Overview * @{ * @details * @@ -270,6 +271,8 @@ * 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. +* 3.11 akm 07/10/23 Update the driver to support for system device-tree flow. +* 3.12 sb 02/20/24 Add missing parenthesis for macro expansions. * * * @@ -478,16 +481,26 @@ extern "C" { * requested if the status event indicates an error. */ typedef void (*XQspiPs_StatusHandler) (void *CallBackRef, u32 StatusEvent, - unsigned ByteCount); + unsigned ByteCount); /** * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddress; /**< Base address of the device */ u32 InputClockHz; /**< Input clock frequency */ u8 ConnectionMode; /**< Single, Stacked and Parallel mode */ +#ifdef SDT + u32 IntrId; /**< Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /**< Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ +#endif } XQspiPs_Config; /** @@ -571,7 +584,7 @@ typedef struct { *****************************************************************************/ #define XQspiPs_SetSlaveIdle(InstancePtr, RegisterValue) \ XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ - XQSPIPS_SICR_OFFSET, (RegisterValue)) + XQSPIPS_SICR_OFFSET, (RegisterValue)) /****************************************************************************/ /** @@ -589,7 +602,7 @@ typedef struct { *****************************************************************************/ #define XQspiPs_GetSlaveIdle(InstancePtr) \ XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + \ - XQSPIPS_SICR_OFFSET) + XQSPIPS_SICR_OFFSET) /****************************************************************************/ /** @@ -608,7 +621,7 @@ typedef struct { *****************************************************************************/ #define XQspiPs_SetTXWatermark(InstancePtr, RegisterValue) \ XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ - XQSPIPS_TXWR_OFFSET, (RegisterValue)) + XQSPIPS_TXWR_OFFSET, (RegisterValue)) /****************************************************************************/ /** @@ -625,7 +638,7 @@ typedef struct { * *****************************************************************************/ #define XQspiPs_GetTXWatermark(InstancePtr) \ - XQspiPs_In32((InstancePtr->Config.BaseAddress) + XQSPIPS_TXWR_OFFSET) + XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_TXWR_OFFSET) /****************************************************************************/ /** @@ -644,7 +657,7 @@ typedef struct { *****************************************************************************/ #define XQspiPs_SetRXWatermark(InstancePtr, RegisterValue) \ XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ - XQSPIPS_RXWR_OFFSET, (RegisterValue)) + XQSPIPS_RXWR_OFFSET, (RegisterValue)) /****************************************************************************/ /** @@ -661,7 +674,7 @@ typedef struct { * *****************************************************************************/ #define XQspiPs_GetRXWatermark(InstancePtr) \ - XQspiPs_In32((InstancePtr->Config.BaseAddress) + XQSPIPS_RXWR_OFFSET) + XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_RXWR_OFFSET) /****************************************************************************/ /** @@ -677,8 +690,8 @@ typedef struct { * *****************************************************************************/ #define XQspiPs_Enable(InstancePtr) \ - XQspiPs_Out32((InstancePtr->Config.BaseAddress) + XQSPIPS_ER_OFFSET, \ - XQSPIPS_ER_ENABLE_MASK) + XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_ER_OFFSET, \ + XQSPIPS_ER_ENABLE_MASK) /****************************************************************************/ /** @@ -694,7 +707,7 @@ typedef struct { * *****************************************************************************/ #define XQspiPs_Disable(InstancePtr) \ - XQspiPs_Out32((InstancePtr->Config.BaseAddress) + XQSPIPS_ER_OFFSET, 0) + XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_ER_OFFSET, 0) /****************************************************************************/ /** @@ -714,7 +727,7 @@ typedef struct { *****************************************************************************/ #define XQspiPs_SetLqspiConfigReg(InstancePtr, RegisterValue) \ XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ - XQSPIPS_LQSPI_CR_OFFSET, (RegisterValue)) + XQSPIPS_LQSPI_CR_OFFSET, (RegisterValue)) /****************************************************************************/ /** @@ -731,35 +744,39 @@ typedef struct { * *****************************************************************************/ #define XQspiPs_GetLqspiConfigReg(InstancePtr) \ - XQspiPs_In32((InstancePtr->Config.BaseAddress) + \ - XQSPIPS_LQSPI_CR_OFFSET) + XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + \ + XQSPIPS_LQSPI_CR_OFFSET) /************************** Function Prototypes ******************************/ /* * Initialization function, implemented in xqspips_sinit.c */ +#ifndef SDT XQspiPs_Config *XQspiPs_LookupConfig(u16 DeviceId); +#else +XQspiPs_Config *XQspiPs_LookupConfig(UINTPTR BaseAddress); +#endif /* * Functions implemented in xqspips.c */ int XQspiPs_CfgInitialize(XQspiPs *InstancePtr, XQspiPs_Config *Config, - u32 EffectiveAddr); + u32 EffectiveAddr); void XQspiPs_Reset(XQspiPs *InstancePtr); void XQspiPs_Abort(XQspiPs *InstancePtr); s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, - u32 ByteCount); + u32 ByteCount); s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, - u8 *RecvBufPtr, u32 ByteCount); + u8 *RecvBufPtr, u32 ByteCount); int XQspiPs_LqspiRead(XQspiPs *InstancePtr, u8 *RecvBufPtr, - u32 Address, unsigned ByteCount); + u32 Address, unsigned ByteCount); int XQspiPs_SetSlaveSelect(XQspiPs *InstancePtr); void XQspiPs_SetStatusHandler(XQspiPs *InstancePtr, void *CallBackRef, - XQspiPs_StatusHandler FuncPtr); + XQspiPs_StatusHandler FuncPtr); void XQspiPs_InterruptHandler(void *InstancePtr); /* @@ -777,9 +794,9 @@ 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); + u8 DelayAfter, u8 DelayInit); void XQspiPs_GetDelays(XQspiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn, - u8 *DelayAfter, u8 *DelayInit); + u8 *DelayAfter, u8 *DelayInit); #ifdef __cplusplus } #endif diff --git a/bsp_z7/ps7_cortexa9_0/include/xqspips_hw.h b/bsp_z7/ps7_cortexa9_0/include/xqspips_hw.h index ab50675..a136a2f 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xqspips_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xqspips_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xqspips_hw.h -* @addtogroup qspips_v3_10 +* @addtogroup qspips Overview * @{ * * This header file contains the identifiers and basic HW access driver @@ -117,18 +118,18 @@ extern "C" { /* 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 + 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 + 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 /* @} */ diff --git a/bsp_z7/ps7_cortexa9_0/include/xreg_cortexa9.h b/bsp_z7/ps7_cortexa9_0/include/xreg_cortexa9.h index 2a4fff2..0d2c7b1 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xreg_cortexa9.h +++ b/bsp_z7/ps7_cortexa9_0/include/xreg_cortexa9.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (c) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -20,6 +21,7 @@ * Ver Who Date Changes * ----- -------- -------- ----------------------------------------------- * 1.00a ecm/sdm 10/20/09 First release +* 9.0 mus 07/29/23 Added definitions for processor affinity register. * * ******************************************************************************/ @@ -489,7 +491,10 @@ extern "C" { #define XREG_CP15_MAIN_TLB_ATTR "cp15:5:c15:c7:2" #endif - +/* Affinity register bits */ +#define XREG_MPIDR_MASK 0xFFFFFFFFU +#define XREG_MPIDR_AFFINITY0_MASK 0x3U +#define XREG_MPIDR_AFFINITY0_SHIFT 0x0U /* MPE register definitions */ #define XREG_FPSID c0 #define XREG_FPSCR c1 diff --git a/bsp_z7/ps7_cortexa9_0/include/xscugic.h b/bsp_z7/ps7_cortexa9_0/include/xscugic.h index 0ee7342..3eb2f65 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xscugic.h +++ b/bsp_z7/ps7_cortexa9_0/include/xscugic.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,56 +8,10 @@ /** * * @file xscugic.h -* @addtogroup scugic Overview +* @addtogroup scugic_api SCUGIC APIs * @{ * @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. -* -* Interrupt Vector Tables -* -* 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. -* -* Nested Interrupts Processing -* -* 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. * *
* MODIFICATION HISTORY: @@ -190,12 +144,14 @@ * executed, redistributor address will be stored in newly * added member of XScuGic data structure "RedistBaseAddr". * It fixes CR#1150432. +* 5.2 ml 03/02/23 Add description to fix Doxygen warnings. +* 5.2 adk 04/14/23 Added support for system device-tree flow. ** ******************************************************************************/ -#ifndef XSCUGIC_H /* prevent circular inclusions */ -#define XSCUGIC_H /* by using protection macros */ +#ifndef XSCUGIC_H /**< prevent circular inclusions */ +#define XSCUGIC_H /**< by using protection macros */ #ifdef __cplusplus extern "C" { @@ -212,13 +168,23 @@ extern "C" { /************************** Constant Definitions *****************************/ +/** + * @name EFUSE status Register information + * EFUSE Status Register + * @{ + */ #define EFUSE_STATUS_OFFSET 0x10 #define EFUSE_STATUS_CPU_MASK 0x80 #if !defined (ARMR5) && !defined (__aarch64__) && !defined (ARMA53_32) -#define ARMA9 +#define ARMA9 /**< ARMA9 macro to identify cortexA9 */ #endif +/** + * @name GICD_CTLR Register information + * GICD_CTLR Status Register + * @{ + */ #define XSCUGIC500_DCTLR_ARE_NS_ENABLE 0x20 #define XSCUGIC500_DCTLR_ARE_S_ENABLE 0x10 @@ -245,8 +211,12 @@ extern "C" { */ typedef struct { - Xil_InterruptHandler Handler; - void *CallBackRef; + Xil_InterruptHandler Handler; /**< Interrupt Handler */ + void *CallBackRef; /**< CallBackRef is the callback reference passed in + by the upper layer when setting the Interrupt + handler for specific interrupt ID, and it will + passed back to Interrupt handler when it is + invoked. */ } XScuGic_VectorTableEntry; /** @@ -254,9 +224,15 @@ typedef struct */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ u32 CpuBaseAddress; /**< CPU Interface Register base address */ u32 DistBaseAddress; /**< Distributor Register base address */ +#else + char *Name; /**< Compatible string */ + u32 DistBaseAddress; /**< Distributor Register base address */ + u32 CpuBaseAddress; /**< CPU Interface Register base address */ +#endif XScuGic_VectorTableEntry HandlerTable[XSCUGIC_MAX_NUM_INTR_INPUTS];/**< Vector table of interrupt handlers */ } XScuGic_Config; @@ -285,17 +261,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Write the given CPU Interface register +* Writes 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be written. +* @param Data 32-bit value to write to the register. * * @return None. * -* @note -* C-style signature: -* void XScuGic_CPUWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) +* @note C-style signature: +* void XScuGic_CPUWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) * *****************************************************************************/ #define XScuGic_CPUWriteReg(InstancePtr, RegOffset, Data) \ @@ -305,16 +280,15 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Read the given CPU Interface register +* Reads 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Rregister offset to be read. * -* @return The 32-bit value of the register +* @return 32-bit value of the register * -* @note -* C-style signature: -* u32 XScuGic_CPUReadReg(XScuGic *InstancePtr, u32 RegOffset) +* @note C-style signature: +* u32 XScuGic_CPUReadReg(XScuGic *InstancePtr, u32 RegOffset) * *****************************************************************************/ #define XScuGic_CPUReadReg(InstancePtr, RegOffset) \ @@ -323,17 +297,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Write the given Distributor Interface register +* Writes 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be written. +* @param Data 32-bit value to write to the register. * * @return None. * -* @note -* C-style signature: -* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) +* @note C-style signature: +* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) * *****************************************************************************/ #define XScuGic_DistWriteReg(InstancePtr, RegOffset, Data) \ @@ -343,16 +316,15 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Read the given Distributor Interface register +* Reads 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be read. * -* @return The 32-bit value of the register +* @return The 32-bit value of the register. * -* @note -* C-style signature: -* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) +* @note C-style signature: +* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) * *****************************************************************************/ #define XScuGic_DistReadReg(InstancePtr, RegOffset) \ @@ -362,17 +334,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Write the given ReDistributor Interface register +* Writes 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be written. +* @param Data 32-bit value to write to the register. * * @return None. * -* @note -* C-style signature: -* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) +* @note C-style signature: +* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) * *****************************************************************************/ #define XScuGic_ReDistWriteReg(InstancePtr, RegOffset, Data) \ @@ -381,16 +352,15 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Read the given ReDistributor Interface register +* Reads 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be read. * -* @return The 32-bit value of the register +* @return 32-bit value of the register. * -* @note -* C-style signature: -* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) +* @note C-style signature: +* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) * *****************************************************************************/ #define XScuGic_ReDistReadReg(InstancePtr, RegOffset) \ @@ -399,17 +369,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Write the given ReDistributor SGI PPI Interface register +* Writes 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be written. +* @param Data 32-bit value to write to the register. * * @return None. * -* @note -* C-style signature: -* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) +* @note C-style signature: +* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) * *****************************************************************************/ #define XScuGic_ReDistSGIPPIWriteReg(InstancePtr, RegOffset, Data) \ @@ -419,16 +388,15 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Read the given ReDistributor SGI PPI Interface register +* Reads 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be read. * * @return The 32-bit value of the register * -* @note -* C-style signature: -* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) +* @note C-style signature: +* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) * *****************************************************************************/ #define XScuGic_ReDistSGIPPIReadReg(InstancePtr, RegOffset) \ @@ -443,9 +411,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #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_IAR1_EL1 "p15, 0, %0, c12, c12, 0" #define XREG_ICC_EOIR0_EL1 "p15, 0, %0, c12, c8, 1" +#define XREG_ICC_EOIR1_EL1 "p15, 0, %0, c12, c12, 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_BPR1_EL1 "p15, 0, %0, c12, c12, 3" #define XREG_ICC_RPR_EL1 "p15, 0, %0, c12, c11, 3" #else #define XREG_ICC_SRE_EL1 "S3_0_C12_C12_5" @@ -463,13 +434,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function enables system register interface for GIC CPU Interface +* Enables system register interface for GIC CPU Interface. * -* @param value to be written +* @param value Value to be written. * * @return None. * -* @note None. * *****************************************************************************/ #if defined (__aarch64__) @@ -480,13 +450,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function enables Grou0 interrupts +* Enable Grou0 interrupts. * * @param None. * * @return None. * -* @note None. * *****************************************************************************/ #if defined(ARMR52) @@ -502,7 +471,6 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ * * @return None. * -* @note None. * *****************************************************************************/ #if defined (ARMR52) @@ -518,13 +486,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function writes to ICC_SGI0R_EL1 +* Writes to ICC_SGI0R_EL1. * -* @param value to be written +* @param value Value to be written. * * @return None. * -* @note None. * *****************************************************************************/ #if defined(ARMR52) @@ -535,13 +502,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** -* This function writes to ICC_SGI1R_EL1 +* Writes to ICC_SGI1R_EL1. * -* @param value to be written +* @param value Value to be written. * * @return None. * -* @note None. * *****************************************************************************/ #if defined(ARMR52) @@ -552,13 +518,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** -* This function reads ICC_SGI1R_EL1 register +* Reads ICC_SGI1R_EL1 register. * * @param None * * @return Value of ICC_SGI1R_EL1 register * -* @note None. * *****************************************************************************/ #if defined (ARMR52) @@ -568,13 +533,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function sets interrupt priority filter +* Sets interrupt priority filter. * * @param None. * * @return None. * -* @note None. * *****************************************************************************/ #if defined (ARMR52) @@ -584,17 +548,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function returns interrupt id of highest priority pending interrupt +* 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) +#define XScuGic_get_IntID() mfcp(XREG_ICC_IAR1_EL1) #elif EL3 #define XScuGic_get_IntID() mfcpnotoken(XREG_ICC_IAR0_EL1) #else @@ -602,17 +565,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function acks the interrupt +* Acknowledges the interrupt. * * @param None. * * @return None. * -* @note None. * *****************************************************************************/ #if defined(ARMR52) -#define XScuGic_ack_Int(val) mtcp(XREG_ICC_EOIR0_EL1,val) +#define XScuGic_ack_Int(val) mtcp(XREG_ICC_EOIR1_EL1,val) #elif EL3 #define XScuGic_ack_Int(val) mtcpnotoken(XREG_ICC_EOIR0_EL1,val) #else @@ -627,7 +589,6 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ * * @return None. * -* @note None. * *****************************************************************************/ #define XScuGic_Get_Rdist_Int_Trigger_Index(IntrId) ((Int_Id%16) * 2U) @@ -660,12 +621,23 @@ void XScuGic_UnmapAllInterruptsFromCpu(XScuGic *InstancePtr, u8 Cpu_Identifier); void XScuGic_Stop(XScuGic *InstancePtr); void XScuGic_SetCpuID(u32 CpuCoreId); u32 XScuGic_GetCpuID(void); +#ifndef SDT u8 XScuGic_IsInitialized(u32 DeviceId); +#else +u8 XScuGic_IsInitialized(u32 BaseAddress); +#endif +#ifndef SDT /* - * Initialization functions in xscugic_sinit.c + * Lookup configuration by using DeviceId */ XScuGic_Config *XScuGic_LookupConfig(u16 DeviceId); +/* + * Lookup configuration by using BaseAddress + */ XScuGic_Config *XScuGic_LookupConfigBaseAddr(UINTPTR BaseAddress); +#else +XScuGic_Config *XScuGic_LookupConfig(UINTPTR BaseAddr); +#endif /* * Interrupt functions in xscugic_intr.c @@ -685,5 +657,6 @@ void XScuGic_MarkCoreAwake(XScuGic *InstancePtr); } #endif -#endif /* end of protection macro */ +#endif +/* end of protection macro */ /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/include/xscugic_hw.h b/bsp_z7/ps7_cortexa9_0/include/xscugic_hw.h index 0bbd0c4..90637a2 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xscugic_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xscugic_hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,11 +8,11 @@ /** * * @file xscugic_hw.h -* @addtogroup scugic Overview +* @addtogroup scugic_api SCUGIC APIs * @{ * -* 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 +* The xscugic_hw.h header file contains identifiers and hardware 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. * @@ -69,13 +69,14 @@ * 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. -* +* 5.2 ml 03/02/23 Add description to fix Doxygen warnings. +* 5.2 mus 03/26/23 Fixed calculation for XSCUGIC_RDIST_INT_PRIORITY_OFFSET_CALC. * * ******************************************************************************/ -#ifndef XSCUGIC_HW_H /* prevent circular inclusions */ -#define XSCUGIC_HW_H /* by using protection macros */ +#ifndef XSCUGIC_HW_H /**< prevent circular inclusions */ +#define XSCUGIC_HW_H /**< by using protection macros */ #ifdef __cplusplus extern "C" { @@ -110,24 +111,31 @@ extern "C" { * 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 */ +#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 */ +#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 +#define XSCUGIC_MAX_NUM_INTR_INPUTS 192U /**< Maximum number of + interrupt sources in + VERSAL */ #else -#define XSCUGIC_MAX_NUM_INTR_INPUTS 195U /* Maximum number of interrupt defined by Zynq Ultrascale Mp */ +#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 +#define XSCUGIC_SPI_INT_ID_START 0x20U /**< First Interrupt Id for + SPI interrupts. */ + +#define XSCUGIC_MAX_INTR_PRIO_VAL 248U /**< The maximum priority value + that can be used in + the GIC. */ +#define XSCUGIC_INTR_PRIO_MASK 0x000000F8U /**< The Interrupt + priority mask value */ /** @name Distributor Interface Register Map * @@ -338,7 +346,7 @@ extern "C" { * There are up to 255 of these registers staring at location 0xC08. * @{ */ -#define XSCUGIC_INT_CFG_MASK 0x00000003U /**< */ +#define XSCUGIC_INT_CFG_MASK 0x00000003U /**< Interrupt configuration Mask */ /* @} */ /** @name PPI Status Register @@ -523,6 +531,7 @@ extern "C" { #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 @@ -535,7 +544,7 @@ extern "C" { /* * GICR_IGROUPR register definitions */ -#if (defined(ARMR52) || EL3) +#if EL3 #define XSCUGIC_DEFAULT_SECURITY 0x0U #else #define XSCUGIC_DEFAULT_SECURITY 0xFFFFFFFFU @@ -551,13 +560,12 @@ extern "C" { /****************************************************************************/ /** * -* Read the Interrupt Configuration Register offset for an interrupt id. +* Reads the Interrupt Configuration Register offset for an interrupt ID. * -* @param InterruptID is the interrupt number. +* @param InterruptID Interrupt number. * * @return The 32-bit value of the offset * -* @note * *****************************************************************************/ #define XSCUGIC_INT_CFG_OFFSET_CALC(InterruptID) \ @@ -566,13 +574,12 @@ extern "C" { /****************************************************************************/ /** * -* Read the Interrupt Priority Register offset for an interrupt id. +* Reads the Interrupt Priority Register offset for an interrupt ID. * -* @param InterruptID is the interrupt number. +* @param InterruptID Interrupt number. * * @return The 32-bit value of the offset * -* @note * *****************************************************************************/ #define XSCUGIC_PRIORITY_OFFSET_CALC(InterruptID) \ @@ -581,13 +588,12 @@ extern "C" { /****************************************************************************/ /** * -* Read the Interrupt Routing Register offset for an interrupt id. +* Reads the Interrupt Routing Register offset for an interrupt ID. * -* @param InterruptID is the interrupt number. +* @param InterruptID Interrupt number. * * @return The 32-bit value of the offset * -* @note * *****************************************************************************/ #define XSCUGIC_IROUTER_OFFSET_CALC(InterruptID) \ @@ -596,13 +602,12 @@ extern "C" { /****************************************************************************/ /** * -* Read the SPI Target Register offset for an interrupt id. +* Reads the SPI Target Register offset for an interrupt ID. * -* @param InterruptID is the interrupt number. +* @param InterruptID Interrupt number. * -* @return The 32-bit value of the offset +* @return The 32-bit value of the offset. * -* @note * *****************************************************************************/ #define XSCUGIC_SPI_TARGET_OFFSET_CALC(InterruptID) \ @@ -610,13 +615,12 @@ extern "C" { /****************************************************************************/ /** * -* Read the SPI Target Register offset for an interrupt id. +* Reads the SPI Target Register offset for an interrupt ID. * -* @param InterruptID is the interrupt number. +* @param InterruptID Interrupt number. * * @return The 32-bit value of the offset * -* @note * *****************************************************************************/ #define XSCUGIC_SECURITY_TARGET_OFFSET_CALC(InterruptID) \ @@ -625,13 +629,12 @@ extern "C" { /****************************************************************************/ /** * -* Read the Re-distributor Interrupt configuration register offset +* Reads the Re-distributor Interrupt configuration register offset. * -* @param InterruptID is the interrupt number. +* @param InterruptID Interrupt number. * * @return The 32-bit value of the offset * -* @note * *****************************************************************************/ #define XSCUGIC_RDIST_INT_CONFIG_OFFSET_CALC(InterruptID) \ @@ -640,28 +643,26 @@ extern "C" { /****************************************************************************/ /** * -* Read the Re-distributor Interrupt Priority register offset +* Reads the Re-distributor Interrupt Priority register offset. * -* @param InterruptID is the interrupt number. +* @param InterruptID 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)) + ((u32)XSCUGIC_RDIST_IPRIORITYR_OFFSET + ((InterruptID/4) * 4)) /****************************************************************************/ /** * -* Read the Interrupt Clear-Enable Register offset for an interrupt ID +* Reads 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. +* @param Register Register offset for the clear/enable bank. +* @param InterruptID Interrupt number. * * @return The 32-bit value of the offset * -* @note * *****************************************************************************/ #define XSCUGIC_EN_DIS_OFFSET_CALC(Register, InterruptID) \ @@ -670,16 +671,15 @@ extern "C" { /****************************************************************************/ /** * -* Read the given Intc register. +* Reads the given Intc register. * -* @param BaseAddress is the base address of the device. -* @param RegOffset is the register offset to be read +* @param BaseAddress Base address of the device. +* @param RegOffset Register offset to be read. * * @return The 32-bit value of the register * -* @note -* C-style signature: -* u32 XScuGic_ReadReg(u32 BaseAddress, u32 RegOffset) +* @note C-style signature: +* u32 XScuGic_ReadReg(u32 BaseAddress, u32 RegOffset) * *****************************************************************************/ #define XScuGic_ReadReg(BaseAddress, RegOffset) \ @@ -688,16 +688,15 @@ extern "C" { /****************************************************************************/ /** * -* Read the given Intc register. +* Reads the given Intc register. * -* @param BaseAddress is the base address of the device. -* @param RegOffset is the register offset to be read +* @param BaseAddress Base address of the device. +* @param RegOffset Register offset to be read. * * @return The 64-bit value of the register * -* @note -* C-style signature: -* u32 XScuGic_ReadReg64(UINTPTR BaseAddress, u32 RegOffset) +* @note C-style signature: +* u32 XScuGic_ReadReg64(UINTPTR BaseAddress, u32 RegOffset) * *****************************************************************************/ #define XScuGic_ReadReg64(BaseAddress, RegOffset) \ @@ -706,17 +705,16 @@ extern "C" { /****************************************************************************/ /** * -* Write the given Intc register. +* Writes 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 +* @param BaseAddress Base address of the device. +* @param RegOffset Register offset to be written +* @param Data 32-bit value to write to the register * * @return None. * -* @note -* C-style signature: -* void XScuGic_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data) +* @note C-style signature: +* void XScuGic_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data) * *****************************************************************************/ #define XScuGic_WriteReg(BaseAddress, RegOffset, Data) \ diff --git a/bsp_z7/ps7_cortexa9_0/include/xscutimer.h b/bsp_z7/ps7_cortexa9_0/include/xscutimer.h index bdce1c6..008b900 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xscutimer.h +++ b/bsp_z7/ps7_cortexa9_0/include/xscutimer.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscutimer.h -* @addtogroup scutimer_v2_4 +* @addtogroup scutimer Overview * @{ * @details * @@ -82,6 +83,7 @@ * 2.3 mus 08/31/20 Updated makefile to support parallel make and * incremental builds, it would help to reduce compilation * time. +* 2.5 dp 07/11/23 Add support for system device tree flow * * ******************************************************************************/ @@ -106,7 +108,11 @@ extern "C" { * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddr; /**< Base address of the device */ #ifdef XIL_INTERRUPT u32 IntrId; @@ -145,9 +151,9 @@ typedef struct { ******************************************************************************/ #define XScuTimer_IsExpired(InstancePtr) \ ((XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_ISR_OFFSET) & \ - XSCUTIMER_ISR_EVENT_FLAG_MASK) == \ - XSCUTIMER_ISR_EVENT_FLAG_MASK) + XSCUTIMER_ISR_OFFSET) & \ + XSCUTIMER_ISR_EVENT_FLAG_MASK) == \ + XSCUTIMER_ISR_EVENT_FLAG_MASK) /****************************************************************************/ /** @@ -165,8 +171,8 @@ typedef struct { ******************************************************************************/ #define XScuTimer_RestartTimer(InstancePtr) \ XScuTimer_LoadTimer((InstancePtr), \ - XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_LOAD_OFFSET)) + XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ + XSCUTIMER_LOAD_OFFSET)) /****************************************************************************/ /** @@ -186,7 +192,7 @@ typedef struct { ******************************************************************************/ #define XScuTimer_LoadTimer(InstancePtr, Value) \ XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_LOAD_OFFSET, (Value)) + XSCUTIMER_LOAD_OFFSET, (Value)) /****************************************************************************/ /** @@ -204,7 +210,7 @@ typedef struct { ******************************************************************************/ #define XScuTimer_GetCounterValue(InstancePtr) \ XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_COUNTER_OFFSET) + XSCUTIMER_COUNTER_OFFSET) /****************************************************************************/ /** @@ -221,10 +227,10 @@ typedef struct { ******************************************************************************/ #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)) + XSCUTIMER_CONTROL_OFFSET, \ + (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ + XSCUTIMER_CONTROL_OFFSET) | \ + XSCUTIMER_CONTROL_AUTO_RELOAD_MASK)) /****************************************************************************/ /** @@ -241,10 +247,10 @@ typedef struct { ******************************************************************************/ #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))) + XSCUTIMER_CONTROL_OFFSET, \ + (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ + XSCUTIMER_CONTROL_OFFSET) & \ + ~(XSCUTIMER_CONTROL_AUTO_RELOAD_MASK))) /****************************************************************************/ /** @@ -261,10 +267,10 @@ typedef struct { ******************************************************************************/ #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)) + XSCUTIMER_CONTROL_OFFSET, \ + (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ + XSCUTIMER_CONTROL_OFFSET) | \ + XSCUTIMER_CONTROL_IRQ_ENABLE_MASK)) /****************************************************************************/ /** @@ -281,10 +287,10 @@ typedef struct { ******************************************************************************/ #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))) + XSCUTIMER_CONTROL_OFFSET, \ + (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ + XSCUTIMER_CONTROL_OFFSET) & \ + ~(XSCUTIMER_CONTROL_IRQ_ENABLE_MASK))) /*****************************************************************************/ /** @@ -301,7 +307,7 @@ typedef struct { ******************************************************************************/ #define XScuTimer_GetInterruptStatus(InstancePtr) \ XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_ISR_OFFSET) + XSCUTIMER_ISR_OFFSET) /*****************************************************************************/ /** @@ -318,14 +324,18 @@ typedef struct { ******************************************************************************/ #define XScuTimer_ClearInterruptStatus(InstancePtr) \ XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_ISR_OFFSET, XSCUTIMER_ISR_EVENT_FLAG_MASK) + XSCUTIMER_ISR_OFFSET, XSCUTIMER_ISR_EVENT_FLAG_MASK) /************************** Function Prototypes ******************************/ /* * Lookup configuration in xscutimer_sinit.c */ +#ifndef SDT XScuTimer_Config *XScuTimer_LookupConfig(u16 DeviceId); +#else +XScuTimer_Config *XScuTimer_LookupConfig(UINTPTR BaseAddr); +#endif /* * Selftest function in xscutimer_selftest.c diff --git a/bsp_z7/ps7_cortexa9_0/include/xscutimer_hw.h b/bsp_z7/ps7_cortexa9_0/include/xscutimer_hw.h index c34acd1..8eb1875 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xscutimer_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xscutimer_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscutimer_hw.h -* @addtogroup scutimer_v2_4 +* @addtogroup scutimer Overview * @{ * * This file contains the hardware interface to the Timer. diff --git a/bsp_z7/ps7_cortexa9_0/include/xscuwdt.h b/bsp_z7/ps7_cortexa9_0/include/xscuwdt.h index 8d11ff8..9130e4d 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xscuwdt.h +++ b/bsp_z7/ps7_cortexa9_0/include/xscuwdt.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscuwdt.h -* @addtogroup scuwdt_v2_4 +* @addtogroup Overview * @{ * @details * @@ -106,6 +107,8 @@ * time. * 2.3 sne 09/16/20 Fixed MISRA-C violations. * 2.4 sne 02/04/21 Fixed Doxygen warnings. +* 2.5 asa 07/18/23 Added support for system device tree based workflow +* decoupling flow. * * ******************************************************************************/ @@ -129,8 +132,18 @@ extern "C" { * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ - u32 BaseAddr; /**< Base address of the device */ +#else + char *Name; /**< Unique name of the device */ +#endif + UINTPTR BaseAddr; /**< Register base address */ +#ifdef SDT + u32 IntrId; /** Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ +#endif } XScuWdt_Config; /** @@ -168,7 +181,7 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; #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) + XSCUWDT_RST_STS_RESET_FLAG_MASK) == XSCUWDT_RST_STS_RESET_FLAG_MASK) /****************************************************************************/ /** @@ -189,7 +202,7 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; #define XScuWdt_IsTimerExpired(InstancePtr) \ ((XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \ XSCUWDT_ISR_OFFSET) & \ - XSCUWDT_ISR_EVENT_FLAG_MASK) == XSCUWDT_ISR_EVENT_FLAG_MASK) + XSCUWDT_ISR_EVENT_FLAG_MASK) == XSCUWDT_ISR_EVENT_FLAG_MASK) /****************************************************************************/ /** @@ -230,7 +243,7 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; ******************************************************************************/ #define XScuWdt_LoadWdt(InstancePtr, Value) \ XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \ - XSCUWDT_LOAD_OFFSET, (Value)) + XSCUWDT_LOAD_OFFSET, (Value)) /****************************************************************************/ /** @@ -250,7 +263,7 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \ XSCUWDT_CONTROL_OFFSET, \ (XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \ - XSCUWDT_CONTROL_OFFSET) | \ + XSCUWDT_CONTROL_OFFSET) | \ (XSCUWDT_CONTROL_WD_MODE_MASK))) /****************************************************************************/ @@ -271,14 +284,14 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; * ******************************************************************************/ #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); \ -} + { \ + XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \ + XSCUWDT_DISABLE_OFFSET, \ + XSCUWDT_DISABLE_VALUE1); \ + XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \ + XSCUWDT_DISABLE_OFFSET, \ + XSCUWDT_DISABLE_VALUE2); \ + } /****************************************************************************/ /** @@ -332,14 +345,18 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; #define XScuWdt_EnableAutoReload(InstancePtr) \ XScuWdt_SetControlReg((InstancePtr), \ (XScuWdt_GetControlReg(InstancePtr) | \ - XSCUWDT_CONTROL_AUTO_RELOAD_MASK)) + XSCUWDT_CONTROL_AUTO_RELOAD_MASK)) /************************** Function Prototypes ******************************/ /* * Lookup configuration in xscuwdt_sinit.c. */ +#ifndef SDT XScuWdt_Config *XScuWdt_LookupConfig(u16 DeviceId); +#else +XScuWdt_Config *XScuWdt_LookupConfig(UINTPTR BaseAddress); +#endif /* * Selftest function in xscuwdt_selftest.c diff --git a/bsp_z7/ps7_cortexa9_0/include/xscuwdt_hw.h b/bsp_z7/ps7_cortexa9_0/include/xscuwdt_hw.h index 0cdfc1e..3c401ec 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xscuwdt_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xscuwdt_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscuwdt_hw.h -* @addtogroup scuwdt_v2_4 +* @addtogroup Overview * @{ * * This file contains the hardware interface to the Xilinx SCU private Watch Dog diff --git a/bsp_z7/ps7_cortexa9_0/include/xsdps.h b/bsp_z7/ps7_cortexa9_0/include/xsdps.h index 77aa9c6..3bdc4f6 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xsdps.h +++ b/bsp_z7/ps7_cortexa9_0/include/xsdps.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,75 +8,10 @@ /** * * @file xsdps.h -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{ * @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. -* -* Initialization & Configuration -* -* 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. -* -* Data transfer -* -* 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. -* -* File system use -* -* 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. -* -* eMMC support -* -* 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. * *
* MODIFICATION HISTORY: @@ -161,6 +96,11 @@ * 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. +* 4.2 ro 06/12/23 Added support for system device-tree flow. +* 4.2 ap 08/09/23 Reordered XSdPs_FrameCmd XSdPs_Identify_UhsMode functions +* 4.3 ap 10/11/23 Resolved compilation errors with Microblaze RISC-V +* 4.3 ap 11/29/23 Add support for Sanitize feature. +* 4.3 ap 12/22/23 Add support to read custom HS400 tap delay value from design for eMMC. * ** @@ -243,8 +183,12 @@ extern "C" { * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ - u32 BaseAddress; /**< Base address of the device */ +#else + char *Name; +#endif + UINTPTR BaseAddress; /**< Base address of the device */ u32 InputClockHz; /**< Input clock frequency */ u32 CardDetect; /**< Card Detect */ u32 WriteProtect; /**< Write Protect */ @@ -253,7 +197,7 @@ typedef struct { u32 HasEMIO; /**< If SD is connected to EMIO */ u8 SlotType; /**< Slot type */ u8 IsCacheCoherent; /**< If SD is Cache Coherent or not */ -#if defined (XCLOCKING) +#if defined (XCLOCKING) || defined (SDT) u32 RefClk; /**< Input clocks */ #endif u32 ITapDly_SDR_Clk50; /**< Input Tap delay for HSD/SDR25 modes */ @@ -262,6 +206,7 @@ typedef struct { 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 */ + u32 OTapDly_DDR_Clk200; /**< Input Tap delay for HS400 modes */ } XSdPs_Config; /** @@ -275,7 +220,8 @@ typedef struct { #pragma data_alignment = 32 } XSdPs_Adma2Descriptor32; #else -} __attribute__((__packed__))XSdPs_Adma2Descriptor32; +} +__attribute__((__packed__))XSdPs_Adma2Descriptor32; #endif /** @@ -325,11 +271,11 @@ typedef struct { u8 IsTuningDone; /**< Flag to indicate HS200 tuning complete */ #ifdef __ICCARM__ #pragma data_alignment = 32 - XSdPs_Adma2Descriptor32 Adma2_DescrTbl32[32]; - XSdPs_Adma2Descriptor64 Adma2_DescrTbl64[32]; + XSdPs_Adma2Descriptor32 Adma2_DescrTbl32[32]; /**< ADMA descriptor table 32 Bit */ + XSdPs_Adma2Descriptor64 Adma2_DescrTbl64[32]; /**< ADMA descriptor table 64 Bit */ #else - XSdPs_Adma2Descriptor32 Adma2_DescrTbl32[32] __attribute__ ((aligned(32))); - XSdPs_Adma2Descriptor64 Adma2_DescrTbl64[32] __attribute__ ((aligned(32))); + XSdPs_Adma2Descriptor32 Adma2_DescrTbl32[32] __attribute__ ((aligned(32))); /**< ADMA descriptor table 32 Bit */ + XSdPs_Adma2Descriptor64 Adma2_DescrTbl64[32] __attribute__ ((aligned(32))); /**< ADMA descriptor table 64 Bit */ #endif } XSdPs; @@ -355,10 +301,24 @@ typedef struct { */ #define ENABLE_HS400_MODE +/************************** Variable Definitions *****************************/ +/** + * XSdPs Configuration Table + */ +#ifndef SDT +extern XSdPs_Config XSdPs_ConfigTable[XPAR_XSDPS_NUM_INSTANCES]; +#else +extern XSdPs_Config XSdPs_ConfigTable[]; +#endif + /************************** Function Prototypes ******************************/ +#ifndef SDT XSdPs_Config *XSdPs_LookupConfig(u16 DeviceId); +#else +XSdPs_Config *XSdPs_LookupConfig(u32 BaseAddress); +#endif s32 XSdPs_CfgInitialize(XSdPs *InstancePtr, XSdPs_Config *ConfigPtr, - u32 EffectiveAddr); + UINTPTR 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); @@ -380,6 +340,7 @@ 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); +s32 XSdPs_Sanitize(XSdPs *InstancePtr); #ifdef __cplusplus } diff --git a/bsp_z7/ps7_cortexa9_0/include/xsdps_core.h b/bsp_z7/ps7_cortexa9_0/include/xsdps_core.h index 239c2f1..9a5a289 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xsdps_core.h +++ b/bsp_z7/ps7_cortexa9_0/include/xsdps_core.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,10 +8,10 @@ /** * * @file xsdps_core.h -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{ * -* The xsdps_core.h header file contains the identifiers and basic HW access driver +* The xsdps_core.h header file contains the identifiers and basic hardware access driver * functions (or macros) that can be used to access the device. Other driver * functions are defined in xsdps.h. * @@ -27,6 +27,7 @@ * 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. +* 4.2 ap 08/09/23 Add XSdPs_SetTapDelay APIs. * * ******************************************************************************/ @@ -110,6 +111,10 @@ void XSdPs_ConfigInterrupt(XSdPs *InstancePtr); s32 XSdPs_SendErase(XSdPs *InstancePtr); s32 XSdPs_SetEndAddr(XSdPs *InstancePtr, u32 EndAddr); s32 XSdPs_SetStartAddr(XSdPs *InstancePtr, u32 StartAddr); +void XSdPs_SetTapDelay_SDR104(XSdPs *InstancePtr); +void XSdPs_SetTapDelay_SDR50(XSdPs *InstancePtr); +void XSdPs_SetTapDelay_DDR50(XSdPs *InstancePtr); +void XSdPs_SetTapDelay_SDR25(XSdPs *InstancePtr); #ifdef VERSAL_NET u32 XSdPs_Select_HS400(XSdPs *InstancePtr); #endif diff --git a/bsp_z7/ps7_cortexa9_0/include/xsdps_hw.h b/bsp_z7/ps7_cortexa9_0/include/xsdps_hw.h index 7ee7774..9257158 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xsdps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xsdps_hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,7 +8,7 @@ /** * * @file xsdps_hw.h -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{{ * * The xsdps_hw.h header file contains the identifiers and basic HW access driver @@ -45,6 +45,9 @@ * 4.0 sk 02/25/22 Add support for eMMC5.1. * sk 04/07/22 Fix typo in 'XSDPS_MMC_1_BIT_BUS_ARG' macro definition. * 4.1 sk 11/10/22 Add SD/eMMC Tap delay support for Versal Net. +* 4.2 ro 06/12/23 Added support for system device-tree flow. +* 4.3 ap 11/29/23 Add support for Sanitize feature. +* 4.3 ap 12/22/23 Add support to read custom HS400 tap delay value from design for eMMC. * * * @@ -63,8 +66,8 @@ extern "C" { #include "xil_types.h" #include "xil_assert.h" #include "xil_io.h" +#include "bspconfig.h" #include "xparameters.h" - /************************** Constant Definitions *****************************/ /** @name Register Map @@ -76,8 +79,8 @@ extern "C" { #define XSDPS_SDMA_SYS_ADDR_OFFSET 0x00U /**< SDMA System Address Register */ #define XSDPS_SDMA_SYS_ADDR_LO_OFFSET XSDPS_SDMA_SYS_ADDR_OFFSET - /**< SDMA System Address - Low Register */ +/**< SDMA System Address + Low Register */ #define XSDPS_ARGMT2_LO_OFFSET 0x00U /**< Argument2 Low Register */ #define XSDPS_SDMA_SYS_ADDR_HI_OFFSET 0x02U /**< SDMA System Address High Register */ @@ -87,7 +90,7 @@ extern "C" { #define XSDPS_BLK_CNT_OFFSET 0x06U /**< Block Count Register */ #define XSDPS_ARGMT_OFFSET 0x08U /**< Argument Register */ #define XSDPS_ARGMT1_LO_OFFSET XSDPS_ARGMT_OFFSET - /**< Argument1 Register */ +/**< Argument1 Register */ #define XSDPS_ARGMT1_HI_OFFSET 0x0AU /**< Argument1 Register */ #define XSDPS_XFER_MODE_OFFSET 0x0CU /**< Transfer Mode Register */ @@ -714,16 +717,16 @@ extern "C" { #define RESP_NONE (u32)XSDPS_CMD_RESP_NONE_MASK #define RESP_R1 (u32)XSDPS_CMD_RESP_L48_MASK | (u32)XSDPS_CMD_CRC_CHK_EN_MASK | \ - (u32)XSDPS_CMD_INX_CHK_EN_MASK + (u32)XSDPS_CMD_INX_CHK_EN_MASK #define RESP_R1B (u32)XSDPS_CMD_RESP_L48_BSY_CHK_MASK | \ - (u32)XSDPS_CMD_CRC_CHK_EN_MASK | (u32)XSDPS_CMD_INX_CHK_EN_MASK + (u32)XSDPS_CMD_CRC_CHK_EN_MASK | (u32)XSDPS_CMD_INX_CHK_EN_MASK #define RESP_R2 (u32)XSDPS_CMD_RESP_L136_MASK | (u32)XSDPS_CMD_CRC_CHK_EN_MASK #define RESP_R3 (u32)XSDPS_CMD_RESP_L48_MASK #define RESP_R6 (u32)XSDPS_CMD_RESP_L48_BSY_CHK_MASK | \ - (u32)XSDPS_CMD_CRC_CHK_EN_MASK | (u32)XSDPS_CMD_INX_CHK_EN_MASK + (u32)XSDPS_CMD_CRC_CHK_EN_MASK | (u32)XSDPS_CMD_INX_CHK_EN_MASK /** @} */ @@ -929,18 +932,24 @@ extern "C" { #define EXT_CSD_PART_CONFIG_ACC_BOOT1 (0x2U) #define EXT_CSD_PART_CONFIG_ACC_RPMB (0x3U) #define EXT_CSD_PART_CONFIG_ACC_GP0 (0x4U) +#define EXT_CSD_SANITIZE_START (0x1U) #define EXT_CSD_PART_CONFIG_BYTE (179U) +#define EXT_CSD_SANIT_CONFIG_BYTE (165U) #define XSDPS_MMC_PART_CFG_0_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24U) \ - | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ - | ((u32)(0U) << 8U)) + | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ + | ((u32)(0U) << 8U)) #define XSDPS_MMC_PART_CFG_1_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24U) \ - | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ - | ((u32)EXT_CSD_PART_CONFIG_ACC_BOOT0 << 8U)) + | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ + | ((u32)EXT_CSD_PART_CONFIG_ACC_BOOT0 << 8U)) #define XSDPS_MMC_PART_CFG_2_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24U) \ - | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ - | ((u32)EXT_CSD_PART_CONFIG_ACC_BOOT1 << 8U)) + | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ + | ((u32)EXT_CSD_PART_CONFIG_ACC_BOOT1 << 8U)) + +#define XSDPS_MMC_START_SANITIZE_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24U) \ + | ((u32)EXT_CSD_SANIT_CONFIG_BYTE << 16U) \ + | ((u32)EXT_CSD_SANITIZE_START << 8U)) #define EXT_CSD_PART_SUPPORT_PART_EN (0x1U) @@ -952,14 +961,14 @@ extern "C" { #define EXT_CSD_CARD_TYPE_52 (1U<<1) /* Card can run at 52MHz */ #define EXT_CSD_CARD_TYPE_MASK 0x3FU /* Mask out reserved bits */ #define EXT_CSD_CARD_TYPE_DDR_1_8V (1U<<2) /* Card can run at 52MHz */ - /* DDR mode @1.8V or 3V I/O */ +/* DDR mode @1.8V or 3V I/O */ #define EXT_CSD_CARD_TYPE_DDR_1_2V (1U<<3) /* Card can run at 52MHz */ - /* DDR mode @1.2V I/O */ +/* DDR mode @1.2V I/O */ #define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \ - | EXT_CSD_CARD_TYPE_DDR_1_2V) + | EXT_CSD_CARD_TYPE_DDR_1_2V) #define EXT_CSD_CARD_TYPE_SDR_1_8V (1U<<4) /* Card can run at 200MHz */ #define EXT_CSD_CARD_TYPE_SDR_1_2V (1U<<5) /* Card can run at 200MHz */ - /* SDR mode @1.2V I/O */ +/* SDR mode @1.2V I/O */ #define EXT_CSD_BUS_WIDTH_BYTE 183U #define EXT_CSD_BUS_WIDTH_1_BIT 0U /* Card is in 1 bit mode */ #define EXT_CSD_BUS_WIDTH_4_BIT 1U /* Card is in 4 bit mode */ @@ -992,44 +1001,44 @@ extern "C" { * SD/MMC Arguments for Bus Speed and Bus Width. */ #define XSDPS_MMC_DEF_SPEED_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ - | ((u32)EXT_CSD_HS_TIMING_DEF << 8)) + | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ + | ((u32)EXT_CSD_HS_TIMING_DEF << 8)) #define XSDPS_MMC_HIGH_SPEED_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ - | ((u32)EXT_CSD_HS_TIMING_HIGH << 8)) + | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ + | ((u32)EXT_CSD_HS_TIMING_HIGH << 8)) #define XSDPS_MMC_HS200_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ - | ((u32)EXT_CSD_HS_TIMING_HS200 << 8)) + | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ + | ((u32)EXT_CSD_HS_TIMING_HS200 << 8)) #define XSDPS_MMC_HS400_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ - | ((u32)EXT_CSD_HS_TIMING_HS400 << 8)) + | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ + | ((u32)EXT_CSD_HS_TIMING_HS400 << 8)) #define XSDPS_MMC_1_BIT_BUS_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ - | ((u32)EXT_CSD_BUS_WIDTH_1_BIT << 8)) + | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ + | ((u32)EXT_CSD_BUS_WIDTH_1_BIT << 8)) #define XSDPS_MMC_4_BIT_BUS_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ - | ((u32)EXT_CSD_BUS_WIDTH_4_BIT << 8)) + | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ + | ((u32)EXT_CSD_BUS_WIDTH_4_BIT << 8)) #define XSDPS_MMC_8_BIT_BUS_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ - | ((u32)EXT_CSD_BUS_WIDTH_8_BIT << 8)) + | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ + | ((u32)EXT_CSD_BUS_WIDTH_8_BIT << 8)) #define XSDPS_MMC_DDR_4_BIT_BUS_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ - | ((u32)EXT_CSD_BUS_WIDTH_DDR_4_BIT << 8)) + | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ + | ((u32)EXT_CSD_BUS_WIDTH_DDR_4_BIT << 8)) #define XSDPS_MMC_DDR_8_BIT_BUS_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ - | ((u32)EXT_CSD_BUS_WIDTH_DDR_8_BIT << 8)) + | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ + | ((u32)EXT_CSD_BUS_WIDTH_DDR_8_BIT << 8)) #define XSDPS_MMC_RST_FUN_EN_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_RST_N_FUN_BYTE << 16) \ - | ((u32)EXT_CSD_RST_N_FUN_PERM_EN << 8)) + | ((u32)EXT_CSD_RST_N_FUN_BYTE << 16) \ + | ((u32)EXT_CSD_RST_N_FUN_PERM_EN << 8)) #define XSDPS_MMC_DELAY_FOR_SWITCH 1000U @@ -1196,6 +1205,8 @@ extern "C" { #define SD_ITAPCHGWIN 0x00000200U #define SD_ITAPDLYENA 0x00000100U #define SD_OTAPDLYENA 0x00000040U +#define SD_OTAPDLYSEL_SD104_B0 0x00000002U +#define SD_OTAPDLYSEL_SD104_B2 0x00000002U #define SD_OTAPDLYSEL_HS200_B0 0x00000007U #define SD_OTAPDLYSEL_HS200_B2 0x00000007U #define SD_OTAPDLYSEL_HS400 0x00000004U @@ -1224,6 +1235,8 @@ extern "C" { #define SD_ITAPCHGWIN 0x00000200U #define SD_ITAPDLYENA 0x00000100U #define SD_OTAPDLYENA 0x00000040U +#define SD_OTAPDLYSEL_SD104_B0 0x00000002U +#define SD_OTAPDLYSEL_SD104_B2 0x00000002U #define SD_OTAPDLYSEL_HS200_B0 0x00000002U #define SD_OTAPDLYSEL_HS200_B2 0x00000002U #define SD_ITAPDLYSEL_SD50 0x0000000EU @@ -1255,6 +1268,8 @@ extern "C" { #define SD1_ITAPCHGWIN 0x02000000U #define SD1_ITAPDLYENA 0x01000000U #define SD1_OTAPDLYENA 0x00400000U +#define SD_OTAPDLYSEL_SD104_B0 0x00000003U +#define SD_OTAPDLYSEL_SD104_B2 0x00000002U #define SD_OTAPDLYSEL_HS200_B0 0x00000003U #define SD_OTAPDLYSEL_HS200_B2 0x00000002U #define SD_ITAPDLYSEL_SD50 0x00000014U @@ -1273,7 +1288,7 @@ extern "C" { #endif /** @} */ -#ifdef __MICROBLAZE__ +#if defined (__MICROBLAZE__) || defined (__riscv) #define XPS_SYS_CTRL_BASEADDR 0xFF180000U /**< System controller Baseaddress */ #endif @@ -1294,16 +1309,16 @@ extern "C" { /****************************************************************************/ /** -* Read a register. +* Reads a register. * -* @param InstancePtr is the pointer to the sdps instance. -* @param RegOffset contains the offset from the 1st register of the +* @param InstancePtr Pointer to the sdps instance. +* @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 XSdPs_ReadReg(XSdPs *InstancePtr. s32 RegOffset) +* u32 XSdPs_ReadReg(XSdPs *InstancePtr. s32 RegOffset) * ******************************************************************************/ #define XSdPs_ReadReg64(InstancePtr, RegOffset) \ @@ -1311,36 +1326,36 @@ extern "C" { /***************************************************************************/ /** -* Write to a register. +* Writes to a register. * -* @param InstancePtr is the pointer to the sdps instance. -* @param RegOffset contains the offset from the 1st register of the +* @param InstancePtr Pointer to the sdps instance. +* @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. +* @param RegisterValue Value to be written to the register. * * @return None. * * @note C-Style signature: -* void XSdPs_WriteReg(XSdPs *InstancePtr, s32 RegOffset, -* u64 RegisterValue) +* void XSdPs_WriteReg(XSdPs *InstancePtr, s32 RegOffset, +* u64 RegisterValue) * ******************************************************************************/ #define XSdPs_WriteReg64(InstancePtr, RegOffset, RegisterValue) \ XSdPs_Out64((InstancePtr->Config.BaseAddress) + (RegOffset), \ - (RegisterValue)) + (RegisterValue)) /****************************************************************************/ /** -* Read a register. +* Reads a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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 XSdPs_ReadReg(u32 BaseAddress. int RegOffset) +* u32 XSdPs_ReadReg(UINTPTR BaseAddress. int RegOffset) * ******************************************************************************/ #define XSdPs_ReadReg(BaseAddress, RegOffset) \ @@ -1348,18 +1363,18 @@ extern "C" { /***************************************************************************/ /** -* Write to a register. +* Writes to a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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. +* @param RegisterValue Value to be written to the register. * * @return None. * * @note C-Style signature: -* void XSdPs_WriteReg(u32 BaseAddress, int RegOffset, -* u32 RegisterValue) +* void XSdPs_WriteReg(UINTPTR BaseAddress, int RegOffset, +* u32 RegisterValue) * ******************************************************************************/ #define XSdPs_WriteReg(BaseAddress, RegOffset, RegisterValue) \ @@ -1367,25 +1382,25 @@ extern "C" { /****************************************************************************/ /** -* Read a register. +* Reads a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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: -* u16 XSdPs_ReadReg(u32 BaseAddress. int RegOffset) +* u16 XSdPs_ReadReg(UINTPTR BaseAddress. int RegOffset) * ******************************************************************************/ -static INLINE u16 XSdPs_ReadReg16(u32 BaseAddress, u8 RegOffset) +static INLINE u16 XSdPs_ReadReg16(UINTPTR BaseAddress, u8 RegOffset) { -#if defined (__MICROBLAZE__) +#if defined (__MICROBLAZE__) || defined (__riscv) u32 Reg; BaseAddress += RegOffset & 0xFC; Reg = XSdPs_In32(BaseAddress); - Reg >>= ((RegOffset & 0x3)*8); + Reg >>= ((RegOffset & 0x3) * 8); return (u16)Reg; #else return XSdPs_In16((UINTPTR)(BaseAddress) + (UINTPTR)(RegOffset)); @@ -1394,29 +1409,29 @@ static INLINE u16 XSdPs_ReadReg16(u32 BaseAddress, u8 RegOffset) /***************************************************************************/ /** -* Write to a register. +* Writes to a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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. +* @param RegisterValue Value to be written to the register. * * @return None. * * @note C-Style signature: -* void XSdPs_WriteReg(u32 BaseAddress, int RegOffset, -* u16 RegisterValue) +* void XSdPs_WriteReg(UINTPTR BaseAddress, int RegOffset, +* u16 RegisterValue) * ******************************************************************************/ -static INLINE void XSdPs_WriteReg16(u32 BaseAddress, u8 RegOffset, u16 RegisterValue) +static INLINE void XSdPs_WriteReg16(UINTPTR BaseAddress, u8 RegOffset, u16 RegisterValue) { -#if defined (__MICROBLAZE__) +#if defined (__MICROBLAZE__) || defined (__riscv) u32 Reg; BaseAddress += RegOffset & 0xFC; Reg = XSdPs_In32(BaseAddress); - Reg &= ~(0xFFFFU<<((RegOffset & 0x3)*8)); - Reg |= RegisterValue <<((RegOffset & 0x3)*8); + Reg &= ~(0xFFFFU << ((RegOffset & 0x3) * 8)); + Reg |= RegisterValue << ((RegOffset & 0x3) * 8); XSdPs_Out32(BaseAddress, Reg); #else XSdPs_Out16((UINTPTR)(BaseAddress) + (UINTPTR)(RegOffset), (RegisterValue)); @@ -1425,25 +1440,25 @@ static INLINE void XSdPs_WriteReg16(u32 BaseAddress, u8 RegOffset, u16 RegisterV /****************************************************************************/ /** -* Read a register. +* Reads a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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: -* u8 XSdPs_ReadReg(u32 BaseAddress. int RegOffset) +* u8 XSdPs_ReadReg(UINTPTR BaseAddress. int RegOffset) * ******************************************************************************/ -static INLINE u8 XSdPs_ReadReg8(u32 BaseAddress, u8 RegOffset) +static INLINE u8 XSdPs_ReadReg8(UINTPTR BaseAddress, u8 RegOffset) { -#if defined (__MICROBLAZE__) +#if defined (__MICROBLAZE__) || defined (__riscv) u32 Reg; BaseAddress += RegOffset & 0xFC; Reg = XSdPs_In32(BaseAddress); - Reg >>= ((RegOffset & 0x3)*8); + Reg >>= ((RegOffset & 0x3) * 8); return (u8)Reg; #else return XSdPs_In8((UINTPTR)(BaseAddress) + (UINTPTR)(RegOffset)); @@ -1451,28 +1466,28 @@ static INLINE u8 XSdPs_ReadReg8(u32 BaseAddress, u8 RegOffset) } /***************************************************************************/ /** -* Write to a register. +* Writes to a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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. +* @param RegisterValue Value to be written to the register. * * @return None. * * @note C-Style signature: -* void XSdPs_WriteReg(u32 BaseAddress, int RegOffset, -* u8 RegisterValue) +* void XSdPs_WriteReg(UINTPTR BaseAddress, int RegOffset, +* u8 RegisterValue) * ******************************************************************************/ -static INLINE void XSdPs_WriteReg8(u32 BaseAddress, u8 RegOffset, u8 RegisterValue) +static INLINE void XSdPs_WriteReg8(UINTPTR BaseAddress, u8 RegOffset, u8 RegisterValue) { -#if defined (__MICROBLAZE__) +#if defined (__MICROBLAZE__) || defined (__riscv) u32 Reg; BaseAddress += RegOffset & 0xFC; Reg = XSdPs_In32(BaseAddress); - Reg &= ~(0xFFU<<((RegOffset & 0x3)*8)); - Reg |= RegisterValue <<((RegOffset & 0x3)*8); + Reg &= ~(0xFFU << ((RegOffset & 0x3) * 8)); + Reg |= RegisterValue << ((RegOffset & 0x3) * 8); XSdPs_Out32(BaseAddress, Reg); #else XSdPs_Out8((UINTPTR)(BaseAddress) + (UINTPTR)(RegOffset), (RegisterValue)); @@ -1480,19 +1495,19 @@ static INLINE void XSdPs_WriteReg8(u32 BaseAddress, u8 RegOffset, u8 RegisterVal } /***************************************************************************/ /** -* Macro to get present status register +* Macro to get present status register. * -* @param BaseAddress contains the base address of the device. +* @param BaseAddress Contains the base address of the device. * * @return None. * * @note C-Style signature: -* void XSdPs_WriteReg(u32 BaseAddress, int RegOffset, -* u8 RegisterValue) +* void XSdPs_WriteReg(UINTPTR BaseAddress, int RegOffset, +* u8 RegisterValue) * ******************************************************************************/ #define XSdPs_GetPresentStatusReg(BaseAddress) \ - XSdPs_In32((BaseAddress) + (XSDPS_PRES_STATE_OFFSET)) + XSdPs_In32((BaseAddress) + (XSDPS_PRES_STATE_OFFSET)) /************************** Function Prototypes ******************************/ diff --git a/bsp_z7/ps7_cortexa9_0/include/xstatus.h b/bsp_z7/ps7_cortexa9_0/include/xstatus.h index 85d1e73..f534bdf 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xstatus.h +++ b/bsp_z7/ps7_cortexa9_0/include/xstatus.h @@ -32,6 +32,7 @@ extern "C" { #include "xil_types.h" #include "xil_assert.h" +#include "bspconfig.h" /************************** Constant Definitions *****************************/ diff --git a/bsp_z7/ps7_cortexa9_0/include/xttcps.h b/bsp_z7/ps7_cortexa9_0/include/xttcps.h index 643e73e..e62fc6f 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xttcps.h +++ b/bsp_z7/ps7_cortexa9_0/include/xttcps.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -149,6 +149,7 @@ * It fixes CR#1084697. * 3.16 adk 04/19/22 Fix infinite loop in the examples by adding polled * timeout loop. +* 3.18 adk 04/14/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -181,6 +182,7 @@ typedef void (*XTtcPs_StatusHandler) (const void *CallBackRef, u32 StatusEvent); #define XTTCPS_MAX_INTERVAL_COUNT 0xFFFFFFFFU #endif +#define XTTCPS_NUM_COUNTERS 3U /** @name Configuration options * * Options for the device. Each of the options is bit field, so more than one @@ -203,11 +205,18 @@ typedef void (*XTtcPs_StatusHandler) (const void *CallBackRef, u32 StatusEvent); * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID for device */ +#else + char *Name; +#endif u32 BaseAddress; /**< Base address for device */ u32 InputClockHz; /**< Input clock frequency */ -#ifdef XIL_INTERRUPT - u16 IntrId; +#if !defined(SDT) && defined(XIL_INTERRUPT) + u32 IntrId; + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] Parent base address */ +#elif defined(SDT) + u32 IntrId[XTTCPS_NUM_COUNTERS]; /** Bits[11:0] Interrupt-id Bits[15:12] trigger type and level flags */ UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] Parent base address */ #endif } XTtcPs_Config; @@ -487,7 +496,11 @@ typedef u32 XMatchRegValue; /* * Initialization functions in xttcps_sinit.c */ +#ifndef SDT XTtcPs_Config *XTtcPs_LookupConfig(u16 DeviceId); +#else +XTtcPs_Config *XTtcPs_LookupConfig(u32 BaseAddress); +#endif /* * Required functions, in xttcps.c @@ -495,6 +508,7 @@ XTtcPs_Config *XTtcPs_LookupConfig(u16 DeviceId); s32 XTtcPs_CfgInitialize(XTtcPs *InstancePtr, XTtcPs_Config * ConfigPtr, u32 EffectiveAddr); +u32 XTtcPs_Release(XTtcPs *InstancePtr); void XTtcPs_SetMatchValue(XTtcPs *InstancePtr, u8 MatchIndex, XMatchRegValue Value); XMatchRegValue XTtcPs_GetMatchValue(XTtcPs *InstancePtr, u8 MatchIndex); diff --git a/bsp_z7/ps7_cortexa9_0/include/xuartps.h b/bsp_z7/ps7_cortexa9_0/include/xuartps.h index 20dd99f..89ed5fd 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xuartps.h +++ b/bsp_z7/ps7_cortexa9_0/include/xuartps.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (C) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -149,6 +149,7 @@ * 3.9 rna 12/03/19 Modified the XUARTPS_MAX_RATE macro. * 3.9 sd 02/06/20 Added clock support * 3.12 gm 11/04/22 Added timeout support using Xil_WaitForEvent +* 3.13 adk 14/04/23 Added support for system device-tree flow. * * * @@ -272,13 +273,23 @@ extern "C" { * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddress; /**< Base address of device (IPIF) */ u32 InputClockHz;/**< Input clock frequency */ s32 ModemPinsConnected; /** Specifies whether modem pins are connected * to MIO or FMIO */ -#if defined (XCLOCKING) - u32 RefClk; /**< Input clock frequency */ +#if defined (XCLOCKING) || defined(SDT) + u32 RefClk; /**< Input clock frequency */ +#endif +#if defined(SDT) + u32 IntrId; /** Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ #endif } XUartPs_Config; @@ -444,7 +455,11 @@ typedef struct { /************************** Function Prototypes *****************************/ /* Static lookup function implemented in xuartps_sinit.c */ +#ifndef SDT XUartPs_Config *XUartPs_LookupConfig(u16 DeviceId); +#else +XUartPs_Config *XUartPs_LookupConfig(u32 BaseAddress); +#endif /* Interface functions implemented in xuartps.c */ s32 XUartPs_CfgInitialize(XUartPs *InstancePtr, diff --git a/bsp_z7/ps7_cortexa9_0/include/xuartps_hw.h b/bsp_z7/ps7_cortexa9_0/include/xuartps_hw.h index 59d4ccf..f45d5c8 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xuartps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xuartps_hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (C) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -32,6 +32,8 @@ * 3.1 kvn 04/10/15 Modified code for latest RTL changes. * 3.6 ms 02/16/18 Updates flow control mode offset value in * modem control register. +* 4.0 sd 02/02/24 Added macros for transmission FIFO empty check +* and transmission active state check * * * @@ -48,6 +50,7 @@ extern "C" { #include "xil_types.h" #include "xil_assert.h" #include "xil_io.h" +#include "xstatus.h" /************************** Constant Definitions *****************************/ @@ -408,6 +411,36 @@ extern "C" { ((Xil_In32((BaseAddress) + XUARTPS_SR_OFFSET) & \ (u32)XUARTPS_SR_TXFULL) == (u32)XUARTPS_SR_TXFULL) +/****************************************************************************/ +/** +* Check if transmission FIFO is empty +* +* @return TRUE if the TX FIFO is empty, FALSE if Tx FIFO is not empty +* +* @note C-Style signature: +* u32 XUartPs_IsTransmitEmpty(u32 BaseAddress) +* +******************************************************************************/ +#define XUartPs_IsTransmitEmpty(BaseAddress) \ + ((Xil_In32((BaseAddress) + XUARTPS_SR_OFFSET) & \ + (u32)XUARTPS_SR_TXEMPTY) == (u32)XUARTPS_SR_TXEMPTY) + +/****************************************************************************/ +/** +* Check if transmission state machine is active +* +* @return TRUE if the TX state machine is active, FALSE if Tx state machine +* is In-active +* +* @note C-Style signature: +* u32 XUartPs_IsTransmitActive(u32 BaseAddress) +* +******************************************************************************/ +#define XUartPs_IsTransmitActive(BaseAddress) \ + ((Xil_In32((BaseAddress) + XUARTPS_SR_OFFSET) & \ + (u32)XUARTPS_SR_TACTIVE) == (u32)XUARTPS_SR_TACTIVE) + + /************************** Function Prototypes ******************************/ void XUartPs_SendByte(u32 BaseAddress, u8 Data); @@ -416,6 +449,8 @@ u8 XUartPs_RecvByte(u32 BaseAddress); void XUartPs_ResetHw(u32 BaseAddress); +void XUartPs_WaitTransmitDone(u32 BaseAddress); + /************************** Variable Definitions *****************************/ #ifdef __cplusplus diff --git a/bsp_z7/ps7_cortexa9_0/include/xusbps.h b/bsp_z7/ps7_cortexa9_0/include/xusbps.h index 5c01051..d215b77 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xusbps.h +++ b/bsp_z7/ps7_cortexa9_0/include/xusbps.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xusbps.h -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * @details * @@ -163,6 +164,7 @@ * examples. * 2.5 pm 02/20/20 Added ISO support for usb 2.0 and ch9 common framework * calls. + * 2.8 pm 07/07/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -256,13 +258,13 @@ extern "C" { #define XUSBPS_EP_STS_CONTROLLER_STATE 2 /**< Current controller state. */ /* @} */ - /* - * Device Speeds - */ - #define XUSBPS_SPEED_UNKNOWN 0U - #define XUSBPS_SPEED_LOW 1U - #define XUSBPS_SPEED_FULL 2U - #define XUSBPS_SPEED_HIGH 3U +/* + * Device Speeds + */ +#define XUSBPS_SPEED_UNKNOWN 0U +#define XUSBPS_SPEED_LOW 1U +#define XUSBPS_SPEED_FULL 2U +#define XUSBPS_SPEED_HIGH 3U /** * @name USB Default alternate setting @@ -272,15 +274,15 @@ extern "C" { #define XUSBPS_DEFAULT_ALT_SETTING 0 /**< The default alternate setting is 0 */ /* @} */ - /* - * Device States - */ - #define XUSBPS_STATE_ATTACHED 0U - #define XUSBPS_STATE_POWERED 1U - #define XUSBPS_STATE_DEFAULT 2U - #define XUSBPS_STATE_ADDRESS 3U - #define XUSBPS_STATE_CONFIGURED 4U - #define XUSBPS_STATE_SUSPENDED 5U +/* + * Device States + */ +#define XUSBPS_STATE_ATTACHED 0U +#define XUSBPS_STATE_POWERED 1U +#define XUSBPS_STATE_DEFAULT 2U +#define XUSBPS_STATE_ADDRESS 3U +#define XUSBPS_STATE_CONFIGURED 4U +#define XUSBPS_STATE_SUSPENDED 5U /** * @name Endpoint event types @@ -290,11 +292,11 @@ extern "C" { * @{ */ #define XUSBPS_EP_EVENT_SETUP_DATA_RECEIVED 0x01 - /**< Setup data has been received on the endpoint. */ +/**< Setup data has been received on the endpoint. */ #define XUSBPS_EP_EVENT_DATA_RX 0x02 - /**< Data frame has been received on the endpoint. */ +/**< Data frame has been received on the endpoint. */ #define XUSBPS_EP_EVENT_DATA_TX 0x03 - /**< Data frame has been sent on the endpoint. */ +/**< Data frame has been sent on the endpoint. */ /* @} */ @@ -303,7 +305,7 @@ extern "C" { * @{ */ #define XUSBPS_MAX_PACKET_SIZE 1024 - /**< Maximum value can be put into the queue head */ +/**< Maximum value can be put into the queue head */ /* @} */ /**************************** Type Definitions *******************************/ @@ -320,7 +322,7 @@ extern "C" { * was registered. */ typedef void (*XUsbPs_EpHandlerFunc)(void *CallBackRef, - u8 EpNum, u8 EventType, void *Data); + u8 EpNum, u8 EventType, void *Data); /****************************************************************************** * This data type defines the callback function to be used for Endpoint @@ -369,24 +371,24 @@ typedef u8 XUsbPs_dTD[XUSBPS_dTD_ALIGN]; */ typedef struct { XUsbPs_dQH *dQH; - /**< Pointer to the Queue Head structure of the endpoint. */ + /**< Pointer to the Queue Head structure of the endpoint. */ XUsbPs_dTD *dTDs; - /**< Pointer to the first dTD of the dTD list for this - * endpoint. */ + /**< Pointer to the first dTD of the dTD list for this + * endpoint. */ XUsbPs_dTD *dTDCurr; - /**< Buffer to the currently processed descriptor. */ + /**< Buffer to the currently processed descriptor. */ u8 *dTDBufs; - /**< Pointer to the first buffer of the buffer list for this - * endpoint. */ + /**< Pointer to the first buffer of the buffer list for this + * endpoint. */ XUsbPs_EpHandlerFunc HandlerFunc; XUsbPs_EpIsoHandlerFunc HandlerIsoFunc; - /**< Handler function for this endpoint. */ + /**< Handler function for this endpoint. */ void *HandlerRef; - /**< User data reference for the handler. */ + /**< User data reference for the handler. */ u32 RequestedBytes; /**< RequestedBytes for transfer */ u32 BytesTxed; /**< Actual Bytes transferred */ u8 *BufferPtr; /**< Buffer location */ @@ -400,23 +402,23 @@ typedef struct { */ typedef struct { XUsbPs_dQH *dQH; - /**< Pointer to the Queue Head structure of the endpoint. */ + /**< Pointer to the Queue Head structure of the endpoint. */ XUsbPs_dTD *dTDs; - /**< List of pointers to the Transfer Descriptors of the - * endpoint. */ + /**< List of pointers to the Transfer Descriptors of the + * endpoint. */ XUsbPs_dTD *dTDHead; - /**< Buffer to the next available descriptor in the list. */ + /**< Buffer to the next available descriptor in the list. */ XUsbPs_dTD *dTDTail; - /**< Buffer to the last unsent descriptor in the list*/ + /**< Buffer to the last unsent descriptor in the list*/ XUsbPs_EpHandlerFunc HandlerFunc; XUsbPs_EpIsoHandlerFunc HandlerIsoFunc; - /**< Handler function for this endpoint. */ + /**< Handler function for this endpoint. */ void *HandlerRef; - /**< User data reference for the handler. */ + /**< User data reference for the handler. */ u32 RequestedBytes; /**< RequestedBytes for transfer */ u32 BytesTxed; /**< Actual Bytes transferred */ u8 *BufferPtr; /**< Buffer location */ @@ -462,21 +464,21 @@ XUsbPs_SetupData; */ typedef struct { u32 Type; - /**< Endpoint type: - - XUSBPS_EP_TYPE_CONTROL - - XUSBPS_EP_TYPE_ISOCHRONOUS - - XUSBPS_EP_TYPE_BULK - - XUSBPS_EP_TYPE_INTERRUPT */ + /**< Endpoint type: + - XUSBPS_EP_TYPE_CONTROL + - XUSBPS_EP_TYPE_ISOCHRONOUS + - XUSBPS_EP_TYPE_BULK + - XUSBPS_EP_TYPE_INTERRUPT */ u32 NumBufs; - /**< Number of buffers to be handled by this endpoint. */ + /**< Number of buffers to be handled by this endpoint. */ u32 BufSize; - /**< Buffer size. Only relevant for OUT (receive) Endpoints. */ + /**< Buffer size. Only relevant for OUT (receive) Endpoints. */ u16 MaxPacketSize; - /**< Maximum packet size for this endpoint. This number will - * define the maximum number of bytes sent on the wire per - * transaction. Range: 0..1024 */ + /**< Maximum packet size for this endpoint. This number will + * define the maximum number of bytes sent on the wire per + * transaction. Range: 0..1024 */ } XUsbPs_EpSetup; @@ -502,7 +504,7 @@ typedef struct { in the core. */ XUsbPs_EpConfig EpCfg[XUSBPS_MAX_ENDPOINTS]; - /**< List of endpoint configurations. */ + /**< List of endpoint configurations. */ u32 DMAMemPhys; /**< Physical base address of DMAable memory @@ -518,7 +520,7 @@ typedef struct { * structure which is allocated by the caller. */ XUsbPs_Endpoint Ep[XUSBPS_MAX_ENDPOINTS]; - /**< List of endpoint metadata structures. */ + /**< List of endpoint metadata structures. */ u32 PhysAligned; /**< 64 byte aligned base address of the DMA memory block. Will be computed and set by @@ -536,8 +538,17 @@ typedef struct { * XUsbPs_ConfigureDevice() function call */ typedef struct { +#ifndef SDT u16 DeviceID; /**< Unique ID of controller. */ +#else + char *Name; /**< Unique Name of controller */ +#endif u32 BaseAddress; /**< Core register base address. */ +#ifdef SDT + u16 IntrId; /** Bits[11:0] Interrupt-id Bits[15:12] trigger type */ + /** level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] */ +#endif } XUsbPs_Config; typedef XUsbPs_Config Usb_Config; @@ -556,7 +567,7 @@ struct Usb_DevData { */ typedef struct { XUsbPs_SetupData SetupData; - /**< Setup Packet buffer */ + /**< Setup Packet buffer */ XUsbPs_Config Config; /**< Configuration structure */ int CurrentAltSetting; /**< Current alternative setting of interface */ @@ -573,15 +584,15 @@ typedef struct { * XUsbPs_ConfigureDevice() function call. */ XUsbPs_DeviceConfig DeviceConfig; - /**< Configuration for the DEVICE mode. */ + /**< Configuration for the DEVICE mode. */ XUsbPs_IntrHandlerFunc HandlerFunc; - /**< Handler function for the controller. */ + /**< Handler function for the controller. */ void *HandlerRef; - /**< User data reference for the handler. */ + /**< User data reference for the handler. */ u32 HandlerMask; - /**< User interrupt mask. Defines which interrupts will cause - * the callback to be called. */ + /**< User interrupt mask. Defines which interrupts will cause + * the callback to be called. */ struct Usb_DevData *AppData; u8 IsConfigDone; void *data_ptr; /* pointer for storing applications data */ @@ -655,7 +666,7 @@ typedef struct { ******************************************************************************/ #define XUsbPs_ForceFS(InstancePtr) \ XUsbPs_SetBits(InstancePtr, XUSBPS_PORTSCR1_OFFSET, \ - XUSBPS_PORTSCR_PFSC_MASK) + XUSBPS_PORTSCR_PFSC_MASK) /*****************************************************************************/ @@ -671,14 +682,14 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_StartTimer0(InstancePtr, Interval) \ -{ \ - XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XUSBPS_TIMER0_LD_OFFSET, (Interval)); \ - XUsbPs_SetBits(InstancePtr, XUSBPS_TIMER0_CTL_OFFSET, \ - XUSBPS_TIMER_RUN_MASK | \ - XUSBPS_TIMER_RESET_MASK | \ - XUSBPS_TIMER_REPEAT_MASK); \ -} \ + { \ + XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ + XUSBPS_TIMER0_LD_OFFSET, (Interval)); \ + XUsbPs_SetBits(InstancePtr, XUSBPS_TIMER0_CTL_OFFSET, \ + XUSBPS_TIMER_RUN_MASK | \ + XUSBPS_TIMER_RESET_MASK | \ + XUSBPS_TIMER_REPEAT_MASK); \ + } \ /*****************************************************************************/ @@ -693,7 +704,7 @@ typedef struct { ******************************************************************************/ #define XUsbPs_StopTimer0(InstancePtr) \ XUsbPs_ClrBits(InstancePtr, XUSBPS_TIMER0_CTL_OFFSET, \ - XUSBPS_TIMER_RUN_MASK) + XUSBPS_TIMER_RUN_MASK) /*****************************************************************************/ @@ -708,8 +719,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_ReadTimer0(InstancePtr) \ XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XUSBPS_TIMER0_CTL_OFFSET) & \ - XUSBPS_TIMER_COUNTER_MASK + XUSBPS_TIMER0_CTL_OFFSET) & \ + XUSBPS_TIMER_COUNTER_MASK /*****************************************************************************/ @@ -724,7 +735,7 @@ typedef struct { ******************************************************************************/ #define XUsbPs_RemoteWakeup(InstancePtr) \ XUsbPs_SetBits(InstancePtr, XUSBPS_PORTSCR1_OFFSET, \ - XUSBPS_PORTSCR_FPR_MASK) + XUSBPS_PORTSCR_FPR_MASK) /****************************************************************************** @@ -749,8 +760,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_EpEnable(InstancePtr, EpNum, Dir) \ XUsbPs_SetBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum), \ - ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXE_MASK : 0) | \ - ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXE_MASK : 0)) + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXE_MASK : 0) | \ + ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXE_MASK : 0)) /*****************************************************************************/ @@ -770,8 +781,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_EpDisable(InstancePtr, EpNum, Dir) \ XUsbPs_ClrBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum), \ - ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXE_MASK : 0) | \ - ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXE_MASK : 0)) + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXE_MASK : 0) | \ + ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXE_MASK : 0)) /*****************************************************************************/ @@ -792,8 +803,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_EpStall(InstancePtr, EpNum, Dir) \ XUsbPs_SetBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum), \ - ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXS_MASK : 0) | \ - ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXS_MASK : 0)) + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXS_MASK : 0) | \ + ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXS_MASK : 0)) /*****************************************************************************/ @@ -813,8 +824,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_EpUnStall(InstancePtr, EpNum, Dir) \ XUsbPs_ClrBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum), \ - ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXS_MASK : 0) | \ - ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXS_MASK : 0)) + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXS_MASK : 0) | \ + ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXS_MASK : 0)) /*****************************************************************************/ @@ -834,8 +845,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_EpFlush(InstancePtr, EpNum, Dir) \ XUsbPs_SetBits(InstancePtr, XUSBPS_EPFLUSH_OFFSET, \ - 1 << (EpNum + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? \ - XUSBPS_EPFLUSH_RX_SHIFT:XUSBPS_EPFLUSH_TX_SHIFT))) \ + 1 << (EpNum + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? \ + XUSBPS_EPFLUSH_RX_SHIFT:XUSBPS_EPFLUSH_TX_SHIFT))) \ /*****************************************************************************/ /** @@ -849,7 +860,7 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_IntrEnable(InstancePtr, IntrMask) \ - XUsbPs_SetBits(InstancePtr, XUSBPS_IER_OFFSET, IntrMask) + XUsbPs_SetBits(InstancePtr, XUSBPS_IER_OFFSET, IntrMask) /*****************************************************************************/ @@ -865,7 +876,7 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_IntrDisable(InstancePtr, IntrMask) \ - XUsbPs_ClrBits(InstancePtr, XUSBPS_IER_OFFSET, IntrMask) + XUsbPs_ClrBits(InstancePtr, XUSBPS_IER_OFFSET, IntrMask) /*****************************************************************************/ @@ -914,7 +925,7 @@ typedef struct { ******************************************************************************/ #define XUsbPs_NakIntrClear(InstancePtr, NakIntrMask) \ XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XUSBPS_EPNAKISR_OFFSET, NakIntrMask) + XUSBPS_EPNAKISR_OFFSET, NakIntrMask) @@ -940,8 +951,8 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_SetIntrThreshold(InstancePtr, Threshold) \ - XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XUSBPS_CMD_OFFSET, (Threshold))\ + XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ + XUSBPS_CMD_OFFSET, (Threshold))\ /*****************************************************************************/ @@ -955,8 +966,8 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_SetSetupTripwire(InstancePtr) \ - XUsbPs_SetBits(InstancePtr, XUSBPS_CMD_OFFSET, \ - XUSBPS_CMD_SUTW_MASK) + XUsbPs_SetBits(InstancePtr, XUSBPS_CMD_OFFSET, \ + XUSBPS_CMD_SUTW_MASK) /*****************************************************************************/ @@ -970,8 +981,8 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_ClrSetupTripwire(InstancePtr) \ - XUsbPs_ClrBits(InstancePtr, XUSBPS_CMD_OFFSET, \ - XUSBPS_CMD_SUTW_MASK) + XUsbPs_ClrBits(InstancePtr, XUSBPS_CMD_OFFSET, \ + XUSBPS_CMD_SUTW_MASK) /*****************************************************************************/ @@ -989,9 +1000,9 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_SetupTripwireIsSet(InstancePtr) \ - (XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XUSBPS_CMD_OFFSET) & \ - XUSBPS_CMD_SUTW_MASK ? TRUE : FALSE) + (XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + XUSBPS_CMD_OFFSET) & \ + XUSBPS_CMD_SUTW_MASK ? TRUE : FALSE) /****************************************************************************** @@ -1015,8 +1026,8 @@ typedef struct { *****************************************************************************/ #define XUsbPs_SetBits(InstancePtr, RegOffset, Bits) \ XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, RegOffset, \ - XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - RegOffset) | (Bits)); + XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + RegOffset) | (Bits)); /****************************************************************************/ @@ -1037,8 +1048,8 @@ typedef struct { *****************************************************************************/ #define XUsbPs_ClrBits(InstancePtr, RegOffset, Bits) \ XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, RegOffset, \ - XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - RegOffset) & ~(Bits)); + XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + RegOffset) & ~(Bits)); /************************** Function Prototypes ******************************/ @@ -1049,10 +1060,10 @@ typedef struct { * Implemented in file xusbps.c */ int XUsbPs_CfgInitialize(XUsbPs *InstancePtr, - const XUsbPs_Config *ConfigPtr, u32 BaseAddress); + const XUsbPs_Config *ConfigPtr, u32 BaseAddress); int XUsbPs_ConfigureDevice(XUsbPs *InstancePtr, - const XUsbPs_DeviceConfig *CfgPtr); + const XUsbPs_DeviceConfig *CfgPtr); /** * Common functions used for DEVICE/HOST mode. @@ -1086,23 +1097,23 @@ int XUsbPs_RequestHostResume(const XUsbPs *InstancePtr); int XUsbPs_EpBufferSend(XUsbPs *InstancePtr, u8 EpNum, const u8 *BufferPtr, u32 BufferLen); int XUsbPs_EpBufferSendWithZLT(XUsbPs *InstancePtr, u8 EpNum, - const u8 *BufferPtr, u32 BufferLen); + const u8 *BufferPtr, u32 BufferLen); int XUsbPs_EpBufferReceive(XUsbPs *InstancePtr, u8 EpNum, - u8 **BufferPtr, u32 *BufferLenPtr, u32 *Handle); + u8 **BufferPtr, u32 *BufferLenPtr, u32 *Handle); void XUsbPs_EpBufferRelease(u32 Handle); int XUsbPs_EpSetHandler(XUsbPs *InstancePtr, u8 EpNum, u8 Direction, XUsbPs_EpHandlerFunc CallBackFunc, void *CallBackRef); s32 XUsbPs_EpSetIsoHandler(XUsbPs *InstancePtr, u8 EpNum, u8 Direction, - XUsbPs_EpIsoHandlerFunc CallBackFunc); + XUsbPs_EpIsoHandlerFunc CallBackFunc); int XUsbPs_EpGetSetupData(XUsbPs *InstancePtr, int EpNum, - XUsbPs_SetupData *SetupDataPtr); + XUsbPs_SetupData *SetupDataPtr); int XUsbPs_EpPrime(XUsbPs *InstancePtr, u8 EpNum, u8 Direction); int XUsbPs_ReconfigureEp(XUsbPs *InstancePtr, XUsbPs_DeviceConfig *CfgPtr, - int EpNum, unsigned short NewDirection, int DirectionChanged); + int EpNum, unsigned short NewDirection, int DirectionChanged); /* * Interrupt handling functions @@ -1112,17 +1123,21 @@ int XUsbPs_ReconfigureEp(XUsbPs *InstancePtr, XUsbPs_DeviceConfig *CfgPtr, void XUsbPs_IntrHandler(void *InstancePtr); int XUsbPs_IntrSetHandler(XUsbPs *InstancePtr, - XUsbPs_IntrHandlerFunc CallBackFunc, - void *CallBackRef, u32 Mask); + XUsbPs_IntrHandlerFunc CallBackFunc, + void *CallBackRef, u32 Mask); void XUsbPs_EpGetData(XUsbPs *InstancePtr, u8 EpNum, u32 BufferLen); s32 XUsbPs_EpDataBufferReceive(XUsbPs *InstancePtr, u8 EpNum, - u8 *BufferPtr, u32 BufferLen); + u8 *BufferPtr, u32 BufferLen); /* * Helper functions for static configuration. * Implemented in xusbps_sinit.c */ +#ifndef SDT XUsbPs_Config *XUsbPs_LookupConfig(u16 DeviceId); +#else +XUsbPs_Config *XUsbPs_LookupConfig(u32 BaseAddress); +#endif #ifdef __cplusplus } diff --git a/bsp_z7/ps7_cortexa9_0/include/xusbps_endpoint.h b/bsp_z7/ps7_cortexa9_0/include/xusbps_endpoint.h index b924726..2869929 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xusbps_endpoint.h +++ b/bsp_z7/ps7_cortexa9_0/include/xusbps_endpoint.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xusbps_endpoint.h -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * * This is an internal file containung the definitions for endpoints. It is @@ -67,9 +68,9 @@ extern "C" { * @{ */ #define XUSBPS_dTDNLP_T_MASK 0x00000001 - /**< USB dTD Next Link Pointer Terminate Bit */ +/**< USB dTD Next Link Pointer Terminate Bit */ #define XUSBPS_dTDNLP_ADDR_MASK 0xFFFFFFE0 - /**< USB dTD Next Link Pointer Address [31:5] */ +/**< USB dTD Next Link Pointer Address [31:5] */ /* @} */ @@ -108,16 +109,16 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDInvalidateCache(dTDPtr) \ - Xil_DCacheInvalidateRange((unsigned int)dTDPtr, sizeof(XUsbPs_dTD)) + Xil_DCacheInvalidateRange((unsigned int)dTDPtr, sizeof(XUsbPs_dTD)) #define XUsbPs_dTDFlushCache(dTDPtr) \ - Xil_DCacheFlushRange((unsigned int)dTDPtr, sizeof(XUsbPs_dTD)) + Xil_DCacheFlushRange((unsigned int)dTDPtr, sizeof(XUsbPs_dTD)) #define XUsbPs_dQHInvalidateCache(dQHPtr) \ - Xil_DCacheInvalidateRange((unsigned int)dQHPtr, sizeof(XUsbPs_dQH)) + Xil_DCacheInvalidateRange((unsigned int)dQHPtr, sizeof(XUsbPs_dQH)) #define XUsbPs_dQHFlushCache(dQHPtr) \ - Xil_DCacheFlushRange((unsigned int)dQHPtr, sizeof(XUsbPs_dQH)) + Xil_DCacheFlushRange((unsigned int)dQHPtr, sizeof(XUsbPs_dQH)) /*****************************************************************************/ /** @@ -132,9 +133,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetTransferLen(dTDPtr, Len) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ (XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) & \ - ~XUSBPS_dTDTOKEN_LEN_MASK) | ((Len) << 16)) + ~XUSBPS_dTDTOKEN_LEN_MASK) | ((Len) << 16)) /*****************************************************************************/ @@ -151,8 +152,8 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDGetNLP(dTDPtr) \ - (XUsbPs_dTD *) ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP)\ - & XUSBPS_dTDNLP_ADDR_MASK)) + (XUsbPs_dTD *) ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP)\ + & XUSBPS_dTDNLP_ADDR_MASK)) /*****************************************************************************/ @@ -168,10 +169,10 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetNLP(dTDPtr, NLP) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ (XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP) & \ - ~XUSBPS_dTDNLP_ADDR_MASK) | \ - ((NLP) & XUSBPS_dTDNLP_ADDR_MASK)) + ~XUSBPS_dTDNLP_ADDR_MASK) | \ + ((NLP) & XUSBPS_dTDNLP_ADDR_MASK)) /*****************************************************************************/ @@ -188,8 +189,8 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDGetTransferLen(dTDPtr) \ - (u32) ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) \ - & XUSBPS_dTDTOKEN_LEN_MASK) >> 16) + (u32) ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) \ + & XUSBPS_dTDTOKEN_LEN_MASK) >> 16) /*****************************************************************************/ @@ -205,9 +206,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetIOC(dTDPtr) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) | \ - XUSBPS_dTDTOKEN_IOC_MASK) + XUSBPS_dTDTOKEN_IOC_MASK) /*****************************************************************************/ @@ -222,9 +223,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetTerminate(dTDPtr) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP) | \ - XUSBPS_dTDNLP_T_MASK) + XUSBPS_dTDNLP_T_MASK) /*****************************************************************************/ @@ -239,9 +240,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDClrTerminate(dTDPtr) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP) & \ - ~XUSBPS_dTDNLP_T_MASK) + ~XUSBPS_dTDNLP_T_MASK) /*****************************************************************************/ @@ -260,8 +261,8 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDIsActive(dTDPtr) \ - ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) & \ - XUSBPS_dTDTOKEN_ACTIVE_MASK) ? TRUE : FALSE) + ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) & \ + XUSBPS_dTDTOKEN_ACTIVE_MASK) ? TRUE : FALSE) /*****************************************************************************/ @@ -276,9 +277,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetActive(dTDPtr) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) | \ - XUSBPS_dTDTOKEN_ACTIVE_MASK) + XUSBPS_dTDTOKEN_ACTIVE_MASK) /*****************************************************************************/ /** @@ -293,9 +294,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetMultO(dTDPtr, val) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ (XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) & \ - (~XUSBPS_dTDTOKEN_MULTO_MASK)) | val) + (~XUSBPS_dTDTOKEN_MULTO_MASK)) | val) /*****************************************************************************/ @@ -326,7 +327,7 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_WritedTD(dTDPtr, Id, Val) \ - (*(u32 *) ((u32)(dTDPtr) + (u32)(Id)) = (u32)(Val)) + (*(u32 *) ((u32)(dTDPtr) + (u32)(Id)) = (u32)(Val)) /******************************************************************************/ @@ -368,17 +369,17 @@ extern "C" { * @{ */ #define XUSBPS_dQHCFG_IOS_MASK 0x00008000 - /**< USB dQH Interrupt on Setup Bit */ +/**< USB dQH Interrupt on Setup Bit */ #define XUSBPS_dQHCFG_MPL_MASK 0x07FF0000 - /**< USB dQH Maximum Packet Length - * Field [10:0] */ +/**< USB dQH Maximum Packet Length + * Field [10:0] */ #define XUSBPS_dQHCFG_MPL_SHIFT 16 #define XUSBPS_dQHCFG_ZLT_MASK 0x20000000 - /**< USB dQH Zero Length Termination - * Select Bit */ +/**< USB dQH Zero Length Termination + * Select Bit */ #define XUSBPS_dQHCFG_MULT_MASK 0xC0000000 - /* USB dQH Number of Transactions Field - * [1:0] */ +/* USB dQH Number of Transactions Field + * [1:0] */ #define XUSBPS_dQHCFG_MULT_SHIFT 30 /* @} */ @@ -396,9 +397,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dQHSetMaxPacketLen(dQHPtr, Len) \ - XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ + XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ (XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & \ - ~XUSBPS_dQHCFG_MPL_MASK) | ((Len) << 16)) + ~XUSBPS_dQHCFG_MPL_MASK) | ((Len) << 16)) /*****************************************************************************/ /** @@ -412,9 +413,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dQHSetIOS(dQHPtr) \ - XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ + XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) | \ - XUSBPS_dQHCFG_IOS_MASK) + XUSBPS_dQHCFG_IOS_MASK) /*****************************************************************************/ /** @@ -428,9 +429,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dQHClrIOS(dQHPtr) \ - XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ + XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & \ - ~XUSBPS_dQHCFG_IOS_MASK) + ~XUSBPS_dQHCFG_IOS_MASK) /*****************************************************************************/ /** @@ -445,9 +446,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dQHEnableZLT(dQHPtr) \ - XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ + XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & \ - ~XUSBPS_dQHCFG_ZLT_MASK) + ~XUSBPS_dQHCFG_ZLT_MASK) /*****************************************************************************/ @@ -463,9 +464,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dQHDisableZLT(dQHPtr) \ - XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ + XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) | \ - XUSBPS_dQHCFG_ZLT_MASK) + XUSBPS_dQHCFG_ZLT_MASK) /*****************************************************************************/ /** @@ -495,7 +496,7 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_WritedQH(dQHPtr, Id, Val) \ - (*(u32 *) ((u32)(dQHPtr) + (u32)(Id)) = (u32)(Val)) + (*(u32 *) ((u32)(dQHPtr) + (u32)(Id)) = (u32)(Val)) diff --git a/bsp_z7/ps7_cortexa9_0/include/xusbps_hw.h b/bsp_z7/ps7_cortexa9_0/include/xusbps_hw.h index 4f985dc..2f057a6 100644 --- a/bsp_z7/ps7_cortexa9_0/include/xusbps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/include/xusbps_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xusbps_hw.h -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * * This header file contains identifiers and low-level driver functions (or @@ -22,7 +23,7 @@ * 1.00a wgr 10/10/10 First release * 1.04a nm 10/23/12 Fixed CR# 679106. * 1.05a kpc 07/03/13 Added XUsbPs_ResetHw function prototype - * 2.00a kpc 04/03/14 Fixed CR#777764. Corrected max endpoint vale and masks + * 2.00a kpc 04/03/14 Fixed CR#777764. Corrected max endpoint vale and masks * 2.5 pm 02/20/20 Added Endpoint Control Register bit positions for Rx & Tx * * @@ -110,7 +111,7 @@ extern "C" { /* NOTE: The Port Control / Status Register index is 1-based. */ #define XUSBPS_PORTSCRn_OFFSET(n) \ - (XUSBPS_PORTSCR1_OFFSET + (((n)-1) * XUSBPS_REG_SPACING)) + (XUSBPS_PORTSCR1_OFFSET + (((n)-1) * XUSBPS_REG_SPACING)) #define XUSBPS_OTGCSR_OFFSET 0x000001A4 /**< OTG Status and Control */ @@ -133,7 +134,7 @@ extern "C" { #define XUSBPS_EP_ALL_MASK 0x0FFF0FFF /**< Mask used for endpoint control * registers */ #define XUSBPS_EPCRn_OFFSET(n) \ - (XUSBPS_EPCR0_OFFSET + ((n) * XUSBPS_REG_SPACING)) + (XUSBPS_EPCR0_OFFSET + ((n) * XUSBPS_REG_SPACING)) #define XUSBPS_EPFLUSH_RX_SHIFT 0 #define XUSBPS_EPFLUSH_TX_SHIFT 16 @@ -251,24 +252,24 @@ extern "C" { #define XUSBPS_IXR_TI1_MASK 0x02000000 /**< Timer 1 Interrupt */ #define XUSBPS_IXR_ALL (XUSBPS_IXR_UI_MASK | \ - XUSBPS_IXR_UE_MASK | \ - XUSBPS_IXR_PC_MASK | \ - XUSBPS_IXR_FRE_MASK | \ - XUSBPS_IXR_AA_MASK | \ - XUSBPS_IXR_UR_MASK | \ - XUSBPS_IXR_SR_MASK | \ - XUSBPS_IXR_SLE_MASK | \ - XUSBPS_IXR_ULPI_MASK | \ - XUSBPS_IXR_HCH_MASK | \ - XUSBPS_IXR_RCL_MASK | \ - XUSBPS_IXR_PS_MASK | \ - XUSBPS_IXR_AS_MASK | \ - XUSBPS_IXR_NAK_MASK | \ - XUSBPS_IXR_UA_MASK | \ - XUSBPS_IXR_UP_MASK | \ - XUSBPS_IXR_TI0_MASK | \ - XUSBPS_IXR_TI1_MASK) - /**< Mask for ALL IRQ types */ + XUSBPS_IXR_UE_MASK | \ + XUSBPS_IXR_PC_MASK | \ + XUSBPS_IXR_FRE_MASK | \ + XUSBPS_IXR_AA_MASK | \ + XUSBPS_IXR_UR_MASK | \ + XUSBPS_IXR_SR_MASK | \ + XUSBPS_IXR_SLE_MASK | \ + XUSBPS_IXR_ULPI_MASK | \ + XUSBPS_IXR_HCH_MASK | \ + XUSBPS_IXR_RCL_MASK | \ + XUSBPS_IXR_PS_MASK | \ + XUSBPS_IXR_AS_MASK | \ + XUSBPS_IXR_NAK_MASK | \ + XUSBPS_IXR_UA_MASK | \ + XUSBPS_IXR_UP_MASK | \ + XUSBPS_IXR_TI0_MASK | \ + XUSBPS_IXR_TI1_MASK) +/**< Mask for ALL IRQ types */ /* @} */ @@ -291,13 +292,13 @@ extern "C" { * @{ */ #define XUSBPS_DEVICEADDR_DEVICEAADV_MASK 0x01000000 - /**< Device Addr Auto Advance */ +/**< Device Addr Auto Advance */ #define XUSBPS_DEVICEADDR_ADDR_MASK 0xFE000000 - /**< Device Address */ +/**< Device Address */ #define XUSBPS_DEVICEADDR_ADDR_SHIFT 25 - /**< Address shift */ +/**< Address shift */ #define XUSBPS_DEVICEADDR_MAX 127 - /**< Biggest allowed address */ +/**< Biggest allowed address */ /* @} */ /** @name USB TT Control Register (TTCTRL) bit positions. @@ -319,11 +320,11 @@ extern "C" { * @{ */ #define XUSBPS_TXFILL_OVERHEAD_MASK 0x000000FF - /**< Scheduler Overhead */ +/**< Scheduler Overhead */ #define XUSBPS_TXFILL_HEALTH_MASK 0x00001F00 - /**< Scheduler Health Cntr */ +/**< Scheduler Health Cntr */ #define XUSBPS_TXFILL_BURST_MASK 0x003F0000 - /**< FIFO Burst Threshold */ +/**< FIFO Burst Threshold */ /* @} */ @@ -411,22 +412,22 @@ extern "C" { * Enable Bit */ #define XUSBPS_OTG_ISB_ALL (XUSBPS_OTGSC_IDIS_MASK |\ - XUSBPS_OTGSC_AVVIS_MASK | \ - XUSBPS_OTGSC_ASVIS_MASK | \ - XUSBPS_OTGSC_BSVIS_MASK | \ - XUSBPS_OTGSC_BSEIS_MASK | \ - XUSBPS_OTGSC_1MSS_MASK | \ - XUSBPS_OTGSC_DPIS_MASK) - /** Mask for All IRQ status masks */ + XUSBPS_OTGSC_AVVIS_MASK | \ + XUSBPS_OTGSC_ASVIS_MASK | \ + XUSBPS_OTGSC_BSVIS_MASK | \ + XUSBPS_OTGSC_BSEIS_MASK | \ + XUSBPS_OTGSC_1MSS_MASK | \ + XUSBPS_OTGSC_DPIS_MASK) +/** Mask for All IRQ status masks */ #define XUSBPS_OTG_IEB_ALL (XUSBPS_OTGSC_IDIE_MASK |\ - XUSBPS_OTGSC_AVVIE_MASK | \ - XUSBPS_OTGSC_ASVIE_MASK | \ - XUSBPS_OTGSC_BSVIE_MASK | \ - XUSBPS_OTGSC_BSEE_IEB_MASK | \ - XUSBPS_OTGSC_1MSE_MASK | \ - XUSBPS_OTGSC_DPIE_MASK) - /** Mask for All IRQ Enable masks */ + XUSBPS_OTGSC_AVVIE_MASK | \ + XUSBPS_OTGSC_ASVIE_MASK | \ + XUSBPS_OTGSC_BSVIE_MASK | \ + XUSBPS_OTGSC_BSEE_IEB_MASK | \ + XUSBPS_OTGSC_1MSE_MASK | \ + XUSBPS_OTGSC_DPIE_MASK) +/** Mask for All IRQ Enable masks */ /* @} */ @@ -468,7 +469,7 @@ extern "C" { * *****************************************************************************/ #define XUsbPs_ReadReg(BaseAddress, RegOffset) \ - Xil_In32(BaseAddress + (RegOffset)) + Xil_In32(BaseAddress + (RegOffset)) /****************************************************************************/ @@ -487,7 +488,7 @@ extern "C" { * *****************************************************************************/ #define XUsbPs_WriteReg(BaseAddress, RegOffset, Data) \ - Xil_Out32(BaseAddress + (RegOffset), (Data)) + Xil_Out32(BaseAddress + (RegOffset), (Data)) /************************** Function Prototypes ******************************/ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/cpu_cortexa9/src/xcpu_cortexa9.h b/bsp_z7/ps7_cortexa9_0/libsrc/cpu_cortexa9/src/xcpu_cortexa9.h index 3c23a5f..f6b3728 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/cpu_cortexa9/src/xcpu_cortexa9.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/cpu_cortexa9/src/xcpu_cortexa9.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xcpu_cortexa9.h -* @addtogroup cpu_cortexa9_v2_11 +* @addtogroup cpu_cortexa9 Overview * @{ * @details * diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.c b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.c index 5bac22a..6730ca1 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdevcfg.c -* @addtogroup devcfg_v3_7 +* @addtogroup devcfg Overview * @{ * * This file contains the implementation of the interface functions for XDcfg @@ -55,7 +56,7 @@ * XDCFG_INT_STS_OFFSET) & * XDCFG_IXR_D_P_DONE_MASK) != * XDCFG_IXR_D_P_DONE_MASK); -* +* 3.8 Nava 06/21/23 Added support for system device-tree flow. * * * @@ -106,7 +107,7 @@ * ******************************************************************************/ int XDcfg_CfgInitialize(XDcfg *InstancePtr, - XDcfg_Config *ConfigPtr, u32 EffectiveAddress) + XDcfg_Config *ConfigPtr, u32 EffectiveAddress) { Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(ConfigPtr != NULL); @@ -124,7 +125,9 @@ int XDcfg_CfgInitialize(XDcfg *InstancePtr, /* * Copy configuration into instance. */ +#ifndef SDT InstancePtr->Config.DeviceId = ConfigPtr->DeviceId; +#endif /* * Save the base address pointer such that the registers of the block @@ -172,10 +175,10 @@ void XDcfg_EnablePCAP(XDcfg *InstancePtr) CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, - XDCFG_CTRL_OFFSET); + XDCFG_CTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_CTRL_OFFSET, - (CtrlReg | XDCFG_CTRL_PCAP_MODE_MASK)); + (CtrlReg | XDCFG_CTRL_PCAP_MODE_MASK)); } @@ -203,10 +206,10 @@ void XDcfg_DisablePCAP(XDcfg *InstancePtr) CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, - XDCFG_CTRL_OFFSET); + XDCFG_CTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_CTRL_OFFSET, - (CtrlReg & ( ~XDCFG_CTRL_PCAP_MODE_MASK))); + (CtrlReg & ( ~XDCFG_CTRL_PCAP_MODE_MASK))); } @@ -235,10 +238,10 @@ void XDcfg_SetControlRegister(XDcfg *InstancePtr, u32 Mask) CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, - XDCFG_CTRL_OFFSET); + XDCFG_CTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_CTRL_OFFSET, - (CtrlReg | Mask)); + (CtrlReg | Mask)); } @@ -266,10 +269,10 @@ void XDcfg_ClearControlRegister(XDcfg *InstancePtr, u32 Mask) CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, - XDCFG_CTRL_OFFSET); + XDCFG_CTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_CTRL_OFFSET, - (CtrlReg & ~Mask)); + (CtrlReg & ~Mask)); } @@ -488,7 +491,7 @@ void XDcfg_SetRomShadowRegister(XDcfg *InstancePtr, u32 Data) Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_ROM_SHADOW_OFFSET, - Data); + Data); } @@ -545,10 +548,10 @@ void XDcfg_SetMiscControlRegister(XDcfg *InstancePtr, u32 Mask) RegData = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, - XDCFG_MCTRL_OFFSET); + XDCFG_MCTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, XDCFG_MCTRL_OFFSET, - (RegData | Mask)); + (RegData | Mask)); } /****************************************************************************/ @@ -601,10 +604,10 @@ u32 XDcfg_IsDmaBusy(XDcfg *InstancePtr) /* Read the PCAP status register for DMA status */ RegData = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, - XDCFG_STATUS_OFFSET); + XDCFG_STATUS_OFFSET); if ((RegData & XDCFG_STATUS_DMA_CMD_Q_F_MASK) == - XDCFG_STATUS_DMA_CMD_Q_F_MASK){ + XDCFG_STATUS_DMA_CMD_Q_F_MASK) { return XST_SUCCESS; } @@ -637,24 +640,24 @@ u32 XDcfg_IsDmaBusy(XDcfg *InstancePtr) * ****************************************************************************/ void XDcfg_InitiateDma(XDcfg *InstancePtr, u32 SourcePtr, u32 DestPtr, - u32 SrcWordLength, u32 DestWordLength) + u32 SrcWordLength, u32 DestWordLength) { XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_DMA_SRC_ADDR_OFFSET, - SourcePtr); + XDCFG_DMA_SRC_ADDR_OFFSET, + SourcePtr); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_DMA_DEST_ADDR_OFFSET, - DestPtr); + XDCFG_DMA_DEST_ADDR_OFFSET, + DestPtr); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_DMA_SRC_LEN_OFFSET, - SrcWordLength); + XDCFG_DMA_SRC_LEN_OFFSET, + SrcWordLength); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_DMA_DEST_LEN_OFFSET, - DestWordLength); + XDCFG_DMA_DEST_LEN_OFFSET, + DestWordLength); } /******************************************************************************/ @@ -680,8 +683,8 @@ void XDcfg_InitiateDma(XDcfg *InstancePtr, u32 SourcePtr, u32 DestPtr, * ****************************************************************************/ static u32 XDcfg_PcapReadback(XDcfg *InstancePtr, u32 SourcePtr, - u32 SrcWordLength, u32 DestPtr, - u32 DestWordLength) + u32 SrcWordLength, u32 DestPtr, + u32 DestWordLength) { u32 IntrReg; @@ -689,7 +692,7 @@ static u32 XDcfg_PcapReadback(XDcfg *InstancePtr, u32 SourcePtr, * Send READ Frame command to FPGA */ XDcfg_InitiateDma(InstancePtr, SourcePtr, XDCFG_DMA_INVALID_ADDRESS, - SrcWordLength, 0); + SrcWordLength, 0); /* * Store the enabled interrupts to enable before the actual read @@ -701,10 +704,10 @@ static u32 XDcfg_PcapReadback(XDcfg *InstancePtr, u32 SourcePtr, /* * 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); + 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 . */ @@ -714,7 +717,7 @@ static u32 XDcfg_PcapReadback(XDcfg *InstancePtr, u32 SourcePtr, * Initiate the DMA write command. */ XDcfg_InitiateDma(InstancePtr, XDCFG_DMA_INVALID_ADDRESS, (u32)DestPtr, - 0, DestWordLength); + 0, DestWordLength); return XST_SUCCESS; } @@ -762,9 +765,9 @@ static u32 XDcfg_PcapReadback(XDcfg *InstancePtr, u32 SourcePtr, * *****************************************************************************/ u32 XDcfg_Transfer(XDcfg *InstancePtr, - void *SourcePtr, u32 SrcWordLength, - void *DestPtr, u32 DestWordLength, - u32 TransferType) + void *SourcePtr, u32 SrcWordLength, + void *DestPtr, u32 DestWordLength, + u32 TransferType) { u32 CtrlReg; @@ -781,7 +784,7 @@ u32 XDcfg_Transfer(XDcfg *InstancePtr, * Check whether the fabric is in initialized state */ if ((XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_STATUS_OFFSET) - & XDCFG_STATUS_PCFG_INIT_MASK) == 0) { + & XDCFG_STATUS_PCFG_INIT_MASK) == 0) { /* * We don't need to check PCFG_INIT to be high for * non-encrypted loopback transfers. @@ -792,7 +795,7 @@ u32 XDcfg_Transfer(XDcfg *InstancePtr, } if ((TransferType == XDCFG_SECURE_PCAP_WRITE) || - (TransferType == XDCFG_NON_SECURE_PCAP_WRITE)) { + (TransferType == XDCFG_NON_SECURE_PCAP_WRITE)) { /* Check for valid source pointer and length */ if ((!SourcePtr) || (SrcWordLength == 0)) { @@ -803,8 +806,8 @@ u32 XDcfg_Transfer(XDcfg *InstancePtr, CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_MCTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_MCTRL_OFFSET, (CtrlReg & - ~(XDCFG_MCTRL_PCAP_LPBK_MASK))); + XDCFG_MCTRL_OFFSET, (CtrlReg & + ~(XDCFG_MCTRL_PCAP_LPBK_MASK))); if (TransferType == XDCFG_NON_SECURE_PCAP_WRITE) { /* @@ -815,8 +818,8 @@ u32 XDcfg_Transfer(XDcfg *InstancePtr, XDCFG_CTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_CTRL_OFFSET, (CtrlReg & - ~XDCFG_CTRL_PCAP_RATE_EN_MASK)); + XDCFG_CTRL_OFFSET, (CtrlReg & + ~XDCFG_CTRL_PCAP_RATE_EN_MASK)); } if (TransferType == XDCFG_SECURE_PCAP_WRITE) { @@ -828,11 +831,11 @@ u32 XDcfg_Transfer(XDcfg *InstancePtr, * operation. */ XDcfg_SetControlRegister(InstancePtr, - XDCFG_CTRL_PCAP_RATE_EN_MASK); + XDCFG_CTRL_PCAP_RATE_EN_MASK); } XDcfg_InitiateDma(InstancePtr, (u32)SourcePtr, - (u32)DestPtr, SrcWordLength, DestWordLength); + (u32)DestPtr, SrcWordLength, DestWordLength); } @@ -847,8 +850,8 @@ u32 XDcfg_Transfer(XDcfg *InstancePtr, CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_MCTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_MCTRL_OFFSET, (CtrlReg & - ~(XDCFG_MCTRL_PCAP_LPBK_MASK))); + XDCFG_MCTRL_OFFSET, (CtrlReg & + ~(XDCFG_MCTRL_PCAP_LPBK_MASK))); /* * For PCAP readback of FPGA configuration register or memory, @@ -860,26 +863,26 @@ u32 XDcfg_Transfer(XDcfg *InstancePtr, * transfer to support this mode of operation. */ return XDcfg_PcapReadback(InstancePtr, - (u32)SourcePtr, SrcWordLength, - (u32)DestPtr, DestWordLength); + (u32)SourcePtr, SrcWordLength, + (u32)DestPtr, DestWordLength); } if ((TransferType == XDCFG_CONCURRENT_SECURE_READ_WRITE) || - (TransferType == XDCFG_CONCURRENT_NONSEC_READ_WRITE)) { + (TransferType == XDCFG_CONCURRENT_NONSEC_READ_WRITE)) { if ((!SourcePtr) || (SrcWordLength == 0) || - (!DestPtr) || (DestWordLength == 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_MCTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_MCTRL_OFFSET, (CtrlReg | - XDCFG_MCTRL_PCAP_LPBK_MASK)); + XDCFG_MCTRL_OFFSET, (CtrlReg | + XDCFG_MCTRL_PCAP_LPBK_MASK)); /* * Clear QUARTER_PCAP_RATE_EN bit @@ -889,8 +892,8 @@ u32 XDcfg_Transfer(XDcfg *InstancePtr, XDCFG_CTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_CTRL_OFFSET, (CtrlReg & - ~XDCFG_CTRL_PCAP_RATE_EN_MASK)); + XDCFG_CTRL_OFFSET, (CtrlReg & + ~XDCFG_CTRL_PCAP_RATE_EN_MASK)); } if (TransferType == XDCFG_CONCURRENT_SECURE_READ_WRITE) { @@ -898,8 +901,8 @@ u32 XDcfg_Transfer(XDcfg *InstancePtr, CtrlReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, XDCFG_MCTRL_OFFSET); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_MCTRL_OFFSET, (CtrlReg & - ~(XDCFG_MCTRL_PCAP_LPBK_MASK))); + XDCFG_MCTRL_OFFSET, (CtrlReg & + ~(XDCFG_MCTRL_PCAP_LPBK_MASK))); /* * Set the QUARTER_PCAP_RATE_EN bit @@ -907,11 +910,11 @@ u32 XDcfg_Transfer(XDcfg *InstancePtr, * cycles, this is required for encrypted data. */ XDcfg_SetControlRegister(InstancePtr, - XDCFG_CTRL_PCAP_RATE_EN_MASK); + XDCFG_CTRL_PCAP_RATE_EN_MASK); } XDcfg_InitiateDma(InstancePtr, (u32)SourcePtr, - (u32)DestPtr, SrcWordLength, DestWordLength); + (u32)DestPtr, SrcWordLength, DestWordLength); } return XST_SUCCESS; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.h b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.h index e567699..694e3b3 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdevcfg.h -* @addtogroup devcfg_v3_7 +* @addtogroup devcfg Overview * @{ * @details * @@ -133,6 +134,7 @@ * 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 +* 3.8 Nava 06/21/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -178,8 +180,18 @@ typedef void (*XDcfg_IntrHandler) (void *CallBackRef, u32 Status); * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddr; /**< Base address of the device */ +#ifdef SDT + u32 IntrId; /** Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ +#endif } XDcfg_Config; /** @@ -210,7 +222,7 @@ typedef struct { *****************************************************************************/ #define XDcfg_Unlock(InstancePtr) \ XDcfg_WriteReg((InstancePtr)->Config.BaseAddr, \ - XDCFG_UNLOCK_OFFSET, XDCFG_UNLOCK_DATA) + XDCFG_UNLOCK_OFFSET, XDCFG_UNLOCK_DATA) @@ -230,8 +242,8 @@ typedef struct { #define XDcfg_GetPsVersion(InstancePtr) \ ((XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, \ XDCFG_MCTRL_OFFSET)) & \ - XDCFG_MCTRL_PCAP_PS_VERSION_MASK) >> \ - XDCFG_MCTRL_PCAP_PS_VERSION_SHIFT + XDCFG_MCTRL_PCAP_PS_VERSION_MASK) >> \ + XDCFG_MCTRL_PCAP_PS_VERSION_SHIFT @@ -250,7 +262,7 @@ typedef struct { *****************************************************************************/ #define XDcfg_ReadMultiBootConfig(InstancePtr) \ XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, \ - XDCFG_MULTIBOOT_ADDR_OFFSET) + XDCFG_MULTIBOOT_ADDR_OFFSET) /****************************************************************************/ @@ -269,8 +281,8 @@ typedef struct { *****************************************************************************/ #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))) + ((XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, XDCFG_CTRL_OFFSET)) \ + & ( ~XDCFG_CTRL_PCAP_PR_MASK))) /****************************************************************************/ /** @@ -288,8 +300,8 @@ typedef struct { *****************************************************************************/ #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)) + ((XDcfg_ReadReg((InstancePtr)->Config.BaseAddr, XDCFG_CTRL_OFFSET)) \ + | XDCFG_CTRL_PCAP_PR_MASK)) @@ -298,7 +310,11 @@ typedef struct { /* * Lookup configuration in xdevcfg_sinit.c. */ +#ifndef SDT XDcfg_Config *XDcfg_LookupConfig(u16 DeviceId); +#else +XDcfg_Config *XDcfg_LookupConfig(UINTPTR BaseAddress); +#endif /* * Selftest function in xdevcfg_selftest.c @@ -309,7 +325,7 @@ int XDcfg_SelfTest(XDcfg *InstancePtr); * Interface functions in xdevcfg.c */ int XDcfg_CfgInitialize(XDcfg *InstancePtr, - XDcfg_Config *ConfigPtr, u32 EffectiveAddress); + XDcfg_Config *ConfigPtr, u32 EffectiveAddress); void XDcfg_EnablePCAP(XDcfg *InstancePtr); @@ -344,12 +360,12 @@ u32 XDcfg_GetMiscControlRegister(XDcfg *InstancePtr); u32 XDcfg_IsDmaBusy(XDcfg *InstancePtr); void XDcfg_InitiateDma(XDcfg *InstancePtr, u32 SourcePtr, u32 DestPtr, - u32 SrcWordLength, u32 DestWordLength); + u32 SrcWordLength, u32 DestWordLength); u32 XDcfg_Transfer(XDcfg *InstancePtr, - void *SourcePtr, u32 SrcWordLength, - void *DestPtr, u32 DestWordLength, - u32 TransferType); + void *SourcePtr, u32 SrcWordLength, + void *DestPtr, u32 DestWordLength, + u32 TransferType); /* * Interrupt related function prototypes implemented in xdevcfg_intr.c @@ -367,7 +383,7 @@ void XDcfg_IntrClear(XDcfg *InstancePtr, u32 Mask); void XDcfg_InterruptHandler(XDcfg *InstancePtr); void XDcfg_SetHandler(XDcfg *InstancePtr, void *CallBackFunc, - void *CallBackRef); + void *CallBackRef); #ifdef __cplusplus } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_g.c index 28d1efd..b779f05 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_g.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdevcfg_g.c -* @addtogroup devcfg_v3_7 +* @addtogroup devcfg Overview * @{ * * This file contains a table that specifies the configuration of the Device diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.c b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.c index 1feacd9..a5efdec 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdevcfg_hw.c -* @addtogroup devcfg_v3_7 +* @addtogroup devcfg Overview * @{ * * This file contains the implementation of the interface reset functionality @@ -17,6 +18,7 @@ * Ver Who Date Changes * ----- --- -------- --------------------------------------------- * 2.04a kpc 10/07/13 First release +* 3.8 Nava 06/21/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -59,7 +61,7 @@ void XDcfg_ResetHw(u32 BaseAddr) /* Mask the interrupts */ XDcfg_WriteReg(BaseAddr, XDCFG_INT_MASK_OFFSET, - XDCFG_IXR_ALL_MASK); + XDCFG_IXR_ALL_MASK); /* Clear the interuupt status */ Regval = XDcfg_ReadReg(BaseAddr, XDCFG_INT_STS_OFFSET); XDcfg_WriteReg(BaseAddr, XDCFG_INT_STS_OFFSET, Regval); @@ -77,7 +79,7 @@ void XDcfg_ResetHw(u32 BaseAddr) XDcfg_WriteReg(BaseAddr, XDCFG_MCTRL_OFFSET, Regval); /*Reset the configuration register to reset value */ XDcfg_WriteReg(BaseAddr, XDCFG_CFG_OFFSET, - XDCFG_CONFIG_RESET_VALUE); + 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; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.h index 1b7d881..3db7835 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdevcfg_hw.h -* @addtogroup devcfg_v3_7 +* @addtogroup devcfg Overview * @{ * * This file contains the hardware interface to the Device Config Interface. @@ -26,6 +27,7 @@ * 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. +* 3.8 Nava 06/21/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -210,14 +212,14 @@ extern "C" { * 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) + 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 @@ -266,9 +268,9 @@ extern "C" { * Status */ #define XDCFG_STATUS_EFUSE_BBRAM_KEY_DISABLE_MASK 0x00000008 - /**< BBRAM key - * disable - */ +/**< BBRAM key + * disable + */ #define XDCFG_STATUS_EFUSE_SEC_EN_MASK 0x00000004 /**< Efuse Security * Enable Status */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_intr.c b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_intr.c index 9e7a741..77dd267 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_intr.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_intr.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdevcfg_intr.c -* @addtogroup devcfg_v3_7 +* @addtogroup devcfg Overview * @{ * * Contains the implementation of interrupt related functions of the XDcfg @@ -22,6 +23,7 @@ * 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 +* 3.8 Nava 06/21/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -70,11 +72,11 @@ void XDcfg_IntrEnable(XDcfg *InstancePtr, u32 Mask) * Enable the specified interrupts in the Interrupt Mask Register. */ RegValue = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, - XDCFG_INT_MASK_OFFSET); + XDCFG_INT_MASK_OFFSET); RegValue &= ~(Mask & XDCFG_IXR_ALL_MASK); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_INT_MASK_OFFSET, - RegValue); + XDCFG_INT_MASK_OFFSET, + RegValue); } @@ -108,11 +110,11 @@ void XDcfg_IntrDisable(XDcfg *InstancePtr, u32 Mask) * Disable the specified interrupts in the Interrupt Mask Register. */ RegValue = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, - XDCFG_INT_MASK_OFFSET); + XDCFG_INT_MASK_OFFSET); RegValue |= (Mask & XDCFG_IXR_ALL_MASK); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_INT_MASK_OFFSET, - RegValue); + XDCFG_INT_MASK_OFFSET, + RegValue); } /****************************************************************************/ /** @@ -170,7 +172,7 @@ u32 XDcfg_IntrGetStatus(XDcfg *InstancePtr) * Return the value read from the Interrupt Status register. */ return XDcfg_ReadReg(InstancePtr->Config.BaseAddr, - XDCFG_INT_STS_OFFSET); + XDCFG_INT_STS_OFFSET); } /****************************************************************************/ @@ -199,8 +201,8 @@ void XDcfg_IntrClear(XDcfg *InstancePtr, u32 Mask) Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_INT_STS_OFFSET, - Mask); + XDCFG_INT_STS_OFFSET, + Mask); } @@ -232,7 +234,7 @@ void XDcfg_InterruptHandler(XDcfg *InstancePtr) * Read the Interrupt status register. */ IntrStatusReg = XDcfg_ReadReg(InstancePtr->Config.BaseAddr, - XDCFG_INT_STS_OFFSET); + XDCFG_INT_STS_OFFSET); /* * Write the status back to clear the interrupts so that no @@ -240,13 +242,13 @@ void XDcfg_InterruptHandler(XDcfg *InstancePtr) * This also does the DMA acknowledgment automatically. */ XDcfg_WriteReg(InstancePtr->Config.BaseAddr, - XDCFG_INT_STS_OFFSET, IntrStatusReg); + XDCFG_INT_STS_OFFSET, IntrStatusReg); /* * Signal application that there are events to handle. */ InstancePtr->StatusHandler(InstancePtr->CallBackRef, - IntrStatusReg); + IntrStatusReg); } @@ -268,7 +270,7 @@ void XDcfg_InterruptHandler(XDcfg *InstancePtr) * *****************************************************************************/ void XDcfg_SetHandler(XDcfg *InstancePtr, void *CallBackFunc, - void *CallBackRef) + void *CallBackRef) { /* * Asserts validate the input arguments diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_selftest.c b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_selftest.c index f1fa391..6392cef 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_selftest.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_selftest.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdevcfg_selftest.c -* @addtogroup devcfg_v3_7 +* @addtogroup devcfg Overview * @{ * * Contains diagnostic self-test functions for the XDcfg driver. diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_sinit.c index b42d32b..4bd6def 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/devcfg/src/xdevcfg_sinit.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdevcfg_sinit.c -* @addtogroup devcfg_v3_7 +* @addtogroup devcfg Overview * @{ * * This file contains method for static initialization (compile-time) of the @@ -20,6 +21,7 @@ * ----- --- -------- --------------------------------------------- * 1.00a hvm 02/07/11 First release * 3.5 ms 08/07/17 Fixed compilation warnings. +* 3.8 Nava 06/21/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -27,7 +29,9 @@ /***************************** Include Files *********************************/ #include "xdevcfg.h" +#ifndef SDT #include "xparameters.h" +#endif /************************** Constant Definitions *****************************/ @@ -50,6 +54,7 @@ * @note None. * ******************************************************************************/ +#ifndef SDT XDcfg_Config *XDcfg_LookupConfig(u16 DeviceId) { extern XDcfg_Config XDcfg_ConfigTable[]; @@ -65,4 +70,22 @@ XDcfg_Config *XDcfg_LookupConfig(u16 DeviceId) return (CfgPtr); } +#else +XDcfg_Config *XDcfg_LookupConfig(UINTPTR BaseAddress) +{ + extern XDcfg_Config XDcfg_ConfigTable[]; + XDcfg_Config *CfgPtr = NULL; + u32 Index; + + for (Index = (u32)0x0; XDcfg_ConfigTable[Index].Name != NULL; Index++) { + if ((XDcfg_ConfigTable[Index].BaseAddr == BaseAddress) || + !BaseAddress) { + CfgPtr = &XDcfg_ConfigTable[Index]; + break; + } + } + + return (CfgPtr); +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.c b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.c index 27dffb9..33e4fa3 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdmaps.c -* @addtogroup dmaps_v2_8 +* @addtogroup dmaps Overview * @{ * * This file contains the implementation of the interface functions for XDmaPs @@ -46,6 +47,7 @@ * 2.3 kpc 14/10/16 Fixed the compiler error when optimization O0 is used. * 2.5 hk 08/16/19 Add a memory barrier before DMASEV as per specification. * 2.6 hk 02/14/20 Correct boundary check for Channel. +* 2.7 aj 12/07/23 Fixed changes to support system device tree flow * * * @@ -78,8 +80,8 @@ /************************** Function Prototypes *****************************/ static int XDmaPs_Exec_DMAKILL(u32 BaseAddr, - unsigned int Channel, - unsigned int Thread); + unsigned int Channel, + unsigned int Thread); static void XDmaPs_BufPool_Free(XDmaPs_ProgBuf *Pool, void *Buf); @@ -88,7 +90,7 @@ static int XDmaPs_Exec_DMAGO(u32 BaseAddr, unsigned int Channel, u32 DmaProg); static void XDmaPs_DoneISR_n(XDmaPs *InstPtr, unsigned Channel); static void *XDmaPs_BufPool_Allocate(XDmaPs_ProgBuf *Pool); static int XDmaPs_BuildDmaProg(unsigned Channel, XDmaPs_Cmd *Cmd, - unsigned CacheLength); + unsigned CacheLength); static void XDmaPs_Print_DmaProgBuf(char *Buf, int Length); @@ -125,8 +127,8 @@ static void XDmaPs_Print_DmaProgBuf(char *Buf, int Length); * *****************************************************************************/ int XDmaPs_CfgInitialize(XDmaPs *InstPtr, - XDmaPs_Config *Config, - u32 EffectiveAddr) + XDmaPs_Config *Config, + u32 EffectiveAddr) { int Status = XST_SUCCESS; unsigned int CacheLength = 0; @@ -143,15 +145,26 @@ int XDmaPs_CfgInitialize(XDmaPs *InstPtr, /* * Setup the driver instance using passed in parameters */ +#ifndef SDT InstPtr->Config.DeviceId = Config->DeviceId; +#endif InstPtr->Config.BaseAddress = EffectiveAddr; +#ifdef SDT + InstPtr->Config.IntrParent = Config->IntrParent; + /* Added one fault Inerrupt and eight per-channel Interrupt */ + for (Channel = 0; Channel < (XDMAPS_CHANNELS_PER_DEV + 1); Channel++) { + InstPtr->Config.IntrId[Channel] = Config->IntrId[Channel]; + } +#endif + CfgReg = XDmaPs_ReadReg(EffectiveAddr, XDMAPS_CR1_OFFSET); CacheLength = CfgReg & XDMAPS_CR1_I_CACHE_LEN_MASK; - if (CacheLength < 2 || CacheLength > 5) + if (CacheLength < 2 || CacheLength > 5) { CacheLength = 0; - else + } else { CacheLength = 1 << CacheLength; + } InstPtr->CacheLength = CacheLength; @@ -161,7 +174,11 @@ int XDmaPs_CfgInitialize(XDmaPs *InstPtr, for (Channel = 0; Channel < XDMAPS_CHANNELS_PER_DEV; Channel++) { ChanData = InstPtr->Chans + Channel; ChanData->ChanId = Channel; +#ifndef SDT ChanData->DevId = Config->DeviceId; +#else + ChanData->DevId = XDmaPs_GetDrvIndex(InstPtr, EffectiveAddr); +#endif } InstPtr->IsReady = 1; @@ -185,7 +202,7 @@ int XDmaPs_ResetManager(XDmaPs *InstPtr) { int Status; Status = XDmaPs_Exec_DMAKILL(InstPtr->Config.BaseAddress, - 0, 0); + 0, 0); return Status; } @@ -207,7 +224,7 @@ int XDmaPs_ResetChannel(XDmaPs *InstPtr, unsigned int Channel) { int Status; Status = XDmaPs_Exec_DMAKILL(InstPtr->Config.BaseAddress, - Channel, 1); + Channel, 1); return Status; @@ -247,8 +264,11 @@ void XDmaPs_FaultISR(XDmaPs *InstPtr) Fsm = XDmaPs_ReadReg(BaseAddr, XDMAPS_FSM_OFFSET) & 0x01; Fsc = XDmaPs_ReadReg(BaseAddr, XDMAPS_FSC_OFFSET) & 0xFF; - +#ifndef SDT DevId = InstPtr->Config.DeviceId; +#else + DevId = XDmaPs_GetDrvIndex(InstPtr, BaseAddr); +#endif if (Fsm) { /* @@ -275,9 +295,9 @@ void XDmaPs_FaultISR(XDmaPs *InstPtr) if (Fsc & (0x01 << Chan)) { FaultType = XDmaPs_ReadReg(BaseAddr, - XDmaPs_FTCn_OFFSET(Chan)); + XDmaPs_FTCn_OFFSET(Chan)); Pc = XDmaPs_ReadReg(BaseAddr, - XDmaPs_CPCn_OFFSET(Chan)); + XDmaPs_CPCn_OFFSET(Chan)); /* kill the channel thread */ /* Should we disable interrupt? */ @@ -302,7 +322,7 @@ void XDmaPs_FaultISR(XDmaPs *InstPtr) DmaProgBuf = (void *)DmaCmd->GeneratedDmaProg; if (DmaProgBuf) XDmaPs_BufPool_Free(ChanData->ProgBufPool, - DmaProgBuf); + DmaProgBuf); DmaCmd->GeneratedDmaProg = NULL; } @@ -332,16 +352,17 @@ void XDmaPs_FaultISR(XDmaPs *InstPtr) * ******************************************************************************/ int XDmaPs_SetDoneHandler(XDmaPs *InstPtr, - unsigned Channel, - XDmaPsDoneHandler DoneHandler, - void *CallbackRef) + unsigned Channel, + XDmaPsDoneHandler DoneHandler, + void *CallbackRef) { XDmaPs_ChannelData *ChanData; Xil_AssertNonvoid(InstPtr != NULL); - if (Channel >= XDMAPS_CHANNELS_PER_DEV) + if (Channel >= XDMAPS_CHANNELS_PER_DEV) { return XST_FAILURE; + } ChanData = InstPtr->Chans + Channel; @@ -367,8 +388,8 @@ int XDmaPs_SetDoneHandler(XDmaPs *InstPtr, * ******************************************************************************/ int XDmaPs_SetFaultHandler(XDmaPs *InstPtr, - XDmaPsFaultHandler FaultHandler, - void *CallbackRef) + XDmaPsFaultHandler FaultHandler, + void *CallbackRef) { Xil_AssertNonvoid(InstPtr != NULL); @@ -437,7 +458,7 @@ 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) + u32 Imm, unsigned int Ns) { /* * DMAGO encoding: @@ -504,7 +525,7 @@ static INLINE int XDmaPs_Instr_DMALD(char *DmaProg) * *****************************************************************************/ static INLINE int XDmaPs_Instr_DMALP(char *DmaProg, unsigned Lc, - unsigned LoopIterations) + unsigned LoopIterations) { /* * DMALP encoding @@ -742,19 +763,19 @@ int XDmaPs_Instr_DMAWMB(char *DmaProg) static INLINE unsigned XDmaPs_ToEndianSwapSizeBits(unsigned int EndianSwapSize) { switch (EndianSwapSize) { - case 0: - case 8: - return 0; - case 16: - return 1; - case 32: - return 2; - case 64: - return 3; - case 128: - return 4; - default: - return 0; + case 0: + case 8: + return 0; + case 16: + return 1; + case 32: + return 2; + case 64: + return 3; + case 128: + return 4; + default: + return 0; } } @@ -775,24 +796,24 @@ static INLINE unsigned XDmaPs_ToEndianSwapSizeBits(unsigned int EndianSwapSize) static INLINE unsigned XDmaPs_ToBurstSizeBits(unsigned BurstSize) { switch (BurstSize) { - case 1: - return 0; - case 2: - return 1; - case 4: - return 2; - case 8: - return 3; - case 16: - return 4; - case 32: - return 5; - case 64: - return 6; - case 128: - return 7; - default: - return 0; + case 1: + return 0; + case 2: + return 1; + case 4: + return 2; + case 8: + return 3; + case 16: + return 4; + case 32: + return 5; + case 64: + return 6; + case 128: + return 7; + default: + return 0; } } @@ -835,7 +856,7 @@ u32 XDmaPs_ToCCRValue(XDmaPs_ChanCtrl *ChanCtrl) XDmaPs_ToBurstSizeBits(ChanCtrl->DstBurstSize); unsigned dst_burst_len = (ChanCtrl->DstBurstLen - 1) & 0x0F; unsigned dst_cache_ctrl = (ChanCtrl->DstCacheCtrl & 0x03) - | ((ChanCtrl->DstCacheCtrl & 0x08) >> 1); + | ((ChanCtrl->DstCacheCtrl & 0x08) >> 1); unsigned dst_prot_ctrl = ChanCtrl->DstProtCtrl & 0x07; unsigned dst_inc_bit = ChanCtrl->DstInc & 1; @@ -843,21 +864,21 @@ u32 XDmaPs_ToCCRValue(XDmaPs_ChanCtrl *ChanCtrl) XDmaPs_ToBurstSizeBits(ChanCtrl->SrcBurstSize); unsigned src_burst_len = (ChanCtrl->SrcBurstLen - 1) & 0x0F; unsigned src_cache_ctrl = (ChanCtrl->SrcCacheCtrl & 0x03) - | ((ChanCtrl->SrcCacheCtrl & 0x08) >> 1); + | ((ChanCtrl->SrcCacheCtrl & 0x08) >> 1); unsigned src_prot_ctrl = ChanCtrl->SrcProtCtrl & 0x07; unsigned src_inc_bit = ChanCtrl->SrcInc & 1; u32 ccr_value = (es << 28) - | (dst_cache_ctrl << 25) - | (dst_prot_ctrl << 22) - | (dst_burst_len << 18) - | (dst_burst_size << 15) - | (dst_inc_bit << 14) - | (src_cache_ctrl << 11) - | (src_prot_ctrl << 8) - | (src_burst_len << 4) - | (src_burst_size << 1) - | (src_inc_bit); + | (dst_cache_ctrl << 25) + | (dst_prot_ctrl << 22) + | (dst_burst_len << 18) + | (dst_burst_size << 15) + | (dst_inc_bit << 14) + | (src_cache_ctrl << 11) + | (src_prot_ctrl << 8) + | (src_burst_len << 4) + | (src_burst_size << 1) + | (src_inc_bit); return ccr_value; } @@ -883,9 +904,9 @@ u32 XDmaPs_ToCCRValue(XDmaPs_ChanCtrl *ChanCtrl) * *****************************************************************************/ int XDmaPs_ConstructSingleLoop(char *DmaProgStart, - int CacheLength, - char *DmaProgLoopStart, - int LoopCount) + int CacheLength, + char *DmaProgLoopStart, + int LoopCount) { int CacheStartOffset; int CacheEndOffset; @@ -909,7 +930,7 @@ int XDmaPs_ConstructSingleLoop(char *DmaProgStart, != CacheEndOffset / CacheLength) { /* insert the nops */ NumNops = CacheLength - - CacheStartOffset % CacheLength; + - CacheStartOffset % CacheLength; while (NumNops--) { DmaProgBuf += XDmaPs_Instr_DMANOP(DmaProgBuf); @@ -920,7 +941,7 @@ int XDmaPs_ConstructSingleLoop(char *DmaProgStart, DmaProgBuf += XDmaPs_Instr_DMALD(DmaProgBuf); DmaProgBuf += XDmaPs_Instr_DMAST(DmaProgBuf); DmaProgBuf += XDmaPs_Instr_DMALPEND(DmaProgBuf, - DmaProgBuf - 2, 0); + DmaProgBuf - 2, 0); return DmaProgBuf - DmaProgLoopStart; } @@ -948,10 +969,10 @@ int XDmaPs_ConstructSingleLoop(char *DmaProgStart, * *****************************************************************************/ int XDmaPs_ConstructNestedLoop(char *DmaProgStart, - int CacheLength, - char *DmaProgLoopStart, - unsigned int LoopCountOuter, - unsigned int LoopCountInner) + int CacheLength, + char *DmaProgLoopStart, + unsigned int LoopCountOuter, + unsigned int LoopCountInner) { int CacheStartOffset; int CacheEndOffset; @@ -974,14 +995,14 @@ int XDmaPs_ConstructNestedLoop(char *DmaProgStart, */ DmaProgBuf += XDmaPs_ConstructSingleLoop(DmaProgStart, - CacheLength, - DmaProgBuf, - LoopCountInner); + CacheLength, + DmaProgBuf, + LoopCountInner); /* outer loop end */ DmaProgBuf += XDmaPs_Instr_DMALPEND(DmaProgBuf, - InnerLoopStart, - 1); + InnerLoopStart, + 1); /* * the nested loop is constructed for @@ -1004,7 +1025,7 @@ int XDmaPs_ConstructNestedLoop(char *DmaProgStart, != CacheEndOffset / CacheLength) { /* insert the nops */ NumNops = CacheLength - - CacheStartOffset % CacheLength; + - CacheStartOffset % CacheLength; while (NumNops--) { DmaProgBuf += XDmaPs_Instr_DMANOP(DmaProgBuf); @@ -1021,10 +1042,10 @@ int XDmaPs_ConstructNestedLoop(char *DmaProgStart, /* inner DMALPEND */ DmaProgBuf += XDmaPs_Instr_DMALPEND(DmaProgBuf, - DmaProgBuf - 2, 0); + DmaProgBuf - 2, 0); /* outer DMALPEND */ DmaProgBuf += XDmaPs_Instr_DMALPEND(DmaProgBuf, - InnerLoopStart, 1); + InnerLoopStart, 1); /* return the number of bytes */ return DmaProgBuf - DmaProgLoopStart; @@ -1066,7 +1087,7 @@ int XDmaPs_ConstructNestedLoop(char *DmaProgStart, * *****************************************************************************/ static int XDmaPs_BuildDmaProg(unsigned Channel, XDmaPs_Cmd *Cmd, - unsigned CacheLength) + unsigned CacheLength) { /* * unpack arguments @@ -1118,18 +1139,20 @@ static int XDmaPs_BuildDmaProg(unsigned Channel, XDmaPs_Cmd *Cmd, /* insert DMAMOV for SAR and DAR */ DmaProgBuf += XDmaPs_Instr_DMAMOV(DmaProgBuf, - XDMAPS_MOV_SAR, - SrcAddr); + XDMAPS_MOV_SAR, + SrcAddr); DmaProgBuf += XDmaPs_Instr_DMAMOV(DmaProgBuf, - XDMAPS_MOV_DAR, - DstAddr); + XDMAPS_MOV_DAR, + DstAddr); - if (ChanCtrl->SrcInc) + if (ChanCtrl->SrcInc) { SrcUnaligned = SrcAddr % ChanCtrl->SrcBurstSize; + } - if (ChanCtrl->DstInc) + if (ChanCtrl->DstInc) { DstUnaligned = DstAddr % ChanCtrl->DstBurstSize; + } if ((SrcUnaligned && DstInc) || (DstUnaligned && SrcInc)) { ChanCtrl = &Mem2MemByteCC; @@ -1151,12 +1174,12 @@ static int XDmaPs_BuildDmaProg(unsigned Channel, XDmaPs_Cmd *Cmd, /* if head is unaligned, transfer head in bytes */ UnalignedCount = MemBurstSize - Unaligned; CCRValue = XDMAPS_CCR_SINGLE_BYTE - | (SrcInc & 1) - | ((DstInc & 1) << 14); + | (SrcInc & 1) + | ((DstInc & 1) << 14); DmaProgBuf += XDmaPs_Instr_DMAMOV(DmaProgBuf, - XDMAPS_MOV_CCR, - CCRValue); + XDMAPS_MOV_CCR, + CCRValue); for (Index = 0; Index < UnalignedCount; Index++) { DmaProgBuf += XDmaPs_Instr_DMALD(DmaProgBuf); @@ -1169,8 +1192,8 @@ static int XDmaPs_BuildDmaProg(unsigned Channel, XDmaPs_Cmd *Cmd, /* now the burst transfer part */ CCRValue = XDmaPs_ToCCRValue(ChanCtrl); DmaProgBuf += XDmaPs_Instr_DMAMOV(DmaProgBuf, - XDMAPS_MOV_CCR, - CCRValue); + XDMAPS_MOV_CCR, + CCRValue); BurstBytes = ChanCtrl->SrcBurstSize * ChanCtrl->SrcBurstLen; @@ -1196,16 +1219,16 @@ static int XDmaPs_BuildDmaProg(unsigned Channel, XDmaPs_Cmd *Cmd, if (LoopCount1 > 1) DmaProgBuf += XDmaPs_ConstructNestedLoop(DmaProgStart, - CacheLength, - DmaProgBuf, - LoopCount1, - 256); + CacheLength, + DmaProgBuf, + LoopCount1, + 256); else DmaProgBuf += XDmaPs_ConstructSingleLoop(DmaProgStart, - CacheLength, - DmaProgBuf, - 256); + CacheLength, + DmaProgBuf, + 256); /* there will be some that cannot be covered by * nested loops @@ -1215,9 +1238,9 @@ static int XDmaPs_BuildDmaProg(unsigned Channel, XDmaPs_Cmd *Cmd, if (LoopCount > 0) { DmaProgBuf += XDmaPs_ConstructSingleLoop(DmaProgStart, - CacheLength, - DmaProgBuf, - LoopCount); + CacheLength, + DmaProgBuf, + LoopCount); } if (TailBytes) { @@ -1244,13 +1267,13 @@ static int XDmaPs_BuildDmaProg(unsigned Channel, XDmaPs_Cmd *Cmd, DmaProgBuf += XDmaPs_Instr_DMAMOV(DmaProgBuf, - XDMAPS_MOV_CCR, - CCRValue); + XDMAPS_MOV_CCR, + CCRValue); DmaProgBuf += XDmaPs_ConstructSingleLoop(DmaProgStart, - CacheLength, - DmaProgBuf, - TailWords); + CacheLength, + DmaProgBuf, + TailWords); } @@ -1264,19 +1287,19 @@ static int XDmaPs_BuildDmaProg(unsigned Channel, XDmaPs_Cmd *Cmd, * to perform a burst. */ CCRValue = XDMAPS_CCR_SINGLE_BYTE - | (SrcInc & 1) - | ((DstInc & 1) << 14); + | (SrcInc & 1) + | ((DstInc & 1) << 14); DmaProgBuf += XDmaPs_Instr_DMAMOV(DmaProgBuf, - XDMAPS_MOV_CCR, - CCRValue); + XDMAPS_MOV_CCR, + CCRValue); DmaProgBuf += XDmaPs_ConstructSingleLoop(DmaProgStart, - CacheLength, - DmaProgBuf, - TailBytes); + CacheLength, + DmaProgBuf, + TailBytes); } } @@ -1322,8 +1345,9 @@ int XDmaPs_GenDmaProg(XDmaPs *InstPtr, unsigned int Channel, XDmaPs_Cmd *Cmd) Xil_AssertNonvoid(Cmd != NULL); - if (Channel > XDMAPS_CHANNELS_PER_DEV) + if (Channel > XDMAPS_CHANNELS_PER_DEV) { return XST_FAILURE; + } ChanData = InstPtr->Chans + Channel; ChanCtrl = &Cmd->ChanCtrl; @@ -1352,7 +1376,7 @@ int XDmaPs_GenDmaProg(XDmaPs *InstPtr, unsigned int Channel, XDmaPs_Cmd *Cmd) Cmd->GeneratedDmaProg = Buf; ProgLen = XDmaPs_BuildDmaProg(Channel, Cmd, - InstPtr->CacheLength); + InstPtr->CacheLength); Cmd->GeneratedDmaProgLength = ProgLen; @@ -1396,8 +1420,9 @@ int XDmaPs_FreeDmaProg(XDmaPs *InstPtr, unsigned int Channel, XDmaPs_Cmd *Cmd) Xil_AssertNonvoid(InstPtr != NULL); Xil_AssertNonvoid(Cmd != NULL); - if (Channel > XDMAPS_CHANNELS_PER_DEV) + if (Channel > XDMAPS_CHANNELS_PER_DEV) { return XST_FAILURE; + } Buf = (void *)Cmd->GeneratedDmaProg; ChanData = InstPtr->Chans + Channel; @@ -1437,8 +1462,8 @@ int XDmaPs_FreeDmaProg(XDmaPs *InstPtr, unsigned int Channel, XDmaPs_Cmd *Cmd) * ****************************************************************************/ int XDmaPs_Start(XDmaPs *InstPtr, unsigned int Channel, - XDmaPs_Cmd *Cmd, - int HoldDmaProg) + XDmaPs_Cmd *Cmd, + int HoldDmaProg) { int Status; u32 DmaProg = 0; @@ -1450,32 +1475,35 @@ int XDmaPs_Start(XDmaPs *InstPtr, unsigned int Channel, Cmd->DmaStatus = XST_FAILURE; - if (XDmaPs_IsActive(InstPtr, Channel)) + if (XDmaPs_IsActive(InstPtr, Channel)) { return XST_DEVICE_BUSY; + } if (!Cmd->UserDmaProg && !Cmd->GeneratedDmaProg) { Status = XDmaPs_GenDmaProg(InstPtr, Channel, Cmd); - if (Status) + if (Status) { return XST_FAILURE; + } } InstPtr->Chans[Channel].HoldDmaProg = HoldDmaProg; - if (Cmd->UserDmaProg) + if (Cmd->UserDmaProg) { DmaProg = (u32)Cmd->UserDmaProg; - else if (Cmd->GeneratedDmaProg) + } else if (Cmd->GeneratedDmaProg) { DmaProg = (u32)Cmd->GeneratedDmaProg; + } if (DmaProg) { /* enable the interrupt */ Inten = XDmaPs_ReadReg(InstPtr->Config.BaseAddress, - XDMAPS_INTEN_OFFSET); + XDMAPS_INTEN_OFFSET); Inten |= 0x01 << Channel; /* set the correpsonding bit */ XDmaPs_WriteReg(InstPtr->Config.BaseAddress, - XDMAPS_INTEN_OFFSET, - Inten); + XDMAPS_INTEN_OFFSET, + Inten); Inten = XDmaPs_ReadReg(InstPtr->Config.BaseAddress, - XDMAPS_INTEN_OFFSET); + XDMAPS_INTEN_OFFSET); InstPtr->Chans[Channel].DmaCmdToHw = Cmd; @@ -1484,13 +1512,12 @@ int XDmaPs_Start(XDmaPs *InstPtr, unsigned int Channel, } if (Cmd->ChanCtrl.DstInc) { Xil_DCacheInvalidateRange(Cmd->BD.DstAddr, - Cmd->BD.Length); + Cmd->BD.Length); } Status = XDmaPs_Exec_DMAGO(InstPtr->Config.BaseAddress, - Channel, DmaProg); - } - else { + Channel, DmaProg); + } else { InstPtr->Chans[Channel].DmaCmdToHw = NULL; Status = XST_FAILURE; } @@ -1517,8 +1544,9 @@ int XDmaPs_IsActive(XDmaPs *InstPtr, unsigned int Channel) Xil_AssertNonvoid(InstPtr != NULL); /* Need to assert Channel is in range */ - if (Channel >= XDMAPS_CHANNELS_PER_DEV) + if (Channel >= XDMAPS_CHANNELS_PER_DEV) { return XST_FAILURE; + } return InstPtr->Chans[Channel].DmaCmdToHw != NULL; } @@ -1725,8 +1753,8 @@ void XDmaPs_DoneISR_7(XDmaPs *InstPtr) * *****************************************************************************/ static int XDmaPs_Exec_DMAKILL(u32 BaseAddr, - unsigned int Channel, - unsigned int Thread) + unsigned int Channel, + unsigned int Thread) { u32 DbgInst0; int WaitCount; @@ -1736,14 +1764,15 @@ static int XDmaPs_Exec_DMAKILL(u32 BaseAddr, /* wait while debug status is busy */ WaitCount = 0; while ((XDmaPs_ReadReg(BaseAddr, XDMAPS_DBGSTATUS_OFFSET) - & XDMAPS_DBGSTATUS_BUSY) - && (WaitCount < XDMAPS_MAX_WAIT)) + & XDMAPS_DBGSTATUS_BUSY) + && (WaitCount < XDMAPS_MAX_WAIT)) { WaitCount++; + } if (WaitCount >= XDMAPS_MAX_WAIT) { /* wait time out */ xil_printf("PL330 device at %x debug status busy time out\n", - BaseAddr); + BaseAddr); return -1; } @@ -1816,7 +1845,7 @@ static int XDmaPs_Exec_DMAGO(u32 BaseAddr, unsigned int Channel, u32 DmaProg) /* wait while debug status is busy */ WaitCount = 0; while ((XDmaPs_ReadReg(BaseAddr, XDMAPS_DBGSTATUS_OFFSET) - & XDMAPS_DBGSTATUS_BUSY) + & XDMAPS_DBGSTATUS_BUSY) && (WaitCount < XDMAPS_MAX_WAIT)) { WaitCount++; @@ -1837,7 +1866,7 @@ static int XDmaPs_Exec_DMAGO(u32 BaseAddr, unsigned int Channel, u32 DmaProg) /* wait while the DMA Manager is busy */ WaitCount = 0; while ((XDmaPs_ReadReg(BaseAddr, - XDMAPS_DS_OFFSET) & XDMAPS_DS_DMA_STATUS) + XDMAPS_DS_OFFSET) & XDMAPS_DS_DMA_STATUS) != XDMAPS_DS_DMA_STATUS_STOPPED && WaitCount <= XDMAPS_MAX_WAIT) { WaitCount++; @@ -1896,7 +1925,7 @@ static void XDmaPs_DoneISR_n(XDmaPs *InstPtr, unsigned Channel) DmaProgBuf = (void *)DmaCmd->GeneratedDmaProg; if (DmaProgBuf) XDmaPs_BufPool_Free(ChanData->ProgBufPool, - DmaProgBuf); + DmaProgBuf); DmaCmd->GeneratedDmaProg = NULL; } @@ -1925,8 +1954,9 @@ static void XDmaPs_DoneISR_n(XDmaPs *InstPtr, unsigned Channel) static void XDmaPs_Print_DmaProgBuf(char *Buf, int Length) { int Index; - for (Index = 0; Index < Length; Index++) + for (Index = 0; Index < Length; Index++) { xil_printf("[%x] %x\r\n", Index, Buf[Index]); + } } /****************************************************************************/ @@ -1940,20 +1970,20 @@ static void XDmaPs_Print_DmaProgBuf(char *Buf, int Length) * @note None. * *****************************************************************************/ - void XDmaPs_Print_DmaProg(XDmaPs_Cmd *Cmd) +void XDmaPs_Print_DmaProg(XDmaPs_Cmd *Cmd) { if (Cmd->GeneratedDmaProg && Cmd->GeneratedDmaProgLength) { xil_printf("Generated DMA program (%d):\r\n", Cmd->GeneratedDmaProgLength); XDmaPs_Print_DmaProgBuf((char *)Cmd->GeneratedDmaProg, - Cmd->GeneratedDmaProgLength); + Cmd->GeneratedDmaProgLength); } if (Cmd->UserDmaProg && Cmd->UserDmaProgLength) { xil_printf("User defined DMA program (%d):\r\n", Cmd->UserDmaProgLength); XDmaPs_Print_DmaProgBuf((char *)Cmd->UserDmaProg, - Cmd->UserDmaProgLength); + Cmd->UserDmaProgLength); } } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.h b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.h index 179c840..4b98640 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdmaps.h -* @addtogroup dmaps_v2_8 +* @addtogroup dmaps Overview * @{ * @details * @@ -60,6 +61,7 @@ * 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. +* 2.9 aj 11/07/23 Added support for system device tree * * *****************************************************************************/ @@ -88,8 +90,19 @@ extern "C" { * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddress; /**< Base address of device (IPIF) */ + +#ifdef SDT + u32 IntrId[9]; /** Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ +#endif } XDmaPs_Config; @@ -169,15 +182,15 @@ typedef struct { * It's the done handler a user can set for a channel */ typedef void (*XDmaPsDoneHandler) (unsigned int Channel, - XDmaPs_Cmd *DmaCmd, - void *CallbackRef); + 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); + XDmaPs_Cmd *DmaCmd, + void *CallbackRef); #define XDMAPS_MAX_CHAN_BUFS 2 #define XDMAPS_CHAN_BUF_LEN 128 @@ -236,18 +249,18 @@ typedef struct { * Functions implemented in xdmaps.c */ int XDmaPs_CfgInitialize(XDmaPs *InstPtr, - XDmaPs_Config *Config, - u32 EffectiveAddr); + XDmaPs_Config *Config, + u32 EffectiveAddr); int XDmaPs_Start(XDmaPs *InstPtr, unsigned int Channel, - XDmaPs_Cmd *Cmd, - int HoldDmaProg); + XDmaPs_Cmd *Cmd, + int HoldDmaProg); int XDmaPs_IsActive(XDmaPs *InstPtr, unsigned int Channel); int XDmaPs_GenDmaProg(XDmaPs *InstPtr, unsigned int Channel, - XDmaPs_Cmd *Cmd); + XDmaPs_Cmd *Cmd); int XDmaPs_FreeDmaProg(XDmaPs *InstPtr, unsigned int Channel, - XDmaPs_Cmd *Cmd); + XDmaPs_Cmd *Cmd); void XDmaPs_Print_DmaProg(XDmaPs_Cmd *Cmd); @@ -256,13 +269,13 @@ int XDmaPs_ResetChannel(XDmaPs *InstPtr, unsigned int Channel); int XDmaPs_SetDoneHandler(XDmaPs *InstPtr, - unsigned Channel, - XDmaPsDoneHandler DoneHandler, - void *CallbackRef); + unsigned Channel, + XDmaPsDoneHandler DoneHandler, + void *CallbackRef); int XDmaPs_SetFaultHandler(XDmaPs *InstPtr, - XDmaPsFaultHandler FaultHandler, - void *CallbackRef); + XDmaPsFaultHandler FaultHandler, + void *CallbackRef); void XDmaPs_Print_DmaProg(XDmaPs_Cmd *Cmd); int XDmaPs_Instr_DMARMB(char *DmaProg); @@ -276,10 +289,10 @@ int XDmaPs_Instr_DMAWMB(char *DmaProg); 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); + 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); + 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); @@ -312,7 +325,12 @@ void XDmaPs_FaultISR(XDmaPs *InstPtr); /* * Static loopup function implemented in xdmaps_sinit.c */ +#ifndef SDT XDmaPs_Config *XDmaPs_LookupConfig(u16 DeviceId); +#else +XDmaPs_Config *XDmaPs_LookupConfig(UINTPTR BaseAddress); +u32 XDmaPs_GetDrvIndex(XDmaPs *InstancePtr, UINTPTR BaseAddress); +#endif /* diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_g.c index 30facf1..2a8cdeb 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_g.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdmaps_g.c -* @addtogroup dmaps_v2_8 +* @addtogroup dmaps Overview * @{ * * This file contains a configuration table where each entry is a configuration diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.c b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.c index cb45d29..9a2d632 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,10 +8,10 @@ /** * * @file xdmaps_hw.c -* @addtogroup dmaps_v2_8 +* @addtogroup dmaps Overview * @{ * -* This file contains the implementation of the interface reset functionality +* This file contains the implementation of the interface reset functionality * for XDmaPs driver. * *
@@ -40,10 +41,10 @@ /*****************************************************************************/ /** -* This function perform the reset sequence to the given dmaps interface by +* 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 +* Disable all the interuupts * Clear the pending interrupts * Kill all the active channel threads * Kill the manager thread @@ -52,8 +53,8 @@ * * @return N/A * -* @note -* This function will not modify the slcr registers that are relavant for +* @note +* This function will not modify the slcr registers that are relavant for * dmaps controller ******************************************************************************/ void XDmaPs_ResetHw(u32 BaseAddress) @@ -67,22 +68,23 @@ void XDmaPs_ResetHw(u32 BaseAddress) /* 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++) { + for (ChanIndex = 0; ChanIndex < XDMAPS_CHANNELS_PER_DEV; ChanIndex++) { while ((XDmaPs_ReadReg(BaseAddress, XDMAPS_DBGSTATUS_OFFSET) - & XDMAPS_DBGSTATUS_BUSY) - && (WaitCount < XDMAPS_MAX_WAIT)) - WaitCount++; + & XDMAPS_DBGSTATUS_BUSY) + && (WaitCount < XDMAPS_MAX_WAIT)) { + WaitCount++; + } - DbgInst = XDmaPs_DBGINST0(0, 0x01, ChanIndex, 1); + 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_DBGINST1_OFFSET, 0x0); XDmaPs_WriteReg(BaseAddress, XDMAPS_DBGCMD_OFFSET, 0x0); - } + } /* Kill the manager thread */ - DbgInst = XDmaPs_DBGINST0(0, 0x01, 0, 0); + 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); + XDmaPs_WriteReg(BaseAddress, XDMAPS_DBGINST1_OFFSET, 0x0); + XDmaPs_WriteReg(BaseAddress, XDMAPS_DBGCMD_OFFSET, 0x0); } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.h index d039278..32c2c91 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdmaps_hw.h -* @addtogroup dmaps_v2_8 +* @addtogroup dmaps Overview * @{ * * This header file contains the hardware interface of an XDmaPs device. @@ -233,7 +234,7 @@ extern "C" { #define XDMAPS_INTCLR_ALL_MASK 0xFF #define XDmaPs_ReadReg(BaseAddress, RegOffset) \ - Xil_In32((BaseAddress) + (RegOffset)) + Xil_In32((BaseAddress) + (RegOffset)) /***************************************************************************/ /** @@ -251,7 +252,7 @@ extern "C" { * u32 RegisterValue) ******************************************************************************/ #define XDmaPs_WriteReg(BaseAddress, RegOffset, RegisterValue) \ - Xil_Out32((BaseAddress) + (RegOffset), (RegisterValue)) + Xil_Out32((BaseAddress) + (RegOffset), (RegisterValue)) /************************** Variable Definitions *****************************/ /************************** Function Prototypes *****************************/ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_selftest.c b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_selftest.c index dd2d4d3..e0e9d92 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_selftest.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_selftest.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xdmaps_selftest.c -* @addtogroup dmaps_v2_8 +* @addtogroup dmaps Overview * @{ * * This file contains the self-test functions for the XDmaPs driver. @@ -71,13 +72,15 @@ int XDmaPs_SelfTest(XDmaPs *InstPtr) int i; if (XDmaPs_ReadReg(BaseAddr, XDMAPS_DBGSTATUS_OFFSET) - & XDMAPS_DBGSTATUS_BUSY) + & XDMAPS_DBGSTATUS_BUSY) { return XST_FAILURE; + } for (i = 0; i < XDMAPS_CHANNELS_PER_DEV; i++) { if (XDmaPs_ReadReg(BaseAddr, - XDmaPs_CSn_OFFSET(i))) + XDmaPs_CSn_OFFSET(i))) { return XST_FAILURE; + } } return XST_SUCCESS; } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_sinit.c index 751df21..d36215c 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/dmaps/src/xdmaps_sinit.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,10 +8,10 @@ /** * * @file xdmaps_sinit.c -* @addtogroup dmaps_v2_8 +* @addtogroup dmaps Overview * @{ * -* The implementation of the XDmaPs driver's static initialzation +* The implementation of the XDmaPs driver's static initialization * functionality. * ** ******************************************************************************/ @@ -89,7 +92,9 @@ s32 XGpioPs_CfgInitialize(XGpioPs *InstancePtr, const XGpioPs_Config *ConfigPtr, */ InstancePtr->IsReady = 0U; InstancePtr->GpioConfig.BaseAddr = EffectiveAddr; +#ifndef SDT InstancePtr->GpioConfig.DeviceId = ConfigPtr->DeviceId; +#endif InstancePtr->Handler = (XGpioPs_Handler)StubHandler; InstancePtr->Platform = XGetPlatform_Info(); @@ -176,6 +181,7 @@ s32 XGpioPs_CfgInitialize(XGpioPs *InstancePtr, const XGpioPs_Config *ConfigPtr, ((u32)(i) * XGPIOPS_REG_MASK_OFFSET) + XGPIOPS_INTDIS_OFFSET, 0xFFFFFFFFU); } + InstancePtr->CoreIntrMask[i] = 0; } /* Indicate the component is now ready to use. */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.h b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.h index 8b1d89f..cce171a 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -124,6 +124,11 @@ * 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. +* 3.12 gm 07/11/23 Added SDT support. +* 3.13 gm 03/15/24 Remove const of XGpioPs InstancePtr from function proto +* type of XGpioPs_IntrEnable, XGpioPs_IntrDisable, +* XGpioPs_IntrEnablePin and XGpioPs_IntrDisablePin +* to add multi-core interrupt support. * * * @@ -167,6 +172,7 @@ extern "C" { * Zynq Ultrascale+ MP GPIO device */ #define XGPIOPS_MAX_BANKS 0x04U /**< Max banks in a Zynq GPIO device */ +#define XGPIOPS_MAX_BANKS_CNT 0x06U /**< Max banks number of all platforms */ #define XGPIOPS_DEVICE_MAX_PIN_NUM_ZYNQMP (u32)174 /**< Max pins in the * Zynq Ultrascale+ MP GPIO device @@ -209,8 +215,18 @@ typedef void (*XGpioPs_Handler) (void *CallBackRef, u32 Bank, u32 Status); * This typedef contains configuration information for a device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif UINTPTR BaseAddr; /**< Register base address */ +#ifdef SDT + u16 IntrId; /** Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ +#endif } XGpioPs_Config; /** @@ -227,6 +243,7 @@ typedef struct { 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*/ + u32 CoreIntrMask[XGPIOPS_MAX_BANKS_CNT]; /**< Interrupt mask per core */ } XGpioPs; /************************** Variable Definitions *****************************/ @@ -262,12 +279,12 @@ void XGpioPs_SetOutputEnablePin(const XGpioPs *InstancePtr, u32 Pin, u32 OpEnabl u32 XGpioPs_GetOutputEnablePin(const XGpioPs *InstancePtr, u32 Pin); /* Diagnostic functions in xgpiops_selftest.c */ -s32 XGpioPs_SelfTest(const XGpioPs *InstancePtr); +s32 XGpioPs_SelfTest(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); +void XGpioPs_IntrEnable(XGpioPs *InstancePtr, u8 Bank, u32 Mask); +void XGpioPs_IntrDisable(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); @@ -283,14 +300,18 @@ void XGpioPs_IntrHandler(const XGpioPs *InstancePtr); 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); +void XGpioPs_IntrEnablePin(XGpioPs *InstancePtr, u32 Pin); +void XGpioPs_IntrDisablePin(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 */ +#ifndef SDT XGpioPs_Config *XGpioPs_LookupConfig(u16 DeviceId); +#else +XGpioPs_Config *XGpioPs_LookupConfig(u32 BaseAddress); +#endif #ifdef __cplusplus } #endif diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_g.c index 8d55f88..d8e1186 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_g.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.c b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.c index 7734ba8..57e684a 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.h index d291abb..3248dc2 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_intr.c b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_intr.c index 0f3e26b..504df04 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_intr.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_intr.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -35,6 +35,7 @@ * 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. +* 3.13 gm 03/15/24 Added multi-core interrupt support. * * * @@ -71,7 +72,7 @@ * @note None. * *****************************************************************************/ -void XGpioPs_IntrEnable(const XGpioPs *InstancePtr, u8 Bank, u32 Mask) +void XGpioPs_IntrEnable(XGpioPs *InstancePtr, u8 Bank, u32 Mask) { Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); @@ -87,6 +88,9 @@ void XGpioPs_IntrEnable(const XGpioPs *InstancePtr, u8 Bank, u32 Mask) XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr, ((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) + XGPIOPS_INTEN_OFFSET, Mask); + + /* Setup mask for CPU */ + InstancePtr->CoreIntrMask[Bank] |= Mask; } /****************************************************************************/ @@ -102,7 +106,7 @@ void XGpioPs_IntrEnable(const XGpioPs *InstancePtr, u8 Bank, u32 Mask) * @note None. * *****************************************************************************/ -void XGpioPs_IntrEnablePin(const XGpioPs *InstancePtr, u32 Pin) +void XGpioPs_IntrEnablePin(XGpioPs *InstancePtr, u32 Pin) { u8 Bank; u8 PinNumber; @@ -123,6 +127,9 @@ void XGpioPs_IntrEnablePin(const XGpioPs *InstancePtr, u32 Pin) XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr, ((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) + XGPIOPS_INTEN_OFFSET, IntrReg); + + /* Setup mask for CPU */ + InstancePtr->CoreIntrMask[Bank] |= IntrReg; } /****************************************************************************/ @@ -142,7 +149,7 @@ void XGpioPs_IntrEnablePin(const XGpioPs *InstancePtr, u32 Pin) * @note None. * *****************************************************************************/ -void XGpioPs_IntrDisable(const XGpioPs *InstancePtr, u8 Bank, u32 Mask) +void XGpioPs_IntrDisable(XGpioPs *InstancePtr, u8 Bank, u32 Mask) { Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); @@ -158,6 +165,9 @@ void XGpioPs_IntrDisable(const XGpioPs *InstancePtr, u8 Bank, u32 Mask) XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr, ((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) + XGPIOPS_INTDIS_OFFSET, Mask); + + /* Setup mask for CPU */ + InstancePtr->CoreIntrMask[Bank] &= ~Mask; } /****************************************************************************/ @@ -173,7 +183,7 @@ void XGpioPs_IntrDisable(const XGpioPs *InstancePtr, u8 Bank, u32 Mask) * @note None. * *****************************************************************************/ -void XGpioPs_IntrDisablePin(const XGpioPs *InstancePtr, u32 Pin) +void XGpioPs_IntrDisablePin(XGpioPs *InstancePtr, u32 Pin) { u8 Bank; u8 PinNumber; @@ -194,6 +204,9 @@ void XGpioPs_IntrDisablePin(const XGpioPs *InstancePtr, u32 Pin) XGpioPs_WriteReg(InstancePtr->GpioConfig.BaseAddr, ((u32)(Bank) * XGPIOPS_REG_MASK_OFFSET) + XGPIOPS_INTDIS_OFFSET, IntrReg); + + /* Setup mask for CPU */ + InstancePtr->CoreIntrMask[Bank] &= ~IntrReg; } /****************************************************************************/ @@ -735,6 +748,7 @@ void XGpioPs_SetCallbackHandler(XGpioPs *InstancePtr, void *CallBackRef, void XGpioPs_IntrHandler(const XGpioPs *InstancePtr) { u8 Bank; + u32 Mask; u32 IntrStatus; u32 IntrEnabled; @@ -755,12 +769,12 @@ void XGpioPs_IntrHandler(const XGpioPs *InstancePtr) #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)); + Mask = IntrStatus & IntrEnabled & InstancePtr->CoreIntrMask[Bank]; + + if (Mask != (u32)0) + { + XGpioPs_IntrClear(InstancePtr, Bank, Mask); + InstancePtr->Handler(InstancePtr->CallBackRef, Bank, Mask); } } } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_selftest.c b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_selftest.c index b666f7d..db8eb0b 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_selftest.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_selftest.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -61,7 +61,7 @@ * * ******************************************************************************/ -s32 XGpioPs_SelfTest(const XGpioPs *InstancePtr) +s32 XGpioPs_SelfTest(XGpioPs *InstancePtr) { s32 Status = (s32)0; u32 IntrEnabled; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_sinit.c index 72a2ad8..3b59fe3 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops_sinit.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -24,6 +24,8 @@ * ----- ---- -------- ----------------------------------------------- * 1.00a sv 01/15/10 First Release * 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance. +* 3.12 gm 07/11/23 Added SDT support. +* * * ******************************************************************************/ @@ -57,6 +59,7 @@ * @note None. * ******************************************************************************/ +#ifndef SDT XGpioPs_Config *XGpioPs_LookupConfig(u16 DeviceId) { XGpioPs_Config *CfgPtr = NULL; @@ -71,4 +74,21 @@ XGpioPs_Config *XGpioPs_LookupConfig(u16 DeviceId) return (XGpioPs_Config *)CfgPtr; } +#else +XGpioPs_Config *XGpioPs_LookupConfig(u32 BaseAddress) +{ + XGpioPs_Config *CfgPtr = NULL; + u32 Index; + + for (Index = (u32)0x0; XGpioPs_ConfigTable[Index].Name != NULL; Index++) { + if ((XGpioPs_ConfigTable[Index].BaseAddr == BaseAddress) || + !BaseAddress) { + CfgPtr = &XGpioPs_ConfigTable[Index]; + break; + } + } + + return (XGpioPs_Config *)CfgPtr; +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.c b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.c index 68f1d3f..0974aed 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xqspips.c -* @addtogroup qspips_v3_10 +* @addtogroup qspips Overview * @{ * * Contains implements the interface functions of the XQspiPs driver. @@ -117,7 +118,7 @@ typedef struct { /************************** Function Prototypes ******************************/ static void XQspiPs_GetReadData(XQspiPs *InstancePtr, u32 Data, u8 Size); static void StubStatusHandler(void *CallBackRef, u32 StatusEvent, - unsigned ByteCount); + unsigned ByteCount); /************************** Variable Definitions *****************************/ @@ -191,7 +192,7 @@ static XQspiPsInstFormat FlashInst[] = { * ******************************************************************************/ int XQspiPs_CfgInitialize(XQspiPs *InstancePtr, XQspiPs_Config *ConfigPtr, - u32 EffectiveAddr) + u32 EffectiveAddr) { Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(ConfigPtr != NULL); @@ -265,11 +266,11 @@ void XQspiPs_Reset(XQspiPs *InstancePtr) * Do not modify reserved bits. */ ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); ConfigReg |= XQSPIPS_CR_RESET_MASK_SET; ConfigReg &= ~XQSPIPS_CR_RESET_MASK_CLR; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPS_CR_OFFSET, - ConfigReg); + ConfigReg); } /*****************************************************************************/ @@ -299,7 +300,7 @@ void XQspiPs_Abort(XQspiPs *InstancePtr) * De-assert slave select lines. */ ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); ConfigReg |= (XQSPIPS_CR_SSCTRL_MASK | XQSPIPS_CR_SSFORCE_MASK); XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPS_CR_OFFSET, ConfigReg); @@ -310,24 +311,24 @@ void XQspiPs_Abort(XQspiPs *InstancePtr) IsLock = XQspiPs_ReadReg(XPAR_XSLCR_0_BASEADDR, SLCR_LOCKSTA); if (IsLock) { XQspiPs_WriteReg(XPAR_XSLCR_0_BASEADDR, SLCR_UNLOCK, - SLCR_UNLOCK_MASK); + SLCR_UNLOCK_MASK); } XQspiPs_WriteReg(XPAR_XSLCR_0_BASEADDR, LQSPI_RST_CTRL, - LQSPI_RST_CTRL_MASK); + LQSPI_RST_CTRL_MASK); XQspiPs_WriteReg(XPAR_XSLCR_0_BASEADDR, LQSPI_RST_CTRL, 0x0); if (IsLock) { XQspiPs_WriteReg(XPAR_XSLCR_0_BASEADDR, SLCR_LOCK, - SLCR_LOCK_MASK); + SLCR_LOCK_MASK); } /* * Set the RX and TX FIFO threshold to reset value (one) */ XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_RXWR_OFFSET, XQSPIPS_RXWR_RESET_VALUE); + XQSPIPS_RXWR_OFFSET, XQSPIPS_RXWR_RESET_VALUE); XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_TXWR_OFFSET, XQSPIPS_TXWR_RESET_VALUE); + XQSPIPS_TXWR_OFFSET, XQSPIPS_TXWR_RESET_VALUE); InstancePtr->RemainingBytes = 0; InstancePtr->RequestedBytes = 0; @@ -400,7 +401,7 @@ void XQspiPs_Abort(XQspiPs *InstancePtr) * ******************************************************************************/ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, - u32 ByteCount) + u32 ByteCount) { u32 StatusReg; u32 ConfigReg; @@ -460,7 +461,7 @@ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, * Set the RX FIFO threshold */ XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_RXWR_OFFSET, XQSPIPS_RXFIFO_THRESHOLD_OPT); + XQSPIPS_RXWR_OFFSET, XQSPIPS_RXFIFO_THRESHOLD_OPT); /* * If the slave select is "Forced" or under manual control, @@ -468,11 +469,11 @@ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, */ if (XQspiPs_IsManualChipSelect(InstancePtr)) { ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); ConfigReg &= ~XQSPIPS_CR_SSCTRL_MASK; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET, - ConfigReg); + XQSPIPS_CR_OFFSET, + ConfigReg); } /* @@ -484,7 +485,7 @@ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, * Clear all the interrupts. */ XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPS_SR_OFFSET, - XQSPIPS_IXR_WR_TO_CLR_MASK); + XQSPIPS_IXR_WR_TO_CLR_MASK); if (Index < ARRAY_SIZE(FlashInst)) { CurrInst = &FlashInst[Index]; @@ -493,7 +494,7 @@ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, * Spansion (3 bytes) and Micron (2 bytes) */ if ((CurrInst->OpCode == XQSPIPS_FLASH_OPCODE_WRSR) && - (ByteCount == 3)) { + (ByteCount == 3)) { CurrInst->InstSize = 3; CurrInst->TxOffset = XQSPIPS_TXD_11_OFFSET; } @@ -511,36 +512,36 @@ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, * The remaining bytes of the instruction will be transmitted * through TXD0 below. */ - switch (ByteCount%4) { - case XQSPIPS_SIZE_ONE: - CurrInst->OpCode = Instruction; - CurrInst->InstSize = XQSPIPS_SIZE_ONE; - CurrInst->TxOffset = XQSPIPS_TXD_01_OFFSET; - if (ByteCount > 4) { - SwitchFlag = 1; - } - break; - case XQSPIPS_SIZE_TWO: - CurrInst->OpCode = Instruction; - CurrInst->InstSize = XQSPIPS_SIZE_TWO; - CurrInst->TxOffset = XQSPIPS_TXD_10_OFFSET; - if (ByteCount > 4) { - SwitchFlag = 1; - } - break; - case XQSPIPS_SIZE_THREE: - CurrInst->OpCode = Instruction; - CurrInst->InstSize = XQSPIPS_SIZE_THREE; - CurrInst->TxOffset = XQSPIPS_TXD_11_OFFSET; - if (ByteCount > 4) { - SwitchFlag = 1; - } - break; - default: - CurrInst->OpCode = Instruction; - CurrInst->InstSize = XQSPIPS_SIZE_FOUR; - CurrInst->TxOffset = XQSPIPS_TXD_00_OFFSET; - break; + switch (ByteCount % 4) { + case XQSPIPS_SIZE_ONE: + CurrInst->OpCode = Instruction; + CurrInst->InstSize = XQSPIPS_SIZE_ONE; + CurrInst->TxOffset = XQSPIPS_TXD_01_OFFSET; + if (ByteCount > 4) { + SwitchFlag = 1; + } + break; + case XQSPIPS_SIZE_TWO: + CurrInst->OpCode = Instruction; + CurrInst->InstSize = XQSPIPS_SIZE_TWO; + CurrInst->TxOffset = XQSPIPS_TXD_10_OFFSET; + if (ByteCount > 4) { + SwitchFlag = 1; + } + break; + case XQSPIPS_SIZE_THREE: + CurrInst->OpCode = Instruction; + CurrInst->InstSize = XQSPIPS_SIZE_THREE; + CurrInst->TxOffset = XQSPIPS_TXD_11_OFFSET; + if (ByteCount > 4) { + SwitchFlag = 1; + } + break; + default: + CurrInst->OpCode = Instruction; + CurrInst->InstSize = XQSPIPS_SIZE_FOUR; + CurrInst->TxOffset = XQSPIPS_TXD_00_OFFSET; + break; } } @@ -577,8 +578,8 @@ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, */ if (XQspiPs_IsManualStart(InstancePtr)) { ConfigReg = XQspiPs_ReadReg( - InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + InstancePtr->Config.BaseAddress, + XQSPIPS_CR_OFFSET); ConfigReg |= XQSPIPS_CR_MANSTRT_MASK; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPS_CR_OFFSET, ConfigReg); @@ -588,8 +589,8 @@ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, */ do { StatusReg = XQspiPs_ReadReg( - InstancePtr->Config.BaseAddress, - XQSPIPS_SR_OFFSET); + InstancePtr->Config.BaseAddress, + XQSPIPS_SR_OFFSET); } while ((StatusReg & XQSPIPS_IXR_TXOW_MASK) == 0); } @@ -599,15 +600,15 @@ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, * we have to send). */ while ((InstancePtr->RemainingBytes > 0) && - (TransCount < XQSPIPS_FIFO_DEPTH)) { + (TransCount < XQSPIPS_FIFO_DEPTH)) { /* * In case of Write fill the Tx FIFO with data to be transmitted. * In case of Read fill the TX FIFO with first 4bytes(1Byte Command + 3Byte Address) * of data from TX Buffer and the remaining bytes(i.e., RequestedBytes - 4) * with DUMMY. */ - if(InstancePtr->RecvBufferPtr && - ((InstancePtr->RequestedBytes - InstancePtr->RemainingBytes) > 4)) { + if (InstancePtr->RecvBufferPtr && + ((InstancePtr->RequestedBytes - InstancePtr->RemainingBytes) > 4)) { XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPS_TXD_00_OFFSET, XQSPIPS_DUMMY_TX_DATA); } else { @@ -629,19 +630,19 @@ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, * enabling interrupts should have been done by the caller). */ XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_IER_OFFSET, XQSPIPS_IXR_RXNEMPTY_MASK | - XQSPIPS_IXR_TXOW_MASK | XQSPIPS_IXR_RXOVR_MASK | - XQSPIPS_IXR_TXUF_MASK); + XQSPIPS_IER_OFFSET, XQSPIPS_IXR_RXNEMPTY_MASK | + XQSPIPS_IXR_TXOW_MASK | XQSPIPS_IXR_RXOVR_MASK | + XQSPIPS_IXR_TXUF_MASK); /* * If, in Manual Start mode, Start the transfer. */ if (XQspiPs_IsManualStart(InstancePtr)) { ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); ConfigReg |= XQSPIPS_CR_MANSTRT_MASK; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET, ConfigReg); + XQSPIPS_CR_OFFSET, ConfigReg); } return XST_SUCCESS; @@ -701,7 +702,7 @@ s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, * ******************************************************************************/ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, - u8 *RecvBufPtr, u32 ByteCount) + u8 *RecvBufPtr, u32 ByteCount) { u32 StatusReg; u32 ConfigReg; @@ -762,7 +763,7 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, * Set the RX FIFO threshold */ XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_RXWR_OFFSET, XQSPIPS_RXFIFO_THRESHOLD_OPT); + XQSPIPS_RXWR_OFFSET, XQSPIPS_RXFIFO_THRESHOLD_OPT); /* * If the slave select is "Forced" or under manual control, @@ -770,11 +771,11 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, */ if (XQspiPs_IsManualChipSelect(InstancePtr)) { ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); ConfigReg &= ~XQSPIPS_CR_SSCTRL_MASK; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET, - ConfigReg); + XQSPIPS_CR_OFFSET, + ConfigReg); } /* @@ -790,7 +791,7 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, * Spansion (3 bytes) and Micron (2 bytes) */ if ((CurrInst->OpCode == XQSPIPS_FLASH_OPCODE_WRSR) && - (ByteCount == 3)) { + (ByteCount == 3)) { CurrInst->InstSize = 3; CurrInst->TxOffset = XQSPIPS_TXD_11_OFFSET; } @@ -808,35 +809,35 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, * through TXD0 below. */ switch (ByteCount % 4) { - case XQSPIPS_SIZE_ONE: - CurrInst->OpCode = Instruction; - CurrInst->InstSize = XQSPIPS_SIZE_ONE; - CurrInst->TxOffset = XQSPIPS_TXD_01_OFFSET; - if (ByteCount > 4) { - SwitchFlag = 1; - } - break; - case XQSPIPS_SIZE_TWO: - CurrInst->OpCode = Instruction; - CurrInst->InstSize = XQSPIPS_SIZE_TWO; - CurrInst->TxOffset = XQSPIPS_TXD_10_OFFSET; - if (ByteCount > 4) { - SwitchFlag = 1; - } - break; - case XQSPIPS_SIZE_THREE: - CurrInst->OpCode = Instruction; - CurrInst->InstSize = XQSPIPS_SIZE_THREE; - CurrInst->TxOffset = XQSPIPS_TXD_11_OFFSET; - if (ByteCount > 4) { - SwitchFlag = 1; - } - break; - default: - CurrInst->OpCode = Instruction; - CurrInst->InstSize = XQSPIPS_SIZE_FOUR; - CurrInst->TxOffset = XQSPIPS_TXD_00_OFFSET; - break; + case XQSPIPS_SIZE_ONE: + CurrInst->OpCode = Instruction; + CurrInst->InstSize = XQSPIPS_SIZE_ONE; + CurrInst->TxOffset = XQSPIPS_TXD_01_OFFSET; + if (ByteCount > 4) { + SwitchFlag = 1; + } + break; + case XQSPIPS_SIZE_TWO: + CurrInst->OpCode = Instruction; + CurrInst->InstSize = XQSPIPS_SIZE_TWO; + CurrInst->TxOffset = XQSPIPS_TXD_10_OFFSET; + if (ByteCount > 4) { + SwitchFlag = 1; + } + break; + case XQSPIPS_SIZE_THREE: + CurrInst->OpCode = Instruction; + CurrInst->InstSize = XQSPIPS_SIZE_THREE; + CurrInst->TxOffset = XQSPIPS_TXD_11_OFFSET; + if (ByteCount > 4) { + SwitchFlag = 1; + } + break; + default: + CurrInst->OpCode = Instruction; + CurrInst->InstSize = XQSPIPS_SIZE_FOUR; + CurrInst->TxOffset = XQSPIPS_TXD_00_OFFSET; + break; } } @@ -860,7 +861,7 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, /* Write the command to the FIFO */ XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - CurrInst->TxOffset, Data); + CurrInst->TxOffset, Data); ++TransCount; /* @@ -873,8 +874,8 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, */ if (XQspiPs_IsManualStart(InstancePtr)) { ConfigReg = XQspiPs_ReadReg( - InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + InstancePtr->Config.BaseAddress, + XQSPIPS_CR_OFFSET); ConfigReg |= XQSPIPS_CR_MANSTRT_MASK; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPS_CR_OFFSET, ConfigReg); @@ -884,8 +885,8 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, */ do { StatusReg = XQspiPs_ReadReg( - InstancePtr->Config.BaseAddress, - XQSPIPS_SR_OFFSET); + InstancePtr->Config.BaseAddress, + XQSPIPS_SR_OFFSET); } while ((StatusReg & XQSPIPS_IXR_TXOW_MASK) == 0); } @@ -901,15 +902,15 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, * many as we have to send). */ while ((InstancePtr->RemainingBytes > 0) && - (TransCount < XQSPIPS_FIFO_DEPTH)) { + (TransCount < XQSPIPS_FIFO_DEPTH)) { /* * In case of Write fill the Tx FIFO with data to be transmitted. * In case of Read fill the TX FIFO with first 4bytes(1Byte Command + 3Byte Address) * of data from TX Buffer and the remaining bytes(i.e., RequestedBytes - 4) * with DUMMY. */ - if(InstancePtr->RecvBufferPtr && - ((InstancePtr->RequestedBytes - InstancePtr->RemainingBytes) > 4)) { + if (InstancePtr->RecvBufferPtr && + ((InstancePtr->RequestedBytes - InstancePtr->RemainingBytes) > 4)) { XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPS_TXD_00_OFFSET, XQSPIPS_DUMMY_TX_DATA); } else { @@ -927,22 +928,22 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, } while ((InstancePtr->RemainingBytes > 0) || - (InstancePtr->RequestedBytes > 0)) { + (InstancePtr->RequestedBytes > 0)) { /* * Fill the TX FIFO with RX threshold no. of entries (or as * many as we have to send, in case that's less). */ while ((InstancePtr->RemainingBytes > 0) && - (TransCount < XQSPIPS_RXFIFO_THRESHOLD_OPT)) { + (TransCount < XQSPIPS_RXFIFO_THRESHOLD_OPT)) { /* * In case of Write fill the Tx FIFO with data to be transmitted. * In case of Read fill the TX FIFO with first 4bytes(1Byte Command + 3Byte Address) * of data from TX Buffer and the remaining bytes(i.e., RequestedBytes - 4) * with DUMMY. */ - if(InstancePtr->RecvBufferPtr && - ((InstancePtr->RequestedBytes - InstancePtr->RemainingBytes) > 4)) { + if (InstancePtr->RecvBufferPtr && + ((InstancePtr->RequestedBytes - InstancePtr->RemainingBytes) > 4)) { XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPS_TXD_00_OFFSET, XQSPIPS_DUMMY_TX_DATA); } else { @@ -964,8 +965,8 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, */ if (IsManualStart == TRUE) { ConfigReg = XQspiPs_ReadReg( - InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + InstancePtr->Config.BaseAddress, + XQSPIPS_CR_OFFSET); ConfigReg |= XQSPIPS_CR_MANSTRT_MASK; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPS_CR_OFFSET, ConfigReg); @@ -988,10 +989,10 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, do { StatusReg = XQspiPs_ReadReg( - InstancePtr->Config.BaseAddress, - XQSPIPS_SR_OFFSET); + InstancePtr->Config.BaseAddress, + XQSPIPS_SR_OFFSET); } while (((StatusReg & XQSPIPS_IXR_TXOW_MASK) == 0) && - ((StatusReg & XQSPIPS_IXR_RXNEMPTY_MASK) == 0)); + ((StatusReg & XQSPIPS_IXR_RXNEMPTY_MASK) == 0)); /* * A transmit has just completed. Process received data @@ -1004,7 +1005,7 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, * software may not care to receive data). */ while ((InstancePtr->RequestedBytes > 0) && - (RxCount < XQSPIPS_RXFIFO_THRESHOLD_OPT)) { + (RxCount < XQSPIPS_RXFIFO_THRESHOLD_OPT)) { u32 Data; RxCount++; @@ -1012,13 +1013,13 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, if (InstancePtr->RecvBufferPtr != NULL) { if (InstancePtr->RequestedBytes < 4) { Data = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_RXD_OFFSET); + XQSPIPS_RXD_OFFSET); XQspiPs_GetReadData(InstancePtr, Data, - InstancePtr->RequestedBytes); + InstancePtr->RequestedBytes); } else { (*(u32 *)InstancePtr->RecvBufferPtr) = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_RXD_OFFSET); + XQSPIPS_RXD_OFFSET); InstancePtr->RecvBufferPtr += 4; InstancePtr->RequestedBytes -= 4; if (InstancePtr->RequestedBytes < 0) { @@ -1027,7 +1028,7 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, } } else { Data = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_RXD_OFFSET); + XQSPIPS_RXD_OFFSET); InstancePtr->RequestedBytes -= 4; } } @@ -1040,10 +1041,10 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, */ if (XQspiPs_IsManualChipSelect(InstancePtr)) { ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); ConfigReg |= XQSPIPS_CR_SSCTRL_MASK; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET, ConfigReg); + XQSPIPS_CR_OFFSET, ConfigReg); } /* @@ -1060,7 +1061,7 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, * Reset the RX FIFO threshold to one */ XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_RXWR_OFFSET, XQSPIPS_RXWR_RESET_VALUE); + XQSPIPS_RXWR_OFFSET, XQSPIPS_RXWR_RESET_VALUE); return XST_SUCCESS; } @@ -1085,7 +1086,7 @@ s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, * ******************************************************************************/ int XQspiPs_LqspiRead(XQspiPs *InstancePtr, u8 *RecvBufPtr, - u32 Address, unsigned ByteCount) + u32 Address, unsigned ByteCount) { int Status = (int)XST_SUCCESS; Xil_AssertNonvoid(InstancePtr != NULL); @@ -1102,11 +1103,11 @@ int XQspiPs_LqspiRead(XQspiPs *InstancePtr, u8 *RecvBufPtr, XQspiPs_Enable(InstancePtr); if (XQspiPs_GetLqspiConfigReg(InstancePtr) & - XQSPIPS_LQSPI_CR_LINEAR_MASK) { + XQSPIPS_LQSPI_CR_LINEAR_MASK) { memcpy((void *)RecvBufPtr, - (const void *)(XPAR_PS7_QSPI_LINEAR_0_S_AXI_BASEADDR + - Address), - (size_t)ByteCount); + (const void *)(XPAR_PS7_QSPI_LINEAR_0_S_AXI_BASEADDR + + Address), + (size_t)ByteCount); Status = (int)XST_SUCCESS; } else { Status = (int)XST_FAILURE; @@ -1160,10 +1161,10 @@ int XQspiPs_SetSlaveSelect(XQspiPs *InstancePtr) * Select the slave */ ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); ConfigReg &= ~XQSPIPS_CR_SSCTRL_MASK; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET, ConfigReg); + XQSPIPS_CR_OFFSET, ConfigReg); return XST_SUCCESS; } @@ -1206,7 +1207,7 @@ int XQspiPs_SetSlaveSelect(XQspiPs *InstancePtr) * ******************************************************************************/ void XQspiPs_SetStatusHandler(XQspiPs *InstancePtr, void *CallBackRef, - XQspiPs_StatusHandler FuncPtr) + XQspiPs_StatusHandler FuncPtr) { Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(FuncPtr != NULL); @@ -1233,7 +1234,7 @@ void XQspiPs_SetStatusHandler(XQspiPs *InstancePtr, void *CallBackRef, * ******************************************************************************/ static void StubStatusHandler(void *CallBackRef, u32 StatusEvent, - unsigned ByteCount) + unsigned ByteCount) { (void) CallBackRef; (void) StatusEvent; @@ -1298,15 +1299,15 @@ void XQspiPs_InterruptHandler(void *InstancePtr) * TX_EMPTY interrupt. */ IntrStatus = XQspiPs_ReadReg(QspiPtr->Config.BaseAddress, - XQSPIPS_SR_OFFSET); + XQSPIPS_SR_OFFSET); XQspiPs_WriteReg(QspiPtr->Config.BaseAddress, XQSPIPS_SR_OFFSET, - (IntrStatus & XQSPIPS_IXR_WR_TO_CLR_MASK)); + (IntrStatus & XQSPIPS_IXR_WR_TO_CLR_MASK)); XQspiPs_WriteReg(QspiPtr->Config.BaseAddress, XQSPIPS_IDR_OFFSET, - XQSPIPS_IXR_TXOW_MASK | XQSPIPS_IXR_RXNEMPTY_MASK | - XQSPIPS_IXR_RXOVR_MASK | XQSPIPS_IXR_TXUF_MASK); + XQSPIPS_IXR_TXOW_MASK | XQSPIPS_IXR_RXNEMPTY_MASK | + XQSPIPS_IXR_RXOVR_MASK | XQSPIPS_IXR_TXUF_MASK); if ((IntrStatus & XQSPIPS_IXR_TXOW_MASK) || - (IntrStatus & XQSPIPS_IXR_RXNEMPTY_MASK)) { + (IntrStatus & XQSPIPS_IXR_RXNEMPTY_MASK)) { /* * Rx FIFO has just reached threshold no. of entries. @@ -1320,24 +1321,24 @@ void XQspiPs_InterruptHandler(void *InstancePtr) */ TransCount = QspiPtr->RequestedBytes - QspiPtr->RemainingBytes; if (TransCount % 4) { - TransCount = TransCount/4 + 1; + TransCount = TransCount / 4 + 1; } else { - TransCount = TransCount/4; + TransCount = TransCount / 4; } while ((Count < TransCount) && - (Count < XQSPIPS_RXFIFO_THRESHOLD_OPT)) { + (Count < XQSPIPS_RXFIFO_THRESHOLD_OPT)) { if (QspiPtr->RecvBufferPtr != NULL) { if (QspiPtr->RequestedBytes < 4) { Data = XQspiPs_ReadReg(QspiPtr->Config.BaseAddress, - XQSPIPS_RXD_OFFSET); + XQSPIPS_RXD_OFFSET); XQspiPs_GetReadData(QspiPtr, Data, - QspiPtr->RequestedBytes); + QspiPtr->RequestedBytes); } else { (*(u32 *)QspiPtr->RecvBufferPtr) = XQspiPs_ReadReg(QspiPtr->Config.BaseAddress, - XQSPIPS_RXD_OFFSET); + XQSPIPS_RXD_OFFSET); QspiPtr->RecvBufferPtr += 4; QspiPtr->RequestedBytes -= 4; if (QspiPtr->RequestedBytes < 0) { @@ -1363,7 +1364,7 @@ void XQspiPs_InterruptHandler(void *InstancePtr) * remaining entries (in case that is less than threshold) */ while ((QspiPtr->RemainingBytes > 0) && - (Count < XQSPIPS_RXFIFO_THRESHOLD_OPT)) { + (Count < XQSPIPS_RXFIFO_THRESHOLD_OPT)) { /* * Send more data. * In case of Write fill the Tx FIFO with data to be transmitted. @@ -1371,8 +1372,8 @@ void XQspiPs_InterruptHandler(void *InstancePtr) * of data from TX Buffer and the remaining bytes(i.e., RequestedBytes - 4) * with DUMMY. */ - if(QspiPtr->RecvBufferPtr && - ((QspiPtr->RequestedBytes - QspiPtr->RemainingBytes) > 4)) { + if (QspiPtr->RecvBufferPtr && + ((QspiPtr->RequestedBytes - QspiPtr->RemainingBytes) > 4)) { XQspiPs_WriteReg(QspiPtr->Config.BaseAddress, XQSPIPS_TXD_00_OFFSET, XQSPIPS_DUMMY_TX_DATA); } else { @@ -1391,7 +1392,7 @@ void XQspiPs_InterruptHandler(void *InstancePtr) } if ((QspiPtr->RemainingBytes == 0) && - (QspiPtr->RequestedBytes == 0)) { + (QspiPtr->RequestedBytes == 0)) { /* * No more data to send. Disable the interrupt * and inform the upper layer software that the @@ -1399,11 +1400,11 @@ void XQspiPs_InterruptHandler(void *InstancePtr) * when another transfer is initiated. */ XQspiPs_WriteReg(QspiPtr->Config.BaseAddress, - XQSPIPS_IDR_OFFSET, - XQSPIPS_IXR_RXNEMPTY_MASK | - XQSPIPS_IXR_TXOW_MASK | - XQSPIPS_IXR_RXOVR_MASK | - XQSPIPS_IXR_TXUF_MASK); + XQSPIPS_IDR_OFFSET, + XQSPIPS_IXR_RXNEMPTY_MASK | + XQSPIPS_IXR_TXOW_MASK | + XQSPIPS_IXR_RXOVR_MASK | + XQSPIPS_IXR_TXUF_MASK); /* * If the Slave select is being manually controlled, @@ -1411,12 +1412,12 @@ void XQspiPs_InterruptHandler(void *InstancePtr) */ if (XQspiPs_IsManualChipSelect(InstancePtr)) { ConfigReg = XQspiPs_ReadReg( - QspiPtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + QspiPtr->Config.BaseAddress, + XQSPIPS_CR_OFFSET); ConfigReg |= XQSPIPS_CR_SSCTRL_MASK; XQspiPs_WriteReg(QspiPtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET, - ConfigReg); + XQSPIPS_CR_OFFSET, + ConfigReg); } /* @@ -1433,11 +1434,11 @@ void XQspiPs_InterruptHandler(void *InstancePtr) * Reset the RX FIFO threshold to one */ XQspiPs_WriteReg(QspiPtr->Config.BaseAddress, - XQSPIPS_RXWR_OFFSET, XQSPIPS_RXWR_RESET_VALUE); + XQSPIPS_RXWR_OFFSET, XQSPIPS_RXWR_RESET_VALUE); QspiPtr->StatusHandler(QspiPtr->StatusRef, - XST_SPI_TRANSFER_DONE, - QspiPtr->RequestedBytes); + XST_SPI_TRANSFER_DONE, + QspiPtr->RequestedBytes); } else { /* * Enable the TXOW interrupt. @@ -1453,12 +1454,12 @@ void XQspiPs_InterruptHandler(void *InstancePtr) */ if (XQspiPs_IsManualStart(QspiPtr)) { ConfigReg = XQspiPs_ReadReg( - QspiPtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + QspiPtr->Config.BaseAddress, + XQSPIPS_CR_OFFSET); ConfigReg |= XQSPIPS_CR_MANSTRT_MASK; XQspiPs_WriteReg( QspiPtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET, ConfigReg); + XQSPIPS_CR_OFFSET, ConfigReg); } } } @@ -1476,11 +1477,11 @@ void XQspiPs_InterruptHandler(void *InstancePtr) */ if (XQspiPs_IsManualChipSelect(InstancePtr)) { ConfigReg = XQspiPs_ReadReg( - QspiPtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + QspiPtr->Config.BaseAddress, + XQSPIPS_CR_OFFSET); ConfigReg |= XQSPIPS_CR_SSCTRL_MASK; XQspiPs_WriteReg(QspiPtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET, ConfigReg); + XQSPIPS_CR_OFFSET, ConfigReg); } /* @@ -1492,10 +1493,10 @@ void XQspiPs_InterruptHandler(void *InstancePtr) * Reset the RX FIFO threshold to one */ XQspiPs_WriteReg(QspiPtr->Config.BaseAddress, - XQSPIPS_RXWR_OFFSET, XQSPIPS_RXWR_RESET_VALUE); + XQSPIPS_RXWR_OFFSET, XQSPIPS_RXWR_RESET_VALUE); QspiPtr->StatusHandler(QspiPtr->StatusRef, - XST_SPI_RECEIVE_OVERRUN, BytesDone); + XST_SPI_RECEIVE_OVERRUN, BytesDone); } if (IntrStatus & XQSPIPS_IXR_TXUF_MASK) { @@ -1508,11 +1509,11 @@ void XQspiPs_InterruptHandler(void *InstancePtr) */ if (XQspiPs_IsManualChipSelect(InstancePtr)) { ConfigReg = XQspiPs_ReadReg( - QspiPtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + QspiPtr->Config.BaseAddress, + XQSPIPS_CR_OFFSET); ConfigReg |= XQSPIPS_CR_SSCTRL_MASK; XQspiPs_WriteReg(QspiPtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET, ConfigReg); + XQSPIPS_CR_OFFSET, ConfigReg); } /* @@ -1524,10 +1525,10 @@ void XQspiPs_InterruptHandler(void *InstancePtr) * Reset the RX FIFO threshold to one */ XQspiPs_WriteReg(QspiPtr->Config.BaseAddress, - XQSPIPS_RXWR_OFFSET, XQSPIPS_RXWR_RESET_VALUE); + XQSPIPS_RXWR_OFFSET, XQSPIPS_RXWR_RESET_VALUE); QspiPtr->StatusHandler(QspiPtr->StatusRef, - XST_SPI_TRANSMIT_UNDERRUN, BytesDone); + XST_SPI_TRANSMIT_UNDERRUN, BytesDone); } } @@ -1552,46 +1553,46 @@ static void XQspiPs_GetReadData(XQspiPs *InstancePtr, u32 Data, u8 Size) if (InstancePtr->RecvBufferPtr) { switch (Size) { - case 1: - if (InstancePtr->ShiftReadData == 1) { - *((u8 *)InstancePtr->RecvBufferPtr) = - ((Data & 0xFF000000) >> 24); - } else { - *((u8 *)InstancePtr->RecvBufferPtr) = - (Data & 0xFF); - } - InstancePtr->RecvBufferPtr += 1; - break; - case 2: - if (InstancePtr->ShiftReadData == 1) { - *((u16 *)InstancePtr->RecvBufferPtr) = - ((Data >> 16) & 0xFF00) | - ((Data >> 8) & 0xFF); - } else { - *((u16 *)InstancePtr->RecvBufferPtr) = - (Data & 0xFFFF); - } - InstancePtr->RecvBufferPtr += 2; - break; - case 3: - if (InstancePtr->ShiftReadData == 1) { - *((u16 *)InstancePtr->RecvBufferPtr) = - ((Data & 0x00FFFF00) >> 8); + case 1: + if (InstancePtr->ShiftReadData == 1) { + *((u8 *)InstancePtr->RecvBufferPtr) = + ((Data & 0xFF000000) >> 24); + } else { + *((u8 *)InstancePtr->RecvBufferPtr) = + (Data & 0xFF); + } + InstancePtr->RecvBufferPtr += 1; + break; + case 2: + if (InstancePtr->ShiftReadData == 1) { + *((u16 *)InstancePtr->RecvBufferPtr) = + ((Data >> 16) & 0xFF00) | + ((Data >> 8) & 0xFF); + } else { + *((u16 *)InstancePtr->RecvBufferPtr) = + (Data & 0xFFFF); + } InstancePtr->RecvBufferPtr += 2; - DataByte3 = ((Data & 0xFF000000) >> 24); - *((u8 *)InstancePtr->RecvBufferPtr) = DataByte3; - } else { - *((u16 *)InstancePtr->RecvBufferPtr) = - (Data & 0xFFFF); - InstancePtr->RecvBufferPtr += 2; - DataByte3 = ((Data & 0x00FF0000) >> 16); - *((u8 *)InstancePtr->RecvBufferPtr) = DataByte3; - } - InstancePtr->RecvBufferPtr += 1; - break; - default: - /* This will never execute */ - break; + break; + case 3: + if (InstancePtr->ShiftReadData == 1) { + *((u16 *)InstancePtr->RecvBufferPtr) = + ((Data & 0x00FFFF00) >> 8); + InstancePtr->RecvBufferPtr += 2; + DataByte3 = ((Data & 0xFF000000) >> 24); + *((u8 *)InstancePtr->RecvBufferPtr) = DataByte3; + } else { + *((u16 *)InstancePtr->RecvBufferPtr) = + (Data & 0xFFFF); + InstancePtr->RecvBufferPtr += 2; + DataByte3 = ((Data & 0x00FF0000) >> 16); + *((u8 *)InstancePtr->RecvBufferPtr) = DataByte3; + } + InstancePtr->RecvBufferPtr += 1; + break; + default: + /* This will never execute */ + break; } } InstancePtr->ShiftReadData = 0; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.h b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.h index d7bae80..11540d1 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xqspips.h -* @addtogroup qspips_v3_10 +* @addtogroup qspips Overview * @{ * @details * @@ -270,6 +271,8 @@ * 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. +* 3.11 akm 07/10/23 Update the driver to support for system device-tree flow. +* 3.12 sb 02/20/24 Add missing parenthesis for macro expansions. * * * @@ -478,16 +481,26 @@ extern "C" { * requested if the status event indicates an error. */ typedef void (*XQspiPs_StatusHandler) (void *CallBackRef, u32 StatusEvent, - unsigned ByteCount); + unsigned ByteCount); /** * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddress; /**< Base address of the device */ u32 InputClockHz; /**< Input clock frequency */ u8 ConnectionMode; /**< Single, Stacked and Parallel mode */ +#ifdef SDT + u32 IntrId; /**< Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /**< Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ +#endif } XQspiPs_Config; /** @@ -571,7 +584,7 @@ typedef struct { *****************************************************************************/ #define XQspiPs_SetSlaveIdle(InstancePtr, RegisterValue) \ XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ - XQSPIPS_SICR_OFFSET, (RegisterValue)) + XQSPIPS_SICR_OFFSET, (RegisterValue)) /****************************************************************************/ /** @@ -589,7 +602,7 @@ typedef struct { *****************************************************************************/ #define XQspiPs_GetSlaveIdle(InstancePtr) \ XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + \ - XQSPIPS_SICR_OFFSET) + XQSPIPS_SICR_OFFSET) /****************************************************************************/ /** @@ -608,7 +621,7 @@ typedef struct { *****************************************************************************/ #define XQspiPs_SetTXWatermark(InstancePtr, RegisterValue) \ XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ - XQSPIPS_TXWR_OFFSET, (RegisterValue)) + XQSPIPS_TXWR_OFFSET, (RegisterValue)) /****************************************************************************/ /** @@ -625,7 +638,7 @@ typedef struct { * *****************************************************************************/ #define XQspiPs_GetTXWatermark(InstancePtr) \ - XQspiPs_In32((InstancePtr->Config.BaseAddress) + XQSPIPS_TXWR_OFFSET) + XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_TXWR_OFFSET) /****************************************************************************/ /** @@ -644,7 +657,7 @@ typedef struct { *****************************************************************************/ #define XQspiPs_SetRXWatermark(InstancePtr, RegisterValue) \ XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ - XQSPIPS_RXWR_OFFSET, (RegisterValue)) + XQSPIPS_RXWR_OFFSET, (RegisterValue)) /****************************************************************************/ /** @@ -661,7 +674,7 @@ typedef struct { * *****************************************************************************/ #define XQspiPs_GetRXWatermark(InstancePtr) \ - XQspiPs_In32((InstancePtr->Config.BaseAddress) + XQSPIPS_RXWR_OFFSET) + XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_RXWR_OFFSET) /****************************************************************************/ /** @@ -677,8 +690,8 @@ typedef struct { * *****************************************************************************/ #define XQspiPs_Enable(InstancePtr) \ - XQspiPs_Out32((InstancePtr->Config.BaseAddress) + XQSPIPS_ER_OFFSET, \ - XQSPIPS_ER_ENABLE_MASK) + XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_ER_OFFSET, \ + XQSPIPS_ER_ENABLE_MASK) /****************************************************************************/ /** @@ -694,7 +707,7 @@ typedef struct { * *****************************************************************************/ #define XQspiPs_Disable(InstancePtr) \ - XQspiPs_Out32((InstancePtr->Config.BaseAddress) + XQSPIPS_ER_OFFSET, 0) + XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_ER_OFFSET, 0) /****************************************************************************/ /** @@ -714,7 +727,7 @@ typedef struct { *****************************************************************************/ #define XQspiPs_SetLqspiConfigReg(InstancePtr, RegisterValue) \ XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ - XQSPIPS_LQSPI_CR_OFFSET, (RegisterValue)) + XQSPIPS_LQSPI_CR_OFFSET, (RegisterValue)) /****************************************************************************/ /** @@ -731,35 +744,39 @@ typedef struct { * *****************************************************************************/ #define XQspiPs_GetLqspiConfigReg(InstancePtr) \ - XQspiPs_In32((InstancePtr->Config.BaseAddress) + \ - XQSPIPS_LQSPI_CR_OFFSET) + XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + \ + XQSPIPS_LQSPI_CR_OFFSET) /************************** Function Prototypes ******************************/ /* * Initialization function, implemented in xqspips_sinit.c */ +#ifndef SDT XQspiPs_Config *XQspiPs_LookupConfig(u16 DeviceId); +#else +XQspiPs_Config *XQspiPs_LookupConfig(UINTPTR BaseAddress); +#endif /* * Functions implemented in xqspips.c */ int XQspiPs_CfgInitialize(XQspiPs *InstancePtr, XQspiPs_Config *Config, - u32 EffectiveAddr); + u32 EffectiveAddr); void XQspiPs_Reset(XQspiPs *InstancePtr); void XQspiPs_Abort(XQspiPs *InstancePtr); s32 XQspiPs_Transfer(XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, - u32 ByteCount); + u32 ByteCount); s32 XQspiPs_PolledTransfer(XQspiPs *InstancePtr, u8 *SendBufPtr, - u8 *RecvBufPtr, u32 ByteCount); + u8 *RecvBufPtr, u32 ByteCount); int XQspiPs_LqspiRead(XQspiPs *InstancePtr, u8 *RecvBufPtr, - u32 Address, unsigned ByteCount); + u32 Address, unsigned ByteCount); int XQspiPs_SetSlaveSelect(XQspiPs *InstancePtr); void XQspiPs_SetStatusHandler(XQspiPs *InstancePtr, void *CallBackRef, - XQspiPs_StatusHandler FuncPtr); + XQspiPs_StatusHandler FuncPtr); void XQspiPs_InterruptHandler(void *InstancePtr); /* @@ -777,9 +794,9 @@ 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); + u8 DelayAfter, u8 DelayInit); void XQspiPs_GetDelays(XQspiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn, - u8 *DelayAfter, u8 *DelayInit); + u8 *DelayAfter, u8 *DelayInit); #ifdef __cplusplus } #endif diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_g.c index 31c0507..30da604 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_g.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xqspips_g.c -* @addtogroup qspips_v3_10 +* @addtogroup qspips Overview * @{ * * This file contains a configuration table that specifies the configuration of diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.c b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.c index 77af96c..ce2691f 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xqspips_hw.c -* @addtogroup qspips_v3_10 +* @addtogroup qspips Overview * @{ * * Contains low level functions, primarily reset related. @@ -71,13 +72,13 @@ void XQspiPs_ResetHw(u32 BaseAddress) * Disable interrupts */ XQspiPs_WriteReg(BaseAddress, XQSPIPS_IDR_OFFSET, - XQSPIPS_IXR_DISABLE_ALL); + XQSPIPS_IXR_DISABLE_ALL); /* * Disable device */ XQspiPs_WriteReg(BaseAddress, XQSPIPS_ER_OFFSET, - 0); + 0); /* * De-assert slave select lines. @@ -92,14 +93,14 @@ void XQspiPs_ResetHw(u32 BaseAddress) * status bit is used next to clear the RXFIFO */ XQspiPs_WriteReg(BaseAddress, XQSPIPS_TXWR_OFFSET, - (XQSPIPS_TXWR_RESET_VALUE & XQSPIPS_TXWR_MASK)); + (XQSPIPS_TXWR_RESET_VALUE & XQSPIPS_TXWR_MASK)); XQspiPs_WriteReg(BaseAddress, XQSPIPS_RXWR_OFFSET, - (XQSPIPS_RXWR_RESET_VALUE & XQSPIPS_RXWR_MASK)); + (XQSPIPS_RXWR_RESET_VALUE & XQSPIPS_RXWR_MASK)); /* * Clear RXFIFO */ - while ((XQspiPs_ReadReg(BaseAddress,XQSPIPS_SR_OFFSET) & + while ((XQspiPs_ReadReg(BaseAddress, XQSPIPS_SR_OFFSET) & XQSPIPS_IXR_RXNEMPTY_MASK) != 0) { XQspiPs_ReadReg(BaseAddress, XQSPIPS_RXD_OFFSET); } @@ -110,7 +111,7 @@ void XQspiPs_ResetHw(u32 BaseAddress) */ XQspiPs_ReadReg(BaseAddress, XQSPIPS_SR_OFFSET); XQspiPs_WriteReg(BaseAddress, XQSPIPS_SR_OFFSET, - XQSPIPS_IXR_WR_TO_CLR_MASK); + XQSPIPS_IXR_WR_TO_CLR_MASK); /* * Write default value to configuration register @@ -124,7 +125,7 @@ void XQspiPs_ResetHw(u32 BaseAddress) * De-select linear mode */ XQspiPs_WriteReg(BaseAddress, XQSPIPS_LQSPI_CR_OFFSET, - 0x0); + 0x0); } @@ -166,33 +167,33 @@ void XQspiPs_LinearInit(u32 BaseAddress) * enable linear mode and use fast read. */ - if(XPAR_XQSPIPS_0_QSPI_MODE == XQSPIPS_CONNECTION_MODE_SINGLE){ + 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){ + } else if (XPAR_XQSPIPS_0_QSPI_MODE == + XQSPIPS_CONNECTION_MODE_STACKED) { LinearCfg = XQSPIPS_LQSPI_CR_RST_STATE | - XQSPIPS_LQSPI_CR_TWO_MEM_MASK; + XQSPIPS_LQSPI_CR_TWO_MEM_MASK; - }else if(XPAR_XQSPIPS_0_QSPI_MODE == - XQSPIPS_CONNECTION_MODE_PARALLEL){ + } 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_LQSPI_CR_TWO_MEM_MASK | + XQSPIPS_LQSPI_CR_SEP_BUS_MASK; } XQspiPs_WriteReg(BaseAddress, XQSPIPS_LQSPI_CR_OFFSET, - LinearCfg); + LinearCfg); /* * Enable device */ XQspiPs_WriteReg(BaseAddress, XQSPIPS_ER_OFFSET, - XQSPIPS_ER_ENABLE_MASK); + XQSPIPS_ER_ENABLE_MASK); } /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.h index ab50675..a136a2f 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xqspips_hw.h -* @addtogroup qspips_v3_10 +* @addtogroup qspips Overview * @{ * * This header file contains the identifiers and basic HW access driver @@ -117,18 +118,18 @@ extern "C" { /* 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 + 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 + 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 /* @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_options.c b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_options.c index 54d455d..70c4479 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_options.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_options.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xqspips_options.c -* @addtogroup qspips_v3_10 +* @addtogroup qspips Overview * @{ * * Contains functions for the configuration of the XQspiPs driver component. @@ -116,7 +117,7 @@ s32 XQspiPs_SetOptions(XQspiPs *InstancePtr, u32 Options) Options &= ~XQSPIPS_LQSPI_MODE_OPTION; ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); /* * Loop through the options table, turning the option on or off @@ -143,18 +144,18 @@ s32 XQspiPs_SetOptions(XQspiPs *InstancePtr, u32 Options) * Check for the LQSPI configuration options. */ ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_LQSPI_CR_OFFSET); + 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_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); + XQSPIPS_LQSPI_CR_OFFSET, ConfigReg); } return XST_SUCCESS; @@ -190,7 +191,7 @@ u32 XQspiPs_GetOptions(XQspiPs *InstancePtr) * Get the current options from QSPI configuration register. */ ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); /* * Loop through the options table to grab options @@ -205,7 +206,7 @@ u32 XQspiPs_GetOptions(XQspiPs *InstancePtr) * Check for the LQSPI configuration options. */ ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_LQSPI_CR_OFFSET); + XQSPIPS_LQSPI_CR_OFFSET); if ((ConfigReg & XQSPIPS_LQSPI_CR_LINEAR_MASK) != 0) { OptionsFlag |= XQSPIPS_LQSPI_MODE_OPTION; @@ -257,15 +258,15 @@ s32 XQspiPs_SetClkPrescaler(XQspiPs *InstancePtr, u8 Prescaler) * results back to the configuration register. */ ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); ConfigReg &= ~XQSPIPS_CR_PRESC_MASK; ConfigReg |= (u32) (Prescaler & XQSPIPS_CR_PRESC_MAXIMUM) << - XQSPIPS_CR_PRESC_SHIFT; + XQSPIPS_CR_PRESC_SHIFT; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET, - ConfigReg); + XQSPIPS_CR_OFFSET, + ConfigReg); return XST_SUCCESS; } @@ -291,7 +292,7 @@ u8 XQspiPs_GetClkPrescaler(XQspiPs *InstancePtr) Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_CR_OFFSET); + XQSPIPS_CR_OFFSET); ConfigReg &= XQSPIPS_CR_PRESC_MASK; @@ -330,7 +331,7 @@ u8 XQspiPs_GetClkPrescaler(XQspiPs *InstancePtr) * ******************************************************************************/ int XQspiPs_SetDelays(XQspiPs *InstancePtr, u8 DelayNss, u8 DelayBtwn, - u8 DelayAfter, u8 DelayInit) + u8 DelayAfter, u8 DelayInit) { u32 DelayRegister; @@ -352,7 +353,7 @@ int XQspiPs_SetDelays(XQspiPs *InstancePtr, u8 DelayNss, u8 DelayBtwn, DelayRegister |= (u32) DelayInit; XQspiPs_WriteReg(InstancePtr->Config.BaseAddress, - XQSPIPS_DR_OFFSET, DelayRegister); + XQSPIPS_DR_OFFSET, DelayRegister); return XST_SUCCESS; } @@ -380,7 +381,7 @@ int XQspiPs_SetDelays(XQspiPs *InstancePtr, u8 DelayNss, u8 DelayBtwn, * ******************************************************************************/ void XQspiPs_GetDelays(XQspiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn, - u8 *DelayAfter, u8 *DelayInit) + u8 *DelayAfter, u8 *DelayInit) { u32 DelayRegister; @@ -388,7 +389,7 @@ void XQspiPs_GetDelays(XQspiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn, Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); DelayRegister = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, - XQSPIPS_DR_OFFSET); + XQSPIPS_DR_OFFSET); *DelayInit = (u8)(DelayRegister & XQSPIPS_DR_INIT_MASK); @@ -399,6 +400,6 @@ void XQspiPs_GetDelays(XQspiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn, XQSPIPS_DR_BTWN_SHIFT); *DelayNss = (u8)((DelayRegister & XQSPIPS_DR_NSS_MASK) >> - XQSPIPS_DR_NSS_SHIFT); + XQSPIPS_DR_NSS_SHIFT); } /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_selftest.c b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_selftest.c index a35158d..c899856 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_selftest.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_selftest.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xqspips_selftest.c -* @addtogroup qspips_v3_10 +* @addtogroup qspips Overview * @{ * * This file contains the implementation of selftest function for the QSPI @@ -86,15 +87,15 @@ int XQspiPs_SelfTest(XQspiPs *InstancePtr) * hardware out there. */ Status = XQspiPs_SetDelays(InstancePtr, DelayTestNss, DelayTestBtwn, - DelayTestAfter, DelayTestInit); + DelayTestAfter, DelayTestInit); if (Status != XST_SUCCESS) { return Status; } XQspiPs_GetDelays(InstancePtr, &DelayTestNss, &DelayTestBtwn, - &DelayTestAfter, &DelayTestInit); + &DelayTestAfter, &DelayTestInit); if ((0x5A != DelayTestNss) || (0xA5 != DelayTestBtwn) || - (0xAA != DelayTestAfter) || (0x55 != DelayTestInit)) { + (0xAA != DelayTestAfter) || (0x55 != DelayTestInit)) { return XST_REGISTER_ERROR; } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_sinit.c index f47fb67..3d1f32e 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/qspips/src/xqspips_sinit.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xqspips_sinit.c -* @addtogroup qspips_v3_10 +* @addtogroup qspips Overview * @{ * * The implementation of the XQspiPs component's static initialization @@ -19,6 +20,7 @@ * Ver Who Date Changes * ----- --- -------- ----------------------------------------------- * 1.00 sdm 11/25/10 First release +* 3.11 akm 07/10/23 Update the driver to support for system device-tree flow. * * ******************************************************************************/ @@ -27,7 +29,9 @@ #include "xstatus.h" #include "xqspips.h" +#ifndef SDT #include "xparameters.h" +#endif /************************** Constant Definitions *****************************/ @@ -58,6 +62,7 @@ extern XQspiPs_Config XQspiPs_ConfigTable[]; * @note None. * ******************************************************************************/ +#ifndef SDT XQspiPs_Config *XQspiPs_LookupConfig(u16 DeviceId) { XQspiPs_Config *CfgPtr = NULL; @@ -71,4 +76,20 @@ XQspiPs_Config *XQspiPs_LookupConfig(u16 DeviceId) } return CfgPtr; } +#else +XQspiPs_Config *XQspiPs_LookupConfig(UINTPTR BaseAddress) +{ + XQspiPs_Config *CfgPtr = NULL; + int Index; + + for (Index = 0U; XQspiPs_ConfigTable[Index].Name != NULL; Index++) { + if ((XQspiPs_ConfigTable[Index].BaseAddress == BaseAddress) || + !BaseAddress) { + CfgPtr = &XQspiPs_ConfigTable[Index]; + break; + } + } + return CfgPtr; +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic.c b/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic.c index bb74614..8016296 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,11 +8,11 @@ /** * * @file xscugic.c -* @addtogroup scugic Overview +* @addtogroup scugic_api SCUGIC APIs * @{ * -* Contains required functions for the XScuGic driver for the Interrupt -* Controller. See xscugic.h for a detailed description of the driver. +* The xscugic.c file contains required functions for the XScuGic driver for the Interrupt +* Controller. * *@@ -26,7 +27,9 @@ /***************************** Include Files ********************************/ #include "xstatus.h" +#ifndef SDT #include "xparameters.h" +#endif #include "xdmaps.h" /************************** Constant Definitions ****************************/ @@ -60,6 +63,7 @@ extern XDmaPs_Config XDmaPs_ConfigTable[]; * None. * ******************************************************************************/ +#ifndef SDT XDmaPs_Config *XDmaPs_LookupConfig(u16 DeviceId) { XDmaPs_Config *CfgPtr = NULL; @@ -75,4 +79,34 @@ XDmaPs_Config *XDmaPs_LookupConfig(u16 DeviceId) return CfgPtr; } +#else +XDmaPs_Config *XDmaPs_LookupConfig(UINTPTR BaseAddress) +{ + XDmaPs_Config *CfgPtr = NULL; + int i; + + for (i = (u32)0x0; XDmaPs_ConfigTable[i].Name != NULL; i++) { + if ((XDmaPs_ConfigTable[i].BaseAddress == BaseAddress) || + !BaseAddress) { + CfgPtr = &XDmaPs_ConfigTable[i]; + break; + } + } + + return CfgPtr; +} + +u32 XDmaPs_GetDrvIndex(XDmaPs *InstancePtr, UINTPTR BaseAddress) +{ + u32 Index = 0; + + for (Index = (u32)0x0; XDmaPs_ConfigTable[Index].Name != NULL; Index++) { + if ((XDmaPs_ConfigTable[Index].BaseAddress == BaseAddress)) { + break; + } + } + + return Index; +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.c b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.c index 88a35cb..82ffae9 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps.c -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * The XEmacPs driver. Functions in this file are the minimum required functions @@ -85,12 +86,21 @@ LONG XEmacPs_CfgInitialize(XEmacPs *InstancePtr, XEmacPs_Config * CfgPtr, Xil_AssertNonvoid(CfgPtr != NULL); /* Set device base address and ID */ +#ifndef SDT InstancePtr->Config.DeviceId = CfgPtr->DeviceId; +#endif InstancePtr->Config.BaseAddress = EffectiveAddress; InstancePtr->Config.IsCacheCoherent = CfgPtr->IsCacheCoherent; +#ifdef SDT + InstancePtr->Config.IntrId = CfgPtr->IntrId; + InstancePtr->Config.IntrParent = CfgPtr->IntrParent; +#endif #if defined (XCLOCKING) InstancePtr->Config.RefClk = CfgPtr->RefClk; #endif +#ifdef SDT + InstancePtr->Config.PhyType = CfgPtr->PhyType; +#endif InstancePtr->Config.S1GDiv0 = CfgPtr->S1GDiv0; InstancePtr->Config.S1GDiv1 = CfgPtr->S1GDiv1; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.h b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.h index ac3e7a7..564d926 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps.h -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * @details * @@ -417,15 +418,15 @@ extern "C" { #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) + ((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 */ /*@}*/ @@ -456,11 +457,11 @@ extern "C" { #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) + XEMACPS_TRL_SIZE) #define XEMACPS_MAX_VLAN_FRAME_SIZE (XEMACPS_MTU + XEMACPS_HDR_SIZE + \ - XEMACPS_HDR_VLAN_SIZE + XEMACPS_TRL_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) + XEMACPS_HDR_VLAN_SIZE + XEMACPS_TRL_SIZE) /* DMACR Bust length hash defines */ @@ -500,7 +501,7 @@ typedef void (*XEmacPs_Handler) (void *CallBackRef); * */ typedef void (*XEmacPs_ErrHandler) (void *CallBackRef, u8 Direction, - u32 ErrorWord); + u32 ErrorWord); /*@}*/ @@ -508,12 +509,25 @@ typedef void (*XEmacPs_ErrHandler) (void *CallBackRef, u8 Direction, * This typedef contains configuration information for a device. */ typedef struct { +#ifdef SDT + char *Name; /**< Unique name of the device */ +#else u16 DeviceId; /**< Unique ID of device */ +#endif 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) +#ifdef SDT + u16 IntrId; + UINTPTR IntrParent; +#endif +#if defined (XCLOCKING) || defined (SDT) u32 RefClk; /**< Input clock */ +#endif +#ifdef SDT + char *PhyType; /**< PhyType indicates which type of PHY interface is + * used (MII, GMII, RGMII, etc. + */ #endif u16 S1GDiv0; /**< 1Gbps Clock Divider 0 */ u8 S1GDiv1; /**< 1Gbps Clock Divider 1 */ @@ -606,8 +620,8 @@ typedef struct XEmacPs_Instance { *****************************************************************************/ #define XEmacPs_IntEnable(InstancePtr, Mask) \ XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_IER_OFFSET, \ - ((Mask) & XEMACPS_IXR_ALL_MASK)); + XEMACPS_IER_OFFSET, \ + ((Mask) & XEMACPS_IXR_ALL_MASK)); /****************************************************************************/ /** @@ -627,8 +641,8 @@ typedef struct XEmacPs_Instance { *****************************************************************************/ #define XEmacPs_IntDisable(InstancePtr, Mask) \ XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_IDR_OFFSET, \ - ((Mask) & XEMACPS_IXR_ALL_MASK)); + XEMACPS_IDR_OFFSET, \ + ((Mask) & XEMACPS_IXR_ALL_MASK)); /****************************************************************************/ /** @@ -648,8 +662,8 @@ typedef struct XEmacPs_Instance { *****************************************************************************/ #define XEmacPs_IntQ1Enable(InstancePtr, Mask) \ XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_INTQ1_IER_OFFSET, \ - ((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK)); + XEMACPS_INTQ1_IER_OFFSET, \ + ((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK)); /****************************************************************************/ /** @@ -669,8 +683,8 @@ typedef struct XEmacPs_Instance { *****************************************************************************/ #define XEmacPs_IntQ1Disable(InstancePtr, Mask) \ XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_INTQ1_IDR_OFFSET, \ - ((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK)); + XEMACPS_INTQ1_IDR_OFFSET, \ + ((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK)); /****************************************************************************/ /** @@ -687,10 +701,10 @@ typedef struct XEmacPs_Instance { * *****************************************************************************/ #define XEmacPs_Transmit(InstancePtr) \ - XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_NWCTRL_OFFSET, \ - (XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_NWCTRL_OFFSET) | XEMACPS_NWCTRL_STARTTX_MASK)) + XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_NWCTRL_OFFSET, \ + (XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_NWCTRL_OFFSET) | XEMACPS_NWCTRL_STARTTX_MASK)) /****************************************************************************/ /** @@ -711,9 +725,9 @@ typedef struct XEmacPs_Instance { * *****************************************************************************/ #define XEmacPs_IsRxCsum(InstancePtr) \ - ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_NWCFG_OFFSET) & XEMACPS_NWCFG_RXCHKSUMEN_MASK) != 0U \ - ? TRUE : FALSE) + ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_NWCFG_OFFSET) & XEMACPS_NWCFG_RXCHKSUMEN_MASK) != 0U \ + ? TRUE : FALSE) /****************************************************************************/ /** @@ -734,9 +748,9 @@ typedef struct XEmacPs_Instance { * *****************************************************************************/ #define XEmacPs_IsTxCsum(InstancePtr) \ - ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_DMACR_OFFSET) & XEMACPS_DMACR_TCPCKSUM_MASK) != 0U \ - ? TRUE : FALSE) + ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_DMACR_OFFSET) & XEMACPS_DMACR_TCPCKSUM_MASK) != 0U \ + ? TRUE : FALSE) /************************** Function Prototypes *****************************/ @@ -761,10 +775,10 @@ typedef struct XEmacPs_Instance { * *****************************************************************************/ #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) |) + XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_RXWATERMARK_OFFSET, \ + (High & XEMACPS_RXWM_HIGH_MASK) | \ + ((Low << XEMACPS_RXWM_LOW_SHFT_MSK) & XEMACPS_RXWM_LOW_MASK) |) /****************************************************************************/ /** @@ -781,8 +795,8 @@ typedef struct XEmacPs_Instance { * *****************************************************************************/ #define XEmacPs_GetRXWatermark(InstancePtr) \ - XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XEMACPS_RXWATERMARK_OFFSET) + XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + XEMACPS_RXWATERMARK_OFFSET) /* * Initialization functions in xemacps.c */ @@ -797,7 +811,12 @@ void XEmacPs_SetQueuePtr(XEmacPs *InstancePtr, UINTPTR QPtr, u8 QueueNum, /* * Lookup configuration in xemacps_sinit.c */ + +#ifndef SDT XEmacPs_Config *XEmacPs_LookupConfig(u16 DeviceId); +#else +XEmacPs_Config *XEmacPs_LookupConfig(UINTPTR BaseAddress); +#endif /* * Interrupt-related functions in xemacps_intr.c @@ -823,7 +842,7 @@ void XEmacPs_ClearHash(XEmacPs *InstancePtr); void XEmacPs_GetHash(XEmacPs *InstancePtr, void *AddressPtr); void XEmacPs_SetMdioDivisor(XEmacPs *InstancePtr, - XEmacPs_MdcDiv Divisor); + XEmacPs_MdcDiv Divisor); void XEmacPs_SetOperatingSpeed(XEmacPs *InstancePtr, u16 Speed); u16 XEmacPs_GetOperatingSpeed(XEmacPs *InstancePtr); LONG XEmacPs_PhyRead(XEmacPs *InstancePtr, u32 PhyAddress, diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bd.h b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bd.h index aff79ff..4641553 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bd.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bd.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps_bd.h -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * This header provides operations to manage buffer descriptors in support @@ -45,6 +46,7 @@ * 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. + * 3.9 aj 22/03/24 Add mask for XEmaPs_BdGetBufAddr * ** @@ -239,11 +241,11 @@ typedef u32 XEmacPs_Bd[XEMACPS_BD_NUM_WORDS]; *****************************************************************************/ #if defined(__aarch64__) || defined(__arch64__) #define XEmacPs_BdGetBufAddr(BdPtr) \ - (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) | \ + ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) & XEMACPS_RXBUF_ADD_MASK) | \ (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_HI_OFFSET)) << 32U) #else #define XEmacPs_BdGetBufAddr(BdPtr) \ - (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET)) + (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) & XEMACPS_RXBUF_ADD_MASK) #endif /*****************************************************************************/ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.c b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.c index 5a355ff..a2d7c33 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps_bdring.c -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * This file implements buffer descriptor ring related functions. @@ -676,12 +677,13 @@ u32 XEmacPs_BdRingFromHwTx(XEmacPs_BdRing * RingPtr, u32 BdLimit, BdPartialCount = 0U; } + /* Move on to next BD in work group */ + CurBdPtr = XEmacPs_BdRingNext(RingPtr, CurBdPtr); + /* Reached the end of the work group */ if (CurBdPtr == RingPtr->HwTail) { break; } - /* Move on to next BD in work group */ - CurBdPtr = XEmacPs_BdRingNext(RingPtr, CurBdPtr); } /* Subtract off any partial packet BDs found */ @@ -822,13 +824,13 @@ u32 XEmacPs_BdRingFromHwRx(XEmacPs_BdRing * RingPtr, u32 BdLimit, BdPartialCount++; } + /* Move on to next BD in work group */ + CurBdPtr = XEmacPs_BdRingNext(RingPtr, CurBdPtr); + /* Reached the end of the work group */ if (CurBdPtr == RingPtr->HwTail) { break; } - - /* Move on to next BD in work group */ - CurBdPtr = XEmacPs_BdRingNext(RingPtr, CurBdPtr); } /* Subtract off any partial packet BDs found */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.h b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.h index f5653db..017669d 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_bdring.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps_bdring.h -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * The Xiline EmacPs Buffer Descriptor ring driver. This is part of EmacPs diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_control.c b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_control.c index 4c72f20..719ba78 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_control.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_control.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2009 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps_control.c -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * Functions in this file implement general purpose command and control related diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_g.c index 020c6f7..7bb25a4 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_g.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps_g.c -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * This file contains a configuration table that specifies the configuration of diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.c b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.c index fdf9bab..06df263 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps_hw.c -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * This file contains the implementation of the ethernet interface reset sequence diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.h index 59fe1ec..765411d 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_hw.h @@ -8,7 +8,7 @@ /** * * @file xemacps_hw.h -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * This header file contains identifiers and low-level driver functions (or diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_intr.c b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_intr.c index 2dbdb0b..c25e773 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_intr.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_intr.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps_intr.c -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * Functions in this file implement general purpose interrupt processing related @@ -228,7 +229,7 @@ void XEmacPs_IntrHandler(void *XEmacPsPtr) /* Transmit error conditions interrupt */ if (((RegISR & XEMACPS_IXR_TX_ERR_MASK) != 0x00000000U) && - (!(RegISR & XEMACPS_IXR_TXCOMPL_MASK) != 0x00000000U)) { + ((!(RegISR & XEMACPS_IXR_TXCOMPL_MASK)) != 0x00000000U)) { /* Clear TX status register */ RegSR = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress, XEMACPS_TXSR_OFFSET); diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_sinit.c index 8214a7d..89d3210 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/emacps/src/xemacps_sinit.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xemacps_sinit.c -* @addtogroup emacps_v3_16 +* @addtogroup emacps Overview * @{ * * This file contains lookup method by device ID when success, it returns @@ -27,7 +28,9 @@ /***************************** Include Files *********************************/ #include "xemacps.h" +#ifndef SDT #include "xparameters.h" +#endif /************************** Constant Definitions *****************************/ @@ -35,7 +38,11 @@ /**************************** Type Definitions *******************************/ /*************************** Variable Definitions *****************************/ +#ifdef SDT +extern XEmacPs_Config XEmacPs_ConfigTable[]; +#else extern XEmacPs_Config XEmacPs_ConfigTable[XPAR_XEMACPS_NUM_INSTANCES]; +#endif /***************** Macros (Inline Functions) Definitions *********************/ @@ -54,6 +61,22 @@ extern XEmacPs_Config XEmacPs_ConfigTable[XPAR_XEMACPS_NUM_INSTANCES]; * device ID, or NULL if no match is found. * ******************************************************************************/ +#ifdef SDT +XEmacPs_Config *XEmacPs_LookupConfig(UINTPTR BaseAddress) +{ + XEmacPs_Config *CfgPtr = NULL; + u32 Index; + /* Checks all the instances */ + for (Index = (u32)0x0; XEmacPs_ConfigTable[Index].Name != NULL; Index++) { + if ((XEmacPs_ConfigTable[Index].BaseAddress == BaseAddress) || + !BaseAddress) { + CfgPtr = &XEmacPs_ConfigTable[Index]; + break; + } + } + return (XEmacPs_Config *)(CfgPtr); +} +#else XEmacPs_Config *XEmacPs_LookupConfig(u16 DeviceId) { XEmacPs_Config *CfgPtr = NULL; @@ -68,4 +91,5 @@ XEmacPs_Config *XEmacPs_LookupConfig(u16 DeviceId) return (XEmacPs_Config *)(CfgPtr); } +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.c b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.c index 460bb2b..41ffbba 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/gpiops/src/xgpiops.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -35,6 +35,9 @@ * as Pointer to const,Casting operation to a pointer, * Literal value requires a U suffix. * 3.5 sne 03/13/19 Added Versal support. +* 3.12 gm 07/11/23 Added SDT support. +* 3.13 gm 03/15/24 Added multi-core interrupt support. +* *
* MODIFICATION HISTORY: @@ -164,7 +164,16 @@ * detecting targeted cores for specific interrupt id. * Also, DoDistributorInit has been modified to move CPU * interface specific register writes to XScuGic_CfgInitialize. -* +* 5.2 ml 03/02/23 Add description to fix Doxygen warnings. +* 5.2 mus 04/26/23 Update DoDistributorInit to initialize priority of SGI and +* PPI interrupts. It was missing for GICv3 based controllers. +* 5.2 mus 07/27/23 Removed dependency on XPAR_CPU_ID by changic logic to get +* CPU ID, it will be read from affinity register of processor +* who is caling SCUGIC driver API's. +* 5.2 ml 09/07/23 Typecasting with u32 to fix MISRA-C_RULE_10.3 violation. +* 5.2 ml 09/07/23 Compared with zero to fix MISRA-C_RULE_14.4 violation. +* 5.2 ml 09/07/23 Added comments to fix HIS COMF violations. +* 5.2 ml 09/07/23 Include xplatform_info.h for all processors. ** ******************************************************************************/ @@ -173,11 +182,13 @@ #include "xil_types.h" #include "xil_assert.h" #include "xscugic.h" -#if defined (VERSAL_NET) + #include "xplatform_info.h" -#endif + /************************** Constant Definitions *****************************/ +#define DEFAULT_PRIORITY 0xa0a0a0a0U /**< Default value for priority_level + register */ /**************************** Type Definitions *******************************/ @@ -185,7 +196,7 @@ /***************** Macros (Inline Functions) Definitions *********************/ /************************** Variable Definitions *****************************/ -static u32 CpuId = XPAR_CPU_ID; /**< CPU Core identifier */ +static u32 CpuId; /**< CPU Core identifier */ /************************** Function Prototypes ******************************/ @@ -201,16 +212,15 @@ static void StubHandler(void *CallBackRef); * - All interrupt sources are disabled * - Enable the distributor * -* @param InstancePtr is a pointer to the XScuGic instance. +* @param InstancePtr Pointer to the XScuGic instance. * * @return None * -* @note None. * ******************************************************************************/ static void DoDistributorInit(const XScuGic *InstancePtr) { - u32 Int_Id; + u32 Int_Id, Offset = 0; #if defined (GICv3) u32 Temp; @@ -239,20 +249,22 @@ static void DoDistributorInit(const XScuGic *InstancePtr) * Only write to the SPI interrupts, so start at 32 */ for (Int_Id = 32U; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; - Int_Id = Int_Id+16U) { + Int_Id = Int_Id + 16U) { /* * Each INT_ID uses two bits, or 16 INT_ID per register * Set them all to be level sensitive, active HIGH. */ XScuGic_DistWriteReg(InstancePtr, - XSCUGIC_INT_CFG_OFFSET_CALC(Int_Id), - 0U); + XSCUGIC_INT_CFG_OFFSET_CALC(Int_Id), + 0U); } +#if defined (GICv3) + Offset = 32U; +#endif -#define DEFAULT_PRIORITY 0xa0a0a0a0U - for (Int_Id = 0U; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; - Int_Id = Int_Id+4U) { + for (Int_Id = Offset; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; + Int_Id = Int_Id + 4U) { /* * 2. The priority using int the priority_level register * The priority_level and spi_target registers use one byte per @@ -260,32 +272,45 @@ static void DoDistributorInit(const XScuGic *InstancePtr) * Write a default value that can be changed elsewhere. */ XScuGic_DistWriteReg(InstancePtr, - XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id), - DEFAULT_PRIORITY); + XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id), + DEFAULT_PRIORITY); } #if defined (GICv3) - for (Int_Id = 0U; Int_Id
* MODIFICATION HISTORY: @@ -190,12 +144,14 @@ * executed, redistributor address will be stored in newly * added member of XScuGic data structure "RedistBaseAddr". * It fixes CR#1150432. +* 5.2 ml 03/02/23 Add description to fix Doxygen warnings. +* 5.2 adk 04/14/23 Added support for system device-tree flow. ** ******************************************************************************/ -#ifndef XSCUGIC_H /* prevent circular inclusions */ -#define XSCUGIC_H /* by using protection macros */ +#ifndef XSCUGIC_H /**< prevent circular inclusions */ +#define XSCUGIC_H /**< by using protection macros */ #ifdef __cplusplus extern "C" { @@ -212,13 +168,23 @@ extern "C" { /************************** Constant Definitions *****************************/ +/** + * @name EFUSE status Register information + * EFUSE Status Register + * @{ + */ #define EFUSE_STATUS_OFFSET 0x10 #define EFUSE_STATUS_CPU_MASK 0x80 #if !defined (ARMR5) && !defined (__aarch64__) && !defined (ARMA53_32) -#define ARMA9 +#define ARMA9 /**< ARMA9 macro to identify cortexA9 */ #endif +/** + * @name GICD_CTLR Register information + * GICD_CTLR Status Register + * @{ + */ #define XSCUGIC500_DCTLR_ARE_NS_ENABLE 0x20 #define XSCUGIC500_DCTLR_ARE_S_ENABLE 0x10 @@ -245,8 +211,12 @@ extern "C" { */ typedef struct { - Xil_InterruptHandler Handler; - void *CallBackRef; + Xil_InterruptHandler Handler; /**< Interrupt Handler */ + void *CallBackRef; /**< CallBackRef is the callback reference passed in + by the upper layer when setting the Interrupt + handler for specific interrupt ID, and it will + passed back to Interrupt handler when it is + invoked. */ } XScuGic_VectorTableEntry; /** @@ -254,9 +224,15 @@ typedef struct */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ u32 CpuBaseAddress; /**< CPU Interface Register base address */ u32 DistBaseAddress; /**< Distributor Register base address */ +#else + char *Name; /**< Compatible string */ + u32 DistBaseAddress; /**< Distributor Register base address */ + u32 CpuBaseAddress; /**< CPU Interface Register base address */ +#endif XScuGic_VectorTableEntry HandlerTable[XSCUGIC_MAX_NUM_INTR_INPUTS];/**< Vector table of interrupt handlers */ } XScuGic_Config; @@ -285,17 +261,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Write the given CPU Interface register +* Writes 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be written. +* @param Data 32-bit value to write to the register. * * @return None. * -* @note -* C-style signature: -* void XScuGic_CPUWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) +* @note C-style signature: +* void XScuGic_CPUWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) * *****************************************************************************/ #define XScuGic_CPUWriteReg(InstancePtr, RegOffset, Data) \ @@ -305,16 +280,15 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Read the given CPU Interface register +* Reads 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Rregister offset to be read. * -* @return The 32-bit value of the register +* @return 32-bit value of the register * -* @note -* C-style signature: -* u32 XScuGic_CPUReadReg(XScuGic *InstancePtr, u32 RegOffset) +* @note C-style signature: +* u32 XScuGic_CPUReadReg(XScuGic *InstancePtr, u32 RegOffset) * *****************************************************************************/ #define XScuGic_CPUReadReg(InstancePtr, RegOffset) \ @@ -323,17 +297,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Write the given Distributor Interface register +* Writes 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be written. +* @param Data 32-bit value to write to the register. * * @return None. * -* @note -* C-style signature: -* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) +* @note C-style signature: +* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) * *****************************************************************************/ #define XScuGic_DistWriteReg(InstancePtr, RegOffset, Data) \ @@ -343,16 +316,15 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Read the given Distributor Interface register +* Reads 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be read. * -* @return The 32-bit value of the register +* @return The 32-bit value of the register. * -* @note -* C-style signature: -* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) +* @note C-style signature: +* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) * *****************************************************************************/ #define XScuGic_DistReadReg(InstancePtr, RegOffset) \ @@ -362,17 +334,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Write the given ReDistributor Interface register +* Writes 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be written. +* @param Data 32-bit value to write to the register. * * @return None. * -* @note -* C-style signature: -* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) +* @note C-style signature: +* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) * *****************************************************************************/ #define XScuGic_ReDistWriteReg(InstancePtr, RegOffset, Data) \ @@ -381,16 +352,15 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Read the given ReDistributor Interface register +* Reads 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be read. * -* @return The 32-bit value of the register +* @return 32-bit value of the register. * -* @note -* C-style signature: -* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) +* @note C-style signature: +* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) * *****************************************************************************/ #define XScuGic_ReDistReadReg(InstancePtr, RegOffset) \ @@ -399,17 +369,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Write the given ReDistributor SGI PPI Interface register +* Writes 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be written. +* @param Data 32-bit value to write to the register. * * @return None. * -* @note -* C-style signature: -* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) +* @note C-style signature: +* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data) * *****************************************************************************/ #define XScuGic_ReDistSGIPPIWriteReg(InstancePtr, RegOffset, Data) \ @@ -419,16 +388,15 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** * -* Read the given ReDistributor SGI PPI Interface register +* Reads 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param RegOffset Register offset to be read. * * @return The 32-bit value of the register * -* @note -* C-style signature: -* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) +* @note C-style signature: +* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset) * *****************************************************************************/ #define XScuGic_ReDistSGIPPIReadReg(InstancePtr, RegOffset) \ @@ -443,9 +411,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #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_IAR1_EL1 "p15, 0, %0, c12, c12, 0" #define XREG_ICC_EOIR0_EL1 "p15, 0, %0, c12, c8, 1" +#define XREG_ICC_EOIR1_EL1 "p15, 0, %0, c12, c12, 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_BPR1_EL1 "p15, 0, %0, c12, c12, 3" #define XREG_ICC_RPR_EL1 "p15, 0, %0, c12, c11, 3" #else #define XREG_ICC_SRE_EL1 "S3_0_C12_C12_5" @@ -463,13 +434,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function enables system register interface for GIC CPU Interface +* Enables system register interface for GIC CPU Interface. * -* @param value to be written +* @param value Value to be written. * * @return None. * -* @note None. * *****************************************************************************/ #if defined (__aarch64__) @@ -480,13 +450,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function enables Grou0 interrupts +* Enable Grou0 interrupts. * * @param None. * * @return None. * -* @note None. * *****************************************************************************/ #if defined(ARMR52) @@ -502,7 +471,6 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ * * @return None. * -* @note None. * *****************************************************************************/ #if defined (ARMR52) @@ -518,13 +486,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function writes to ICC_SGI0R_EL1 +* Writes to ICC_SGI0R_EL1. * -* @param value to be written +* @param value Value to be written. * * @return None. * -* @note None. * *****************************************************************************/ #if defined(ARMR52) @@ -535,13 +502,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** -* This function writes to ICC_SGI1R_EL1 +* Writes to ICC_SGI1R_EL1. * -* @param value to be written +* @param value Value to be written. * * @return None. * -* @note None. * *****************************************************************************/ #if defined(ARMR52) @@ -552,13 +518,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ /****************************************************************************/ /** -* This function reads ICC_SGI1R_EL1 register +* Reads ICC_SGI1R_EL1 register. * * @param None * * @return Value of ICC_SGI1R_EL1 register * -* @note None. * *****************************************************************************/ #if defined (ARMR52) @@ -568,13 +533,12 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function sets interrupt priority filter +* Sets interrupt priority filter. * * @param None. * * @return None. * -* @note None. * *****************************************************************************/ #if defined (ARMR52) @@ -584,17 +548,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function returns interrupt id of highest priority pending interrupt +* 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) +#define XScuGic_get_IntID() mfcp(XREG_ICC_IAR1_EL1) #elif EL3 #define XScuGic_get_IntID() mfcpnotoken(XREG_ICC_IAR0_EL1) #else @@ -602,17 +565,16 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ #endif /****************************************************************************/ /** -* This function acks the interrupt +* Acknowledges the interrupt. * * @param None. * * @return None. * -* @note None. * *****************************************************************************/ #if defined(ARMR52) -#define XScuGic_ack_Int(val) mtcp(XREG_ICC_EOIR0_EL1,val) +#define XScuGic_ack_Int(val) mtcp(XREG_ICC_EOIR1_EL1,val) #elif EL3 #define XScuGic_ack_Int(val) mtcpnotoken(XREG_ICC_EOIR0_EL1,val) #else @@ -627,7 +589,6 @@ extern XScuGic_Config XScuGic_ConfigTable[]; /**< Config table */ * * @return None. * -* @note None. * *****************************************************************************/ #define XScuGic_Get_Rdist_Int_Trigger_Index(IntrId) ((Int_Id%16) * 2U) @@ -660,12 +621,23 @@ void XScuGic_UnmapAllInterruptsFromCpu(XScuGic *InstancePtr, u8 Cpu_Identifier); void XScuGic_Stop(XScuGic *InstancePtr); void XScuGic_SetCpuID(u32 CpuCoreId); u32 XScuGic_GetCpuID(void); +#ifndef SDT u8 XScuGic_IsInitialized(u32 DeviceId); +#else +u8 XScuGic_IsInitialized(u32 BaseAddress); +#endif +#ifndef SDT /* - * Initialization functions in xscugic_sinit.c + * Lookup configuration by using DeviceId */ XScuGic_Config *XScuGic_LookupConfig(u16 DeviceId); +/* + * Lookup configuration by using BaseAddress + */ XScuGic_Config *XScuGic_LookupConfigBaseAddr(UINTPTR BaseAddress); +#else +XScuGic_Config *XScuGic_LookupConfig(UINTPTR BaseAddr); +#endif /* * Interrupt functions in xscugic_intr.c @@ -685,5 +657,6 @@ void XScuGic_MarkCoreAwake(XScuGic *InstancePtr); } #endif -#endif /* end of protection macro */ +#endif +/* end of protection macro */ /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_g.c index 7b5f3ae..d5be5c9 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_g.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,10 +8,10 @@ /** * * @file xscugic_g.c -* @addtogroup scugic Overview +* @addtogroup scugic_api SCUGIC APIs * @{ * -* This file contains a configuration table that specifies the configuration of +* The xscugic_g.c file contains a configuration table that specifies the configuration of * interrupt controller devices in the system. * *
diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_hw.c b/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_hw.c index 88c38c7..45aebfc 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_hw.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_hw.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,14 +8,14 @@ /** * * @file xscugic_hw.c -* @addtogroup scugic Overview +* @addtogroup scugic_api SCUGIC APIs * @{ * -* This file contains low-level driver functions that can be used to access the -* device. The user should refer to the hardware device specification for more +* The xscugic_hw.c file contains low-level driver functions that can be used to access the +* device. The user should refer to the hardware device specification for more * details of the device operation. * These routines are used when the user does not want to create an instance of -* XScuGic structure but still wants to use the ScuGic device. Hence the +* XScuGic structure but still wants to use the ScuGic device. Hence, the * routines provided here take device id or scugic base address as arguments. * Separate static versions of DistInit and CPUInit are provided to implement * the low level driver routines. @@ -93,6 +93,10 @@ * 5.1 mus 03/07/23 Fix XScuGic_InterruptMapFromCpuByDistAddr and * XScuGic_InterruptUnmapFromCpuByDistAddr for GICv3. * +* 5.2 ml 03/02/23 Remove few comments to fix doxygen warnings. +* 5.2 mus 07/19/23 Updated XScuGic_DeviceInterruptHandler to support SDT +* flow. +* 5.2 ml 09/07/23 Added comments to fix HIS COMF violations. ** ******************************************************************************/ @@ -103,12 +107,17 @@ #include "xil_types.h" #include "xil_assert.h" #include "xscugic.h" +#ifndef SDT #include "xparameters.h" #if defined (VERSAL_NET) #include "xplatform_info.h" #endif +#endif + /************************** Constant Definitions *****************************/ +#define DEFAULT_PRIORITY 0xa0a0a0a0U /**< Default value for priority_level + register */ /**************************** Type Definitions *******************************/ /***************** Macros (Inline Functions) Definitions *********************/ @@ -134,12 +143,9 @@ static XScuGic_Config *LookupConfigByBaseAddress(u32 CpuBaseAddress); * - All interrupt sources are disabled * - Enable the distributor * -* @param InstancePtr is a pointer to the XScuGic instance. -* @param CpuID is the Cpu ID to be initialized. * * @return None * -* @note None. * ******************************************************************************/ static void DistInit(const XScuGic_Config *Config) @@ -147,7 +153,7 @@ static void DistInit(const XScuGic_Config *Config) u32 Int_Id; #if (defined (USE_AMP) && (USE_AMP==1)) - #warning "Building GIC for AMP" +#warning "Building GIC for AMP" /* * The distributor should not be initialized by FreeRTOS in the case of @@ -163,14 +169,14 @@ static void DistInit(const XScuGic_Config *Config) UINTPTR RedistBaseAddr; RedistBaseAddr = XScuGic_GetRedistBaseAddr(); - #if defined (GIC600) - XScuGic_WriteReg(RedistBaseAddr,XSCUGIC_RDIST_PWRR_OFFSET, - (XScuGic_ReadReg(RedistBaseAddr, XSCUGIC_RDIST_PWRR_OFFSET) & - (~XSCUGIC_RDIST_PWRR_RDPD_MASK))); - #endif - Waker_State = XScuGic_ReadReg(RedistBaseAddr,XSCUGIC_RDIST_WAKER_OFFSET); - XScuGic_WriteReg(RedistBaseAddr,XSCUGIC_RDIST_WAKER_OFFSET, - Waker_State & (~ XSCUGIC_RDIST_WAKER_LOW_POWER_STATE_MASK)); +#if defined (GIC600) + XScuGic_WriteReg(RedistBaseAddr, XSCUGIC_RDIST_PWRR_OFFSET, + (XScuGic_ReadReg(RedistBaseAddr, XSCUGIC_RDIST_PWRR_OFFSET) & + (~XSCUGIC_RDIST_PWRR_RDPD_MASK))); +#endif + Waker_State = XScuGic_ReadReg(RedistBaseAddr, XSCUGIC_RDIST_WAKER_OFFSET); + XScuGic_WriteReg(RedistBaseAddr, XSCUGIC_RDIST_WAKER_OFFSET, + Waker_State & (~ XSCUGIC_RDIST_WAKER_LOW_POWER_STATE_MASK)); /* Enable system reg interface through ICC_SRE_EL1 */ #if EL3 XScuGic_Enable_SystemReg_CPU_Interface_EL3(); @@ -202,19 +208,17 @@ static void DistInit(const XScuGic_Config *Config) * Only write to the SPI interrupts, so start at 32 */ for (Int_Id = 32U; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; - Int_Id = Int_Id+16U) { + Int_Id = Int_Id + 16U) { /* * Each INT_ID uses two bits, or 16 INT_ID per register * Set them all to be level sensitive, active HIGH. */ XScuGic_WriteReg(Config->DistBaseAddress, - XSCUGIC_INT_CFG_OFFSET_CALC(Int_Id), 0U); + XSCUGIC_INT_CFG_OFFSET_CALC(Int_Id), 0U); } - -#define DEFAULT_PRIORITY 0xa0a0a0a0U for (Int_Id = 0U; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; - Int_Id = Int_Id+4U) { + Int_Id = Int_Id + 4U) { /* * 2. The priority using int the priority_level register * The priority_level and spi_target registers use one byte per @@ -222,34 +226,34 @@ static void DistInit(const XScuGic_Config *Config) * Write a default value that can be changed elsewhere. */ XScuGic_WriteReg(Config->DistBaseAddress, - XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id), - DEFAULT_PRIORITY); + XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id), + DEFAULT_PRIORITY); } #if defined (GICv3) - for (Int_Id = 0U; Int_Id
* MODIFICATION HISTORY: * @@ -21,7 +23,8 @@ * 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. -* +* 5.2 ml 03/02/23 Add description to fix Doxygen warnings. +* 5.2 ml 09/07/23 Added comments to fix HIS COMF violations. ** ******************************************************************************/ @@ -34,7 +37,7 @@ /************************** Constant Definitions *****************************/ -#define XSCUGIC_PCELL_ID 0xB105F00DU +#define XSCUGIC_PCELL_ID 0xB105F00DU /**< PCELL ID value */ /**************************** Type Definitions *******************************/ @@ -49,17 +52,16 @@ /*****************************************************************************/ /** * -* Run a self-test on the driver/device. This test reads the ID registers and +* Runs 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. +* @param InstancePtr 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) @@ -69,7 +71,7 @@ s32 XScuGic_SelfTest(XScuGic *InstancePtr) s32 Status; /* - * Assert the arguments + * Validate the input arguments */ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); @@ -79,8 +81,8 @@ s32 XScuGic_SelfTest(XScuGic *InstancePtr) */ for (Index = 0U; Index <= 3U; Index++) { RegValue1 |= XScuGic_DistReadReg(InstancePtr, - ((u32)XSCUGIC_PCELLID_OFFSET + (Index * 4U))) << - (Index * 8U); + ((u32)XSCUGIC_PCELLID_OFFSET + (Index * 4U))) << + (Index * 8U); } if (XSCUGIC_PCELL_ID != RegValue1) { @@ -88,6 +90,7 @@ s32 XScuGic_SelfTest(XScuGic *InstancePtr) } else { Status = XST_SUCCESS; } + /* Return statement */ return Status; } /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_sinit.c index 50101cf..1f7ce42 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scugic/src/xscugic_sinit.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,11 +8,11 @@ /** * * @file xscugic_sinit.c -* @addtogroup scugic Overview +* @addtogroup scugic_api SCUGIC APIs * @{ * -* Contains static init functions for the XScuGic driver for the Interrupt -* Controller. See xscugic.h for a detailed description of the driver. +* The xscugic_sinit.c contains static init functions for the XScuGic driver for the Interrupt +* Controller. * *
* MODIFICATION HISTORY: @@ -25,7 +25,8 @@ * reported by checkpatch. It fixes CR#1006344. * 4.6 sk 08/05/21 Remove XScuGic_Config variable definition to fix * misrac violation. -* +* 5.2 ml 03/03/23 Add description to fix Doxygen warnings. +* 5.2 ml 09/07/23 Added comments to fix HIS COMF violations. ** ******************************************************************************/ @@ -34,8 +35,10 @@ #include "xil_types.h" #include "xil_assert.h" -#include "xparameters.h" #include "xscugic.h" +#ifndef SDT +#include "xparameters.h" +#endif /************************** Constant Definitions *****************************/ @@ -56,40 +59,82 @@ * 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. +* @param DeviceId 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. +* specified device, or NULL if the device is not found. * -* @note None. * ******************************************************************************/ +#ifndef SDT XScuGic_Config *XScuGic_LookupConfig(u16 DeviceId) { XScuGic_Config *CfgPtr = NULL; u32 Index; + /* + * checks the device Id in configuration table + * whether it matches or not + */ for (Index = 0U; Index < (u32)XPAR_SCUGIC_NUM_INSTANCES; Index++) { if (XScuGic_ConfigTable[Index].DeviceId == DeviceId) { CfgPtr = &XScuGic_ConfigTable[Index]; break; } } - + /* Return statement */ return (XScuGic_Config *)CfgPtr; } +/*****************************************************************************/ +/** +* +* Looks up the device configuration based on the BaseAddress. The return value +* will refer to an entry in the device configuration table defined in the +* xscugic_g.c file. +* +* @param BaseAddress Base address of the device. +* +* @return A pointer to the XScuGic configuration structure for the +* specified device, or NULL if the device is not found. +* +* +******************************************************************************/ XScuGic_Config *XScuGic_LookupConfigBaseAddr(UINTPTR BaseAddress) { - XScuGic_Config *CfgPtr = NULL; - u32 Index; + 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; + /* + * checks the BaseAddress in configuration table + * whether it matches or not + */ + for (Index = 0U; Index < (u32)XPAR_SCUGIC_NUM_INSTANCES; Index++) { + if (XScuGic_ConfigTable[Index].DistBaseAddress == BaseAddress) { + CfgPtr = &XScuGic_ConfigTable[Index]; + break; + } + } + /* Return statement */ + return (XScuGic_Config *)CfgPtr; } +#else +XScuGic_Config *XScuGic_LookupConfig(UINTPTR BaseAddress) +{ + XScuGic_Config *CfgPtr = NULL; + u32 Index; + + /* checks the BaseAddress in configuration table + * whether it matches or not + */ + for (Index = 0U; XScuGic_ConfigTable[Index].Name != NULL; Index++) { + if ((XScuGic_ConfigTable[Index].DistBaseAddress == BaseAddress) || !BaseAddress) { + CfgPtr = &XScuGic_ConfigTable[Index]; + break; + } + } + /* Return statement */ + return (XScuGic_Config *)CfgPtr; +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.c b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.c index 8cdf4c3..96584cb 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscutimer.c -* @addtogroup scutimer_v2_4 +* @addtogroup scutimer Overview * @{ * * Contains the implementation of interface functions of the SCU Timer driver. @@ -20,6 +21,7 @@ * ----- --- -------- --------------------------------------------- * 1.00a nm 03/10/10 First release * 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance. +* 2.5 dp 07/11/23 Add Support for system device tree flow * * ******************************************************************************/ @@ -58,7 +60,7 @@ * ******************************************************************************/ s32 XScuTimer_CfgInitialize(XScuTimer *InstancePtr, - XScuTimer_Config *ConfigPtr, u32 EffectiveAddress) + XScuTimer_Config *ConfigPtr, u32 EffectiveAddress) { s32 Status; Xil_AssertNonvoid(InstancePtr != NULL); @@ -74,7 +76,9 @@ s32 XScuTimer_CfgInitialize(XScuTimer *InstancePtr, /* * Copy configuration into the instance structure. */ +#ifndef SDT InstancePtr->Config.DeviceId = ConfigPtr->DeviceId; +#endif /* * Save the base address pointer such that the registers of the block @@ -93,9 +97,8 @@ s32 XScuTimer_CfgInitialize(XScuTimer *InstancePtr, InstancePtr->Config.IntrParent = ConfigPtr->IntrParent; #endif - Status =(s32)XST_SUCCESS; - } - else { + Status = (s32)XST_SUCCESS; + } else { Status = (s32)XST_DEVICE_IS_STARTED; } return Status; @@ -124,7 +127,7 @@ void XScuTimer_Start(XScuTimer *InstancePtr) * Read the contents of the Control register. */ Register = XScuTimer_ReadReg(InstancePtr->Config.BaseAddr, - XSCUTIMER_CONTROL_OFFSET); + XSCUTIMER_CONTROL_OFFSET); /* * Set the 'timer enable' bit in the register. @@ -135,7 +138,7 @@ void XScuTimer_Start(XScuTimer *InstancePtr) * Update the Control register with the new value. */ XScuTimer_WriteReg(InstancePtr->Config.BaseAddr, - XSCUTIMER_CONTROL_OFFSET, Register); + XSCUTIMER_CONTROL_OFFSET, Register); /* * Indicate that the device is started. @@ -166,7 +169,7 @@ void XScuTimer_Stop(XScuTimer *InstancePtr) * Read the contents of the Control register. */ Register = XScuTimer_ReadReg(InstancePtr->Config.BaseAddr, - XSCUTIMER_CONTROL_OFFSET); + XSCUTIMER_CONTROL_OFFSET); /* * Clear the 'timer enable' bit in the register. @@ -177,7 +180,7 @@ void XScuTimer_Stop(XScuTimer *InstancePtr) * Update the Control register with the new value. */ XScuTimer_WriteReg(InstancePtr->Config.BaseAddr, - XSCUTIMER_CONTROL_OFFSET, Register); + XSCUTIMER_CONTROL_OFFSET, Register); /* * Indicate that the device is stopped. @@ -211,7 +214,7 @@ void XScuTimer_SetPrescaler(XScuTimer *InstancePtr, u8 PrescalerValue) * Read the Timer control register. */ ControlReg = XScuTimer_ReadReg(InstancePtr->Config.BaseAddr, - XSCUTIMER_CONTROL_OFFSET); + XSCUTIMER_CONTROL_OFFSET); /* * Clear all of the prescaler control bits in the register. @@ -227,7 +230,7 @@ void XScuTimer_SetPrescaler(XScuTimer *InstancePtr, u8 PrescalerValue) * Write the register with the new values. */ XScuTimer_WriteReg(InstancePtr->Config.BaseAddr, - XSCUTIMER_CONTROL_OFFSET, ControlReg); + XSCUTIMER_CONTROL_OFFSET, ControlReg); } /*****************************************************************************/ @@ -256,7 +259,7 @@ u8 XScuTimer_GetPrescaler(XScuTimer *InstancePtr) * Read the Timer control register. */ ControlReg = XScuTimer_ReadReg(InstancePtr->Config.BaseAddr, - XSCUTIMER_CONTROL_OFFSET); + XSCUTIMER_CONTROL_OFFSET); ControlReg &= XSCUTIMER_CONTROL_PRESCALER_MASK; return (u8)(ControlReg >> XSCUTIMER_CONTROL_PRESCALER_SHIFT); diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.h b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.h index bdce1c6..008b900 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscutimer.h -* @addtogroup scutimer_v2_4 +* @addtogroup scutimer Overview * @{ * @details * @@ -82,6 +83,7 @@ * 2.3 mus 08/31/20 Updated makefile to support parallel make and * incremental builds, it would help to reduce compilation * time. +* 2.5 dp 07/11/23 Add support for system device tree flow * * ******************************************************************************/ @@ -106,7 +108,11 @@ extern "C" { * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddr; /**< Base address of the device */ #ifdef XIL_INTERRUPT u32 IntrId; @@ -145,9 +151,9 @@ typedef struct { ******************************************************************************/ #define XScuTimer_IsExpired(InstancePtr) \ ((XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_ISR_OFFSET) & \ - XSCUTIMER_ISR_EVENT_FLAG_MASK) == \ - XSCUTIMER_ISR_EVENT_FLAG_MASK) + XSCUTIMER_ISR_OFFSET) & \ + XSCUTIMER_ISR_EVENT_FLAG_MASK) == \ + XSCUTIMER_ISR_EVENT_FLAG_MASK) /****************************************************************************/ /** @@ -165,8 +171,8 @@ typedef struct { ******************************************************************************/ #define XScuTimer_RestartTimer(InstancePtr) \ XScuTimer_LoadTimer((InstancePtr), \ - XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_LOAD_OFFSET)) + XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ + XSCUTIMER_LOAD_OFFSET)) /****************************************************************************/ /** @@ -186,7 +192,7 @@ typedef struct { ******************************************************************************/ #define XScuTimer_LoadTimer(InstancePtr, Value) \ XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_LOAD_OFFSET, (Value)) + XSCUTIMER_LOAD_OFFSET, (Value)) /****************************************************************************/ /** @@ -204,7 +210,7 @@ typedef struct { ******************************************************************************/ #define XScuTimer_GetCounterValue(InstancePtr) \ XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_COUNTER_OFFSET) + XSCUTIMER_COUNTER_OFFSET) /****************************************************************************/ /** @@ -221,10 +227,10 @@ typedef struct { ******************************************************************************/ #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)) + XSCUTIMER_CONTROL_OFFSET, \ + (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ + XSCUTIMER_CONTROL_OFFSET) | \ + XSCUTIMER_CONTROL_AUTO_RELOAD_MASK)) /****************************************************************************/ /** @@ -241,10 +247,10 @@ typedef struct { ******************************************************************************/ #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))) + XSCUTIMER_CONTROL_OFFSET, \ + (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ + XSCUTIMER_CONTROL_OFFSET) & \ + ~(XSCUTIMER_CONTROL_AUTO_RELOAD_MASK))) /****************************************************************************/ /** @@ -261,10 +267,10 @@ typedef struct { ******************************************************************************/ #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)) + XSCUTIMER_CONTROL_OFFSET, \ + (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ + XSCUTIMER_CONTROL_OFFSET) | \ + XSCUTIMER_CONTROL_IRQ_ENABLE_MASK)) /****************************************************************************/ /** @@ -281,10 +287,10 @@ typedef struct { ******************************************************************************/ #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))) + XSCUTIMER_CONTROL_OFFSET, \ + (XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ + XSCUTIMER_CONTROL_OFFSET) & \ + ~(XSCUTIMER_CONTROL_IRQ_ENABLE_MASK))) /*****************************************************************************/ /** @@ -301,7 +307,7 @@ typedef struct { ******************************************************************************/ #define XScuTimer_GetInterruptStatus(InstancePtr) \ XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_ISR_OFFSET) + XSCUTIMER_ISR_OFFSET) /*****************************************************************************/ /** @@ -318,14 +324,18 @@ typedef struct { ******************************************************************************/ #define XScuTimer_ClearInterruptStatus(InstancePtr) \ XScuTimer_WriteReg((InstancePtr)->Config.BaseAddr, \ - XSCUTIMER_ISR_OFFSET, XSCUTIMER_ISR_EVENT_FLAG_MASK) + XSCUTIMER_ISR_OFFSET, XSCUTIMER_ISR_EVENT_FLAG_MASK) /************************** Function Prototypes ******************************/ /* * Lookup configuration in xscutimer_sinit.c */ +#ifndef SDT XScuTimer_Config *XScuTimer_LookupConfig(u16 DeviceId); +#else +XScuTimer_Config *XScuTimer_LookupConfig(UINTPTR BaseAddr); +#endif /* * Selftest function in xscutimer_selftest.c diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_g.c index 75461ce..0ad6dc4 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_g.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscutimer_g.c -* @addtogroup scutimer_v2_4 +* @addtogroup scutimer Overview * @{ * * This file contains a table that specifies the configuration of the SCU diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_hw.h index c34acd1..8eb1875 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscutimer_hw.h -* @addtogroup scutimer_v2_4 +* @addtogroup scutimer Overview * @{ * * This file contains the hardware interface to the Timer. diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_selftest.c b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_selftest.c index 609c217..3d6f9cf 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_selftest.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_selftest.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscutimer_selftest.c -* @addtogroup scutimer_v2_4 +* @addtogroup scutimer Overview * @{ * * Contains diagnostic self-test functions for the XScuTimer driver. @@ -74,10 +75,10 @@ s32 XScuTimer_SelfTest(XScuTimer *InstancePtr) * Save the contents of the Control Register and stop the timer. */ CtrlOrig = XScuTimer_ReadReg(InstancePtr->Config.BaseAddr, - XSCUTIMER_CONTROL_OFFSET); + XSCUTIMER_CONTROL_OFFSET); Register = CtrlOrig & (u32)(~XSCUTIMER_CONTROL_ENABLE_MASK); XScuTimer_WriteReg(InstancePtr->Config.BaseAddr, - XSCUTIMER_CONTROL_OFFSET, Register); + XSCUTIMER_CONTROL_OFFSET, Register); /* * Save the contents of the Load Register. @@ -85,17 +86,17 @@ s32 XScuTimer_SelfTest(XScuTimer *InstancePtr) * compare it with the written value. */ LoadOrig = XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, - XSCUTIMER_LOAD_OFFSET); + XSCUTIMER_LOAD_OFFSET); XScuTimer_LoadTimer(InstancePtr, XSCUTIMER_SELFTEST_VALUE); Register = XScuTimer_ReadReg((InstancePtr)->Config.BaseAddr, - XSCUTIMER_LOAD_OFFSET); + 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); + XSCUTIMER_CONTROL_OFFSET, CtrlOrig); /* * Return a Failure if the contents of the Load Register do not @@ -103,8 +104,7 @@ s32 XScuTimer_SelfTest(XScuTimer *InstancePtr) */ if (Register != XSCUTIMER_SELFTEST_VALUE) { Status = (s32)XST_FAILURE; - } - else { + } else { Status = (s32)XST_SUCCESS; } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_sinit.c index f68200e..a5335ee 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scutimer/src/xscutimer_sinit.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscutimer_sinit.c -* @addtogroup scutimer_v2_4 +* @addtogroup scutimer Overview * @{ * * This file contains method for static initialization (compile-time) of the @@ -20,6 +21,7 @@ * ----- --- -------- --------------------------------------------- * 1.00a nm 03/10/10 First release * 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance. +* 2.5 dp 07/11/23 Add Support for system device tree flow * * ******************************************************************************/ @@ -27,7 +29,9 @@ /***************************** Include Files *********************************/ #include "xscutimer.h" +#ifndef SDT #include "xparameters.h" +#endif /************************** Constant Definitions *****************************/ @@ -36,7 +40,11 @@ /***************** Macros (Inline Functions) Definitions *********************/ /************************** Variable Definitions ****************************/ +#ifndef SDT extern XScuTimer_Config XScuTimer_ConfigTable[XPAR_XSCUTIMER_NUM_INSTANCES]; +#else +extern XScuTimer_Config XScuTimer_ConfigTable[]; +#endif /************************** Function Prototypes ******************************/ @@ -53,6 +61,7 @@ extern XScuTimer_Config XScuTimer_ConfigTable[XPAR_XSCUTIMER_NUM_INSTANCES]; * @note None. * ******************************************************************************/ +#ifndef SDT XScuTimer_Config *XScuTimer_LookupConfig(u16 DeviceId) { XScuTimer_Config *CfgPtr = NULL; @@ -67,4 +76,20 @@ XScuTimer_Config *XScuTimer_LookupConfig(u16 DeviceId) return (XScuTimer_Config *)CfgPtr; } +#else +XScuTimer_Config *XScuTimer_LookupConfig(UINTPTR BaseAddr) +{ + XScuTimer_Config *CfgPtr = NULL; + u32 Index; + + for (Index = 0U; XScuTimer_ConfigTable[Index].Name != NULL; Index++) { + if (XScuTimer_ConfigTable[Index].BaseAddr == BaseAddr) { + CfgPtr = &XScuTimer_ConfigTable[Index]; + break; + } + } + + return (XScuTimer_Config *)CfgPtr; +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.c b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.c index 1c392ec..ce9ec2a 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscuwdt.c -* @addtogroup scuwdt_v2_4 +* @addtogroup Overview * @{ * * Contains the implementation of interface functions of the XScuWdt driver. @@ -20,6 +21,7 @@ * ----- --- -------- --------------------------------------------- * 1.00a sdm 01/15/10 First release * 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance. +* 2.5 asa 07/18/23 Made updates for workflow decoupling flow. * * ******************************************************************************/ @@ -58,7 +60,7 @@ * ******************************************************************************/ s32 XScuWdt_CfgInitialize(XScuWdt *InstancePtr, - XScuWdt_Config *ConfigPtr, u32 EffectiveAddress) + XScuWdt_Config *ConfigPtr, u32 EffectiveAddress) { s32 CfgStatus; Xil_AssertNonvoid(InstancePtr != NULL); @@ -73,12 +75,13 @@ s32 XScuWdt_CfgInitialize(XScuWdt *InstancePtr, */ if (InstancePtr->IsStarted == XIL_COMPONENT_IS_STARTED) { CfgStatus = (s32)XST_DEVICE_IS_STARTED; - } - else { + } else { /* * Copy configuration into instance. */ +#ifndef SDT InstancePtr->Config.DeviceId = ConfigPtr->DeviceId; +#endif /* * Save the base address pointer such that the registers of the block @@ -97,7 +100,7 @@ s32 XScuWdt_CfgInitialize(XScuWdt *InstancePtr, */ InstancePtr->IsReady = XIL_COMPONENT_IS_READY; - CfgStatus =(s32)XST_SUCCESS; + CfgStatus = (s32)XST_SUCCESS; } return CfgStatus; } @@ -128,7 +131,7 @@ void XScuWdt_Start(XScuWdt *InstancePtr) * Read the contents of the Control register. */ Register = XScuWdt_ReadReg(InstancePtr->Config.BaseAddr, - XSCUWDT_CONTROL_OFFSET); + XSCUWDT_CONTROL_OFFSET); /* * Set the 'watchdog enable' bit in the register. @@ -139,7 +142,7 @@ void XScuWdt_Start(XScuWdt *InstancePtr) * Update the Control register with the new value. */ XScuWdt_WriteReg(InstancePtr->Config.BaseAddr, - XSCUWDT_CONTROL_OFFSET, Register); + XSCUWDT_CONTROL_OFFSET, Register); /* * Indicate that the device is started. @@ -170,7 +173,7 @@ void XScuWdt_Stop(XScuWdt *InstancePtr) * Read the contents of the Control register. */ Register = XScuWdt_ReadReg(InstancePtr->Config.BaseAddr, - XSCUWDT_CONTROL_OFFSET); + XSCUWDT_CONTROL_OFFSET); /* * Clear the 'watchdog enable' bit in the register. @@ -181,7 +184,7 @@ void XScuWdt_Stop(XScuWdt *InstancePtr) * Update the Control register with the new value. */ XScuWdt_WriteReg(InstancePtr->Config.BaseAddr, - XSCUWDT_CONTROL_OFFSET, Register); + XSCUWDT_CONTROL_OFFSET, Register); /* * Indicate that the device is stopped. diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.h b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.h index 8d11ff8..9130e4d 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscuwdt.h -* @addtogroup scuwdt_v2_4 +* @addtogroup Overview * @{ * @details * @@ -106,6 +107,8 @@ * time. * 2.3 sne 09/16/20 Fixed MISRA-C violations. * 2.4 sne 02/04/21 Fixed Doxygen warnings. +* 2.5 asa 07/18/23 Added support for system device tree based workflow +* decoupling flow. * * ******************************************************************************/ @@ -129,8 +132,18 @@ extern "C" { * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ - u32 BaseAddr; /**< Base address of the device */ +#else + char *Name; /**< Unique name of the device */ +#endif + UINTPTR BaseAddr; /**< Register base address */ +#ifdef SDT + u32 IntrId; /** Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ +#endif } XScuWdt_Config; /** @@ -168,7 +181,7 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; #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) + XSCUWDT_RST_STS_RESET_FLAG_MASK) == XSCUWDT_RST_STS_RESET_FLAG_MASK) /****************************************************************************/ /** @@ -189,7 +202,7 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; #define XScuWdt_IsTimerExpired(InstancePtr) \ ((XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \ XSCUWDT_ISR_OFFSET) & \ - XSCUWDT_ISR_EVENT_FLAG_MASK) == XSCUWDT_ISR_EVENT_FLAG_MASK) + XSCUWDT_ISR_EVENT_FLAG_MASK) == XSCUWDT_ISR_EVENT_FLAG_MASK) /****************************************************************************/ /** @@ -230,7 +243,7 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; ******************************************************************************/ #define XScuWdt_LoadWdt(InstancePtr, Value) \ XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \ - XSCUWDT_LOAD_OFFSET, (Value)) + XSCUWDT_LOAD_OFFSET, (Value)) /****************************************************************************/ /** @@ -250,7 +263,7 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \ XSCUWDT_CONTROL_OFFSET, \ (XScuWdt_ReadReg((InstancePtr)->Config.BaseAddr, \ - XSCUWDT_CONTROL_OFFSET) | \ + XSCUWDT_CONTROL_OFFSET) | \ (XSCUWDT_CONTROL_WD_MODE_MASK))) /****************************************************************************/ @@ -271,14 +284,14 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; * ******************************************************************************/ #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); \ -} + { \ + XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \ + XSCUWDT_DISABLE_OFFSET, \ + XSCUWDT_DISABLE_VALUE1); \ + XScuWdt_WriteReg((InstancePtr)->Config.BaseAddr, \ + XSCUWDT_DISABLE_OFFSET, \ + XSCUWDT_DISABLE_VALUE2); \ + } /****************************************************************************/ /** @@ -332,14 +345,18 @@ extern XScuWdt_Config XScuWdt_ConfigTable[]; #define XScuWdt_EnableAutoReload(InstancePtr) \ XScuWdt_SetControlReg((InstancePtr), \ (XScuWdt_GetControlReg(InstancePtr) | \ - XSCUWDT_CONTROL_AUTO_RELOAD_MASK)) + XSCUWDT_CONTROL_AUTO_RELOAD_MASK)) /************************** Function Prototypes ******************************/ /* * Lookup configuration in xscuwdt_sinit.c. */ +#ifndef SDT XScuWdt_Config *XScuWdt_LookupConfig(u16 DeviceId); +#else +XScuWdt_Config *XScuWdt_LookupConfig(UINTPTR BaseAddress); +#endif /* * Selftest function in xscuwdt_selftest.c diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_g.c index a8726a6..689e2c5 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_g.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscuwdt_g.c -* @addtogroup scuwdt_v2_4 +* @addtogroup Overview * @{ * * This file contains a table that specifies the configuration of the SCU diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_hw.h index 0cdfc1e..3c401ec 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscuwdt_hw.h -* @addtogroup scuwdt_v2_4 +* @addtogroup Overview * @{ * * This file contains the hardware interface to the Xilinx SCU private Watch Dog diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_selftest.c b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_selftest.c index 4b5c4cd..41af1c7 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_selftest.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_selftest.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscuwdt_selftest.c -* @addtogroup scuwdt_v2_4 +* @addtogroup Overview * @{ * * Contains diagnostic self-test functions for the XScuWdt driver. @@ -95,8 +96,7 @@ s32 XScuWdt_SelfTest(XScuWdt *InstancePtr) if (Register == 0xFFFFFFFFU) { SelfTestStatus = (s32)XST_FAILURE; - } - else { + } else { SelfTestStatus = (s32)XST_SUCCESS; } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_sinit.c index a46afa7..20daf6b 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/scuwdt/src/xscuwdt_sinit.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xscuwdt_sinit.c -* @addtogroup scuwdt_v2_4 +* @addtogroup Overview * @{ * * This file contains method for static initialization (compile-time) of the @@ -20,6 +21,8 @@ * ----- --- -------- --------------------------------------------- * 1.00a sdm 01/15/10 First release * 2.1 sk 02/26/15 Modified the code for MISRA-C:2012 compliance. +* 2.5 asa 07/18/23 Made updates to support system device tree based +* workflow decoupling flow. * * ******************************************************************************/ @@ -27,6 +30,9 @@ /***************************** Include Files *********************************/ #include "xscuwdt.h" +#ifndef SDT +#include "xparameters.h" +#endif /************************** Constant Definitions *****************************/ @@ -49,6 +55,7 @@ * @note None. * ******************************************************************************/ +#ifndef SDT XScuWdt_Config *XScuWdt_LookupConfig(u16 DeviceId) { XScuWdt_Config *CfgPtr = NULL; @@ -63,4 +70,21 @@ XScuWdt_Config *XScuWdt_LookupConfig(u16 DeviceId) return (XScuWdt_Config *)CfgPtr; } +#else +XScuWdt_Config *XScuWdt_LookupConfig(UINTPTR BaseAddress) +{ + XScuWdt_Config *CfgPtr = NULL; + u32 Index; + + for (Index = 0U; XScuWdt_ConfigTable[Index].Name != NULL; Index++) { + if ((XScuWdt_ConfigTable[Index].BaseAddr == BaseAddress) || + !BaseAddress) { + CfgPtr = &XScuWdt_ConfigTable[Index]; + break; + } + } + + return (XScuWdt_Config *)CfgPtr; +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.c b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.c index c4a23e8..7f92284 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,7 +8,7 @@ /** * * @file xsdps.c -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{ * * Contains the interface functions of the XSdPs driver. @@ -90,6 +90,8 @@ * 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. +* 4.2 ro 06/12/23 Added support for system device-tree flow. +* 4.3 ap 11/29/23 Add support for Sanitize feature. * * * @@ -109,21 +111,21 @@ /** * * @brief -* Initializes a specific XSdPs instance such that the driver is ready to use. +* Initializes a specific XSdPs instance so 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 +* @param InstancePtr Pointer to the XSdPs instance. +* @param ConfigPtr 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 +* contents of Configuration. +* @param EffectiveAddr 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. +* ConfigPtr->Config. BaseAddress for this device. * * @return * - XST_SUCCESS if successful. @@ -131,15 +133,15 @@ * 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. +* Initial clock of 400 KHz is set. +* Voltage of 3.3 V 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) + UINTPTR EffectiveAddr) { s32 Status; @@ -157,7 +159,9 @@ s32 XSdPs_CfgInitialize(XSdPs *InstancePtr, XSdPs_Config *ConfigPtr, } /* Set some default values. */ +#ifndef SDT InstancePtr->Config.DeviceId = ConfigPtr->DeviceId; +#endif InstancePtr->Config.BaseAddress = EffectiveAddr; InstancePtr->Config.InputClockHz = ConfigPtr->InputClockHz; InstancePtr->Config.CardDetect = ConfigPtr->CardDetect; @@ -173,6 +177,7 @@ s32 XSdPs_CfgInitialize(XSdPs *InstancePtr, XSdPs_Config *ConfigPtr, 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->Config.OTapDly_DDR_Clk200 = ConfigPtr->OTapDly_DDR_Clk200; InstancePtr->SectorCount = 0U; InstancePtr->Mode = XSDPS_DEFAULT_SPEED_MODE; InstancePtr->OTapDelay = 0U; @@ -185,15 +190,15 @@ s32 XSdPs_CfgInitialize(XSdPs *InstancePtr, XSdPs_Config *ConfigPtr, /* Host Controller version is read. */ InstancePtr->HC_Version = - (u8)(XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL_VER_OFFSET) & XSDPS_HC_SPEC_VER_MASK); + (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); + XSDPS_CAPS_OFFSET); /* Reset the SD bus lines */ Status = XSdPs_ResetConfig(InstancePtr); @@ -219,10 +224,10 @@ RETURN_PATH: /** * * @brief -* Initialize Card with Identification mode sequence +* Initializes Card with Identification mode sequence * * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if initialization was successful @@ -272,7 +277,8 @@ s32 XSdPs_CardInitialize(XSdPs *InstancePtr) Status = XST_FAILURE; goto RETURN_PATH; } - } else { + } + else { Status = XSdPs_MmcCardInitialize(InstancePtr); if (Status != XST_SUCCESS) { Status = XST_FAILURE; @@ -290,13 +296,13 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function performs SD read in polled mode. +* 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param Arg 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. +* @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 @@ -343,7 +349,7 @@ s32 XSdPs_ReadPolled(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff) if (InstancePtr->Config.IsCacheCoherent == 0U) { Xil_DCacheInvalidateRange((INTPTR)Buff, - ((INTPTR)BlkCnt * (INTPTR)InstancePtr->BlkSize)); + ((INTPTR)BlkCnt * (INTPTR)InstancePtr->BlkSize)); } RETURN_PATH: @@ -356,13 +362,13 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function performs SD write in polled mode. +* 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param Arg 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. +* @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 @@ -418,14 +424,13 @@ RETURN_PATH: /** * * @brief -* API to idle the SDIO Interface +* API to idle the SDIO Interface. * * -* @param InstancePtr is a pointer to the XSdPs instance. +* @param InstancePtr Pointer to the XSdPs instance. * * @return None * -* @note None. * ******************************************************************************/ s32 XSdPs_Idle(XSdPs *InstancePtr) @@ -441,8 +446,8 @@ s32 XSdPs_Idle(XSdPs *InstancePtr) /* 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); + | XSDPS_PSR_INHIBIT_DAT_MASK + | XSDPS_PSR_DAT_ACTIVE_MASK); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH ; @@ -469,11 +474,11 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function performs Erase operation on the given address range. +* 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param StartAddr Address of the first write block to be erased. +* @param EndAddr Address of the last write block of the continuous * range to be erased. * * @return @@ -501,12 +506,12 @@ s32 XSdPs_Erase(XSdPs *InstancePtr, u32 StartAddr, u32 EndAddr) } 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) { + ((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); + XSDPS_PRES_STATE_OFFSET); if ((PresentStateReg & XSDPS_PSR_CARD_INSRT_MASK) == 0x0U) { Status = XST_FAILURE; goto RETURN_PATH; @@ -545,4 +550,45 @@ RETURN_PATH: return Status; } +/*****************************************************************************/ +/** +* @brief +* Performs Sanitize operation on the unmapped user address range. +* +* @param InstancePtr Pointer to the instance to be worked on. +* +* @return +* - XST_SUCCESS if Sanitize is successful +* - XST_FAILURE if failure - could be because another transfer +* is in progress or card not present or Sanitize operation failure. +* +******************************************************************************/ +s32 XSdPs_Sanitize(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 + + if (InstancePtr->IsBusy == TRUE) { + Status = XST_FAILURE; + goto RETURN_PATH; + } + + Status = XSdPs_Set_Mmc_ExtCsd(InstancePtr, XSDPS_MMC_START_SANITIZE_ARG); + if (Status != XST_SUCCESS) { + Status = XST_FAILURE; + goto RETURN_PATH; + } + +RETURN_PATH: +#if defined (XCLOCKING) + Xil_ClockDisable(InstancePtr->Config.RefClk); +#endif + return Status; +} /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.h b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.h index 77aa9c6..3bdc4f6 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,75 +8,10 @@ /** * * @file xsdps.h -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{ * @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. -* -* Initialization & Configuration -* -* 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. -* -* Data transfer -* -* 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. -* -* File system use -* -* 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. -* -* eMMC support -* -* 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. * *
* MODIFICATION HISTORY: @@ -161,6 +96,11 @@ * 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. +* 4.2 ro 06/12/23 Added support for system device-tree flow. +* 4.2 ap 08/09/23 Reordered XSdPs_FrameCmd XSdPs_Identify_UhsMode functions +* 4.3 ap 10/11/23 Resolved compilation errors with Microblaze RISC-V +* 4.3 ap 11/29/23 Add support for Sanitize feature. +* 4.3 ap 12/22/23 Add support to read custom HS400 tap delay value from design for eMMC. * ** @@ -243,8 +183,12 @@ extern "C" { * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ - u32 BaseAddress; /**< Base address of the device */ +#else + char *Name; +#endif + UINTPTR BaseAddress; /**< Base address of the device */ u32 InputClockHz; /**< Input clock frequency */ u32 CardDetect; /**< Card Detect */ u32 WriteProtect; /**< Write Protect */ @@ -253,7 +197,7 @@ typedef struct { u32 HasEMIO; /**< If SD is connected to EMIO */ u8 SlotType; /**< Slot type */ u8 IsCacheCoherent; /**< If SD is Cache Coherent or not */ -#if defined (XCLOCKING) +#if defined (XCLOCKING) || defined (SDT) u32 RefClk; /**< Input clocks */ #endif u32 ITapDly_SDR_Clk50; /**< Input Tap delay for HSD/SDR25 modes */ @@ -262,6 +206,7 @@ typedef struct { 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 */ + u32 OTapDly_DDR_Clk200; /**< Input Tap delay for HS400 modes */ } XSdPs_Config; /** @@ -275,7 +220,8 @@ typedef struct { #pragma data_alignment = 32 } XSdPs_Adma2Descriptor32; #else -} __attribute__((__packed__))XSdPs_Adma2Descriptor32; +} +__attribute__((__packed__))XSdPs_Adma2Descriptor32; #endif /** @@ -325,11 +271,11 @@ typedef struct { u8 IsTuningDone; /**< Flag to indicate HS200 tuning complete */ #ifdef __ICCARM__ #pragma data_alignment = 32 - XSdPs_Adma2Descriptor32 Adma2_DescrTbl32[32]; - XSdPs_Adma2Descriptor64 Adma2_DescrTbl64[32]; + XSdPs_Adma2Descriptor32 Adma2_DescrTbl32[32]; /**< ADMA descriptor table 32 Bit */ + XSdPs_Adma2Descriptor64 Adma2_DescrTbl64[32]; /**< ADMA descriptor table 64 Bit */ #else - XSdPs_Adma2Descriptor32 Adma2_DescrTbl32[32] __attribute__ ((aligned(32))); - XSdPs_Adma2Descriptor64 Adma2_DescrTbl64[32] __attribute__ ((aligned(32))); + XSdPs_Adma2Descriptor32 Adma2_DescrTbl32[32] __attribute__ ((aligned(32))); /**< ADMA descriptor table 32 Bit */ + XSdPs_Adma2Descriptor64 Adma2_DescrTbl64[32] __attribute__ ((aligned(32))); /**< ADMA descriptor table 64 Bit */ #endif } XSdPs; @@ -355,10 +301,24 @@ typedef struct { */ #define ENABLE_HS400_MODE +/************************** Variable Definitions *****************************/ +/** + * XSdPs Configuration Table + */ +#ifndef SDT +extern XSdPs_Config XSdPs_ConfigTable[XPAR_XSDPS_NUM_INSTANCES]; +#else +extern XSdPs_Config XSdPs_ConfigTable[]; +#endif + /************************** Function Prototypes ******************************/ +#ifndef SDT XSdPs_Config *XSdPs_LookupConfig(u16 DeviceId); +#else +XSdPs_Config *XSdPs_LookupConfig(u32 BaseAddress); +#endif s32 XSdPs_CfgInitialize(XSdPs *InstancePtr, XSdPs_Config *ConfigPtr, - u32 EffectiveAddr); + UINTPTR 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); @@ -380,6 +340,7 @@ 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); +s32 XSdPs_Sanitize(XSdPs *InstancePtr); #ifdef __cplusplus } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_card.c b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_card.c index 52c5424..49854c1 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_card.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_card.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,7 +8,7 @@ /** * * @file xsdps_card.c -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{ * * The xsdps_card.c file contains the interface functions of the XSdPs driver. @@ -38,6 +38,8 @@ * sa 01/04/23 Update register bit polling logic to use Xil_WaitForEvent/ * Xil_WaitForEvents API. * sa 01/25/23 Use instance structure to store DMA descriptor tables. +* 4.2 ap 08/09/23 reordered function XSdPs_Identify_UhsMode. +* 4.3 ap 12/22/23 Add support to read custom HS400 tap delay value from design for eMMC. * * ******************************************************************************/ @@ -56,10 +58,10 @@ /*****************************************************************************/ /** * @brief -* This function performs SD read in polled mode. +* 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param Arg 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. @@ -78,22 +80,23 @@ s32 XSdPs_Read(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff) #ifdef XSDPS_DEBUG xil_printf("Max transfer length supported is 2MB\n"); #endif - return XST_FAILURE; - } - - XSdPs_SetupReadDma(InstancePtr, (u16)BlkCnt, (u16)InstancePtr->BlkSize, Buff); - - if (BlkCnt == 1U) { - /* Send single block read command */ - Status = XSdPs_CmdTransfer(InstancePtr, CMD17, Arg, BlkCnt); - if (Status != XST_SUCCESS) { - Status = XST_FAILURE; - } + Status = XST_FAILURE; } else { - /* Send multiple blocks read command */ - Status = XSdPs_CmdTransfer(InstancePtr, CMD18, Arg, BlkCnt); - if (Status != XST_SUCCESS) { - Status = XST_FAILURE; + + XSdPs_SetupReadDma(InstancePtr, (u16)BlkCnt, (u16)InstancePtr->BlkSize, Buff); + + if (BlkCnt == 1U) { + /* Send single block read command */ + Status = XSdPs_CmdTransfer(InstancePtr, CMD17, Arg, BlkCnt); + if (Status != XST_SUCCESS) { + Status = XST_FAILURE; + } + } else { + /* Send multiple blocks read command */ + Status = XSdPs_CmdTransfer(InstancePtr, CMD18, Arg, BlkCnt); + if (Status != XST_SUCCESS) { + Status = XST_FAILURE; + } } } @@ -103,10 +106,10 @@ s32 XSdPs_Read(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, u8 *Buff) /*****************************************************************************/ /** * @brief -* This function performs SD write in polled mode. +* 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param Arg 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. @@ -125,22 +128,23 @@ s32 XSdPs_Write(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff) #ifdef XSDPS_DEBUG xil_printf("Max transfer length supported is 2MB\n"); #endif - return XST_FAILURE; - } - - XSdPs_SetupWriteDma(InstancePtr, (u16)BlkCnt, (u16)InstancePtr->BlkSize, Buff); - - if (BlkCnt == 1U) { - /* Send single block write command */ - Status = XSdPs_CmdTransfer(InstancePtr, CMD24, Arg, BlkCnt); - if (Status != XST_SUCCESS) { - Status = XST_FAILURE; - } + Status = XST_FAILURE; } else { - /* Send multiple blocks write command */ - Status = XSdPs_CmdTransfer(InstancePtr, CMD25, Arg, BlkCnt); - if (Status != XST_SUCCESS) { - Status = XST_FAILURE; + + XSdPs_SetupWriteDma(InstancePtr, (u16)BlkCnt, (u16)InstancePtr->BlkSize, Buff); + + if (BlkCnt == 1U) { + /* Send single block write command */ + Status = XSdPs_CmdTransfer(InstancePtr, CMD24, Arg, BlkCnt); + if (Status != XST_SUCCESS) { + Status = XST_FAILURE; + } + } else { + /* Send multiple blocks write command */ + Status = XSdPs_CmdTransfer(InstancePtr, CMD25, Arg, BlkCnt); + if (Status != XST_SUCCESS) { + Status = XST_FAILURE; + } } } @@ -150,9 +154,9 @@ s32 XSdPs_Write(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt, const u8 *Buff) /*****************************************************************************/ /** * @brief -* This function is used to check for the transfer complete. +* Checks for the transfer complete. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if transfer was successful @@ -174,12 +178,12 @@ s32 XSdPs_CheckTransferComplete(XSdPs *InstancePtr) * Check for transfer complete */ StatusReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_NORM_INTR_STS_OFFSET); + XSDPS_NORM_INTR_STS_OFFSET); if ((StatusReg & XSDPS_INTR_ERR_MASK) != 0U) { /* Write to clear error bits */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_ERR_INTR_STS_OFFSET, - XSDPS_ERROR_INTR_ALL_MASK); + XSDPS_ERR_INTR_STS_OFFSET, + XSDPS_ERROR_INTR_ALL_MASK); Status = XST_FAILURE; goto RETURN_PATH; } @@ -191,7 +195,7 @@ s32 XSdPs_CheckTransferComplete(XSdPs *InstancePtr) /* Write to clear bit */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_NORM_INTR_STS_OFFSET, XSDPS_INTR_TC_MASK); + XSDPS_NORM_INTR_STS_OFFSET, XSDPS_INTR_TC_MASK); InstancePtr->IsBusy = FALSE; @@ -205,10 +209,10 @@ RETURN_PATH: /** * * @brief -* Identify type of card using CMD0 + CMD1 sequence +* Identifies type of card using CMD0 + CMD1 sequence * * -* @param InstancePtr is a pointer to the XSdPs instance. +* @param InstancePtr Pointer to the XSdPs instance. * ******************************************************************************/ s32 XSdPs_IdentifyCard(XSdPs *InstancePtr) @@ -216,8 +220,8 @@ s32 XSdPs_IdentifyCard(XSdPs *InstancePtr) s32 Status; if ((InstancePtr->HC_Version == XSDPS_HC_SPEC_V3) && - ((InstancePtr->Host_Caps & XSDPS_CAPS_SLOT_TYPE_MASK) - == XSDPS_CAPS_EMB_SLOT)) { + ((InstancePtr->Host_Caps & XSDPS_CAPS_SLOT_TYPE_MASK) + == XSDPS_CAPS_EMB_SLOT)) { InstancePtr->CardType = XSDPS_CHIP_EMMC; Status = XST_SUCCESS; goto RETURN_PATH; @@ -235,7 +239,7 @@ s32 XSdPs_IdentifyCard(XSdPs *InstancePtr) /* Host High Capacity support & High voltage window */ Status = XSdPs_CmdTransfer(InstancePtr, CMD1, - XSDPS_ACMD41_HCS | XSDPS_CMD1_HIGH_VOL, 0U); + XSDPS_ACMD41_HCS | XSDPS_CMD1_HIGH_VOL, 0U); if (Status != XST_SUCCESS) { InstancePtr->CardType = XSDPS_CARD_SD; } else { @@ -243,9 +247,9 @@ s32 XSdPs_IdentifyCard(XSdPs *InstancePtr) } XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_NORM_INTR_STS_OFFSET, XSDPS_NORM_INTR_ALL_MASK); + XSDPS_NORM_INTR_STS_OFFSET, XSDPS_NORM_INTR_ALL_MASK); XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_ERR_INTR_STS_OFFSET, XSDPS_ERROR_INTR_ALL_MASK); + XSDPS_ERR_INTR_STS_OFFSET, XSDPS_ERROR_INTR_ALL_MASK); Status = XSdPs_Reset(InstancePtr, XSDPS_SWRST_CMD_LINE_MASK); if (Status != XST_SUCCESS) { @@ -262,10 +266,10 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* SD initialization is done in this function +* This function Initializes SD. * * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if initialization was successful @@ -315,10 +319,10 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* Mmc initialization is done in this function +* This function initializes MMC * * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if initialization was successful @@ -347,8 +351,8 @@ s32 XSdPs_MmcCardInitialize(XSdPs *InstancePtr) } if (((InstancePtr->CardType == XSDPS_CARD_MMC) && - (InstancePtr->Card_Version > CSD_SPEC_VER_3)) && - (InstancePtr->HC_Version == XSDPS_HC_SPEC_V2)) { + (InstancePtr->Card_Version > CSD_SPEC_VER_3)) && + (InstancePtr->HC_Version == XSDPS_HC_SPEC_V2)) { Status = XSdPs_MmcModeInit(InstancePtr); if (Status != XST_SUCCESS) { Status = XST_FAILURE; @@ -366,7 +370,7 @@ s32 XSdPs_MmcCardInitialize(XSdPs *InstancePtr) } - if (InstancePtr->Mode != XSDPS_DDR52_MODE && InstancePtr->Mode != XSDPS_HS400_MODE) { + if ((InstancePtr->Mode != XSDPS_DDR52_MODE) && (InstancePtr->Mode != XSDPS_HS400_MODE)) { Status = XSdPs_SetBlkSize(InstancePtr, XSDPS_BLK_SIZE_512_MASK); if (Status != XST_SUCCESS) { Status = XST_FAILURE; @@ -374,7 +378,7 @@ s32 XSdPs_MmcCardInitialize(XSdPs *InstancePtr) } } else { XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_BLK_SIZE_OFFSET, XSDPS_BLK_SIZE_512_MASK); + XSDPS_BLK_SIZE_OFFSET, XSDPS_BLK_SIZE_512_MASK); InstancePtr->BlkSize = XSDPS_BLK_SIZE_512_MASK; } @@ -387,9 +391,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function checks if the card is present or not. +* Checks if the card is present or not. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -400,19 +404,19 @@ s32 XSdPs_CheckCardDetect(XSdPs *InstancePtr) s32 Status; if ((InstancePtr->HC_Version == XSDPS_HC_SPEC_V3) && - ((InstancePtr->Host_Caps & XSDPS_CAPS_SLOT_TYPE_MASK) - == XSDPS_CAPS_EMB_SLOT)) { + ((InstancePtr->Host_Caps & XSDPS_CAPS_SLOT_TYPE_MASK) + == XSDPS_CAPS_EMB_SLOT)) { Status = XST_SUCCESS; goto RETURN_PATH; } - if(InstancePtr->Config.CardDetect != 0U) { + if (InstancePtr->Config.CardDetect != 0U) { /* * Check the present state register to make sure * card is inserted and detected by host controller */ PresentStateReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_PRES_STATE_OFFSET); + XSDPS_PRES_STATE_OFFSET); if ((PresentStateReg & XSDPS_PSR_CARD_INSRT_MASK) == 0U) { Status = XST_FAILURE; goto RETURN_PATH; @@ -428,9 +432,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function sends CMD0 to reset the card. +* Sends CMD0 to reset the card. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -451,9 +455,9 @@ s32 XSdPs_CardReset(XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function sends command to get the card interface details. +* Sends command to get the card interface details. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -468,7 +472,7 @@ s32 XSdPs_CardIfCond(XSdPs *InstancePtr) * 0x1AA - Supply Voltage 2.7 - 3.6V and AA is pattern */ Status = XSdPs_CmdTransfer(InstancePtr, CMD8, - XSDPS_CMD8_VOL_PATTERN, 0U); + XSDPS_CMD8_VOL_PATTERN, 0U); if ((Status != XST_SUCCESS) && (Status != XSDPS_CT_ERROR)) { Status = XST_FAILURE; goto RETURN_PATH; @@ -483,7 +487,7 @@ s32 XSdPs_CardIfCond(XSdPs *InstancePtr) } RespOCR = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_RESP0_OFFSET); + XSDPS_RESP0_OFFSET); if (RespOCR != XSDPS_CMD8_VOL_PATTERN) { InstancePtr->Card_Version = XSDPS_SD_VER_1_0; } else { @@ -499,9 +503,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function sends command to get the card operating condition. +* Sends command to get the card operating condition. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -524,17 +528,17 @@ s32 XSdPs_CardOpCond(XSdPs *InstancePtr) Arg = XSDPS_ACMD41_HCS | XSDPS_ACMD41_3V3 | (0x1FFU << 15U); if ((InstancePtr->HC_Version == XSDPS_HC_SPEC_V3) && - (InstancePtr->Config.BusWidth == XSDPS_WIDTH_8)) { + (InstancePtr->Config.BusWidth == XSDPS_WIDTH_8)) { Arg |= XSDPS_OCR_S18; } /* 0x40300000 - Host High Capacity support & 3.3V window */ Status = XSdPs_CmdTransfer(InstancePtr, ACMD41, - Arg, 0U); + Arg, 0U); } else { /* Send CMD1 while card is still busy with power up */ Status = XSdPs_CmdTransfer(InstancePtr, CMD1, - XSDPS_ACMD41_HCS | XSDPS_CMD1_HIGH_VOL, 0U); + XSDPS_ACMD41_HCS | XSDPS_CMD1_HIGH_VOL, 0U); } if (Status != XST_SUCCESS) { Status = XST_FAILURE; @@ -542,7 +546,8 @@ s32 XSdPs_CardOpCond(XSdPs *InstancePtr) } /* Response with card capacity */ - Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_RESP0_OFFSET, XSDPS_RESPOCR_READY, XSDPS_RESPOCR_READY, 1U); + Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_RESP0_OFFSET, XSDPS_RESPOCR_READY, + XSDPS_RESPOCR_READY, 1U); if (Status == XST_SUCCESS) { RespOCR = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, XSDPS_RESP0_OFFSET); break; @@ -578,9 +583,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to get the card ID. +* Gets the card ID. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -598,19 +603,19 @@ s32 XSdPs_GetCardId(XSdPs *InstancePtr) } InstancePtr->CardID[0] = - XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_RESP0_OFFSET); + XSdPs_ReadReg(InstancePtr->Config.BaseAddress, + XSDPS_RESP0_OFFSET); InstancePtr->CardID[1] = - XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_RESP1_OFFSET); + XSdPs_ReadReg(InstancePtr->Config.BaseAddress, + XSDPS_RESP1_OFFSET); InstancePtr->CardID[2] = - XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_RESP2_OFFSET); + XSdPs_ReadReg(InstancePtr->Config.BaseAddress, + XSDPS_RESP2_OFFSET); InstancePtr->CardID[3] = - XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_RESP3_OFFSET); + XSdPs_ReadReg(InstancePtr->Config.BaseAddress, + XSDPS_RESP3_OFFSET); - if(InstancePtr->CardType == XSDPS_CARD_SD) { + if (InstancePtr->CardType == XSDPS_CARD_SD) { do { Status = XSdPs_CmdTransfer(InstancePtr, CMD3, 0U, 0U); if (Status != XST_SUCCESS) { @@ -625,7 +630,7 @@ s32 XSdPs_GetCardId(XSdPs *InstancePtr) Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_RESP0_OFFSET, 0xFFFF0000, 0U, 1U); if (Status != XST_SUCCESS) { InstancePtr->RelCardAddr = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_RESP0_OFFSET) & 0xFFFF0000U; + XSDPS_RESP0_OFFSET) & 0xFFFF0000U; break; } Count = Count - 1U; @@ -653,9 +658,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to get the CSD register from the card. +* Gets the CSD register from the card. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -679,13 +684,13 @@ s32 XSdPs_GetCsd(XSdPs *InstancePtr) * Currently not used for any operation. */ CSD[0] = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_RESP0_OFFSET); + XSDPS_RESP0_OFFSET); CSD[1] = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_RESP1_OFFSET); + XSDPS_RESP1_OFFSET); CSD[2] = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_RESP2_OFFSET); + XSDPS_RESP2_OFFSET); CSD[3] = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_RESP3_OFFSET); + XSDPS_RESP3_OFFSET); InstancePtr->CardSpecData[0] = CSD[0]; InstancePtr->CardSpecData[1] = CSD[1]; @@ -693,7 +698,7 @@ s32 XSdPs_GetCsd(XSdPs *InstancePtr) InstancePtr->CardSpecData[3] = CSD[3]; if (InstancePtr->CardType != XSDPS_CARD_SD) { - InstancePtr->Card_Version = (u8)((u32)(CSD[3] & CSD_SPEC_VER_MASK) >>18U); + InstancePtr->Card_Version = (u8)((u32)(CSD[3] & CSD_SPEC_VER_MASK) >> 18U); Status = XST_SUCCESS; goto RETURN_PATH; } @@ -705,10 +710,10 @@ s32 XSdPs_GetCsd(XSdPs *InstancePtr) DeviceSize |= (CSD[2] & C_SIZE_UPPER_MASK) << 10U; DeviceSize = (DeviceSize + 1U) * Mult; DeviceSize = DeviceSize * BlkLen; - InstancePtr->SectorCount = (DeviceSize/XSDPS_BLK_SIZE_512_MASK); + InstancePtr->SectorCount = (DeviceSize / XSDPS_BLK_SIZE_512_MASK); } else if (((CSD[3] & CSD_STRUCT_MASK) >> 22U) == 1U) { InstancePtr->SectorCount = (((CSD[1] & CSD_V2_C_SIZE_MASK) >> 8U) + - 1U) * 1024U; + 1U) * 1024U; } else { Status = XST_FAILURE; goto RETURN_PATH; @@ -723,9 +728,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to set the card voltage to 1.8V. +* Sets the card voltage to 1.8 V. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -738,10 +743,10 @@ s32 XSdPs_CardSetVoltage18(XSdPs *InstancePtr) /* Stop the clock */ CtrlReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_CLK_CTRL_OFFSET); + XSDPS_CLK_CTRL_OFFSET); CtrlReg &= (u16)(~(XSDPS_CC_SD_CLK_EN_MASK | XSDPS_CC_INT_CLK_EN_MASK)); XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, XSDPS_CLK_CTRL_OFFSET, - CtrlReg); + CtrlReg); /* Check for 1.8V signal enable bit is cleared by Host */ Status = XSdPs_SetVoltage18(InstancePtr); @@ -751,7 +756,7 @@ s32 XSdPs_CardSetVoltage18(XSdPs *InstancePtr) } ClockReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_CLK_CTRL_OFFSET); + XSDPS_CLK_CTRL_OFFSET); /* Enable the clock in the controller */ Status = XSdPs_EnableClock(InstancePtr, ClockReg); if (Status != XST_SUCCESS) { @@ -771,9 +776,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to do initial Reset Configuration. +* Configures the initial Reset. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -786,11 +791,15 @@ s32 XSdPs_ResetConfig(XSdPs *InstancePtr) #ifdef versal if ((InstancePtr->Host_Caps & XSDPS_CAPS_SLOT_TYPE_MASK) - != XSDPS_CAPS_EMB_SLOT) { + != XSDPS_CAPS_EMB_SLOT) { u32 Timeout = 200000U; /* Check for SD Bus Lines low */ - Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_PRES_STATE_OFFSET, XSDPS_PSR_DAT30_SG_LVL_MASK, 0U, Timeout); + Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_PRES_STATE_OFFSET, XSDPS_PSR_DAT30_SG_LVL_MASK, 0U, + Timeout); + if (Status != XST_SUCCESS) { + Status = XST_FAILURE; + } } #endif @@ -809,9 +818,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to do initial Host Configuration. +* Configures the initial Host. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -829,20 +838,20 @@ void XSdPs_HostConfig(XSdPs *InstancePtr) * DMA enabled, block count enabled, data direction card to host(read) */ InstancePtr->TransferMode = XSDPS_TM_DMA_EN_MASK | XSDPS_TM_BLK_CNT_EN_MASK | - XSDPS_TM_DAT_DIR_SEL_MASK; + XSDPS_TM_DAT_DIR_SEL_MASK; /* Set block size to 512 by default */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_BLK_SIZE_OFFSET, XSDPS_BLK_SIZE_512_MASK); + XSDPS_BLK_SIZE_OFFSET, XSDPS_BLK_SIZE_512_MASK); } /*****************************************************************************/ /** * @brief -* This function checks for Reset Done bits to be cleared after a reset assert. +* Checks for Reset Done bits to be cleared after a reset assert. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param Value is the bits to be checked to be cleared. +* @param InstancePtr Pointer to the instance to be worked on. +* @param Value Bits to be checked to be cleared. * * @return None * @@ -855,7 +864,7 @@ s32 XSdPs_CheckResetDone(XSdPs *InstancePtr, u8 Value) /* Proceed with initialization only after reset is complete */ /* Using XSDPS_CLK_CTRL_OFFSET(0x2C) in place of XSDPS_SW_RST_OFFSET(0x2F) for 32bit address aligned reading */ Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_CLK_CTRL_OFFSET, - Value << 24, 0U, Timeout); + ((u32)Value) << 24, 0U, Timeout); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH ; @@ -870,9 +879,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to setup the voltage switch. +* Sets up the voltage switch. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -891,7 +900,7 @@ s32 XSdPs_SetupVoltageSwitch(XSdPs *InstancePtr) /* Wait for CMD and DATA line to go low */ Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_PRES_STATE_OFFSET, - XSDPS_PSR_CMD_SG_LVL_MASK | XSDPS_PSR_DAT30_SG_LVL_MASK, 0U, Timeout); + XSDPS_PSR_CMD_SG_LVL_MASK | XSDPS_PSR_DAT30_SG_LVL_MASK, 0U, Timeout); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH ; @@ -904,9 +913,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to check if the Cmd and Dat buses are high. +* Check if the CMD and DAT buses are high. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -918,8 +927,8 @@ s32 XSdPs_CheckBusHigh(XSdPs *InstancePtr) /* Wait for CMD and DATA line to go high */ Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_PRES_STATE_OFFSET, - XSDPS_PSR_CMD_SG_LVL_MASK | XSDPS_PSR_DAT30_SG_LVL_MASK, - XSDPS_PSR_CMD_SG_LVL_MASK | XSDPS_PSR_DAT30_SG_LVL_MASK, Timeout); + XSDPS_PSR_CMD_SG_LVL_MASK | XSDPS_PSR_DAT30_SG_LVL_MASK, + XSDPS_PSR_CMD_SG_LVL_MASK | XSDPS_PSR_DAT30_SG_LVL_MASK, Timeout); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH ; @@ -940,70 +949,31 @@ RETURN_PATH: * supported bus speed. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param ReadBuff contains the response for CMD6 +* @param InstancePtr Pointer to the XSdPs instance. +* @param ReadBuff Contains the response for CMD6 * * @return None. * -* @note None. * ******************************************************************************/ void XSdPs_Identify_UhsMode(XSdPs *InstancePtr, u8 *ReadBuff) { if (((ReadBuff[13] & UHS_SDR104_SUPPORT) != 0U) && - (InstancePtr->Config.InputClockHz >= XSDPS_SD_INPUT_MAX_CLK)) { + (InstancePtr->Config.InputClockHz >= XSDPS_SD_INPUT_MAX_CLK)) { InstancePtr->Mode = XSDPS_UHS_SPEED_MODE_SDR104; - if (InstancePtr->Config.OTapDly_SDR_Clk200) { - InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_SDR_Clk200; - } else if (InstancePtr->Config.BankNumber == 2U) { - InstancePtr->OTapDelay = SD_OTAPDLYSEL_HS200_B2; - } else { - InstancePtr->OTapDelay = SD_OTAPDLYSEL_HS200_B0; - } + XSdPs_SetTapDelay_SDR104(InstancePtr); } else if (((ReadBuff[13] & UHS_SDR50_SUPPORT) != 0U) && - (InstancePtr->Config.InputClockHz >= XSDPS_SD_SDR50_MAX_CLK)) { + (InstancePtr->Config.InputClockHz >= XSDPS_SD_SDR50_MAX_CLK)) { InstancePtr->Mode = XSDPS_UHS_SPEED_MODE_SDR50; - if (InstancePtr->Config.OTapDly_SDR_Clk100) { - InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_SDR_Clk100; - } else { - InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD50; - } + XSdPs_SetTapDelay_SDR50(InstancePtr); } else if (((ReadBuff[13] & UHS_DDR50_SUPPORT) != 0U) && - (InstancePtr->Config.InputClockHz >= XSDPS_SD_DDR50_MAX_CLK)) { + (InstancePtr->Config.InputClockHz >= XSDPS_SD_DDR50_MAX_CLK)) { InstancePtr->Mode = XSDPS_UHS_SPEED_MODE_DDR50; - if (InstancePtr->Config.OTapDly_DDR_Clk50 && - InstancePtr->Config.ITapDly_DDR_Clk50) { - InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_DDR_Clk50; - InstancePtr->ITapDelay = InstancePtr->Config.ITapDly_DDR_Clk50; - if ((InstancePtr->Config.SlotType == XSDPS_SLOTTYPE_SDADIR) && - (InstancePtr->ITapDelay == SD_ITAPDLYSEL_SD_DDR50)) { - InstancePtr->ITapDelay = SD_AUTODIR_ITAPDLYSEL_DDR50; - } - } else if (InstancePtr->Config.SlotType == XSDPS_SLOTTYPE_SDADIR) { - InstancePtr->ITapDelay = SD_AUTODIR_ITAPDLYSEL_DDR50; - InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD_DDR50; - } else { - InstancePtr->ITapDelay = SD_ITAPDLYSEL_SD_DDR50; - InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD_DDR50; - } + XSdPs_SetTapDelay_DDR50(InstancePtr); } else if (((ReadBuff[13] & UHS_SDR25_SUPPORT) != 0U) && - (InstancePtr->Config.InputClockHz >= XSDPS_SD_SDR25_MAX_CLK)) { + (InstancePtr->Config.InputClockHz >= XSDPS_SD_SDR25_MAX_CLK)) { InstancePtr->Mode = XSDPS_UHS_SPEED_MODE_SDR25; - if (InstancePtr->Config.OTapDly_SDR_Clk50 && - InstancePtr->Config.ITapDly_SDR_Clk50) { - InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_SDR_Clk50; - InstancePtr->ITapDelay = InstancePtr->Config.ITapDly_SDR_Clk50; - if ((InstancePtr->Config.SlotType == XSDPS_SLOTTYPE_SDADIR) && - (InstancePtr->ITapDelay == SD_ITAPDLYSEL_HSD)) { - InstancePtr->ITapDelay = SD_AUTODIR_ITAPDLYSEL_SDR25; - } - } else if (InstancePtr->Config.SlotType == XSDPS_SLOTTYPE_SDADIR) { - InstancePtr->ITapDelay = SD_AUTODIR_ITAPDLYSEL_SDR25; - InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD_HSD; - } else { - InstancePtr->ITapDelay = SD_ITAPDLYSEL_HSD; - InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD_HSD; - } + XSdPs_SetTapDelay_SDR25(InstancePtr); } else { InstancePtr->Mode = XSDPS_UHS_SPEED_MODE_SDR12; } @@ -1013,20 +983,18 @@ void XSdPs_Identify_UhsMode(XSdPs *InstancePtr, u8 *ReadBuff) /** * * @brief -* API to set Tap Delay w.r.t speed modes +* API to set Tap Delay with respect to the speed modes. * * -* @param InstancePtr is a pointer to the XSdPs instance. +* @param InstancePtr Pointer to the XSdPs instance. * * @return None * -* @note None. -* ******************************************************************************/ void XSdPs_SetTapDelay(XSdPs *InstancePtr) { if ((InstancePtr->Mode == XSDPS_DEFAULT_SPEED_MODE) || - (InstancePtr->Mode == XSDPS_UHS_SPEED_MODE_SDR12)) { + (InstancePtr->Mode == XSDPS_UHS_SPEED_MODE_SDR12)) { return; } @@ -1047,9 +1015,9 @@ void XSdPs_SetTapDelay(XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function is used to change the SD Bus Speed. +* Changes the SD Bus Speed. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -1090,11 +1058,11 @@ s32 XSdPs_Change_SdBusSpeed(XSdPs *InstancePtr) if (InstancePtr->Switch1v8 != 0U) { /* Set UHS mode in controller */ CtrlReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL2_OFFSET); + XSDPS_HOST_CTRL2_OFFSET); CtrlReg &= (~(u16)XSDPS_HC2_UHS_MODE_MASK); XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL2_OFFSET, - CtrlReg | (u16)InstancePtr->Mode); + XSDPS_HOST_CTRL2_OFFSET, + CtrlReg | (u16)InstancePtr->Mode); } Status = XST_SUCCESS; @@ -1106,9 +1074,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to change the eMMC bus speed. +* Changes the eMMC bus speed. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -1148,7 +1116,7 @@ RETURN_PATH: * @brief * This function is used to do the Auto tuning. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -1160,13 +1128,12 @@ s32 XSdPs_AutoTuning(XSdPs *InstancePtr) u8 TuningCount; BlkSize = XSDPS_TUNING_CMD_BLKSIZE; - if(InstancePtr->BusWidth == XSDPS_8_BIT_WIDTH) - { - BlkSize = BlkSize*2U; + if (InstancePtr->BusWidth == XSDPS_8_BIT_WIDTH) { + BlkSize = BlkSize * 2U; } BlkSize &= XSDPS_BLK_SIZE_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, XSDPS_BLK_SIZE_OFFSET, - BlkSize); + BlkSize); InstancePtr->TransferMode = XSDPS_TM_DAT_DIR_SEL_MASK; @@ -1192,13 +1159,13 @@ s32 XSdPs_AutoTuning(XSdPs *InstancePtr) } if ((XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL2_OFFSET) & XSDPS_HC2_EXEC_TNG_MASK) == 0U) { + XSDPS_HOST_CTRL2_OFFSET) & XSDPS_HC2_EXEC_TNG_MASK) == 0U) { break; } } if ((XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL2_OFFSET) & XSDPS_HC2_SAMP_CLK_SEL_MASK) == 0U) { + XSDPS_HOST_CTRL2_OFFSET) & XSDPS_HC2_SAMP_CLK_SEL_MASK) == 0U) { Status = XST_FAILURE; goto RETURN_PATH; } @@ -1216,17 +1183,15 @@ RETURN_PATH: /** * * @brief -* API to setup ADMA2 descriptor table +* API to setup ADMA2 descriptor table. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param BlkCnt - block count. -* @param Buff pointer to data buffer. +* @param InstancePtr Pointer to the XSdPs instance. +* @param BlkCnt Block count. +* @param Buff Pointer to data buffer. * * @return None * -* @note None. -* ******************************************************************************/ void XSdPs_SetupADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff) { @@ -1241,15 +1206,14 @@ void XSdPs_SetupADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff) /** * * @brief -* API to setup ADMA2 descriptor table for 64 Bit DMA +* API to setup ADMA2 descriptor table for 64 Bit DMA. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param BlkCnt - block count. +* @param InstancePtr Pointer to the XSdPs instance. +* @param BlkCnt Block count. * * @return None * -* @note None. * ******************************************************************************/ void XSdPs_SetupADMA2DescTbl64Bit(XSdPs *InstancePtr, u32 BlkCnt) @@ -1260,16 +1224,16 @@ void XSdPs_SetupADMA2DescTbl64Bit(XSdPs *InstancePtr, u32 BlkCnt) /* Setup ADMA2 - Write descriptor table and point ADMA SAR to it */ BlkSize = (u32)XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_BLK_SIZE_OFFSET) & - XSDPS_BLK_SIZE_MASK; + XSDPS_BLK_SIZE_OFFSET) & + XSDPS_BLK_SIZE_MASK; - if((BlkCnt*BlkSize) < XSDPS_DESC_MAX_LENGTH) { + if ((BlkCnt * BlkSize) < XSDPS_DESC_MAX_LENGTH) { TotalDescLines = 1U; } else { - TotalDescLines = ((BlkCnt*BlkSize) / XSDPS_DESC_MAX_LENGTH); + TotalDescLines = ((BlkCnt * BlkSize) / XSDPS_DESC_MAX_LENGTH); if (((BlkCnt * BlkSize) % XSDPS_DESC_MAX_LENGTH) != 0U) { TotalDescLines += 1U; } @@ -1278,29 +1242,29 @@ void XSdPs_SetupADMA2DescTbl64Bit(XSdPs *InstancePtr, u32 BlkCnt) for (DescNum = 0U; DescNum < (TotalDescLines - 1U); DescNum++) { InstancePtr->Adma2_DescrTbl64[DescNum].Address = - InstancePtr->Dma64BitAddr + - ((u64)DescNum*XSDPS_DESC_MAX_LENGTH); + InstancePtr->Dma64BitAddr + + ((u64)DescNum * XSDPS_DESC_MAX_LENGTH); InstancePtr->Adma2_DescrTbl64[DescNum].Attribute = - XSDPS_DESC_TRAN | XSDPS_DESC_VALID; + XSDPS_DESC_TRAN | XSDPS_DESC_VALID; InstancePtr->Adma2_DescrTbl64[DescNum].Length = 0U; } InstancePtr->Adma2_DescrTbl64[TotalDescLines - 1U].Address = - InstancePtr->Dma64BitAddr + - ((u64)DescNum*XSDPS_DESC_MAX_LENGTH); + InstancePtr->Dma64BitAddr + + ((u64)DescNum * XSDPS_DESC_MAX_LENGTH); InstancePtr->Adma2_DescrTbl64[TotalDescLines - 1U].Attribute = - XSDPS_DESC_TRAN | XSDPS_DESC_END | XSDPS_DESC_VALID; + XSDPS_DESC_TRAN | XSDPS_DESC_END | XSDPS_DESC_VALID; InstancePtr->Adma2_DescrTbl64[TotalDescLines - 1U].Length = - (u16)((BlkCnt*BlkSize) - (u32)(DescNum*XSDPS_DESC_MAX_LENGTH)); + (u16)((BlkCnt * BlkSize) - (u32)(DescNum * XSDPS_DESC_MAX_LENGTH)); XSdPs_WriteReg(InstancePtr->Config.BaseAddress, XSDPS_ADMA_SAR_OFFSET, - (u32)((UINTPTR)&(InstancePtr->Adma2_DescrTbl64[0]) & ~(u32)0x0U)); + (u32)((UINTPTR) & (InstancePtr->Adma2_DescrTbl64[0]) & ~(u32)0x0U)); if (InstancePtr->Config.IsCacheCoherent == 0U) { - Xil_DCacheFlushRange((INTPTR)&(InstancePtr->Adma2_DescrTbl64[0]), - (INTPTR)sizeof(XSdPs_Adma2Descriptor64) * (INTPTR)32U); + Xil_DCacheFlushRange((INTPTR) & (InstancePtr->Adma2_DescrTbl64[0]), + (INTPTR)sizeof(XSdPs_Adma2Descriptor64) * (INTPTR)32U); } /* Clear the 64-Bit Address variable */ @@ -1312,14 +1276,13 @@ void XSdPs_SetupADMA2DescTbl64Bit(XSdPs *InstancePtr, u32 BlkCnt) /** * * @brief -* API to reset the DLL +* API to reset the DLL. * * -* @param InstancePtr is a pointer to the XSdPs instance. +* @param InstancePtr Pointer to the XSdPs instance. * * @return None * -* @note None. * ******************************************************************************/ s32 XSdPs_DllReset(XSdPs *InstancePtr) @@ -1329,10 +1292,10 @@ s32 XSdPs_DllReset(XSdPs *InstancePtr) /* Disable clock */ ClockReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_CLK_CTRL_OFFSET); + XSDPS_CLK_CTRL_OFFSET); ClockReg &= ~XSDPS_CC_SD_CLK_EN_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_CLK_CTRL_OFFSET, (u16)ClockReg); + XSDPS_CLK_CTRL_OFFSET, (u16)ClockReg); /* Issue DLL Reset to load zero tap values */ XSdPs_DllRstCtrl(InstancePtr, 1U); @@ -1343,7 +1306,7 @@ s32 XSdPs_DllReset(XSdPs *InstancePtr) XSdPs_DllRstCtrl(InstancePtr, 0U); ClockReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_CLK_CTRL_OFFSET); + XSDPS_CLK_CTRL_OFFSET); /* Enable the clock in the controller */ Status = XSdPs_EnableClock(InstancePtr, (u16)ClockReg); if (Status != XST_SUCCESS) { @@ -1356,10 +1319,10 @@ s32 XSdPs_DllReset(XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function is used to identify the eMMC speed mode. +* Identifies the eMMC speed mode. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param ExtCsd is the extended CSD register from the card +* @param InstancePtr Pointer to the instance to be worked on. +* @param ExtCsd Extended CSD register from the card. * * @return None * @@ -1372,18 +1335,18 @@ void XSdPs_IdentifyEmmcMode(XSdPs *InstancePtr, const u8 *ExtCsd) /* Check for card supported speed */ #if defined (VERSAL_NET) && defined (ENABLE_HS400_MODE) if ((ExtCsd[EXT_CSD_DEVICE_TYPE_BYTE] & - (EXT_CSD_DEVICE_TYPE_DDR_1V8_HS400 | - EXT_CSD_DEVICE_TYPE_DDR_1V2_HS400)) != 0U) { + (EXT_CSD_DEVICE_TYPE_DDR_1V8_HS400 | + EXT_CSD_DEVICE_TYPE_DDR_1V2_HS400)) != 0U) { InstancePtr->Mode = XSDPS_HS400_MODE; InstancePtr->IsTuningDone = 0U; InstancePtr->OTapDelay = SD_OTAPDLYSEL_HS200_B0; } else { #endif if ((ExtCsd[EXT_CSD_DEVICE_TYPE_BYTE] & - (EXT_CSD_DEVICE_TYPE_SDR_1V8_HS200 | - EXT_CSD_DEVICE_TYPE_SDR_1V2_HS200)) != 0U) { + (EXT_CSD_DEVICE_TYPE_SDR_1V8_HS200 | + EXT_CSD_DEVICE_TYPE_SDR_1V2_HS200)) != 0U) { InstancePtr->Mode = XSDPS_HS200_MODE; - if (InstancePtr->Config.OTapDly_SDR_Clk200) { + if (InstancePtr->Config.OTapDly_SDR_Clk200 != 0U) { InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_SDR_Clk200; } else if (InstancePtr->Config.BankNumber == 2U) { InstancePtr->OTapDelay = SD_OTAPDLYSEL_HS200_B2; @@ -1391,11 +1354,11 @@ void XSdPs_IdentifyEmmcMode(XSdPs *InstancePtr, const u8 *ExtCsd) InstancePtr->OTapDelay = SD_OTAPDLYSEL_HS200_B0; } } else if ((ExtCsd[EXT_CSD_DEVICE_TYPE_BYTE] & - (EXT_CSD_DEVICE_TYPE_DDR_1V8_HIGH_SPEED | - EXT_CSD_DEVICE_TYPE_DDR_1V2_HIGH_SPEED)) != 0U) { + (EXT_CSD_DEVICE_TYPE_DDR_1V8_HIGH_SPEED | + EXT_CSD_DEVICE_TYPE_DDR_1V2_HIGH_SPEED)) != 0U) { InstancePtr->Mode = XSDPS_DDR52_MODE; - if (InstancePtr->Config.OTapDly_DDR_Clk50 && - InstancePtr->Config.ITapDly_DDR_Clk50) { + if ((InstancePtr->Config.OTapDly_DDR_Clk50 != 0U) && + (InstancePtr->Config.ITapDly_DDR_Clk50 != 0U)) { InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_DDR_Clk50; InstancePtr->ITapDelay = InstancePtr->Config.ITapDly_DDR_Clk50; } else { @@ -1403,10 +1366,10 @@ void XSdPs_IdentifyEmmcMode(XSdPs *InstancePtr, const u8 *ExtCsd) InstancePtr->ITapDelay = SD_ITAPDLYSEL_EMMC_DDR50; } } else if ((ExtCsd[EXT_CSD_DEVICE_TYPE_BYTE] & - EXT_CSD_DEVICE_TYPE_HIGH_SPEED) != 0U) { + EXT_CSD_DEVICE_TYPE_HIGH_SPEED) != 0U) { InstancePtr->Mode = XSDPS_HIGH_SPEED_MODE; - if (InstancePtr->Config.OTapDly_SDR_Clk50 && - InstancePtr->Config.ITapDly_SDR_Clk50) { + if ((InstancePtr->Config.OTapDly_SDR_Clk50 != 0U) && + (InstancePtr->Config.ITapDly_SDR_Clk50 != 0U)) { InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_SDR_Clk50; InstancePtr->ITapDelay = InstancePtr->Config.ITapDly_SDR_Clk50; } else { @@ -1425,10 +1388,10 @@ void XSdPs_IdentifyEmmcMode(XSdPs *InstancePtr, const u8 *ExtCsd) /*****************************************************************************/ /** * @brief -* This function is used to check the eMMC timing. +* Checks the eMMC timing. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param ExtCsd is the extended CSD register from the card +* @param InstancePtr Pointer to the instance to be worked on. +* @param ExtCsd Extended CSD register from the card. * * @return None * @@ -1457,7 +1420,7 @@ s32 XSdPs_CheckEmmcTiming(XSdPs *InstancePtr, u8 *ExtCsd) goto RETURN_PATH; } } else if ((InstancePtr->Mode == XSDPS_HIGH_SPEED_MODE) || - (InstancePtr->Mode == XSDPS_DDR52_MODE)) { + (InstancePtr->Mode == XSDPS_DDR52_MODE)) { if (ExtCsd[EXT_CSD_HS_TIMING_BYTE] != EXT_CSD_HS_TIMING_HIGH) { Status = XST_FAILURE; goto RETURN_PATH; @@ -1476,10 +1439,10 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to set the clock to the passed frequency. +* Sets the clock to the passed frequency. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param SelFreq is the selected frequency +* @param InstancePtr Pointer to the instance to be worked on. +* @param SelFreq Selected frequency * * @return None * @@ -1493,7 +1456,7 @@ s32 XSdPs_SetClock(XSdPs *InstancePtr, u32 SelFreq) /* Disable clock */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_CLK_CTRL_OFFSET, 0U); + XSDPS_CLK_CTRL_OFFSET, 0U); /* If selected frequency is zero, return from here */ if (SelFreq == 0U) { @@ -1504,30 +1467,30 @@ s32 XSdPs_SetClock(XSdPs *InstancePtr, u32 SelFreq) #ifdef VERSAL_NET if (InstancePtr->CardType == XSDPS_CHIP_EMMC) { Reg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_PHYCTRLREG2_OFFSET); + XSDPS_PHYCTRLREG2_OFFSET); Reg &= ~XSDPS_PHYREG2_DLL_EN_MASK; if ((InstancePtr->Mode != XSDPS_DEFAULT_SPEED_MODE) && - (SelFreq > XSDPD_MIN_DLL_MODE_CLK)) { + (SelFreq > XSDPD_MIN_DLL_MODE_CLK)) { XSdPs_WriteReg(InstancePtr->Config.BaseAddress, - XSDPS_PHYCTRLREG2_OFFSET, Reg); + XSDPS_PHYCTRLREG2_OFFSET, Reg); Reg &= ~XSDPS_PHYREG2_FREQ_SEL_MASK; Reg &= ~XSDPS_PHYREG2_TRIM_ICP_MASK; Reg &= ~XSDPS_PHYREG2_DLYTX_SEL_MASK; Reg &= ~XSDPS_PHYREG2_DLYRX_SEL_MASK; Reg |= (XSDPS_PHYREG2_TRIM_ICP_DEF_VAL << - XSDPS_PHYREG2_TRIM_ICP_SHIFT); + XSDPS_PHYREG2_TRIM_ICP_SHIFT); if (SelFreq == XSDPS_MMC_DDR_MAX_CLK) { Reg |= (XSDPS_FREQ_SEL_50MHZ_79MHz << - XSDPS_PHYREG2_FREQ_SEL_SHIFT); + XSDPS_PHYREG2_FREQ_SEL_SHIFT); } XSdPs_WriteReg(InstancePtr->Config.BaseAddress, - XSDPS_PHYCTRLREG2_OFFSET, Reg); + XSDPS_PHYCTRLREG2_OFFSET, Reg); } else { Reg |= XSDPS_PHYREG2_DLYTX_SEL_MASK; Reg |= XSDPS_PHYREG2_DLYRX_SEL_MASK; XSdPs_WriteReg(InstancePtr->Config.BaseAddress, - XSDPS_PHYCTRLREG2_OFFSET, Reg); + XSDPS_PHYCTRLREG2_OFFSET, Reg); } } #endif @@ -1543,17 +1506,17 @@ s32 XSdPs_SetClock(XSdPs *InstancePtr, u32 SelFreq) #ifdef VERSAL_NET if ((InstancePtr->CardType == XSDPS_CHIP_EMMC) && - (InstancePtr->Mode != XSDPS_DEFAULT_SPEED_MODE) && - (SelFreq > XSDPD_MIN_DLL_MODE_CLK)) { + (InstancePtr->Mode != XSDPS_DEFAULT_SPEED_MODE) && + (SelFreq > XSDPD_MIN_DLL_MODE_CLK)) { Reg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_PHYCTRLREG2_OFFSET); + XSDPS_PHYCTRLREG2_OFFSET); Reg |= XSDPS_PHYREG2_DLL_EN_MASK; XSdPs_WriteReg(InstancePtr->Config.BaseAddress, - XSDPS_PHYCTRLREG2_OFFSET, Reg); + XSDPS_PHYCTRLREG2_OFFSET, Reg); /* Wait for 1000 micro sec for DLL READY */ Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_PHYCTRLREG2_OFFSET, - XSDPS_PHYREG2_DLL_RDY_MASK, XSDPS_PHYREG2_DLL_RDY_MASK, Timeout); + XSDPS_PHYREG2_DLL_RDY_MASK, XSDPS_PHYREG2_DLL_RDY_MASK, Timeout); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH ; @@ -1571,9 +1534,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function checks if the voltage is set to 1.8V or not. +* Checks if the voltage is set to 1.8 V or not. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if voltage is 1.8V @@ -1585,7 +1548,7 @@ s32 XSdPs_CheckVoltage18(XSdPs *InstancePtr) u32 Status; if ((XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL2_OFFSET) & XSDPS_HC2_1V8_EN_MASK) == 0U) { + XSDPS_HOST_CTRL2_OFFSET) & XSDPS_HC2_1V8_EN_MASK) == 0U) { Status = XST_FAILURE; goto RETURN_PATH; } @@ -1599,10 +1562,10 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function initializes the command sequence. +* Initializes the command sequence. * -* @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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param Arg Address passed by the user that is to be sent as * argument along with the command. * @param BlkCnt - Block count passed by the user. * @@ -1625,19 +1588,19 @@ s32 XSdPs_SetupCmd(XSdPs *InstancePtr, u32 Arg, u32 BlkCnt) /* Write block count register */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_BLK_CNT_OFFSET, (u16)BlkCnt); + XSDPS_BLK_CNT_OFFSET, (u16)BlkCnt); XSdPs_WriteReg8(InstancePtr->Config.BaseAddress, XSDPS_TIMEOUT_CTRL_OFFSET, 0xEU); /* Write argument register */ XSdPs_WriteReg(InstancePtr->Config.BaseAddress, - XSDPS_ARGMT_OFFSET, Arg); + XSDPS_ARGMT_OFFSET, Arg); XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_NORM_INTR_STS_OFFSET, XSDPS_NORM_INTR_ALL_MASK); + XSDPS_NORM_INTR_STS_OFFSET, XSDPS_NORM_INTR_ALL_MASK); XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_ERR_INTR_STS_OFFSET, XSDPS_ERROR_INTR_ALL_MASK); + XSDPS_ERR_INTR_STS_OFFSET, XSDPS_ERROR_INTR_ALL_MASK); Status = XST_SUCCESS; @@ -1648,10 +1611,10 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function initiates the Cmd transfer to SD card. +* Initiates the Cmd transfer to SD card. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param Cmd is the command to be sent +* @param InstancePtr Pointer to the instance to be worked on. +* @param Cmd Command to be sent * * @return * - XST_SUCCESS if initialization was successful @@ -1680,16 +1643,16 @@ s32 XSdPs_SendCmd(XSdPs *InstancePtr, u32 Cmd) */ if ((Cmd != CMD21) && (Cmd != CMD19)) { PresentStateReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_PRES_STATE_OFFSET); + XSDPS_PRES_STATE_OFFSET); if (((PresentStateReg & XSDPS_PSR_INHIBIT_DAT_MASK) != 0U) && - ((CommandReg & XSDPS_DAT_PRESENT_SEL_MASK) != 0U)) { + ((CommandReg & XSDPS_DAT_PRESENT_SEL_MASK) != 0U)) { Status = XST_FAILURE; goto RETURN_PATH; } } XSdPs_WriteReg(InstancePtr->Config.BaseAddress, XSDPS_XFER_MODE_OFFSET, - (CommandReg << 16) | InstancePtr->TransferMode); + (CommandReg << 16) | InstancePtr->TransferMode); Status = XST_SUCCESS; @@ -1701,10 +1664,10 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function performs Set the address of the first write block to be erased. +* Sets the address of the first write block to be erased. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param StartAddr is the address of the first write block. +* @param InstancePtr Pointer to the instance to be worked on. +* @param StartAddr Address of the first write block. * * @return * - XST_SUCCESS if Set start Address is successful @@ -1727,10 +1690,10 @@ s32 XSdPs_SetStartAddr(XSdPs *InstancePtr, u32 StartAddr) /*****************************************************************************/ /** * @brief -* This function performs Set the address of the last write block to be erased. +* Sets the address of the last write block to be erased. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param EndAddr is the address of the last write block. +* @param InstancePtr Pointer to the instance to be worked on. +* @param EndAddr Address of the last write block. * * @return * - XST_SUCCESS if Set End Address is successful. @@ -1753,9 +1716,9 @@ s32 XSdPs_SetEndAddr(XSdPs *InstancePtr, u32 EndAddr) /*****************************************************************************/ /** * @brief -* This function send Erase command to the device and wait for transfer complete +* Sends Erase command to the device and wait for transfer complete. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if erase operation is successful diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_core.h b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_core.h index 239c2f1..9a5a289 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_core.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_core.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,10 +8,10 @@ /** * * @file xsdps_core.h -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{ * -* The xsdps_core.h header file contains the identifiers and basic HW access driver +* The xsdps_core.h header file contains the identifiers and basic hardware access driver * functions (or macros) that can be used to access the device. Other driver * functions are defined in xsdps.h. * @@ -27,6 +27,7 @@ * 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. +* 4.2 ap 08/09/23 Add XSdPs_SetTapDelay APIs. * * ******************************************************************************/ @@ -110,6 +111,10 @@ void XSdPs_ConfigInterrupt(XSdPs *InstancePtr); s32 XSdPs_SendErase(XSdPs *InstancePtr); s32 XSdPs_SetEndAddr(XSdPs *InstancePtr, u32 EndAddr); s32 XSdPs_SetStartAddr(XSdPs *InstancePtr, u32 StartAddr); +void XSdPs_SetTapDelay_SDR104(XSdPs *InstancePtr); +void XSdPs_SetTapDelay_SDR50(XSdPs *InstancePtr); +void XSdPs_SetTapDelay_DDR50(XSdPs *InstancePtr); +void XSdPs_SetTapDelay_SDR25(XSdPs *InstancePtr); #ifdef VERSAL_NET u32 XSdPs_Select_HS400(XSdPs *InstancePtr); #endif diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_g.c index 8c533f0..5d3a139 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_g.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,7 +8,7 @@ /** * * @file xsdps_g.c -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{ * * The xsdps_g.c file contains a configuration table that specifies the @@ -54,7 +54,8 @@ XSdPs_Config XSdPs_ConfigTable[] = 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 + XPAR_XSDPS_0_CLK_200_SDR_OTAP_DLY, + XPAR_XSDPS_0_CLK_200_DDR_OTAP_DLY } }; /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_host.c b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_host.c index 5f4165c..26a25dc 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_host.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_host.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,7 +8,7 @@ /** * * @file xsdps_host.c -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{ * * The xsdps_host.c file contains the interface functions of the XSdPs driver. @@ -39,6 +39,8 @@ * sa 01/04/23 Update register bit polling logic to use Xil_WaitForEvent/ * Xil_WaitForEvents API. * sa 01/25/23 Use instance structure to store DMA descriptor tables. +* 4.2 ap 08/09/23 Restructured XSdPs_FrameCmd API +* 4.3 ap 12/22/23 Add support to read custom HS400 tap delay value from design for eMMC. * * ******************************************************************************/ @@ -58,11 +60,109 @@ void XSdps_Smc(XSdPs *InstancePtr, u32 RegOffset, u32 Mask, u32 Val) { (void)Xil_Smc(MMIO_WRITE_SMC_FID, (u64)(InstancePtr->SlcrBaseAddr + - RegOffset) | ((u64)Mask << 32), - (u64)Val, 0, 0, 0, 0, 0); + RegOffset) | ((u64)Mask << 32), + (u64)Val, 0, 0, 0, 0, 0); } #endif +/*****************************************************************************/ +/** +* @brief +* Sets the tap delay for SDR104 uhs mode. +* +* @param InstancePtr Pointer to the instance to be worked on. +* +* @return None +* +*******************************************************************************/ +void XSdPs_SetTapDelay_SDR104(XSdPs *InstancePtr) +{ + if (InstancePtr->Config.OTapDly_SDR_Clk200 != 0U) { + InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_SDR_Clk200; + } else if (InstancePtr->Config.BankNumber == 2U) { + InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD104_B2; + } else { + InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD104_B0; + } +} + +/*****************************************************************************/ +/** +* @brief +* Sets the tap delay for SDR50 uhs mode. +* +* @param InstancePtr Pointer to the instance to be worked on. +* +* @return None +* +*******************************************************************************/ +void XSdPs_SetTapDelay_SDR50(XSdPs *InstancePtr) +{ + if (InstancePtr->Config.OTapDly_SDR_Clk100 != 0U) { + InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_SDR_Clk100; + } else { + InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD50; + } +} + +/*****************************************************************************/ +/** +* @brief +* Sets the tap delay for DDR50 uhs mode. +* +* @param InstancePtr Pointer to the instance to be worked on. +* +* @return None +* +*******************************************************************************/ +void XSdPs_SetTapDelay_DDR50(XSdPs *InstancePtr) +{ + if ((InstancePtr->Config.OTapDly_DDR_Clk50 != 0U) && + (InstancePtr->Config.ITapDly_DDR_Clk50 != 0U)) { + InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_DDR_Clk50; + InstancePtr->ITapDelay = InstancePtr->Config.ITapDly_DDR_Clk50; + if ((InstancePtr->Config.SlotType == XSDPS_SLOTTYPE_SDADIR) && + (InstancePtr->ITapDelay == SD_ITAPDLYSEL_SD_DDR50)) { + InstancePtr->ITapDelay = SD_AUTODIR_ITAPDLYSEL_DDR50; + } + } else if (InstancePtr->Config.SlotType == XSDPS_SLOTTYPE_SDADIR) { + InstancePtr->ITapDelay = SD_AUTODIR_ITAPDLYSEL_DDR50; + InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD_DDR50; + } else { + InstancePtr->ITapDelay = SD_ITAPDLYSEL_SD_DDR50; + InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD_DDR50; + } +} + +/*****************************************************************************/ +/** +* @brief +* Sets the tap delay for SDR25 uhs mode. +* +* @param InstancePtr Pointer to the instance to be worked on. +* +* @return None +* +*******************************************************************************/ +void XSdPs_SetTapDelay_SDR25(XSdPs *InstancePtr) +{ + if ((InstancePtr->Config.OTapDly_SDR_Clk50 != 0U) && + (InstancePtr->Config.ITapDly_SDR_Clk50 != 0U)) { + InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_SDR_Clk50; + InstancePtr->ITapDelay = InstancePtr->Config.ITapDly_SDR_Clk50; + if ((InstancePtr->Config.SlotType == XSDPS_SLOTTYPE_SDADIR) && + (InstancePtr->ITapDelay == SD_ITAPDLYSEL_HSD)) { + InstancePtr->ITapDelay = SD_AUTODIR_ITAPDLYSEL_SDR25; + } + } else if (InstancePtr->Config.SlotType == XSDPS_SLOTTYPE_SDADIR) { + InstancePtr->ITapDelay = SD_AUTODIR_ITAPDLYSEL_SDR25; + InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD_HSD; + } else { + InstancePtr->ITapDelay = SD_ITAPDLYSEL_HSD; + InstancePtr->OTapDelay = SD_OTAPDLYSEL_SD_HSD; + } +} + /*****************************************************************************/ /** * @@ -70,7 +170,7 @@ void XSdps_Smc(XSdPs *InstancePtr, u32 RegOffset, u32 Mask, u32 Val) * Switches the SD card voltage from 3v3 to 1v8 * * -* @param InstancePtr is a pointer to the XSdPs instance. +* @param InstancePtr Pointer to the XSdPs instance. * ******************************************************************************/ s32 XSdPs_Switch_Voltage(XSdPs *InstancePtr) @@ -104,9 +204,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function initiates the transfer to or from SD card. +* Initiates the transfer to or from SD card. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if initialization was successful @@ -119,12 +219,12 @@ s32 XSdPs_SetupTransfer(XSdPs *InstancePtr) s32 Status; 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) { + ((InstancePtr->Host_Caps & XSDPS_CAPS_SLOT_TYPE_MASK) + != XSDPS_CAPS_EMB_SLOT)) { + if (InstancePtr->Config.CardDetect != 0U) { /* Check status to ensure card is initialized */ PresentStateReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_PRES_STATE_OFFSET); + XSDPS_PRES_STATE_OFFSET); if ((PresentStateReg & XSDPS_PSR_CARD_INSRT_MASK) == 0x0U) { Status = XST_FAILURE; goto RETURN_PATH; @@ -133,10 +233,10 @@ s32 XSdPs_SetupTransfer(XSdPs *InstancePtr) } /* Set block size to 512 if not already set */ - if(XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_BLK_SIZE_OFFSET) != XSDPS_BLK_SIZE_512_MASK ) { + if (XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, + XSDPS_BLK_SIZE_OFFSET) != XSDPS_BLK_SIZE_512_MASK ) { Status = XSdPs_SetBlkSize(InstancePtr, - XSDPS_BLK_SIZE_512_MASK); + XSDPS_BLK_SIZE_512_MASK); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH; @@ -153,10 +253,10 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function resets the SD card. +* Resets the SD card. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param Value is the type of reset +* @param InstancePtr Pointer to the instance to be worked on. +* @param Value Type of reset * * @return * - XST_SUCCESS if initialization was successful @@ -177,16 +277,16 @@ s32 XSdPs_Reset(XSdPs *InstancePtr, u8 Value) goto RETURN_PATH ; } - RETURN_PATH: - return Status; +RETURN_PATH: + return Status; } /*****************************************************************************/ /** * @brief -* This function sets bit to start execution of tuning. +* Sets bit to start execution of tuning. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -196,18 +296,18 @@ void XSdPs_SetExecTuning(XSdPs *InstancePtr) u16 CtrlReg; CtrlReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL2_OFFSET); + XSDPS_HOST_CTRL2_OFFSET); CtrlReg |= XSDPS_HC2_EXEC_TNG_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL2_OFFSET, CtrlReg); + XSDPS_HOST_CTRL2_OFFSET, CtrlReg); } /*****************************************************************************/ /** * @brief -* This function does SD mode initialization. +* Initializes SD mode. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if initialization is successful @@ -250,9 +350,9 @@ s32 XSdPs_SdModeInit(XSdPs *InstancePtr) } if (((SCR[2] & SCR_SPEC_VER_3) != 0U) && - (ReadBuff[13] >= UHS_SDR50_SUPPORT) && - (InstancePtr->Config.BusWidth == XSDPS_WIDTH_8) && - (InstancePtr->Switch1v8 == 0U)) { + (ReadBuff[13] >= UHS_SDR50_SUPPORT) && + (InstancePtr->Config.BusWidth == XSDPS_WIDTH_8) && + (InstancePtr->Switch1v8 == 0U)) { InstancePtr->Switch1v8 = 1U; @@ -282,14 +382,14 @@ s32 XSdPs_SdModeInit(XSdPs *InstancePtr) if (SCR[0] != 0U) { /* Check for high speed support */ if (((ReadBuff[13] & HIGH_SPEED_SUPPORT) != 0U) && - (InstancePtr->BusWidth >= XSDPS_4_BIT_WIDTH)) { + (InstancePtr->BusWidth >= XSDPS_4_BIT_WIDTH)) { InstancePtr->Mode = XSDPS_HIGH_SPEED_MODE; if (InstancePtr->Config.OTapDly_SDR_Clk50 && - InstancePtr->Config.ITapDly_SDR_Clk50) { + InstancePtr->Config.ITapDly_SDR_Clk50) { InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_SDR_Clk50; InstancePtr->ITapDelay = InstancePtr->Config.ITapDly_SDR_Clk50; if ((InstancePtr->Config.SlotType == XSDPS_SLOTTYPE_SDADIR) && - (InstancePtr->ITapDelay == SD_ITAPDLYSEL_HSD)) { + (InstancePtr->ITapDelay == SD_ITAPDLYSEL_HSD)) { InstancePtr->ITapDelay = SD_AUTODIR_ITAPDLYSEL_HSD; } } else if (InstancePtr->Config.SlotType == XSDPS_SLOTTYPE_SDADIR) { @@ -325,9 +425,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function does MMC mode initialization. +* Initializes MMC mode. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if initialization is successful @@ -363,8 +463,8 @@ s32 XSdPs_MmcModeInit(XSdPs *InstancePtr) InstancePtr->SectorCount |= (u32)ExtCsd[EXT_CSD_SEC_COUNT_BYTE1]; if (((ExtCsd[EXT_CSD_DEVICE_TYPE_BYTE] & - EXT_CSD_DEVICE_TYPE_HIGH_SPEED) != 0U) && - (InstancePtr->BusWidth >= XSDPS_4_BIT_WIDTH)) { + EXT_CSD_DEVICE_TYPE_HIGH_SPEED) != 0U) && + (InstancePtr->BusWidth >= XSDPS_4_BIT_WIDTH)) { InstancePtr->Mode = XSDPS_HIGH_SPEED_MODE; Status = XSdPs_Change_BusSpeed(InstancePtr); if (Status != XST_SUCCESS) { @@ -393,9 +493,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function does eMMC mode initialization. +* Initializes eMMC mode. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if initialization is successful @@ -414,7 +514,7 @@ s32 XSdPs_EmmcModeInit(XSdPs *InstancePtr) #endif if ((InstancePtr->HC_Version == XSDPS_HC_SPEC_V3) && - (InstancePtr->Config.BusWidth == XSDPS_WIDTH_8)) { + (InstancePtr->Config.BusWidth == XSDPS_WIDTH_8)) { /* in case of eMMC data width 8-bit */ InstancePtr->BusWidth = XSDPS_8_BIT_WIDTH; } else if (InstancePtr->Config.BusWidth == XSDPS_WIDTH_4) { @@ -468,7 +568,7 @@ s32 XSdPs_EmmcModeInit(XSdPs *InstancePtr) } /* Enable Rst_n_Fun bit if it is disabled */ - if(ExtCsd[EXT_CSD_RST_N_FUN_BYTE] == EXT_CSD_RST_N_FUN_TEMP_DIS) { + if (ExtCsd[EXT_CSD_RST_N_FUN_BYTE] == EXT_CSD_RST_N_FUN_TEMP_DIS) { Status = XSdPs_Set_Mmc_ExtCsd(InstancePtr, XSDPS_MMC_RST_FUN_EN_ARG); if (Status != XST_SUCCESS) { Status = XST_FAILURE; @@ -485,9 +585,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function disables the bus power. +* Disables the bus power. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -510,9 +610,9 @@ void XSdPs_DisableBusPower(XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function enables the bus power. +* Enables the bus power. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -538,9 +638,9 @@ void XSdPs_EnableBusPower(XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function enumerates the SD card. +* Enumerates the SD card. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -617,16 +717,16 @@ s32 XSdPs_SdCardEnum(XSdPs *InstancePtr) Status = XST_SUCCESS; - RETURN_PATH: - return Status; +RETURN_PATH: + return Status; } /*****************************************************************************/ /** * @brief -* This function enumerates the MMC card. +* Enumerates the MMC card. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -694,9 +794,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function performs SD tuning. +* Performs SD tuning. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -742,10 +842,10 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to enable the clock. +* Enables the clock. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param ClockReg is the clock value to be set. +* @param InstancePtr Pointer to the instance to be worked on. +* @param ClockReg Clock value to be set. * * @return * - XST_SUCCESS if success @@ -760,11 +860,11 @@ s32 XSdPs_EnableClock(XSdPs *InstancePtr, u16 ClockReg) ClkReg |= (u16)XSDPS_CC_INT_CLK_EN_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_CLK_CTRL_OFFSET, ClkReg); + XSDPS_CLK_CTRL_OFFSET, ClkReg); /* Wait for 150ms for internal clock to stabilize */ Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_CLK_CTRL_OFFSET, - XSDPS_CC_INT_CLK_STABLE_MASK, XSDPS_CC_INT_CLK_STABLE_MASK, Timeout); + XSDPS_CC_INT_CLK_STABLE_MASK, XSDPS_CC_INT_CLK_STABLE_MASK, Timeout); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH ; @@ -773,7 +873,7 @@ s32 XSdPs_EnableClock(XSdPs *InstancePtr, u16 ClockReg) /* Enable SD clock */ ClkReg |= XSDPS_CC_SD_CLK_EN_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_CLK_CTRL_OFFSET, ClkReg); + XSDPS_CLK_CTRL_OFFSET, ClkReg); Status = XST_SUCCESS; @@ -784,10 +884,10 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to calculate the bus speed. +* Calculates the bus speed. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param Arg is the argument to be sent along with the command. +* @param InstancePtr Pointer to the instance to be worked on. +* @param Arg Argument to be sent along with the command. * This could be address or any other information * * @return @@ -801,61 +901,61 @@ s32 XSdPs_CalcBusSpeed(XSdPs *InstancePtr, u32 *Arg) if (InstancePtr->CardType == XSDPS_CARD_SD) { switch (InstancePtr->Mode) { - case XSDPS_UHS_SPEED_MODE_SDR12: - *Arg = XSDPS_SWITCH_CMD_SDR12_SET; - InstancePtr->BusSpeed = XSDPS_SD_SDR12_MAX_CLK; - break; - case XSDPS_UHS_SPEED_MODE_SDR25: - *Arg = XSDPS_SWITCH_CMD_SDR25_SET; - InstancePtr->BusSpeed = XSDPS_SD_SDR25_MAX_CLK; - break; - case XSDPS_UHS_SPEED_MODE_SDR50: - *Arg = XSDPS_SWITCH_CMD_SDR50_SET; - InstancePtr->BusSpeed = XSDPS_SD_SDR50_MAX_CLK; - break; - case XSDPS_UHS_SPEED_MODE_SDR104: - *Arg = XSDPS_SWITCH_CMD_SDR104_SET; - InstancePtr->BusSpeed = XSDPS_SD_SDR104_MAX_CLK; - break; - case XSDPS_UHS_SPEED_MODE_DDR50: - *Arg = XSDPS_SWITCH_CMD_DDR50_SET; - InstancePtr->BusSpeed = XSDPS_SD_DDR50_MAX_CLK; - break; - case XSDPS_HIGH_SPEED_MODE: - *Arg = XSDPS_SWITCH_CMD_HS_SET; - InstancePtr->BusSpeed = XSDPS_CLK_50_MHZ; - break; - default: - Status = XST_FAILURE; - break; + case XSDPS_UHS_SPEED_MODE_SDR12: + *Arg = XSDPS_SWITCH_CMD_SDR12_SET; + InstancePtr->BusSpeed = XSDPS_SD_SDR12_MAX_CLK; + break; + case XSDPS_UHS_SPEED_MODE_SDR25: + *Arg = XSDPS_SWITCH_CMD_SDR25_SET; + InstancePtr->BusSpeed = XSDPS_SD_SDR25_MAX_CLK; + break; + case XSDPS_UHS_SPEED_MODE_SDR50: + *Arg = XSDPS_SWITCH_CMD_SDR50_SET; + InstancePtr->BusSpeed = XSDPS_SD_SDR50_MAX_CLK; + break; + case XSDPS_UHS_SPEED_MODE_SDR104: + *Arg = XSDPS_SWITCH_CMD_SDR104_SET; + InstancePtr->BusSpeed = XSDPS_SD_SDR104_MAX_CLK; + break; + case XSDPS_UHS_SPEED_MODE_DDR50: + *Arg = XSDPS_SWITCH_CMD_DDR50_SET; + InstancePtr->BusSpeed = XSDPS_SD_DDR50_MAX_CLK; + break; + case XSDPS_HIGH_SPEED_MODE: + *Arg = XSDPS_SWITCH_CMD_HS_SET; + InstancePtr->BusSpeed = XSDPS_CLK_50_MHZ; + break; + default: + Status = XST_FAILURE; + break; } } else { switch (InstancePtr->Mode) { #ifdef VERSAL_NET - case XSDPS_HS400_MODE: - if (InstancePtr->IsTuningDone == 0U) { - *Arg = XSDPS_MMC_HS200_ARG; - } else { - *Arg = XSDPS_MMC_HS400_ARG; - } - InstancePtr->BusSpeed = XSDPS_MMC_HS200_MAX_CLK; - break; + case XSDPS_HS400_MODE: + if (InstancePtr->IsTuningDone == 0U) { + *Arg = XSDPS_MMC_HS200_ARG; + } else { + *Arg = XSDPS_MMC_HS400_ARG; + } + InstancePtr->BusSpeed = XSDPS_MMC_HS200_MAX_CLK; + break; #endif - case XSDPS_HS200_MODE: - *Arg = XSDPS_MMC_HS200_ARG; - InstancePtr->BusSpeed = XSDPS_MMC_HS200_MAX_CLK; - break; - case XSDPS_DDR52_MODE: - *Arg = XSDPS_MMC_HIGH_SPEED_ARG; - InstancePtr->BusSpeed = XSDPS_MMC_DDR_MAX_CLK; - break; - case XSDPS_HIGH_SPEED_MODE: - *Arg = XSDPS_MMC_HIGH_SPEED_ARG; - InstancePtr->BusSpeed = XSDPS_MMC_HSD_MAX_CLK; - break; - default: - Status = XST_FAILURE; - break; + case XSDPS_HS200_MODE: + *Arg = XSDPS_MMC_HS200_ARG; + InstancePtr->BusSpeed = XSDPS_MMC_HS200_MAX_CLK; + break; + case XSDPS_DDR52_MODE: + *Arg = XSDPS_MMC_HIGH_SPEED_ARG; + InstancePtr->BusSpeed = XSDPS_MMC_DDR_MAX_CLK; + break; + case XSDPS_HIGH_SPEED_MODE: + *Arg = XSDPS_MMC_HIGH_SPEED_ARG; + InstancePtr->BusSpeed = XSDPS_MMC_HSD_MAX_CLK; + break; + default: + Status = XST_FAILURE; + break; } } @@ -867,10 +967,10 @@ s32 XSdPs_CalcBusSpeed(XSdPs *InstancePtr, u32 *Arg) * @brief * This function is used to do the DMA transfer to or from SD card. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param BlkCnt - Block count passed by the user. -* @param BlkSize - Block size passed by the user. -* @param Buff - Pointer to the data buffer for a DMA transfer. +* @param InstancePtr Pointer to the instance to be worked on. +* @param BlkCnt Block count passed by the user. +* @param BlkSize Block size passed by the user. +* @param Buff Pointer to the data buffer for a DMA transfer. * * @return * - XST_SUCCESS if initialization was successful @@ -883,7 +983,7 @@ void XSdPs_SetupReadDma(XSdPs *InstancePtr, u16 BlkCnt, u16 BlkSize, u8 *Buff) BlkSize &= XSDPS_BLK_SIZE_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_BLK_SIZE_OFFSET, BlkSize); + XSDPS_BLK_SIZE_OFFSET, BlkSize); if (InstancePtr->Dma64BitAddr >= ADDRESS_BEYOND_32BIT) { XSdPs_SetupADMA2DescTbl64Bit(InstancePtr, BlkCnt); @@ -891,17 +991,17 @@ void XSdPs_SetupReadDma(XSdPs *InstancePtr, u16 BlkCnt, u16 BlkSize, u8 *Buff) XSdPs_SetupADMA2DescTbl(InstancePtr, BlkCnt, Buff); if (InstancePtr->Config.IsCacheCoherent == 0U) { Xil_DCacheInvalidateRange((INTPTR)Buff, - ((INTPTR)BlkCnt * (INTPTR)BlkSize)); + ((INTPTR)BlkCnt * (INTPTR)BlkSize)); } } if (BlkCnt == 1U) { InstancePtr->TransferMode = XSDPS_TM_BLK_CNT_EN_MASK | - XSDPS_TM_DAT_DIR_SEL_MASK | XSDPS_TM_DMA_EN_MASK; + XSDPS_TM_DAT_DIR_SEL_MASK | XSDPS_TM_DMA_EN_MASK; } else { InstancePtr->TransferMode = XSDPS_TM_AUTO_CMD12_EN_MASK | - XSDPS_TM_BLK_CNT_EN_MASK | XSDPS_TM_DAT_DIR_SEL_MASK | - XSDPS_TM_DMA_EN_MASK | XSDPS_TM_MUL_SIN_BLK_SEL_MASK; + XSDPS_TM_BLK_CNT_EN_MASK | XSDPS_TM_DAT_DIR_SEL_MASK | + XSDPS_TM_DMA_EN_MASK | XSDPS_TM_MUL_SIN_BLK_SEL_MASK; } } @@ -910,10 +1010,10 @@ void XSdPs_SetupReadDma(XSdPs *InstancePtr, u16 BlkCnt, u16 BlkSize, u8 *Buff) * @brief * This function is used to do the DMA transfer to or from SD card. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param BlkCnt - Block count passed by the user. -* @param BlkSize - Block size passed by the user. -* @param Buff - Pointer to the data buffer for a DMA transfer. +* @param InstancePtr Pointer to the instance to be worked on. +* @param BlkCnt Block count passed by the user. +* @param BlkSize Block size passed by the user. +* @param Buff Pointer to the data buffer for a DMA transfer. * * @return * - XST_SUCCESS if initialization was successful @@ -926,7 +1026,7 @@ void XSdPs_SetupWriteDma(XSdPs *InstancePtr, u16 BlkCnt, u16 BlkSize, const u8 * BlkSize &= XSDPS_BLK_SIZE_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_BLK_SIZE_OFFSET, BlkSize); + XSDPS_BLK_SIZE_OFFSET, BlkSize); if (InstancePtr->Dma64BitAddr >= ADDRESS_BEYOND_32BIT) { XSdPs_SetupADMA2DescTbl64Bit(InstancePtr, BlkCnt); @@ -934,17 +1034,17 @@ void XSdPs_SetupWriteDma(XSdPs *InstancePtr, u16 BlkCnt, u16 BlkSize, const u8 * XSdPs_SetupADMA2DescTbl(InstancePtr, BlkCnt, Buff); if (InstancePtr->Config.IsCacheCoherent == 0U) { Xil_DCacheFlushRange((INTPTR)Buff, - ((INTPTR)BlkCnt * (INTPTR)BlkSize)); + ((INTPTR)BlkCnt * (INTPTR)BlkSize)); } } if (BlkCnt == 1U) { InstancePtr->TransferMode = XSDPS_TM_BLK_CNT_EN_MASK | - XSDPS_TM_DMA_EN_MASK; + XSDPS_TM_DMA_EN_MASK; } else { InstancePtr->TransferMode = XSDPS_TM_AUTO_CMD12_EN_MASK | - XSDPS_TM_BLK_CNT_EN_MASK | - XSDPS_TM_MUL_SIN_BLK_SEL_MASK | XSDPS_TM_DMA_EN_MASK; + XSDPS_TM_BLK_CNT_EN_MASK | + XSDPS_TM_MUL_SIN_BLK_SEL_MASK | XSDPS_TM_DMA_EN_MASK; } } @@ -952,16 +1052,15 @@ void XSdPs_SetupWriteDma(XSdPs *InstancePtr, u16 BlkCnt, u16 BlkSize, const u8 * /** * * @brief -* API to setup ADMA2 descriptor table for 32-bit DMA +* API to setup ADMA2 descriptor table for 32-bit DMA. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param BlkCnt - block count. -* @param Buff pointer to data buffer. +* @param InstancePtr Pointer to the XSdPs instance. +* @param BlkCnt Block count. +* @param Buff Pointer to data buffer. * * @return None * -* @note None. * ******************************************************************************/ void XSdPs_Setup32ADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff) @@ -972,13 +1071,13 @@ void XSdPs_Setup32ADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff) /* Setup ADMA2 - Write descriptor table and point ADMA SAR to it */ BlkSize = (u32)XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_BLK_SIZE_OFFSET) & - XSDPS_BLK_SIZE_MASK; + XSDPS_BLK_SIZE_OFFSET) & + XSDPS_BLK_SIZE_MASK; - if((BlkCnt*BlkSize) < XSDPS_DESC_MAX_LENGTH) { + if ((BlkCnt * BlkSize) < XSDPS_DESC_MAX_LENGTH) { TotalDescLines = 1U; } else { - TotalDescLines = ((BlkCnt*BlkSize) / XSDPS_DESC_MAX_LENGTH); + TotalDescLines = ((BlkCnt * BlkSize) / XSDPS_DESC_MAX_LENGTH); if (((BlkCnt * BlkSize) % XSDPS_DESC_MAX_LENGTH) != 0U) { TotalDescLines += 1U; } @@ -986,27 +1085,27 @@ void XSdPs_Setup32ADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff) for (DescNum = 0U; DescNum < (TotalDescLines - 1U); DescNum++) { InstancePtr->Adma2_DescrTbl32[DescNum].Address = - (u32)((UINTPTR)Buff + ((UINTPTR)DescNum*XSDPS_DESC_MAX_LENGTH)); + (u32)((UINTPTR)Buff + ((UINTPTR)DescNum * XSDPS_DESC_MAX_LENGTH)); InstancePtr->Adma2_DescrTbl32[DescNum].Attribute = - XSDPS_DESC_TRAN | XSDPS_DESC_VALID; + XSDPS_DESC_TRAN | XSDPS_DESC_VALID; InstancePtr->Adma2_DescrTbl32[DescNum].Length = 0U; } InstancePtr->Adma2_DescrTbl32[TotalDescLines - 1U].Address = - (u32)((UINTPTR)Buff + ((UINTPTR)DescNum*XSDPS_DESC_MAX_LENGTH)); + (u32)((UINTPTR)Buff + ((UINTPTR)DescNum * XSDPS_DESC_MAX_LENGTH)); InstancePtr->Adma2_DescrTbl32[TotalDescLines - 1U].Attribute = - XSDPS_DESC_TRAN | XSDPS_DESC_END | XSDPS_DESC_VALID; + XSDPS_DESC_TRAN | XSDPS_DESC_END | XSDPS_DESC_VALID; InstancePtr->Adma2_DescrTbl32[TotalDescLines - 1U].Length = - (u16)((BlkCnt*BlkSize) - (u32)(DescNum*XSDPS_DESC_MAX_LENGTH)); + (u16)((BlkCnt * BlkSize) - (u32)(DescNum * XSDPS_DESC_MAX_LENGTH)); XSdPs_WriteReg(InstancePtr->Config.BaseAddress, XSDPS_ADMA_SAR_OFFSET, - (u32)((UINTPTR)&(InstancePtr->Adma2_DescrTbl32[0]) & ~(u32)0x0U)); + (u32)((UINTPTR) & (InstancePtr->Adma2_DescrTbl32[0]) & ~(u32)0x0U)); if (InstancePtr->Config.IsCacheCoherent == 0U) { - Xil_DCacheFlushRange((INTPTR)&(InstancePtr->Adma2_DescrTbl32[0]), - (INTPTR)sizeof(XSdPs_Adma2Descriptor32) * (INTPTR)32U); + Xil_DCacheFlushRange((INTPTR) & (InstancePtr->Adma2_DescrTbl32[0]), + (INTPTR)sizeof(XSdPs_Adma2Descriptor32) * (INTPTR)32U); } } @@ -1014,17 +1113,15 @@ void XSdPs_Setup32ADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff) /** * * @brief -* API to setup ADMA2 descriptor table for 64-bit DMA +* API to setup ADMA2 descriptor table for 64-bit DMA. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param BlkCnt - block count. -* @param Buff pointer to data buffer. +* @param InstancePtr Pointer to the XSdPs instance. +* @param BlkCnt Block count. +* @param Buff Pointer to data buffer. * * @return None * -* @note None. -* ******************************************************************************/ void XSdPs_Setup64ADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff) { @@ -1034,13 +1131,13 @@ void XSdPs_Setup64ADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff) /* Setup ADMA2 - Write descriptor table and point ADMA SAR to it */ BlkSize = (u32)XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_BLK_SIZE_OFFSET) & - XSDPS_BLK_SIZE_MASK; + XSDPS_BLK_SIZE_OFFSET) & + XSDPS_BLK_SIZE_MASK; - if((BlkCnt*BlkSize) < XSDPS_DESC_MAX_LENGTH) { + if ((BlkCnt * BlkSize) < XSDPS_DESC_MAX_LENGTH) { TotalDescLines = 1U; } else { - TotalDescLines = ((BlkCnt*BlkSize) / XSDPS_DESC_MAX_LENGTH); + TotalDescLines = ((BlkCnt * BlkSize) / XSDPS_DESC_MAX_LENGTH); if (((BlkCnt * BlkSize) % XSDPS_DESC_MAX_LENGTH) != 0U) { TotalDescLines += 1U; } @@ -1048,42 +1145,42 @@ void XSdPs_Setup64ADMA2DescTbl(XSdPs *InstancePtr, u32 BlkCnt, const u8 *Buff) for (DescNum = 0U; DescNum < (TotalDescLines - 1U); DescNum++) { InstancePtr->Adma2_DescrTbl64[DescNum].Address = - ((UINTPTR)Buff + ((UINTPTR)DescNum*XSDPS_DESC_MAX_LENGTH)); + ((UINTPTR)Buff + ((UINTPTR)DescNum * XSDPS_DESC_MAX_LENGTH)); InstancePtr->Adma2_DescrTbl64[DescNum].Attribute = - XSDPS_DESC_TRAN | XSDPS_DESC_VALID; + XSDPS_DESC_TRAN | XSDPS_DESC_VALID; InstancePtr->Adma2_DescrTbl64[DescNum].Length = 0U; } InstancePtr->Adma2_DescrTbl64[TotalDescLines - 1U].Address = - (u64)((UINTPTR)Buff + ((UINTPTR)DescNum*XSDPS_DESC_MAX_LENGTH)); + (u64)((UINTPTR)Buff + ((UINTPTR)DescNum * XSDPS_DESC_MAX_LENGTH)); InstancePtr->Adma2_DescrTbl64[TotalDescLines - 1U].Attribute = - XSDPS_DESC_TRAN | XSDPS_DESC_END | XSDPS_DESC_VALID; + XSDPS_DESC_TRAN | XSDPS_DESC_END | XSDPS_DESC_VALID; InstancePtr->Adma2_DescrTbl64[TotalDescLines - 1U].Length = - (u16)((BlkCnt*BlkSize) - (u32)(DescNum*XSDPS_DESC_MAX_LENGTH)); + (u16)((BlkCnt * BlkSize) - (u32)(DescNum * XSDPS_DESC_MAX_LENGTH)); #if defined(__aarch64__) || defined(__arch64__) XSdPs_WriteReg(InstancePtr->Config.BaseAddress, XSDPS_ADMA_SAR_EXT_OFFSET, - (u32)((UINTPTR)(InstancePtr->Adma2_DescrTbl64)>>32U)); + (u32)((UINTPTR)(InstancePtr->Adma2_DescrTbl64) >> 32U)); #endif XSdPs_WriteReg(InstancePtr->Config.BaseAddress, XSDPS_ADMA_SAR_OFFSET, - (u32)((UINTPTR)&(InstancePtr->Adma2_DescrTbl64[0]) & ~(u32)0x0U)); + (u32)((UINTPTR) & (InstancePtr->Adma2_DescrTbl64[0]) & ~(u32)0x0U)); if (InstancePtr->Config.IsCacheCoherent == 0U) { - Xil_DCacheFlushRange((INTPTR)&(InstancePtr->Adma2_DescrTbl64[0]), - (INTPTR)sizeof(XSdPs_Adma2Descriptor64) * (INTPTR)32U); + Xil_DCacheFlushRange((INTPTR) & (InstancePtr->Adma2_DescrTbl64[0]), + (INTPTR)sizeof(XSdPs_Adma2Descriptor64) * (INTPTR)32U); } } /*****************************************************************************/ /** * @brief -* This function is used calculate the clock divisor value. +* Calculates the clock divisor value. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param SelFreq is the selected frequency +* @param InstancePtr Pointer to the instance to be worked on. +* @param SelFreq Selected frequency * * @return Clock divisor value * @@ -1126,11 +1223,11 @@ u32 XSdPs_CalcClock(XSdPs *InstancePtr, u32 SelFreq) /** * * @brief -* API to Set or Reset the DLL +* API to Set or Reset the DLL. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param EnRst is a flag indicating whether to Assert or De-assert Reset. +* @param InstancePtr Pointer to the XSdPs instance. +* @param EnRst Flag indicating whether to Assert or De-assert Reset. * * @return None * @@ -1186,11 +1283,10 @@ void XSdPs_DllRstCtrl(XSdPs *InstancePtr, u8 EnRst) * Function to configure the Tap Delays. * * -* @param InstancePtr is a pointer to the XSdPs instance. +* @param InstancePtr Pointer to the XSdPs instance. * * @return None * -* @note None. * ******************************************************************************/ void XSdPs_ConfigTapDelay(XSdPs *InstancePtr) @@ -1238,7 +1334,7 @@ void XSdPs_ConfigTapDelay(XSdPs *InstancePtr) XSdps_Smc(InstancePtr, SD_ITAPDLY, SD0_ITAPCHGWIN, 0U); } else { XSdps_Smc(InstancePtr, SD_ITAPDLY, (SD0_ITAPDLY_SEL_MASK | - SD0_ITAPCHGWIN | SD0_ITAPDLYENA), 0x0); + SD0_ITAPCHGWIN | SD0_ITAPDLYENA), 0x0); } if (OTapDelay != 0U) { XSdps_Smc(InstancePtr, SD_OTAPDLY, SD0_OTAPDLY_SEL_MASK, OTapDelay); @@ -1287,7 +1383,7 @@ void XSdPs_ConfigTapDelay(XSdPs *InstancePtr) XSdps_Smc(InstancePtr, SD_ITAPDLY, SD1_ITAPCHGWIN, 0U); } else { XSdps_Smc(InstancePtr, SD_ITAPDLY, (SD1_ITAPDLY_SEL_MASK | - SD1_ITAPCHGWIN | SD1_ITAPDLYENA), 0x0); + SD1_ITAPCHGWIN | SD1_ITAPDLYENA), 0x0); } if (OTapDelay != 0U) { XSdps_Smc(InstancePtr, SD_OTAPDLY, SD1_OTAPDLY_SEL_MASK, OTapDelay); @@ -1331,9 +1427,9 @@ void XSdPs_ConfigTapDelay(XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function is used to set voltage to 1.8V. +* Sets voltage to 1.8 V. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if successful @@ -1347,10 +1443,10 @@ s32 XSdPs_SetVoltage18(XSdPs *InstancePtr) /* Enabling 1.8V in controller */ CtrlReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL2_OFFSET); + XSDPS_HOST_CTRL2_OFFSET); CtrlReg |= XSDPS_HC2_1V8_EN_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, XSDPS_HOST_CTRL2_OFFSET, - CtrlReg); + CtrlReg); /* Wait minimum 5mSec */ (void)usleep(5000U); @@ -1367,9 +1463,9 @@ s32 XSdPs_SetVoltage18(XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function is used configure the Power Level. +* Configures the Power Level. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -1397,9 +1493,9 @@ void XSdPs_ConfigPower(XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function is used configure the DMA. +* Configures the DMA. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -1422,9 +1518,9 @@ void XSdPs_ConfigDma(XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function is used configure the Interrupts. +* Configures the Interrupts. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -1433,30 +1529,30 @@ void XSdPs_ConfigInterrupt(XSdPs *InstancePtr) { /* Enable all interrupt status except card interrupt initially */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_NORM_INTR_STS_EN_OFFSET, - XSDPS_NORM_INTR_ALL_MASK & (~XSDPS_INTR_CARD_MASK)); + XSDPS_NORM_INTR_STS_EN_OFFSET, + XSDPS_NORM_INTR_ALL_MASK & (~XSDPS_INTR_CARD_MASK)); XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_ERR_INTR_STS_EN_OFFSET, - XSDPS_ERROR_INTR_ALL_MASK); + XSDPS_ERR_INTR_STS_EN_OFFSET, + XSDPS_ERROR_INTR_ALL_MASK); /* Disable all interrupt signals by default. */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_NORM_INTR_SIG_EN_OFFSET, 0x0U); + XSDPS_NORM_INTR_SIG_EN_OFFSET, 0x0U); XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_ERR_INTR_SIG_EN_OFFSET, 0x0U); + XSDPS_ERR_INTR_SIG_EN_OFFSET, 0x0U); } /*****************************************************************************/ /** -* This function does SD command generation. +* Generates SD command. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param Cmd is the command to be sent. -* @param Arg is the argument to be sent along with the command. +* @param InstancePtr Pointer to the instance to be worked on. +* @param Cmd Command to be sent. +* @param Arg Argument to be sent along with the command. * This could be address or any other information -* @param BlkCnt - Block count passed by the user. +* @param BlkCnt Block count passed by the user. * * @return * - XST_SUCCESS if initialization was successful @@ -1485,50 +1581,51 @@ s32 XSdPs_CmdTransfer(XSdPs *InstancePtr, u32 Cmd, u32 Arg, u32 BlkCnt) /* Polling for response for now */ Mask = XSDPS_INTR_ERR_MASK | XSDPS_INTR_CC_MASK; - if ((Cmd == CMD21) || (Cmd == CMD19)) + if ((Cmd == CMD21) || (Cmd == CMD19)) { Mask |= XSDPS_INTR_BRR_MASK; + } Status = Xil_WaitForEvents(InstancePtr->Config.BaseAddress + XSDPS_NORM_INTR_STS_OFFSET, - Mask, Mask, Timeout, &StatusReg); + Mask, Mask, Timeout, &StatusReg); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH; - } - - if (((Cmd == CMD21) || (Cmd == CMD19)) && (StatusReg & XSDPS_INTR_BRR_MASK)) { - XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_NORM_INTR_STS_OFFSET, XSDPS_INTR_BRR_MASK); } - if ((StatusReg & XSDPS_INTR_ERR_MASK) != 0) { + + if (((Cmd == CMD21) || (Cmd == CMD19)) && (StatusReg & XSDPS_INTR_BRR_MASK) != 0U) { + XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, + XSDPS_NORM_INTR_STS_OFFSET, XSDPS_INTR_BRR_MASK); + } + if ((StatusReg & XSDPS_INTR_ERR_MASK) != 0U) { Status = (s32)XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_ERR_INTR_STS_OFFSET); + XSDPS_ERR_INTR_STS_OFFSET); if (((u32)Status & ~XSDPS_INTR_ERR_CT_MASK) == 0U) { Status = XSDPS_CT_ERROR; } /* Write to clear error bits */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_ERR_INTR_STS_OFFSET, - XSDPS_ERROR_INTR_ALL_MASK); + XSDPS_ERR_INTR_STS_OFFSET, + XSDPS_ERROR_INTR_ALL_MASK); goto RETURN_PATH; } /* Write to clear bit */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_NORM_INTR_STS_OFFSET, - XSDPS_INTR_CC_MASK); + XSDPS_NORM_INTR_STS_OFFSET, + XSDPS_INTR_CC_MASK); Status = XST_SUCCESS; RETURN_PATH: - return Status; + return Status; } /*****************************************************************************/ /** -* This function is used to check if the transfer is completed successfully. +* Checks if the transfer is completed successfully. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return None * @@ -1546,24 +1643,24 @@ s32 XSdps_CheckTransferDone(XSdPs *InstancePtr) */ Mask = XSDPS_INTR_ERR_MASK | XSDPS_INTR_TC_MASK; Status = Xil_WaitForEvents(InstancePtr->Config.BaseAddress + XSDPS_NORM_INTR_STS_OFFSET, - Mask, Mask, Timeout, &StatusReg); + Mask, Mask, Timeout, &StatusReg); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH; } - if ((StatusReg & XSDPS_INTR_ERR_MASK) != 0) { + if ((StatusReg & XSDPS_INTR_ERR_MASK) != 0U) { /* Write to clear error bits */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_ERR_INTR_STS_OFFSET, - XSDPS_ERROR_INTR_ALL_MASK); + XSDPS_ERR_INTR_STS_OFFSET, + XSDPS_ERROR_INTR_ALL_MASK); Status = XST_FAILURE; goto RETURN_PATH; } /* Write to clear bit */ XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_NORM_INTR_STS_OFFSET, XSDPS_INTR_TC_MASK); + XSDPS_NORM_INTR_STS_OFFSET, XSDPS_INTR_TC_MASK); Status = XST_SUCCESS; @@ -1574,10 +1671,10 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to check if the CMD/DATA bus is idle or not. +* Checks if the CMD/DATA bus is idle or not. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param Value is to selct Cmd bus or Dat bus +* @param InstancePtr Pointer to the instance to be worked on. +* @param Value Value to be selected Cmd bus or Dat bus. * * @return None * @@ -1589,12 +1686,12 @@ s32 XSdPs_CheckBusIdle(XSdPs *InstancePtr, u32 Value) s32 Status; PresentStateReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, - XSDPS_PRES_STATE_OFFSET); + XSDPS_PRES_STATE_OFFSET); /* Check for Card Present */ if ((PresentStateReg & XSDPS_PSR_CARD_INSRT_MASK) != 0U) { /* Check for SD idle */ Status = Xil_WaitForEvent(InstancePtr->Config.BaseAddress + XSDPS_PRES_STATE_OFFSET, - Value, 0U, Timeout); + Value, 0U, Timeout); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH ; @@ -1610,17 +1707,19 @@ RETURN_PATH: /** * @brief * This function frames the Command register for a particular command. -* Note that this generates only the command register value i.e. -* the upper 16 bits of the transfer mode and command register. -* This value is already shifted to be upper 16 bits and can be directly -* OR'ed with transfer mode register value. * -* @param InstancePtr is a pointer to the instance to be worked on. -* @param Cmd is the Command to be sent. +* +* @param InstancePtr Pointer to the instance to be worked on. +* @param Cmd Command to be sent. * * @return Command register value complete with response type and * data, CRC and index related flags. * +* @note This generates only the command register value i.e. +* the upper 16 bits of the transfer mode and command register. +* This value is already shifted to be upper 16 bits and can be directly +* OR'ed with transfer mode register value. +* ******************************************************************************/ u32 XSdPs_FrameCmd(XSdPs *InstancePtr, u32 Cmd) { @@ -1628,102 +1727,76 @@ u32 XSdPs_FrameCmd(XSdPs *InstancePtr, u32 Cmd) RetVal = Cmd; - switch(Cmd) { - case CMD0: - RetVal |= RESP_NONE; - break; - case CMD1: - RetVal |= RESP_R3; - break; - case CMD2: - RetVal |= RESP_R2; - break; - case CMD3: - if (InstancePtr->CardType == XSDPS_CARD_SD) { - RetVal |= RESP_R6; - } else { - RetVal |= RESP_R1; - } - break; - case CMD4: - RetVal |= RESP_NONE; - break; - case CMD5: - RetVal |= RESP_R1B; - break; - case CMD6: - if (InstancePtr->CardType == XSDPS_CARD_SD) { - RetVal |= RESP_R1 | (u32)XSDPS_DAT_PRESENT_SEL_MASK; - } else { + switch (Cmd) { + case CMD0: + case CMD4: + RetVal |= RESP_NONE; + break; + case CMD1: + case ACMD41: + RetVal |= RESP_R3; + break; + case CMD2: + case CMD9: + RetVal |= RESP_R2; + break; + case CMD3: + if (InstancePtr->CardType == XSDPS_CARD_SD) { + RetVal |= RESP_R6; + } else { + RetVal |= RESP_R1; + } + break; + case CMD5: + case CMD38: RetVal |= RESP_R1B; - } - break; - case ACMD6: - RetVal |= RESP_R1; - break; - case CMD7: - RetVal |= RESP_R1; - break; - case CMD8: - if (InstancePtr->CardType == XSDPS_CARD_SD) { + break; + case CMD6: + if (InstancePtr->CardType == XSDPS_CARD_SD) { + RetVal |= RESP_R1 | (u32)XSDPS_DAT_PRESENT_SEL_MASK; + } else { + RetVal |= RESP_R1B; + } + break; + case ACMD6: + case CMD7: + case CMD10: + case CMD11: + case CMD12: + case CMD16: + case CMD32: + case CMD33: + case CMD35: + case CMD36: + case ACMD42: + case CMD52: + case CMD55: RetVal |= RESP_R1; - } else { + break; + case CMD8: + if (InstancePtr->CardType == XSDPS_CARD_SD) { + RetVal |= RESP_R1; + } else { + RetVal |= RESP_R1 | (u32)XSDPS_DAT_PRESENT_SEL_MASK; + } + break; + case ACMD13: + case CMD17: + case CMD18: + case CMD19: + case CMD21: + case CMD23: + case ACMD23: + case CMD24: + case CMD25: + case ACMD51: RetVal |= RESP_R1 | (u32)XSDPS_DAT_PRESENT_SEL_MASK; - } - break; - case CMD9: - RetVal |= RESP_R2; - break; - case CMD11: - case CMD10: - case CMD12: - RetVal |= RESP_R1; - break; - case ACMD13: - RetVal |= RESP_R1 | (u32)XSDPS_DAT_PRESENT_SEL_MASK; - break; - case CMD16: - RetVal |= RESP_R1; - break; - case CMD17: - case CMD18: - case CMD19: - case CMD21: - RetVal |= RESP_R1 | (u32)XSDPS_DAT_PRESENT_SEL_MASK; - break; - case CMD23: - case ACMD23: - case CMD24: - case CMD25: - RetVal |= RESP_R1 | (u32)XSDPS_DAT_PRESENT_SEL_MASK; - break; - case CMD32: - case CMD33: - case CMD35: - case CMD36: - RetVal |= RESP_R1; - break; - case CMD38: - RetVal |= RESP_R1B; - break; - case ACMD41: - RetVal |= RESP_R3; - break; - case ACMD42: - RetVal |= RESP_R1; - break; - case ACMD51: - RetVal |= RESP_R1 | (u32)XSDPS_DAT_PRESENT_SEL_MASK; - break; - case CMD52: - case CMD55: - RetVal |= RESP_R1; - break; - case CMD58: - break; - default : - RetVal |= Cmd; - break; + break; + case CMD58: + break; + default : + RetVal |= Cmd; + break; } return RetVal; @@ -1733,9 +1806,9 @@ u32 XSdPs_FrameCmd(XSdPs *InstancePtr, u32 Cmd) /*****************************************************************************/ /** * @brief -* This function selects the HS400 timing mode. +* Selects the HS400 timing mode. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return - XST_SUCCESS if successful * - XST_FAILURE if failure occurred. @@ -1773,7 +1846,11 @@ u32 XSdPs_Select_HS400(XSdPs *InstancePtr) goto RETURN_PATH; } - InstancePtr->OTapDelay = SD_OTAPDLYSEL_HS400; + if (InstancePtr->Config.OTapDly_DDR_Clk200 != 0U){ + InstancePtr->OTapDelay = InstancePtr->Config.OTapDly_DDR_Clk200; + } else { + InstancePtr->OTapDelay = SD_OTAPDLYSEL_HS400; + } Status = XSdPs_Change_ClkFreq(InstancePtr, InstancePtr->BusSpeed); if (Status != XST_SUCCESS) { Status = XST_FAILURE; @@ -1781,11 +1858,11 @@ u32 XSdPs_Select_HS400(XSdPs *InstancePtr) } StatusReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL2_OFFSET); + XSDPS_HOST_CTRL2_OFFSET); StatusReg &= (~(u32)XSDPS_HC2_UHS_MODE_MASK); StatusReg |= XSDPS_HC2_HS400_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, - XSDPS_HOST_CTRL2_OFFSET, (u16)StatusReg); + XSDPS_HOST_CTRL2_OFFSET, (u16)StatusReg); RETURN_PATH: return Status; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_hw.h index 7ee7774..9257158 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,7 +8,7 @@ /** * * @file xsdps_hw.h -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{{ * * The xsdps_hw.h header file contains the identifiers and basic HW access driver @@ -45,6 +45,9 @@ * 4.0 sk 02/25/22 Add support for eMMC5.1. * sk 04/07/22 Fix typo in 'XSDPS_MMC_1_BIT_BUS_ARG' macro definition. * 4.1 sk 11/10/22 Add SD/eMMC Tap delay support for Versal Net. +* 4.2 ro 06/12/23 Added support for system device-tree flow. +* 4.3 ap 11/29/23 Add support for Sanitize feature. +* 4.3 ap 12/22/23 Add support to read custom HS400 tap delay value from design for eMMC. * * * @@ -63,8 +66,8 @@ extern "C" { #include "xil_types.h" #include "xil_assert.h" #include "xil_io.h" +#include "bspconfig.h" #include "xparameters.h" - /************************** Constant Definitions *****************************/ /** @name Register Map @@ -76,8 +79,8 @@ extern "C" { #define XSDPS_SDMA_SYS_ADDR_OFFSET 0x00U /**< SDMA System Address Register */ #define XSDPS_SDMA_SYS_ADDR_LO_OFFSET XSDPS_SDMA_SYS_ADDR_OFFSET - /**< SDMA System Address - Low Register */ +/**< SDMA System Address + Low Register */ #define XSDPS_ARGMT2_LO_OFFSET 0x00U /**< Argument2 Low Register */ #define XSDPS_SDMA_SYS_ADDR_HI_OFFSET 0x02U /**< SDMA System Address High Register */ @@ -87,7 +90,7 @@ extern "C" { #define XSDPS_BLK_CNT_OFFSET 0x06U /**< Block Count Register */ #define XSDPS_ARGMT_OFFSET 0x08U /**< Argument Register */ #define XSDPS_ARGMT1_LO_OFFSET XSDPS_ARGMT_OFFSET - /**< Argument1 Register */ +/**< Argument1 Register */ #define XSDPS_ARGMT1_HI_OFFSET 0x0AU /**< Argument1 Register */ #define XSDPS_XFER_MODE_OFFSET 0x0CU /**< Transfer Mode Register */ @@ -714,16 +717,16 @@ extern "C" { #define RESP_NONE (u32)XSDPS_CMD_RESP_NONE_MASK #define RESP_R1 (u32)XSDPS_CMD_RESP_L48_MASK | (u32)XSDPS_CMD_CRC_CHK_EN_MASK | \ - (u32)XSDPS_CMD_INX_CHK_EN_MASK + (u32)XSDPS_CMD_INX_CHK_EN_MASK #define RESP_R1B (u32)XSDPS_CMD_RESP_L48_BSY_CHK_MASK | \ - (u32)XSDPS_CMD_CRC_CHK_EN_MASK | (u32)XSDPS_CMD_INX_CHK_EN_MASK + (u32)XSDPS_CMD_CRC_CHK_EN_MASK | (u32)XSDPS_CMD_INX_CHK_EN_MASK #define RESP_R2 (u32)XSDPS_CMD_RESP_L136_MASK | (u32)XSDPS_CMD_CRC_CHK_EN_MASK #define RESP_R3 (u32)XSDPS_CMD_RESP_L48_MASK #define RESP_R6 (u32)XSDPS_CMD_RESP_L48_BSY_CHK_MASK | \ - (u32)XSDPS_CMD_CRC_CHK_EN_MASK | (u32)XSDPS_CMD_INX_CHK_EN_MASK + (u32)XSDPS_CMD_CRC_CHK_EN_MASK | (u32)XSDPS_CMD_INX_CHK_EN_MASK /** @} */ @@ -929,18 +932,24 @@ extern "C" { #define EXT_CSD_PART_CONFIG_ACC_BOOT1 (0x2U) #define EXT_CSD_PART_CONFIG_ACC_RPMB (0x3U) #define EXT_CSD_PART_CONFIG_ACC_GP0 (0x4U) +#define EXT_CSD_SANITIZE_START (0x1U) #define EXT_CSD_PART_CONFIG_BYTE (179U) +#define EXT_CSD_SANIT_CONFIG_BYTE (165U) #define XSDPS_MMC_PART_CFG_0_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24U) \ - | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ - | ((u32)(0U) << 8U)) + | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ + | ((u32)(0U) << 8U)) #define XSDPS_MMC_PART_CFG_1_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24U) \ - | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ - | ((u32)EXT_CSD_PART_CONFIG_ACC_BOOT0 << 8U)) + | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ + | ((u32)EXT_CSD_PART_CONFIG_ACC_BOOT0 << 8U)) #define XSDPS_MMC_PART_CFG_2_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24U) \ - | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ - | ((u32)EXT_CSD_PART_CONFIG_ACC_BOOT1 << 8U)) + | ((u32)EXT_CSD_PART_CONFIG_BYTE << 16U) \ + | ((u32)EXT_CSD_PART_CONFIG_ACC_BOOT1 << 8U)) + +#define XSDPS_MMC_START_SANITIZE_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24U) \ + | ((u32)EXT_CSD_SANIT_CONFIG_BYTE << 16U) \ + | ((u32)EXT_CSD_SANITIZE_START << 8U)) #define EXT_CSD_PART_SUPPORT_PART_EN (0x1U) @@ -952,14 +961,14 @@ extern "C" { #define EXT_CSD_CARD_TYPE_52 (1U<<1) /* Card can run at 52MHz */ #define EXT_CSD_CARD_TYPE_MASK 0x3FU /* Mask out reserved bits */ #define EXT_CSD_CARD_TYPE_DDR_1_8V (1U<<2) /* Card can run at 52MHz */ - /* DDR mode @1.8V or 3V I/O */ +/* DDR mode @1.8V or 3V I/O */ #define EXT_CSD_CARD_TYPE_DDR_1_2V (1U<<3) /* Card can run at 52MHz */ - /* DDR mode @1.2V I/O */ +/* DDR mode @1.2V I/O */ #define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \ - | EXT_CSD_CARD_TYPE_DDR_1_2V) + | EXT_CSD_CARD_TYPE_DDR_1_2V) #define EXT_CSD_CARD_TYPE_SDR_1_8V (1U<<4) /* Card can run at 200MHz */ #define EXT_CSD_CARD_TYPE_SDR_1_2V (1U<<5) /* Card can run at 200MHz */ - /* SDR mode @1.2V I/O */ +/* SDR mode @1.2V I/O */ #define EXT_CSD_BUS_WIDTH_BYTE 183U #define EXT_CSD_BUS_WIDTH_1_BIT 0U /* Card is in 1 bit mode */ #define EXT_CSD_BUS_WIDTH_4_BIT 1U /* Card is in 4 bit mode */ @@ -992,44 +1001,44 @@ extern "C" { * SD/MMC Arguments for Bus Speed and Bus Width. */ #define XSDPS_MMC_DEF_SPEED_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ - | ((u32)EXT_CSD_HS_TIMING_DEF << 8)) + | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ + | ((u32)EXT_CSD_HS_TIMING_DEF << 8)) #define XSDPS_MMC_HIGH_SPEED_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ - | ((u32)EXT_CSD_HS_TIMING_HIGH << 8)) + | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ + | ((u32)EXT_CSD_HS_TIMING_HIGH << 8)) #define XSDPS_MMC_HS200_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ - | ((u32)EXT_CSD_HS_TIMING_HS200 << 8)) + | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ + | ((u32)EXT_CSD_HS_TIMING_HS200 << 8)) #define XSDPS_MMC_HS400_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ - | ((u32)EXT_CSD_HS_TIMING_HS400 << 8)) + | ((u32)EXT_CSD_HS_TIMING_BYTE << 16) \ + | ((u32)EXT_CSD_HS_TIMING_HS400 << 8)) #define XSDPS_MMC_1_BIT_BUS_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ - | ((u32)EXT_CSD_BUS_WIDTH_1_BIT << 8)) + | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ + | ((u32)EXT_CSD_BUS_WIDTH_1_BIT << 8)) #define XSDPS_MMC_4_BIT_BUS_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ - | ((u32)EXT_CSD_BUS_WIDTH_4_BIT << 8)) + | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ + | ((u32)EXT_CSD_BUS_WIDTH_4_BIT << 8)) #define XSDPS_MMC_8_BIT_BUS_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ - | ((u32)EXT_CSD_BUS_WIDTH_8_BIT << 8)) + | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ + | ((u32)EXT_CSD_BUS_WIDTH_8_BIT << 8)) #define XSDPS_MMC_DDR_4_BIT_BUS_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ - | ((u32)EXT_CSD_BUS_WIDTH_DDR_4_BIT << 8)) + | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ + | ((u32)EXT_CSD_BUS_WIDTH_DDR_4_BIT << 8)) #define XSDPS_MMC_DDR_8_BIT_BUS_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ - | ((u32)EXT_CSD_BUS_WIDTH_DDR_8_BIT << 8)) + | ((u32)EXT_CSD_BUS_WIDTH_BYTE << 16) \ + | ((u32)EXT_CSD_BUS_WIDTH_DDR_8_BIT << 8)) #define XSDPS_MMC_RST_FUN_EN_ARG (((u32)XSDPS_EXT_CSD_WRITE_BYTE << 24) \ - | ((u32)EXT_CSD_RST_N_FUN_BYTE << 16) \ - | ((u32)EXT_CSD_RST_N_FUN_PERM_EN << 8)) + | ((u32)EXT_CSD_RST_N_FUN_BYTE << 16) \ + | ((u32)EXT_CSD_RST_N_FUN_PERM_EN << 8)) #define XSDPS_MMC_DELAY_FOR_SWITCH 1000U @@ -1196,6 +1205,8 @@ extern "C" { #define SD_ITAPCHGWIN 0x00000200U #define SD_ITAPDLYENA 0x00000100U #define SD_OTAPDLYENA 0x00000040U +#define SD_OTAPDLYSEL_SD104_B0 0x00000002U +#define SD_OTAPDLYSEL_SD104_B2 0x00000002U #define SD_OTAPDLYSEL_HS200_B0 0x00000007U #define SD_OTAPDLYSEL_HS200_B2 0x00000007U #define SD_OTAPDLYSEL_HS400 0x00000004U @@ -1224,6 +1235,8 @@ extern "C" { #define SD_ITAPCHGWIN 0x00000200U #define SD_ITAPDLYENA 0x00000100U #define SD_OTAPDLYENA 0x00000040U +#define SD_OTAPDLYSEL_SD104_B0 0x00000002U +#define SD_OTAPDLYSEL_SD104_B2 0x00000002U #define SD_OTAPDLYSEL_HS200_B0 0x00000002U #define SD_OTAPDLYSEL_HS200_B2 0x00000002U #define SD_ITAPDLYSEL_SD50 0x0000000EU @@ -1255,6 +1268,8 @@ extern "C" { #define SD1_ITAPCHGWIN 0x02000000U #define SD1_ITAPDLYENA 0x01000000U #define SD1_OTAPDLYENA 0x00400000U +#define SD_OTAPDLYSEL_SD104_B0 0x00000003U +#define SD_OTAPDLYSEL_SD104_B2 0x00000002U #define SD_OTAPDLYSEL_HS200_B0 0x00000003U #define SD_OTAPDLYSEL_HS200_B2 0x00000002U #define SD_ITAPDLYSEL_SD50 0x00000014U @@ -1273,7 +1288,7 @@ extern "C" { #endif /** @} */ -#ifdef __MICROBLAZE__ +#if defined (__MICROBLAZE__) || defined (__riscv) #define XPS_SYS_CTRL_BASEADDR 0xFF180000U /**< System controller Baseaddress */ #endif @@ -1294,16 +1309,16 @@ extern "C" { /****************************************************************************/ /** -* Read a register. +* Reads a register. * -* @param InstancePtr is the pointer to the sdps instance. -* @param RegOffset contains the offset from the 1st register of the +* @param InstancePtr Pointer to the sdps instance. +* @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 XSdPs_ReadReg(XSdPs *InstancePtr. s32 RegOffset) +* u32 XSdPs_ReadReg(XSdPs *InstancePtr. s32 RegOffset) * ******************************************************************************/ #define XSdPs_ReadReg64(InstancePtr, RegOffset) \ @@ -1311,36 +1326,36 @@ extern "C" { /***************************************************************************/ /** -* Write to a register. +* Writes to a register. * -* @param InstancePtr is the pointer to the sdps instance. -* @param RegOffset contains the offset from the 1st register of the +* @param InstancePtr Pointer to the sdps instance. +* @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. +* @param RegisterValue Value to be written to the register. * * @return None. * * @note C-Style signature: -* void XSdPs_WriteReg(XSdPs *InstancePtr, s32 RegOffset, -* u64 RegisterValue) +* void XSdPs_WriteReg(XSdPs *InstancePtr, s32 RegOffset, +* u64 RegisterValue) * ******************************************************************************/ #define XSdPs_WriteReg64(InstancePtr, RegOffset, RegisterValue) \ XSdPs_Out64((InstancePtr->Config.BaseAddress) + (RegOffset), \ - (RegisterValue)) + (RegisterValue)) /****************************************************************************/ /** -* Read a register. +* Reads a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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 XSdPs_ReadReg(u32 BaseAddress. int RegOffset) +* u32 XSdPs_ReadReg(UINTPTR BaseAddress. int RegOffset) * ******************************************************************************/ #define XSdPs_ReadReg(BaseAddress, RegOffset) \ @@ -1348,18 +1363,18 @@ extern "C" { /***************************************************************************/ /** -* Write to a register. +* Writes to a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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. +* @param RegisterValue Value to be written to the register. * * @return None. * * @note C-Style signature: -* void XSdPs_WriteReg(u32 BaseAddress, int RegOffset, -* u32 RegisterValue) +* void XSdPs_WriteReg(UINTPTR BaseAddress, int RegOffset, +* u32 RegisterValue) * ******************************************************************************/ #define XSdPs_WriteReg(BaseAddress, RegOffset, RegisterValue) \ @@ -1367,25 +1382,25 @@ extern "C" { /****************************************************************************/ /** -* Read a register. +* Reads a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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: -* u16 XSdPs_ReadReg(u32 BaseAddress. int RegOffset) +* u16 XSdPs_ReadReg(UINTPTR BaseAddress. int RegOffset) * ******************************************************************************/ -static INLINE u16 XSdPs_ReadReg16(u32 BaseAddress, u8 RegOffset) +static INLINE u16 XSdPs_ReadReg16(UINTPTR BaseAddress, u8 RegOffset) { -#if defined (__MICROBLAZE__) +#if defined (__MICROBLAZE__) || defined (__riscv) u32 Reg; BaseAddress += RegOffset & 0xFC; Reg = XSdPs_In32(BaseAddress); - Reg >>= ((RegOffset & 0x3)*8); + Reg >>= ((RegOffset & 0x3) * 8); return (u16)Reg; #else return XSdPs_In16((UINTPTR)(BaseAddress) + (UINTPTR)(RegOffset)); @@ -1394,29 +1409,29 @@ static INLINE u16 XSdPs_ReadReg16(u32 BaseAddress, u8 RegOffset) /***************************************************************************/ /** -* Write to a register. +* Writes to a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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. +* @param RegisterValue Value to be written to the register. * * @return None. * * @note C-Style signature: -* void XSdPs_WriteReg(u32 BaseAddress, int RegOffset, -* u16 RegisterValue) +* void XSdPs_WriteReg(UINTPTR BaseAddress, int RegOffset, +* u16 RegisterValue) * ******************************************************************************/ -static INLINE void XSdPs_WriteReg16(u32 BaseAddress, u8 RegOffset, u16 RegisterValue) +static INLINE void XSdPs_WriteReg16(UINTPTR BaseAddress, u8 RegOffset, u16 RegisterValue) { -#if defined (__MICROBLAZE__) +#if defined (__MICROBLAZE__) || defined (__riscv) u32 Reg; BaseAddress += RegOffset & 0xFC; Reg = XSdPs_In32(BaseAddress); - Reg &= ~(0xFFFFU<<((RegOffset & 0x3)*8)); - Reg |= RegisterValue <<((RegOffset & 0x3)*8); + Reg &= ~(0xFFFFU << ((RegOffset & 0x3) * 8)); + Reg |= RegisterValue << ((RegOffset & 0x3) * 8); XSdPs_Out32(BaseAddress, Reg); #else XSdPs_Out16((UINTPTR)(BaseAddress) + (UINTPTR)(RegOffset), (RegisterValue)); @@ -1425,25 +1440,25 @@ static INLINE void XSdPs_WriteReg16(u32 BaseAddress, u8 RegOffset, u16 RegisterV /****************************************************************************/ /** -* Read a register. +* Reads a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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: -* u8 XSdPs_ReadReg(u32 BaseAddress. int RegOffset) +* u8 XSdPs_ReadReg(UINTPTR BaseAddress. int RegOffset) * ******************************************************************************/ -static INLINE u8 XSdPs_ReadReg8(u32 BaseAddress, u8 RegOffset) +static INLINE u8 XSdPs_ReadReg8(UINTPTR BaseAddress, u8 RegOffset) { -#if defined (__MICROBLAZE__) +#if defined (__MICROBLAZE__) || defined (__riscv) u32 Reg; BaseAddress += RegOffset & 0xFC; Reg = XSdPs_In32(BaseAddress); - Reg >>= ((RegOffset & 0x3)*8); + Reg >>= ((RegOffset & 0x3) * 8); return (u8)Reg; #else return XSdPs_In8((UINTPTR)(BaseAddress) + (UINTPTR)(RegOffset)); @@ -1451,28 +1466,28 @@ static INLINE u8 XSdPs_ReadReg8(u32 BaseAddress, u8 RegOffset) } /***************************************************************************/ /** -* Write to a register. +* Writes to a register. * -* @param BaseAddress contains the base address of the device. -* @param RegOffset contains the offset from the 1st register of the +* @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. +* @param RegisterValue Value to be written to the register. * * @return None. * * @note C-Style signature: -* void XSdPs_WriteReg(u32 BaseAddress, int RegOffset, -* u8 RegisterValue) +* void XSdPs_WriteReg(UINTPTR BaseAddress, int RegOffset, +* u8 RegisterValue) * ******************************************************************************/ -static INLINE void XSdPs_WriteReg8(u32 BaseAddress, u8 RegOffset, u8 RegisterValue) +static INLINE void XSdPs_WriteReg8(UINTPTR BaseAddress, u8 RegOffset, u8 RegisterValue) { -#if defined (__MICROBLAZE__) +#if defined (__MICROBLAZE__) || defined (__riscv) u32 Reg; BaseAddress += RegOffset & 0xFC; Reg = XSdPs_In32(BaseAddress); - Reg &= ~(0xFFU<<((RegOffset & 0x3)*8)); - Reg |= RegisterValue <<((RegOffset & 0x3)*8); + Reg &= ~(0xFFU << ((RegOffset & 0x3) * 8)); + Reg |= RegisterValue << ((RegOffset & 0x3) * 8); XSdPs_Out32(BaseAddress, Reg); #else XSdPs_Out8((UINTPTR)(BaseAddress) + (UINTPTR)(RegOffset), (RegisterValue)); @@ -1480,19 +1495,19 @@ static INLINE void XSdPs_WriteReg8(u32 BaseAddress, u8 RegOffset, u8 RegisterVal } /***************************************************************************/ /** -* Macro to get present status register +* Macro to get present status register. * -* @param BaseAddress contains the base address of the device. +* @param BaseAddress Contains the base address of the device. * * @return None. * * @note C-Style signature: -* void XSdPs_WriteReg(u32 BaseAddress, int RegOffset, -* u8 RegisterValue) +* void XSdPs_WriteReg(UINTPTR BaseAddress, int RegOffset, +* u8 RegisterValue) * ******************************************************************************/ #define XSdPs_GetPresentStatusReg(BaseAddress) \ - XSdPs_In32((BaseAddress) + (XSDPS_PRES_STATE_OFFSET)) + XSdPs_In32((BaseAddress) + (XSDPS_PRES_STATE_OFFSET)) /************************** Function Prototypes ******************************/ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_options.c b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_options.c index fa9a421..e7e166a 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_options.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_options.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,7 +8,7 @@ /** * * @file xsdps_options.c -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{ * * The xsdps_options.c file ontains APIs for changing the various options in host and card. @@ -82,11 +82,11 @@ /** * * @brief -* API to change clock freq to given value. +* API to change clock frequency to a given value. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param SelFreq - Clock frequency in Hz. +* @param InstancePtr Pointer to the XSdPs instance. +* @param SelFreq Clock frequency in Hz. * * @return None * @@ -148,10 +148,10 @@ s32 XSdPs_Change_ClkFreq(XSdPs *InstancePtr, u32 SelFreq) /*****************************************************************************/ /** * @brief -* Update Block size for read/write operations. +* Updates 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. +* @param InstancePtr Pointer to the instance to be worked on. +* @param BlkSize Block size passed by the user. * * @return None * @@ -193,11 +193,11 @@ RETURN_PATH: /** * * @brief -* API to get bus width support by card. +* Gets bus width support by card. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param ReadBuff - buffer to store SCR register returned by card. +* @param InstancePtr Pointer to the XSdPs instance. +* @param ReadBuff Buffer to store SCR register returned by card. * * @return * - XST_SUCCESS if successful. @@ -262,16 +262,15 @@ s32 XSdPs_Get_BusWidth(XSdPs *InstancePtr, u8 *ReadBuff) /** * * @brief -* API to set bus width to 4-bit in card and host +* Sets bus width to 4-bit in card and host. * * -* @param InstancePtr is a pointer to the XSdPs instance. +* @param InstancePtr Pointer to the XSdPs instance. * * @return * - XST_SUCCESS if successful. * - XST_FAILURE if fail. * -* @note None. * ******************************************************************************/ s32 XSdPs_Change_BusWidth(XSdPs *InstancePtr) @@ -366,11 +365,11 @@ s32 XSdPs_Change_BusWidth(XSdPs *InstancePtr) /** * * @brief -* API to get bus speed supported by card. +* Gets bus speed supported by card. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param ReadBuff - buffer to store function group support data +* @param InstancePtr Pointer to the XSdPs instance. +* @param ReadBuff Buffer to store function group support data * returned by card. * * @return @@ -431,17 +430,16 @@ s32 XSdPs_Get_BusSpeed(XSdPs *InstancePtr, u8 *ReadBuff) /** * * @brief -* API to get SD card status information. +* Gets SD card status information. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param SdStatReg - buffer to store status data returned by card. +* @param InstancePtr 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) @@ -494,16 +492,15 @@ s32 XSdPs_Get_Status(XSdPs *InstancePtr, u8 *SdStatReg) /** * * @brief -* API to set high speed in card and host. Changes clock in host accordingly. +* Sets high speed in card and host. Changes clock in host accordingly. * * -* @param InstancePtr is a pointer to the XSdPs instance. +* @param InstancePtr Pointer to the XSdPs instance. * * @return * - XST_SUCCESS if successful. * - XST_FAILURE if fail. * -* @note None. * ******************************************************************************/ s32 XSdPs_Change_BusSpeed(XSdPs *InstancePtr) @@ -575,17 +572,16 @@ s32 XSdPs_Change_BusSpeed(XSdPs *InstancePtr) /** * * @brief -* API to get EXT_CSD register of eMMC. +* Gets EXT_CSD register of eMMC. * * -* @param InstancePtr is a pointer to the XSdPs instance. -* @param ReadBuff - buffer to store EXT_CSD +* @param InstancePtr 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) @@ -638,17 +634,16 @@ s32 XSdPs_Get_Mmc_ExtCsd(XSdPs *InstancePtr, u8 *ReadBuff) /** * * @brief -* API to write EXT_CSD register of eMMC. +* Writes 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 +* @param InstancePtr Pointer to the XSdPs instance. +* @param Arg 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) @@ -682,16 +677,15 @@ s32 XSdPs_Set_Mmc_ExtCsd(XSdPs *InstancePtr, u32 Arg) /** * * @brief -* API to send pullup command to card before using DAT line 3(using 4-bit bus) +* Sends pullup command to card before using DAT line 3(using 4-bit bus). * * -* @param InstancePtr is a pointer to the XSdPs instance. +* @param InstancePtr Pointer to the XSdPs instance. * * @return * - XST_SUCCESS if successful. * - XST_FAILURE if fail. * -* @note None. * ******************************************************************************/ s32 XSdPs_Pullup(XSdPs *InstancePtr) @@ -728,14 +722,13 @@ s32 XSdPs_Pullup(XSdPs *InstancePtr) * Selects card and sets default block size * * -* @param InstancePtr is a pointer to the XSdPs instance. +* @param InstancePtr 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) @@ -755,13 +748,13 @@ s32 XSdPs_Select_Card (XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function performs SD read in polled mode. +* 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param Arg 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. +* @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 @@ -803,13 +796,13 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function start SD write transfer. +* Starts 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 +* @param InstancePtr Pointer to the instance to be worked on. +* @param Arg 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. +* @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 @@ -851,9 +844,9 @@ RETURN_PATH: /*****************************************************************************/ /** * @brief -* This function is used to check if the transfer is completed successfully. +* Checks if the transfer is completed successfully. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if transfer was successful @@ -876,9 +869,9 @@ s32 XSdPs_CheckReadTransfer(XSdPs *InstancePtr) /*****************************************************************************/ /** * @brief -* This function is used to check for the write transfer completed. +* Checks for the write transfer completed. * -* @param InstancePtr is a pointer to the instance to be worked on. +* @param InstancePtr Pointer to the instance to be worked on. * * @return * - XST_SUCCESS if transfer was successful diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_sinit.c index 22a4b7f..50a4915 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/sdps/src/xsdps_sinit.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,11 +8,11 @@ /** * * @file xsdps_sinit.c -* @addtogroup sdps Overview +* @addtogroup sdps_api SDPS APIs * @{ * -* The implementation of the XSdPs component's static initialization -* functionality. +* The file contains the implementation of the static initialization +* functionality of the XSdPs component. * *
* MODIFICATION HISTORY: @@ -22,6 +22,7 @@ * 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. +* 4.2 ro 06/12/23 Added support for system device-tree flow. * ** @@ -40,10 +41,6 @@ /************************** Function Prototypes ******************************/ /************************** Variable Definitions *****************************/ -/** - * XSdPs Configuration Table - */ -extern XSdPs_Config XSdPs_ConfigTable[XPAR_XSDPS_NUM_INSTANCES]; /*****************************************************************************/ /** @@ -52,7 +49,7 @@ extern XSdPs_Config XSdPs_ConfigTable[XPAR_XSDPS_NUM_INSTANCES]; * 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 +* @param DeviceId Contains the ID of the device to look up the * configuration for. * * @return @@ -60,9 +57,9 @@ extern XSdPs_Config XSdPs_ConfigTable[XPAR_XSDPS_NUM_INSTANCES]; * 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. * ******************************************************************************/ +#ifndef SDT XSdPs_Config *XSdPs_LookupConfig(u16 DeviceId) { XSdPs_Config *CfgPtr = NULL; @@ -76,4 +73,21 @@ XSdPs_Config *XSdPs_LookupConfig(u16 DeviceId) } return (XSdPs_Config *)CfgPtr; } +#else +XSdPs_Config *XSdPs_LookupConfig(u32 BaseAddress) +{ + XSdPs_Config *CfgPtr = NULL; + u32 Index; + + for (Index = 0U; XSdPs_ConfigTable[Index].Name != NULL; Index++) { + if ((XSdPs_ConfigTable[Index].BaseAddress == BaseAddress) || + !BaseAddress) { + CfgPtr = &XSdPs_ConfigTable[Index]; + break; + } + } + return (XSdPs_Config *)CfgPtr; +} +#endif + /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/boot.S b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/boot.S index 3ee6914..5305e14 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/boot.S +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/boot.S @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (c) 2010 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ /*****************************************************************************/ @@ -64,6 +65,8 @@ * 742230 and 743622. These do not apply to * Cortex-A9 revision r3p0 being used in Zynq * platforms. +* 9.0 mus 07/27/23 Removed dependency on XPAR_CPU_ID, updated logic to use +* CPU affinity register to read CPU ID. * * * @@ -73,7 +76,10 @@ * ******************************************************************************/ +#include "bspconfig.h" +#ifndef SDT #include "xparameters.h" +#endif #include "xil_errata.h" .globl MMUTable @@ -146,16 +152,12 @@ _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 + b OKToRun CheckEFUSE: ldr r0,=EFUSEStaus @@ -177,24 +179,6 @@ CheckEFUSE: 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 @@ -204,7 +188,6 @@ OKToRun: /* set VBAR to the _vector_table address in linker script */ ldr r0, =vector_base mcr p15, 0, r0, c12, c0, 0 - MRC p15, 0, r1, c12, c0, 0 /*invalidate scu*/ #if USE_AMP!=1 diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/outbyte.c b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/outbyte.c index 1080862..db60e6d 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/outbyte.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/outbyte.c @@ -8,12 +8,12 @@ #ifdef __cplusplus extern "C" { #endif -void outbyte(uint8_t c); +void outbyte(char c); #ifdef __cplusplus } #endif -void outbyte(uint8_t c) { +void outbyte(char c) { XUartPs_SendByte(STDOUT_BASEADDRESS, c); } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/pm_api_version.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/pm_api_version.h new file mode 100644 index 0000000..5498048 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/pm_api_version.h @@ -0,0 +1,268 @@ +/****************************************************************************** +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +/*****************************************************************************/ +/** + * @file pm_api_version.h + * + * @addtogroup xpm_versal_apis XilPM APIs + *****************************************************************************/ + + +#ifndef PM_API_VERSION_H_ +#define PM_API_VERSION_H_ + +/*****************************************************************************/ +/** + * @section EEMI_API_DETAIL XilPM EEMI API Version Detail + * + * This section provides details of EEMI API version and it's history for PM APIs of XilPM library. + * + * | NAME | ID | Platform | Version| Description | + * |----------------------------|-------|---------------|:------:|---------------------------------------------------------------------------| + * | PM_GET_API_VERSION | 0x1 | Both | 1 | The API is used to request the version number of the API | + * | PM_SET_CONFIGURATION | 0x2 | ZynqMP | 1 | The API is used to configure the power management framework | + * | ^ | ^ | ^ | ^ | Note: Deprecated in Versal but supported in ZynqMP | + * | PM_GET_NODE_STATUS | 0x3 | Both | 1 | The API is used to obtain information about current status of a device | + * | PM_GET_OP_CHARACTERISTIC | 0x4 | Both | 2 | V1 - The API is used to get operating characteristics of a device | + * | ^ | ^ | ^ | ^ | V2 - Added support of bitmask functionality, user can check the supported\n "type" first before performing the actual functionality | + * | PM_REGISTER_NOTIFIER | 0x5 | Both | 2 | V1 - The API is used to register a subsystem to be notified about the\n device event | + * | ^ | ^ | ^ | ^ | V2 - Added support of event management functionality | + * | ^ | ^ | ^ | ^ | Note: V2 is supported in Versal but ZynqMP supports only V1 | + * | PM_REQUEST_SUSPEND | 0x6 | Both | 1 | The API is used to send suspend request to another subsystem | + * | PM_SELF_SUSPEND | 0x7 | Both | 3 | V1 - The API is used to suspend a child subsystem | + * | ^ | ^ | ^ | ^ | V2 - Added support of cpu idle functionality during force powerdown | + * | ^ | ^ | ^ | ^ | V3 - Added support of CPU off state | + * | ^ | ^ | ^ | ^ | Note: V3 is supported in Versal and Versal NET but ZynqMP supports only V1| + * | PM_FORCE_POWERDOWN | 0x8 | Both | 2 | V1 - The API is used to Powerdown other processor or node | + * | ^ | ^ | ^ | ^ | V2 - Added support of cpu idle functionality during force powerdown | + * | ^ | ^ | ^ | ^ | Note: V2 is supported in Versal but ZynqMP supports only V1 | + * | PM_ABORT_SUSPEND | 0x9 | Both | 1 | The API is used by a subsystem to abort suspend of a child subsystem | + * | PM_REQUEST_WAKEUP | 0xA | Both | 1 | The API is used to start-up and wake-up a child subsystem | + * | PM_SET_WAKEUP_SOURCE | 0xB | Both | 1 | The API is used to set wakeup source | + * | PM_SYSTEM_SHUTDOWN | 0xC | Both | 1 | The API is used to shutdown or restart the system | + * | PM_REQUEST_NODE | 0xD | Both | 2 | V1 - The API is used to request the usage of a device | + * | ^ | ^ | ^ | ^ | V2 - Added support of security policy handling during request device | + * | ^ | ^ | ^ | ^ | Note: V2 is supported in Versal but ZynqMP supports only V1 | + * | PM_RELEASE_NODE | 0xE | Both | 2 | V1 - The API is used to release the usage of a device | + * | ^ | ^ | ^ | ^ | V2 - Added support of security policy handling during request device | + * | ^ | ^ | ^ | ^ | Note: V2 is supported in Versal but ZynqMP supports only V1 | + * | PM_SET_REQUIREMENT | 0xF | Both | 1 | The API is used to announce a change in requirement for a specific slave\n node which is currently in use | + * | PM_SET_MAX_LATENCY | 0x10 | Both | 1 | The API is used to set maximum allowed latency for the device | + * | PM_RESET_ASSERT | 0x11 | Both | 1 | The API is used to reset or de-reset a device | + * | PM_RESET_GET_STATUS | 0x12 | Both | 1 | The API is used to read the device reset state | + * | PM_MMIO_WRITE | 0x13 | ZynqMP | 1 | The API is used to write a value into a register | + * | ^ | ^ | ^ | ^ | Note: Deprecated in Versal but supported in ZynqMP | + * | PM_MMIO_READ | 0x14 | ZynqMP | 1 | The API is used to read a value from a register | + * | ^ | ^ | ^ | ^ | Note: Deprecated in Versal but supported in ZynqMP | + * | PM_INIT_FINALIZE | 0x15 | Both | 1 | The API is used to initialize subsystem and release unused devices | + * | PM_GET_CHIPID | 0x18 | Both | 1 | The API is used to request the version and ID code of a chip | + * | PM_PINCTRL_REQUEST | 0x1C | Both | 1 | The API is used to request the pin | + * | PM_PINCTRL_RELEASE | 0x1D | Both | 1 | The API is used to release the pin | + * | PM_PINCTRL_GET_FUNCTION | 0x1E | Both | 1 | The API is used to read the pin function | + * | PM_PINCTRL_SET_FUNCTION | 0x1F | Both | 1 | The API is used to set the pin function | + * | PM_PINCTRL_CONFIG_PARAM_GET| 0x20 | Both | 1 | The API is used to read the pin parameter value | + * | PM_PINCTRL_CONFIG_PARAM_SET| 0x21 | Both | 2 | V1 - The API is used to set the pin parameter value | + * | ^ | ^ | ^ | ^ | V2 - Added support of MIO tri-state controlling functionality | + * | ^ | ^ | ^ | ^ | Note: V2 is supported in ZynqMP but Versal supports only V1 | + * | PM_IOCTL | 0x22 | Both | 3 | V1 - The API is used to perform driver-like IOCTL functions on shared\n system devices | + * | ^ | ^ | ^ | ^ | V2 - Added support of bitmask functionality, user can check the supported\n ID first before performing the actual functionality | + * | ^ | ^ | ^ | ^ | V3 - Add support of zeroization of AIE data and program memory separately | + * | ^ | ^ | ^ | ^ | Note: V3 is supported in Versal but ZynqMP supports only V2 | + * | PM_QUERY_DATA | 0x23 | Both | 2 | V1 - The API is used to query information about the platform resources | + * | ^ | ^ | ^ | ^ | V2 - Added support of bitmask functionality, user can check the supported\n ID first before performing the actual functionality | + * | PM_CLOCK_ENABLE | 0x24 | Both | 1 | The API is used to enable the clock | + * | PM_CLOCK_DISABLE | 0x25 | Both | 1 | The API is used to disable the clock | + * | PM_CLOCK_GETSTATE | 0x26 | Both | 1 | The API is used to read the clock state | + * | PM_CLOCK_SETDIVIDER | 0x27 | Both | 1 | The API is used to set the divider value of the clock | + * | PM_CLOCK_GETDIVIDER | 0x28 | Both | 1 | The API is used to read the clock divider | + * | PM_CLOCK_SETPARENT | 0x2B | Both | 1 | The API is used to set the parent of the clock | + * | PM_CLOCK_GETPARENT | 0x2C | Both | 1 | The API is used to read the clock parent | + * | PM_PLL_SET_PARAM | 0x30 | Both | 1 | The API is used to set the parameter of PLL clock | + * | PM_PLL_GET_PARAM | 0x31 | Both | 1 | The API is used to read the parameter of PLL clock | + * | PM_PLL_SET_MODE | 0x32 | Both | 1 | The API is used to set the mode of PLL clock | + * | PM_PLL_GET_MODE | 0x33 | Both | 1 | The API is used to read the mode of PLL clock | + * | PM_REGISTER_ACCESS | 0x34 | ZynqMP | 1 | The API is used for register read/write access data | + * | ^ | ^ | ^ | ^ | Note: Deprecated in Versal but supported in ZynqMP | + * | PM_EFUSE_ACCESS | 0x35 | ZynqMP | 1 | The API is used to provide access to efuse memory | + * | ^ | ^ | ^ | ^ | Note: Deprecated in Versal but supported in ZynqMP | + * | PM_FEATURE_CHECK | 0x3F | Both | 2 | V1 - The API is used to return supported version of the given API | + * | ^ | ^ | ^ | ^ | V2 - Added support of bitmask payload functionality | + * + *****************************************************************************/ + +/*****************************************************************************/ +/** + * @section IOCTL_ID_DETAIL XilPM IOCTL IDs Detail + * + * This section provides the details of the IOCTL IDs which are supported across the different platforms and their brief descriptions. + * + * | Name | ID | Platform | Description | + * |------------------------------------|-------|---------------|---------------------------------------| + * | IOCTL_GET_RPU_OPER_MODE | 0 | Both | Get RPU mode | + * | IOCTL_SET_RPU_OPER_MODE | 1 | Both | Set RPU mode | + * | IOCTL_RPU_BOOT_ADDR_CONFIG | 2 | Both | RPU boot address config | + * | IOCTL_TCM_COMB_CONFIG | 3 | Both | TCM config | + * | IOCTL_SET_TAPDELAY_BYPASS | 4 | Both | TAP delay bypass | + * | IOCTL_SD_DLL_RESET | 6 | Both | SD DLL reset | + * | IOCTL_SET_SD_TAPDELAY | 7 | Both | SD TAP delay | + * | IOCTL_SET_PLL_FRAC_MODE | 8 | Both | Set PLL frac mode | + * | IOCTL_GET_PLL_FRAC_MODE | 9 | Both | Get PLL frac mode | + * | IOCTL_SET_PLL_FRAC_DATA | 10 | Both | Set PLL frac data | + * | IOCTL_GET_PLL_FRAC_DATA | 11 | Both | Get PLL frac data | + * | IOCTL_WRITE_GGS | 12 | Both | Write GGS | + * | IOCTL_READ_GGS | 13 | Both | Read GGS | + * | IOCTL_WRITE_PGGS | 14 | Both | Write PGGS | + * | IOCTL_READ_PGGS | 15 | Both | Read PGGS | + * | IOCTL_ULPI_RESET | 16 | ZynqMP | ULPI reset | + * | IOCTL_SET_BOOT_HEALTH_STATUS | 17 | Both | Set boot status | + * | IOCTL_AFI | 18 | ZynqMP | AFI | + * | IOCTL_OSPI_MUX_SELECT | 21 | Versal | OSPI mux select | + * | IOCTL_USB_SET_STATE | 22 | Versal | USB set state | + * | IOCTL_GET_LAST_RESET_REASON | 23 | Versal | Get last reset reason | + * | IOCTL_AIE_ISR_CLEAR | 24 | Versal | AIE ISR clear | + * | IOCTL_REGISTER_SGI | 25 | None | Register SGI to ATF | + * | IOCTL_SET_FEATURE_CONFIG | 26 | ZynqMP | Set runtime feature config | + * | IOCTL_GET_FEATURE_CONFIG | 27 | ZynqMP | Get runtime feature config | + * | IOCTL_READ_REG | 28 | Versal | Read a 32-bit register | + * | IOCTL_MASK_WRITE_REG | 29 | Versal | RMW a 32-bit register | + * | IOCTL_SET_SD_CONFIG | 30 | ZynqMP | Set SD config register value | + * | IOCTL_SET_GEM_CONFIG | 31 | ZynqMP | Set GEM config register value | + * | IOCTL_SET_USB_CONFIG | 32 | ZynqMP | Set USB config register value | + * | IOCTL_AIE_OPS | 33 | Versal | AIE1/AIEML Run Time Operations | + * | IOCTL_GET_QOS | 34 | Versal | Get Device QoS value | + * | IOCTL_GET_APU_OPER_MODE | 35 | Versal | Get APU operation mode | + * | IOCTL_SET_APU_OPER_MODE | 36 | Versal | Set APU operation mode | + * | IOCTL_PREPARE_DDR_SHUTDOWN | 37 | Versal | Prepare DDR for shut down | + * | IOCTL_GET_SSIT_TEMP | 38 | Versal | Get secondary SLR min/max temperature | + * + *****************************************************************************/ + +/*****************************************************************************/ +/** + * @section QUERY_ID_DETAIL XilPM QUERY IDs Detail + * + * This section provides the details of the QUERY IDs which are supported across the different platforms and their brief descriptions. + * + * | Name | ID | Platform | Description | + * |--------------------------------------------|-------|---------------|---------------------------------------| + * | XPM_QID_INVALID | 0 | Both | Invalid Query ID | + * | XPM_QID_CLOCK_GET_NAME | 1 | Both | Get clock name | + * | XPM_QID_CLOCK_GET_TOPOLOGY | 2 | Both | Get clock topology | + * | XPM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS | 3 | Both | Get clock fixedfactor parameter | + * | XPM_QID_CLOCK_GET_MUXSOURCES | 4 | Both | Get clock mux sources | + * | XPM_QID_CLOCK_GET_ATTRIBUTES | 5 | Both | Get clock attributes | + * | XPM_QID_PINCTRL_GET_NUM_PINS | 6 | Both | Get total pins | + * | XPM_QID_PINCTRL_GET_NUM_FUNCTIONS | 7 | Both | Get total pin functions | + * | XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS | 8 | Both | Get total pin function groups | + * | XPM_QID_PINCTRL_GET_FUNCTION_NAME | 9 | Both | Get pin function name | + * | XPM_QID_PINCTRL_GET_FUNCTION_GROUPS | 10 | Both | Get pin function groups | + * | XPM_QID_PINCTRL_GET_PIN_GROUPS | 11 | Both | Get pin groups | + * | XPM_QID_CLOCK_GET_NUM_CLOCKS | 12 | Both | Get number of clocks | + * | XPM_QID_CLOCK_GET_MAX_DIVISOR | 13 | Both | Get max clock divisor | + * | XPM_QID_PLD_GET_PARENT | 14 | Versal | Get PLD parent | + * | XPM_QID_PINCTRL_GET_ATTRIBUTES | 15 | Versal | Get pin attributes | + * + *****************************************************************************/ + + +/*****************************************************************************/ +/** + * @section GET_OP_CHAR_DETAIL XilPM GET_OP_CHAR IDs Detail + * + * This section provides the details of the GET_OP_CHAR IDs which are supported across the different platforms and their brief descriptions. + * + * | Name | ID | Platform | Description | + * |------------------------------------|-------|---------------|-----------------------------------------------| + * | PM_OPCHAR_TYPE_POWER | 1 | ZynqMP | Operating characteristic ID power | + * | PM_OPCHAR_TYPE_TEMP | 2 | Versal | Operating characteristic ID temperature | + * | PM_OPCHAR_TYPE_LATENCY | 3 | Both | Operating characteristic ID latency | + * + *****************************************************************************/ + + +/** + * PM API IDs + */ +typedef enum { + PM_API_MIN, /**< 0x0 */ + PM_GET_API_VERSION, /**< 0x1 */ + PM_SET_CONFIGURATION, /**< 0x2 */ + PM_GET_NODE_STATUS, /**< 0x3 */ + PM_GET_OP_CHARACTERISTIC, /**< 0x4 */ + PM_REGISTER_NOTIFIER, /**< 0x5 */ + PM_REQUEST_SUSPEND, /**< 0x6 */ + PM_SELF_SUSPEND, /**< 0x7 */ + PM_FORCE_POWERDOWN, /**< 0x8 */ + PM_ABORT_SUSPEND, /**< 0x9 */ + PM_REQUEST_WAKEUP, /**< 0xA */ + PM_SET_WAKEUP_SOURCE, /**< 0xB */ + PM_SYSTEM_SHUTDOWN, /**< 0xC */ + PM_REQUEST_NODE, /**< 0xD */ + PM_RELEASE_NODE, /**< 0xE */ + PM_SET_REQUIREMENT, /**< 0xF */ + PM_SET_MAX_LATENCY, /**< 0x10 */ + PM_RESET_ASSERT, /**< 0x11 */ + PM_RESET_GET_STATUS, /**< 0x12 */ + PM_MMIO_WRITE, /**< 0x13 */ + PM_MMIO_READ, /**< 0x14 */ + PM_INIT_FINALIZE, /**< 0x15 */ + PM_FPGA_LOAD, /**< 0x16 */ + PM_FPGA_GET_STATUS, /**< 0x17 */ + PM_GET_CHIPID, /**< 0x18 */ + PM_SECURE_RSA_AES, /**< 0x19 */ + PM_SECURE_SHA, /**< 0x1A */ + PM_SECURE_RSA, /**< 0x1B */ + PM_PINCTRL_REQUEST, /**< 0x1C */ + PM_PINCTRL_RELEASE, /**< 0x1D */ + PM_PINCTRL_GET_FUNCTION, /**< 0x1E */ + PM_PINCTRL_SET_FUNCTION, /**< 0x1F */ + PM_PINCTRL_CONFIG_PARAM_GET, /**< 0x20 */ + PM_PINCTRL_CONFIG_PARAM_SET, /**< 0x21 */ + PM_IOCTL, /**< 0x22 */ + PM_QUERY_DATA, /**< 0x23 */ + PM_CLOCK_ENABLE, /**< 0x24 */ + PM_CLOCK_DISABLE, /**< 0x25 */ + PM_CLOCK_GETSTATE, /**< 0x26 */ + PM_CLOCK_SETDIVIDER, /**< 0x27 */ + PM_CLOCK_GETDIVIDER, /**< 0x28 */ + PM_CLOCK_SETRATE, /**< 0x29 */ + /* PM_CLOCK_GETRATE API is deprecated */ + PM_RESERVE_ID, /**< 0x2A */ + PM_CLOCK_SETPARENT, /**< 0x2B */ + PM_CLOCK_GETPARENT, /**< 0x2C */ + PM_SECURE_IMAGE, /**< 0x2D */ + PM_FPGA_READ, /**< 0x2E */ + PM_SECURE_AES, /**< 0x2F */ + PM_PLL_SET_PARAMETER, /**< 0x30 */ + PM_PLL_GET_PARAMETER, /**< 0x31 */ + PM_PLL_SET_MODE, /**< 0x32 */ + PM_PLL_GET_MODE, /**< 0x33 */ + PM_REGISTER_ACCESS, /**< 0x34 */ + PM_EFUSE_ACCESS, /**< 0x35 */ + PM_ADD_SUBSYSTEM, /**< 0x36 */ + PM_DESTROY_SUBSYSTEM, /**< 0x37 */ + PM_DESCRIBE_NODES, /**< 0x38 */ + PM_ADD_NODE, /**< 0x39 */ + PM_ADD_NODE_PARENT, /**< 0x3A */ + PM_ADD_NODE_NAME, /**< 0x3B */ + PM_ADD_REQUIREMENT, /**< 0x3C */ + PM_SET_CURRENT_SUBSYSTEM, /**< 0x3D */ + PM_INIT_NODE, /**< 0x3E */ + PM_FEATURE_CHECK, /**< 0x3F */ + PM_ISO_CONTROL, /**< 0x40 */ + PM_ACTIVATE_SUBSYSTEM, /**< 0x41 */ + PM_SET_NODE_ACCESS, /**< 0x42 */ + PM_BISR, /**< 0x43 */ + PM_APPLY_TRIM, /**< 0x44 */ + PM_NOC_CLOCK_ENABLE, /**< 0x45 */ + PM_IF_NOC_CLOCK_ENABLE, /**< 0x46 */ + PM_FORCE_HOUSECLEAN, /**< 0x47 */ + PM_FPGA_GET_VERSION, /**< 0x48 */ + PM_FPGA_GET_FEATURE_LIST, /**< 0x49 */ + PM_API_MAX /**< 0x4A */ +} XPm_ApiId; + +#endif /* PM_API_VERSION_H_ */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/print.c b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/print.c index e8ac3d4..cb66494 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/print.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/print.c @@ -12,19 +12,22 @@ * the new terms are clearly indicated on the first page of each file where * they apply. * - */ + *****************************************************************************/ +/***************************** Include Files *********************************/ -/* - * print -- do a raw print of a string - */ #include "xil_printf.h" +/*****************************************************************************/ +/** +* print -- do a raw print of a string +* +******************************************************************************/ void print(const char8 *ptr) { #if defined (__aarch64__) && (HYP_GUEST == 1) && (EL1_NONSECURE == 1) && defined (XEN_USE_PV_CONSOLE) XPVXenConsole_Write(ptr); #else -#ifdef STDOUT_BASEADDRESS +#if defined(STDOUT_BASEADDRESS) || defined(SDT) while (*ptr != (char8)0) { outbyte (*ptr); ptr++; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/putnum.c b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/putnum.c index a4c5e47..3582ffe 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/putnum.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/putnum.c @@ -11,11 +11,7 @@ * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. - */ - -/* - * putnum -- print a 32 bit number in hex - */ + *****************************************************************************/ /***************************** Include Files *********************************/ #include "xil_types.h" @@ -24,6 +20,11 @@ /************************** Function Prototypes ******************************/ void putnum(u32 num); +/*****************************************************************************/ +/** +* putnum -- print a 32 bit number in hex +* +******************************************************************************/ void putnum(u32 num) { char8 buf[9]; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/read.c b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/read.c index eb81317..decf665 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/read.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/read.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (c) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,7 +9,10 @@ */ #ifndef UNDEFINE_FILE_OPS #include "xil_printf.h" +#include "bspconfig.h" +#ifndef SDT #include "xparameters.h" +#endif #ifdef __cplusplus extern "C" { @@ -28,7 +32,7 @@ __attribute__((weak)) s32 read (s32 fd, char8* buf, s32 nbytes); __attribute__((weak)) s32 read (s32 fd, char8* buf, s32 nbytes) { -#ifdef STDIN_BASEADDRESS +#if defined (STDIN_BASEADDRESS) || defined(SDT) s32 i; s32 numbytes = 0; char8* LocalBuf = buf; @@ -56,7 +60,7 @@ read (s32 fd, char8* buf, s32 nbytes) __attribute__((weak)) s32 _read (s32 fd, char8* buf, s32 nbytes) { -#ifdef STDIN_BASEADDRESS +#if defined(STDIN_BASEADDRESS) || defined(SDT) s32 i; s32 numbytes = 0; char8* LocalBuf = buf; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/sleep.c b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/sleep.c index efa60da..d3e3d76 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/sleep.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/sleep.c @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (c) 2009 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2009 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -21,7 +22,7 @@ * 6.6 srm 10/18/17 Updated sleep routines to support user configurable * implementation. Now sleep routines will use Timer * specified by the user (i.e. Global timer/TTC timer) -* +* 9.0 ml 03/03/23 Add description to fix doxygen warnings. * * ******************************************************************************/ @@ -36,7 +37,7 @@ #endif /*****************************************************************************/ -/* +/** * * This API is used to provide delays in seconds * @@ -46,7 +47,7 @@ * * @note None. * -****************************************************************************/ +******************************************************************************/ unsigned sleep_A9(unsigned int seconds) { #if defined (SLEEP_TIMER_BASEADDR) diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/sleep.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/sleep.h index 3c9c788..c41750f 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/sleep.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/sleep.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (c) 2014 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2014 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -30,7 +31,8 @@ * 8.0 sk 03/17/22 Modify sleep_MB parameter type from unsigned int to * u32 and usleep_MB parameter type from unsigned long to * ULONG to fix misra_c_2012_rule_4_6 violation. -* +* 9.0 ml 03/03/23 Add description to fix doxygen warnings. +* 9.1 mus 10/24/23 Add support for RISC-V. * * ******************************************************************************/ @@ -87,6 +89,7 @@ extern "C" { (timeout>0) ? 0 : -1; \ } ) +/************************** Function Prototypes ******************************/ void usleep(ULONG useconds); void sleep(u32 seconds); void usleep_R5(ULONG useconds); @@ -97,6 +100,10 @@ int usleep_A53(unsigned long useconds); unsigned sleep_A53(unsigned int seconds); int usleep_A9(unsigned long useconds); unsigned sleep_A9(unsigned int seconds); +void sleep_riscv(u32 seconds); +void usleep_riscv(ULONG useconds); + +/*****************************************************************************/ #ifdef __cplusplus } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/translation_table.S b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/translation_table.S index 125fe7f..cd8e49f 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/translation_table.S +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/translation_table.S @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (c) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ /*****************************************************************************/ @@ -67,7 +68,12 @@ * * ******************************************************************************/ +#include "bspconfig.h" +#ifndef SDT #include "xparameters.h" +#else +#include "xmem_config.h" +#endif .globl MMUTable .section .mmu_tbl,"a" @@ -84,6 +90,11 @@ MMUTable: .set DDR_END, XPAR_PS7_DDR_0_S_AXI_HIGHADDR .set DDR_SIZE, (DDR_END - DDR_START)+1 .set DDR_REG, DDR_SIZE/0x100000 +#elif defined(XPAR_PS7_DDR_0_BASEADDRESS) +.set DDR_START, XPAR_PS7_DDR_0_BASEADDRESS +.set DDR_END, XPAR_PS7_DDR_0_HIGHADDRESS +.set DDR_SIZE, (DDR_END - DDR_START)+1 +.set DDR_REG, DDR_SIZE/0x100000 #else .set DDR_REG, 0 #endif diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/usleep.c b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/usleep.c index 26966bf..82f15ce 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/usleep.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/usleep.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (c) 2009 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -25,6 +26,7 @@ * 6.6 srm 10/18/17 Updated sleep routines to support user configurable * implementation. Now sleep routines will use Timer * specified by the user (i.e. Global timer/TTC timer) +* 9.0 ml 03/03/23 Added description to fix doxygen warnings. * * ******************************************************************************/ @@ -45,7 +47,7 @@ #if defined (SLEEP_TIMER_BASEADDR) #define COUNTS_PER_USECOND (SLEEP_TIMER_FREQUENCY / 1000000) #else -/* Global Timer is always clocked at half of the CPU frequency */ +/**< Global Timer is always clocked at half of the CPU frequency */ #define COUNTS_PER_USECOND (XPAR_CPU_CORTEXA9_CORE_CLOCK_FREQ_HZ / (2U*1000000U)) #endif diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/write.c b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/write.c index cf1d35e..279a0cd 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/write.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/write.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (c) 2009 - 2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -8,7 +9,10 @@ */ #ifndef UNDEFINE_FILE_OPS #include "xil_printf.h" +#include "bspconfig.h" +#ifndef SDT #include "xparameters.h" +#endif #ifdef __cplusplus extern "C" { @@ -30,7 +34,7 @@ __attribute__((weak)) sint32 write (sint32 fd, char8* buf, sint32 nbytes) { -#ifdef STDOUT_BASEADDRESS +#if defined(STDOUT_BASEADDRESS) || defined(SDT) s32 i; char8* LocalBuf = buf; @@ -69,7 +73,7 @@ _write (sint32 fd, char8* buf, sint32 nbytes) length = XPVXenConsole_Write(buf); return length; #else -#ifdef STDOUT_BASEADDRESS +#if defined(STDOUT_BASEADDRESS) || defined(SDT) s32 i; char8* LocalBuf = buf; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xcortexa9.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xcortexa9.h new file mode 100644 index 0000000..65a9db0 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xcortexa9.h @@ -0,0 +1,18 @@ +/****************************************************************************** +* Copyright (c) 2021-2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ +#ifndef XIL_XCORTEXA9_H_ /* prevent circular inclusions */ +#define XIL_XCORTEXA9_H_ /* by using protection macros */ + +/***************************** Include Files ********************************/ + +#include "xil_types.h" + +/**************************** Type Definitions ******************************/ +typedef struct { + u32 CpuFreq; +} XCortexa9_Config; + +#endif /* XIL_XCORTEXA9_H_ */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xcortexa9_config.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xcortexa9_config.h new file mode 100644 index 0000000..1a774f1 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xcortexa9_config.h @@ -0,0 +1,18 @@ +/****************************************************************************** +* Copyright (c) 2021-2022 Xilinx, Inc. All rights reserved. +* Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ +#ifndef XIL_XCORTEXA9_CONFIG_H_ /* prevent circular inclusions */ +#define XIL_XCORTEXA9_CONFIG_H_ /* by using protection macros */ + +/***************************** Include Files ********************************/ + +#include "xcortexa9.h" + +/************************** Variable Definitions ****************************/ +extern XCortexa9_Config XCortexa9_ConfigTable; + +/***************** Macros (Inline Functions) Definitions ********************/ +#define XGet_CpuFreq() XCortexa9_ConfigTable.CpuFreq +#endif /* XIL_XCORTEXA9_CONFIG_H_ */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xdebug.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xdebug.h index 8e6b3ef..74bfdb0 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xdebug.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xdebug.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2002 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -61,13 +61,13 @@ int printf(const char *format, ...); #else /* defined(DEBUG) && !defined(NDEBUG) */ -#define xdbg_stmnt(x) +#define xdbg_stmnt(x) /**< Debug statement */ /* See VxWorks comments above */ #if defined(XENV_VXWORKS) && defined(_WRS_GNU_VAR_MACROS) #define xdbg_printf(type, args...) #else /* ANSI Syntax */ -#define xdbg_printf(...) +#define xdbg_printf(...) /**< Debug printf */ #endif #endif /* defined(DEBUG) && !defined(NDEBUG) */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil-crt0.S b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil-crt0.S index a560286..5d87bc1 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil-crt0.S +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil-crt0.S @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (c) 2009 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ /*****************************************************************************/ @@ -25,6 +26,7 @@ * Now the TTC instance as specified by the user will be * started. * 7.7 adk 11/30/21 Added support for xiltimer library. +* 9.1 dp 01/24/24 Dont invoke XTime_StartTTCTimer when xiltimer is enabled * * * @note @@ -93,7 +95,7 @@ _start: mov r1, #0x0 /* Reset and start Triple Timer Counter */ - #if defined SLEEP_TIMER_BASEADDR + #if defined SLEEP_TIMER_BASEADDR && !defined(XPAR_XILTIMER_ENABLED) bl XTime_StartTTCTimer #endif diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cache.c b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cache.c index f00fb25..23cbb7b 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cache.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cache.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (c) 2010 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -89,6 +89,18 @@ * 8.1 asa 02/13/23 The existing Xil_DCacheInvalidateRange has a bug where * the last cache line will not get invalidated under certain * scenarios. Changes are made to fix the same. +* 9.0 ml 03/03/23 Added description to fix doxygen warnings. +* mus 09/21/23 Fix infinite loop in Xil_DCacheInvalidateRange when +* USE_AMP=1. +* 9.1 asa 01/12/24 Fix issues in Xil_DCacheInvalidateRange. +* 9.1 asa 01/29/24 In an unlikely scenario where the start address +* passed is 0x0 and length is less than 0x20 (cache line), +* the XilDCacheInvalidateRange API will result in +* a probable crash as it will try to invalidate the +* complete 4 GB address range. +* Changes are made to fix the same. +* 9.1 asa 31/01/24 Fix overflow issues under corner cases for various +* cache maintenance APIs. * * ******************************************************************************/ @@ -109,7 +121,9 @@ /************************** Variable Definitions *****************************/ -#define IRQ_FIQ_MASK 0xC0U /* Mask IRQ and FIQ interrupts in cpsr */ +#define IRQ_FIQ_MASK 0xC0U /**< Mask IRQ and FIQ interrupts in cpsr */ +#define MAX_ADDR 0xFFFFFFFFU +#define LAST_CACHELINE_START 0xFFFFFFE0U #ifdef __GNUC__ extern s32 _stack_end; @@ -117,7 +131,8 @@ #endif #ifndef USE_AMP -/**************************************************************************** +/***************************************************************************/ +/** * * Access L2 Debug Control Register. * @@ -139,7 +154,8 @@ static void Xil_L2WriteDebugCtrl(u32 Value) #endif } -/**************************************************************************** +/***************************************************************************/ +/** * * Perform L2 Cache Sync Operation. * @@ -300,13 +316,14 @@ void Xil_DCacheInvalidateLine(u32 adr) * @return None. * ****************************************************************************/ -void Xil_DCacheInvalidateRange(INTPTR opstartaddr, u32 len) +void Xil_DCacheInvalidateRange(INTPTR adr, u32 len) { const u32 cacheline = 32U; INTPTR tempadr; INTPTR opendaddr; INTPTR endaddr; u32 currmask; + u32 unalignedstart = 0x0; volatile u32 *L2CCOffset = (volatile u32 *)(XPS_L2CC_BASEADDR + XPS_L2CC_CACHE_INVLD_PA_OFFSET); @@ -314,27 +331,29 @@ void Xil_DCacheInvalidateRange(INTPTR opstartaddr, u32 len) mtcpsr(currmask | IRQ_FIQ_MASK); if (len != 0U) { - opendaddr = opstartaddr + len; + ((MAX_ADDR - (u32)adr) < len) ? (opendaddr = MAX_ADDR) : (opendaddr = adr + len); endaddr = opendaddr; - if ((opstartaddr & (cacheline-1U)) != 0U) { - opstartaddr &= (~(cacheline - 1U)); + if ((adr & (cacheline-1U)) != 0U) { + adr &= (~(cacheline - 1U)); + unalignedstart = 1; - Xil_L1DCacheFlushLine(opstartaddr); + Xil_L1DCacheFlushLine(adr); #ifndef USE_AMP /* Disable Write-back and line fills */ Xil_L2WriteDebugCtrl(0x3U); - Xil_L2CacheFlushLine(opstartaddr); + Xil_L2CacheFlushLine(adr); /* Enable Write-back and line fills */ Xil_L2WriteDebugCtrl(0x0U); Xil_L2CacheSync(); #endif - opstartaddr += cacheline; + tempadr = adr; + (u32)adr >= LAST_CACHELINE_START ? (adr = endaddr) : (adr += cacheline); } if ((opendaddr & (cacheline-1U)) != 0U) { opendaddr &= (~(cacheline - 1U)); - if (opendaddr != opstartaddr) { + if ((opendaddr != tempadr) || (unalignedstart == 0x0U)) { Xil_L1DCacheFlushLine(opendaddr); #ifndef USE_AMP /* Disable Write-back and line fills */ @@ -343,31 +362,32 @@ void Xil_DCacheInvalidateRange(INTPTR opstartaddr, u32 len) /* Enable Write-back and line fills */ Xil_L2WriteDebugCtrl(0x0U); Xil_L2CacheSync(); + (u32)endaddr >= cacheline ? (endaddr -= cacheline) : (endaddr = 0); #endif } } - tempadr = opstartaddr; + tempadr = adr; - while (tempadr < endaddr) { #ifndef USE_AMP + while (tempadr < endaddr) { /* Invalidate L2 cache line */ *L2CCOffset = tempadr; Xil_L2CacheSync(); - tempadr += cacheline; -#endif + ((MAX_ADDR - (u32)tempadr) < cacheline) ? (tempadr = MAX_ADDR) : (tempadr += cacheline) ; } +#endif - while (opstartaddr < endaddr) { + while (adr < endaddr) { /* Invalidate L1 Data cache line */ #if defined (__GNUC__) || defined (__ICCARM__) - asm_cp15_inval_dc_line_mva_poc(opstartaddr); + asm_cp15_inval_dc_line_mva_poc(adr); #else { volatile register u32 Reg __asm(XREG_CP15_INVAL_DC_LINE_MVA_POC); - Reg = opstartaddr; } + Reg = adr; } #endif - opstartaddr += cacheline; + ((MAX_ADDR - (u32)adr) < cacheline) ? (adr = MAX_ADDR) : (adr += cacheline) ; } /* Wait for L1 cache invalidation to complete */ dsb(); @@ -444,7 +464,7 @@ void Xil_DCacheFlushLine(u32 adr) * @return None. * ****************************************************************************/ -void Xil_DCacheFlushRange(INTPTR opstartadr, u32 len) +void Xil_DCacheFlushRange(INTPTR adr, u32 len) { const u32 cacheline = 32U; u32 opendadr; @@ -458,10 +478,10 @@ void Xil_DCacheFlushRange(INTPTR opstartadr, u32 len) mtcpsr(currmask | IRQ_FIQ_MASK); if (len != 0U) { - opendadr = opstartadr + len; - opstartadr &= ~(cacheline - 1U); + ((MAX_ADDR - (u32)adr) < len) ? (opendadr = MAX_ADDR) : (opendadr = adr + len); + adr &= ~(cacheline - 1U); - tempadr = opstartadr; + tempadr = adr; while (tempadr < opendadr) { /* Flush L1 Data cache line */ @@ -472,7 +492,7 @@ void Xil_DCacheFlushRange(INTPTR opstartadr, u32 len) __asm(XREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC); Reg = tempadr; } #endif - tempadr += cacheline; + ((MAX_ADDR - (u32)tempadr) < cacheline) ? (tempadr = MAX_ADDR) : (tempadr += cacheline); } /* Wait for L1 cache clean and invalidation to complete */ dsb(); @@ -480,11 +500,11 @@ void Xil_DCacheFlushRange(INTPTR opstartadr, u32 len) #ifndef USE_AMP /* Disable Write-back and line fills */ Xil_L2WriteDebugCtrl(0x3U); - while ((u32)opstartadr < opendadr) { + while ((u32)adr < opendadr) { /* Flush L2 cache line */ - *L2CCOffset = opstartadr; + *L2CCOffset = adr; Xil_L2CacheSync(); - opstartadr += cacheline; + ((MAX_ADDR - (u32)adr) < cacheline) ? (adr = MAX_ADDR) : (adr += cacheline); } Xil_L2WriteDebugCtrl(0x0U); #endif @@ -627,7 +647,7 @@ void Xil_ICacheInvalidateRange(INTPTR adr, u32 len) /* Back the starting address up to the start of a cache line * perform cache operations until adr+len */ - end = LocalAddr + len; + ((MAX_ADDR - LocalAddr) < len) ? (end = MAX_ADDR) : (end = LocalAddr + len); LocalAddr = LocalAddr & ~(cacheline - 1U); while (LocalAddr < end) { @@ -645,7 +665,7 @@ void Xil_ICacheInvalidateRange(INTPTR adr, u32 len) __asm(XREG_CP15_INVAL_IC_LINE_MVA_POU); Reg = LocalAddr; } #endif - LocalAddr += cacheline; + ((MAX_ADDR - LocalAddr) < cacheline) ? (LocalAddr = MAX_ADDR) : (LocalAddr += cacheline) ; } /* Wait for L1 I cache invalidation to complete */ dsb(); @@ -860,7 +880,7 @@ void Xil_L1DCacheInvalidateRange(u32 adr, u32 len) /* Back the starting address up to the start of a cache line * perform cache operations until adr+len */ - end = LocalAddr + len; + ((MAX_ADDR - LocalAddr) < len) ? (end = MAX_ADDR) : (end = LocalAddr + len); LocalAddr = LocalAddr & ~(cacheline - 1U); while (LocalAddr < end) { @@ -872,7 +892,7 @@ void Xil_L1DCacheInvalidateRange(u32 adr, u32 len) __asm(XREG_CP15_INVAL_DC_LINE_MVA_POC); Reg = LocalAddr; } #endif - LocalAddr += cacheline; + ((MAX_ADDR - LocalAddr) < cacheline) ? (LocalAddr = MAX_ADDR) : (LocalAddr += cacheline); } /* Wait for L1 cache invalidation to complete */ @@ -1006,7 +1026,7 @@ void Xil_L1DCacheFlushRange(u32 adr, u32 len) /* Back the starting address up to the start of a cache line * perform cache operations until adr+len */ - end = LocalAddr + len; + ((MAX_ADDR - LocalAddr) < len) ? (end = MAX_ADDR) : (end = LocalAddr + len); LocalAddr = LocalAddr & ~(cacheline - 1U); while (LocalAddr < end) { @@ -1018,7 +1038,7 @@ void Xil_L1DCacheFlushRange(u32 adr, u32 len) __asm(XREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC); Reg = LocalAddr; } #endif - LocalAddr += cacheline; + ((MAX_ADDR - LocalAddr) < cacheline) ? (LocalAddr = MAX_ADDR) : (LocalAddr += cacheline); } /* Wait for L1 cache clean and invalidation to complete */ @@ -1182,7 +1202,7 @@ void Xil_L1ICacheInvalidateRange(u32 adr, u32 len) /* Back the starting address up to the start of a cache line * perform cache operations until adr+len */ - end = LocalAddr + len; + ((MAX_ADDR - LocalAddr) < len) ? (end = MAX_ADDR) : (end = LocalAddr + len); LocalAddr = LocalAddr & ~(cacheline - 1U); while (LocalAddr < end) { @@ -1194,7 +1214,7 @@ void Xil_L1ICacheInvalidateRange(u32 adr, u32 len) __asm(XREG_CP15_INVAL_IC_LINE_MVA_POU); Reg = LocalAddr; } #endif - LocalAddr += cacheline; + ((MAX_ADDR - LocalAddr) < cacheline) ? (LocalAddr = MAX_ADDR) : (LocalAddr += cacheline); } /* Wait for L1 cache invalidation to complete */ @@ -1378,7 +1398,7 @@ void Xil_L2CacheInvalidateRange(u32 adr, u32 len) /* Back the starting address up to the start of a cache line * perform cache operations until adr+len */ - end = LocalAddr + len; + ((MAX_ADDR - LocalAddr) < len) ? (end = MAX_ADDR) : (end = LocalAddr + len); LocalAddr = LocalAddr & ~(cacheline - 1U); /* Disable Write-back and line fills */ @@ -1387,7 +1407,7 @@ void Xil_L2CacheInvalidateRange(u32 adr, u32 len) while (LocalAddr < end) { *L2CCOffset = LocalAddr; Xil_L2CacheSync(); - LocalAddr += cacheline; + ((MAX_ADDR - LocalAddr) < cacheline) ? (LocalAddr = MAX_ADDR) : (LocalAddr += cacheline); } /* Enable Write-back and line fills */ @@ -1489,7 +1509,7 @@ void Xil_L2CacheFlushRange(u32 adr, u32 len) /* Back the starting address up to the start of a cache line * perform cache operations until adr+len */ - end = LocalAddr + len; + ((MAX_ADDR - LocalAddr) < len) ? (end = MAX_ADDR) : (end = LocalAddr + len); LocalAddr = LocalAddr & ~(cacheline - 1U); /* Disable Write-back and line fills */ @@ -1498,7 +1518,7 @@ void Xil_L2CacheFlushRange(u32 adr, u32 len) while (LocalAddr < end) { *L2CCOffset = LocalAddr; Xil_L2CacheSync(); - LocalAddr += cacheline; + ((MAX_ADDR - LocalAddr) < cacheline) ? (LocalAddr = MAX_ADDR) : (LocalAddr += cacheline); } /* Enable Write-back and line fills */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cache.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cache.h index 75cd6f6..7c94568 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cache.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cache.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (c) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -26,6 +27,7 @@ * 3.04a sdm 01/02/12 Remove redundant dsb/dmb instructions in cache maintenance * APIs. * 6.8 aru 09/06/18 Removed compilation warnings for ARMCC toolchain. +* 9.0 ml 03/03/23 Updated function prototypes. * * ******************************************************************************/ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cryptoalginfo.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cryptoalginfo.h new file mode 100644 index 0000000..df95b88 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_cryptoalginfo.h @@ -0,0 +1,50 @@ +/******************************************************************************/ +/** +* Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +/****************************************************************************/ +/** +* @file xil_cryptoalginfo.h +* @{ +* @details +* +* Crypto algotithm information structure declaration. +* +*
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- -------- -------- ----------------------------------------------- +* 9.0 mmd 07/04/23 First release. +*+* +*****************************************************************************/ +#ifndef XIL_CRYPTOALGINFO_H +#define XIL_CRYPTOALGINFO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************** Include Files *********************************/ +#include "xil_types.h" + +/**************************** Type Definitions *******************************/ +typedef enum _Xil_CryptoAlgNistStatus { + NOT_APPLICABLE = 0x00, + NIST_COMPLIANT = 0x11, + NIST_NON_COMPLIANT = 0xFE, +} Xil_CryptoAlgNistStatus; + +typedef struct _Xil_CryptoAlgInfo { + u32 Version; + Xil_CryptoAlgNistStatus NistStatus; +} Xil_CryptoAlgInfo; + +#ifdef __cplusplus +} +#endif + +#endif /* XIL_CRYPTOALGINFO_H */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_exception.c b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_exception.c index 4388d52..e08ecb9 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_exception.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_exception.c @@ -1,7 +1,6 @@ /****************************************************************************** * Copyright (c) 2015 - 2022 Xilinx, Inc. All rights reserved. * Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. -* * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -44,10 +43,11 @@ * file to fix misra_c_2012_rule_5_6 violation. * 8.1 asa 02/12/23 Updated data abort and prefetch abort fault * status reporting for ARMv7. -* Updated Sync and SError fault status reporting -* for ARMv8. -* -* +* Updated Sync and SError fault status reporting +* for ARMv8. +* 9.0 ml 03/03/23 Add description to fix doxygen warnings. +* 9.0 ml 14/04/23 Add comment to default case in switch statement to fix +* misra-c violation. * * *****************************************************************************/ @@ -159,14 +159,14 @@ void Xil_ExceptionInit(void) /*****************************************************************************/ /** * @brief Register a handler for a specific exception. This handler is being -* called when the processor encounters the specified exception. +* called when the processor encounters the specified exception. * * @param Exception_id contains the ID of the exception source and should -* be in the range of 0 to XIL_EXCEPTION_ID_LAST. -* See xil_exception.h for further information. +* be in the range of 0 to XIL_EXCEPTION_ID_LAST. +* See xil_exception.h for further information. * @param Handler to the Handler for that exception. * @param Data is a reference to Data that will be passed to the -* Handler when it gets called. +* Handler when it gets called. * * @return None. * @@ -175,7 +175,7 @@ void Xil_ExceptionRegisterHandler(u32 Exception_id, Xil_ExceptionHandler Handler, void *Data) { -#if (defined (versal) && !defined(ARMR5) && EL3) || defined(ARMR52) +#if (defined (versal) && !defined(ARMR5) && EL3) if ( XIL_EXCEPTION_ID_IRQ_INT == Exception_id ) { /* @@ -209,7 +209,7 @@ void Xil_GetExceptionRegisterHandler(u32 Exception_id, Xil_ExceptionHandler *Handler, void **Data) { -#if (defined (versal) && !defined(ARMR5) && EL3) || defined(ARMR52) +#if (defined (versal) && !defined(ARMR5) && EL3) if ( XIL_EXCEPTION_ID_IRQ_INT == Exception_id ) { /* @@ -229,12 +229,12 @@ void Xil_GetExceptionRegisterHandler(u32 Exception_id, /*****************************************************************************/ /** * -* @brief Removes the Handler for a specific exception Id. The stub Handler -* is then registered for this exception Id. +* @brief Removes the Handler for a specific exception id. The stub Handler +* is then registered for this exception id. * * @param Exception_id contains the ID of the exception source and should -* be in the range of 0 to XIL_EXCEPTION_ID_LAST. -* See xil_exception.h for further information. +* be in the range of 0 to XIL_EXCEPTION_ID_LAST. +* See xil_exception.h for further information. * * @return None. * @@ -852,6 +852,8 @@ static u32 NotifyFaultStatusDetails(u32 Fault_Type, u32 FaultStatus) break; #endif default: + /* if above cases doesn't match, then + default case will execute and terminate a statement sequence */ break; } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_exception.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_exception.h index 3a5bb29..b517983 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_exception.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_exception.h @@ -75,8 +75,10 @@ #include "xil_types.h" #include "xpseudo_asm.h" #include "bspconfig.h" +#ifndef SDT #include "xparameters.h" #include "xdebug.h" +#endif #ifdef __cplusplus extern "C" { @@ -228,7 +230,7 @@ extern "C" { /* * XIL_EXCEPTION_ID_INT is defined for all Xilinx processors. */ -#if (defined (versal) && !defined(ARMR5) && EL3) || defined(ARMR52) +#if (defined (versal) && !defined(ARMR5) && EL3) #define XIL_EXCEPTION_ID_INT XIL_EXCEPTION_ID_FIQ_INT #else #define XIL_EXCEPTION_ID_INT XIL_EXCEPTION_ID_IRQ_INT @@ -267,7 +269,7 @@ extern XExc_VectorTableEntry XExc_VectorTable[]; * C-Style signature: void Xil_ExceptionEnableMask(Mask) * ******************************************************************************/ -#if (defined (versal) && !defined(ARMR5) && EL3) || defined(ARMR52) +#if (defined (versal) && !defined(ARMR5) && EL3) /* * Cortexa72 processor in versal is coupled with GIC-500, and GIC-500 supports * only FIQ at EL3. Hence, tweaking this macro to always enable FIQ @@ -295,7 +297,7 @@ extern XExc_VectorTableEntry XExc_VectorTable[]; * @note None. * ******************************************************************************/ -#if (defined (versal) && !defined(ARMR5) && EL3) || defined(ARMR52) +#if (defined (versal) && !defined(ARMR5) && EL3) #define Xil_ExceptionEnable() \ Xil_ExceptionEnableMask(XIL_EXCEPTION_FIQ) #else @@ -315,7 +317,7 @@ extern XExc_VectorTableEntry XExc_VectorTable[]; * C-Style signature: Xil_ExceptionDisableMask(Mask) * ******************************************************************************/ -#if (defined (versal) && !defined(ARMR5) && EL3) || defined(ARMR52) +#if (defined (versal) && !defined(ARMR5) && EL3) /* * Cortexa72 processor in versal is coupled with GIC-500, and GIC-500 supports * only FIQ at EL3. Hence, tweaking this macro to always disable FIQ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_io.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_io.h index 853ef6b..382bc87 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_io.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xil_io.h @@ -1,5 +1,6 @@ /****************************************************************************** -* Copyright (c) 2014 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2014 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -32,12 +33,12 @@ * 7.50 dp 02/12/21 Fix compilation error in Xil_EndianSwap32() that occur * when -Werror=conversion compiler flag is enabled * 7.5 mus 05/17/21 Update the functions with comments. It fixes CR#1067739. -* +* 9.0 ml 03/03/23 Add description and remove comments to fix doxygen warnings. * ******************************************************************************/ -#ifndef XIL_IO_H /* prevent circular inclusions */ -#define XIL_IO_H /* by using protection macros */ +#ifndef XIL_IO_H /**< prevent circular inclusions */ +#define XIL_IO_H /**< by using protection macros */ #ifdef __cplusplus extern "C" { @@ -63,25 +64,25 @@ extern u32 XStl_RegUpdate(u32 RegAddr, u32 RegVal); /***************** Macros (Inline Functions) Definitions *********************/ #if defined __GNUC__ #if defined (__MICROBLAZE__) -# define INST_SYNC mbar(0) -# define DATA_SYNC mbar(1) +# define INST_SYNC mbar(0) /**< Instruction Synchronization Barrier */ +# define DATA_SYNC mbar(1) /**< Data Synchronization Barrier */ # else -# define SYNCHRONIZE_IO dmb() -# define INST_SYNC isb() -# define DATA_SYNC dsb() +# define SYNCHRONIZE_IO dmb() /**< Data Memory Barrier */ +# define INST_SYNC isb() /**< Instruction Synchronization Barrier */ +# define DATA_SYNC dsb() /**< Data Synchronization Barrier */ # endif #else -# define SYNCHRONIZE_IO -# define INST_SYNC -# define DATA_SYNC -# define INST_SYNC -# define DATA_SYNC +# define SYNCHRONIZE_IO /**< Data Memory Barrier */ +# define INST_SYNC /**< Instruction Synchronization Barrier */ +# define DATA_SYNC /**< Data Synchronization Barrier */ +# define INST_SYNC /**< Instruction Synchronization Barrier */ +# define DATA_SYNC /**< Data Synchronization Barrier */ #endif #if defined (__GNUC__) || defined (__ICCARM__) || defined (__MICROBLAZE__) -#define INLINE inline +#define INLINE inline /**< static inline keyword */ #else -#define INLINE __inline +#define INLINE __inline /**
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- -------- -------- ----------------------------------------------- +* 1.0 gm 14/06/23 Initial release. +*+******************************************************************************/ + +/***************************** Include Files *********************************/ + +#include "bspconfig.h" +#if defined (XPM_SUPPORT) +#include "xil_assert.h" +#include "xparameters.h" +#include "pm_api_sys.h" +#include "xpm_nodeid.h" +#include "xstatus.h" +#include "xpm_init.h" + +/************************** Constant Definitions *****************************/ + +#define XPMU_IPI_CHANNEL_ID XPAR_XIPIPSU_0_DEVICE_ID + +/**************************** Type Definitions *******************************/ + +/***************** Macros (Inline Functions) Definitions *********************/ + +/************************** Variable Definitions *****************************/ + +static XIpiPsu IpiInst; +/************************** Function Prototypes ******************************/ + +/************************** Global Variables ********************************/ + +#ifdef VERSAL_NET +XpmNodeInfo XpmNodeData[] = { + /* { Base Address, Node ID, Reset ID } */ + { 0xF1B00000U, PM_DEV_USB_0, PM_RST_USB_0 }, /* USB_0 */ + { 0xF1C00000U, PM_DEV_USB_1, PM_RST_USB_1 }, /* USB_1 */ + { 0xF19E0000U, PM_DEV_GEM_0, PM_RST_GEM_0 }, /* GEM_0 */ + { 0xF19F0000U, PM_DEV_GEM_1, PM_RST_GEM_1 }, /* GEM_1 */ + { 0xF1960000U, PM_DEV_SPI_0, PM_RST_SPI_0 }, /* SPI_0 */ + { 0xF1970000U, PM_DEV_SPI_1, PM_RST_SPI_1 }, /* SPI_1 */ + { 0xF1940000U, PM_DEV_I2C_0, PM_RST_I2C_0 }, /* I2C_0 */ + { 0xF1950000U, PM_DEV_I2C_1, PM_RST_I2C_1 }, /* I2C_1 */ + { 0xF1980000U, PM_DEV_CAN_FD_0, PM_RST_CAN_FD_0 }, /* CAN_FD_0 */ + { 0xF1990000U, PM_DEV_CAN_FD_1, PM_RST_CAN_FD_1 }, /* CAN_FD_1 */ + { 0xF1920000U, PM_DEV_UART_0, PM_RST_UART_0 }, /* UART_0 */ + { 0xF1930000U, PM_DEV_UART_1, PM_RST_UART_1 }, /* UART_1 */ + { 0xF19D0000U, PM_DEV_GPIO, PM_RST_GPIO_LPD }, /* GPIO */ + { 0xF1DC0000U, PM_DEV_TTC_0, PM_RST_TTC_0 }, /* TTC_0 */ + { 0xF1DD0000U, PM_DEV_TTC_1, PM_RST_TTC_1 }, /* TTC_1 */ + { 0xF1DE0000U, PM_DEV_TTC_2, PM_RST_TTC_2 }, /* TTC_2 */ + { 0xF1DF0000U, PM_DEV_TTC_3, PM_RST_TTC_3 }, /* TTC_3 */ + { 0xEA420000U, PM_DEV_LPD_SWDT_0, PM_RST_SWDT_0 }, /* LPD_SWDT_0 */ + { 0xEA430000U, PM_DEV_LPD_SWDT_1, PM_RST_SWDT_1 }, /* LPD_SWDT_1 */ + { 0xECC10000U, PM_DEV_FPD_SWDT_0, PM_RST_FPD_SWDT_0 }, /* FPD_SWDT_0 */ + { 0xECD10000U, PM_DEV_FPD_SWDT_1, PM_RST_FPD_SWDT_1 }, /* FPD_SWDT_1 */ + { 0xECE10000U, PM_DEV_FPD_SWDT_2, PM_RST_FPD_SWDT_2 }, /* FPD_SWDT_2 */ + { 0xECF10000U, PM_DEV_FPD_SWDT_3, PM_RST_FPD_SWDT_3 }, /* FPD_SWDT_3 */ + { 0xF1010000U, PM_DEV_OSPI, PM_RST_OSPI }, /* OSPI */ + { 0xF1030000U, PM_DEV_QSPI, PM_RST_QSPI }, /* QSPI */ + { 0xF1020000U, PM_DEV_GPIO_PMC, PM_RST_GPIO_PMC }, /* GPIO_PMC */ + { 0xF1000000U, PM_DEV_I2C_PMC, PM_RST_I2C_PMC }, /* I2C_PMC */ + { 0xF1040000U, PM_DEV_SDIO_0, PM_RST_SDIO_0 }, /* SDIO_0 */ + { 0xF1050000U, PM_DEV_SDIO_1, PM_RST_SDIO_1 }, /* EMMC */ + { 0xEBD00000U, PM_DEV_ADMA_0, PM_RST_ADMA }, /* ADMA_0 */ + { 0xEBD10000U, PM_DEV_ADMA_1, PM_RST_ADMA }, /* ADMA_1 */ + { 0xEBD20000U, PM_DEV_ADMA_2, PM_RST_ADMA }, /* ADMA_2 */ + { 0xEBD30000U, PM_DEV_ADMA_3, PM_RST_ADMA }, /* ADMA_3 */ + { 0xEBD40000U, PM_DEV_ADMA_4, PM_RST_ADMA }, /* ADMA_4 */ + { 0xEBD50000U, PM_DEV_ADMA_5, PM_RST_ADMA }, /* ADMA_5 */ + { 0xEBD60000U, PM_DEV_ADMA_6, PM_RST_ADMA }, /* ADMA_6 */ + { 0xEBD70000U, PM_DEV_ADMA_7, PM_RST_ADMA }, /* ADMA_7 */ + { 0xEB300000U, PM_DEV_IPI_0, PM_RST_IPI }, /* IPI */ +}; +#elif defined(versal) +XpmNodeInfo XpmNodeData[] = { + /* { Base Address, Node ID, Reset ID } */ + { 0xFE200000U, PM_DEV_USB_0, PM_RST_USB_0 }, /* USB_0 */ + { 0xFF0C0000U, PM_DEV_GEM_0, PM_RST_GEM_0 }, /* GEM_0 */ + { 0xFF0D0000U, PM_DEV_GEM_1, PM_RST_GEM_1 }, /* GEM_1 */ + { 0xFF040000U, PM_DEV_SPI_0, PM_RST_SPI_0 }, /* SPI_0 */ + { 0xFF050000U, PM_DEV_SPI_1, PM_RST_SPI_1 }, /* SPI_1 */ + { 0xFF020000U, PM_DEV_I2C_0, PM_RST_I2C_0 }, /* I2C_0 */ + { 0xFF030000U, PM_DEV_I2C_1, PM_RST_I2C_1 }, /* I2C_1 */ + { 0xFF060000U, PM_DEV_CAN_FD_0, PM_RST_CAN_FD_0 }, /* CAN_FD_0 */ + { 0xFF070000U, PM_DEV_CAN_FD_1, PM_RST_CAN_FD_1 }, /* CAN_FD_1 */ + { 0xFF000000U, PM_DEV_UART_0, PM_RST_UART_0 }, /* UART_0 */ + { 0xFF010000U, PM_DEV_UART_1, PM_RST_UART_1 }, /* UART_1 */ + { 0xFF0B0000U, PM_DEV_GPIO, PM_RST_GPIO_LPD }, /* GPIO */ + { 0xFF0E0000U, PM_DEV_TTC_0, PM_RST_TTC_0 }, /* TTC_0 */ + { 0xFF0F0000U, PM_DEV_TTC_1, PM_RST_TTC_1 }, /* TTC_1 */ + { 0xFF100000U, PM_DEV_TTC_2, PM_RST_TTC_2 }, /* TTC_2 */ + { 0xFF110000U, PM_DEV_TTC_3, PM_RST_TTC_3 }, /* TTC_3 */ + { 0xFF120000U, PM_DEV_SWDT_LPD, PM_RST_SWDT_LPD }, /* SWDT_LPD */ + { 0xFD4D0000U, PM_DEV_SWDT_FPD, PM_RST_SWDT_FPD }, /* SWDT_FPD */ + { 0xF1010000U, PM_DEV_OSPI, PM_RST_OSPI }, /* OSPI */ + { 0xF1030000U, PM_DEV_QSPI, PM_RST_QSPI }, /* QSPI */ + { 0xF1020000U, PM_DEV_GPIO_PMC, PM_RST_GPIO_PMC }, /* GPIO_PMC */ + { 0xF1000000U, PM_DEV_I2C_PMC, PM_RST_I2C_PMC }, /* I2C_PMC */ + { 0xF1040000U, PM_DEV_SDIO_0, PM_RST_SDIO_0 }, /* SDIO_0 */ + { 0xF1050000U, PM_DEV_SDIO_1, PM_RST_SDIO_1 }, /* SDIO_1 */ + { 0xFFA80000U, PM_DEV_ADMA_0, PM_RST_ADMA }, /* ADMA_0 */ + { 0xFFA90000U, PM_DEV_ADMA_1, PM_RST_ADMA }, /* ADMA_1 */ + { 0xFFAA0000U, PM_DEV_ADMA_2, PM_RST_ADMA }, /* ADMA_2 */ + { 0xFFAB0000U, PM_DEV_ADMA_3, PM_RST_ADMA }, /* ADMA_3 */ + { 0xFFAC0000U, PM_DEV_ADMA_4, PM_RST_ADMA }, /* ADMA_4 */ + { 0xFFAD0000U, PM_DEV_ADMA_5, PM_RST_ADMA }, /* ADMA_5 */ + { 0xFFAE0000U, PM_DEV_ADMA_6, PM_RST_ADMA }, /* ADMA_6 */ + { 0xFFAF0000U, PM_DEV_ADMA_7, PM_RST_ADMA }, /* ADMA_7 */ + { 0xFF300000U, PM_DEV_IPI_0, PM_RST_IPI }, /* IPI */ +}; +#endif + +/****************************************************************************/ +/** + * * + * * @brief This API is used to provide the node id. + * * + * * @return Node ID if successful, otherwise XST_FAILURE. + * * + * * @note none + * * + * *****************************************************************************/ +UINTPTR XpmGetNodeId(UINTPTR BaseAddress) +{ + u32 id; + + for (id = 0; id < MAX_NODE_COUNT; id++) { + if (BaseAddress == XpmNodeData[id].BaseAddress) { + return XpmNodeData[id].NodeId; + } + } + return (UINTPTR)XST_FAILURE; +} + +/****************************************************************************/ +/** + * * + * * @brief This API is used to provide the reset id. + * * + * * @return Reset ID if successful, otherwise XST_FAILURE. + * * + * * @note none + * * + * *****************************************************************************/ +UINTPTR XpmGetResetId(UINTPTR BaseAddress) +{ + u32 id; + + for (id = 0; id < MAX_NODE_COUNT; id++) { + if (BaseAddress == XpmNodeData[id].BaseAddress) { + return XpmNodeData[id].ResetId; + } + } + return (UINTPTR)XST_FAILURE; +} + +static XStatus XpmIpiConfig(XIpiPsu *const IpiInst) +{ + XStatus status; + XIpiPsu_Config *IpiCfgPtr; + + Xil_AssertNonvoid(IpiInst != NULL); + + /* Look Up the config data */ + IpiCfgPtr = XIpiPsu_LookupConfig(XPMU_IPI_CHANNEL_ID); + if (NULL == IpiCfgPtr) { + status = XST_FAILURE; + xil_printf("%s ERROR in getting CfgPtr\n", __func__); + return status; + } + + /* Init with the Cfg Data */ + status = XIpiPsu_CfgInitialize(IpiInst, IpiCfgPtr, + IpiCfgPtr->BaseAddress); + if (XST_SUCCESS != status) { + xil_printf("%s ERROR #%d in configuring IPI\n", __func__, status); + } + return status; +} + +/****************************************************************************/ +/** + * * + * * This API initializes the ipi and xilpm through constructor. + * * + * * @return none + * * + * * @note none + * * + * *****************************************************************************/ +void __attribute__ ((constructor)) xpminit() +{ + XStatus status; + + status = XpmIpiConfig(&IpiInst); + if (XST_SUCCESS != status) { + xil_printf("IPI configuration failed.\n"); + } + + status = XPm_InitXilpm(&IpiInst); + if (XST_SUCCESS != status) { + xil_printf("Xilpm library initialization failed.\n"); + } +} +#endif diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xpm_init.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xpm_init.h new file mode 100644 index 0000000..f2856be --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xpm_init.h @@ -0,0 +1,46 @@ +/****************************************************************************** +*Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +*SPDX-License-Identifier: MIT +******************************************************************************/ + +/*****************************************************************************/ +/** +* +* @file xpm_init.h +* @addtogroup xpm_init xpm_init APIs +*
+* MODIFICATION HISTORY: +* +* Ver Who Date Changes +* ----- -------- -------- ----------------------------------------------- +* 1.0 gm 14/06/23 Initial release. +*+******************************************************************************/ + +#ifndef XPM_INIT_H +#define XPM_INIT_H + +/************************** Constant Definitions *****************************/ + +#if defined (XPM_SUPPORT) +#ifdef VERSAL_NET +#define MAX_NODE_COUNT 38 +#elif defined(versal) +#define MAX_NODE_COUNT 33 +#endif + +/**************************** Type Definitions *******************************/ + +typedef struct { + UINTPTR BaseAddress; + UINTPTR NodeId; + UINTPTR ResetId; +} XpmNodeInfo; + +/************************** Function Prototypes ******************************/ + +UINTPTR XpmGetNodeId(UINTPTR BaseAddress); +UINTPTR XpmGetResetId(UINTPTR BaseAddress); + +#endif +#endif diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xpseudo_asm_gcc.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xpseudo_asm_gcc.h index b8517d3..5721b4c 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xpseudo_asm_gcc.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xpseudo_asm_gcc.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (c) 2014 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved. +* Copyright (c) 2022 - 2024 Advanced Micro Devices, Inc. All rights reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -23,6 +23,7 @@ * 7.2 dp 04/30/20 Added clobber "cc" to mtcpsr for aarch32 processors * 8.0 mus 02/24/22 Added macro mfcpnotoken and mtcpnotoken. * 8.1 asa 02/13/23 Create macros to read ESR, FAR and ELR registers. +* 9.1 ml 11/15/23 Fix compilation errors reported with -std=c2x compiler flag * * ******************************************************************************/ @@ -56,9 +57,9 @@ extern "C" { #if defined (__aarch64__) /* pseudo assembler instructions */ #define mfcpsr() ({u32 rval = 0U; \ - asm volatile("mrs %0, DAIF" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, DAIF" : "=r" (rval));\ + rval;\ + }) #define mtcpsr(v) __asm__ __volatile__ ("msr DAIF, %0" : : "r" (v)) @@ -68,12 +69,10 @@ extern "C" { #define cpsief() //__asm__ __volatile__("cpsie f\n") #define cpsidf() //__asm__ __volatile__("cpsid f\n") - - #define mtgpr(rn, v) /*__asm__ __volatile__(\ "mov r" stringify(rn) ", %0 \n"\ : : "r" (v)\ - )*/ +)*/ #define mfgpr(rn) /*({u32 rval; \ __asm__ __volatile__(\ @@ -81,7 +80,7 @@ extern "C" { : "=r" (rval)\ );\ rval;\ - })*/ +})*/ /* memory synchronization operations */ @@ -94,47 +93,45 @@ extern "C" { /* Data Memory Barrier */ #define dmb() __asm__ __volatile__("dmb sy") - /* Memory Operations */ #define ldr(adr) ({u64 rval; \ - __asm__ __volatile__(\ - "ldr %0,[%1]"\ - : "=r" (rval) : "r" (adr)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "ldr %0,[%1]"\ + : "=r" (rval) : "r" (adr)\ + );\ + rval;\ + }) #if (EL3 == 1) #define mfelrel3() ({u64 rval = 0U; \ - asm volatile("mrs %0, ELR_EL3" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, ELR_EL3" : "=r" (rval));\ + rval;\ + }) #define mfesrel3() ({u64 rval = 0U; \ - asm volatile("mrs %0, ESR_EL3" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, ESR_EL3" : "=r" (rval));\ + rval;\ + }) #define mffarel3() ({u64 rval = 0U; \ - asm volatile("mrs %0, FAR_EL3" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, FAR_EL3" : "=r" (rval));\ + rval;\ + }) #else #define mfelrel1() ({u64 rval = 0U; \ - asm volatile("mrs %0, ELR_EL1" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, ELR_EL1" : "=r" (rval));\ + rval;\ + }) #define mfesrel1() ({u64 rval = 0U; \ - asm volatile("mrs %0, ESR_EL1" : "=r" (rval));\ - rval;\ - }) + __asm volatile("mrs %0, ESR_EL1" : "=r" (rval));\ + rval;\ + }) #define mffarel1() ({u64 rval = 0U; \ - asm volatile("mrs %0, FAR_EL1" : "=r" (rval));\ - rval;\ - }) - + __asm volatile("mrs %0, FAR_EL1" : "=r" (rval));\ + rval;\ + }) #endif @@ -144,17 +141,17 @@ extern "C" { /* pseudo assembler instructions */ #define mfcpsr() ({u32 rval = 0U; \ - __asm__ __volatile__(\ - "mrs %0, cpsr\n"\ - : "=r" (rval)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "mrs %0, cpsr\n"\ + : "=r" (rval)\ + );\ + rval;\ + }) #define mtcpsr(v) __asm__ __volatile__(\ - "msr cpsr,%0\n"\ - : : "r" (v) : "cc" \ - ) + "msr cpsr,%0\n"\ + : : "r" (v) : "cc" \ + ) #define cpsiei() __asm__ __volatile__("cpsie i\n") #define cpsidi() __asm__ __volatile__("cpsid i\n") @@ -162,20 +159,18 @@ extern "C" { #define cpsief() __asm__ __volatile__("cpsie f\n") #define cpsidf() __asm__ __volatile__("cpsid f\n") - - #define mtgpr(rn, v) __asm__ __volatile__(\ - "mov r" stringify(rn) ", %0 \n"\ - : : "r" (v)\ - ) + "mov r" stringify(rn) ", %0 \n"\ + : : "r" (v)\ + ) #define mfgpr(rn) ({u32 rval; \ - __asm__ __volatile__(\ - "mov %0,r" stringify(rn) "\n"\ - : "=r" (rval)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "mov %0,r" stringify(rn) "\n"\ + : "=r" (rval)\ + );\ + rval;\ + }) /* memory synchronization operations */ @@ -188,44 +183,43 @@ extern "C" { /* Data Memory Barrier */ #define dmb() __asm__ __volatile__ ("dmb" : : : "memory") - /* Memory Operations */ #define ldr(adr) ({u32 rval; \ - __asm__ __volatile__(\ - "ldr %0,[%1]"\ - : "=r" (rval) : "r" (adr)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "ldr %0,[%1]"\ + : "=r" (rval) : "r" (adr)\ + );\ + rval;\ + }) #endif #define ldrb(adr) ({u8 rval; \ - __asm__ __volatile__(\ - "ldrb %0,[%1]"\ - : "=r" (rval) : "r" (adr)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "ldrb %0,[%1]"\ + : "=r" (rval) : "r" (adr)\ + );\ + rval;\ + }) #define strw(adr, val) __asm__ __volatile__(\ - "str %0,[%1]\n"\ - : : "r" (val), "r" (adr)\ - ) + "str %0,[%1]\n"\ + : : "r" (val), "r" (adr)\ + ) #define strb(adr, val) __asm__ __volatile__(\ - "strb %0,[%1]\n"\ - : : "r" (val), "r" (adr)\ - ) + "strb %0,[%1]\n"\ + : : "r" (val), "r" (adr)\ + ) /* Count leading zeroes (clz) */ #define clz(arg) ({u8 rval; \ - __asm__ __volatile__(\ - "clz %0,%1"\ - : "=r" (rval) : "r" (arg)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "clz %0,%1"\ + : "=r" (rval) : "r" (arg)\ + );\ + rval;\ + }) #if defined (__aarch64__) #define mtcpdc(reg,val) __asm__ __volatile__("dc " #reg ",%0" : : "r" (val)) @@ -236,14 +230,14 @@ extern "C" { #define mtcpat(reg,val) __asm__ __volatile__("at " #reg ",%0" : : "r" (val)) /* CP15 operations */ #define mfcp(reg) ({u64 rval = 0U;\ - __asm__ __volatile__("mrs %0, " #reg : "=r" (rval));\ - rval;\ - }) + __asm__ __volatile__("mrs %0, " #reg : "=r" (rval));\ + rval;\ + }) #define mfcpnotoken(reg) ({u64 rval = 0U;\ - __asm__ __volatile__("mrs %0, " reg : "=r" (rval));\ - rval;\ - }) + __asm__ __volatile__("mrs %0, " reg : "=r" (rval));\ + rval;\ + }) #define mtcp(reg,val) __asm__ __volatile__("msr " #reg ",%0" : : "r" (val)) #define mtcpnotoken(reg,val) __asm__ __volatile__("msr " reg ",%0" : : "r" (val)) @@ -251,22 +245,22 @@ extern "C" { #else /* CP15 operations */ #define mtcp(rn, v) __asm__ __volatile__(\ - "mcr " rn "\n"\ - : : "r" (v)\ - ); + "mcr " rn "\n"\ + : : "r" (v)\ + ); #define mfcp(rn) ({u32 rval = 0U; \ - __asm__ __volatile__(\ - "mrc " rn "\n"\ - : "=r" (rval)\ - );\ - rval;\ - }) + __asm__ __volatile__(\ + "mrc " rn "\n"\ + : "=r" (rval)\ + );\ + rval;\ + }) #define mtcp2(rn, v) __asm__ __volatile__(\ - "mcrr " rn "\n"\ - : : "r" (v), "r" (0)\ - ); + "mcrr " rn "\n"\ + : : "r" (v), "r" (0)\ + ); #endif diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xreg_cortexa9.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xreg_cortexa9.h index 2a4fff2..0d2c7b1 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xreg_cortexa9.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xreg_cortexa9.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (c) 2009 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -20,6 +21,7 @@ * Ver Who Date Changes * ----- -------- -------- ----------------------------------------------- * 1.00a ecm/sdm 10/20/09 First release +* 9.0 mus 07/29/23 Added definitions for processor affinity register. * * ******************************************************************************/ @@ -489,7 +491,10 @@ extern "C" { #define XREG_CP15_MAIN_TLB_ATTR "cp15:5:c15:c7:2" #endif - +/* Affinity register bits */ +#define XREG_MPIDR_MASK 0xFFFFFFFFU +#define XREG_MPIDR_AFFINITY0_MASK 0x3U +#define XREG_MPIDR_AFFINITY0_SHIFT 0x0U /* MPE register definitions */ #define XREG_FPSID c0 #define XREG_FPSCR c1 diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xstatus.h b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xstatus.h index 85d1e73..f534bdf 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xstatus.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/xstatus.h @@ -32,6 +32,7 @@ extern "C" { #include "xil_types.h" #include "xil_assert.h" +#include "bspconfig.h" /************************** Constant Definitions *****************************/ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps.c b/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps.c index 56727eb..49f2c5b 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -41,6 +41,17 @@ * 3.10 aru 05/06/19 Added assert check for driver instance and freq * parameter in XTtcPs_CalcIntervalFromFreq(). * 3.10 aru 05/30/19 Added interrupt handler to clear ISR +* 3.18 gm 06/26/23 Added PM Request node support. +* 3.18 gm 07/17/23 Added PM Release node support. +* 3.18 ml 09/08/23 Updated code by using ternary operator +* to fix MISRA-C violation for Rule 10.3 +* 3.18 ml 09/08/23 Replaced TRUE with Numerical value to fix +* MISRA-C violation for Rule 10.5 +* 3.18 ml 09/07/23 Removed XTtcPs_ClearInterruptStatus function call to avoid the +* the same operation for 2 times. +* 3.18 ml 09/07/23 Added U to numerical to fix MISRA-C violation for Rule 10.4 +* 3.18 ml 09/08/23 Typecast with u32 to fix MISRA-C violation for Rule 12.2 and 10.7 +* 3.18 ml 09/08/23 Added comments to fix HIS COMF violations. * * ******************************************************************************/ @@ -48,6 +59,14 @@ /***************************** Include Files *********************************/ #include "xttcps.h" +#if defined (XPM_SUPPORT) +#include "pm_defs.h" +#include "pm_api_sys.h" +#include "xil_types.h" +#include "pm_client.h" +#include "xpm_init.h" +#include "xdebug.h" +#endif /************************** Constant Definitions *****************************/ @@ -59,6 +78,35 @@ static void StubStatusHandler(const void *CallBackRef, u32 StatusEvent); /************************** Variable Definitions *****************************/ +#if defined (XPM_SUPPORT) +/* + * Instance - counters list + * Ttc0 - 0 to 2 + * Ttc1 - 3 to 5 + * Ttc2 - 6 to 8 + * Ttc3 - 9 to 11 + * + * TtcNodeState is an array which holds the present state of the counter + * in it's corresponding index value. Index value will be incremented + * during ttc counter request node and decremented during release node. + * + */ +static u32 TtcNodeState[XPAR_XTTCPS_NUM_INSTANCES]; + +extern XTtcPs_Config XTtcPs_ConfigTable[XPAR_XTTCPS_NUM_INSTANCES]; + +static u32 GetTtcNodeAddress(u16 DeviceId) +{ + u32 Index; + + for (Index = 0U; Index < (u32)XPAR_XTTCPS_NUM_INSTANCES; Index++) { + if (XTtcPs_ConfigTable[Index].DeviceId == DeviceId) { + return XTtcPs_ConfigTable[Index].BaseAddress; + } + } + return 0; +} +#endif /*****************************************************************************/ /** @@ -97,34 +145,68 @@ static void StubStatusHandler(const void *CallBackRef, u32 StatusEvent); * ******************************************************************************/ s32 XTtcPs_CfgInitialize(XTtcPs *InstancePtr, XTtcPs_Config *ConfigPtr, - u32 EffectiveAddr) + u32 EffectiveAddr) { s32 Status; u32 IsStartResult; +#if defined (XPM_SUPPORT) + u32 TtcNodeAddr; +#endif +#ifdef SDT + u16 Count; +#endif + /* * Assert to validate input arguments. */ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(ConfigPtr != NULL); +#if defined (XPM_SUPPORT) + TtcNodeAddr = GetTtcNodeAddress((ConfigPtr->DeviceId / 3) * 3); + + Status = XPm_RequestNode(XpmGetNodeId((UINTPTR)TtcNodeAddr), PM_CAP_ACCESS, MAX_QOS, REQUEST_ACK_BLOCKING); + if (XST_SUCCESS != Status) { + xdbg_printf(XDBG_DEBUG_ERROR, "Ttc: XPm_RequestNode failed\r\n"); + return Status; + } + + Status = XPm_ResetAssert(XpmGetResetId((UINTPTR)TtcNodeAddr), XILPM_RESET_ACTION_RELEASE); + if (XST_SUCCESS != Status) { + xdbg_printf(XDBG_DEBUG_ERROR, "Ttc: XPm_ResetAssert() ERROR=0x%x \r\n", Status); + return Status; + } + + TtcNodeState[ConfigPtr->DeviceId]++; +#endif + /* * Set some default values */ +#ifndef SDT InstancePtr->Config.DeviceId = ConfigPtr->DeviceId; +#endif InstancePtr->Config.BaseAddress = EffectiveAddr; InstancePtr->Config.InputClockHz = ConfigPtr->InputClockHz; InstancePtr->StatusHandler = StubStatusHandler; -#ifdef XIL_INTERRUPT +#if defined(XIL_INTERRUPT) && !defined(SDT) InstancePtr->Config.IntrId = ConfigPtr->IntrId; InstancePtr->Config.IntrParent = ConfigPtr->IntrParent; #endif - IsStartResult = XTtcPs_IsStarted(InstancePtr); +#ifdef SDT + for (Count = 0; Count < XTTCPS_NUM_COUNTERS; Count++) { + InstancePtr->Config.IntrId[Count] = ConfigPtr->IntrId[Count]; + } + InstancePtr->Config.IntrParent = ConfigPtr->IntrParent; +#endif + + IsStartResult = XTtcPs_IsStarted(InstancePtr) ? 1U : 0U; /* * If the timer counter has already started, return an error * Device should be stopped first. */ - if(IsStartResult == (u32)TRUE) { + if (IsStartResult == 1U) { Status = XST_DEVICE_IS_STARTED; } else { @@ -136,26 +218,26 @@ s32 XTtcPs_CfgInitialize(XTtcPs *InstancePtr, XTtcPs_Config *ConfigPtr, * Reset the count control register to it's default value. */ XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_CNT_CNTRL_OFFSET, - XTTCPS_CNT_CNTRL_RESET_VALUE); + XTTCPS_CNT_CNTRL_OFFSET, + XTTCPS_CNT_CNTRL_RESET_VALUE); /* * Reset the rest of the registers to the default values. */ XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_CLK_CNTRL_OFFSET, 0x00U); + XTTCPS_CLK_CNTRL_OFFSET, 0x00U); XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_INTERVAL_VAL_OFFSET, 0x00U); + XTTCPS_INTERVAL_VAL_OFFSET, 0x00U); XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_MATCH_0_OFFSET, 0x00U); + XTTCPS_MATCH_0_OFFSET, 0x00U); XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_MATCH_1_OFFSET, 0x00U); + XTTCPS_MATCH_1_OFFSET, 0x00U); XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_MATCH_2_OFFSET, 0x00U); + XTTCPS_MATCH_2_OFFSET, 0x00U); XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_IER_OFFSET, 0x00U); + XTTCPS_IER_OFFSET, 0x00U); XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_ISR_OFFSET, XTTCPS_IXR_ALL_MASK); + XTTCPS_ISR_OFFSET, XTTCPS_IXR_ALL_MASK); InstancePtr->IsReady = XIL_COMPONENT_IS_READY; @@ -168,6 +250,81 @@ s32 XTtcPs_CfgInitialize(XTtcPs *InstancePtr, XTtcPs_Config *ConfigPtr, return Status; } +#if defined (XPM_SUPPORT) +static u32 CheckTtcNodeState(u16 TtcNodeId) +{ + u8 IdOffset; + u16 TtcBaseNodeId; + u32 State = FALSE; + + TtcBaseNodeId = ((TtcNodeId / 3) * 3); + + for (IdOffset = TtcBaseNodeId; IdOffset < (TtcBaseNodeId + 3); IdOffset++) { + if (TtcNodeState[IdOffset] == 0) { + continue; + } else { + if (IdOffset == TtcNodeId) { + if ((TtcNodeState[IdOffset] - 1) == 0) { + continue; + } + } + State = TRUE; + break; + } + } + return State; +} +#endif + +/*****************************************************************************/ +/** +* +* This routine releases resources of XTtcPs instance/driver. +* +* @param None +* @return - XST_SUCCESS if node release was successful +* - XST_FAILURE if node release was fail, Node won't be released +* if any other counter/counters in that TTC in use. +* +* @note None. +* +******************************************************************************/ +u32 XTtcPs_Release(XTtcPs *InstancePtr) +{ + u32 Status = XST_SUCCESS; +#if defined (XPM_SUPPORT) + u32 TtcNodeAddr; +#endif + + Xil_AssertNonvoid(InstancePtr != NULL); + +#if defined (XPM_SUPPORT) + if (InstancePtr->Config.DeviceId >= XPAR_XTTCPS_NUM_INSTANCES) { + Status = XST_FAILURE; + } else { + /* Stop ttc */ + XTtcPs_Stop(InstancePtr); + + /* Clear interrupt status */ + XTtcPs_ClearInterruptStatus(InstancePtr, + XTtcPs_GetInterruptStatus(InstancePtr)); + + /* Disable interrupts */ + XTtcPs_DisableInterrupts(InstancePtr, XTTCPS_IXR_ALL_MASK); + + /* Release node, if no other counter in use under that ttc node */ + if (TRUE == CheckTtcNodeState(InstancePtr->Config.DeviceId)) { + Status = XST_FAILURE; + } else { + TtcNodeAddr = GetTtcNodeAddress((InstancePtr->Config.DeviceId / 3) * 3); + Status = XPm_ReleaseNode(XpmGetNodeId((UINTPTR)TtcNodeAddr)); + TtcNodeState[InstancePtr->Config.DeviceId]--; + } + } +#endif + return Status; +} + /*****************************************************************************/ /** * @@ -196,7 +353,7 @@ s32 XTtcPs_CfgInitialize(XTtcPs *InstancePtr, XTtcPs_Config *ConfigPtr, void XTtcPs_SetMatchValue(XTtcPs *InstancePtr, u8 MatchIndex, XMatchRegValue Value) { /* - * Assert to validate input arguments. + * Validate input arguments and in case of error conditions assert. */ Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); @@ -206,7 +363,7 @@ void XTtcPs_SetMatchValue(XTtcPs *InstancePtr, u8 MatchIndex, XMatchRegValue Val * Write the value to the correct match register with MatchIndex */ XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTtcPs_Match_N_Offset(MatchIndex), Value); + XTtcPs_Match_N_Offset(MatchIndex), Value); } /*****************************************************************************/ @@ -230,14 +387,14 @@ XMatchRegValue XTtcPs_GetMatchValue(XTtcPs *InstancePtr, u8 MatchIndex) u32 MatchReg; /* - * Assert to validate input arguments. + * Validate input arguments and in case of error conditions assert. */ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); Xil_AssertNonvoid(MatchIndex < XTTCPS_NUM_MATCH_REG); MatchReg = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress, - XTtcPs_Match_N_Offset(MatchIndex)); + XTtcPs_Match_N_Offset(MatchIndex)); return (XMatchRegValue) MatchReg; } @@ -278,7 +435,7 @@ void XTtcPs_SetPrescaler(XTtcPs *InstancePtr, u8 PrescalerValue) * Read the clock control register */ ClockReg = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress, - XTTCPS_CLK_CNTRL_OFFSET); + XTTCPS_CLK_CNTRL_OFFSET); /* * Clear all of the prescaler control bits in the register @@ -291,7 +448,7 @@ void XTtcPs_SetPrescaler(XTtcPs *InstancePtr, u8 PrescalerValue) * Set the prescaler value and enable prescaler */ ClockReg |= (u32)(((u32)PrescalerValue << (u32)XTTCPS_CLK_CNTRL_PS_VAL_SHIFT) & - (u32)XTTCPS_CLK_CNTRL_PS_VAL_MASK); + (u32)XTTCPS_CLK_CNTRL_PS_VAL_MASK); ClockReg |= (u32)XTTCPS_CLK_CNTRL_PS_EN_MASK; } @@ -299,7 +456,7 @@ void XTtcPs_SetPrescaler(XTtcPs *InstancePtr, u8 PrescalerValue) * Write the register with the new values. */ XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_CLK_CNTRL_OFFSET, ClockReg); + XTTCPS_CLK_CNTRL_OFFSET, ClockReg); } /*****************************************************************************/ @@ -341,18 +498,17 @@ u8 XTtcPs_GetPrescaler(XTtcPs *InstancePtr) * Read the clock control register */ ClockReg = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress, - XTTCPS_CLK_CNTRL_OFFSET); + XTTCPS_CLK_CNTRL_OFFSET); - if (0 == (ClockReg & XTTCPS_CLK_CNTRL_PS_EN_MASK)) { + if (0U == (ClockReg & XTTCPS_CLK_CNTRL_PS_EN_MASK)) { /* * Prescaler is disabled. Return the correct flag value */ Status = (u8)XTTCPS_CLK_CNTRL_PS_DISABLE; - } - else { + } else { Status = (u8)((ClockReg & (u32)XTTCPS_CLK_CNTRL_PS_VAL_MASK) >> - (u32)XTTCPS_CLK_CNTRL_PS_VAL_SHIFT); + (u32)XTTCPS_CLK_CNTRL_PS_VAL_SHIFT); } return Status; } @@ -382,17 +538,17 @@ u8 XTtcPs_GetPrescaler(XTtcPs *InstancePtr) * ****************************************************************************/ void XTtcPs_CalcIntervalFromFreq(XTtcPs *InstancePtr, u32 Freq, - XInterval *Interval, u8 *Prescaler) + XInterval *Interval, u8 *Prescaler) { u8 TmpPrescaler; UINTPTR TempValue; u32 InputClock; /* - * Assert to validate input arguments. - */ + * Assert to validate input arguments. + */ Xil_AssertVoid(InstancePtr != NULL); - Xil_AssertVoid(Freq > 0U); + Xil_AssertVoid(Freq > 0U); InputClock = InstancePtr->Config.InputClockHz; /* @@ -400,7 +556,7 @@ void XTtcPs_CalcIntervalFromFreq(XTtcPs *InstancePtr, u32 Freq, * smaller the prescaler, the larger the count and the more accurate the * PWM setting. */ - TempValue = InputClock/ Freq; + TempValue = InputClock / Freq; if (TempValue < 4U) { /* @@ -427,7 +583,7 @@ void XTtcPs_CalcIntervalFromFreq(XTtcPs *InstancePtr, u32 Freq, for (TmpPrescaler = 0U; TmpPrescaler < XTTCPS_CLK_CNTRL_PS_DISABLE; TmpPrescaler++) { - TempValue = InputClock/ (Freq * (1U << (TmpPrescaler + 1U))); + TempValue = InputClock / (Freq * ((u32)1U << (TmpPrescaler + 1U))); /* * The first value less than 2^16 is the best bet @@ -469,16 +625,10 @@ u32 XTtcPs_InterruptHandler(XTtcPs *InstancePtr) { u32 XTtcPsStatusReg; - Xil_AssertNonvoid(InstancePtr != NULL); - XTtcPsStatusReg = XTtcPs_GetInterruptStatus(InstancePtr); - XTtcPs_ClearInterruptStatus(InstancePtr, XTtcPsStatusReg); InstancePtr->StatusHandler(InstancePtr->StatusRef, - XTtcPsStatusReg); + XTtcPsStatusReg); return XST_SUCCESS; - - - } /*****************************************************************************/ @@ -505,12 +655,14 @@ u32 XTtcPs_InterruptHandler(XTtcPs *InstancePtr) * ******************************************************************************/ void XTtcPs_SetStatusHandler(XTtcPs *InstancePtr, void *CallBackRef, - XTtcPs_StatusHandler FuncPointer) + XTtcPs_StatusHandler FuncPointer) { + /* + * Validate input arguments and in case of error conditions assert. + */ Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(FuncPointer != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); - InstancePtr->StatusHandler = FuncPointer; InstancePtr->StatusRef = CallBackRef; } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps.h b/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps.h index 643e73e..e62fc6f 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -149,6 +149,7 @@ * It fixes CR#1084697. * 3.16 adk 04/19/22 Fix infinite loop in the examples by adding polled * timeout loop. +* 3.18 adk 04/14/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -181,6 +182,7 @@ typedef void (*XTtcPs_StatusHandler) (const void *CallBackRef, u32 StatusEvent); #define XTTCPS_MAX_INTERVAL_COUNT 0xFFFFFFFFU #endif +#define XTTCPS_NUM_COUNTERS 3U /** @name Configuration options * * Options for the device. Each of the options is bit field, so more than one @@ -203,11 +205,18 @@ typedef void (*XTtcPs_StatusHandler) (const void *CallBackRef, u32 StatusEvent); * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID for device */ +#else + char *Name; +#endif u32 BaseAddress; /**< Base address for device */ u32 InputClockHz; /**< Input clock frequency */ -#ifdef XIL_INTERRUPT - u16 IntrId; +#if !defined(SDT) && defined(XIL_INTERRUPT) + u32 IntrId; + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] Parent base address */ +#elif defined(SDT) + u32 IntrId[XTTCPS_NUM_COUNTERS]; /** Bits[11:0] Interrupt-id Bits[15:12] trigger type and level flags */ UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] Parent base address */ #endif } XTtcPs_Config; @@ -487,7 +496,11 @@ typedef u32 XMatchRegValue; /* * Initialization functions in xttcps_sinit.c */ +#ifndef SDT XTtcPs_Config *XTtcPs_LookupConfig(u16 DeviceId); +#else +XTtcPs_Config *XTtcPs_LookupConfig(u32 BaseAddress); +#endif /* * Required functions, in xttcps.c @@ -495,6 +508,7 @@ XTtcPs_Config *XTtcPs_LookupConfig(u16 DeviceId); s32 XTtcPs_CfgInitialize(XTtcPs *InstancePtr, XTtcPs_Config * ConfigPtr, u32 EffectiveAddr); +u32 XTtcPs_Release(XTtcPs *InstancePtr); void XTtcPs_SetMatchValue(XTtcPs *InstancePtr, u8 MatchIndex, XMatchRegValue Value); XMatchRegValue XTtcPs_GetMatchValue(XTtcPs *InstancePtr, u8 MatchIndex); diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_options.c b/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_options.c index 6da2260..a65f29a 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_options.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_options.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -23,6 +23,8 @@ * compilation warnings. * 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance. * 3.10 aru 05/16/19 Removed the redudant code from XTtcPs_SetOptions(). +* 3.18 ml 09/08/23 Updated code to fix MISRA-C violation for Rule 14.3 +* 3.18 ml 09/08/23 Added comments to fix HIS COMF violations. * * ******************************************************************************/ @@ -57,24 +59,38 @@ typedef struct { } OptionsMap; static OptionsMap TmrCtrOptionsTable[] = { - {XTTCPS_OPTION_EXTERNAL_CLK, XTTCPS_CLK_CNTRL_SRC_MASK, - XTTCPS_CLK_CNTRL_OFFSET}, - {XTTCPS_OPTION_CLK_EDGE_NEG, XTTCPS_CLK_CNTRL_EXT_EDGE_MASK, - XTTCPS_CLK_CNTRL_OFFSET}, - {XTTCPS_OPTION_INTERVAL_MODE, XTTCPS_CNT_CNTRL_INT_MASK, - XTTCPS_CNT_CNTRL_OFFSET}, - {XTTCPS_OPTION_DECREMENT, XTTCPS_CNT_CNTRL_DECR_MASK, - XTTCPS_CNT_CNTRL_OFFSET}, - {XTTCPS_OPTION_MATCH_MODE, XTTCPS_CNT_CNTRL_MATCH_MASK, - XTTCPS_CNT_CNTRL_OFFSET}, - {XTTCPS_OPTION_WAVE_DISABLE, XTTCPS_CNT_CNTRL_EN_WAVE_MASK, - XTTCPS_CNT_CNTRL_OFFSET}, - {XTTCPS_OPTION_WAVE_POLARITY, XTTCPS_CNT_CNTRL_POL_WAVE_MASK, - XTTCPS_CNT_CNTRL_OFFSET}, + { + XTTCPS_OPTION_EXTERNAL_CLK, XTTCPS_CLK_CNTRL_SRC_MASK, + XTTCPS_CLK_CNTRL_OFFSET + }, + { + XTTCPS_OPTION_CLK_EDGE_NEG, XTTCPS_CLK_CNTRL_EXT_EDGE_MASK, + XTTCPS_CLK_CNTRL_OFFSET + }, + { + XTTCPS_OPTION_INTERVAL_MODE, XTTCPS_CNT_CNTRL_INT_MASK, + XTTCPS_CNT_CNTRL_OFFSET + }, + { + XTTCPS_OPTION_DECREMENT, XTTCPS_CNT_CNTRL_DECR_MASK, + XTTCPS_CNT_CNTRL_OFFSET + }, + { + XTTCPS_OPTION_MATCH_MODE, XTTCPS_CNT_CNTRL_MATCH_MASK, + XTTCPS_CNT_CNTRL_OFFSET + }, + { + XTTCPS_OPTION_WAVE_DISABLE, XTTCPS_CNT_CNTRL_EN_WAVE_MASK, + XTTCPS_CNT_CNTRL_OFFSET + }, + { + XTTCPS_OPTION_WAVE_POLARITY, XTTCPS_CNT_CNTRL_POL_WAVE_MASK, + XTTCPS_CNT_CNTRL_OFFSET + }, }; #define XTTCPS_NUM_TMRCTR_OPTIONS (sizeof(TmrCtrOptionsTable) / \ - sizeof(OptionsMap)) + sizeof(OptionsMap)) /*****************************************************************************/ /** @@ -100,48 +116,43 @@ s32 XTtcPs_SetOptions(XTtcPs *InstancePtr, u32 Options) u32 CountReg; u32 ClockReg; u32 Index; - s32 Status = XST_SUCCESS; - + /* + * Validate input arguments and in case of error conditions assert. + */ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); - ClockReg = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress, - XTTCPS_CLK_CNTRL_OFFSET); + XTTCPS_CLK_CNTRL_OFFSET); CountReg = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress, - XTTCPS_CNT_CNTRL_OFFSET); - + XTTCPS_CNT_CNTRL_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 = 0U; Index < XTTCPS_NUM_TMRCTR_OPTIONS; Index++) { if ((Options & TmrCtrOptionsTable[Index].Option) != (u32)0) { - if(TmrCtrOptionsTable[Index].Register == XTTCPS_CLK_CNTRL_OFFSET) { + if (TmrCtrOptionsTable[Index].Register == XTTCPS_CLK_CNTRL_OFFSET) { ClockReg |= TmrCtrOptionsTable[Index].Mask; } else { CountReg |= TmrCtrOptionsTable[Index].Mask; } } else { - if(TmrCtrOptionsTable[Index].Register == XTTCPS_CLK_CNTRL_OFFSET) { + if (TmrCtrOptionsTable[Index].Register == XTTCPS_CLK_CNTRL_OFFSET) { ClockReg &= ~TmrCtrOptionsTable[Index].Mask; } else { CountReg &= ~TmrCtrOptionsTable[Index].Mask; } } } - /* * Now write the registers. Leave it to the upper layers to restart the * device. */ - if (Status != (s32)XST_FAILURE ) { - XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_CLK_CNTRL_OFFSET, ClockReg); - XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, - XTTCPS_CNT_CNTRL_OFFSET, CountReg); - } - - return Status; + XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, + XTTCPS_CLK_CNTRL_OFFSET, ClockReg); + XTtcPs_WriteReg(InstancePtr->Config.BaseAddress, + XTTCPS_CNT_CNTRL_OFFSET, CountReg); + return XST_SUCCESS; } /*****************************************************************************/ @@ -167,6 +178,9 @@ u32 XTtcPs_GetOptions(XTtcPs *InstancePtr) u32 Register; u32 Index; + /* + * Validate input arguments and in case of error conditions assert. + */ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); @@ -180,14 +194,13 @@ u32 XTtcPs_GetOptions(XTtcPs *InstancePtr) * currently set. */ Register = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress, - TmrCtrOptionsTable[Index]. - Register); + TmrCtrOptionsTable[Index]. + Register); if ((Register & TmrCtrOptionsTable[Index].Mask) != (u32)0) { OptionsFlag |= TmrCtrOptionsTable[Index].Option; } } - return OptionsFlag; } /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_selftest.c b/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_selftest.c index a0be259..f1a4676 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_selftest.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_selftest.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -21,6 +21,7 @@ * ----- ------ -------- --------------------------------------------- * 1.00a drg/jz 01/21/10 First release * 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance. +* 3.18 ml 09/08/23 Added comments to fix HIS COMF violations. * * ******************************************************************************/ @@ -65,6 +66,9 @@ s32 XTtcPs_SelfTest(XTtcPs *InstancePtr) s32 Status; u32 TempReg; + /* + * Validate input arguments and in case of error conditions assert. + */ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); @@ -72,11 +76,10 @@ s32 XTtcPs_SelfTest(XTtcPs *InstancePtr) * All the TTC registers should be in their default state right now. */ TempReg = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress, - XTTCPS_CNT_CNTRL_OFFSET); + XTTCPS_CNT_CNTRL_OFFSET); if (XTTCPS_CNT_CNTRL_RESET_VALUE != (u32)TempReg) { Status = XST_FAILURE; - } - else { + } else { Status = XST_SUCCESS; } return Status; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_sinit.c index 5d50de9..4b104b8 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/ttcps/src/xttcps_sinit.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -27,7 +27,9 @@ /***************************** Include Files *********************************/ #include "xttcps.h" +#ifndef SDT #include "xparameters.h" +#endif /************************** Constant Definitions *****************************/ @@ -38,7 +40,11 @@ /************************** Function Prototypes ******************************/ /************************** Variable Definitions *****************************/ +#ifndef SDT extern XTtcPs_Config XTtcPs_ConfigTable[XPAR_XTTCPS_NUM_INSTANCES]; +#else +extern XTtcPs_Config XTtcPs_ConfigTable[]; +#endif /*****************************************************************************/ /** @@ -56,6 +62,7 @@ extern XTtcPs_Config XTtcPs_ConfigTable[XPAR_XTTCPS_NUM_INSTANCES]; * @note None. * ******************************************************************************/ +#ifndef SDT XTtcPs_Config *XTtcPs_LookupConfig(u16 DeviceId) { XTtcPs_Config *CfgPtr = NULL; @@ -70,4 +77,21 @@ XTtcPs_Config *XTtcPs_LookupConfig(u16 DeviceId) return (XTtcPs_Config *)CfgPtr; } +#else +XTtcPs_Config *XTtcPs_LookupConfig(u32 BaseAddress) +{ + XTtcPs_Config *CfgPtr = NULL; + u32 Index; + + for (Index = 0U; XTtcPs_ConfigTable[Index].Name != NULL; Index++) { + if ((XTtcPs_ConfigTable[Index].BaseAddress == BaseAddress) || + !BaseAddress) { + CfgPtr = &XTtcPs_ConfigTable[Index]; + break; + } + } + + return (XTtcPs_Config *)CfgPtr; +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps.c b/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps.c index 86af54d..a5ec877 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (C) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -124,6 +124,11 @@ s32 XUartPs_CfgInitialize(XUartPs *InstancePtr, #endif InstancePtr->Config.ModemPinsConnected = Config->ModemPinsConnected; +#if defined(SDT) + InstancePtr->Config.IntrId = Config->IntrId; + InstancePtr->Config.IntrParent = Config->IntrParent; +#endif + /* Initialize other instance data to default values */ InstancePtr->Handler = (XUartPs_Handler)XUartPs_StubHandler; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps.h b/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps.h index 20dd99f..89ed5fd 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (C) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -149,6 +149,7 @@ * 3.9 rna 12/03/19 Modified the XUARTPS_MAX_RATE macro. * 3.9 sd 02/06/20 Added clock support * 3.12 gm 11/04/22 Added timeout support using Xil_WaitForEvent +* 3.13 adk 14/04/23 Added support for system device-tree flow. * * * @@ -272,13 +273,23 @@ extern "C" { * This typedef contains configuration information for the device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddress; /**< Base address of device (IPIF) */ u32 InputClockHz;/**< Input clock frequency */ s32 ModemPinsConnected; /** Specifies whether modem pins are connected * to MIO or FMIO */ -#if defined (XCLOCKING) - u32 RefClk; /**< Input clock frequency */ +#if defined (XCLOCKING) || defined(SDT) + u32 RefClk; /**< Input clock frequency */ +#endif +#if defined(SDT) + u32 IntrId; /** Bits[11:0] Interrupt-id Bits[15:12] + * trigger type and level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] + * Parent base address */ #endif } XUartPs_Config; @@ -444,7 +455,11 @@ typedef struct { /************************** Function Prototypes *****************************/ /* Static lookup function implemented in xuartps_sinit.c */ +#ifndef SDT XUartPs_Config *XUartPs_LookupConfig(u16 DeviceId); +#else +XUartPs_Config *XUartPs_LookupConfig(u32 BaseAddress); +#endif /* Interface functions implemented in xuartps.c */ s32 XUartPs_CfgInitialize(XUartPs *InstancePtr, diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_hw.c b/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_hw.c index ec5c088..6fde0e6 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_hw.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_hw.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (C) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -20,6 +20,7 @@ * 1.00 drg/jz 01/12/10 First Release * 1.05a hk 08/22/13 Added reset function * 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance. +* 4.00 sd 02/02/24 Added wait for transmission done function * * *****************************************************************************/ @@ -152,4 +153,39 @@ void XUartPs_ResetHw(u32 BaseAddress) (u32)XUARTPS_CR_STOPBRK)); } + +/****************************************************************************/ +/** +* +* This function waits for transmission to complete +* +* @return None +* +* @note None. +* +*****************************************************************************/ +void XUartPs_WaitTransmitDone(u32 BaseAddress) +{ + /* Wait until Transmitter FIFO is empty */ + while (!XUartPs_IsTransmitEmpty(BaseAddress)) { + ; + } + /* Wait until Transmitter state machine is In-Active */ + while (XUartPs_IsTransmitActive(BaseAddress)) { + ; + } +} + + +#ifdef SDT +#ifdef XPAR_STDIN_IS_UARTPS +void outbyte(char c) { + XUartPs_SendByte(STDOUT_BASEADDRESS, c); +} + +char inbyte(void) { + return XUartPs_RecvByte(STDIN_BASEADDRESS); +} +#endif +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_hw.h index 59d4ccf..f45d5c8 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (C) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -32,6 +32,8 @@ * 3.1 kvn 04/10/15 Modified code for latest RTL changes. * 3.6 ms 02/16/18 Updates flow control mode offset value in * modem control register. +* 4.0 sd 02/02/24 Added macros for transmission FIFO empty check +* and transmission active state check * * * @@ -48,6 +50,7 @@ extern "C" { #include "xil_types.h" #include "xil_assert.h" #include "xil_io.h" +#include "xstatus.h" /************************** Constant Definitions *****************************/ @@ -408,6 +411,36 @@ extern "C" { ((Xil_In32((BaseAddress) + XUARTPS_SR_OFFSET) & \ (u32)XUARTPS_SR_TXFULL) == (u32)XUARTPS_SR_TXFULL) +/****************************************************************************/ +/** +* Check if transmission FIFO is empty +* +* @return TRUE if the TX FIFO is empty, FALSE if Tx FIFO is not empty +* +* @note C-Style signature: +* u32 XUartPs_IsTransmitEmpty(u32 BaseAddress) +* +******************************************************************************/ +#define XUartPs_IsTransmitEmpty(BaseAddress) \ + ((Xil_In32((BaseAddress) + XUARTPS_SR_OFFSET) & \ + (u32)XUARTPS_SR_TXEMPTY) == (u32)XUARTPS_SR_TXEMPTY) + +/****************************************************************************/ +/** +* Check if transmission state machine is active +* +* @return TRUE if the TX state machine is active, FALSE if Tx state machine +* is In-active +* +* @note C-Style signature: +* u32 XUartPs_IsTransmitActive(u32 BaseAddress) +* +******************************************************************************/ +#define XUartPs_IsTransmitActive(BaseAddress) \ + ((Xil_In32((BaseAddress) + XUARTPS_SR_OFFSET) & \ + (u32)XUARTPS_SR_TACTIVE) == (u32)XUARTPS_SR_TACTIVE) + + /************************** Function Prototypes ******************************/ void XUartPs_SendByte(u32 BaseAddress, u8 Data); @@ -416,6 +449,8 @@ u8 XUartPs_RecvByte(u32 BaseAddress); void XUartPs_ResetHw(u32 BaseAddress); +void XUartPs_WaitTransmitDone(u32 BaseAddress); + /************************** Variable Definitions *****************************/ #ifdef __cplusplus diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_sinit.c index de64a8c..50d95bc 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/uartps/src/xuartps_sinit.c @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. -* Copyright (C) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +* Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -28,7 +28,9 @@ /***************************** Include Files ********************************/ #include "xstatus.h" +#ifndef SDT #include "xparameters.h" +#endif #include "xuartps.h" /************************** Constant Definitions ****************************/ @@ -38,7 +40,12 @@ /***************** Macros (Inline Functions) Definitions ********************/ /************************** Variable Definitions ****************************/ +#ifndef SDT extern XUartPs_Config XUartPs_ConfigTable[XPAR_XUARTPS_NUM_INSTANCES]; +#else +extern XUartPs_Config XUartPs_ConfigTable[]; +#endif + /************************** Function Prototypes *****************************/ @@ -56,6 +63,7 @@ extern XUartPs_Config XUartPs_ConfigTable[XPAR_XUARTPS_NUM_INSTANCES]; * @note None. * ******************************************************************************/ +#ifndef SDT XUartPs_Config *XUartPs_LookupConfig(u16 DeviceId) { XUartPs_Config *CfgPtr = NULL; @@ -71,4 +79,21 @@ XUartPs_Config *XUartPs_LookupConfig(u16 DeviceId) return (XUartPs_Config *)CfgPtr; } +#else +XUartPs_Config *XUartPs_LookupConfig(u32 BaseAddress) +{ + XUartPs_Config *CfgPtr = NULL; + u32 Index; + + for (Index = 0U; XUartPs_ConfigTable[Index].Name != NULL; Index++) { + if ((XUartPs_ConfigTable[Index].BaseAddress == BaseAddress) || + !BaseAddress) { + CfgPtr = &XUartPs_ConfigTable[Index]; + break; + } + } + + return (XUartPs_Config *)CfgPtr; +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps.c b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps.c index c3dabfc..a5c5b21 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps.c @@ -1,12 +1,13 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ /******************************************************************************/ /** * @file xusbps.c -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * * The XUsbPs driver. Functions in this file are the minimum required @@ -74,7 +75,7 @@ * ******************************************************************************/ int XUsbPs_CfgInitialize(XUsbPs *InstancePtr, - const XUsbPs_Config *ConfigPtr, u32 VirtBaseAddress) + const XUsbPs_Config *ConfigPtr, u32 VirtBaseAddress) { Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(ConfigPtr != NULL); @@ -118,16 +119,16 @@ void XUsbPs_DeviceReset(XUsbPs *InstancePtr) * itself. */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, XUSBPS_EPSTAT_OFFSET, - XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPSTAT_OFFSET)); + XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, + XUSBPS_EPSTAT_OFFSET)); /* Clear all the endpoint complete status bits by reading the * XUSBPS_EPCOMPL_OFFSET register and writings its value back * to itself. */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, XUSBPS_EPCOMPL_OFFSET, - XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPCOMPL_OFFSET)); + XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, + XUSBPS_EPCOMPL_OFFSET)); /* Cancel all endpoint prime status by waiting until all bits * in XUSBPS_EPPRIME_OFFSET are 0 and then writing 0xFFFFFFFF @@ -137,25 +138,25 @@ void XUsbPs_DeviceReset(XUsbPs *InstancePtr) */ Timeout = XUSBPS_TIMEOUT_COUNTER; while ((XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPPRIME_OFFSET) & - XUSBPS_EP_ALL_MASK) && --Timeout) { + XUSBPS_EPPRIME_OFFSET) & + XUSBPS_EP_ALL_MASK) && --Timeout) { /* NOP */ } XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPFLUSH_OFFSET, 0xFFFFFFFF); + XUSBPS_EPFLUSH_OFFSET, 0xFFFFFFFF); XUsbPs_Stop(InstancePtr); /* Write to CR register for controller reset */ - XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, XUSBPS_CMD_OFFSET, - XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_CMD_OFFSET) | XUSBPS_CMD_RST_MASK); + XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, XUSBPS_CMD_OFFSET, + XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, + XUSBPS_CMD_OFFSET) | XUSBPS_CMD_RST_MASK); /* Wait for reset to finish, hardware clears the reset bit once done */ Timeout = 1000000; - while((XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_CMD_OFFSET) & - XUSBPS_CMD_RST_MASK) && --Timeout) { + while ((XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, + XUSBPS_CMD_OFFSET) & + XUSBPS_CMD_RST_MASK) && --Timeout) { /* NOP */ } } @@ -196,14 +197,14 @@ int XUsbPs_Reset(XUsbPs *InstancePtr) * system) this can lead to _very_ long Timeout periods. */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_CMD_OFFSET, XUSBPS_CMD_RST_MASK); + XUSBPS_CMD_OFFSET, XUSBPS_CMD_RST_MASK); /* Wait for the RESET bit to be cleared by HW. */ Timeout = XUSBPS_TIMEOUT_COUNTER; while ((XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_CMD_OFFSET) & - XUSBPS_CMD_RST_MASK) && --Timeout) { + XUSBPS_CMD_OFFSET) & + XUSBPS_CMD_RST_MASK) && --Timeout) { /* NOP */ } @@ -320,8 +321,8 @@ int XUsbPs_SetDeviceAddress(XUsbPs *InstancePtr, u8 Address) Xil_AssertNonvoid(InstancePtr != NULL); if ((InstancePtr->AppData != NULL) && - (InstancePtr->AppData->State == - XUSBPS_STATE_CONFIGURED)) { + (InstancePtr->AppData->State == + XUSBPS_STATE_CONFIGURED)) { return XST_FAILURE; } @@ -335,15 +336,16 @@ int XUsbPs_SetDeviceAddress(XUsbPs *InstancePtr, u8 Address) * after an IN occurred and has been ACKed on the endpoint. */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_DEVICEADDR_OFFSET, - (Address << XUSBPS_DEVICEADDR_ADDR_SHIFT) | - XUSBPS_DEVICEADDR_DEVICEAADV_MASK); + XUSBPS_DEVICEADDR_OFFSET, + (Address << XUSBPS_DEVICEADDR_ADDR_SHIFT) | + XUSBPS_DEVICEADDR_DEVICEAADV_MASK); if (InstancePtr->AppData != NULL) { - if (Address) + if (Address) { InstancePtr->AppData->State = XUSBPS_STATE_ADDRESS; - else + } else { InstancePtr->AppData->State = XUSBPS_STATE_DEFAULT; + } } return XST_SUCCESS; } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps.h b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps.h index 5c01051..d215b77 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xusbps.h -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * @details * @@ -163,6 +164,7 @@ * examples. * 2.5 pm 02/20/20 Added ISO support for usb 2.0 and ch9 common framework * calls. + * 2.8 pm 07/07/23 Added support for system device-tree flow. * * ******************************************************************************/ @@ -256,13 +258,13 @@ extern "C" { #define XUSBPS_EP_STS_CONTROLLER_STATE 2 /**< Current controller state. */ /* @} */ - /* - * Device Speeds - */ - #define XUSBPS_SPEED_UNKNOWN 0U - #define XUSBPS_SPEED_LOW 1U - #define XUSBPS_SPEED_FULL 2U - #define XUSBPS_SPEED_HIGH 3U +/* + * Device Speeds + */ +#define XUSBPS_SPEED_UNKNOWN 0U +#define XUSBPS_SPEED_LOW 1U +#define XUSBPS_SPEED_FULL 2U +#define XUSBPS_SPEED_HIGH 3U /** * @name USB Default alternate setting @@ -272,15 +274,15 @@ extern "C" { #define XUSBPS_DEFAULT_ALT_SETTING 0 /**< The default alternate setting is 0 */ /* @} */ - /* - * Device States - */ - #define XUSBPS_STATE_ATTACHED 0U - #define XUSBPS_STATE_POWERED 1U - #define XUSBPS_STATE_DEFAULT 2U - #define XUSBPS_STATE_ADDRESS 3U - #define XUSBPS_STATE_CONFIGURED 4U - #define XUSBPS_STATE_SUSPENDED 5U +/* + * Device States + */ +#define XUSBPS_STATE_ATTACHED 0U +#define XUSBPS_STATE_POWERED 1U +#define XUSBPS_STATE_DEFAULT 2U +#define XUSBPS_STATE_ADDRESS 3U +#define XUSBPS_STATE_CONFIGURED 4U +#define XUSBPS_STATE_SUSPENDED 5U /** * @name Endpoint event types @@ -290,11 +292,11 @@ extern "C" { * @{ */ #define XUSBPS_EP_EVENT_SETUP_DATA_RECEIVED 0x01 - /**< Setup data has been received on the endpoint. */ +/**< Setup data has been received on the endpoint. */ #define XUSBPS_EP_EVENT_DATA_RX 0x02 - /**< Data frame has been received on the endpoint. */ +/**< Data frame has been received on the endpoint. */ #define XUSBPS_EP_EVENT_DATA_TX 0x03 - /**< Data frame has been sent on the endpoint. */ +/**< Data frame has been sent on the endpoint. */ /* @} */ @@ -303,7 +305,7 @@ extern "C" { * @{ */ #define XUSBPS_MAX_PACKET_SIZE 1024 - /**< Maximum value can be put into the queue head */ +/**< Maximum value can be put into the queue head */ /* @} */ /**************************** Type Definitions *******************************/ @@ -320,7 +322,7 @@ extern "C" { * was registered. */ typedef void (*XUsbPs_EpHandlerFunc)(void *CallBackRef, - u8 EpNum, u8 EventType, void *Data); + u8 EpNum, u8 EventType, void *Data); /****************************************************************************** * This data type defines the callback function to be used for Endpoint @@ -369,24 +371,24 @@ typedef u8 XUsbPs_dTD[XUSBPS_dTD_ALIGN]; */ typedef struct { XUsbPs_dQH *dQH; - /**< Pointer to the Queue Head structure of the endpoint. */ + /**< Pointer to the Queue Head structure of the endpoint. */ XUsbPs_dTD *dTDs; - /**< Pointer to the first dTD of the dTD list for this - * endpoint. */ + /**< Pointer to the first dTD of the dTD list for this + * endpoint. */ XUsbPs_dTD *dTDCurr; - /**< Buffer to the currently processed descriptor. */ + /**< Buffer to the currently processed descriptor. */ u8 *dTDBufs; - /**< Pointer to the first buffer of the buffer list for this - * endpoint. */ + /**< Pointer to the first buffer of the buffer list for this + * endpoint. */ XUsbPs_EpHandlerFunc HandlerFunc; XUsbPs_EpIsoHandlerFunc HandlerIsoFunc; - /**< Handler function for this endpoint. */ + /**< Handler function for this endpoint. */ void *HandlerRef; - /**< User data reference for the handler. */ + /**< User data reference for the handler. */ u32 RequestedBytes; /**< RequestedBytes for transfer */ u32 BytesTxed; /**< Actual Bytes transferred */ u8 *BufferPtr; /**< Buffer location */ @@ -400,23 +402,23 @@ typedef struct { */ typedef struct { XUsbPs_dQH *dQH; - /**< Pointer to the Queue Head structure of the endpoint. */ + /**< Pointer to the Queue Head structure of the endpoint. */ XUsbPs_dTD *dTDs; - /**< List of pointers to the Transfer Descriptors of the - * endpoint. */ + /**< List of pointers to the Transfer Descriptors of the + * endpoint. */ XUsbPs_dTD *dTDHead; - /**< Buffer to the next available descriptor in the list. */ + /**< Buffer to the next available descriptor in the list. */ XUsbPs_dTD *dTDTail; - /**< Buffer to the last unsent descriptor in the list*/ + /**< Buffer to the last unsent descriptor in the list*/ XUsbPs_EpHandlerFunc HandlerFunc; XUsbPs_EpIsoHandlerFunc HandlerIsoFunc; - /**< Handler function for this endpoint. */ + /**< Handler function for this endpoint. */ void *HandlerRef; - /**< User data reference for the handler. */ + /**< User data reference for the handler. */ u32 RequestedBytes; /**< RequestedBytes for transfer */ u32 BytesTxed; /**< Actual Bytes transferred */ u8 *BufferPtr; /**< Buffer location */ @@ -462,21 +464,21 @@ XUsbPs_SetupData; */ typedef struct { u32 Type; - /**< Endpoint type: - - XUSBPS_EP_TYPE_CONTROL - - XUSBPS_EP_TYPE_ISOCHRONOUS - - XUSBPS_EP_TYPE_BULK - - XUSBPS_EP_TYPE_INTERRUPT */ + /**< Endpoint type: + - XUSBPS_EP_TYPE_CONTROL + - XUSBPS_EP_TYPE_ISOCHRONOUS + - XUSBPS_EP_TYPE_BULK + - XUSBPS_EP_TYPE_INTERRUPT */ u32 NumBufs; - /**< Number of buffers to be handled by this endpoint. */ + /**< Number of buffers to be handled by this endpoint. */ u32 BufSize; - /**< Buffer size. Only relevant for OUT (receive) Endpoints. */ + /**< Buffer size. Only relevant for OUT (receive) Endpoints. */ u16 MaxPacketSize; - /**< Maximum packet size for this endpoint. This number will - * define the maximum number of bytes sent on the wire per - * transaction. Range: 0..1024 */ + /**< Maximum packet size for this endpoint. This number will + * define the maximum number of bytes sent on the wire per + * transaction. Range: 0..1024 */ } XUsbPs_EpSetup; @@ -502,7 +504,7 @@ typedef struct { in the core. */ XUsbPs_EpConfig EpCfg[XUSBPS_MAX_ENDPOINTS]; - /**< List of endpoint configurations. */ + /**< List of endpoint configurations. */ u32 DMAMemPhys; /**< Physical base address of DMAable memory @@ -518,7 +520,7 @@ typedef struct { * structure which is allocated by the caller. */ XUsbPs_Endpoint Ep[XUSBPS_MAX_ENDPOINTS]; - /**< List of endpoint metadata structures. */ + /**< List of endpoint metadata structures. */ u32 PhysAligned; /**< 64 byte aligned base address of the DMA memory block. Will be computed and set by @@ -536,8 +538,17 @@ typedef struct { * XUsbPs_ConfigureDevice() function call */ typedef struct { +#ifndef SDT u16 DeviceID; /**< Unique ID of controller. */ +#else + char *Name; /**< Unique Name of controller */ +#endif u32 BaseAddress; /**< Core register base address. */ +#ifdef SDT + u16 IntrId; /** Bits[11:0] Interrupt-id Bits[15:12] trigger type */ + /** level flags */ + UINTPTR IntrParent; /** Bit[0] Interrupt parent type Bit[64/32:1] */ +#endif } XUsbPs_Config; typedef XUsbPs_Config Usb_Config; @@ -556,7 +567,7 @@ struct Usb_DevData { */ typedef struct { XUsbPs_SetupData SetupData; - /**< Setup Packet buffer */ + /**< Setup Packet buffer */ XUsbPs_Config Config; /**< Configuration structure */ int CurrentAltSetting; /**< Current alternative setting of interface */ @@ -573,15 +584,15 @@ typedef struct { * XUsbPs_ConfigureDevice() function call. */ XUsbPs_DeviceConfig DeviceConfig; - /**< Configuration for the DEVICE mode. */ + /**< Configuration for the DEVICE mode. */ XUsbPs_IntrHandlerFunc HandlerFunc; - /**< Handler function for the controller. */ + /**< Handler function for the controller. */ void *HandlerRef; - /**< User data reference for the handler. */ + /**< User data reference for the handler. */ u32 HandlerMask; - /**< User interrupt mask. Defines which interrupts will cause - * the callback to be called. */ + /**< User interrupt mask. Defines which interrupts will cause + * the callback to be called. */ struct Usb_DevData *AppData; u8 IsConfigDone; void *data_ptr; /* pointer for storing applications data */ @@ -655,7 +666,7 @@ typedef struct { ******************************************************************************/ #define XUsbPs_ForceFS(InstancePtr) \ XUsbPs_SetBits(InstancePtr, XUSBPS_PORTSCR1_OFFSET, \ - XUSBPS_PORTSCR_PFSC_MASK) + XUSBPS_PORTSCR_PFSC_MASK) /*****************************************************************************/ @@ -671,14 +682,14 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_StartTimer0(InstancePtr, Interval) \ -{ \ - XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XUSBPS_TIMER0_LD_OFFSET, (Interval)); \ - XUsbPs_SetBits(InstancePtr, XUSBPS_TIMER0_CTL_OFFSET, \ - XUSBPS_TIMER_RUN_MASK | \ - XUSBPS_TIMER_RESET_MASK | \ - XUSBPS_TIMER_REPEAT_MASK); \ -} \ + { \ + XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ + XUSBPS_TIMER0_LD_OFFSET, (Interval)); \ + XUsbPs_SetBits(InstancePtr, XUSBPS_TIMER0_CTL_OFFSET, \ + XUSBPS_TIMER_RUN_MASK | \ + XUSBPS_TIMER_RESET_MASK | \ + XUSBPS_TIMER_REPEAT_MASK); \ + } \ /*****************************************************************************/ @@ -693,7 +704,7 @@ typedef struct { ******************************************************************************/ #define XUsbPs_StopTimer0(InstancePtr) \ XUsbPs_ClrBits(InstancePtr, XUSBPS_TIMER0_CTL_OFFSET, \ - XUSBPS_TIMER_RUN_MASK) + XUSBPS_TIMER_RUN_MASK) /*****************************************************************************/ @@ -708,8 +719,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_ReadTimer0(InstancePtr) \ XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XUSBPS_TIMER0_CTL_OFFSET) & \ - XUSBPS_TIMER_COUNTER_MASK + XUSBPS_TIMER0_CTL_OFFSET) & \ + XUSBPS_TIMER_COUNTER_MASK /*****************************************************************************/ @@ -724,7 +735,7 @@ typedef struct { ******************************************************************************/ #define XUsbPs_RemoteWakeup(InstancePtr) \ XUsbPs_SetBits(InstancePtr, XUSBPS_PORTSCR1_OFFSET, \ - XUSBPS_PORTSCR_FPR_MASK) + XUSBPS_PORTSCR_FPR_MASK) /****************************************************************************** @@ -749,8 +760,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_EpEnable(InstancePtr, EpNum, Dir) \ XUsbPs_SetBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum), \ - ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXE_MASK : 0) | \ - ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXE_MASK : 0)) + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXE_MASK : 0) | \ + ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXE_MASK : 0)) /*****************************************************************************/ @@ -770,8 +781,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_EpDisable(InstancePtr, EpNum, Dir) \ XUsbPs_ClrBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum), \ - ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXE_MASK : 0) | \ - ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXE_MASK : 0)) + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXE_MASK : 0) | \ + ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXE_MASK : 0)) /*****************************************************************************/ @@ -792,8 +803,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_EpStall(InstancePtr, EpNum, Dir) \ XUsbPs_SetBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum), \ - ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXS_MASK : 0) | \ - ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXS_MASK : 0)) + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXS_MASK : 0) | \ + ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXS_MASK : 0)) /*****************************************************************************/ @@ -813,8 +824,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_EpUnStall(InstancePtr, EpNum, Dir) \ XUsbPs_ClrBits(InstancePtr, XUSBPS_EPCRn_OFFSET(EpNum), \ - ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXS_MASK : 0) | \ - ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXS_MASK : 0)) + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? XUSBPS_EPCR_RXS_MASK : 0) | \ + ((Dir) & XUSBPS_EP_DIRECTION_IN ? XUSBPS_EPCR_TXS_MASK : 0)) /*****************************************************************************/ @@ -834,8 +845,8 @@ typedef struct { ******************************************************************************/ #define XUsbPs_EpFlush(InstancePtr, EpNum, Dir) \ XUsbPs_SetBits(InstancePtr, XUSBPS_EPFLUSH_OFFSET, \ - 1 << (EpNum + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? \ - XUSBPS_EPFLUSH_RX_SHIFT:XUSBPS_EPFLUSH_TX_SHIFT))) \ + 1 << (EpNum + ((Dir) & XUSBPS_EP_DIRECTION_OUT ? \ + XUSBPS_EPFLUSH_RX_SHIFT:XUSBPS_EPFLUSH_TX_SHIFT))) \ /*****************************************************************************/ /** @@ -849,7 +860,7 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_IntrEnable(InstancePtr, IntrMask) \ - XUsbPs_SetBits(InstancePtr, XUSBPS_IER_OFFSET, IntrMask) + XUsbPs_SetBits(InstancePtr, XUSBPS_IER_OFFSET, IntrMask) /*****************************************************************************/ @@ -865,7 +876,7 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_IntrDisable(InstancePtr, IntrMask) \ - XUsbPs_ClrBits(InstancePtr, XUSBPS_IER_OFFSET, IntrMask) + XUsbPs_ClrBits(InstancePtr, XUSBPS_IER_OFFSET, IntrMask) /*****************************************************************************/ @@ -914,7 +925,7 @@ typedef struct { ******************************************************************************/ #define XUsbPs_NakIntrClear(InstancePtr, NakIntrMask) \ XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XUSBPS_EPNAKISR_OFFSET, NakIntrMask) + XUSBPS_EPNAKISR_OFFSET, NakIntrMask) @@ -940,8 +951,8 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_SetIntrThreshold(InstancePtr, Threshold) \ - XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ - XUSBPS_CMD_OFFSET, (Threshold))\ + XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, \ + XUSBPS_CMD_OFFSET, (Threshold))\ /*****************************************************************************/ @@ -955,8 +966,8 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_SetSetupTripwire(InstancePtr) \ - XUsbPs_SetBits(InstancePtr, XUSBPS_CMD_OFFSET, \ - XUSBPS_CMD_SUTW_MASK) + XUsbPs_SetBits(InstancePtr, XUSBPS_CMD_OFFSET, \ + XUSBPS_CMD_SUTW_MASK) /*****************************************************************************/ @@ -970,8 +981,8 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_ClrSetupTripwire(InstancePtr) \ - XUsbPs_ClrBits(InstancePtr, XUSBPS_CMD_OFFSET, \ - XUSBPS_CMD_SUTW_MASK) + XUsbPs_ClrBits(InstancePtr, XUSBPS_CMD_OFFSET, \ + XUSBPS_CMD_SUTW_MASK) /*****************************************************************************/ @@ -989,9 +1000,9 @@ typedef struct { * ******************************************************************************/ #define XUsbPs_SetupTripwireIsSet(InstancePtr) \ - (XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - XUSBPS_CMD_OFFSET) & \ - XUSBPS_CMD_SUTW_MASK ? TRUE : FALSE) + (XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + XUSBPS_CMD_OFFSET) & \ + XUSBPS_CMD_SUTW_MASK ? TRUE : FALSE) /****************************************************************************** @@ -1015,8 +1026,8 @@ typedef struct { *****************************************************************************/ #define XUsbPs_SetBits(InstancePtr, RegOffset, Bits) \ XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, RegOffset, \ - XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - RegOffset) | (Bits)); + XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + RegOffset) | (Bits)); /****************************************************************************/ @@ -1037,8 +1048,8 @@ typedef struct { *****************************************************************************/ #define XUsbPs_ClrBits(InstancePtr, RegOffset, Bits) \ XUsbPs_WriteReg((InstancePtr)->Config.BaseAddress, RegOffset, \ - XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ - RegOffset) & ~(Bits)); + XUsbPs_ReadReg((InstancePtr)->Config.BaseAddress, \ + RegOffset) & ~(Bits)); /************************** Function Prototypes ******************************/ @@ -1049,10 +1060,10 @@ typedef struct { * Implemented in file xusbps.c */ int XUsbPs_CfgInitialize(XUsbPs *InstancePtr, - const XUsbPs_Config *ConfigPtr, u32 BaseAddress); + const XUsbPs_Config *ConfigPtr, u32 BaseAddress); int XUsbPs_ConfigureDevice(XUsbPs *InstancePtr, - const XUsbPs_DeviceConfig *CfgPtr); + const XUsbPs_DeviceConfig *CfgPtr); /** * Common functions used for DEVICE/HOST mode. @@ -1086,23 +1097,23 @@ int XUsbPs_RequestHostResume(const XUsbPs *InstancePtr); int XUsbPs_EpBufferSend(XUsbPs *InstancePtr, u8 EpNum, const u8 *BufferPtr, u32 BufferLen); int XUsbPs_EpBufferSendWithZLT(XUsbPs *InstancePtr, u8 EpNum, - const u8 *BufferPtr, u32 BufferLen); + const u8 *BufferPtr, u32 BufferLen); int XUsbPs_EpBufferReceive(XUsbPs *InstancePtr, u8 EpNum, - u8 **BufferPtr, u32 *BufferLenPtr, u32 *Handle); + u8 **BufferPtr, u32 *BufferLenPtr, u32 *Handle); void XUsbPs_EpBufferRelease(u32 Handle); int XUsbPs_EpSetHandler(XUsbPs *InstancePtr, u8 EpNum, u8 Direction, XUsbPs_EpHandlerFunc CallBackFunc, void *CallBackRef); s32 XUsbPs_EpSetIsoHandler(XUsbPs *InstancePtr, u8 EpNum, u8 Direction, - XUsbPs_EpIsoHandlerFunc CallBackFunc); + XUsbPs_EpIsoHandlerFunc CallBackFunc); int XUsbPs_EpGetSetupData(XUsbPs *InstancePtr, int EpNum, - XUsbPs_SetupData *SetupDataPtr); + XUsbPs_SetupData *SetupDataPtr); int XUsbPs_EpPrime(XUsbPs *InstancePtr, u8 EpNum, u8 Direction); int XUsbPs_ReconfigureEp(XUsbPs *InstancePtr, XUsbPs_DeviceConfig *CfgPtr, - int EpNum, unsigned short NewDirection, int DirectionChanged); + int EpNum, unsigned short NewDirection, int DirectionChanged); /* * Interrupt handling functions @@ -1112,17 +1123,21 @@ int XUsbPs_ReconfigureEp(XUsbPs *InstancePtr, XUsbPs_DeviceConfig *CfgPtr, void XUsbPs_IntrHandler(void *InstancePtr); int XUsbPs_IntrSetHandler(XUsbPs *InstancePtr, - XUsbPs_IntrHandlerFunc CallBackFunc, - void *CallBackRef, u32 Mask); + XUsbPs_IntrHandlerFunc CallBackFunc, + void *CallBackRef, u32 Mask); void XUsbPs_EpGetData(XUsbPs *InstancePtr, u8 EpNum, u32 BufferLen); s32 XUsbPs_EpDataBufferReceive(XUsbPs *InstancePtr, u8 EpNum, - u8 *BufferPtr, u32 BufferLen); + u8 *BufferPtr, u32 BufferLen); /* * Helper functions for static configuration. * Implemented in xusbps_sinit.c */ +#ifndef SDT XUsbPs_Config *XUsbPs_LookupConfig(u16 DeviceId); +#else +XUsbPs_Config *XUsbPs_LookupConfig(u32 BaseAddress); +#endif #ifdef __cplusplus } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_endpoint.c b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_endpoint.c index a22510e..de7b77e 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_endpoint.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_endpoint.c @@ -1,12 +1,13 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ /******************************************************************************/ /** * @file xusbps_endpoint.c -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * * Endpoint specific function implementations. @@ -22,7 +23,7 @@ * 1.03a nm 09/21/12 Fixed CR#678977. Added proper sequence for setup packet * handling. * 1.04a nm 11/02/12 Fixed CR#683931. Mult bits are set properly in dQH. - * 2.00a kpc 04/03/14 Fixed CR#777763. Updated the macro names + * 2.00a kpc 04/03/14 Fixed CR#777763. Updated the macro names * 2.1 kpc 04/28/14 Added XUsbPs_EpBufferSendWithZLT api and merged common * code to XUsbPs_EpQueueRequest. * 2.3 bss 01/19/16 Modified XUsbPs_EpQueueRequest function to fix CR#873972 @@ -52,7 +53,7 @@ static void XUsbPs_EpListInit(XUsbPs_DeviceConfig *DevCfgPtr); static void XUsbPs_dQHInit(XUsbPs_DeviceConfig *DevCfgPtr); static int XUsbPs_dTDInit(XUsbPs_DeviceConfig *DevCfgPtr); static int XUsbPs_dTDAttachBuffer(XUsbPs_dTD *dTDPtr, - const u8 *BufferPtr, u32 BufferLen); + const u8 *BufferPtr, u32 BufferLen); static void XUsbPs_dQHSetMaxPacketLenISO(XUsbPs_dQH *dQHPtr, u32 Len); @@ -60,11 +61,11 @@ static void XUsbPs_dQHSetMaxPacketLenISO(XUsbPs_dQH *dQHPtr, u32 Len); * request. */ static void XUsbPs_dQHReinitEp(XUsbPs_DeviceConfig *DevCfgPtr, - int EpNum, unsigned short NewDirection); + int EpNum, unsigned short NewDirection); static int XUsbPs_dTDReinitEp(XUsbPs_DeviceConfig *DevCfgPtr, - int EpNum, unsigned short NewDirection); + int EpNum, unsigned short NewDirection); static int XUsbPs_EpQueueRequest(XUsbPs *InstancePtr, u8 EpNum, - const u8 *BufferPtr, u32 BufferLen, u8 ReqZero); + const u8 *BufferPtr, u32 BufferLen, u8 ReqZero); /******************************* Functions ************************************/ @@ -92,7 +93,7 @@ static int XUsbPs_EpQueueRequest(XUsbPs *InstancePtr, u8 EpNum, * ******************************************************************************/ int XUsbPs_ConfigureDevice(XUsbPs *InstancePtr, - const XUsbPs_DeviceConfig *CfgPtr) + const XUsbPs_DeviceConfig *CfgPtr) { int Status; u32 ModeValue = 0x0; @@ -107,8 +108,8 @@ int XUsbPs_ConfigureDevice(XUsbPs *InstancePtr, /* Align the buffer to a 2048 byte (XUSBPS_dQH_BASE_ALIGN) boundary.*/ InstancePtr->DeviceConfig.PhysAligned = (InstancePtr->DeviceConfig.DMAMemPhys + - XUSBPS_dQH_BASE_ALIGN) & - ~(XUSBPS_dQH_BASE_ALIGN -1); + XUSBPS_dQH_BASE_ALIGN) & + ~(XUSBPS_dQH_BASE_ALIGN - 1); /* Initialize the endpoint pointer list data structure. */ XUsbPs_EpListInit(&InstancePtr->DeviceConfig); @@ -131,8 +132,8 @@ int XUsbPs_ConfigureDevice(XUsbPs *InstancePtr, /* Set the Queue Head List address. */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPLISTADDR_OFFSET, - InstancePtr->DeviceConfig.PhysAligned); + XUSBPS_EPLISTADDR_OFFSET, + InstancePtr->DeviceConfig.PhysAligned); /* Set the USB mode register to configure DEVICE mode. * @@ -144,10 +145,10 @@ int XUsbPs_ConfigureDevice(XUsbPs *InstancePtr, ModeValue = XUSBPS_MODE_CM_DEVICE_MASK | XUSBPS_MODE_SLOM_MASK; XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_MODE_OFFSET, ModeValue); + XUSBPS_MODE_OFFSET, ModeValue); XUsbPs_SetBits(InstancePtr, XUSBPS_OTGCSR_OFFSET, - XUSBPS_OTGSC_OT_MASK); + XUSBPS_OTGSC_OT_MASK); return XST_SUCCESS; } @@ -169,13 +170,13 @@ int XUsbPs_ConfigureDevice(XUsbPs *InstancePtr, * ******************************************************************************/ int XUsbPs_EpBufferSend(XUsbPs *InstancePtr, u8 EpNum, - const u8 *BufferPtr, u32 BufferLen) + const u8 *BufferPtr, u32 BufferLen) { Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(EpNum < InstancePtr->DeviceConfig.NumEndpoints); return XUsbPs_EpQueueRequest(InstancePtr, EpNum, BufferPtr, - BufferLen, FALSE); + BufferLen, FALSE); } /*****************************************************************************/ @@ -196,7 +197,7 @@ int XUsbPs_EpBufferSend(XUsbPs *InstancePtr, u8 EpNum, * ******************************************************************************/ int XUsbPs_EpBufferSendWithZLT(XUsbPs *InstancePtr, u8 EpNum, - const u8 *BufferPtr, u32 BufferLen) + const u8 *BufferPtr, u32 BufferLen) { u8 ReqZero = FALSE; XUsbPs_EpSetup *Ep; @@ -207,12 +208,12 @@ int XUsbPs_EpBufferSendWithZLT(XUsbPs *InstancePtr, u8 EpNum, Ep = &InstancePtr->DeviceConfig.EpCfg[EpNum].In; if ((BufferLen >= Ep->MaxPacketSize) && - (BufferLen % Ep->MaxPacketSize == 0)) { + (BufferLen % Ep->MaxPacketSize == 0)) { ReqZero = TRUE; } return XUsbPs_EpQueueRequest(InstancePtr, EpNum, BufferPtr, - BufferLen, ReqZero); + BufferLen, ReqZero); } /*****************************************************************************/ @@ -234,7 +235,7 @@ int XUsbPs_EpBufferSendWithZLT(XUsbPs *InstancePtr, u8 EpNum, * ******************************************************************************/ static int XUsbPs_EpQueueRequest(XUsbPs *InstancePtr, u8 EpNum, - const u8 *BufferPtr, u32 BufferLen, u8 ReqZero) + const u8 *BufferPtr, u32 BufferLen, u8 ReqZero) { int Status; u32 Token; @@ -259,7 +260,7 @@ static int XUsbPs_EpQueueRequest(XUsbPs *InstancePtr, u8 EpNum, Xil_DCacheFlushRange((unsigned int)BufferPtr, BufferLen); - if(Ep->dTDTail != Ep->dTDHead) { + if (Ep->dTDTail != Ep->dTDHead) { PipeEmpty = 0; } XUsbPs_dTDInvalidateCache(Ep->dTDHead); @@ -298,11 +299,12 @@ static int XUsbPs_EpQueueRequest(XUsbPs *InstancePtr, u8 EpNum, InstancePtr-> DeviceConfig.EpCfg[EpNum].Out.MaxPacketSize; if (BufferLen == 0 || - (BufferLen % - InstancePtr-> - DeviceConfig.EpCfg[EpNum]. - Out.MaxPacketSize)) + (BufferLen % + InstancePtr-> + DeviceConfig.EpCfg[EpNum]. + Out.MaxPacketSize)) { Multo++; + } XUsbPs_dTDSetMultO(Ep->dTDHead, (Multo << 10)); } @@ -324,32 +326,32 @@ static int XUsbPs_EpQueueRequest(XUsbPs *InstancePtr, u8 EpNum, ReqZero = FALSE; } - } while(BufferLen || exit); + } while (BufferLen || exit); XUsbPs_dTDSetTerminate(Ep->dTDHead); XUsbPs_dTDFlushCache(Ep->dTDHead); - if(!PipeEmpty) { + if (!PipeEmpty) { /* Read the endpoint prime register. */ RegValue = XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, XUSBPS_EPPRIME_OFFSET); - if(RegValue & BitMask) { + if (RegValue & BitMask) { return XST_SUCCESS; } do { RegValue = XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, XUSBPS_CMD_OFFSET); XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, XUSBPS_CMD_OFFSET, - RegValue | XUSBPS_CMD_ATDTW_MASK); + RegValue | XUSBPS_CMD_ATDTW_MASK); Temp = XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, XUSBPS_EPRDY_OFFSET) - & BitMask; - } while(!(XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, XUSBPS_CMD_OFFSET) & - XUSBPS_CMD_ATDTW_MASK)); + & BitMask; + } while (!(XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, XUSBPS_CMD_OFFSET) & + XUSBPS_CMD_ATDTW_MASK)); RegValue = XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, XUSBPS_CMD_OFFSET); XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, XUSBPS_CMD_OFFSET, - RegValue & ~XUSBPS_CMD_ATDTW_MASK); + RegValue & ~XUSBPS_CMD_ATDTW_MASK); - if(Temp) { + if (Temp) { return XST_SUCCESS; } } @@ -412,10 +414,10 @@ void XUsbPs_EpGetData(XUsbPs *InstancePtr, u8 EpNum, u32 BufferLen) XUsbPs_dTDInvalidateCache(Ep->dTDCurr); DataBuff = (u8 *) XUsbPs_ReaddTD(Ep->dTDCurr, - XUSBPS_dTDUSERDATA); + XUSBPS_dTDUSERDATA); length = EpSetup->BufSize - - XUsbPs_dTDGetTransferLen(Ep->dTDCurr); + XUsbPs_dTDGetTransferLen(Ep->dTDCurr); if (length > 0) { BufferLen = length; @@ -426,11 +428,11 @@ void XUsbPs_EpGetData(XUsbPs *InstancePtr, u8 EpNum, u32 BufferLen) /* Invalidate the Buffer Pointer */ InavalidateLen = BufferLen; if (BufferLen % 32) { - InavalidateLen = (BufferLen/32) * 32 + 32; + InavalidateLen = (BufferLen / 32) * 32 + 32; } Xil_DCacheInvalidateRange((unsigned int)DataBuff, - InavalidateLen); + InavalidateLen); memcpy(Ep->BufferPtr, DataBuff, BufferLen); @@ -460,12 +462,12 @@ void XUsbPs_EpGetData(XUsbPs *InstancePtr, u8 EpNum, u32 BufferLen) * or lesser data. */ if ((Ep->RequestedBytes <= Ep->BytesTxed) || - (Ep->BytesTxed % EpSetup->MaxPacketSize)) { + (Ep->BytesTxed % EpSetup->MaxPacketSize)) { Ep->MemAlloted = 0; if (Ep->HandlerIsoFunc) { Ep->HandlerIsoFunc(Ep->HandlerRef, - Ep->RequestedBytes, - Ep->BytesTxed); + Ep->RequestedBytes, + Ep->BytesTxed); } break; @@ -501,7 +503,7 @@ void XUsbPs_EpGetData(XUsbPs *InstancePtr, u8 EpNum, u32 BufferLen) * ******************************************************************************/ int XUsbPs_EpBufferReceive(XUsbPs *InstancePtr, u8 EpNum, - u8 **BufferPtr, u32 *BufferLenPtr, u32 *Handle) + u8 **BufferPtr, u32 *BufferLenPtr, u32 *Handle) { XUsbPs_EpOut *Ep; XUsbPs_EpSetup *EpSetup; @@ -534,14 +536,14 @@ int XUsbPs_EpBufferReceive(XUsbPs *InstancePtr, u8 EpNum, * Transfer Descriptor. */ *BufferPtr = (u8 *) XUsbPs_ReaddTD(Ep->dTDCurr, - XUSBPS_dTDUSERDATA); + XUSBPS_dTDUSERDATA); length = EpSetup->BufSize - - XUsbPs_dTDGetTransferLen(Ep->dTDCurr); + XUsbPs_dTDGetTransferLen(Ep->dTDCurr); - if(length > 0) { + if (length > 0) { *BufferLenPtr = length; - }else { + } else { *BufferLenPtr = 0; } @@ -616,7 +618,7 @@ void XUsbPs_EpBufferRelease(u32 Handle) * ******************************************************************************/ s32 XUsbPs_EpDataBufferReceive(XUsbPs *InstancePtr, u8 EpNum, - u8 *BufferPtr, u32 BufferLen) + u8 *BufferPtr, u32 BufferLen) { XUsbPs_EpOut *Ep; @@ -670,8 +672,8 @@ s32 XUsbPs_EpDataBufferReceive(XUsbPs *InstancePtr, u8 EpNum, * ******************************************************************************/ int XUsbPs_EpSetHandler(XUsbPs *InstancePtr, u8 EpNum, u8 Direction, - XUsbPs_EpHandlerFunc CallBackFunc, - void *CallBackRef) + XUsbPs_EpHandlerFunc CallBackFunc, + void *CallBackRef) { XUsbPs_Endpoint *Ep; @@ -681,12 +683,12 @@ int XUsbPs_EpSetHandler(XUsbPs *InstancePtr, u8 EpNum, u8 Direction, Ep = &InstancePtr->DeviceConfig.Ep[EpNum]; - if(Direction & XUSBPS_EP_DIRECTION_OUT) { + if (Direction & XUSBPS_EP_DIRECTION_OUT) { Ep->Out.HandlerFunc = CallBackFunc; Ep->Out.HandlerRef = CallBackRef; } - if(Direction & XUSBPS_EP_DIRECTION_IN) { + if (Direction & XUSBPS_EP_DIRECTION_IN) { Ep->In.HandlerFunc = CallBackFunc; Ep->In.HandlerRef = CallBackRef; } @@ -718,7 +720,7 @@ int XUsbPs_EpSetHandler(XUsbPs *InstancePtr, u8 EpNum, u8 Direction, * ******************************************************************************/ s32 XUsbPs_EpSetIsoHandler(XUsbPs *InstancePtr, u8 EpNum, u8 Direction, - XUsbPs_EpIsoHandlerFunc CallBackFunc) + XUsbPs_EpIsoHandlerFunc CallBackFunc) { XUsbPs_Endpoint *Ep; void *CallBackRef = (void *) InstancePtr->AppData; @@ -770,21 +772,21 @@ int XUsbPs_EpPrime(XUsbPs *InstancePtr, u8 EpNum, u8 Direction) /* Get the right bit mask for the endpoint direction. */ switch (Direction) { - case XUSBPS_EP_DIRECTION_OUT: - Mask = 0x00000001; - break; + case XUSBPS_EP_DIRECTION_OUT: + Mask = 0x00000001; + break; - case XUSBPS_EP_DIRECTION_IN: - Mask = 0x00010000; - break; + case XUSBPS_EP_DIRECTION_IN: + Mask = 0x00010000; + break; - default: - return XST_INVALID_PARAM; + default: + return XST_INVALID_PARAM; } /* Write the endpoint prime register. */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPPRIME_OFFSET, Mask << EpNum); + XUSBPS_EPPRIME_OFFSET, Mask << EpNum); return XST_SUCCESS; } @@ -807,7 +809,7 @@ int XUsbPs_EpPrime(XUsbPs *InstancePtr, u8 EpNum, u8 Direction) * @note None. ******************************************************************************/ int XUsbPs_EpGetSetupData(XUsbPs *InstancePtr, int EpNum, - XUsbPs_SetupData *SetupDataPtr) + XUsbPs_SetupData *SetupDataPtr) { XUsbPs_EpOut *Ep; @@ -844,7 +846,7 @@ int XUsbPs_EpGetSetupData(XUsbPs *InstancePtr, int EpNum, /* Clear the pending endpoint setup stat bit. */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPSTAT_OFFSET, 1 << EpNum); + XUSBPS_EPSTAT_OFFSET, 1 << EpNum); /* Clear the Tripwire bit and continue. */ @@ -877,8 +879,8 @@ int XUsbPs_EpGetSetupData(XUsbPs *InstancePtr, int EpNum, */ Timeout = XUSBPS_TIMEOUT_COUNTER; while ((XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPSTAT_OFFSET) & - (1 << EpNum)) && --Timeout) { + XUSBPS_EPSTAT_OFFSET) & + (1 << EpNum)) && --Timeout) { /* NOP */ } if (0 == Timeout) { @@ -1063,18 +1065,18 @@ static void XUsbPs_dQHInit(XUsbPs_DeviceConfig *DevCfgPtr) * values in queue head than other types. * Also enable ZLT for isochronous. */ - if(XUSBPS_EP_TYPE_ISOCHRONOUS == EpCfg[EpNum].Out.Type) { + if (XUSBPS_EP_TYPE_ISOCHRONOUS == EpCfg[EpNum].Out.Type) { XUsbPs_dQHSetMaxPacketLenISO(Ep[EpNum].Out.dQH, - EpCfg[EpNum].Out.MaxPacketSize); + EpCfg[EpNum].Out.MaxPacketSize); XUsbPs_dQHEnableZLT(Ep[EpNum].Out.dQH); - }else { + } else { XUsbPs_dQHSetMaxPacketLen(Ep[EpNum].Out.dQH, - EpCfg[EpNum].Out.MaxPacketSize); + EpCfg[EpNum].Out.MaxPacketSize); XUsbPs_dQHDisableZLT(Ep[EpNum].Out.dQH); } /* Only control OUT needs this */ - if(XUSBPS_EP_TYPE_CONTROL == EpCfg[EpNum].Out.Type) { + if (XUSBPS_EP_TYPE_CONTROL == EpCfg[EpNum].Out.Type) { XUsbPs_dQHSetIOS(Ep[EpNum].Out.dQH); } @@ -1089,17 +1091,17 @@ static void XUsbPs_dQHInit(XUsbPs_DeviceConfig *DevCfgPtr) /* IN Queue Heads. */ if (XUSBPS_EP_TYPE_NONE != EpCfg[EpNum].In.Type) { XUsbPs_WritedQH(Ep[EpNum].In.dQH, - XUSBPS_dQHCPTR, Ep[EpNum].In.dTDs); + XUSBPS_dQHCPTR, Ep[EpNum].In.dTDs); /* Isochronous ep packet size can be larger than 1024.*/ - if(XUSBPS_EP_TYPE_ISOCHRONOUS == EpCfg[EpNum].In.Type) { + if (XUSBPS_EP_TYPE_ISOCHRONOUS == EpCfg[EpNum].In.Type) { XUsbPs_dQHSetMaxPacketLenISO(Ep[EpNum].In.dQH, - EpCfg[EpNum].In.MaxPacketSize); + EpCfg[EpNum].In.MaxPacketSize); XUsbPs_dQHEnableZLT(Ep[EpNum].In.dQH); - }else { + } else { XUsbPs_dQHSetMaxPacketLen(Ep[EpNum].In.dQH, - EpCfg[EpNum].In.MaxPacketSize); + EpCfg[EpNum].In.MaxPacketSize); XUsbPs_dQHDisableZLT(Ep[EpNum].In.dQH); } @@ -1154,8 +1156,7 @@ static int XUsbPs_dTDInit(XUsbPs_DeviceConfig *DevCfgPtr) */ if (XUSBPS_EP_TYPE_NONE != EpCfg[EpNum].Out.Type) { NumdTD = EpCfg[EpNum].Out.NumBufs; - } - else { + } else { NumdTD = 0; } @@ -1168,7 +1169,7 @@ static int XUsbPs_dTDInit(XUsbPs_DeviceConfig *DevCfgPtr) /* Set NEXT link pointer. */ XUsbPs_WritedTD(&Out->dTDs[Td], XUSBPS_dTDNLP, - &Out->dTDs[NextTd]); + &Out->dTDs[NextTd]); /* Set the OUT descriptor ACTIVE and enable the * interrupt on complete. @@ -1187,10 +1188,10 @@ static int XUsbPs_dTDInit(XUsbPs_DeviceConfig *DevCfgPtr) } Status = XUsbPs_dTDAttachBuffer( - &Out->dTDs[Td], - Out->dTDBufs + - (Td * EpCfg[EpNum].Out.BufSize), - EpCfg[EpNum].Out.BufSize); + &Out->dTDs[Td], + Out->dTDBufs + + (Td * EpCfg[EpNum].Out.BufSize), + EpCfg[EpNum].Out.BufSize); if (XST_SUCCESS != Status) { return XST_FAILURE; } @@ -1207,8 +1208,7 @@ static int XUsbPs_dTDInit(XUsbPs_DeviceConfig *DevCfgPtr) */ if (XUSBPS_EP_TYPE_NONE != EpCfg[EpNum].In.Type) { NumdTD = EpCfg[EpNum].In.NumBufs; - } - else { + } else { NumdTD = 0; } @@ -1219,7 +1219,7 @@ static int XUsbPs_dTDInit(XUsbPs_DeviceConfig *DevCfgPtr) /* Set NEXT link pointer. */ XUsbPs_WritedTD(In->dTDs[Td], XUSBPS_dTDNLP, - In->dTDs[NextTd]); + In->dTDs[NextTd]); /* Set the IN descriptor's TERMINATE bits. */ XUsbPs_dTDSetTerminate(In->dTDs[Td]); @@ -1255,7 +1255,7 @@ static int XUsbPs_dTDInit(XUsbPs_DeviceConfig *DevCfgPtr) * ******************************************************************************/ static int XUsbPs_dTDAttachBuffer(XUsbPs_dTD *dTDPtr, - const u8 *BufferPtr, u32 BufferLen) + const u8 *BufferPtr, u32 BufferLen) { u32 BufAddr; u32 BufEnd; @@ -1286,7 +1286,7 @@ static int XUsbPs_dTDAttachBuffer(XUsbPs_dTD *dTDPtr, * Only do this check, if we are not sending a 0-length buffer. */ if (BufferLen > 0) { - BufEnd = BufAddr + BufferLen -1; + BufEnd = BufAddr + BufferLen - 1; PtrNum = 1; while ((BufAddr & 0xFFFFF000) != (BufEnd & 0xFFFFF000)) { @@ -1297,7 +1297,7 @@ static int XUsbPs_dTDAttachBuffer(XUsbPs_dTD *dTDPtr, */ BufAddr = (BufAddr + 0x1000) & 0xFFFFF000; XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDBPTR(PtrNum), - BufAddr); + BufAddr); PtrNum++; } } @@ -1344,14 +1344,14 @@ static void XUsbPs_dQHSetMaxPacketLenISO(XUsbPs_dQH *dQHPtr, u32 Len) /* Set Max packet size */ XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, - (XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & - ~XUSBPS_dQHCFG_MPL_MASK) | + (XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & + ~XUSBPS_dQHCFG_MPL_MASK) | (MaxPktSize << XUSBPS_dQHCFG_MPL_SHIFT)); /* Set Mult to tell hardware how many transactions in each microframe */ XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, - (XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & - ~XUSBPS_dQHCFG_MULT_MASK) | + (XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & + ~XUSBPS_dQHCFG_MULT_MASK) | (Mult << XUSBPS_dQHCFG_MULT_SHIFT)); } @@ -1382,8 +1382,9 @@ static void XUsbPs_dQHSetMaxPacketLenISO(XUsbPs_dQH *dQHPtr, u32 Len) * ******************************************************************************/ int XUsbPs_ReconfigureEp(XUsbPs *InstancePtr, XUsbPs_DeviceConfig *CfgPtr, - int EpNum, unsigned short NewDirection, - int DirectionChanged) { + int EpNum, unsigned short NewDirection, + int DirectionChanged) +{ int Status = XST_SUCCESS; XUsbPs_Endpoint *Ep; @@ -1398,8 +1399,8 @@ int XUsbPs_ReconfigureEp(XUsbPs *InstancePtr, XUsbPs_DeviceConfig *CfgPtr, /* If transfer direction changes, dTDs has to be reset * Number of buffers are preset and should not to be changed. */ - if(DirectionChanged) { - if(NewDirection == XUSBPS_EP_DIRECTION_OUT) { + if (DirectionChanged) { + if (NewDirection == XUSBPS_EP_DIRECTION_OUT) { u8 *p; /* Swap the pointer to the dTDs. @@ -1409,19 +1410,19 @@ int XUsbPs_ReconfigureEp(XUsbPs *InstancePtr, XUsbPs_DeviceConfig *CfgPtr, /* Set the OUT buffer if buffer size is not zero */ - if(EpCfg[EpNum].Out.BufSize > 0) { + if (EpCfg[EpNum].Out.BufSize > 0) { Ep[EpNum].Out.dTDBufs = p; } - } else if(NewDirection == XUSBPS_EP_DIRECTION_IN) { + } else if (NewDirection == XUSBPS_EP_DIRECTION_IN) { Ep[EpNum].In.dTDs = Ep[EpNum].Out.dTDs; } } /* Reset dTD progress tracking pointers */ - if(NewDirection == XUSBPS_EP_DIRECTION_IN) { + if (NewDirection == XUSBPS_EP_DIRECTION_IN) { Ep[EpNum].In.dTDHead = Ep[EpNum].In.dTDTail = Ep[EpNum].In.dTDs; - } else if(NewDirection == XUSBPS_EP_DIRECTION_OUT) { + } else if (NewDirection == XUSBPS_EP_DIRECTION_OUT) { Ep[EpNum].Out.dTDCurr = Ep[EpNum].Out.dTDs; } @@ -1432,7 +1433,7 @@ int XUsbPs_ReconfigureEp(XUsbPs *InstancePtr, XUsbPs_DeviceConfig *CfgPtr, /* Reinitialize the dTD linked list, and flush the cache */ Status = XUsbPs_dTDReinitEp(CfgPtr, EpNum, NewDirection); - if(Status != XST_SUCCESS) { + if (Status != XST_SUCCESS) { return Status; } @@ -1458,7 +1459,7 @@ int XUsbPs_ReconfigureEp(XUsbPs *InstancePtr, XUsbPs_DeviceConfig *CfgPtr, * ******************************************************************************/ static void XUsbPs_dQHReinitEp(XUsbPs_DeviceConfig *DevCfgPtr, -int EpNum, unsigned short NewDirection) + int EpNum, unsigned short NewDirection) { XUsbPs_Endpoint *Ep; XUsbPs_EpConfig *EpCfg; @@ -1477,23 +1478,23 @@ int EpNum, unsigned short NewDirection) * - Enable Interrupt On Setup (IOS) * */ - if(NewDirection == XUSBPS_EP_DIRECTION_OUT) { + if (NewDirection == XUSBPS_EP_DIRECTION_OUT) { /* OUT Queue Heads. */ XUsbPs_WritedQH(Ep[EpNum].Out.dQH, - XUSBPS_dQHCPTR, Ep[EpNum].Out.dTDs); + XUSBPS_dQHCPTR, Ep[EpNum].Out.dTDs); /* For isochronous, ep max packet size translates to different * values in queue head than other types. * Also enable ZLT for isochronous. */ - if(XUSBPS_EP_TYPE_ISOCHRONOUS == EpCfg[EpNum].Out.Type) { + if (XUSBPS_EP_TYPE_ISOCHRONOUS == EpCfg[EpNum].Out.Type) { XUsbPs_dQHSetMaxPacketLenISO(Ep[EpNum].Out.dQH, - EpCfg[EpNum].Out.MaxPacketSize); + EpCfg[EpNum].Out.MaxPacketSize); XUsbPs_dQHEnableZLT(Ep[EpNum].Out.dQH); - }else { + } else { XUsbPs_dQHSetMaxPacketLen(Ep[EpNum].Out.dQH, - EpCfg[EpNum].Out.MaxPacketSize); + EpCfg[EpNum].Out.MaxPacketSize); XUsbPs_dQHDisableZLT(Ep[EpNum].Out.dQH); } @@ -1506,21 +1507,21 @@ int EpNum, unsigned short NewDirection) XUsbPs_dQHFlushCache(Ep[EpNum].Out.dQH); - } else if(NewDirection == XUSBPS_EP_DIRECTION_IN) { + } else if (NewDirection == XUSBPS_EP_DIRECTION_IN) { /* IN Queue Heads. */ XUsbPs_WritedQH(Ep[EpNum].In.dQH, - XUSBPS_dQHCPTR, Ep[EpNum].In.dTDs); + XUSBPS_dQHCPTR, Ep[EpNum].In.dTDs); /* Isochronous ep packet size can be larger than 1024. */ - if(XUSBPS_EP_TYPE_ISOCHRONOUS == EpCfg[EpNum].In.Type) { + if (XUSBPS_EP_TYPE_ISOCHRONOUS == EpCfg[EpNum].In.Type) { XUsbPs_dQHSetMaxPacketLenISO(Ep[EpNum].In.dQH, - EpCfg[EpNum].In.MaxPacketSize); + EpCfg[EpNum].In.MaxPacketSize); XUsbPs_dQHEnableZLT(Ep[EpNum].In.dQH); - }else { + } else { XUsbPs_dQHSetMaxPacketLen(Ep[EpNum].In.dQH, - EpCfg[EpNum].In.MaxPacketSize); + EpCfg[EpNum].In.MaxPacketSize); XUsbPs_dQHDisableZLT(Ep[EpNum].In.dQH); } @@ -1553,7 +1554,7 @@ int EpNum, unsigned short NewDirection) * ******************************************************************************/ static int XUsbPs_dTDReinitEp(XUsbPs_DeviceConfig *DevCfgPtr, -int EpNum, unsigned short NewDirection) + int EpNum, unsigned short NewDirection) { XUsbPs_Endpoint *Ep; XUsbPs_EpConfig *EpCfg; @@ -1567,7 +1568,7 @@ int EpNum, unsigned short NewDirection) EpCfg = DevCfgPtr->EpCfg; - if(NewDirection == XUSBPS_EP_DIRECTION_OUT) { + if (NewDirection == XUSBPS_EP_DIRECTION_OUT) { XUsbPs_EpOut *Out = &Ep[EpNum].Out; /* OUT Descriptors @@ -1589,7 +1590,7 @@ int EpNum, unsigned short NewDirection) /* Set NEXT link pointer. */ XUsbPs_WritedTD(&Out->dTDs[Td], XUSBPS_dTDNLP, - &Out->dTDs[NextTd]); + &Out->dTDs[NextTd]); /* Set the OUT descriptor ACTIVE and enable the * interrupt on complete. @@ -1604,17 +1605,17 @@ int EpNum, unsigned short NewDirection) if (Out->dTDBufs != NULL) { Status = XUsbPs_dTDAttachBuffer( - &Out->dTDs[Td], - Out->dTDBufs + - (Td * EpCfg[EpNum].Out.BufSize), - EpCfg[EpNum].Out.BufSize); + &Out->dTDs[Td], + Out->dTDBufs + + (Td * EpCfg[EpNum].Out.BufSize), + EpCfg[EpNum].Out.BufSize); if (Status != XST_SUCCESS) { return XST_FAILURE; } } XUsbPs_dTDFlushCache(&Out->dTDs[Td]); } - } else if(NewDirection == XUSBPS_EP_DIRECTION_IN) { + } else if (NewDirection == XUSBPS_EP_DIRECTION_IN) { XUsbPs_EpIn *In = &Ep[EpNum].In; /* IN Descriptors @@ -1633,7 +1634,7 @@ int EpNum, unsigned short NewDirection) /* Set NEXT link pointer. */ XUsbPs_WritedTD(&In->dTDs[Td], XUSBPS_dTDNLP, - &In->dTDs[NextTd]); + &In->dTDs[NextTd]); /* Set the IN descriptor's TERMINATE bits. */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_endpoint.h b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_endpoint.h index b924726..2869929 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_endpoint.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_endpoint.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xusbps_endpoint.h -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * * This is an internal file containung the definitions for endpoints. It is @@ -67,9 +68,9 @@ extern "C" { * @{ */ #define XUSBPS_dTDNLP_T_MASK 0x00000001 - /**< USB dTD Next Link Pointer Terminate Bit */ +/**< USB dTD Next Link Pointer Terminate Bit */ #define XUSBPS_dTDNLP_ADDR_MASK 0xFFFFFFE0 - /**< USB dTD Next Link Pointer Address [31:5] */ +/**< USB dTD Next Link Pointer Address [31:5] */ /* @} */ @@ -108,16 +109,16 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDInvalidateCache(dTDPtr) \ - Xil_DCacheInvalidateRange((unsigned int)dTDPtr, sizeof(XUsbPs_dTD)) + Xil_DCacheInvalidateRange((unsigned int)dTDPtr, sizeof(XUsbPs_dTD)) #define XUsbPs_dTDFlushCache(dTDPtr) \ - Xil_DCacheFlushRange((unsigned int)dTDPtr, sizeof(XUsbPs_dTD)) + Xil_DCacheFlushRange((unsigned int)dTDPtr, sizeof(XUsbPs_dTD)) #define XUsbPs_dQHInvalidateCache(dQHPtr) \ - Xil_DCacheInvalidateRange((unsigned int)dQHPtr, sizeof(XUsbPs_dQH)) + Xil_DCacheInvalidateRange((unsigned int)dQHPtr, sizeof(XUsbPs_dQH)) #define XUsbPs_dQHFlushCache(dQHPtr) \ - Xil_DCacheFlushRange((unsigned int)dQHPtr, sizeof(XUsbPs_dQH)) + Xil_DCacheFlushRange((unsigned int)dQHPtr, sizeof(XUsbPs_dQH)) /*****************************************************************************/ /** @@ -132,9 +133,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetTransferLen(dTDPtr, Len) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ (XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) & \ - ~XUSBPS_dTDTOKEN_LEN_MASK) | ((Len) << 16)) + ~XUSBPS_dTDTOKEN_LEN_MASK) | ((Len) << 16)) /*****************************************************************************/ @@ -151,8 +152,8 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDGetNLP(dTDPtr) \ - (XUsbPs_dTD *) ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP)\ - & XUSBPS_dTDNLP_ADDR_MASK)) + (XUsbPs_dTD *) ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP)\ + & XUSBPS_dTDNLP_ADDR_MASK)) /*****************************************************************************/ @@ -168,10 +169,10 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetNLP(dTDPtr, NLP) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ (XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP) & \ - ~XUSBPS_dTDNLP_ADDR_MASK) | \ - ((NLP) & XUSBPS_dTDNLP_ADDR_MASK)) + ~XUSBPS_dTDNLP_ADDR_MASK) | \ + ((NLP) & XUSBPS_dTDNLP_ADDR_MASK)) /*****************************************************************************/ @@ -188,8 +189,8 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDGetTransferLen(dTDPtr) \ - (u32) ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) \ - & XUSBPS_dTDTOKEN_LEN_MASK) >> 16) + (u32) ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) \ + & XUSBPS_dTDTOKEN_LEN_MASK) >> 16) /*****************************************************************************/ @@ -205,9 +206,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetIOC(dTDPtr) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) | \ - XUSBPS_dTDTOKEN_IOC_MASK) + XUSBPS_dTDTOKEN_IOC_MASK) /*****************************************************************************/ @@ -222,9 +223,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetTerminate(dTDPtr) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP) | \ - XUSBPS_dTDNLP_T_MASK) + XUSBPS_dTDNLP_T_MASK) /*****************************************************************************/ @@ -239,9 +240,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDClrTerminate(dTDPtr) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDNLP, \ XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDNLP) & \ - ~XUSBPS_dTDNLP_T_MASK) + ~XUSBPS_dTDNLP_T_MASK) /*****************************************************************************/ @@ -260,8 +261,8 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDIsActive(dTDPtr) \ - ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) & \ - XUSBPS_dTDTOKEN_ACTIVE_MASK) ? TRUE : FALSE) + ((XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) & \ + XUSBPS_dTDTOKEN_ACTIVE_MASK) ? TRUE : FALSE) /*****************************************************************************/ @@ -276,9 +277,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetActive(dTDPtr) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) | \ - XUSBPS_dTDTOKEN_ACTIVE_MASK) + XUSBPS_dTDTOKEN_ACTIVE_MASK) /*****************************************************************************/ /** @@ -293,9 +294,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dTDSetMultO(dTDPtr, val) \ - XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ + XUsbPs_WritedTD(dTDPtr, XUSBPS_dTDTOKEN, \ (XUsbPs_ReaddTD(dTDPtr, XUSBPS_dTDTOKEN) & \ - (~XUSBPS_dTDTOKEN_MULTO_MASK)) | val) + (~XUSBPS_dTDTOKEN_MULTO_MASK)) | val) /*****************************************************************************/ @@ -326,7 +327,7 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_WritedTD(dTDPtr, Id, Val) \ - (*(u32 *) ((u32)(dTDPtr) + (u32)(Id)) = (u32)(Val)) + (*(u32 *) ((u32)(dTDPtr) + (u32)(Id)) = (u32)(Val)) /******************************************************************************/ @@ -368,17 +369,17 @@ extern "C" { * @{ */ #define XUSBPS_dQHCFG_IOS_MASK 0x00008000 - /**< USB dQH Interrupt on Setup Bit */ +/**< USB dQH Interrupt on Setup Bit */ #define XUSBPS_dQHCFG_MPL_MASK 0x07FF0000 - /**< USB dQH Maximum Packet Length - * Field [10:0] */ +/**< USB dQH Maximum Packet Length + * Field [10:0] */ #define XUSBPS_dQHCFG_MPL_SHIFT 16 #define XUSBPS_dQHCFG_ZLT_MASK 0x20000000 - /**< USB dQH Zero Length Termination - * Select Bit */ +/**< USB dQH Zero Length Termination + * Select Bit */ #define XUSBPS_dQHCFG_MULT_MASK 0xC0000000 - /* USB dQH Number of Transactions Field - * [1:0] */ +/* USB dQH Number of Transactions Field + * [1:0] */ #define XUSBPS_dQHCFG_MULT_SHIFT 30 /* @} */ @@ -396,9 +397,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dQHSetMaxPacketLen(dQHPtr, Len) \ - XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ + XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ (XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & \ - ~XUSBPS_dQHCFG_MPL_MASK) | ((Len) << 16)) + ~XUSBPS_dQHCFG_MPL_MASK) | ((Len) << 16)) /*****************************************************************************/ /** @@ -412,9 +413,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dQHSetIOS(dQHPtr) \ - XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ + XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) | \ - XUSBPS_dQHCFG_IOS_MASK) + XUSBPS_dQHCFG_IOS_MASK) /*****************************************************************************/ /** @@ -428,9 +429,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dQHClrIOS(dQHPtr) \ - XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ + XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & \ - ~XUSBPS_dQHCFG_IOS_MASK) + ~XUSBPS_dQHCFG_IOS_MASK) /*****************************************************************************/ /** @@ -445,9 +446,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dQHEnableZLT(dQHPtr) \ - XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ + XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) & \ - ~XUSBPS_dQHCFG_ZLT_MASK) + ~XUSBPS_dQHCFG_ZLT_MASK) /*****************************************************************************/ @@ -463,9 +464,9 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_dQHDisableZLT(dQHPtr) \ - XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ + XUsbPs_WritedQH(dQHPtr, XUSBPS_dQHCFG, \ XUsbPs_ReaddQH(dQHPtr, XUSBPS_dQHCFG) | \ - XUSBPS_dQHCFG_ZLT_MASK) + XUSBPS_dQHCFG_ZLT_MASK) /*****************************************************************************/ /** @@ -495,7 +496,7 @@ extern "C" { * ******************************************************************************/ #define XUsbPs_WritedQH(dQHPtr, Id, Val) \ - (*(u32 *) ((u32)(dQHPtr) + (u32)(Id)) = (u32)(Val)) + (*(u32 *) ((u32)(dQHPtr) + (u32)(Id)) = (u32)(Val)) diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_g.c index 6f90f51..20921f3 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_g.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xusbps_g.c -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * This file contains a configuration table where each entry is a configuration * structure for an XUsbPs device in the system. @@ -41,13 +42,13 @@ XUsbPs_Config XUsbPs_ConfigTable[] = { { - 0, - XPAR_XUSBPS_0_BASEADDR + 0, + XPAR_XUSBPS_0_BASEADDR }, #ifdef XPAR_XUSBPS_1_BASEADDR { - 1, - XPAR_XUSBPS_1_BASEADDR + 1, + XPAR_XUSBPS_1_BASEADDR } #endif }; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_hw.c b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_hw.c index f06656a..7829eb8 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_hw.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_hw.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xusbps_hw.c -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * * The implementation of the XUsbPs interface reset functionality @@ -43,7 +44,7 @@ /*****************************************************************************/ /** -* This function perform the reset sequence to the given usbps interface by +* This function perform the reset sequence to the given usbps interface by * configuring the appropriate control bits in the usbps specific registers. * the usbps reset sequence involves the below steps * Disable the interrupts @@ -61,34 +62,33 @@ void XUsbPs_ResetHw(u32 BaseAddress) { u32 RegVal; u32 Timeout = 0; - + /* Host and device mode */ /* Disable the interrupts */ - XUsbPs_WriteReg(BaseAddress,XUSBPS_IER_OFFSET,0x0); + XUsbPs_WriteReg(BaseAddress, XUSBPS_IER_OFFSET, 0x0); /* Clear the interuupt status */ - RegVal = XUsbPs_ReadReg(BaseAddress,XUSBPS_ISR_OFFSET); - XUsbPs_WriteReg(BaseAddress,XUSBPS_ISR_OFFSET,RegVal); + RegVal = XUsbPs_ReadReg(BaseAddress, XUSBPS_ISR_OFFSET); + XUsbPs_WriteReg(BaseAddress, XUSBPS_ISR_OFFSET, RegVal); - /* Perform the reset operation using USB CMD register */ - RegVal = XUsbPs_ReadReg(BaseAddress,XUSBPS_CMD_OFFSET); + /* Perform the reset operation using USB CMD register */ + RegVal = XUsbPs_ReadReg(BaseAddress, XUSBPS_CMD_OFFSET); RegVal = RegVal | XUSBPS_CMD_RST_MASK; - XUsbPs_WriteReg(BaseAddress,XUSBPS_CMD_OFFSET,RegVal); - RegVal = XUsbPs_ReadReg(BaseAddress,XUSBPS_CMD_OFFSET); + XUsbPs_WriteReg(BaseAddress, XUSBPS_CMD_OFFSET, RegVal); + RegVal = XUsbPs_ReadReg(BaseAddress, XUSBPS_CMD_OFFSET); /* Wait till the reset operation returns success */ /* * FIX ME: right now no indication to the caller or user about * timeout overflow */ - while ((RegVal & XUSBPS_CMD_RST_MASK) && (Timeout < XUSBPS_RESET_TIMEOUT)) - { - RegVal = XUsbPs_ReadReg(BaseAddress,XUSBPS_CMD_OFFSET); + while ((RegVal & XUSBPS_CMD_RST_MASK) && (Timeout < XUSBPS_RESET_TIMEOUT)) { + RegVal = XUsbPs_ReadReg(BaseAddress, XUSBPS_CMD_OFFSET); Timeout++; } - /* Update periodic list base address register with reset value */ - XUsbPs_WriteReg(BaseAddress,XUSBPS_LISTBASE_OFFSET,0x0); - /* Update async/endpoint list base address register with reset value */ - XUsbPs_WriteReg(BaseAddress,XUSBPS_ASYNCLISTADDR_OFFSET,0x0); - + /* Update periodic list base address register with reset value */ + XUsbPs_WriteReg(BaseAddress, XUSBPS_LISTBASE_OFFSET, 0x0); + /* Update async/endpoint list base address register with reset value */ + XUsbPs_WriteReg(BaseAddress, XUSBPS_ASYNCLISTADDR_OFFSET, 0x0); + } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_hw.h index 4f985dc..2f057a6 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xusbps_hw.h -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * * This header file contains identifiers and low-level driver functions (or @@ -22,7 +23,7 @@ * 1.00a wgr 10/10/10 First release * 1.04a nm 10/23/12 Fixed CR# 679106. * 1.05a kpc 07/03/13 Added XUsbPs_ResetHw function prototype - * 2.00a kpc 04/03/14 Fixed CR#777764. Corrected max endpoint vale and masks + * 2.00a kpc 04/03/14 Fixed CR#777764. Corrected max endpoint vale and masks * 2.5 pm 02/20/20 Added Endpoint Control Register bit positions for Rx & Tx * * @@ -110,7 +111,7 @@ extern "C" { /* NOTE: The Port Control / Status Register index is 1-based. */ #define XUSBPS_PORTSCRn_OFFSET(n) \ - (XUSBPS_PORTSCR1_OFFSET + (((n)-1) * XUSBPS_REG_SPACING)) + (XUSBPS_PORTSCR1_OFFSET + (((n)-1) * XUSBPS_REG_SPACING)) #define XUSBPS_OTGCSR_OFFSET 0x000001A4 /**< OTG Status and Control */ @@ -133,7 +134,7 @@ extern "C" { #define XUSBPS_EP_ALL_MASK 0x0FFF0FFF /**< Mask used for endpoint control * registers */ #define XUSBPS_EPCRn_OFFSET(n) \ - (XUSBPS_EPCR0_OFFSET + ((n) * XUSBPS_REG_SPACING)) + (XUSBPS_EPCR0_OFFSET + ((n) * XUSBPS_REG_SPACING)) #define XUSBPS_EPFLUSH_RX_SHIFT 0 #define XUSBPS_EPFLUSH_TX_SHIFT 16 @@ -251,24 +252,24 @@ extern "C" { #define XUSBPS_IXR_TI1_MASK 0x02000000 /**< Timer 1 Interrupt */ #define XUSBPS_IXR_ALL (XUSBPS_IXR_UI_MASK | \ - XUSBPS_IXR_UE_MASK | \ - XUSBPS_IXR_PC_MASK | \ - XUSBPS_IXR_FRE_MASK | \ - XUSBPS_IXR_AA_MASK | \ - XUSBPS_IXR_UR_MASK | \ - XUSBPS_IXR_SR_MASK | \ - XUSBPS_IXR_SLE_MASK | \ - XUSBPS_IXR_ULPI_MASK | \ - XUSBPS_IXR_HCH_MASK | \ - XUSBPS_IXR_RCL_MASK | \ - XUSBPS_IXR_PS_MASK | \ - XUSBPS_IXR_AS_MASK | \ - XUSBPS_IXR_NAK_MASK | \ - XUSBPS_IXR_UA_MASK | \ - XUSBPS_IXR_UP_MASK | \ - XUSBPS_IXR_TI0_MASK | \ - XUSBPS_IXR_TI1_MASK) - /**< Mask for ALL IRQ types */ + XUSBPS_IXR_UE_MASK | \ + XUSBPS_IXR_PC_MASK | \ + XUSBPS_IXR_FRE_MASK | \ + XUSBPS_IXR_AA_MASK | \ + XUSBPS_IXR_UR_MASK | \ + XUSBPS_IXR_SR_MASK | \ + XUSBPS_IXR_SLE_MASK | \ + XUSBPS_IXR_ULPI_MASK | \ + XUSBPS_IXR_HCH_MASK | \ + XUSBPS_IXR_RCL_MASK | \ + XUSBPS_IXR_PS_MASK | \ + XUSBPS_IXR_AS_MASK | \ + XUSBPS_IXR_NAK_MASK | \ + XUSBPS_IXR_UA_MASK | \ + XUSBPS_IXR_UP_MASK | \ + XUSBPS_IXR_TI0_MASK | \ + XUSBPS_IXR_TI1_MASK) +/**< Mask for ALL IRQ types */ /* @} */ @@ -291,13 +292,13 @@ extern "C" { * @{ */ #define XUSBPS_DEVICEADDR_DEVICEAADV_MASK 0x01000000 - /**< Device Addr Auto Advance */ +/**< Device Addr Auto Advance */ #define XUSBPS_DEVICEADDR_ADDR_MASK 0xFE000000 - /**< Device Address */ +/**< Device Address */ #define XUSBPS_DEVICEADDR_ADDR_SHIFT 25 - /**< Address shift */ +/**< Address shift */ #define XUSBPS_DEVICEADDR_MAX 127 - /**< Biggest allowed address */ +/**< Biggest allowed address */ /* @} */ /** @name USB TT Control Register (TTCTRL) bit positions. @@ -319,11 +320,11 @@ extern "C" { * @{ */ #define XUSBPS_TXFILL_OVERHEAD_MASK 0x000000FF - /**< Scheduler Overhead */ +/**< Scheduler Overhead */ #define XUSBPS_TXFILL_HEALTH_MASK 0x00001F00 - /**< Scheduler Health Cntr */ +/**< Scheduler Health Cntr */ #define XUSBPS_TXFILL_BURST_MASK 0x003F0000 - /**< FIFO Burst Threshold */ +/**< FIFO Burst Threshold */ /* @} */ @@ -411,22 +412,22 @@ extern "C" { * Enable Bit */ #define XUSBPS_OTG_ISB_ALL (XUSBPS_OTGSC_IDIS_MASK |\ - XUSBPS_OTGSC_AVVIS_MASK | \ - XUSBPS_OTGSC_ASVIS_MASK | \ - XUSBPS_OTGSC_BSVIS_MASK | \ - XUSBPS_OTGSC_BSEIS_MASK | \ - XUSBPS_OTGSC_1MSS_MASK | \ - XUSBPS_OTGSC_DPIS_MASK) - /** Mask for All IRQ status masks */ + XUSBPS_OTGSC_AVVIS_MASK | \ + XUSBPS_OTGSC_ASVIS_MASK | \ + XUSBPS_OTGSC_BSVIS_MASK | \ + XUSBPS_OTGSC_BSEIS_MASK | \ + XUSBPS_OTGSC_1MSS_MASK | \ + XUSBPS_OTGSC_DPIS_MASK) +/** Mask for All IRQ status masks */ #define XUSBPS_OTG_IEB_ALL (XUSBPS_OTGSC_IDIE_MASK |\ - XUSBPS_OTGSC_AVVIE_MASK | \ - XUSBPS_OTGSC_ASVIE_MASK | \ - XUSBPS_OTGSC_BSVIE_MASK | \ - XUSBPS_OTGSC_BSEE_IEB_MASK | \ - XUSBPS_OTGSC_1MSE_MASK | \ - XUSBPS_OTGSC_DPIE_MASK) - /** Mask for All IRQ Enable masks */ + XUSBPS_OTGSC_AVVIE_MASK | \ + XUSBPS_OTGSC_ASVIE_MASK | \ + XUSBPS_OTGSC_BSVIE_MASK | \ + XUSBPS_OTGSC_BSEE_IEB_MASK | \ + XUSBPS_OTGSC_1MSE_MASK | \ + XUSBPS_OTGSC_DPIE_MASK) +/** Mask for All IRQ Enable masks */ /* @} */ @@ -468,7 +469,7 @@ extern "C" { * *****************************************************************************/ #define XUsbPs_ReadReg(BaseAddress, RegOffset) \ - Xil_In32(BaseAddress + (RegOffset)) + Xil_In32(BaseAddress + (RegOffset)) /****************************************************************************/ @@ -487,7 +488,7 @@ extern "C" { * *****************************************************************************/ #define XUsbPs_WriteReg(BaseAddress, RegOffset, Data) \ - Xil_Out32(BaseAddress + (RegOffset), (Data)) + Xil_Out32(BaseAddress + (RegOffset), (Data)) /************************** Function Prototypes ******************************/ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_intr.c b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_intr.c index 061825a..2acfaaf 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_intr.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_intr.c @@ -1,12 +1,13 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ /******************************************************************************/ /** * @file xusbps_intr.c -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * * This file contains the functions that are related to interrupt processing @@ -83,15 +84,15 @@ void XUsbPs_IntrHandler(void *HandlerRef) /* Clear the interrupt status register. */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_ISR_OFFSET, IrqSts); + XUSBPS_ISR_OFFSET, IrqSts); /* Nak interrupt, used to respond to host's IN request */ - if(IrqSts & XUSBPS_IXR_NAK_MASK) { + if (IrqSts & XUSBPS_IXR_NAK_MASK) { /* Ack the hardware */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPNAKISR_OFFSET, - XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPNAKISR_OFFSET)); + XUSBPS_EPNAKISR_OFFSET, + XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, + XUSBPS_EPNAKISR_OFFSET)); } @@ -134,25 +135,25 @@ void XUsbPs_IntrHandler(void *HandlerRef) * is possible to send setup packets on other endpoints). */ EpStat = XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPSTAT_OFFSET); + XUSBPS_EPSTAT_OFFSET); if (EpStat & 0x0001) { /* Handle the setup packet */ XUsbPs_IntrHandleEp0Setup(InstancePtr); /* Re-Prime the endpoint. * Endpoint is de-primed if a setup packet comes in. - */ + */ XUsbPs_EpPrime(InstancePtr, 0, XUSBPS_EP_DIRECTION_OUT); } /* Check for RX and TX complete interrupts. */ EpCompl = XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPCOMPL_OFFSET); + XUSBPS_EPCOMPL_OFFSET); /* ACK the complete interrupts. */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPCOMPL_OFFSET, EpCompl); + XUSBPS_EPCOMPL_OFFSET, EpCompl); /* Check OUT (RX) endpoints. */ if (EpCompl & XUSBPS_EP_OUT_MASK) { @@ -189,8 +190,8 @@ void XUsbPs_IntrHandler(void *HandlerRef) * ******************************************************************************/ int XUsbPs_IntrSetHandler(XUsbPs *InstancePtr, - XUsbPs_IntrHandlerFunc CallBackFunc, - void *CallBackRef, u32 Mask) + XUsbPs_IntrHandlerFunc CallBackFunc, + void *CallBackRef, u32 Mask) { Xil_AssertNonvoid(InstancePtr != NULL); @@ -256,27 +257,27 @@ static void XUsbPs_IntrHandleTX(XUsbPs *InstancePtr, u32 EpCompl) if (InstancePtr->DeviceConfig.EpCfg[Index].In.Type == - XUSBPS_EP_TYPE_ISOCHRONOUS) { + XUSBPS_EP_TYPE_ISOCHRONOUS) { if (Ep->HandlerIsoFunc) { Ep->HandlerIsoFunc(Ep->HandlerRef, - Ep->RequestedBytes, - Ep->BytesTxed); + Ep->RequestedBytes, + Ep->BytesTxed); } } else { if (Ep->HandlerFunc) { - void *BufPtr; + void *BufPtr; - BufPtr = (void *) XUsbPs_ReaddTD(Ep->dTDTail, - XUSBPS_dTDUSERDATA); + BufPtr = (void *) XUsbPs_ReaddTD(Ep->dTDTail, + XUSBPS_dTDUSERDATA); - Ep->HandlerFunc(Ep->HandlerRef, Index, - XUSBPS_EP_EVENT_DATA_TX, - BufPtr); + Ep->HandlerFunc(Ep->HandlerRef, Index, + XUSBPS_EP_EVENT_DATA_TX, + BufPtr); } } Ep->dTDTail = XUsbPs_dTDGetNLP(Ep->dTDTail); - } while(Ep->dTDTail != Ep->dTDHead); + } while (Ep->dTDTail != Ep->dTDHead); } } @@ -329,25 +330,26 @@ static void XUsbPs_IntrHandleRX(XUsbPs *InstancePtr, u32 EpCompl) * taken. */ if (InstancePtr->DeviceConfig.EpCfg[Index].Out.Type == - XUSBPS_EP_TYPE_ISOCHRONOUS){ + XUSBPS_EP_TYPE_ISOCHRONOUS) { if (Index == 0) { u8 BufferPtr[64] = {0}; /* Get the data buffer. */ XUsbPs_EpDataBufferReceive(InstancePtr, - 0, &BufferPtr[0], 64); + 0, &BufferPtr[0], 64); Ep->MemAlloted = 0; } if (Ep->MemAlloted == 1) { XUsbPs_EpGetData(InstancePtr, Index, - Ep->RequestedBytes); - } else + Ep->RequestedBytes); + } else { break; + } } else { if (Ep->HandlerFunc) { - Ep->HandlerFunc(Ep->HandlerRef, Index, - XUSBPS_EP_EVENT_DATA_RX, NULL); + Ep->HandlerFunc(Ep->HandlerRef, Index, + XUSBPS_EP_EVENT_DATA_RX, NULL); } Ep->dTDCurr = XUsbPs_dTDGetNLP(Ep->dTDCurr); @@ -379,11 +381,12 @@ static void XUsbPs_IntrHandleReset(XUsbPs *InstancePtr, u32 IrqSts) u32 Timeout; u8 Index; - if (InstancePtr->AppData != NULL) + if (InstancePtr->AppData != NULL) { InstancePtr->AppData->State = XUSBPS_STATE_DEFAULT; + } for (Index = 0; Index < InstancePtr->DeviceConfig.NumEndpoints; - Index++) { + Index++) { InstancePtr->DeviceConfig.Ep[Index].Out.MemAlloted = 0; InstancePtr->DeviceConfig.Ep[Index].Out.BufferPtr = NULL; InstancePtr->DeviceConfig.Ep[Index].Out.BytesTxed = 0; @@ -398,8 +401,8 @@ static void XUsbPs_IntrHandleReset(XUsbPs *InstancePtr, u32 IrqSts) * itself. */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, XUSBPS_EPSTAT_OFFSET, - XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPSTAT_OFFSET)); + XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, + XUSBPS_EPSTAT_OFFSET)); /* Clear all the endpoint complete status bits by reading the * XUSBPS_EPCOMPL_OFFSET register and writings its value back @@ -407,8 +410,8 @@ static void XUsbPs_IntrHandleReset(XUsbPs *InstancePtr, u32 IrqSts) */ XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, XUSBPS_EPCOMPL_OFFSET, - XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPCOMPL_OFFSET)); + XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, + XUSBPS_EPCOMPL_OFFSET)); /* Cancel all endpoint prime status by waiting until all bits * in XUSBPS_EPPRIME_OFFSET are 0 and then writing 0xFFFFFFFF @@ -418,12 +421,12 @@ static void XUsbPs_IntrHandleReset(XUsbPs *InstancePtr, u32 IrqSts) */ Timeout = XUSBPS_TIMEOUT_COUNTER; while ((XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPPRIME_OFFSET) & - XUSBPS_EP_ALL_MASK) && --Timeout) { + XUSBPS_EPPRIME_OFFSET) & + XUSBPS_EP_ALL_MASK) && --Timeout) { /* NOP */ } XUsbPs_WriteReg(InstancePtr->Config.BaseAddress, - XUSBPS_EPFLUSH_OFFSET, 0xFFFFFFFF); + XUSBPS_EPFLUSH_OFFSET, 0xFFFFFFFF); /* Make sure that the reset bit in XUSBPS_PORTSCR1_OFFSET is * still set at this point. If the code gets to this point and @@ -431,8 +434,8 @@ static void XUsbPs_IntrHandleReset(XUsbPs *InstancePtr, u32 IrqSts) * hardware reset is necessary. */ if (!(XUsbPs_ReadReg(InstancePtr->Config.BaseAddress, - XUSBPS_PORTSCR1_OFFSET) & - XUSBPS_PORTSCR_PR_MASK)) { + XUSBPS_PORTSCR1_OFFSET) & + XUSBPS_PORTSCR_PR_MASK)) { /* Send a notification to the user that a hardware * RESET is required. At this point we can only hope * that the user registered an interrupt handler and @@ -441,8 +444,7 @@ static void XUsbPs_IntrHandleReset(XUsbPs *InstancePtr, u32 IrqSts) if (InstancePtr->HandlerFunc) { (InstancePtr->HandlerFunc)(InstancePtr->HandlerRef, IrqSts); - } - else { + } else { for (;;); } diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_sinit.c index bc53739..fc0daa6 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/usbps/src/xusbps_sinit.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2010 - 2021 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xusbps_sinit.c -* @addtogroup usbps_v2_7 +* @addtogroup usbps Overview * @{ * * The implementation of the XUsbPs driver's static initialization @@ -19,6 +20,7 @@ * Ver Who Date Changes * ----- ---- -------- ----------------------------------------------- * 1.00a wgr 10/10/10 First release + * 2.8 pm 07/07/23 Added support for system device-tree flow. * * *****************************************************************************/ @@ -55,6 +57,7 @@ extern XUsbPs_Config XUsbPs_ConfigTable[]; * controller ID was not found. * ******************************************************************************/ +#ifndef SDT XUsbPs_Config *XUsbPs_LookupConfig(u16 DeviceID) { XUsbPs_Config *CfgPtr = NULL; @@ -70,4 +73,22 @@ XUsbPs_Config *XUsbPs_LookupConfig(u16 DeviceID) return CfgPtr; } +#else +XUsbPs_Config *XUsbPs_LookupConfig(u32 BaseAddress) +{ + XUsbPs_Config *CfgPtr = NULL; + + int Index; + + for (Index = 0U; XUsbPs_ConfigTable[Index].Name != NULL; Index++) { + if ((XUsbPs_ConfigTable[Index].BaseAddress == BaseAddress) || + !BaseAddress) { + CfgPtr = &XUsbPs_ConfigTable[Index]; + break; + } + } + + return CfgPtr; +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/Makefile b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/Makefile index 5feeb49..66f37aa 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/Makefile +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/Makefile @@ -1,4 +1,5 @@ -DRIVER_LIB_VERSION = 1.0 +# Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +DRIVER_LIB_VERSION = 2.7 COMPILER= ARCHIVER= CP=cp diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps.c b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps.c index e8eb9ee..644900f 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xadcps.c -* @addtogroup xadcps_v2_6 +* @addtogroup Overview * @{ * * This file contains the driver API functions that can be used to access @@ -33,6 +34,8 @@ * (CR#854437). * 2.3 mn 07/09/18 Fix Doxygen warning * 2.6 aad 11/02/20 Fix MISRAC Mandatory and Advisory errors. +* 2.7 cog 07/24/23 Added support for SDT flow +* * * * @@ -94,11 +97,13 @@ int XAdcPs_CfgInitialize(XAdcPs *InstancePtr, XAdcPs_Config *ConfigPtr, /* * Set the values read from the device config and the base address. */ +#ifndef SDT InstancePtr->Config.DeviceId = ConfigPtr->DeviceId; +#endif InstancePtr->Config.BaseAddress = EffectiveAddr; /* Write Unlock value to Device Config Unlock register */ - XAdcPs_WriteReg(XPAR_XDCFG_0_BASEADDR, + XAdcPs_WriteReg((InstancePtr)->Config.BaseAddress, XADCPS_UNLK_OFFSET, XADCPS_UNLK_VALUE); /* Enable the PS access of xadc and set FIFO thresholds */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps.h b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps.h index 980f394..f73ff96 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xadcps.h -* @addtogroup xadcps_v2_6 +* @addtogroup Overview * @{ * @details * @@ -157,6 +158,8 @@ * 2.6 aad 11/02/20 Fix MISRAC Mandatory and Advisory errors. * aad 12/17/20 Added missing function declarations and removed * functions with no definitions. +* 2.7 cog 07/24/23 Added support for SDT flow +* * * * @@ -300,7 +303,11 @@ extern "C" { * device. */ typedef struct { +#ifndef SDT u16 DeviceId; /**< Unique ID of device */ +#else + char *Name; +#endif u32 BaseAddress; /**< Device base address */ } XAdcPs_Config; @@ -472,7 +479,11 @@ typedef struct { /** * Functions in xadcps_sinit.c */ +#ifndef SDT XAdcPs_Config *XAdcPs_LookupConfig(u16 DeviceId); +#else +XAdcPs_Config *XAdcPs_LookupConfig(u32 BaseAddress); +#endif /** * Functions in xadcps.c diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_g.c b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_g.c index 338bb94..521805c 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_g.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_g.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xadcps_g.c -* @addtogroup xadcps_v2_6 +* @addtogroup Overview * @{ * * This file contains a configuration table that specifies the configuration diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_hw.h b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_hw.h index 51cc7c5..1477617 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_hw.h +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_hw.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xadcps_hw.h -* @addtogroup xadcps_v2_6 +* @addtogroup Overview * @{ * * This header file contains identifiers and basic driver functions (or diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_intr.c b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_intr.c index dfb1d2d..2bbd1f3 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_intr.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_intr.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xadcps_intr.c -* @addtogroup xadcps_v2_6 +* @addtogroup Overview * @{ * * This file contains interrupt handling API functions of the XADC diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_selftest.c b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_selftest.c index b144c7a..f403f49 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_selftest.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_selftest.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xadcps_selftest.c -* @addtogroup xadcps_v2_6 +* @addtogroup Overview * @{ * * This file contains a diagnostic self test function for the XAdcPs driver. diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_sinit.c b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_sinit.c index e06988a..a1649e6 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_sinit.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xadcps/src/xadcps_sinit.c @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2011 - 2020 Xilinx, Inc. All rights reserved. +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. * SPDX-License-Identifier: MIT ******************************************************************************/ @@ -7,7 +8,7 @@ /** * * @file xadcps_sinit.c -* @addtogroup xadcps_v2_6 +* @addtogroup Overview * @{ * * This file contains the implementation of the XAdcPs driver's static @@ -23,6 +24,7 @@ * ----- ----- -------- ----------------------------------------------------- * 1.00a ssb 12/22/11 First release based on the XPS/AXI XADC driver * 2.6 aad 11/02/20 Fix MISRAC Mandatory and Advisory errors. +* 2.7 cog 07/24/23 Added support for SDT flow * * * @@ -30,8 +32,10 @@ /***************************** Include Files *********************************/ -#include "xparameters.h" #include "xadcps.h" +#ifndef SDT +#include "xparameters.h" +#endif /************************** Constant Definitions *****************************/ @@ -61,6 +65,7 @@ extern XAdcPs_Config XAdcPs_ConfigTable[]; * @note None. * ******************************************************************************/ +#ifndef SDT XAdcPs_Config *XAdcPs_LookupConfig(u16 DeviceId) { XAdcPs_Config *CfgPtr = NULL; @@ -75,4 +80,21 @@ XAdcPs_Config *XAdcPs_LookupConfig(u16 DeviceId) return CfgPtr; } +#else +XAdcPs_Config *XAdcPs_LookupConfig(u32 BaseAddress) +{ + XAdcPs_Config *CfgPtr = NULL; + u32 Index; + + for (Index=0; XAdcPs_ConfigTable[Index].Name != NULL; Index++) { + if ((XAdcPs_ConfigTable[Index].BaseAddress == BaseAddress) || + !BaseAddress) { + CfgPtr = &XAdcPs_ConfigTable[Index]; + break; + } + } + + return CfgPtr; +} +#endif /** @} */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/data/xilffs.mld b/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/data/xilffs.mld index ef73eb5..5a13408 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/data/xilffs.mld +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/data/xilffs.mld @@ -11,6 +11,8 @@ # 1.00 srm 02/16/18 Updated to pick up latest freertos port 10.0 # 4.1 hk 11/21/18 Add additional LFN options # 4.2 aru 07/10/19 Fix coverity warnings +# 5.2 ht 09/12/23 Added code for versioning of library. +# 5.2 ap 10/11/23 Add TRIM option for SDT flow. ############################################################################## OPTION psf_version = 2.1; @@ -20,8 +22,8 @@ BEGIN LIBRARY xilffs OPTION copyfiles = all; OPTION REQUIRES_OS = (standalone freertos10_xilinx); OPTION APP_LINKER_FLAGS = "-Wl,--start-group,-lxilffs,-lxil,-lgcc,-lc,--end-group"; - OPTION desc = "Generic Fat File System Library"; - OPTION VERSION = 5.0; + OPTION desc = "Generic Fat File System Library R0.15"; + OPTION VERSION = 5.2; OPTION NAME = xilffs; PARAM name = fs_interface, desc = "Enables file system with selected interface. Enter 1 for SD. Enter 2 for RAM", type = int, default = 1; PARAM name = read_only, desc = "Enables the file system in Read_Only mode if true. ZynqMP fsbl will set this to true", type = bool, default = false; diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/data/xilffs.tcl b/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/data/xilffs.tcl index ac14532..45708cb 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/data/xilffs.tcl +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/data/xilffs.tcl @@ -1,5 +1,6 @@ ############################################################################### # Copyright (c) 2013 - 2022 Xilinx, Inc. All rights reserved. +# Copyright (c) 2022 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # SPDX-License-Identifier: MIT # # Modification History @@ -9,6 +10,7 @@ # 1.00a hk/sg 10/17/13 First release # 2.0 hk 12/13/13 Modified to use new TCL API's # 4.1 hk 11/21/18 Use additional LFN options +# 5.2 ap 12/11/23 Added support for microblaze risc-v # ############################################################################## @@ -112,7 +114,7 @@ proc xgen_opts_file {libhandle} { if {$ramfs_start_addr == ""} { puts $file_handle "\#define RAMFS_START_ADDR 0x10000000" - if {$proc_type == "microblaze"} { + if {$proc_type == "microblaze" || $proc_type == "microblaze_riscv"} { puts "WARNING : Specify RAM FS start address \ in system.mss for Microblaze\n" } @@ -184,7 +186,7 @@ proc xgen_opts_file {libhandle} { puts $file_handle "\#define FILE_SYSTEM_SET_FS_RPATH $set_fs_rpath" # MB does not allow word access from RAM - if {$proc_type != "microblaze" && $word_access == true} { + if {$proc_type != "microblaze" && $proc_type != "microblaze_riscv" && $word_access == true} { puts $file_handle "\#define FILE_SYSTEM_WORD_ACCESS" } } else { diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/examples/xilffs_polled_example.c b/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/examples/xilffs_polled_example.c deleted file mode 100644 index aa73e38..0000000 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/examples/xilffs_polled_example.c +++ /dev/null @@ -1,234 +0,0 @@ -/****************************************************************************** -* Copyright (c) 2013 - 2022 Xilinx, Inc. All rights reserved. -* Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. -* SPDX-License-Identifier: MIT -******************************************************************************/ - -/*****************************************************************************/ -/** -* -* @file xilffs_polled_example.c -* -* -* @note This example uses file system with SD to write to and read from -* an SD card using ADMA2 in polled mode. -* To test this example File System should not be in Read Only mode. -* To test this example USE_MKFS option should be true. -* -* This example was tested using SD2.0 card and eMMC (using eMMC to SD adaptor). -* -* To test with different logical drives, drive number should be mentioned in -* both FileName and Path variables. By default, it will take drive 0 if drive -* number is not mentioned in the FileName variable. -* For example, to test logical drive 1 -* FileName = "1:/
-* MODIFICATION HISTORY: -* -* Ver Who Date Changes -* ----- --- -------- ----------------------------------------------- -* 1.00a hk 10/17/13 First release -* 2.2 hk 07/28/14 Make changes to enable use of data cache. -* 2.5 sk 07/15/15 Used File size as 8KB to test on emulation platform. -* 2.9 sk 06/09/16 Added support for mkfs. -* 3.10 mn 08/18/18 Change file size to 8MB from 8KB for ZynqMP platform -* -*-* -******************************************************************************/ - -/***************************** Include Files *********************************/ - -#include "xparameters.h" /* SDK generated parameters */ -#include "xsdps.h" /* SD device driver */ -#include "xil_printf.h" -#include "ff.h" -#include "xil_cache.h" -#include "xplatform_info.h" - -/************************** Constant Definitions *****************************/ - - -/**************************** Type Definitions *******************************/ - -/***************** Macros (Inline Functions) Definitions *********************/ - -/************************** Function Prototypes ******************************/ -int FfsSdPolledExample(void); - -/************************** Variable Definitions *****************************/ -static FIL fil; /* File object */ -static FATFS fatfs; -/* - * To test logical drive 0, FileName should be "0:/
+ * MODIFICATION HISTORY: + * + * Ver Who Date Changes + * ----- ---- -------- ------------------------------------------------------- + * 5.2 ht 10/10/23 Added code for versioning of library. + * + *+ * + *@note + *****************************************************************************/ +#ifndef XILFFS_H +#define XILFFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************** Include Files *********************************/ +#include "xil_util.h" +#include "xil_io.h" +#include "xil_types.h" + +/************************** Constant Definitions *****************************/ +/* Library version info */ +#define XILFFS_MAJOR_VERSION 5U +#define XILFFS_MINOR_VERSION 2U + +/****************** Macros (Inline Functions) Definitions *********************/ + +/*****************************************************************************/ +/** + * + * @brief This function returns the version number of xilffs library. + * + * @return 32-bit version number + * +******************************************************************************/ +static __attribute__((always_inline)) INLINE +u32 Xilffs_GetLibVersion(void) +{ + return (XIL_BUILD_VERSION(XILFFS_MAJOR_VERSION, XILFFS_MINOR_VERSION)); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* XILFFS_H */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/src/xilffs.cmake b/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/src/xilffs.cmake new file mode 100644 index 0000000..3a5fff7 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/src/xilffs.cmake @@ -0,0 +1,93 @@ +# Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +# SPDX-License-Identifier: MIT +cmake_minimum_required(VERSION 3.3) + +SET(XILFFS_fs_interface 1 CACHE STRING "Enables file system with selected interface. Enter 1 for SD. Enter 2 for RAM") +SET_PROPERTY(CACHE XILFFS_fs_interface PROPERTY STRINGS 1 2) +option(XILFFS_read_only "Enables the file system in Read_Only mode if true. ZynqMP fsbl will set this to true" OFF) +option(XILFFS_enable_exfat "0:Disable exFAT, 1:Enable exFAT(Also Enables LFN)" OFF) +SET(XILFFS_use_lfn 0 CACHE STRING "Enables the Long File Name(LFN) support if non-zero. Disabled by default: 0, LFN with static working buffer: 1, Dynamic working buffer: 2 (on stack) or 3 (on heap)") +SET_PROPERTY(CACHE XILFFS_use_lfn PROPERTY STRINGS 0 1 2 3) +option(XILFFS_use_mkfs "Disable(0) or Enable(1) f_mkfs function. ZynqMP fsbl will set this to false" ON) +option(XILFFS_use_trim "Disable(0) or Enable(1) TRIM function. ZynqMP fsbl will set this to false" OFF) +option(XILFFS_enable_multi_partition "0:Single partition, 1:Enable multiple partition" OFF) +SET(XILFFS_num_logical_vol 2 CACHE STRING "Number of volumes (logical drives, from 1 to 10) to be used.") +SET(XILFFS_use_strfunc 0 CACHE STRING "Enables the string functions (valid values 0 to 2).") +SET_PROPERTY(CACHE XILFFS_use_strfunc PROPERTY STRINGS 0 1 2) +SET(XILFFS_set_fs_rpath 0 CACHE STRING "Configures relative path feature (valid values 0 to 2).") +SET_PROPERTY(CACHE XILFFS_set_fs_rpath PROPERTY STRINGS 0 1 2) +option(XILFFS_word_access "Enables word access for misaligned memory access platform" ON) +option(XILFFS_use_chmod "Enables use of CHMOD functionality for changing attributes (valid only with read_only set to false)" OFF) + +SET(XILFFS_ramfs_size 3145728 CACHE STRING "RAM FS size") +SET(XILFFS_ramfs_start_addr CACHE STRING "RAM FS start address") + +if (${XILFFS_fs_interface} EQUAL 2) + set(FILE_SYSTEM_INTERFACE_RAM " ") + set(RAMFS_SIZE ${XILFFS_ramfs_size}) + if(${XILFFS_ramfs_start_addr}) + set(RAMFS_START_ADDR ${XILFFS_ramfs_start_addr}) + else() + set(RAMFS_START_ADDR 0x10000000) + endif() +endif() + +if (${XILFFS_fs_interface} EQUAL 1) + set(FILE_SYSTEM_INTERFACE_SD " ") +endif() + +if (${XILFFS_fs_interface}) + if (${XILFFS_read_only}) + set(FILE_SYSTEM_READ_ONLY " ") + endif() + if (${XILFFS_enable_exfat}) + set(XILFFS_use_lfn 1) + set(FILE_SYSTEM_FS_EXFAT " ") + endif() + if (${XILFFS_use_lfn} GREATER 0) + set(FILE_SYSTEM_USE_LFN ${XILFFS_use_lfn}) + endif() + if (${XILFFS_use_mkfs}) + set(FILE_SYSTEM_USE_MKFS " ") + endif() + if (${XILFFS_enable_multi_partition}) + set(FILE_SYSTEM_MULTI_PARTITION " ") + endif() + if (${XILFFS_use_trim}) + set(FILE_SYSTEM_USE_TRIM " ") + endif() + if (${XILFFS_use_chmod}) + if (${XILFFS_read_only}) + message("WARNING : Cannot Enable CHMOD in read only mode\n") + message("WARNING : File System supports only up to 10 logical drives Setting back the num of vol to 10\n") + else() + set(FILE_SYSTEM_USE_CHMOD " ") + endif() + endif() + + if (${XILFFS_num_logical_vol}) + if (${XILFFS_num_logical_vol} GREATER 10) + message("WARNING : File System supports only up to 10 logical drives Setting back the num of vol to 10\n") + set(FILE_SYSTEM_NUM_LOGIC_VOL 10) + else() + set(FILE_SYSTEM_NUM_LOGIC_VOL ${XILFFS_num_logical_vol}) + endif() + endif() + if (${XILFFS_use_strfunc}) + set(FILE_SYSTEM_USE_STRFUNC ${XILFFS_use_strfunc}) + endif() + if (${XILFFS_set_fs_rpath}) + set(FILE_SYSTEM_SET_FS_RPATH ${XILFFS_set_fs_rpath}) + endif() + + if((NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "microblaze") AND + (NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "microblaze_riscv") AND + (NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "microblazeel") AND + (NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "plm_microblaze") AND + (NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "pmu_microblaze") AND + (${XILFFS_word_access})) + set(FILE_SYSTEM_WORD_ACCESS " ") + endif() + +endif() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/xilffs_config.h.in ${CMAKE_BINARY_DIR}/include/xilffs_config.h) diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/src/xilffs_config.h.in b/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/src/xilffs_config.h.in new file mode 100644 index 0000000..a8dd518 --- /dev/null +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xilffs/src/xilffs_config.h.in @@ -0,0 +1,30 @@ +/****************************************************************************** +* Copyright (c) 2023 - 2024 Advanced Micro Devices, Inc. All Rights Reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ +#ifndef XILFFS_CONFIG_H +#define XILFFS_CONFIG_H + +#include "xparameters.h" + +#if (defined XPAR_XSDPS_0_BASEADDR) +#cmakedefine FILE_SYSTEM_INTERFACE_SD @FILE_SYSTEM_INTERFACE_SD@ +#endif + +#cmakedefine FILE_SYSTEM_INTERFACE_RAM @FILE_SYSTEM_INTERFACE_RAM@ +#cmakedefine RAMFS_SIZE @RAMFS_SIZE@ +#cmakedefine RAMFS_START_ADDR @RAMFS_START_ADDR@ + +#cmakedefine FILE_SYSTEM_READ_ONLY @FILE_SYSTEM_READ_ONLY@ +#cmakedefine FILE_SYSTEM_FS_EXFAT @FILE_SYSTEM_FS_EXFAT@ +#cmakedefine FILE_SYSTEM_USE_LFN @FILE_SYSTEM_USE_LFN@ +#cmakedefine FILE_SYSTEM_USE_MKFS @FILE_SYSTEM_USE_MKFS@ +#cmakedefine FILE_SYSTEM_USE_TRIM @FILE_SYSTEM_USE_TRIM@ +#cmakedefine FILE_SYSTEM_MULTI_PARTITION @FILE_SYSTEM_MULTI_PARTITION@ +#cmakedefine FILE_SYSTEM_USE_CHMOD @FILE_SYSTEM_USE_CHMOD@ +#cmakedefine FILE_SYSTEM_NUM_LOGIC_VOL @FILE_SYSTEM_NUM_LOGIC_VOL@ +#cmakedefine FILE_SYSTEM_WORD_ACCESS @FILE_SYSTEM_WORD_ACCESS@ +#cmakedefine FILE_SYSTEM_USE_STRFUNC @FILE_SYSTEM_USE_STRFUNC@ +#cmakedefine FILE_SYSTEM_SET_FS_RPATH @FILE_SYSTEM_SET_FS_RPATH@ + +#endif /* XILFFS_CONFIG_H */ diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/xilrsa/data/xilrsa.mld b/bsp_z7/ps7_cortexa9_0/libsrc/xilrsa/data/xilrsa.mld index cdf6b33..8ff8f4b 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/xilrsa/data/xilrsa.mld +++ b/bsp_z7/ps7_cortexa9_0/libsrc/xilrsa/data/xilrsa.mld @@ -1,5 +1,6 @@ ############################################################################### # Copyright (c) 2014 - 2020 Xilinx, Inc. All rights reserved. +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT # # Modification History @@ -22,6 +23,6 @@ BEGIN LIBRARY xilrsa OPTION SUPPORTED_PERIPHERALS = (ps7_cortexa9); OPTION APP_LINKER_FLAGS = "-Wl,--start-group,-lrsa,-lxil,-lgcc,-lc,--end-group"; OPTION desc = "Xilinx RSA Library to access RSA and SHA software algorithms on Zynq "; - OPTION VERSION = 1.6; + OPTION VERSION = 1.8; OPTION NAME = xilrsa; END LIBRARY