]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/pdk.git/blob - packages/ti/board/diag/ospi/src/ospi_test.h
PDK-6943: Board: Updated ospi diagnostic test for am64x evm
[processor-sdk/pdk.git] / packages / ti / board / diag / ospi / src / ospi_test.h
1 /*
2  * Copyright (C) 2018-2020 Texas Instruments Incorporated - http://www.ti.com/
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
34 /**
35  *  \file   ospi_test.h
36  *
37  *  \brief  ospi diagnostic test header file.
38  *
39  */
41 #ifndef _OSPI_TEST_H_
42 #define _OSPI_TEST_H_
44 #include <stdlib.h>
46 #if defined(SOC_J721E) || defined(SOC_J7200)
47 #include <ti/csl/csl_gpio.h>
48 #include <ti/drv/gpio/GPIO.h>
49 #include <ti/drv/gpio/soc/GPIO_soc.h>
50 #endif
52 #include <ti/drv/uart/UART_stdio.h>
53 #include <ti/drv/spi/SPI.h>
54 #include <ti/drv/spi/soc/SPI_soc.h>
56 #include <ti/board/src/flash/include/board_flash.h>
57 #if defined(j7200_evm) || defined (am64x_evm)
58 #include <ti/board/src/flash/nor/ospi/nor_xspi.h>
59 #else
60 #include <ti/board/src/flash/nor/ospi/nor_ospi.h>
61 #endif
62 #include "board.h"
63 #include "board_cfg.h"
64 #include "diag_common_cfg.h"
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
70 #if !defined(am64x_evm)
71 #define UDMA_ENABLE
72 #endif
74 #if defined(UDMA_ENABLE)
75 /* for enabling SPI_DMA */
76 #include <ti/drv/udma/udma.h>
78 /*
79  * Ring parameters
80  */
81 /** \brief Number of ring entries - we can prime this much memcpy operations */
82 #define UDMA_TEST_APP_RING_ENTRIES      (1U)
83 /** \brief Size (in bytes) of each ring entry (Size of pointer - 64-bit) */
84 #define UDMA_TEST_APP_RING_ENTRY_SIZE   (sizeof(uint64_t))
85 /** \brief Total ring memory */
86 #define UDMA_TEST_APP_RING_MEM_SIZE     (UDMA_TEST_APP_RING_ENTRIES * \
87                                          UDMA_TEST_APP_RING_ENTRY_SIZE)
88 /**
89  *  \brief UDMA TR packet descriptor memory.
90  *  This contains the CSL_UdmapCppi5TRPD + Padding to sizeof(CSL_UdmapTR15) +
91  *  one Type_15 TR (CSL_UdmapTR15) + one TR response of 4 bytes.
92  *  Since CSL_UdmapCppi5TRPD is less than CSL_UdmapTR15, size is just two times
93  *  CSL_UdmapTR15 for alignment.
94  */
95 #define UDMA_TEST_APP_TRPD_SIZE         ((sizeof(CSL_UdmapTR15) * 2U) + 4U)
96 #endif
98 #if defined(SOC_J721E) || defined(SOC_J7200)
99 #define BOARD_DIAG_OSPI_HYPER_BUS_SEL_PIN     (0U)
100 #endif
102 #if defined(j7200_evm) || defined (am64x_evm)
103 #define BOARD_DIAG_OSPI_FLASH_ID              (BOARD_FLASH_ID_S28HS512T)
104 #elif defined(am64x_evm) || defined(am64x_svb)
105 #define BOARD_DIAG_OSPI_FLASH_ID              (BOARD_FLASH_ID_MT35XU256ABA1G12)
106 #else
107 #define BOARD_DIAG_OSPI_FLASH_ID              (BOARD_FLASH_ID_MT35XU512ABA1G12)
108 #endif
110 #ifdef DIAG_STRESS_TEST
111 #define ONE_KB_SIZE                           (1024U) /* 1024 Bytes */
113 #define TEST_DATA_LEN                         (NOR_BLOCK_SIZE)
114 #define MAX_BUFF_SIZE                         (TEST_DATA_LEN + ONE_KB_SIZE)
117 #else /* #ifdef DIAG_STRESS_TEST */
119 #define TEST_DATA_LEN                         (NOR_PAGE_SIZE)
120 #define MAX_BUFF_SIZE                         (TEST_DATA_LEN + 4)
122 #endif /* #ifdef DIAG_STRESS_TEST */
124 #define BOARD_OSPI_FIRST_PAGE        (0x0000)
125 #define BOARD_OSPI_LAST_PAGE         (NOR_SIZE - TEST_DATA_LEN)
127 /**
128  * \brief  ospi test function
129  *
130  * This function executes ospi flash test
131  *
132  * \return  int8_t
133  *              0  - in case of success
134  *             -1  - in case of failure
135  */
136 int8_t BoardDiag_OspiTest(void);
138 #ifdef __cplusplus
140 #endif /* __cplusplus */
142 #endif /* _OSPI_TEST_H_ */