1 /*
2 * Copyright (C) 2019 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_quad_test.h
36 *
37 * \brief NOR flash diagnostic test header file.
38 *
39 */
41 #ifndef _OSPI_QUAD_TEST_H_
42 #define _OSPI_QUAD_TEST_H_
44 #include <ti/drv/uart/UART_stdio.h>
45 #include <stdlib.h>
46 #include <ti/drv/spi/SPI.h>
47 #include <ti/board/src/flash/include/board_flash.h>
48 #include <ti/drv/spi/soc/SPI_soc.h>
49 #include "board.h"
50 #include "board_cfg.h"
51 #include "diag_common_cfg.h"
53 #if defined(SOC_J721E)
54 #include <ti/drv/gpio/GPIO.h>
55 #include <ti/drv/gpio/soc/GPIO_soc.h>
56 #include <ti/csl/csl_gpio.h>
57 #endif
59 //#define UDMA_ENABLE
60 #if defined(UDMA_ENABLE)
61 /* for enabling SPI_DMA */
62 #include <ti/drv/udma/udma.h>
64 /*
65 * Ring parameters
66 */
67 /** \brief Number of ring entries - we can prime this much memcpy operations */
68 #define UDMA_TEST_APP_RING_ENTRIES (1U)
69 /** \brief Size (in bytes) of each ring entry (Size of pointer - 64-bit) */
70 #define UDMA_TEST_APP_RING_ENTRY_SIZE (sizeof(uint64_t))
71 /** \brief Total ring memory */
72 #define UDMA_TEST_APP_RING_MEM_SIZE (UDMA_TEST_APP_RING_ENTRIES * \
73 UDMA_TEST_APP_RING_ENTRY_SIZE)
74 /**
75 * \brief UDMA TR packet descriptor memory.
76 * This contains the CSL_UdmapCppi5TRPD + Padding to sizeof(CSL_UdmapTR15) +
77 * one Type_15 TR (CSL_UdmapTR15) + one TR response of 4 bytes.
78 * Since CSL_UdmapCppi5TRPD is less than CSL_UdmapTR15, size is just two times
79 * CSL_UdmapTR15 for alignment.
80 */
81 #define UDMA_TEST_APP_TRPD_SIZE ((sizeof(CSL_UdmapTR15) * 2U) + 4U)
82 #endif
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
88 #ifdef DIAG_STRESS_TEST
89 #define ONE_KB_SIZE (1024U) /* 1024 Bytes */
91 #define NOR_PAGE_SIZE (256 * ONE_KB_SIZE)
92 #define TEST_DATA_LEN (NOR_PAGE_SIZE)
93 #define BUFF_SIZE (TEST_DATA_LEN)
94 #define MAX_BUFF_SIZE (257 * ONE_KB_SIZE)
95 #define BOARD_SPI_LAST_PAGE (0x03FC0000)
97 #else
98 #define NOR_PAGE_SIZE (256U)
99 #define TEST_DATA_LEN (NOR_PAGE_SIZE)
100 #define BUFF_SIZE (TEST_DATA_LEN)
101 #define MAX_BUFF_SIZE (260U)
102 #define BOARD_SPI_LAST_PAGE (0x03FFFF00)
103 #endif
105 #define DATA_PATTERN_FF (1)
106 #define DATA_PATTERN_INC (2)
107 #define DATA_PATTERN_AA (3)
108 #define DATA_PATTERN_55 (4)
109 #define DATA_PATTERN_RANDOM (5)
111 #define BOARD_SPI_FIRST_PAGE (0x0000)
113 #define MAX_CLOCK 133000000 /* 133MHz */
115 /**
116 * \brief NOR flash test function
117 *
118 * This function executes NOR flash test
119 *
120 * \return int8_t
121 * 0 - in case of success
122 * -1 - in case of failure
123 */
124 int8_t BoardDiag_spiTest(void);
126 #ifdef __cplusplus
127 }
128 #endif /* __cplusplus */
130 #endif /* _OSPI_QUAD_TEST_H_ */