1 /******************************************************************************* 2 * Copyright 2019-2021 Microchip FPGA Embedded Systems Solutions. 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 * MPFS HAL Embedded Software 7 * 8 */ 9 10 /******************************************************************************* 11 * @file mss_ddr_debug.h 12 * @author Microchip-FPGA Embedded Systems Solutions 13 * @brief mss_ddr_debug related defines 14 * 15 */ 16 17 /*=========================================================================*//** 18 @page DDR setup and monitoring 19 ============================================================================== 20 @section intro_sec Introduction 21 ============================================================================== 22 DDR debug helper functions 23 24 ============================================================================== 25 @section Items located in the north west corner 26 ============================================================================== 27 - 28 29 ============================================================================== 30 @section Overview of DDR related hardware 31 ============================================================================== 32 33 *//*=========================================================================*/ 34 35 #include <stddef.h> 36 #include <stdint.h> 37 38 39 #ifndef __MSS_DDr_DEBUG_H_ 40 #define __MSS_DDr_DEBUG_H_ 1 41 42 #ifdef DEBUG_DDR_INIT 43 #include "drivers/mss/mss_mmuart/mss_uart.h" 44 #endif 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 #ifndef TEST_64BIT_ACCESS 51 #define TEST_64BIT_ACCESS 1 52 #endif 53 54 #ifndef TEST_32BIT_ACCESS 55 #define TEST_32BIT_ACCESS 1 56 #endif 57 58 typedef enum DDR_ACCESS_SIZE_ 59 { 60 DDR_8_BIT, 61 DDR_16_BIT, 62 DDR_32_BIT, 63 DDR_64_BIT 64 } DDR_ACCESS_SIZE; 65 66 67 /***************************************************************************//** 68 The ddr_read_write_fn function is used to write/read test patterns to the DDR 69 70 @return 71 This function returns 0 if successful, number of errors if not. 72 73 Example: 74 @code 75 76 if (ddr_read_write_fn() != 0U) 77 { 78 .. warn the user, increment error count , wait for watchdog reset 79 } 80 81 @endcode 82 */ 83 uint32_t 84 ddr_read_write_fn 85 ( 86 uint64_t* DDR_word_ptr, 87 uint32_t no_access, 88 uint32_t pattern 89 ); 90 91 #ifdef DEBUG_DDR_INIT 92 /***************************************************************************//** 93 The uprint32() function is used to print to the designated debug port 94 95 Example: 96 @code 97 98 (void)uprint32(g_debug_uart, "\n\r DDR_TRAINING_FAIL: ", error); 99 100 @endcode 101 */ 102 void 103 uprint32 104 ( 105 mss_uart_instance_t * uart, 106 const char* msg, 107 uint32_t d 108 ); 109 110 /***************************************************************************//** 111 The uprint64() function is used to print to the designated debug port 112 113 Example: 114 @code 115 116 (void)uprint64(g_debug_uart, "\n\r DDR_TRAINING_FAIL: ", error); 117 118 @endcode 119 */ 120 void 121 uprint64 122 ( 123 mss_uart_instance_t * uart, 124 const char* msg, 125 uint64_t d 126 ); 127 128 /***************************************************************************//** 129 The uprint() function is used to print to the designated debug port 130 131 Example: 132 @code 133 134 (void)uprint(g_debug_uart, "\n\r DDR_TRAINING_FAIL: "); 135 136 @endcode 137 */ 138 void 139 uprint 140 ( 141 mss_uart_instance_t * uart, 142 const char* msg 143 ); 144 145 /***************************************************************************//** 146 The error_status() function is used to print to the designated debug port 147 148 Example: 149 @code 150 151 (void)error_status(g_debug_uart, "\n\r DDR_TRAINING_FAIL: ", error); 152 153 @endcode 154 */ 155 uint32_t error_status(mss_uart_instance_t *g_mss_uart_debug_pt, uint32_t error); 156 157 /***************************************************************************//** 158 The wrcalib_status() function is used to print to the designated debug port 159 160 Example: 161 @code 162 163 (void)wrcalib_status(mss_uart_instance_t *g_mss_uart_debug_pt); 164 165 @endcode 166 */ 167 uint32_t wrcalib_status(mss_uart_instance_t *g_mss_uart_debug_pt); 168 169 /***************************************************************************//** 170 The tip_register_status() function is used to print ddr TIP status to the 171 designated debug port 172 173 Example: 174 @code 175 176 (void)tip_register_status(mss_uart_instance_t *g_mss_uart_debug_pt); 177 178 @endcode 179 */ 180 uint32_t tip_register_status (mss_uart_instance_t *g_mss_uart_debug_pt); 181 182 /***************************************************************************//** 183 The setup_ddr_debug_port() function is used to setup a serial port dedicated 184 to printing information on the DDR start-up. 185 186 @return 187 This function returns 0 if successful 188 189 Example: 190 @code 191 192 if (ddr_setup() != 0U) 193 { 194 .. warn the user, increment error count , wait for watchdog reset 195 } 196 197 @endcode 198 */ 199 uint32_t 200 setup_ddr_debug_port 201 ( 202 mss_uart_instance_t * uart 203 ); 204 205 /***************************************************************************//** 206 * 207 */ 208 void 209 sweep_status 210 ( 211 mss_uart_instance_t *g_mss_uart_debug_pt 212 ); 213 214 /***************************************************************************//** 215 * 216 */ 217 void 218 print_reg_array 219 ( 220 mss_uart_instance_t * uart, 221 uint32_t *reg_pointer, 222 uint32_t no_of_regs 223 ); 224 #endif 225 226 /***************************************************************************//** 227 * 228 */ 229 void 230 load_ddr_pattern 231 ( 232 uint64_t base, 233 uint32_t size, 234 uint8_t pattern_offset 235 ); 236 237 /***************************************************************************//** 238 * 239 */ 240 uint32_t 241 test_ddr 242 ( 243 uint32_t no_of_iterations, 244 uint32_t size 245 ); 246 247 248 249 250 #ifdef __cplusplus 251 } 252 #endif 253 254 #endif /* __MSS_DDRC_H_ */ 255 256 257