diff --git a/.github/.cSpellWords.txt b/.github/.cSpellWords.txt index 4b9f2d5f0b..f6e02d5937 100644 --- a/.github/.cSpellWords.txt +++ b/.github/.cSpellWords.txt @@ -1593,6 +1593,7 @@ XPBL Xplorer XPROT xpsr +XSCUGIC xtopology xtopologyp xzvf diff --git a/source/portable/NetworkInterface/Zynq/NetworkInterface.c b/source/portable/NetworkInterface/Zynq/NetworkInterface.c index 8b5913bf16..a90c0d14ac 100644 --- a/source/portable/NetworkInterface/Zynq/NetworkInterface.c +++ b/source/portable/NetworkInterface/Zynq/NetworkInterface.c @@ -149,21 +149,21 @@ struct xtopology_t xXTopologies[ XPAR_XEMACPS_NUM_INSTANCES ] = { [ 0 ] = { - .emac_baseaddr = XPAR_PS7_ETHERNET_0_BASEADDR, + .emac_baseaddr = ZYNQ_ETHERNET_0_BASEADDR, .emac_type = xemac_type_emacps, .intc_baseaddr = 0x0, .intc_emac_intr = 0x0, - .scugic_baseaddr = XPAR_PS7_SCUGIC_0_BASEADDR, + .scugic_baseaddr = ZYNQ_SCUGIC_0_BASEADDR, .scugic_emac_intr = 0x36, }, #if ( XPAR_XEMACPS_NUM_INSTANCES > 1 ) [ 1 ] = { - .emac_baseaddr = XPAR_PS7_ETHERNET_1_BASEADDR, + .emac_baseaddr = ZYNQ_ETHERNET_1_BASEADDR, .emac_type = xemac_type_emacps, .intc_baseaddr = 0x0, .intc_emac_intr = 0x0, - .scugic_baseaddr = XPAR_PS7_SCUGIC_0_BASEADDR, + .scugic_baseaddr = ZYNQ_SCUGIC_0_BASEADDR, .scugic_emac_intr = 0x4D, /* See "7.2.3 Shared Peripheral Interrupts (SPI)" */ }, #endif @@ -173,14 +173,18 @@ XEmacPs_Config mac_configs[ XPAR_XEMACPS_NUM_INSTANCES ] = { [ 0 ] = { - .DeviceId = XPAR_PS7_ETHERNET_0_DEVICE_ID, /**< Unique ID of device, used for 'xEMACIndex' */ - .BaseAddress = XPAR_PS7_ETHERNET_0_BASEADDR /**< Physical base address of IPIF registers */ + #ifndef SDT + .DeviceId = XPAR_PS7_ETHERNET_0_DEVICE_ID, /**< Unique ID of device, used for 'xEMACIndex' */ + #endif + .BaseAddress = ZYNQ_ETHERNET_0_BASEADDR /**< Physical base address of IPIF registers */ }, #if ( XPAR_XEMACPS_NUM_INSTANCES > 1 ) [ 1 ] = { - .DeviceId = XPAR_PS7_ETHERNET_1_DEVICE_ID, /**< Unique ID of device */ - .BaseAddress = XPAR_PS7_ETHERNET_1_BASEADDR /**< Physical base address of IPIF registers */ + #ifndef SDT + .DeviceId = XPAR_PS7_ETHERNET_1_DEVICE_ID, /**< Unique ID of device */ + #endif + .BaseAddress = ZYNQ_ETHERNET_1_BASEADDR /**< Physical base address of IPIF registers */ }, #endif }; diff --git a/source/portable/NetworkInterface/Zynq/uncached_memory.c b/source/portable/NetworkInterface/Zynq/uncached_memory.c index d13625d7cd..7a7c3b6658 100644 --- a/source/portable/NetworkInterface/Zynq/uncached_memory.c +++ b/source/portable/NetworkInterface/Zynq/uncached_memory.c @@ -82,7 +82,11 @@ #ifndef uncMEMORY_SIZE #define uncMEMORY_SIZE uncMINIMAL_MEMORY_SIZE #endif - #define DDR_MEMORY_END ( XPAR_PS7_DDR_0_S_AXI_HIGHADDR + 1 ) + #ifndef SDT + #define DDR_MEMORY_END ( XPAR_PS7_DDR_0_S_AXI_HIGHADDR + 1 ) + #else + #define DDR_MEMORY_END ( XPAR_PS7_DDR_0_HIGHADDRESS + 1 ) + #endif #define uncMEMORY_ATTRIBUTE 0x1C02 #endif /* ( ipconfigULTRASCALE == 1 ) */ diff --git a/source/portable/NetworkInterface/Zynq/x_emacpsif.h b/source/portable/NetworkInterface/Zynq/x_emacpsif.h index 378431f066..cd18fd997e 100644 --- a/source/portable/NetworkInterface/Zynq/x_emacpsif.h +++ b/source/portable/NetworkInterface/Zynq/x_emacpsif.h @@ -38,8 +38,25 @@ extern "C" { #endif - #define XPAR_PS7_ETHERNET_1_DEVICE_ID 1 - #define XPAR_PS7_ETHERNET_1_BASEADDR 0xE000C000 + #ifdef SDT + #define ZYNQ_SCUGIC_0_BASEADDR XPAR_XSCUGIC_0_BASEADDR + #define ZYNQ_ETHERNET_0_BASEADDR XPAR_XEMACPS_0_BASEADDR + #if ( XPAR_XEMACPS_NUM_INSTANCES > 1 ) + #define ZYNQ_ETHERNET_1_BASEADDR XPAR_XEMACPS_1_BASEADDR + #endif + #else + #ifndef XPAR_PS7_ETHERNET_1_DEVICE_ID + #define XPAR_PS7_ETHERNET_1_DEVICE_ID 1 + #endif + #ifndef XPAR_PS7_ETHERNET_1_BASEADDR + #define XPAR_PS7_ETHERNET_1_BASEADDR 0xE000C000 + #endif + #define ZYNQ_SCUGIC_0_BASEADDR XPAR_PS7_SCUGIC_0_BASEADDR + #define ZYNQ_ETHERNET_0_BASEADDR XPAR_PS7_ETHERNET_0_BASEADDR + #if ( XPAR_XEMACPS_NUM_INSTANCES > 1 ) + #define ZYNQ_ETHERNET_1_BASEADDR XPAR_PS7_ETHERNET_1_BASEADDR + #endif + #endif /* ifdef SDT */ extern XEmacPs_Config mac_configs[ XPAR_XEMACPS_NUM_INSTANCES ]; @@ -145,6 +162,8 @@ void clean_dma_txdescs( xemacpsif_s * xemacpsif ); void resetrx_on_no_rxdata( xemacpsif_s * xemacpsif ); + BaseType_t get_xEMACIndex( const XEmacPs * xemacpsp ); + /** * @brief Initialise the interface number 'xIndex'. Do not call directly. */ diff --git a/source/portable/NetworkInterface/Zynq/x_emacpsif_dma.c b/source/portable/NetworkInterface/Zynq/x_emacpsif_dma.c index 69e2f809eb..34b9d8d436 100644 --- a/source/portable/NetworkInterface/Zynq/x_emacpsif_dma.c +++ b/source/portable/NetworkInterface/Zynq/x_emacpsif_dma.c @@ -129,7 +129,7 @@ static void prvPassEthMessages( NetworkBufferDescriptor_t * pxDescriptor ); int is_tx_space_available( xemacpsif_s * xemacpsif ) { size_t uxCount; - BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId; + BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps ); if( xTXDescriptorSemaphores[ xEMACIndex ] != NULL ) { @@ -147,7 +147,7 @@ void emacps_check_tx( xemacpsif_s * xemacpsif ) { int tail = xemacpsif->txTail; int head = xemacpsif->txHead; - BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId; + BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps ); size_t uxCount = ( ( UBaseType_t ) ipconfigNIC_N_TX_DESC ) - uxSemaphoreGetCount( xTXDescriptorSemaphores[ xEMACIndex ] ); /* uxCount is the number of TX descriptors that are in use by the DMA. */ @@ -210,7 +210,7 @@ void emacps_send_handler( void * arg ) BaseType_t xEMACIndex; xemacpsif = ( xemacpsif_s * ) arg; - xEMACIndex = xemacpsif->emacps.Config.DeviceId; + xEMACIndex = get_xEMACIndex( &xemacpsif->emacps ); /* This function is called from an ISR. The Xilinx ISR-handler has already * cleared the TXCOMPL and TXSR_USEDREAD status bits in the XEMACPS_TXSR register. @@ -254,7 +254,7 @@ XStatus emacps_send_message( xemacpsif_s * xemacpsif, int txHead = xemacpsif->txHead; int iHasSent = 0; uint32_t ulBaseAddress = xemacpsif->emacps.Config.BaseAddress; - BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId; + BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps ); TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 5000U ); /* This driver wants to own all network buffers which are to be transmitted. */ @@ -362,7 +362,7 @@ void emacps_recv_handler( void * arg ) xemacpsif = ( xemacpsif_s * ) arg; xemacpsif->isr_events |= EMAC_IF_RX_EVENT; - xEMACIndex = xemacpsif->emacps.Config.DeviceId; + xEMACIndex = get_xEMACIndex( &xemacpsif->emacps ); /* The driver has already cleared the FRAMERX, BUFFNA and error bits * in the XEMACPS_RXSR register, @@ -491,7 +491,7 @@ int emacps_check_rx( xemacpsif_s * xemacpsif, int rx_bytes; volatile int msgCount = 0; int rxHead = xemacpsif->rxHead; - BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId; + BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps ); BaseType_t xAccepted; #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) @@ -632,7 +632,7 @@ void clean_dma_txdescs( xemacpsif_s * xemacpsif ) { int index; unsigned char * ucTxBuffer; - BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId; + BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps ); /* Clear all TX descriptors and assign uncached memory to each descriptor. * "tx_space" points to the first available TX buffer. */ @@ -653,7 +653,7 @@ void clean_dma_txdescs( xemacpsif_s * xemacpsif ) XStatus init_dma( xemacpsif_s * xemacpsif ) { NetworkBufferDescriptor_t * pxBuffer; - BaseType_t xEMACIndex = xemacpsif->emacps.Config.DeviceId; + BaseType_t xEMACIndex = get_xEMACIndex( &xemacpsif->emacps ); int iIndex; UBaseType_t xRxSize; diff --git a/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.c b/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.c index b73a06e9e0..34a564e3a4 100644 --- a/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.c +++ b/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.c @@ -91,7 +91,7 @@ void emacps_error_handler( void * arg, BaseType_t xEMACIndex; xemacpsif = ( xemacpsif_s * ) ( arg ); - xEMACIndex = xemacpsif->emacps.Config.DeviceId; + xEMACIndex = get_xEMACIndex( &xemacpsif->emacps ); if( ( Direction != XEMACPS_SEND ) || ( ErrorWord != XEMACPS_TXSR_USEDREAD_MASK ) ) { @@ -158,7 +158,7 @@ static void emacps_handle_error( void * arg, xemacpsif = ( xemacpsif_s * ) ( arg ); xemacps = &xemacpsif->emacps; - xEMACIndex = xemacps->Config.DeviceId; + xEMACIndex = get_xEMACIndex( xemacps ); last_err_msg = NULL; @@ -253,3 +253,17 @@ void HandleTxErrors( xemacpsif_s * xemacpsif ) } /*taskEXIT_CRITICAL( ); */ } + +BaseType_t get_xEMACIndex( const XEmacPs * xemacpsp ) +{ + #if ( XPAR_XEMACPS_NUM_INSTANCES == 1 ) + ( void ) xemacpsp; + return 0; + #else + #ifndef SDT + return xemacpsp->Config.DeviceId; + #else + return xemacpsp->Config.BaseAddress != ZYNQ_ETHERNET_0_BASEADDR; + #endif + #endif +} diff --git a/source/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c b/source/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c index 9b055fe710..6ea17fe921 100644 --- a/source/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c +++ b/source/portable/NetworkInterface/Zynq/x_emacpsif_physpeed.c @@ -173,7 +173,7 @@ static int detect_phy( XEmacPs * xemacpsp ) { /* Found a valid PHY address */ FreeRTOS_printf( ( "XEmacPs detect_phy: PHY detected at address %d.\n", ( unsigned ) phy_addr ) ); - phy_detected[ xemacpsp->Config.DeviceId ] = phy_addr; + phy_detected[ get_xEMACIndex( xemacpsp ) ] = phy_addr; return phy_addr; } } @@ -506,7 +506,7 @@ static void SetUpSLCRDivisors( int mac_baseaddr, volatile u32 slcrBaseAddress; #ifndef PEEP - u32 SlcrDiv0; + u32 SlcrDiv0 = 0; u32 SlcrDiv1 = 0; u32 SlcrTxClkCntrl; #endif @@ -591,11 +591,19 @@ static void SetUpSLCRDivisors( int mac_baseaddr, } } - SlcrTxClkCntrl = *( volatile unsigned int * ) ( slcrBaseAddress ); - SlcrTxClkCntrl &= EMACPS_SLCR_DIV_MASK; - SlcrTxClkCntrl |= ( SlcrDiv1 << 20 ); - SlcrTxClkCntrl |= ( SlcrDiv0 << 8 ); - *( volatile unsigned int * ) ( slcrBaseAddress ) = SlcrTxClkCntrl; + /* SDT drivers should not write to the register */ + #ifndef SDT + SlcrTxClkCntrl = *( volatile unsigned int * ) ( slcrBaseAddress ); + SlcrTxClkCntrl &= EMACPS_SLCR_DIV_MASK; + SlcrTxClkCntrl |= ( SlcrDiv1 << 20 ); + SlcrTxClkCntrl |= ( SlcrDiv0 << 8 ); + *( volatile unsigned int * ) ( slcrBaseAddress ) = SlcrTxClkCntrl; + #else + ( void ) SlcrTxClkCntrl; + ( void ) SlcrDiv0; + ( void ) SlcrDiv1; + ( void ) slcrBaseAddress; + #endif #endif /* ifdef PEEP */ *( volatile unsigned int * ) ( SLCR_LOCK_ADDR ) = SLCR_LOCK_KEY_VALUE; }