mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-21 14:41:31 +00:00
ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase() part 1
Fix broken multiline debug strings, fix comments. No functional change. Signed-off-by: Marek Vasut <marex@denx.de>
This commit is contained in:
parent
d145ca9fc3
commit
2f3589ca54
1 changed files with 70 additions and 80 deletions
|
@ -1566,7 +1566,7 @@ static int sdr_find_window_center(const u32 grp, const u32 work_bgn,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find a good dqs enable to use */
|
/* find a good dqs enable to use */
|
||||||
static uint32_t rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(uint32_t grp)
|
static uint32_t rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(u32 grp)
|
||||||
{
|
{
|
||||||
uint32_t d, p, i;
|
uint32_t d, p, i;
|
||||||
uint32_t bit_chk;
|
uint32_t bit_chk;
|
||||||
|
@ -1581,16 +1581,13 @@ static uint32_t rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(uint32_t grp)
|
||||||
scc_mgr_set_dqs_en_delay_all_ranks(grp, 0);
|
scc_mgr_set_dqs_en_delay_all_ranks(grp, 0);
|
||||||
scc_mgr_set_dqs_en_phase_all_ranks(grp, 0);
|
scc_mgr_set_dqs_en_phase_all_ranks(grp, 0);
|
||||||
|
|
||||||
/* ************************************************************** */
|
/* Step 0: Determine number of delay taps for each phase tap. */
|
||||||
/* * Step 0 : Determine number of delay taps for each phase tap * */
|
dtaps_per_ptap = IO_DELAY_PER_OPA_TAP / IO_DELAY_PER_DQS_EN_DCHAIN_TAP;
|
||||||
dtaps_per_ptap = IO_DELAY_PER_OPA_TAP/IO_DELAY_PER_DQS_EN_DCHAIN_TAP;
|
|
||||||
|
|
||||||
/* ********************************************************* */
|
/* Step 1: First push vfifo until we get a failing read. */
|
||||||
/* * Step 1 : First push vfifo until we get a failing read * */
|
|
||||||
find_vfifo_failing_read(grp);
|
find_vfifo_failing_read(grp);
|
||||||
|
|
||||||
/* ******************************************************** */
|
/* Step 2: Find first working phase, increment in ptaps. */
|
||||||
/* * step 2: find first working phase, increment in ptaps * */
|
|
||||||
work_bgn = 0;
|
work_bgn = 0;
|
||||||
if (sdr_working_phase(grp, &work_bgn, &d, &p, &i))
|
if (sdr_working_phase(grp, &work_bgn, &d, &p, &i))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1598,25 +1595,25 @@ static uint32_t rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(uint32_t grp)
|
||||||
work_end = work_bgn;
|
work_end = work_bgn;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If d is 0 then the working window covers a phase tap and
|
* If d is 0 then the working window covers a phase tap and we can
|
||||||
* we can follow the old procedure otherwise, we've found the beginning,
|
* follow the old procedure. Otherwise, we've found the beginning
|
||||||
* and we need to increment the dtaps until we find the end.
|
* and we need to increment the dtaps until we find the end.
|
||||||
*/
|
*/
|
||||||
if (d == 0) {
|
if (d == 0) {
|
||||||
/* ********************************************************* */
|
/*
|
||||||
/* * step 3a: if we have room, back off by one and
|
* Step 3a: If we have room, back off by one and
|
||||||
increment in dtaps * */
|
* increment in dtaps.
|
||||||
|
*/
|
||||||
sdr_backup_phase(grp, &work_bgn, &p);
|
sdr_backup_phase(grp, &work_bgn, &p);
|
||||||
|
|
||||||
/* ********************************************************* */
|
/*
|
||||||
/* * step 4a: go forward from working phase to non working
|
* Step 4a: go forward from working phase to non working
|
||||||
phase, increment in ptaps * */
|
* phase, increment in ptaps.
|
||||||
|
*/
|
||||||
if (sdr_nonworking_phase(grp, &work_end, &p, &i))
|
if (sdr_nonworking_phase(grp, &work_end, &p, &i))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* ********************************************************* */
|
/* Step 5a: Back off one from last, increment in dtaps. */
|
||||||
/* * step 5a: back off one from last, increment in dtaps * */
|
|
||||||
|
|
||||||
/* Special case code for backing up a phase */
|
/* Special case code for backing up a phase */
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
|
@ -1629,97 +1626,92 @@ static uint32_t rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(uint32_t grp)
|
||||||
work_end -= IO_DELAY_PER_OPA_TAP;
|
work_end -= IO_DELAY_PER_OPA_TAP;
|
||||||
scc_mgr_set_dqs_en_phase_all_ranks(grp, p);
|
scc_mgr_set_dqs_en_phase_all_ranks(grp, p);
|
||||||
|
|
||||||
/* * The actual increment of dtaps is done outside of
|
|
||||||
the if/else loop to share code */
|
|
||||||
d = 0;
|
d = 0;
|
||||||
|
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: p: \
|
debug_cond(DLEVEL == 2, "%s:%d p: ptap=%u\n",
|
||||||
ptap=%u\n", __func__, __LINE__,
|
__func__, __LINE__, p);
|
||||||
p);
|
|
||||||
} else {
|
} else {
|
||||||
/* ******************************************************* */
|
/*
|
||||||
/* * step 3-5b: Find the right edge of the window using
|
* Step 3-5b: Find the right edge of the window
|
||||||
delay taps * */
|
* using delay taps.
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: \
|
*/
|
||||||
ptap=%u dtap=%u bgn=%u\n", __func__, __LINE__,
|
debug_cond(DLEVEL == 2,
|
||||||
p, d, work_bgn);
|
"%s:%d ptap=%u dtap=%u bgn=%u\n",
|
||||||
|
__func__, __LINE__, p, d, work_bgn);
|
||||||
|
|
||||||
work_end = work_bgn;
|
work_end = work_bgn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The dtap increment to find the failing edge is done here */
|
/* The dtap increment to find the failing edge is done here. */
|
||||||
for (; d <= IO_DQS_EN_DELAY_MAX; d++, work_end +=
|
for (; d <= IO_DQS_EN_DELAY_MAX;
|
||||||
IO_DELAY_PER_DQS_EN_DCHAIN_TAP) {
|
d++, work_end += IO_DELAY_PER_DQS_EN_DCHAIN_TAP) {
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: \
|
debug_cond(DLEVEL == 2, "%s:%d end-2: dtap=%u\n",
|
||||||
end-2: dtap=%u\n", __func__, __LINE__, d);
|
__func__, __LINE__, d);
|
||||||
scc_mgr_set_dqs_en_delay_all_ranks(grp, d);
|
|
||||||
|
|
||||||
if (!rw_mgr_mem_calibrate_read_test_all_ranks(grp, 1,
|
scc_mgr_set_dqs_en_delay_all_ranks(grp, d);
|
||||||
PASS_ONE_BIT,
|
|
||||||
&bit_chk, 0)) {
|
if (!rw_mgr_mem_calibrate_read_test_all_ranks(grp, 1,
|
||||||
break;
|
PASS_ONE_BIT,
|
||||||
}
|
&bit_chk, 0)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Go back to working dtap */
|
/* Go back to working dtap */
|
||||||
if (d != 0)
|
if (d != 0)
|
||||||
work_end -= IO_DELAY_PER_DQS_EN_DCHAIN_TAP;
|
work_end -= IO_DELAY_PER_DQS_EN_DCHAIN_TAP;
|
||||||
|
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: p/d: \
|
debug_cond(DLEVEL == 2,
|
||||||
ptap=%u dtap=%u end=%u\n", __func__, __LINE__,
|
"%s:%d p/d: ptap=%u dtap=%u end=%u\n",
|
||||||
p, d-1, work_end);
|
__func__, __LINE__, p, d - 1, work_end);
|
||||||
|
|
||||||
if (work_end < work_bgn) {
|
if (work_end < work_bgn) {
|
||||||
/* nil range */
|
/* nil range */
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: end-2: \
|
debug_cond(DLEVEL == 2, "%s:%d end-2: failed\n",
|
||||||
failed\n", __func__, __LINE__);
|
__func__, __LINE__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: found range [%u,%u]\n",
|
debug_cond(DLEVEL == 2, "%s:%d found range [%u,%u]\n",
|
||||||
__func__, __LINE__, work_bgn, work_end);
|
__func__, __LINE__, work_bgn, work_end);
|
||||||
|
|
||||||
/* *************************************************************** */
|
|
||||||
/*
|
/*
|
||||||
* * We need to calculate the number of dtaps that equal a ptap
|
* We need to calculate the number of dtaps that equal a ptap.
|
||||||
* * To do that we'll back up a ptap and re-find the edge of the
|
* To do that we'll back up a ptap and re-find the edge of the
|
||||||
* * window using dtaps
|
* window using dtaps
|
||||||
*/
|
*/
|
||||||
|
debug_cond(DLEVEL == 2, "%s:%d calculate dtaps_per_ptap for tracking\n",
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: calculate dtaps_per_ptap \
|
__func__, __LINE__);
|
||||||
for tracking\n", __func__, __LINE__);
|
|
||||||
|
|
||||||
/* Special case code for backing up a phase */
|
/* Special case code for backing up a phase */
|
||||||
if (p == 0) {
|
if (p == 0) {
|
||||||
p = IO_DQS_EN_PHASE_MAX;
|
p = IO_DQS_EN_PHASE_MAX;
|
||||||
rw_mgr_decr_vfifo(grp);
|
rw_mgr_decr_vfifo(grp);
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: backedup \
|
debug_cond(DLEVEL == 2, "%s:%d backedup cycle/phase: p=%u\n",
|
||||||
cycle/phase: p=%u\n", __func__, __LINE__,
|
__func__, __LINE__, p);
|
||||||
p);
|
|
||||||
} else {
|
} else {
|
||||||
p = p - 1;
|
p = p - 1;
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: backedup \
|
debug_cond(DLEVEL == 2, "%s:%d backedup phase only: p=%u",
|
||||||
phase only: p=%u", __func__, __LINE__,
|
__func__, __LINE__, p);
|
||||||
p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scc_mgr_set_dqs_en_phase_all_ranks(grp, p);
|
scc_mgr_set_dqs_en_phase_all_ranks(grp, p);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Increase dtap until we first see a passing read (in case the
|
* Increase dtap until we first see a passing read (in case the
|
||||||
* window is smaller than a ptap),
|
* window is smaller than a ptap), and then a failing read to
|
||||||
* and then a failing read to mark the edge of the window again
|
* mark the edge of the window again.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Find a passing read */
|
/* Find a passing read. */
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: find passing read\n",
|
debug_cond(DLEVEL == 2, "%s:%d find passing read\n",
|
||||||
__func__, __LINE__);
|
__func__, __LINE__);
|
||||||
found_passing_read = 0;
|
found_passing_read = 0;
|
||||||
found_failing_read = 0;
|
found_failing_read = 0;
|
||||||
initial_failing_dtap = d;
|
initial_failing_dtap = d;
|
||||||
for (; d <= IO_DQS_EN_DELAY_MAX; d++) {
|
for (; d <= IO_DQS_EN_DELAY_MAX; d++) {
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: testing \
|
debug_cond(DLEVEL == 2, "%s:%d testing read d=%u\n",
|
||||||
read d=%u\n", __func__, __LINE__, d);
|
__func__, __LINE__, d);
|
||||||
scc_mgr_set_dqs_en_delay_all_ranks(grp, d);
|
scc_mgr_set_dqs_en_delay_all_ranks(grp, d);
|
||||||
|
|
||||||
if (rw_mgr_mem_calibrate_read_test_all_ranks(grp, 1,
|
if (rw_mgr_mem_calibrate_read_test_all_ranks(grp, 1,
|
||||||
|
@ -1731,12 +1723,12 @@ static uint32_t rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(uint32_t grp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_passing_read) {
|
if (found_passing_read) {
|
||||||
/* Find a failing read */
|
/* Find a failing read. */
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: find failing \
|
debug_cond(DLEVEL == 2, "%s:%d find failing read\n",
|
||||||
read\n", __func__, __LINE__);
|
__func__, __LINE__);
|
||||||
for (d = d + 1; d <= IO_DQS_EN_DELAY_MAX; d++) {
|
for (d = d + 1; d <= IO_DQS_EN_DELAY_MAX; d++) {
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: \
|
debug_cond(DLEVEL == 2, "%s:%d testing read d=%u\n",
|
||||||
testing read d=%u\n", __func__, __LINE__, d);
|
__func__, __LINE__, d);
|
||||||
scc_mgr_set_dqs_en_delay_all_ranks(grp, d);
|
scc_mgr_set_dqs_en_delay_all_ranks(grp, d);
|
||||||
|
|
||||||
if (!rw_mgr_mem_calibrate_read_test_all_ranks
|
if (!rw_mgr_mem_calibrate_read_test_all_ranks
|
||||||
|
@ -1746,9 +1738,9 @@ static uint32_t rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(uint32_t grp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug_cond(DLEVEL == 1, "%s:%d find_dqs_en_phase: failed to \
|
debug_cond(DLEVEL == 1,
|
||||||
calculate dtaps", __func__, __LINE__);
|
"%s:%d failed to calculate dtaps per ptap. Fall back on static value\n",
|
||||||
debug_cond(DLEVEL == 1, "per ptap. Fall back on static value\n");
|
__func__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1761,14 +1753,12 @@ static uint32_t rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(uint32_t grp)
|
||||||
dtaps_per_ptap = d - initial_failing_dtap;
|
dtaps_per_ptap = d - initial_failing_dtap;
|
||||||
|
|
||||||
writel(dtaps_per_ptap, &sdr_reg_file->dtaps_per_ptap);
|
writel(dtaps_per_ptap, &sdr_reg_file->dtaps_per_ptap);
|
||||||
debug_cond(DLEVEL == 2, "%s:%d find_dqs_en_phase: dtaps_per_ptap=%u \
|
debug_cond(DLEVEL == 2, "%s:%d dtaps_per_ptap=%u - %u = %u",
|
||||||
- %u = %u", __func__, __LINE__, d,
|
__func__, __LINE__, d, initial_failing_dtap, dtaps_per_ptap);
|
||||||
initial_failing_dtap, dtaps_per_ptap);
|
|
||||||
|
|
||||||
/* ******************************************** */
|
/* Step 6: Find the centre of the window. */
|
||||||
/* * step 6: Find the centre of the window * */
|
|
||||||
if (sdr_find_window_centre(grp, work_bgn, work_end))
|
if (sdr_find_window_centre(grp, work_bgn, work_end))
|
||||||
return 0; /* FIXME: Old code, return 0 means failure :-( */
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue