liblitedram: define SDRAM_WLC_DEBUG

SDRAM_WLC_DEBUG is 0 or 1 based on SDRAM_WRITE_LATENCY_CALIBRATION_DEBUG.
This reduces number of #ifdefs

Signed-off-by: Maciej Dudek <mdudek@antmicro.com>
This commit is contained in:
Maciej Dudek 2023-01-24 19:51:56 +01:00 committed by Michal Sieron
parent 8e848f6a13
commit 25b502dec8
1 changed files with 17 additions and 12 deletions

View File

@ -34,6 +34,12 @@
#ifdef CSR_SDRAM_BASE #ifdef CSR_SDRAM_BASE
#ifdef SDRAM_WRITE_LATENCY_CALIBRATION_DEBUG
#define SDRAM_WLC_DEBUG 1
#else
#define SDRAM_WLC_DEBUG 0
#endif
#if SDRAM_PHY_DELAYS > 32 #if SDRAM_PHY_DELAYS > 32
#define MODULO (SDRAM_PHY_DELAYS/32) #define MODULO (SDRAM_PHY_DELAYS/32)
#else #else
@ -1085,9 +1091,9 @@ static void sdram_write_latency_calibration(void) {
best_score = 0; best_score = 0;
best_bitslip = -1; best_bitslip = -1;
for(bitslip=0; bitslip<SDRAM_PHY_BITSLIPS; bitslip+=2) { /* +2 for tCK steps */ for(bitslip=0; bitslip<SDRAM_PHY_BITSLIPS; bitslip+=2) { /* +2 for tCK steps */
#ifdef SDRAM_WRITE_LATENCY_CALIBRATION_DEBUG if (SDRAM_WLC_DEBUG)
printf("m%d wb%02d:\n", module, bitslip); printf("m%d wb%02d:\n", module, bitslip);
#endif
score = 0; score = 0;
/* Select module */ /* Select module */
ddrphy_dly_sel_write(1 << module); ddrphy_dly_sel_write(1 << module);
@ -1102,12 +1108,11 @@ static void sdram_write_latency_calibration(void) {
sdram_read_leveling_rst_bitslip(module); sdram_read_leveling_rst_bitslip(module);
for(i=0; i<SDRAM_PHY_BITSLIPS; i++) { for(i=0; i<SDRAM_PHY_BITSLIPS; i++) {
/* Compute score */ /* Compute score */
#ifdef SDRAM_WRITE_LATENCY_CALIBRATION_DEBUG const int debug = SDRAM_WLC_DEBUG; // Local variable should be optimized out
subscore = sdram_read_leveling_scan_module(module, i, 1); subscore = sdram_read_leveling_scan_module(module, i, debug);
// If SDRAM_WRITE_LATENCY_CALIBRATION_DEBUG was not defined, SDRAM_WLC_DEBUG will be defined as 0, so if(0) should be optimized out
if (debug)
printf("\n"); printf("\n");
#else
subscore = sdram_read_leveling_scan_module(module, i, 0);
#endif
score = subscore > score ? subscore : score; score = subscore > score ? subscore : score;
/* Increment bitslip */ /* Increment bitslip */
sdram_read_leveling_inc_bitslip(module); sdram_read_leveling_inc_bitslip(module);
@ -1130,9 +1135,9 @@ static void sdram_write_latency_calibration(void) {
printf("m%d:- ", module); printf("m%d:- ", module);
else else
printf("m%d:%d ", module, bitslip); printf("m%d:%d ", module, bitslip);
#ifdef SDRAM_WRITE_LATENCY_CALIBRATION_DEBUG
if (SDRAM_WLC_DEBUG)
printf("\n"); printf("\n");
#endif
/* Select best write window */ /* Select best write window */
ddrphy_dly_sel_write(1 << module); ddrphy_dly_sel_write(1 << module);