Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/47493 )
Change subject: nb/intel/sandybridge: Extract some IOSAV sequences into macros ......................................................................
nb/intel/sandybridge: Extract some IOSAV sequences into macros
This allows deduplicating them while preserving reproducibility.
Tested with BUILD_TIMELESS=1, Asus P8Z77-V LX2 remains identical.
Change-Id: Ic7d1a5732296bb678b9954f80508e9f7de7ff319 Signed-off-by: Angel Pons th3fanbus@gmail.com --- M src/northbridge/intel/sandybridge/raminit_common.c M src/northbridge/intel/sandybridge/raminit_common.h 2 files changed, 518 insertions(+), 1,034 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/93/47493/1
diff --git a/src/northbridge/intel/sandybridge/raminit_common.c b/src/northbridge/intel/sandybridge/raminit_common.c index 7a77434..d58eef4 100644 --- a/src/northbridge/intel/sandybridge/raminit_common.c +++ b/src/northbridge/intel/sandybridge/raminit_common.c @@ -530,26 +530,7 @@ /* Choose a populated rank */ slotrank = (ctrl->rankmap[channel] & 1) ? 0 : 2;
- const struct iosav_ssq sequence[] = { - /* DRAM command ZQCS */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_ZQCS, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = 8, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - }, - }; + const struct iosav_ssq sequence[] = ZQCS_SEQUENCE(3, 8, slotrank, 0); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* @@ -1069,93 +1050,7 @@ { wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* - * DRAM command MRS - * - * Write MR3 MPR enable. In this mode only RD and RDA - * are allowed, and all reads return a predefined pattern. - */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 4, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [1] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = 4, - .data_direction = SSQ_RD, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [2] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 15, - .cmd_delay_gap = 4, - .post_ssq_wait = ctrl->CAS + 36, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - }, - /* - * DRAM command MRS - * - * Write MR3 MPR disable. - */ - [3] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - }; + const struct iosav_ssq sequence[] = READ_MPR_SEQUENCE(1, 3, 15, 36); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -1760,30 +1655,7 @@
wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* DRAM command PREA */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_PRE, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tRP, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 1024, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .addr_wrap = 18, - }, - }, - }; + const struct iosav_ssq sequence[] = PREA_SEQUENCE(18); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -1893,94 +1765,7 @@ FOR_ALL_POPULATED_RANKS { wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* - * DRAM command MRS - * - * Write MR3 MPR enable. - * In this mode only RD and RDA are allowed, - * and all reads return a predefined pattern. - */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 4, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [1] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 3, - .cmd_delay_gap = 4, - .post_ssq_wait = 4, - .data_direction = SSQ_RD, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [2] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = ctrl->CAS + 8, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - }, - /* - * DRAM command MRS - * - * Write MR3 MPR disable. - */ - [3] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - }; + const struct iosav_ssq sequence[] = READ_MPR_SEQUENCE(3, 4, 1, 8); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -1999,94 +1784,7 @@ FOR_ALL_POPULATED_RANKS { wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* - * DRAM command MRS - * - * Write MR3 MPR enable. - * In this mode only RD and RDA are allowed, - * and all reads return a predefined pattern. - */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 4, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [1] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 3, - .cmd_delay_gap = 4, - .post_ssq_wait = 4, - .data_direction = SSQ_RD, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [2] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = ctrl->CAS + 8, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - }, - /* - * DRAM command MRS - * - * Write MR3 MPR disable. - */ - [3] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - }; + const struct iosav_ssq sequence[] = READ_MPR_SEQUENCE(3, 4, 1, 8); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -2432,29 +2130,7 @@ /* choose an existing rank. */ slotrank = !(ctrl->rankmap[channel] & 1) ? 2 : 0;
- const struct iosav_ssq sequence[] = { - /* DRAM command ZQCS */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_ZQCS, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = 4, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .addr_wrap = 31, - }, - }, - }; + const struct iosav_ssq sequence[] = ZQCS_SEQUENCE(4, 4, slotrank, 31); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -2529,29 +2205,7 @@ MCHBAR32(IOSAV_STATUS_ch(channel)); wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* DRAM command ZQCS */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_ZQCS, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = 101, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = 0, - }, - .addr_update = { - .addr_wrap = 31, - }, - }, - }; + const struct iosav_ssq sequence[] = ZQCS_SEQUENCE(4, 101, 0, 31); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -2618,103 +2272,7 @@
wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* DRAM command ACT */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_ACT, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 8, - .cmd_delay_gap = MAX(ctrl->tRRD, (ctrl->tFAW >> 2) + 1), - .post_ssq_wait = ctrl->tRCD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = ctr, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_bank = 1, - .addr_wrap = 18, - }, - }, - /* DRAM command WR */ - [1] = { - .sp_cmd_ctrl = { - .command = IOSAV_WR, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 32, - .cmd_delay_gap = 4, - .post_ssq_wait = ctrl->CWL + ctrl->tWTR + 8, - .data_direction = SSQ_WR, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_addr_8 = 1, - .addr_wrap = 18, - .lfsr_upd = 3, - .lfsr_xors = 2, - }, - }, - /* DRAM command RD */ - [2] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 32, - .cmd_delay_gap = 4, - .post_ssq_wait = MAX(ctrl->tRTP, 8), - .data_direction = SSQ_RD, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_addr_8 = 1, - .addr_wrap = 18, - .lfsr_upd = 3, - .lfsr_xors = 2, - }, - }, - /* DRAM command PRE */ - [3] = { - .sp_cmd_ctrl = { - .command = IOSAV_PRE, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = 15, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 1024, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .addr_wrap = 18, - }, - }, - }; + const struct iosav_ssq sequence[] = COMMAND_TRAINING_SEQUENCE(ctr); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Program LFSR for the RD/WR subsequences */ @@ -2783,29 +2341,7 @@ /* Choose an existing rank */ slotrank = !(ctrl->rankmap[channel] & 1) ? 2 : 0;
- const struct iosav_ssq sequence[] = { - /* DRAM command ZQCS */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_ZQCS, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = 4, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .addr_wrap = 31, - }, - }, - }; + const struct iosav_ssq sequence[] = ZQCS_SEQUENCE(4, 4, slotrank, 31); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -2823,29 +2359,7 @@ /* choose an existing rank. */ slotrank = !(ctrl->rankmap[channel] & 1) ? 2 : 0;
- const struct iosav_ssq sequence[] = { - /* DRAM command ZQCS */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_ZQCS, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = 4, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .addr_wrap = 31, - }, - }, - }; + const struct iosav_ssq sequence[] = ZQCS_SEQUENCE(4, 4, slotrank, 31); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -3007,94 +2521,7 @@
wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* - * DRAM command MRS - * - * Write MR3 MPR enable. - * In this mode only RD and RDA are allowed, - * and all reads return a predefined pattern. - */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 4, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [1] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 500, - .cmd_delay_gap = 4, - .post_ssq_wait = 4, - .data_direction = SSQ_RD, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [2] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = ctrl->CAS + 8, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - }, - /* - * DRAM command MRS - * - * Write MR3 MPR disable. - */ - [3] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - }; + const struct iosav_ssq sequence[] = READ_MPR_SEQUENCE(500, 4, 1, 8); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -3152,94 +2579,7 @@ FOR_ALL_POPULATED_RANKS { wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* - * DRAM command MRS - * - * Write MR3 MPR enable. - * In this mode only RD and RDA are allowed, - * and all reads return a predefined pattern. - */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 4, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [1] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 3, - .cmd_delay_gap = 4, - .post_ssq_wait = 4, - .data_direction = SSQ_RD, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [2] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = ctrl->CAS + 8, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - }, - /* - * DRAM command MRS - * - * Write MR3 MPR disable. - */ - [3] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - }; + const struct iosav_ssq sequence[] = READ_MPR_SEQUENCE(3, 4, 1, 8); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -3260,94 +2600,7 @@ FOR_ALL_POPULATED_RANKS { wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* - * DRAM command MRS - * - * Write MR3 MPR enable. - * In this mode only RD and RDA are allowed, - * and all reads return a predefined pattern. - */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 4, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [1] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 3, - .cmd_delay_gap = 4, - .post_ssq_wait = 4, - .data_direction = SSQ_RD, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - }, - /* DRAM command RD */ - [2] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = ctrl->CAS + 8, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - }, - /* - * DRAM command MRS - * - * Write MR3 MPR disable. - */ - [3] = { - .sp_cmd_ctrl = { - .command = IOSAV_MRS, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tMOD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 3, - .rank = slotrank, - }, - }, - }; + const struct iosav_ssq sequence[] = READ_MPR_SEQUENCE(3, 4, 1, 8); iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -3448,97 +2701,7 @@ } wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* DRAM command ACT */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_ACT, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 4, - .cmd_delay_gap = MAX(ctrl->tRRD, - (ctrl->tFAW >> 2) + 1), - .post_ssq_wait = ctrl->tRCD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .addr_wrap = 18, - }, - }, - /* DRAM command WR */ - [1] = { - .sp_cmd_ctrl = { - .command = IOSAV_WR, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 32, - .cmd_delay_gap = 20, - .post_ssq_wait = ctrl->tWTR + - ctrl->CWL + 8, - .data_direction = SSQ_WR, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_addr_8 = 1, - .addr_wrap = 18, - }, - }, - /* DRAM command RD */ - [2] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 32, - .cmd_delay_gap = 20, - .post_ssq_wait = MAX(ctrl->tRTP, 8), - .data_direction = SSQ_RD, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_addr_8 = 1, - .addr_wrap = 18, - }, - }, - /* DRAM command PRE */ - [3] = { - .sp_cmd_ctrl = { - .command = IOSAV_PRE, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = ctrl->tRP, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 1024, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - }, - }; + const struct iosav_ssq sequence[] = WRITE_DATA_SEQUENCE; iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -3637,96 +2800,7 @@ { wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* DRAM command ACT */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_ACT, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 4, - .cmd_delay_gap = MAX((ctrl->tFAW >> 2) + 1, ctrl->tRRD), - .post_ssq_wait = ctrl->tRCD, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_bank = 1, - .addr_wrap = 18, - }, - }, - /* DRAM command WR */ - [1] = { - .sp_cmd_ctrl = { - .command = IOSAV_WR, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 480, - .cmd_delay_gap = 4, - .post_ssq_wait = ctrl->tWTR + ctrl->CWL + 8, - .data_direction = SSQ_WR, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_addr_8 = 1, - .addr_wrap = 18, - }, - }, - /* DRAM command RD */ - [2] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 480, - .cmd_delay_gap = 4, - .post_ssq_wait = MAX(ctrl->tRTP, 8), - .data_direction = SSQ_RD, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_addr_8 = 1, - .addr_wrap = 18, - }, - }, - /* DRAM command PRE */ - [3] = { - .sp_cmd_ctrl = { - .command = IOSAV_PRE, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 4, - .post_ssq_wait = ctrl->tRP, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 1024, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - }, - }; + const struct iosav_ssq sequence[] = READ_WRITE_SEQUENCE_ALT_2; iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ @@ -3903,99 +2977,7 @@ } wait_for_iosav(channel);
- const struct iosav_ssq sequence[] = { - /* DRAM command ACT */ - [0] = { - .sp_cmd_ctrl = { - .command = IOSAV_ACT, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 4, - .cmd_delay_gap = 8, - .post_ssq_wait = 40, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_bank = 1, - .addr_wrap = 18, - }, - }, - /* DRAM command WR */ - [1] = { - .sp_cmd_ctrl = { - .command = IOSAV_WR, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 100, - .cmd_delay_gap = 4, - .post_ssq_wait = 40, - .data_direction = SSQ_WR, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_addr_8 = 1, - .addr_wrap = 18, - }, - }, - /* DRAM command RD */ - [2] = { - .sp_cmd_ctrl = { - .command = IOSAV_RD, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 100, - .cmd_delay_gap = 4, - .post_ssq_wait = 40, - .data_direction = SSQ_RD, - }, - .sp_cmd_addr = { - .address = 0, - .rowbits = 0, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .inc_addr_8 = 1, - .addr_wrap = 18, - }, - }, - /* DRAM command PRE */ - [3] = { - .sp_cmd_ctrl = { - .command = IOSAV_PRE, - .ranksel_ap = 1, - }, - .subseq_ctrl = { - .cmd_executions = 1, - .cmd_delay_gap = 3, - .post_ssq_wait = 40, - .data_direction = SSQ_NA, - }, - .sp_cmd_addr = { - .address = 1024, - .rowbits = 6, - .bank = 0, - .rank = slotrank, - }, - .addr_update = { - .addr_wrap = 18, - }, - }, - }; + const struct iosav_ssq sequence[] = MEMORY_TEST_SEQUENCE; iosav_write_sequence(channel, sequence, ARRAY_SIZE(sequence));
/* Execute command queue */ diff --git a/src/northbridge/intel/sandybridge/raminit_common.h b/src/northbridge/intel/sandybridge/raminit_common.h index a8644ae..9989bc2 100644 --- a/src/northbridge/intel/sandybridge/raminit_common.h +++ b/src/northbridge/intel/sandybridge/raminit_common.h @@ -98,6 +98,508 @@ } addr_update; };
+#define ZQCS_SEQUENCE(gap, post, slotrank, wrap) \ + { \ + /* DRAM command ZQCS */ \ + [0] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_ZQCS, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 1, \ + .cmd_delay_gap = gap, \ + .post_ssq_wait = post, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .addr_wrap = wrap, \ + }, \ + }, \ + } + +#define PREA_SEQUENCE(wrap) \ + { \ + /* DRAM command PREA */ \ + [0] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_PRE, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 1, \ + .cmd_delay_gap = 3, \ + .post_ssq_wait = ctrl->tRP, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 1024, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .addr_wrap = wrap, \ + }, \ + }, \ + } + +#define READ_MPR_SEQUENCE(loops, gap, loops2, post) \ + { \ + /* \ + * DRAM command MRS \ + * \ + * Write MR3 MPR enable. In this mode only RD and RDA \ + * are allowed, and all reads return a predefined pattern. \ + */ \ + [0] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_MRS, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 1, \ + .cmd_delay_gap = 3, \ + .post_ssq_wait = ctrl->tMOD, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 4, \ + .rowbits = 6, \ + .bank = 3, \ + .rank = slotrank, \ + }, \ + }, \ + /* DRAM command RD */ \ + [1] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_RD, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = loops, \ + .cmd_delay_gap = gap, \ + .post_ssq_wait = 4, \ + .data_direction = SSQ_RD, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 0, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + }, \ + /* DRAM command RD */ \ + [2] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_RD, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = loops2, \ + .cmd_delay_gap = 4, \ + .post_ssq_wait = ctrl->CAS + post, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + }, \ + /* \ + * DRAM command MRS \ + * \ + * Write MR3 MPR disable. \ + */ \ + [3] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_MRS, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 1, \ + .cmd_delay_gap = 3, \ + .post_ssq_wait = ctrl->tMOD, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 6, \ + .bank = 3, \ + .rank = slotrank, \ + }, \ + }, \ + } + +#define COMMAND_TRAINING_SEQUENCE(ctr) \ + { \ + [0] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_ACT, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 8, \ + .cmd_delay_gap = MAX(ctrl->tRRD, (ctrl->tFAW >> 2) + 1), \ + .post_ssq_wait = ctrl->tRCD, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = ctr, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_bank = 1, \ + .addr_wrap = 18, \ + }, \ + }, \ + [1] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_WR, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 32, \ + .cmd_delay_gap = 4, \ + .post_ssq_wait = ctrl->CWL + ctrl->tWTR + 8, \ + .data_direction = SSQ_WR, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 0, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_addr_8 = 1, \ + .addr_wrap = 18, \ + .lfsr_upd = 3, \ + .lfsr_xors = 2, \ + }, \ + }, \ + [2] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_RD, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 32, \ + .cmd_delay_gap = 4, \ + .post_ssq_wait = MAX(ctrl->tRTP, 8), \ + .data_direction = SSQ_RD, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 0, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_addr_8 = 1, \ + .addr_wrap = 18, \ + .lfsr_upd = 3, \ + .lfsr_xors = 2, \ + }, \ + }, \ + [3] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_PRE, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 1, \ + .cmd_delay_gap = 4, \ + .post_ssq_wait = 15, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 1024, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .addr_wrap = 18, \ + }, \ + }, \ + } + +#define WRITE_DATA_SEQUENCE \ + { \ + [0] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_ACT, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 4, \ + .cmd_delay_gap = MAX(ctrl->tRRD, (ctrl->tFAW >> 2) + 1), \ + .post_ssq_wait = ctrl->tRCD, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_bank = 0, \ + .addr_wrap = 18, \ + }, \ + }, \ + [1] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_WR, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 32, \ + .cmd_delay_gap = 20, \ + .post_ssq_wait = ctrl->CWL + ctrl->tWTR + 8, \ + .data_direction = SSQ_WR, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 0, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_addr_8 = 1, \ + .addr_wrap = 18, \ + }, \ + }, \ + [2] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_RD, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 32, \ + .cmd_delay_gap = 20, \ + .post_ssq_wait = MAX(ctrl->tRTP, 8), \ + .data_direction = SSQ_RD, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 0, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_addr_8 = 1, \ + .addr_wrap = 18, \ + }, \ + }, \ + [3] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_PRE, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 1, \ + .cmd_delay_gap = 3, \ + .post_ssq_wait = ctrl->tRP, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 1024, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + }, \ + } + +#define READ_WRITE_SEQUENCE_ALT_2 \ + { \ + [0] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_ACT, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 4, \ + .cmd_delay_gap = MAX((ctrl->tFAW >> 2) + 1, ctrl->tRRD), \ + .post_ssq_wait = ctrl->tRCD, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_bank = 1, \ + .addr_wrap = 18, \ + }, \ + }, \ + [1] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_WR, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 480, \ + .cmd_delay_gap = 4, \ + .post_ssq_wait = ctrl->tWTR + ctrl->CWL + 8, \ + .data_direction = SSQ_WR, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 0, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_addr_8 = 1, \ + .addr_wrap = 18, \ + }, \ + }, \ + [2] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_RD, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 480, \ + .cmd_delay_gap = 4, \ + .post_ssq_wait = MAX(ctrl->tRTP, 8), \ + .data_direction = SSQ_RD, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 0, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_addr_8 = 1, \ + .addr_wrap = 18, \ + }, \ + }, \ + [3] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_PRE, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 1, \ + .cmd_delay_gap = 4, \ + .post_ssq_wait = ctrl->tRP, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 1024, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + }, \ + } + +#define MEMORY_TEST_SEQUENCE \ + { \ + [0] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_ACT, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 4, \ + .cmd_delay_gap = 8, \ + .post_ssq_wait = 40, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_bank = 1, \ + .addr_wrap = 18, \ + }, \ + }, \ + [1] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_WR, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 100, \ + .cmd_delay_gap = 4, \ + .post_ssq_wait = 40, \ + .data_direction = SSQ_WR, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 0, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_addr_8 = 1, \ + .addr_wrap = 18, \ + }, \ + }, \ + [2] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_RD, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 100, \ + .cmd_delay_gap = 4, \ + .post_ssq_wait = 40, \ + .data_direction = SSQ_RD, \ + }, \ + .sp_cmd_addr = { \ + .address = 0, \ + .rowbits = 0, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .inc_addr_8 = 1, \ + .addr_wrap = 18, \ + }, \ + }, \ + [3] = { \ + .sp_cmd_ctrl = { \ + .command = IOSAV_PRE, \ + .ranksel_ap = 1, \ + }, \ + .subseq_ctrl = { \ + .cmd_executions = 1, \ + .cmd_delay_gap = 3, \ + .post_ssq_wait = 40, \ + .data_direction = SSQ_NA, \ + }, \ + .sp_cmd_addr = { \ + .address = 1024, \ + .rowbits = 6, \ + .bank = 0, \ + .rank = slotrank, \ + }, \ + .addr_update = { \ + .addr_wrap = 18, \ + }, \ + }, \ + } + void iosav_write_sequence(const int ch, const struct iosav_ssq *seq, const unsigned int length); void iosav_run_queue(const int ch, const u8 loops, const u8 as_timer); void iosav_run_once(const int ch);