xilisf: Modified SPIPS examples to support on ZynqMP.

This patch modifies the SPIPS examples to support on
ZynqMP. In Zynq we are selecting hardware using chip
select 0 where as 1 in ZynqMP and also we will use
two different interrupt id's in two platforms.

Signed-off-by: P L Sai Krishna <lakshmis@xilinx.com>
Reviewed-by: Harini Katakam <harinik@xilinx.com>
This commit is contained in:
P L Sai Krishna 2015-08-07 21:41:42 +05:30 committed by Nava kishore Manne
parent 2d669b2c21
commit 3e2f36ff4e
2 changed files with 33 additions and 12 deletions

View file

@ -60,6 +60,7 @@
* for each sector erase.
* 5.0 sb 08/05/14 Registering to Xilisf Interrupt handler
* instead of driver handler.
* 5.4 sk 08/07/15 Modified the example to support on ZynqMP.
*</pre>
*
******************************************************************************/
@ -70,6 +71,7 @@
#include "xscugic.h" /* Interrupt controller device driver */
#include "xil_exception.h"
#include "xil_printf.h"
#include "xplatform_info.h"
#include <xilisf.h>
/************************** Constant Definitions *****************************/
@ -120,7 +122,8 @@
* to select the FLASH device on the SPI bus, this signal is typically
* connected to the chip select of the device
*/
#define FLASH_SPI_SELECT 0x01
#define FLASH_SPI_SELECT_1 0x01
#define FLASH_SPI_SELECT_0 0x00
/**************************** Type Definitions *******************************/
@ -231,6 +234,14 @@ int SpiFlashIntrExample(XScuGic *IntcInstancePtr, XSpiPs *SpiInstancePtr,
u32 Count;
XSpiPs_Config *ConfigPtr; /* Pointer to Configuration ROM data */
u32 TempAddress;
u32 MaxSize = MAX_DATA;
u32 ChipSelect = FLASH_SPI_SELECT_1;
if (XGetPlatform_Info() == XPLAT_ZYNQ_ULTRA_MP) {
MaxSize = 1024 * 10;
ChipSelect = FLASH_SPI_SELECT_0; /* Device is on CS 0 */
SpiIntrId = XPAR_XSPIPS_0_INTR;
}
/*
* Lookup the device configuration in the temporary CROM table. Use this
@ -245,7 +256,7 @@ int SpiFlashIntrExample(XScuGic *IntcInstancePtr, XSpiPs *SpiInstancePtr,
ConfigPtr->BaseAddress);
/* Initialize the XILISF Library */
XIsf_Initialize(&Isf, SpiInstancePtr, FLASH_SPI_SELECT,
XIsf_Initialize(&Isf, SpiInstancePtr, ChipSelect,
IsfWriteBuffer);
XIsf_SetTransferMode(&Isf, XISF_INTERRUPT_MODE);
@ -276,7 +287,7 @@ int SpiFlashIntrExample(XScuGic *IntcInstancePtr, XSpiPs *SpiInstancePtr,
/* Unprotect Sectors */
FlashWrite(&Isf, 0, 0, XISF_WRITE_STATUS_REG);
FlashErase(&Isf, TEST_ADDRESS, MAX_DATA);
FlashErase(&Isf, TEST_ADDRESS, MaxSize);
/*
* Initialize the write buffer for a pattern to write to the FLASH
@ -285,7 +296,7 @@ int SpiFlashIntrExample(XScuGic *IntcInstancePtr, XSpiPs *SpiInstancePtr,
* changed in a debug environment to guarantee
*/
TempAddress = TEST_ADDRESS;
for (UniqueValue = UNIQUE_VALUE, Count = 0; Count < MAX_DATA;
for (UniqueValue = UNIQUE_VALUE, Count = 0; Count < MaxSize;
Count++, UniqueValue++, TempAddress++) {
WriteBuffer[0] = (u8)(UniqueValue);
FlashWrite(&Isf, TempAddress, 1, XISF_WRITE);
@ -295,7 +306,7 @@ int SpiFlashIntrExample(XScuGic *IntcInstancePtr, XSpiPs *SpiInstancePtr,
* Read the contents of the FLASH from TEST_ADDRESS, using Normal Read
* command
*/
FlashRead(&Isf, TEST_ADDRESS, MAX_DATA, XISF_READ);
FlashRead(&Isf, TEST_ADDRESS, MaxSize, XISF_READ);
/*
* Setup a pointer to the start of the data that was read into the read
@ -303,7 +314,7 @@ int SpiFlashIntrExample(XScuGic *IntcInstancePtr, XSpiPs *SpiInstancePtr,
*/
BufferPtr = &ReadBuffer[DATA_OFFSET];
for (UniqueValue = UNIQUE_VALUE, Count = 0; Count < MAX_DATA;
for (UniqueValue = UNIQUE_VALUE, Count = 0; Count < MaxSize;
Count++, UniqueValue++) {
if (BufferPtr[Count] != (u8)(UniqueValue)) {
return XST_FAILURE;

View file

@ -57,6 +57,7 @@
* or write operation. (CR 703816)
* 3.02 srt 04/26/13 Modified Erase function to perform Write Enable operation
* for each sector erase.
* 5.4 sk 08/07/15 Modified the example to support on ZynqMP.
*
*</pre>
*
@ -68,6 +69,7 @@
#include "xscugic.h" /* Interrupt controller device driver */
#include "xil_exception.h"
#include "xil_printf.h"
#include "xplatform_info.h"
#include <xilisf.h>
/************************** Constant Definitions *****************************/
@ -115,7 +117,8 @@
* to select the FLASH device on the SPI bus, this signal is typically
* connected to the chip select of the device
*/
#define FLASH_SPI_SELECT 0x01
#define FLASH_SPI_SELECT_1 0x01
#define FLASH_SPI_SELECT_0 0x00
/**************************** Type Definitions *******************************/
@ -204,6 +207,13 @@ int SpiFlashPolledExample(XSpiPs *SpiInstancePtr,
u32 Count;
XSpiPs_Config *ConfigPtr; /* Pointer to Configuration ROM data */
u32 TempAddress;
u32 MaxSize = MAX_DATA;
u32 ChipSelect = FLASH_SPI_SELECT_1;
if (XGetPlatform_Info() == XPLAT_ZYNQ_ULTRA_MP) {
MaxSize = 1024 * 10;
ChipSelect = FLASH_SPI_SELECT_0; /* Device is on CS 0 */
}
/*
* Lookup the device configuration in the temporary CROM table. Use this
@ -218,7 +228,7 @@ int SpiFlashPolledExample(XSpiPs *SpiInstancePtr,
ConfigPtr->BaseAddress);
/* Initialize the XILISF Library */
XIsf_Initialize(&Isf, SpiInstancePtr, FLASH_SPI_SELECT,
XIsf_Initialize(&Isf, SpiInstancePtr, ChipSelect,
IsfWriteBuffer);
memset(WriteBuffer, 0x00, sizeof(WriteBuffer));
@ -227,7 +237,7 @@ int SpiFlashPolledExample(XSpiPs *SpiInstancePtr,
/* Unprotect Sectors */
FlashWrite(&Isf, 0, 0, XISF_WRITE_STATUS_REG);
FlashErase(&Isf, TEST_ADDRESS, MAX_DATA);
FlashErase(&Isf, TEST_ADDRESS, MaxSize);
/*
* Initialize the write buffer for a pattern to write to the FLASH
@ -236,7 +246,7 @@ int SpiFlashPolledExample(XSpiPs *SpiInstancePtr,
* changed in a debug environment to guarantee
*/
TempAddress = TEST_ADDRESS;
for (UniqueValue = UNIQUE_VALUE, Count = 0; Count < MAX_DATA;
for (UniqueValue = UNIQUE_VALUE, Count = 0; Count < MaxSize;
Count++, UniqueValue++, TempAddress++) {
WriteBuffer[0] = (u8)(UniqueValue);
FlashWrite(&Isf, TempAddress, 1, XISF_WRITE);
@ -246,7 +256,7 @@ int SpiFlashPolledExample(XSpiPs *SpiInstancePtr,
* Read the contents of the FLASH from TEST_ADDRESS, using Normal Read
* command
*/
FlashRead(&Isf, TEST_ADDRESS, MAX_DATA, XISF_READ);
FlashRead(&Isf, TEST_ADDRESS, MaxSize, XISF_READ);
/*
* Setup a pointer to the start of the data that was read into the read
@ -254,7 +264,7 @@ int SpiFlashPolledExample(XSpiPs *SpiInstancePtr,
*/
BufferPtr = &ReadBuffer[DATA_OFFSET];
for (UniqueValue = UNIQUE_VALUE, Count = 0; Count < MAX_DATA;
for (UniqueValue = UNIQUE_VALUE, Count = 0; Count < MaxSize;
Count++, UniqueValue++) {
if (BufferPtr[Count] != (u8)(UniqueValue)) {
return XST_FAILURE;