summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/RISC-V_RV64_PolarFire_SoftConsole/polarfire_hal/platform/mpfs_hal/common/nwc/mss_ddr_debug.h
blob: 20c3c111b4d02f007d5b2eadc4e820ead1d5ddeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*******************************************************************************
 * Copyright 2019-2021 Microchip FPGA Embedded Systems Solutions.
 *
 * SPDX-License-Identifier: MIT
 *
 * MPFS HAL Embedded Software
 *
 */

/*******************************************************************************
 * @file mss_ddr_debug.h
 * @author Microchip-FPGA Embedded Systems Solutions
 * @brief mss_ddr_debug related defines
 *
 */

/*=========================================================================*//**
  @page DDR setup and monitoring
  ==============================================================================
  @section intro_sec Introduction
  ==============================================================================
  DDR debug helper functions

  ==============================================================================
  @section Items located in the north west corner
  ==============================================================================
  -

  ==============================================================================
  @section Overview of DDR related hardware
  ==============================================================================

 *//*=========================================================================*/

#include <stddef.h>
#include <stdint.h>


#ifndef __MSS_DDr_DEBUG_H_
#define __MSS_DDr_DEBUG_H_ 1

#ifdef DEBUG_DDR_INIT
#include "drivers/mss/mss_mmuart/mss_uart.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifndef TEST_64BIT_ACCESS
#define TEST_64BIT_ACCESS 1
#endif

#ifndef TEST_32BIT_ACCESS
#define TEST_32BIT_ACCESS 1
#endif

typedef enum DDR_ACCESS_SIZE_
{
    DDR_8_BIT,
    DDR_16_BIT,
    DDR_32_BIT,
    DDR_64_BIT
} DDR_ACCESS_SIZE;


/***************************************************************************//**
 The ddr_read_write_fn function is used to write/read test patterns to the DDR

  @return
    This function returns 0 if successful, number of errors if not.

  Example:
  @code

    if (ddr_read_write_fn() != 0U)
    {
        .. warn the user, increment error count , wait for watchdog reset
    }

  @endcode
 */
uint32_t
ddr_read_write_fn
(
uint64_t* DDR_word_ptr,
uint32_t no_access,
uint32_t pattern
);

#ifdef DEBUG_DDR_INIT
/***************************************************************************//**
  The uprint32() function is used to print to the designated debug port

  Example:
  @code

  (void)uprint32(g_debug_uart, "\n\r DDR_TRAINING_FAIL: ", error);

  @endcode
 */
void
uprint32
(
mss_uart_instance_t * uart,
const char* msg,
uint32_t d
);

/***************************************************************************//**
  The uprint64() function is used to print to the designated debug port

  Example:
  @code

  (void)uprint64(g_debug_uart, "\n\r DDR_TRAINING_FAIL: ", error);

  @endcode
 */
void
uprint64
(
mss_uart_instance_t * uart,
const char* msg,
uint64_t d
);

/***************************************************************************//**
  The error_status() function is used to print to the designated debug port

  Example:
  @code

  (void)error_status(g_debug_uart, "\n\r DDR_TRAINING_FAIL: ", error);

  @endcode
 */
uint32_t error_status(mss_uart_instance_t *g_mss_uart_debug_pt, uint32_t error);

/***************************************************************************//**
  The wrcalib_status() function is used to print to the designated debug port

  Example:
  @code

  (void)wrcalib_status(mss_uart_instance_t *g_mss_uart_debug_pt);

  @endcode
 */
uint32_t wrcalib_status(mss_uart_instance_t *g_mss_uart_debug_pt);

/***************************************************************************//**
  The tip_register_status() function is used to print ddr TIP status to the
  designated debug port

  Example:
  @code

  (void)tip_register_status(mss_uart_instance_t *g_mss_uart_debug_pt);

  @endcode
 */
uint32_t tip_register_status (mss_uart_instance_t *g_mss_uart_debug_pt);

/***************************************************************************//**
  The setup_ddr_debug_port() function is used to setup a serial port dedicated
  to printing information on the DDR start-up.

  @return
    This function returns 0 if successful

  Example:
  @code

    if (ddr_setup() != 0U)
    {
        .. warn the user, increment error count , wait for watchdog reset
    }

  @endcode
 */
uint32_t
setup_ddr_debug_port
(
mss_uart_instance_t * uart
);

/***************************************************************************//**
 *
 */
void
sweep_status
(
mss_uart_instance_t *g_mss_uart_debug_pt
);

/***************************************************************************//**
 *
 */
void
print_reg_array
(
mss_uart_instance_t * uart,
uint32_t *reg_pointer,
uint32_t no_of_regs
);
#endif

/***************************************************************************//**
 *
 */
void
load_ddr_pattern
(
uint64_t base,
uint32_t size,
uint8_t pattern_offset
);

/***************************************************************************//**
 *
 */
uint32_t
test_ddr
(
uint32_t no_of_iterations,
uint32_t size
);




#ifdef __cplusplus
}
#endif

#endif /* __MSS_DDRC_H_ */