software/liblitedram: allow cmd_delay adjustment even when enforced by the phy.
This commit is contained in:
parent
4f76656018
commit
a9234a8793
|
@ -107,6 +107,7 @@ void sdram_mode_register_write(char reg, int value) {
|
||||||
#ifdef SDRAM_PHY_WRITE_LEVELING_CAPABLE
|
#ifdef SDRAM_PHY_WRITE_LEVELING_CAPABLE
|
||||||
|
|
||||||
int _sdram_write_leveling_cmd_scan = 1;
|
int _sdram_write_leveling_cmd_scan = 1;
|
||||||
|
int _sdram_write_leveling_cmd_delay = 0;
|
||||||
int _sdram_write_leveling_dat_delays[16];
|
int _sdram_write_leveling_dat_delays[16];
|
||||||
|
|
||||||
static void sdram_write_leveling_on(void)
|
static void sdram_write_leveling_on(void)
|
||||||
|
@ -147,6 +148,7 @@ void sdram_write_leveling_rst_cmd_delay(int show) {
|
||||||
|
|
||||||
void sdram_write_leveling_force_cmd_delay(int taps, int show) {
|
void sdram_write_leveling_force_cmd_delay(int taps, int show) {
|
||||||
_sdram_write_leveling_cmd_scan = 0;
|
_sdram_write_leveling_cmd_scan = 0;
|
||||||
|
_sdram_write_leveling_cmd_delay = taps;
|
||||||
if (show)
|
if (show)
|
||||||
printf("Forcing Cmd delay to %d taps\n", taps);
|
printf("Forcing Cmd delay to %d taps\n", taps);
|
||||||
ddrphy_cdly_rst_write(1);
|
ddrphy_cdly_rst_write(1);
|
||||||
|
@ -371,7 +373,8 @@ int sdram_write_leveling(void)
|
||||||
int cdly_range_end;
|
int cdly_range_end;
|
||||||
int cdly_range_step;
|
int cdly_range_step;
|
||||||
|
|
||||||
#ifndef SDRAM_PHY_CMD_DELAY
|
|
||||||
|
if (_sdram_write_leveling_cmd_scan) {
|
||||||
printf(" Cmd/Clk scan:\n");
|
printf(" Cmd/Clk scan:\n");
|
||||||
|
|
||||||
/* Center write leveling by varying cdly. Searching through all possible
|
/* Center write leveling by varying cdly. Searching through all possible
|
||||||
|
@ -403,9 +406,9 @@ int sdram_write_leveling(void)
|
||||||
cdly_range_step /= 4;
|
cdly_range_step /= 4;
|
||||||
}
|
}
|
||||||
printf("| best: %d\n", best_cdly);
|
printf("| best: %d\n", best_cdly);
|
||||||
#else
|
} else {
|
||||||
best_cdly = SDRAM_PHY_CMD_DELAY;
|
best_cdly = _sdram_write_leveling_cmd_delay;
|
||||||
#endif
|
}
|
||||||
printf(" Setting Cmd/Clk delay to %d taps.\n", best_cdly);
|
printf(" Setting Cmd/Clk delay to %d taps.\n", best_cdly);
|
||||||
/* set working or forced delay */
|
/* set working or forced delay */
|
||||||
if (best_cdly >= 0) {
|
if (best_cdly >= 0) {
|
||||||
|
@ -755,13 +758,7 @@ int sdram_leveling(void)
|
||||||
|
|
||||||
#ifdef SDRAM_PHY_WRITE_LEVELING_CAPABLE
|
#ifdef SDRAM_PHY_WRITE_LEVELING_CAPABLE
|
||||||
printf("Write leveling:\n");
|
printf("Write leveling:\n");
|
||||||
if (_sdram_write_leveling_cmd_scan) {
|
|
||||||
sdram_write_leveling();
|
sdram_write_leveling();
|
||||||
} else {
|
|
||||||
/* use only the current cdly */
|
|
||||||
int delays[SDRAM_PHY_MODULES];
|
|
||||||
sdram_write_leveling_scan(delays, 128, 1);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SDRAM_PHY_READ_LEVELING_CAPABLE
|
#ifdef SDRAM_PHY_READ_LEVELING_CAPABLE
|
||||||
|
@ -785,6 +782,10 @@ int sdram_init(void)
|
||||||
int i;
|
int i;
|
||||||
sdram_write_leveling_rst_cmd_delay(0);
|
sdram_write_leveling_rst_cmd_delay(0);
|
||||||
for (i=0; i<16; i++) sdram_write_leveling_rst_dat_delay(i, 0);
|
for (i=0; i<16; i++) sdram_write_leveling_rst_dat_delay(i, 0);
|
||||||
|
#endif
|
||||||
|
#ifdef SDRAM_PHY_CMD_DELAY
|
||||||
|
_sdram_write_leveling_cmd_scan = 0;
|
||||||
|
_sdram_write_leveling_cmd_delay = SDRAM_PHY_CMD_DELAY;
|
||||||
#endif
|
#endif
|
||||||
printf("Initializing SDRAM @0x%08x...\n", MAIN_RAM_BASE);
|
printf("Initializing SDRAM @0x%08x...\n", MAIN_RAM_BASE);
|
||||||
sdram_software_control_on();
|
sdram_software_control_on();
|
||||||
|
|
Loading…
Reference in New Issue