Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: BSD-3-Clause |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright Altera Corporation (C) 2012-2015 |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 7 | #include <log.h> |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 8 | #include <asm/io.h> |
| 9 | #include <asm/arch/sdram.h> |
Marek Vasut | 04372fb | 2015-07-18 02:46:56 +0200 | [diff] [blame] | 10 | #include <errno.h> |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 11 | #include <hang.h> |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 12 | #include "sequencer.h" |
Marek Vasut | 9c76df5 | 2015-08-02 16:55:45 +0200 | [diff] [blame] | 13 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 14 | static const struct socfpga_sdr_rw_load_manager *sdr_rw_load_mgr_regs = |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 15 | (struct socfpga_sdr_rw_load_manager *) |
| 16 | (SDR_PHYGRP_RWMGRGRP_ADDRESS | 0x800); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 17 | static const struct socfpga_sdr_rw_load_jump_manager *sdr_rw_load_jump_mgr_regs |
| 18 | = (struct socfpga_sdr_rw_load_jump_manager *) |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 19 | (SDR_PHYGRP_RWMGRGRP_ADDRESS | 0xC00); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 20 | static const struct socfpga_sdr_reg_file *sdr_reg_file = |
Marek Vasut | a1c654a | 2015-07-12 18:31:05 +0200 | [diff] [blame] | 21 | (struct socfpga_sdr_reg_file *)SDR_PHYGRP_REGFILEGRP_ADDRESS; |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 22 | static const struct socfpga_sdr_scc_mgr *sdr_scc_mgr = |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 23 | (struct socfpga_sdr_scc_mgr *) |
| 24 | (SDR_PHYGRP_SCCGRP_ADDRESS | 0xe00); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 25 | static const struct socfpga_phy_mgr_cmd *phy_mgr_cmd = |
Marek Vasut | 1bc6f14 | 2015-07-12 18:54:37 +0200 | [diff] [blame] | 26 | (struct socfpga_phy_mgr_cmd *)SDR_PHYGRP_PHYMGRGRP_ADDRESS; |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 27 | static const struct socfpga_phy_mgr_cfg *phy_mgr_cfg = |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 28 | (struct socfpga_phy_mgr_cfg *) |
| 29 | (SDR_PHYGRP_PHYMGRGRP_ADDRESS | 0x40); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 30 | static const struct socfpga_data_mgr *data_mgr = |
Marek Vasut | c4815f7 | 2015-07-12 19:03:33 +0200 | [diff] [blame] | 31 | (struct socfpga_data_mgr *)SDR_PHYGRP_DATAMGRGRP_ADDRESS; |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 32 | static const struct socfpga_sdr_ctrl *sdr_ctrl = |
Marek Vasut | 6cb9f16 | 2015-07-12 20:49:39 +0200 | [diff] [blame] | 33 | (struct socfpga_sdr_ctrl *)SDR_CTRLGRP_ADDRESS; |
| 34 | |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 35 | #define DELTA_D 1 |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * In order to reduce ROM size, most of the selectable calibration steps are |
| 39 | * decided at compile time based on the user's calibration mode selection, |
| 40 | * as captured by the STATIC_CALIB_STEPS selection below. |
| 41 | * |
| 42 | * However, to support simulation-time selection of fast simulation mode, where |
| 43 | * we skip everything except the bare minimum, we need a few of the steps to |
| 44 | * be dynamic. In those cases, we either use the DYNAMIC_CALIB_STEPS for the |
| 45 | * check, which is based on the rtl-supplied value, or we dynamically compute |
| 46 | * the value to use based on the dynamically-chosen calibration mode |
| 47 | */ |
| 48 | |
| 49 | #define DLEVEL 0 |
| 50 | #define STATIC_IN_RTL_SIM 0 |
| 51 | #define STATIC_SKIP_DELAY_LOOPS 0 |
| 52 | |
| 53 | #define STATIC_CALIB_STEPS (STATIC_IN_RTL_SIM | CALIB_SKIP_FULL_TEST | \ |
| 54 | STATIC_SKIP_DELAY_LOOPS) |
| 55 | |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 56 | #define SKIP_DELAY_LOOP_VALUE_OR_ZERO(non_skip_value) \ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 57 | ((non_skip_value) & seq->skip_delay_mask) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 58 | |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 59 | bool dram_is_ddr(const u8 ddr) |
| 60 | { |
| 61 | const struct socfpga_sdram_config *cfg = socfpga_get_sdram_config(); |
| 62 | const u8 type = (cfg->ctrl_cfg >> SDR_CTRLGRP_CTRLCFG_MEMTYPE_LSB) & |
| 63 | SDR_CTRLGRP_CTRLCFG_MEMTYPE_MASK; |
| 64 | |
| 65 | if (ddr == 2 && type == 1) /* DDR2 */ |
| 66 | return true; |
| 67 | |
| 68 | if (ddr == 3 && type == 2) /* DDR3 */ |
| 69 | return true; |
| 70 | |
| 71 | return false; |
| 72 | } |
| 73 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 74 | static void set_failing_group_stage(struct socfpga_sdrseq *seq, |
| 75 | u32 group, u32 stage, u32 substage) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 76 | { |
| 77 | /* |
| 78 | * Only set the global stage if there was not been any other |
| 79 | * failing group |
| 80 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 81 | if (seq->gbl.error_stage == CAL_STAGE_NIL) { |
| 82 | seq->gbl.error_substage = substage; |
| 83 | seq->gbl.error_stage = stage; |
| 84 | seq->gbl.error_group = group; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 85 | } |
| 86 | } |
| 87 | |
Marek Vasut | 2c0d2d9 | 2015-07-12 21:10:24 +0200 | [diff] [blame] | 88 | static void reg_file_set_group(u16 set_group) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 89 | { |
Marek Vasut | 2c0d2d9 | 2015-07-12 21:10:24 +0200 | [diff] [blame] | 90 | clrsetbits_le32(&sdr_reg_file->cur_stage, 0xffff0000, set_group << 16); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 91 | } |
| 92 | |
Marek Vasut | 2c0d2d9 | 2015-07-12 21:10:24 +0200 | [diff] [blame] | 93 | static void reg_file_set_stage(u8 set_stage) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 94 | { |
Marek Vasut | 2c0d2d9 | 2015-07-12 21:10:24 +0200 | [diff] [blame] | 95 | clrsetbits_le32(&sdr_reg_file->cur_stage, 0xffff, set_stage & 0xff); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 96 | } |
| 97 | |
Marek Vasut | 2c0d2d9 | 2015-07-12 21:10:24 +0200 | [diff] [blame] | 98 | static void reg_file_set_sub_stage(u8 set_sub_stage) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 99 | { |
Marek Vasut | 2c0d2d9 | 2015-07-12 21:10:24 +0200 | [diff] [blame] | 100 | set_sub_stage &= 0xff; |
| 101 | clrsetbits_le32(&sdr_reg_file->cur_stage, 0xff00, set_sub_stage << 8); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 102 | } |
| 103 | |
Marek Vasut | 7c89c2d | 2015-07-17 01:36:32 +0200 | [diff] [blame] | 104 | /** |
| 105 | * phy_mgr_initialize() - Initialize PHY Manager |
| 106 | * |
| 107 | * Initialize PHY Manager. |
| 108 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 109 | static void phy_mgr_initialize(struct socfpga_sdrseq *seq) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 110 | { |
Marek Vasut | 7c89c2d | 2015-07-17 01:36:32 +0200 | [diff] [blame] | 111 | u32 ratio; |
| 112 | |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 113 | debug("%s:%d\n", __func__, __LINE__); |
Marek Vasut | 7c89c2d | 2015-07-17 01:36:32 +0200 | [diff] [blame] | 114 | /* Calibration has control over path to memory */ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 115 | /* |
| 116 | * In Hard PHY this is a 2-bit control: |
| 117 | * 0: AFI Mux Select |
| 118 | * 1: DDIO Mux Select |
| 119 | */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 120 | writel(0x3, &phy_mgr_cfg->mux_sel); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 121 | |
| 122 | /* USER memory clock is not stable we begin initialization */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 123 | writel(0, &phy_mgr_cfg->reset_mem_stbl); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 124 | |
| 125 | /* USER calibration status all set to zero */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 126 | writel(0, &phy_mgr_cfg->cal_status); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 127 | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 128 | writel(0, &phy_mgr_cfg->cal_debug_info); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 129 | |
Marek Vasut | 7c89c2d | 2015-07-17 01:36:32 +0200 | [diff] [blame] | 130 | /* Init params only if we do NOT skip calibration. */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 131 | if ((seq->dyn_calib_steps & CALIB_SKIP_ALL) == CALIB_SKIP_ALL) |
Marek Vasut | 7c89c2d | 2015-07-17 01:36:32 +0200 | [diff] [blame] | 132 | return; |
| 133 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 134 | ratio = seq->rwcfg->mem_dq_per_read_dqs / |
| 135 | seq->rwcfg->mem_virtual_groups_per_read_dqs; |
| 136 | seq->param.read_correct_mask_vg = (1 << ratio) - 1; |
| 137 | seq->param.write_correct_mask_vg = (1 << ratio) - 1; |
| 138 | seq->param.read_correct_mask = (1 << seq->rwcfg->mem_dq_per_read_dqs) |
| 139 | - 1; |
| 140 | seq->param.write_correct_mask = (1 << seq->rwcfg->mem_dq_per_write_dqs) |
| 141 | - 1; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 142 | } |
| 143 | |
Marek Vasut | 080bf64 | 2015-07-20 08:15:57 +0200 | [diff] [blame] | 144 | /** |
| 145 | * set_rank_and_odt_mask() - Set Rank and ODT mask |
| 146 | * @rank: Rank mask |
| 147 | * @odt_mode: ODT mode, OFF or READ_WRITE |
| 148 | * |
| 149 | * Set Rank and ODT mask (On-Die Termination). |
| 150 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 151 | static void set_rank_and_odt_mask(struct socfpga_sdrseq *seq, |
| 152 | const u32 rank, const u32 odt_mode) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 153 | { |
Marek Vasut | b2dfd10 | 2015-07-20 08:03:11 +0200 | [diff] [blame] | 154 | u32 odt_mask_0 = 0; |
| 155 | u32 odt_mask_1 = 0; |
| 156 | u32 cs_and_odt_mask; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 157 | |
Marek Vasut | b2dfd10 | 2015-07-20 08:03:11 +0200 | [diff] [blame] | 158 | if (odt_mode == RW_MGR_ODT_MODE_OFF) { |
| 159 | odt_mask_0 = 0x0; |
| 160 | odt_mask_1 = 0x0; |
| 161 | } else { /* RW_MGR_ODT_MODE_READ_WRITE */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 162 | switch (seq->rwcfg->mem_number_of_ranks) { |
Marek Vasut | 287cdf6 | 2015-07-20 08:09:05 +0200 | [diff] [blame] | 163 | case 1: /* 1 Rank */ |
| 164 | /* Read: ODT = 0 ; Write: ODT = 1 */ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 165 | odt_mask_0 = 0x0; |
| 166 | odt_mask_1 = 0x1; |
Marek Vasut | 287cdf6 | 2015-07-20 08:09:05 +0200 | [diff] [blame] | 167 | break; |
| 168 | case 2: /* 2 Ranks */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 169 | if (seq->rwcfg->mem_number_of_cs_per_dimm == 1) { |
Marek Vasut | 080bf64 | 2015-07-20 08:15:57 +0200 | [diff] [blame] | 170 | /* |
| 171 | * - Dual-Slot , Single-Rank (1 CS per DIMM) |
| 172 | * OR |
| 173 | * - RDIMM, 4 total CS (2 CS per DIMM, 2 DIMM) |
| 174 | * |
| 175 | * Since MEM_NUMBER_OF_RANKS is 2, they |
| 176 | * are both single rank with 2 CS each |
| 177 | * (special for RDIMM). |
| 178 | * |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 179 | * Read: Turn on ODT on the opposite rank |
| 180 | * Write: Turn on ODT on all ranks |
| 181 | */ |
| 182 | odt_mask_0 = 0x3 & ~(1 << rank); |
| 183 | odt_mask_1 = 0x3; |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 184 | if (dram_is_ddr(2)) |
| 185 | odt_mask_1 &= ~(1 << rank); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 186 | } else { |
| 187 | /* |
Marek Vasut | 080bf64 | 2015-07-20 08:15:57 +0200 | [diff] [blame] | 188 | * - Single-Slot , Dual-Rank (2 CS per DIMM) |
| 189 | * |
| 190 | * Read: Turn on ODT off on all ranks |
| 191 | * Write: Turn on ODT on active rank |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 192 | */ |
| 193 | odt_mask_0 = 0x0; |
| 194 | odt_mask_1 = 0x3 & (1 << rank); |
| 195 | } |
Marek Vasut | 287cdf6 | 2015-07-20 08:09:05 +0200 | [diff] [blame] | 196 | break; |
| 197 | case 4: /* 4 Ranks */ |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 198 | /* |
| 199 | * DDR3 Read, DDR2 Read/Write: |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 200 | * ----------+-----------------------+ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 201 | * | ODT | |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 202 | * +-----------------------+ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 203 | * Rank | 3 | 2 | 1 | 0 | |
| 204 | * ----------+-----+-----+-----+-----+ |
| 205 | * 0 | 0 | 1 | 0 | 0 | |
| 206 | * 1 | 1 | 0 | 0 | 0 | |
| 207 | * 2 | 0 | 0 | 0 | 1 | |
| 208 | * 3 | 0 | 0 | 1 | 0 | |
| 209 | * ----------+-----+-----+-----+-----+ |
| 210 | * |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 211 | * DDR3 Write: |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 212 | * ----------+-----------------------+ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 213 | * | ODT | |
| 214 | * Write To +-----------------------+ |
| 215 | * Rank | 3 | 2 | 1 | 0 | |
| 216 | * ----------+-----+-----+-----+-----+ |
| 217 | * 0 | 0 | 1 | 0 | 1 | |
| 218 | * 1 | 1 | 0 | 1 | 0 | |
| 219 | * 2 | 0 | 1 | 0 | 1 | |
| 220 | * 3 | 1 | 0 | 1 | 0 | |
| 221 | * ----------+-----+-----+-----+-----+ |
| 222 | */ |
| 223 | switch (rank) { |
| 224 | case 0: |
| 225 | odt_mask_0 = 0x4; |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 226 | if (dram_is_ddr(2)) |
| 227 | odt_mask_1 = 0x4; |
| 228 | else if (dram_is_ddr(3)) |
| 229 | odt_mask_1 = 0x5; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 230 | break; |
| 231 | case 1: |
| 232 | odt_mask_0 = 0x8; |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 233 | if (dram_is_ddr(2)) |
| 234 | odt_mask_1 = 0x8; |
| 235 | else if (dram_is_ddr(3)) |
| 236 | odt_mask_1 = 0xA; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 237 | break; |
| 238 | case 2: |
| 239 | odt_mask_0 = 0x1; |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 240 | if (dram_is_ddr(2)) |
| 241 | odt_mask_1 = 0x1; |
| 242 | else if (dram_is_ddr(3)) |
| 243 | odt_mask_1 = 0x5; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 244 | break; |
| 245 | case 3: |
| 246 | odt_mask_0 = 0x2; |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 247 | if (dram_is_ddr(2)) |
| 248 | odt_mask_1 = 0x2; |
| 249 | else if (dram_is_ddr(3)) |
| 250 | odt_mask_1 = 0xA; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 251 | break; |
| 252 | } |
Marek Vasut | 287cdf6 | 2015-07-20 08:09:05 +0200 | [diff] [blame] | 253 | break; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 254 | } |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 255 | } |
| 256 | |
Marek Vasut | b2dfd10 | 2015-07-20 08:03:11 +0200 | [diff] [blame] | 257 | cs_and_odt_mask = (0xFF & ~(1 << rank)) | |
| 258 | ((0xFF & odt_mask_0) << 8) | |
| 259 | ((0xFF & odt_mask_1) << 16); |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 260 | writel(cs_and_odt_mask, SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 261 | RW_MGR_SET_CS_AND_ODT_MASK_OFFSET); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 262 | } |
| 263 | |
Marek Vasut | c76976d | 2015-07-12 22:28:33 +0200 | [diff] [blame] | 264 | /** |
| 265 | * scc_mgr_set() - Set SCC Manager register |
| 266 | * @off: Base offset in SCC Manager space |
| 267 | * @grp: Read/Write group |
| 268 | * @val: Value to be set |
| 269 | * |
| 270 | * This function sets the SCC Manager (Scan Chain Control Manager) register. |
| 271 | */ |
| 272 | static void scc_mgr_set(u32 off, u32 grp, u32 val) |
| 273 | { |
| 274 | writel(val, SDR_PHYGRP_SCCGRP_ADDRESS | off | (grp << 2)); |
| 275 | } |
| 276 | |
Marek Vasut | e893f4d | 2015-07-20 07:16:42 +0200 | [diff] [blame] | 277 | /** |
| 278 | * scc_mgr_initialize() - Initialize SCC Manager registers |
| 279 | * |
| 280 | * Initialize SCC Manager registers. |
| 281 | */ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 282 | static void scc_mgr_initialize(void) |
| 283 | { |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 284 | /* |
Marek Vasut | e893f4d | 2015-07-20 07:16:42 +0200 | [diff] [blame] | 285 | * Clear register file for HPS. 16 (2^4) is the size of the |
| 286 | * full register file in the scc mgr: |
| 287 | * RFILE_DEPTH = 1 + log2(MEM_DQ_PER_DQS + 1 + MEM_DM_PER_DQS + |
| 288 | * MEM_IF_READ_DQS_WIDTH - 1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 289 | */ |
Marek Vasut | c76976d | 2015-07-12 22:28:33 +0200 | [diff] [blame] | 290 | int i; |
Marek Vasut | e893f4d | 2015-07-20 07:16:42 +0200 | [diff] [blame] | 291 | |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 292 | for (i = 0; i < 16; i++) { |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 293 | debug_cond(DLEVEL >= 1, "%s:%d: Clearing SCC RFILE index %u\n", |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 294 | __func__, __LINE__, i); |
Marek Vasut | 8e9e62c | 2016-04-04 17:28:16 +0200 | [diff] [blame] | 295 | scc_mgr_set(SCC_MGR_HHP_RFILE_OFFSET, i, 0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 299 | static void scc_mgr_set_dqdqs_output_phase(u32 write_group, u32 phase) |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 300 | { |
Marek Vasut | c76976d | 2015-07-12 22:28:33 +0200 | [diff] [blame] | 301 | scc_mgr_set(SCC_MGR_DQDQS_OUT_PHASE_OFFSET, write_group, phase); |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 302 | } |
| 303 | |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 304 | static void scc_mgr_set_dqs_bus_in_delay(u32 read_group, u32 delay) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 305 | { |
Marek Vasut | c76976d | 2015-07-12 22:28:33 +0200 | [diff] [blame] | 306 | scc_mgr_set(SCC_MGR_DQS_IN_DELAY_OFFSET, read_group, delay); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 307 | } |
| 308 | |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 309 | static void scc_mgr_set_dqs_en_phase(u32 read_group, u32 phase) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 310 | { |
Marek Vasut | c76976d | 2015-07-12 22:28:33 +0200 | [diff] [blame] | 311 | scc_mgr_set(SCC_MGR_DQS_EN_PHASE_OFFSET, read_group, phase); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 312 | } |
| 313 | |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 314 | static void scc_mgr_set_dqs_en_delay(u32 read_group, u32 delay) |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 315 | { |
Marek Vasut | c76976d | 2015-07-12 22:28:33 +0200 | [diff] [blame] | 316 | scc_mgr_set(SCC_MGR_DQS_EN_DELAY_OFFSET, read_group, delay); |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 317 | } |
| 318 | |
Marek Vasut | 70ed80a | 2016-04-04 21:16:18 +0200 | [diff] [blame] | 319 | static void scc_mgr_set_dq_in_delay(u32 dq_in_group, u32 delay) |
| 320 | { |
| 321 | scc_mgr_set(SCC_MGR_IO_IN_DELAY_OFFSET, dq_in_group, delay); |
| 322 | } |
| 323 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 324 | static void scc_mgr_set_dqs_io_in_delay(struct socfpga_sdrseq *seq, |
| 325 | u32 delay) |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 326 | { |
Marek Vasut | 70ed80a | 2016-04-04 21:16:18 +0200 | [diff] [blame] | 327 | scc_mgr_set(SCC_MGR_IO_IN_DELAY_OFFSET, |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 328 | seq->rwcfg->mem_dq_per_write_dqs, delay); |
| 329 | } |
| 330 | |
| 331 | static void scc_mgr_set_dm_in_delay(struct socfpga_sdrseq *seq, u32 dm, |
| 332 | u32 delay) |
| 333 | { |
| 334 | scc_mgr_set(SCC_MGR_IO_IN_DELAY_OFFSET, |
| 335 | seq->rwcfg->mem_dq_per_write_dqs + 1 + dm, |
Marek Vasut | 70ed80a | 2016-04-04 21:16:18 +0200 | [diff] [blame] | 336 | delay); |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 337 | } |
| 338 | |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 339 | static void scc_mgr_set_dq_out1_delay(u32 dq_in_group, u32 delay) |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 340 | { |
Marek Vasut | c76976d | 2015-07-12 22:28:33 +0200 | [diff] [blame] | 341 | scc_mgr_set(SCC_MGR_IO_OUT1_DELAY_OFFSET, dq_in_group, delay); |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 342 | } |
| 343 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 344 | static void scc_mgr_set_dqs_out1_delay(struct socfpga_sdrseq *seq, |
| 345 | u32 delay) |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 346 | { |
Marek Vasut | c76976d | 2015-07-12 22:28:33 +0200 | [diff] [blame] | 347 | scc_mgr_set(SCC_MGR_IO_OUT1_DELAY_OFFSET, |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 348 | seq->rwcfg->mem_dq_per_write_dqs, delay); |
| 349 | } |
| 350 | |
| 351 | static void scc_mgr_set_dm_out1_delay(struct socfpga_sdrseq *seq, u32 dm, |
| 352 | u32 delay) |
| 353 | { |
| 354 | scc_mgr_set(SCC_MGR_IO_OUT1_DELAY_OFFSET, |
| 355 | seq->rwcfg->mem_dq_per_write_dqs + 1 + dm, |
Marek Vasut | c76976d | 2015-07-12 22:28:33 +0200 | [diff] [blame] | 356 | delay); |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | /* load up dqs config settings */ |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 360 | static void scc_mgr_load_dqs(u32 dqs) |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 361 | { |
| 362 | writel(dqs, &sdr_scc_mgr->dqs_ena); |
| 363 | } |
| 364 | |
| 365 | /* load up dqs io config settings */ |
| 366 | static void scc_mgr_load_dqs_io(void) |
| 367 | { |
| 368 | writel(0, &sdr_scc_mgr->dqs_io_ena); |
| 369 | } |
| 370 | |
| 371 | /* load up dq config settings */ |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 372 | static void scc_mgr_load_dq(u32 dq_in_group) |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 373 | { |
| 374 | writel(dq_in_group, &sdr_scc_mgr->dq_ena); |
| 375 | } |
| 376 | |
| 377 | /* load up dm config settings */ |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 378 | static void scc_mgr_load_dm(u32 dm) |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 379 | { |
| 380 | writel(dm, &sdr_scc_mgr->dm_ena); |
| 381 | } |
| 382 | |
Marek Vasut | 0b69b80 | 2015-07-12 23:25:21 +0200 | [diff] [blame] | 383 | /** |
| 384 | * scc_mgr_set_all_ranks() - Set SCC Manager register for all ranks |
| 385 | * @off: Base offset in SCC Manager space |
| 386 | * @grp: Read/Write group |
| 387 | * @val: Value to be set |
| 388 | * @update: If non-zero, trigger SCC Manager update for all ranks |
| 389 | * |
| 390 | * This function sets the SCC Manager (Scan Chain Control Manager) register |
| 391 | * and optionally triggers the SCC update for all ranks. |
| 392 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 393 | static void scc_mgr_set_all_ranks(struct socfpga_sdrseq *seq, |
| 394 | const u32 off, const u32 grp, const u32 val, |
Marek Vasut | 0b69b80 | 2015-07-12 23:25:21 +0200 | [diff] [blame] | 395 | const int update) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 396 | { |
Marek Vasut | 0b69b80 | 2015-07-12 23:25:21 +0200 | [diff] [blame] | 397 | u32 r; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 398 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 399 | for (r = 0; r < seq->rwcfg->mem_number_of_ranks; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 400 | r += NUM_RANKS_PER_SHADOW_REG) { |
Marek Vasut | 0b69b80 | 2015-07-12 23:25:21 +0200 | [diff] [blame] | 401 | scc_mgr_set(off, grp, val); |
Marek Vasut | 162d60e | 2015-07-12 23:14:33 +0200 | [diff] [blame] | 402 | |
Marek Vasut | 0b69b80 | 2015-07-12 23:25:21 +0200 | [diff] [blame] | 403 | if (update || (r == 0)) { |
| 404 | writel(grp, &sdr_scc_mgr->dqs_ena); |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 405 | writel(0, &sdr_scc_mgr->update); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 410 | static void scc_mgr_set_dqs_en_phase_all_ranks(struct socfpga_sdrseq *seq, |
| 411 | u32 read_group, u32 phase) |
Marek Vasut | 0b69b80 | 2015-07-12 23:25:21 +0200 | [diff] [blame] | 412 | { |
| 413 | /* |
| 414 | * USER although the h/w doesn't support different phases per |
| 415 | * shadow register, for simplicity our scc manager modeling |
| 416 | * keeps different phase settings per shadow reg, and it's |
| 417 | * important for us to keep them in sync to match h/w. |
| 418 | * for efficiency, the scan chain update should occur only |
| 419 | * once to sr0. |
| 420 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 421 | scc_mgr_set_all_ranks(seq, SCC_MGR_DQS_EN_PHASE_OFFSET, |
Marek Vasut | 0b69b80 | 2015-07-12 23:25:21 +0200 | [diff] [blame] | 422 | read_group, phase, 0); |
| 423 | } |
| 424 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 425 | static void scc_mgr_set_dqdqs_output_phase_all_ranks(struct socfpga_sdrseq *seq, |
| 426 | u32 write_group, u32 phase) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 427 | { |
Marek Vasut | 0b69b80 | 2015-07-12 23:25:21 +0200 | [diff] [blame] | 428 | /* |
| 429 | * USER although the h/w doesn't support different phases per |
| 430 | * shadow register, for simplicity our scc manager modeling |
| 431 | * keeps different phase settings per shadow reg, and it's |
| 432 | * important for us to keep them in sync to match h/w. |
| 433 | * for efficiency, the scan chain update should occur only |
| 434 | * once to sr0. |
| 435 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 436 | scc_mgr_set_all_ranks(seq, SCC_MGR_DQDQS_OUT_PHASE_OFFSET, |
Marek Vasut | 0b69b80 | 2015-07-12 23:25:21 +0200 | [diff] [blame] | 437 | write_group, phase, 0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 438 | } |
| 439 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 440 | static void scc_mgr_set_dqs_en_delay_all_ranks(struct socfpga_sdrseq *seq, |
| 441 | u32 read_group, u32 delay) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 442 | { |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 443 | /* |
| 444 | * In shadow register mode, the T11 settings are stored in |
| 445 | * registers in the core, which are updated by the DQS_ENA |
| 446 | * signals. Not issuing the SCC_MGR_UPD command allows us to |
| 447 | * save lots of rank switching overhead, by calling |
| 448 | * select_shadow_regs_for_update with update_scan_chains |
| 449 | * set to 0. |
| 450 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 451 | scc_mgr_set_all_ranks(seq, SCC_MGR_DQS_EN_DELAY_OFFSET, |
Marek Vasut | 0b69b80 | 2015-07-12 23:25:21 +0200 | [diff] [blame] | 452 | read_group, delay, 1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 453 | } |
| 454 | |
Marek Vasut | 5be355c | 2015-07-12 23:39:06 +0200 | [diff] [blame] | 455 | /** |
| 456 | * scc_mgr_set_oct_out1_delay() - Set OCT output delay |
| 457 | * @write_group: Write group |
| 458 | * @delay: Delay value |
| 459 | * |
| 460 | * This function sets the OCT output delay in SCC manager. |
| 461 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 462 | static void scc_mgr_set_oct_out1_delay(struct socfpga_sdrseq *seq, |
| 463 | const u32 write_group, const u32 delay) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 464 | { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 465 | const int ratio = seq->rwcfg->mem_if_read_dqs_width / |
| 466 | seq->rwcfg->mem_if_write_dqs_width; |
Marek Vasut | 5be355c | 2015-07-12 23:39:06 +0200 | [diff] [blame] | 467 | const int base = write_group * ratio; |
| 468 | int i; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 469 | /* |
| 470 | * Load the setting in the SCC manager |
| 471 | * Although OCT affects only write data, the OCT delay is controlled |
| 472 | * by the DQS logic block which is instantiated once per read group. |
| 473 | * For protocols where a write group consists of multiple read groups, |
| 474 | * the setting must be set multiple times. |
| 475 | */ |
Marek Vasut | 5be355c | 2015-07-12 23:39:06 +0200 | [diff] [blame] | 476 | for (i = 0; i < ratio; i++) |
| 477 | scc_mgr_set(SCC_MGR_OCT_OUT1_DELAY_OFFSET, base + i, delay); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 478 | } |
| 479 | |
Marek Vasut | 37a37ca | 2015-07-19 01:32:55 +0200 | [diff] [blame] | 480 | /** |
| 481 | * scc_mgr_set_hhp_extras() - Set HHP extras. |
| 482 | * |
| 483 | * Load the fixed setting in the SCC manager HHP extras. |
| 484 | */ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 485 | static void scc_mgr_set_hhp_extras(void) |
| 486 | { |
| 487 | /* |
| 488 | * Load the fixed setting in the SCC manager |
Marek Vasut | 37a37ca | 2015-07-19 01:32:55 +0200 | [diff] [blame] | 489 | * bits: 0:0 = 1'b1 - DQS bypass |
| 490 | * bits: 1:1 = 1'b1 - DQ bypass |
| 491 | * bits: 4:2 = 3'b001 - rfifo_mode |
| 492 | * bits: 6:5 = 2'b01 - rfifo clock_select |
| 493 | * bits: 7:7 = 1'b0 - separate gating from ungating setting |
| 494 | * bits: 8:8 = 1'b0 - separate OE from Output delay setting |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 495 | */ |
Marek Vasut | 37a37ca | 2015-07-19 01:32:55 +0200 | [diff] [blame] | 496 | const u32 value = (0 << 8) | (0 << 7) | (1 << 5) | |
| 497 | (1 << 2) | (1 << 1) | (1 << 0); |
| 498 | const u32 addr = SDR_PHYGRP_SCCGRP_ADDRESS | |
| 499 | SCC_MGR_HHP_GLOBALS_OFFSET | |
| 500 | SCC_MGR_HHP_EXTRAS_OFFSET; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 501 | |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 502 | debug_cond(DLEVEL >= 1, "%s:%d Setting HHP Extras\n", |
Marek Vasut | 37a37ca | 2015-07-19 01:32:55 +0200 | [diff] [blame] | 503 | __func__, __LINE__); |
| 504 | writel(value, addr); |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 505 | debug_cond(DLEVEL >= 1, "%s:%d Done Setting HHP Extras\n", |
Marek Vasut | 37a37ca | 2015-07-19 01:32:55 +0200 | [diff] [blame] | 506 | __func__, __LINE__); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 507 | } |
| 508 | |
Marek Vasut | f42af35 | 2015-07-20 04:41:53 +0200 | [diff] [blame] | 509 | /** |
| 510 | * scc_mgr_zero_all() - Zero all DQS config |
| 511 | * |
| 512 | * Zero all DQS config. |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 513 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 514 | static void scc_mgr_zero_all(struct socfpga_sdrseq *seq) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 515 | { |
Marek Vasut | f42af35 | 2015-07-20 04:41:53 +0200 | [diff] [blame] | 516 | int i, r; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 517 | |
| 518 | /* |
| 519 | * USER Zero all DQS config settings, across all groups and all |
| 520 | * shadow registers |
| 521 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 522 | for (r = 0; r < seq->rwcfg->mem_number_of_ranks; |
Marek Vasut | f42af35 | 2015-07-20 04:41:53 +0200 | [diff] [blame] | 523 | r += NUM_RANKS_PER_SHADOW_REG) { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 524 | for (i = 0; i < seq->rwcfg->mem_if_read_dqs_width; i++) { |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 525 | /* |
| 526 | * The phases actually don't exist on a per-rank basis, |
| 527 | * but there's no harm updating them several times, so |
| 528 | * let's keep the code simple. |
| 529 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 530 | scc_mgr_set_dqs_bus_in_delay(i, |
| 531 | seq->iocfg->dqs_in_reserve |
| 532 | ); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 533 | scc_mgr_set_dqs_en_phase(i, 0); |
| 534 | scc_mgr_set_dqs_en_delay(i, 0); |
| 535 | } |
| 536 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 537 | for (i = 0; i < seq->rwcfg->mem_if_write_dqs_width; i++) { |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 538 | scc_mgr_set_dqdqs_output_phase(i, 0); |
Marek Vasut | f42af35 | 2015-07-20 04:41:53 +0200 | [diff] [blame] | 539 | /* Arria V/Cyclone V don't have out2. */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 540 | scc_mgr_set_oct_out1_delay(seq, i, |
| 541 | seq->iocfg->dqs_out_reserve); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 542 | } |
| 543 | } |
| 544 | |
Marek Vasut | f42af35 | 2015-07-20 04:41:53 +0200 | [diff] [blame] | 545 | /* Multicast to all DQS group enables. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 546 | writel(0xff, &sdr_scc_mgr->dqs_ena); |
| 547 | writel(0, &sdr_scc_mgr->update); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 548 | } |
| 549 | |
Marek Vasut | c5c5f53 | 2015-07-17 02:06:20 +0200 | [diff] [blame] | 550 | /** |
| 551 | * scc_set_bypass_mode() - Set bypass mode and trigger SCC update |
| 552 | * @write_group: Write group |
| 553 | * |
| 554 | * Set bypass mode and trigger SCC update. |
| 555 | */ |
| 556 | static void scc_set_bypass_mode(const u32 write_group) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 557 | { |
Marek Vasut | c5c5f53 | 2015-07-17 02:06:20 +0200 | [diff] [blame] | 558 | /* Multicast to all DQ enables. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 559 | writel(0xff, &sdr_scc_mgr->dq_ena); |
| 560 | writel(0xff, &sdr_scc_mgr->dm_ena); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 561 | |
Marek Vasut | c5c5f53 | 2015-07-17 02:06:20 +0200 | [diff] [blame] | 562 | /* Update current DQS IO enable. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 563 | writel(0, &sdr_scc_mgr->dqs_io_ena); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 564 | |
Marek Vasut | c5c5f53 | 2015-07-17 02:06:20 +0200 | [diff] [blame] | 565 | /* Update the DQS logic. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 566 | writel(write_group, &sdr_scc_mgr->dqs_ena); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 567 | |
Marek Vasut | c5c5f53 | 2015-07-17 02:06:20 +0200 | [diff] [blame] | 568 | /* Hit update. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 569 | writel(0, &sdr_scc_mgr->update); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 570 | } |
| 571 | |
Marek Vasut | 5e83789 | 2015-07-13 00:30:09 +0200 | [diff] [blame] | 572 | /** |
| 573 | * scc_mgr_load_dqs_for_write_group() - Load DQS settings for Write Group |
| 574 | * @write_group: Write group |
| 575 | * |
| 576 | * Load DQS settings for Write Group, do not trigger SCC update. |
| 577 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 578 | static void scc_mgr_load_dqs_for_write_group(struct socfpga_sdrseq *seq, |
| 579 | const u32 write_group) |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 580 | { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 581 | const int ratio = seq->rwcfg->mem_if_read_dqs_width / |
| 582 | seq->rwcfg->mem_if_write_dqs_width; |
Marek Vasut | 5e83789 | 2015-07-13 00:30:09 +0200 | [diff] [blame] | 583 | const int base = write_group * ratio; |
| 584 | int i; |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 585 | /* |
Marek Vasut | 5e83789 | 2015-07-13 00:30:09 +0200 | [diff] [blame] | 586 | * Load the setting in the SCC manager |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 587 | * Although OCT affects only write data, the OCT delay is controlled |
| 588 | * by the DQS logic block which is instantiated once per read group. |
| 589 | * For protocols where a write group consists of multiple read groups, |
Marek Vasut | 5e83789 | 2015-07-13 00:30:09 +0200 | [diff] [blame] | 590 | * the setting must be set multiple times. |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 591 | */ |
Marek Vasut | 5e83789 | 2015-07-13 00:30:09 +0200 | [diff] [blame] | 592 | for (i = 0; i < ratio; i++) |
| 593 | writel(base + i, &sdr_scc_mgr->dqs_ena); |
Marek Vasut | 5ff825b | 2015-07-12 22:11:55 +0200 | [diff] [blame] | 594 | } |
| 595 | |
Marek Vasut | d41ea93 | 2015-07-20 08:41:04 +0200 | [diff] [blame] | 596 | /** |
| 597 | * scc_mgr_zero_group() - Zero all configs for a group |
| 598 | * |
| 599 | * Zero DQ, DM, DQS and OCT configs for a group. |
| 600 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 601 | static void scc_mgr_zero_group(struct socfpga_sdrseq *seq, |
| 602 | const u32 write_group, const int out_only) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 603 | { |
Marek Vasut | d41ea93 | 2015-07-20 08:41:04 +0200 | [diff] [blame] | 604 | int i, r; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 605 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 606 | for (r = 0; r < seq->rwcfg->mem_number_of_ranks; |
Marek Vasut | d41ea93 | 2015-07-20 08:41:04 +0200 | [diff] [blame] | 607 | r += NUM_RANKS_PER_SHADOW_REG) { |
| 608 | /* Zero all DQ config settings. */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 609 | for (i = 0; i < seq->rwcfg->mem_dq_per_write_dqs; i++) { |
Marek Vasut | 07aee5b | 2015-07-12 22:07:33 +0200 | [diff] [blame] | 610 | scc_mgr_set_dq_out1_delay(i, 0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 611 | if (!out_only) |
Marek Vasut | 07aee5b | 2015-07-12 22:07:33 +0200 | [diff] [blame] | 612 | scc_mgr_set_dq_in_delay(i, 0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 613 | } |
| 614 | |
Marek Vasut | d41ea93 | 2015-07-20 08:41:04 +0200 | [diff] [blame] | 615 | /* Multicast to all DQ enables. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 616 | writel(0xff, &sdr_scc_mgr->dq_ena); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 617 | |
Marek Vasut | d41ea93 | 2015-07-20 08:41:04 +0200 | [diff] [blame] | 618 | /* Zero all DM config settings. */ |
Marek Vasut | 70ed80a | 2016-04-04 21:16:18 +0200 | [diff] [blame] | 619 | for (i = 0; i < RW_MGR_NUM_DM_PER_WRITE_GROUP; i++) { |
| 620 | if (!out_only) |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 621 | scc_mgr_set_dm_in_delay(seq, i, 0); |
| 622 | scc_mgr_set_dm_out1_delay(seq, i, 0); |
Marek Vasut | 70ed80a | 2016-04-04 21:16:18 +0200 | [diff] [blame] | 623 | } |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 624 | |
Marek Vasut | d41ea93 | 2015-07-20 08:41:04 +0200 | [diff] [blame] | 625 | /* Multicast to all DM enables. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 626 | writel(0xff, &sdr_scc_mgr->dm_ena); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 627 | |
Marek Vasut | d41ea93 | 2015-07-20 08:41:04 +0200 | [diff] [blame] | 628 | /* Zero all DQS IO settings. */ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 629 | if (!out_only) |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 630 | scc_mgr_set_dqs_io_in_delay(seq, 0); |
Marek Vasut | d41ea93 | 2015-07-20 08:41:04 +0200 | [diff] [blame] | 631 | |
| 632 | /* Arria V/Cyclone V don't have out2. */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 633 | scc_mgr_set_dqs_out1_delay(seq, seq->iocfg->dqs_out_reserve); |
| 634 | scc_mgr_set_oct_out1_delay(seq, write_group, |
| 635 | seq->iocfg->dqs_out_reserve); |
| 636 | scc_mgr_load_dqs_for_write_group(seq, write_group); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 637 | |
Marek Vasut | d41ea93 | 2015-07-20 08:41:04 +0200 | [diff] [blame] | 638 | /* Multicast to all DQS IO enables (only 1 in total). */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 639 | writel(0, &sdr_scc_mgr->dqs_io_ena); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 640 | |
Marek Vasut | d41ea93 | 2015-07-20 08:41:04 +0200 | [diff] [blame] | 641 | /* Hit update to zero everything. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 642 | writel(0, &sdr_scc_mgr->update); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 643 | } |
| 644 | } |
| 645 | |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 646 | /* |
| 647 | * apply and load a particular input delay for the DQ pins in a group |
| 648 | * group_bgn is the index of the first dq pin (in the write group) |
| 649 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 650 | static void scc_mgr_apply_group_dq_in_delay(struct socfpga_sdrseq *seq, |
| 651 | u32 group_bgn, u32 delay) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 652 | { |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 653 | u32 i, p; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 654 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 655 | for (i = 0, p = group_bgn; i < seq->rwcfg->mem_dq_per_read_dqs; |
| 656 | i++, p++) { |
Marek Vasut | 07aee5b | 2015-07-12 22:07:33 +0200 | [diff] [blame] | 657 | scc_mgr_set_dq_in_delay(p, delay); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 658 | scc_mgr_load_dq(p); |
| 659 | } |
| 660 | } |
| 661 | |
Marek Vasut | 300c2e6 | 2015-07-17 05:42:49 +0200 | [diff] [blame] | 662 | /** |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 663 | * scc_mgr_apply_group_dq_out1_delay() - Apply and load an output delay for the |
| 664 | * DQ pins in a group |
Marek Vasut | 300c2e6 | 2015-07-17 05:42:49 +0200 | [diff] [blame] | 665 | * @delay: Delay value |
| 666 | * |
| 667 | * Apply and load a particular output delay for the DQ pins in a group. |
| 668 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 669 | static void scc_mgr_apply_group_dq_out1_delay(struct socfpga_sdrseq *seq, |
| 670 | const u32 delay) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 671 | { |
Marek Vasut | 300c2e6 | 2015-07-17 05:42:49 +0200 | [diff] [blame] | 672 | int i; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 673 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 674 | for (i = 0; i < seq->rwcfg->mem_dq_per_write_dqs; i++) { |
Marek Vasut | 300c2e6 | 2015-07-17 05:42:49 +0200 | [diff] [blame] | 675 | scc_mgr_set_dq_out1_delay(i, delay); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 676 | scc_mgr_load_dq(i); |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | /* apply and load a particular output delay for the DM pins in a group */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 681 | static void scc_mgr_apply_group_dm_out1_delay(struct socfpga_sdrseq *seq, |
| 682 | u32 delay1) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 683 | { |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 684 | u32 i; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 685 | |
| 686 | for (i = 0; i < RW_MGR_NUM_DM_PER_WRITE_GROUP; i++) { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 687 | scc_mgr_set_dm_out1_delay(seq, i, delay1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 688 | scc_mgr_load_dm(i); |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | |
| 693 | /* apply and load delay on both DQS and OCT out1 */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 694 | static void scc_mgr_apply_group_dqs_io_and_oct_out1(struct socfpga_sdrseq *seq, |
| 695 | u32 write_group, u32 delay) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 696 | { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 697 | scc_mgr_set_dqs_out1_delay(seq, delay); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 698 | scc_mgr_load_dqs_io(); |
| 699 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 700 | scc_mgr_set_oct_out1_delay(seq, write_group, delay); |
| 701 | scc_mgr_load_dqs_for_write_group(seq, write_group); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 702 | } |
| 703 | |
Marek Vasut | 5cb1b50 | 2015-07-17 05:33:28 +0200 | [diff] [blame] | 704 | /** |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 705 | * scc_mgr_apply_group_all_out_delay_add() - Apply a delay to the entire output |
| 706 | * side: DQ, DM, DQS, OCT |
Marek Vasut | 5cb1b50 | 2015-07-17 05:33:28 +0200 | [diff] [blame] | 707 | * @write_group: Write group |
| 708 | * @delay: Delay value |
| 709 | * |
| 710 | * Apply a delay to the entire output side: DQ, DM, DQS, OCT. |
| 711 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 712 | static void scc_mgr_apply_group_all_out_delay_add(struct socfpga_sdrseq *seq, |
| 713 | const u32 write_group, |
Marek Vasut | 8eccde3 | 2015-07-17 05:30:14 +0200 | [diff] [blame] | 714 | const u32 delay) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 715 | { |
Marek Vasut | 8eccde3 | 2015-07-17 05:30:14 +0200 | [diff] [blame] | 716 | u32 i, new_delay; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 717 | |
Marek Vasut | 8eccde3 | 2015-07-17 05:30:14 +0200 | [diff] [blame] | 718 | /* DQ shift */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 719 | for (i = 0; i < seq->rwcfg->mem_dq_per_write_dqs; i++) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 720 | scc_mgr_load_dq(i); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 721 | |
Marek Vasut | 8eccde3 | 2015-07-17 05:30:14 +0200 | [diff] [blame] | 722 | /* DM shift */ |
| 723 | for (i = 0; i < RW_MGR_NUM_DM_PER_WRITE_GROUP; i++) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 724 | scc_mgr_load_dm(i); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 725 | |
Marek Vasut | 5cb1b50 | 2015-07-17 05:33:28 +0200 | [diff] [blame] | 726 | /* DQS shift */ |
| 727 | new_delay = READ_SCC_DQS_IO_OUT2_DELAY + delay; |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 728 | if (new_delay > seq->iocfg->io_out2_delay_max) { |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 729 | debug_cond(DLEVEL >= 1, |
Marek Vasut | 5cb1b50 | 2015-07-17 05:33:28 +0200 | [diff] [blame] | 730 | "%s:%d (%u, %u) DQS: %u > %d; adding %u to OUT1\n", |
| 731 | __func__, __LINE__, write_group, delay, new_delay, |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 732 | seq->iocfg->io_out2_delay_max, |
| 733 | new_delay - seq->iocfg->io_out2_delay_max); |
| 734 | new_delay -= seq->iocfg->io_out2_delay_max; |
| 735 | scc_mgr_set_dqs_out1_delay(seq, new_delay); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | scc_mgr_load_dqs_io(); |
| 739 | |
Marek Vasut | 5cb1b50 | 2015-07-17 05:33:28 +0200 | [diff] [blame] | 740 | /* OCT shift */ |
| 741 | new_delay = READ_SCC_OCT_OUT2_DELAY + delay; |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 742 | if (new_delay > seq->iocfg->io_out2_delay_max) { |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 743 | debug_cond(DLEVEL >= 1, |
Marek Vasut | 5cb1b50 | 2015-07-17 05:33:28 +0200 | [diff] [blame] | 744 | "%s:%d (%u, %u) DQS: %u > %d; adding %u to OUT1\n", |
| 745 | __func__, __LINE__, write_group, delay, |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 746 | new_delay, seq->iocfg->io_out2_delay_max, |
| 747 | new_delay - seq->iocfg->io_out2_delay_max); |
| 748 | new_delay -= seq->iocfg->io_out2_delay_max; |
| 749 | scc_mgr_set_oct_out1_delay(seq, write_group, new_delay); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 750 | } |
| 751 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 752 | scc_mgr_load_dqs_for_write_group(seq, write_group); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 753 | } |
| 754 | |
Marek Vasut | f51a7d3 | 2015-07-19 02:18:21 +0200 | [diff] [blame] | 755 | /** |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 756 | * scc_mgr_apply_group_all_out_delay_add() - Apply a delay to the entire output |
| 757 | * side to all ranks |
Marek Vasut | f51a7d3 | 2015-07-19 02:18:21 +0200 | [diff] [blame] | 758 | * @write_group: Write group |
| 759 | * @delay: Delay value |
| 760 | * |
| 761 | * Apply a delay to the entire output side (DQ, DM, DQS, OCT) to all ranks. |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 762 | */ |
Marek Vasut | f51a7d3 | 2015-07-19 02:18:21 +0200 | [diff] [blame] | 763 | static void |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 764 | scc_mgr_apply_group_all_out_delay_add_all_ranks(struct socfpga_sdrseq *seq, |
| 765 | const u32 write_group, |
Marek Vasut | f51a7d3 | 2015-07-19 02:18:21 +0200 | [diff] [blame] | 766 | const u32 delay) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 767 | { |
Marek Vasut | f51a7d3 | 2015-07-19 02:18:21 +0200 | [diff] [blame] | 768 | int r; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 769 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 770 | for (r = 0; r < seq->rwcfg->mem_number_of_ranks; |
Marek Vasut | f51a7d3 | 2015-07-19 02:18:21 +0200 | [diff] [blame] | 771 | r += NUM_RANKS_PER_SHADOW_REG) { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 772 | scc_mgr_apply_group_all_out_delay_add(seq, write_group, delay); |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 773 | writel(0, &sdr_scc_mgr->update); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 774 | } |
| 775 | } |
| 776 | |
Marek Vasut | f936f94 | 2015-07-26 11:07:19 +0200 | [diff] [blame] | 777 | /** |
| 778 | * set_jump_as_return() - Return instruction optimization |
| 779 | * |
| 780 | * Optimization used to recover some slots in ddr3 inst_rom could be |
| 781 | * applied to other protocols if we wanted to |
| 782 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 783 | static void set_jump_as_return(struct socfpga_sdrseq *seq) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 784 | { |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 785 | /* |
Marek Vasut | f936f94 | 2015-07-26 11:07:19 +0200 | [diff] [blame] | 786 | * To save space, we replace return with jump to special shared |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 787 | * RETURN instruction so we set the counter to large value so that |
Marek Vasut | f936f94 | 2015-07-26 11:07:19 +0200 | [diff] [blame] | 788 | * we always jump. |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 789 | */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 790 | writel(0xff, &sdr_rw_load_mgr_regs->load_cntr0); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 791 | writel(seq->rwcfg->rreturn, &sdr_rw_load_jump_mgr_regs->load_jump_add0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 792 | } |
| 793 | |
Marek Vasut | 3de9622 | 2015-07-26 11:46:04 +0200 | [diff] [blame] | 794 | /** |
| 795 | * delay_for_n_mem_clocks() - Delay for N memory clocks |
| 796 | * @clocks: Length of the delay |
| 797 | * |
| 798 | * Delay for N memory clocks. |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 799 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 800 | static void delay_for_n_mem_clocks(struct socfpga_sdrseq *seq, |
| 801 | const u32 clocks) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 802 | { |
Marek Vasut | 90a584b | 2015-07-26 11:11:28 +0200 | [diff] [blame] | 803 | u32 afi_clocks; |
Marek Vasut | 6a39be6 | 2015-07-26 11:42:53 +0200 | [diff] [blame] | 804 | u16 c_loop; |
| 805 | u8 inner; |
| 806 | u8 outer; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 807 | |
| 808 | debug("%s:%d: clocks=%u ... start\n", __func__, __LINE__, clocks); |
| 809 | |
Marek Vasut | cbcaf46 | 2015-07-26 11:34:09 +0200 | [diff] [blame] | 810 | /* Scale (rounding up) to get afi clocks. */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 811 | afi_clocks = DIV_ROUND_UP(clocks, seq->misccfg->afi_rate_ratio); |
Marek Vasut | cbcaf46 | 2015-07-26 11:34:09 +0200 | [diff] [blame] | 812 | if (afi_clocks) /* Temporary underflow protection */ |
| 813 | afi_clocks--; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 814 | |
| 815 | /* |
Marek Vasut | 90a584b | 2015-07-26 11:11:28 +0200 | [diff] [blame] | 816 | * Note, we don't bother accounting for being off a little |
| 817 | * bit because of a few extra instructions in outer loops. |
| 818 | * Note, the loops have a test at the end, and do the test |
| 819 | * before the decrement, and so always perform the loop |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 820 | * 1 time more than the counter value |
| 821 | */ |
Marek Vasut | 6a39be6 | 2015-07-26 11:42:53 +0200 | [diff] [blame] | 822 | c_loop = afi_clocks >> 16; |
| 823 | outer = c_loop ? 0xff : (afi_clocks >> 8); |
| 824 | inner = outer ? 0xff : afi_clocks; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 825 | |
| 826 | /* |
| 827 | * rom instructions are structured as follows: |
| 828 | * |
| 829 | * IDLE_LOOP2: jnz cntr0, TARGET_A |
| 830 | * IDLE_LOOP1: jnz cntr1, TARGET_B |
| 831 | * return |
| 832 | * |
| 833 | * so, when doing nested loops, TARGET_A is set to IDLE_LOOP2, and |
| 834 | * TARGET_B is set to IDLE_LOOP2 as well |
| 835 | * |
| 836 | * if we have no outer loop, though, then we can use IDLE_LOOP1 only, |
| 837 | * and set TARGET_B to IDLE_LOOP1 and we skip IDLE_LOOP2 entirely |
| 838 | * |
| 839 | * a little confusing, but it helps save precious space in the inst_rom |
| 840 | * and sequencer rom and keeps the delays more accurate and reduces |
| 841 | * overhead |
| 842 | */ |
Marek Vasut | cbcaf46 | 2015-07-26 11:34:09 +0200 | [diff] [blame] | 843 | if (afi_clocks < 0x100) { |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 844 | writel(SKIP_DELAY_LOOP_VALUE_OR_ZERO(inner), |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 845 | &sdr_rw_load_mgr_regs->load_cntr1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 846 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 847 | writel(seq->rwcfg->idle_loop1, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 848 | &sdr_rw_load_jump_mgr_regs->load_jump_add1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 849 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 850 | writel(seq->rwcfg->idle_loop1, SDR_PHYGRP_RWMGRGRP_ADDRESS | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 851 | RW_MGR_RUN_SINGLE_GROUP_OFFSET); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 852 | } else { |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 853 | writel(SKIP_DELAY_LOOP_VALUE_OR_ZERO(inner), |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 854 | &sdr_rw_load_mgr_regs->load_cntr0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 855 | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 856 | writel(SKIP_DELAY_LOOP_VALUE_OR_ZERO(outer), |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 857 | &sdr_rw_load_mgr_regs->load_cntr1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 858 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 859 | writel(seq->rwcfg->idle_loop2, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 860 | &sdr_rw_load_jump_mgr_regs->load_jump_add0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 861 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 862 | writel(seq->rwcfg->idle_loop2, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 863 | &sdr_rw_load_jump_mgr_regs->load_jump_add1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 864 | |
Marek Vasut | 0c1b81b | 2015-07-26 11:44:54 +0200 | [diff] [blame] | 865 | do { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 866 | writel(seq->rwcfg->idle_loop2, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 867 | SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 868 | RW_MGR_RUN_SINGLE_GROUP_OFFSET); |
Marek Vasut | 0c1b81b | 2015-07-26 11:44:54 +0200 | [diff] [blame] | 869 | } while (c_loop-- != 0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 870 | } |
| 871 | debug("%s:%d clocks=%u ... end\n", __func__, __LINE__, clocks); |
| 872 | } |
| 873 | |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 874 | static void delay_for_n_ns(struct socfpga_sdrseq *seq, const u32 ns) |
| 875 | { |
| 876 | delay_for_n_mem_clocks(seq, (ns * seq->misccfg->afi_clk_freq * |
| 877 | seq->misccfg->afi_rate_ratio) / 1000); |
| 878 | } |
| 879 | |
Marek Vasut | 944fe71 | 2015-07-13 00:44:30 +0200 | [diff] [blame] | 880 | /** |
| 881 | * rw_mgr_mem_init_load_regs() - Load instruction registers |
| 882 | * @cntr0: Counter 0 value |
| 883 | * @cntr1: Counter 1 value |
| 884 | * @cntr2: Counter 2 value |
| 885 | * @jump: Jump instruction value |
| 886 | * |
| 887 | * Load instruction registers. |
| 888 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 889 | static void rw_mgr_mem_init_load_regs(struct socfpga_sdrseq *seq, |
| 890 | u32 cntr0, u32 cntr1, u32 cntr2, u32 jump) |
Marek Vasut | 944fe71 | 2015-07-13 00:44:30 +0200 | [diff] [blame] | 891 | { |
Marek Vasut | 5ded732 | 2015-08-02 19:42:26 +0200 | [diff] [blame] | 892 | u32 grpaddr = SDR_PHYGRP_RWMGRGRP_ADDRESS | |
Marek Vasut | 944fe71 | 2015-07-13 00:44:30 +0200 | [diff] [blame] | 893 | RW_MGR_RUN_SINGLE_GROUP_OFFSET; |
| 894 | |
| 895 | /* Load counters */ |
| 896 | writel(SKIP_DELAY_LOOP_VALUE_OR_ZERO(cntr0), |
| 897 | &sdr_rw_load_mgr_regs->load_cntr0); |
| 898 | writel(SKIP_DELAY_LOOP_VALUE_OR_ZERO(cntr1), |
| 899 | &sdr_rw_load_mgr_regs->load_cntr1); |
| 900 | writel(SKIP_DELAY_LOOP_VALUE_OR_ZERO(cntr2), |
| 901 | &sdr_rw_load_mgr_regs->load_cntr2); |
| 902 | |
| 903 | /* Load jump address */ |
| 904 | writel(jump, &sdr_rw_load_jump_mgr_regs->load_jump_add0); |
| 905 | writel(jump, &sdr_rw_load_jump_mgr_regs->load_jump_add1); |
| 906 | writel(jump, &sdr_rw_load_jump_mgr_regs->load_jump_add2); |
| 907 | |
| 908 | /* Execute count instruction */ |
| 909 | writel(jump, grpaddr); |
| 910 | } |
| 911 | |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 912 | /** |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 913 | * rw_mgr_mem_load_user_ddr2() - Load user calibration values for DDR2 |
| 914 | * @handoff: Indicate whether this is initialization or handoff phase |
| 915 | * |
| 916 | * Load user calibration values and optionally precharge the banks. |
| 917 | */ |
| 918 | static void rw_mgr_mem_load_user_ddr2(struct socfpga_sdrseq *seq, |
| 919 | const int handoff) |
| 920 | { |
| 921 | u32 grpaddr = SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 922 | RW_MGR_RUN_SINGLE_GROUP_OFFSET; |
| 923 | u32 r; |
| 924 | |
| 925 | for (r = 0; r < seq->rwcfg->mem_number_of_ranks; r++) { |
| 926 | /* set rank */ |
| 927 | set_rank_and_odt_mask(seq, r, RW_MGR_ODT_MODE_OFF); |
| 928 | |
| 929 | /* precharge all banks ... */ |
| 930 | writel(seq->rwcfg->precharge_all, grpaddr); |
| 931 | |
| 932 | writel(seq->rwcfg->emr2, grpaddr); |
| 933 | writel(seq->rwcfg->emr3, grpaddr); |
| 934 | writel(seq->rwcfg->emr, grpaddr); |
| 935 | |
| 936 | if (handoff) { |
| 937 | writel(seq->rwcfg->mr_user, grpaddr); |
| 938 | continue; |
| 939 | } |
| 940 | |
| 941 | writel(seq->rwcfg->mr_dll_reset, grpaddr); |
| 942 | |
| 943 | writel(seq->rwcfg->precharge_all, grpaddr); |
| 944 | |
| 945 | writel(seq->rwcfg->refresh, grpaddr); |
| 946 | delay_for_n_ns(seq, 200); |
| 947 | writel(seq->rwcfg->refresh, grpaddr); |
| 948 | delay_for_n_ns(seq, 200); |
| 949 | |
| 950 | writel(seq->rwcfg->mr_calib, grpaddr); |
| 951 | writel(/*seq->rwcfg->*/0x0b, grpaddr); // EMR_OCD_ENABLE |
| 952 | writel(seq->rwcfg->emr, grpaddr); |
| 953 | delay_for_n_mem_clocks(seq, 200); |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | /** |
| 958 | * rw_mgr_mem_load_user_ddr3() - Load user calibration values |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 959 | * @fin1: Final instruction 1 |
| 960 | * @fin2: Final instruction 2 |
| 961 | * @precharge: If 1, precharge the banks at the end |
| 962 | * |
| 963 | * Load user calibration values and optionally precharge the banks. |
| 964 | */ |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 965 | static void rw_mgr_mem_load_user_ddr3(struct socfpga_sdrseq *seq, |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 966 | const u32 fin1, const u32 fin2, |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 967 | const int precharge) |
| 968 | { |
| 969 | u32 grpaddr = SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 970 | RW_MGR_RUN_SINGLE_GROUP_OFFSET; |
| 971 | u32 r; |
| 972 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 973 | for (r = 0; r < seq->rwcfg->mem_number_of_ranks; r++) { |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 974 | /* set rank */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 975 | set_rank_and_odt_mask(seq, r, RW_MGR_ODT_MODE_OFF); |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 976 | |
| 977 | /* precharge all banks ... */ |
| 978 | if (precharge) |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 979 | writel(seq->rwcfg->precharge_all, grpaddr); |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 980 | |
| 981 | /* |
| 982 | * USER Use Mirror-ed commands for odd ranks if address |
| 983 | * mirrorring is on |
| 984 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 985 | if ((seq->rwcfg->mem_address_mirroring >> r) & 0x1) { |
| 986 | set_jump_as_return(seq); |
| 987 | writel(seq->rwcfg->mrs2_mirr, grpaddr); |
| 988 | delay_for_n_mem_clocks(seq, 4); |
| 989 | set_jump_as_return(seq); |
| 990 | writel(seq->rwcfg->mrs3_mirr, grpaddr); |
| 991 | delay_for_n_mem_clocks(seq, 4); |
| 992 | set_jump_as_return(seq); |
| 993 | writel(seq->rwcfg->mrs1_mirr, grpaddr); |
| 994 | delay_for_n_mem_clocks(seq, 4); |
| 995 | set_jump_as_return(seq); |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 996 | writel(fin1, grpaddr); |
| 997 | } else { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 998 | set_jump_as_return(seq); |
| 999 | writel(seq->rwcfg->mrs2, grpaddr); |
| 1000 | delay_for_n_mem_clocks(seq, 4); |
| 1001 | set_jump_as_return(seq); |
| 1002 | writel(seq->rwcfg->mrs3, grpaddr); |
| 1003 | delay_for_n_mem_clocks(seq, 4); |
| 1004 | set_jump_as_return(seq); |
| 1005 | writel(seq->rwcfg->mrs1, grpaddr); |
| 1006 | set_jump_as_return(seq); |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 1007 | writel(fin2, grpaddr); |
| 1008 | } |
| 1009 | |
| 1010 | if (precharge) |
| 1011 | continue; |
| 1012 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1013 | set_jump_as_return(seq); |
| 1014 | writel(seq->rwcfg->zqcl, grpaddr); |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 1015 | |
| 1016 | /* tZQinit = tDLLK = 512 ck cycles */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1017 | delay_for_n_mem_clocks(seq, 512); |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 1018 | } |
| 1019 | } |
| 1020 | |
Marek Vasut | 8e9d7d0 | 2015-07-26 10:57:06 +0200 | [diff] [blame] | 1021 | /** |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 1022 | * rw_mgr_mem_load_user() - Load user calibration values |
| 1023 | * @fin1: Final instruction 1 |
| 1024 | * @fin2: Final instruction 2 |
| 1025 | * @precharge: If 1, precharge the banks at the end |
| 1026 | * |
| 1027 | * Load user calibration values and optionally precharge the banks. |
| 1028 | */ |
| 1029 | static void rw_mgr_mem_load_user(struct socfpga_sdrseq *seq, |
| 1030 | const u32 fin1, const u32 fin2, |
| 1031 | const int precharge) |
| 1032 | { |
| 1033 | if (dram_is_ddr(2)) |
| 1034 | rw_mgr_mem_load_user_ddr2(seq, precharge); |
| 1035 | else if (dram_is_ddr(3)) |
| 1036 | rw_mgr_mem_load_user_ddr3(seq, fin1, fin2, precharge); |
| 1037 | else |
| 1038 | hang(); |
| 1039 | } |
| 1040 | /** |
Marek Vasut | 8e9d7d0 | 2015-07-26 10:57:06 +0200 | [diff] [blame] | 1041 | * rw_mgr_mem_initialize() - Initialize RW Manager |
| 1042 | * |
| 1043 | * Initialize RW Manager. |
| 1044 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1045 | static void rw_mgr_mem_initialize(struct socfpga_sdrseq *seq) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1046 | { |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1047 | debug("%s:%d\n", __func__, __LINE__); |
| 1048 | |
| 1049 | /* The reset / cke part of initialization is broadcasted to all ranks */ |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 1050 | if (dram_is_ddr(3)) { |
| 1051 | writel(RW_MGR_RANK_ALL, SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 1052 | RW_MGR_SET_CS_AND_ODT_MASK_OFFSET); |
| 1053 | } |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1054 | |
| 1055 | /* |
| 1056 | * Here's how you load register for a loop |
| 1057 | * Counters are located @ 0x800 |
| 1058 | * Jump address are located @ 0xC00 |
| 1059 | * For both, registers 0 to 3 are selected using bits 3 and 2, like |
| 1060 | * in 0x800, 0x804, 0x808, 0x80C and 0xC00, 0xC04, 0xC08, 0xC0C |
| 1061 | * I know this ain't pretty, but Avalon bus throws away the 2 least |
| 1062 | * significant bits |
| 1063 | */ |
| 1064 | |
Marek Vasut | 8e9d7d0 | 2015-07-26 10:57:06 +0200 | [diff] [blame] | 1065 | /* Start with memory RESET activated */ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1066 | |
| 1067 | /* tINIT = 200us */ |
| 1068 | |
| 1069 | /* |
| 1070 | * 200us @ 266MHz (3.75 ns) ~ 54000 clock cycles |
| 1071 | * If a and b are the number of iteration in 2 nested loops |
| 1072 | * it takes the following number of cycles to complete the operation: |
| 1073 | * number_of_cycles = ((2 + n) * a + 2) * b |
| 1074 | * where n is the number of instruction in the inner loop |
| 1075 | * One possible solution is n = 0 , a = 256 , b = 106 => a = FF, |
| 1076 | * b = 6A |
| 1077 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1078 | rw_mgr_mem_init_load_regs(seq, seq->misccfg->tinit_cntr0_val, |
| 1079 | seq->misccfg->tinit_cntr1_val, |
| 1080 | seq->misccfg->tinit_cntr2_val, |
| 1081 | seq->rwcfg->init_reset_0_cke_0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1082 | |
Marek Vasut | 8e9d7d0 | 2015-07-26 10:57:06 +0200 | [diff] [blame] | 1083 | /* Indicate that memory is stable. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1084 | writel(1, &phy_mgr_cfg->reset_mem_stbl); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1085 | |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 1086 | if (dram_is_ddr(2)) { |
| 1087 | writel(seq->rwcfg->nop, SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 1088 | RW_MGR_RUN_SINGLE_GROUP_OFFSET); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1089 | |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 1090 | /* Bring up clock enable. */ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1091 | |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 1092 | /* tXRP < 400 ck cycles */ |
| 1093 | delay_for_n_ns(seq, 400); |
| 1094 | } else if (dram_is_ddr(3)) { |
| 1095 | /* |
| 1096 | * transition the RESET to high |
| 1097 | * Wait for 500us |
| 1098 | */ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1099 | |
Marek Vasut | 9a5a90a | 2019-10-18 00:22:31 +0200 | [diff] [blame] | 1100 | /* |
| 1101 | * 500us @ 266MHz (3.75 ns) ~ 134000 clock cycles |
| 1102 | * If a and b are the number of iteration in 2 nested loops |
| 1103 | * it takes the following number of cycles to complete the |
| 1104 | * operation number_of_cycles = ((2 + n) * a + 2) * b |
| 1105 | * where n is the number of instruction in the inner loop |
| 1106 | * One possible solution is |
| 1107 | * n = 2 , a = 131 , b = 256 => a = 83, b = FF |
| 1108 | */ |
| 1109 | rw_mgr_mem_init_load_regs(seq, seq->misccfg->treset_cntr0_val, |
| 1110 | seq->misccfg->treset_cntr1_val, |
| 1111 | seq->misccfg->treset_cntr2_val, |
| 1112 | seq->rwcfg->init_reset_1_cke_0); |
| 1113 | /* Bring up clock enable. */ |
| 1114 | |
| 1115 | /* tXRP < 250 ck cycles */ |
| 1116 | delay_for_n_mem_clocks(seq, 250); |
| 1117 | } |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1118 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1119 | rw_mgr_mem_load_user(seq, seq->rwcfg->mrs0_dll_reset_mirr, |
| 1120 | seq->rwcfg->mrs0_dll_reset, 0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1121 | } |
| 1122 | |
Marek Vasut | f1f22f7 | 2015-07-26 10:59:19 +0200 | [diff] [blame] | 1123 | /** |
| 1124 | * rw_mgr_mem_handoff() - Hand off the memory to user |
| 1125 | * |
| 1126 | * At the end of calibration we have to program the user settings in |
| 1127 | * and hand off the memory to the user. |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1128 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1129 | static void rw_mgr_mem_handoff(struct socfpga_sdrseq *seq) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1130 | { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1131 | rw_mgr_mem_load_user(seq, seq->rwcfg->mrs0_user_mirr, |
| 1132 | seq->rwcfg->mrs0_user, 1); |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 1133 | /* |
Marek Vasut | f1f22f7 | 2015-07-26 10:59:19 +0200 | [diff] [blame] | 1134 | * Need to wait tMOD (12CK or 15ns) time before issuing other |
| 1135 | * commands, but we will have plenty of NIOS cycles before actual |
| 1136 | * handoff so its okay. |
Marek Vasut | ecd2334 | 2015-07-13 00:51:05 +0200 | [diff] [blame] | 1137 | */ |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1138 | } |
| 1139 | |
Marek Vasut | 8371c2e | 2015-07-21 06:00:36 +0200 | [diff] [blame] | 1140 | /** |
| 1141 | * rw_mgr_mem_calibrate_write_test_issue() - Issue write test command |
| 1142 | * @group: Write Group |
| 1143 | * @use_dm: Use DM |
| 1144 | * |
| 1145 | * Issue write test command. Two variants are provided, one that just tests |
| 1146 | * a write pattern and another that tests datamask functionality. |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1147 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1148 | static void rw_mgr_mem_calibrate_write_test_issue(struct socfpga_sdrseq *seq, |
| 1149 | u32 group, u32 test_dm) |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1150 | { |
Marek Vasut | 8371c2e | 2015-07-21 06:00:36 +0200 | [diff] [blame] | 1151 | const u32 quick_write_mode = |
| 1152 | (STATIC_CALIB_STEPS & CALIB_SKIP_WRITES) && |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1153 | seq->misccfg->enable_super_quick_calibration; |
Marek Vasut | 8371c2e | 2015-07-21 06:00:36 +0200 | [diff] [blame] | 1154 | u32 mcc_instruction; |
| 1155 | u32 rw_wl_nop_cycles; |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1156 | |
| 1157 | /* |
| 1158 | * Set counter and jump addresses for the right |
| 1159 | * number of NOP cycles. |
| 1160 | * The number of supported NOP cycles can range from -1 to infinity |
| 1161 | * Three different cases are handled: |
| 1162 | * |
| 1163 | * 1. For a number of NOP cycles greater than 0, the RW Mgr looping |
| 1164 | * mechanism will be used to insert the right number of NOPs |
| 1165 | * |
| 1166 | * 2. For a number of NOP cycles equals to 0, the micro-instruction |
| 1167 | * issuing the write command will jump straight to the |
| 1168 | * micro-instruction that turns on DQS (for DDRx), or outputs write |
| 1169 | * data (for RLD), skipping |
| 1170 | * the NOP micro-instruction all together |
| 1171 | * |
| 1172 | * 3. A number of NOP cycles equal to -1 indicates that DQS must be |
| 1173 | * turned on in the same micro-instruction that issues the write |
| 1174 | * command. Then we need |
| 1175 | * to directly jump to the micro-instruction that sends out the data |
| 1176 | * |
| 1177 | * NOTE: Implementing this mechanism uses 2 RW Mgr jump-counters |
| 1178 | * (2 and 3). One jump-counter (0) is used to perform multiple |
| 1179 | * write-read operations. |
| 1180 | * one counter left to issue this command in "multiple-group" mode |
| 1181 | */ |
| 1182 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1183 | rw_wl_nop_cycles = seq->gbl.rw_wl_nop_cycles; |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1184 | |
| 1185 | if (rw_wl_nop_cycles == -1) { |
| 1186 | /* |
| 1187 | * CNTR 2 - We want to execute the special write operation that |
| 1188 | * turns on DQS right away and then skip directly to the |
| 1189 | * instruction that sends out the data. We set the counter to a |
| 1190 | * large number so that the jump is always taken. |
| 1191 | */ |
| 1192 | writel(0xFF, &sdr_rw_load_mgr_regs->load_cntr2); |
| 1193 | |
| 1194 | /* CNTR 3 - Not used */ |
| 1195 | if (test_dm) { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1196 | mcc_instruction = seq->rwcfg->lfsr_wr_rd_dm_bank_0_wl_1; |
| 1197 | writel(seq->rwcfg->lfsr_wr_rd_dm_bank_0_data, |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1198 | &sdr_rw_load_jump_mgr_regs->load_jump_add2); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1199 | writel(seq->rwcfg->lfsr_wr_rd_dm_bank_0_nop, |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1200 | &sdr_rw_load_jump_mgr_regs->load_jump_add3); |
| 1201 | } else { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1202 | mcc_instruction = seq->rwcfg->lfsr_wr_rd_bank_0_wl_1; |
| 1203 | writel(seq->rwcfg->lfsr_wr_rd_bank_0_data, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1204 | &sdr_rw_load_jump_mgr_regs->load_jump_add2); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1205 | writel(seq->rwcfg->lfsr_wr_rd_bank_0_nop, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1206 | &sdr_rw_load_jump_mgr_regs->load_jump_add3); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1207 | } |
| 1208 | } else if (rw_wl_nop_cycles == 0) { |
| 1209 | /* |
| 1210 | * CNTR 2 - We want to skip the NOP operation and go straight |
| 1211 | * to the DQS enable instruction. We set the counter to a large |
| 1212 | * number so that the jump is always taken. |
| 1213 | */ |
| 1214 | writel(0xFF, &sdr_rw_load_mgr_regs->load_cntr2); |
| 1215 | |
| 1216 | /* CNTR 3 - Not used */ |
| 1217 | if (test_dm) { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1218 | mcc_instruction = seq->rwcfg->lfsr_wr_rd_dm_bank_0; |
| 1219 | writel(seq->rwcfg->lfsr_wr_rd_dm_bank_0_dqs, |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1220 | &sdr_rw_load_jump_mgr_regs->load_jump_add2); |
| 1221 | } else { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1222 | mcc_instruction = seq->rwcfg->lfsr_wr_rd_bank_0; |
| 1223 | writel(seq->rwcfg->lfsr_wr_rd_bank_0_dqs, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1224 | &sdr_rw_load_jump_mgr_regs->load_jump_add2); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1225 | } |
| 1226 | } else { |
| 1227 | /* |
| 1228 | * CNTR 2 - In this case we want to execute the next instruction |
| 1229 | * and NOT take the jump. So we set the counter to 0. The jump |
| 1230 | * address doesn't count. |
| 1231 | */ |
| 1232 | writel(0x0, &sdr_rw_load_mgr_regs->load_cntr2); |
| 1233 | writel(0x0, &sdr_rw_load_jump_mgr_regs->load_jump_add2); |
| 1234 | |
| 1235 | /* |
| 1236 | * CNTR 3 - Set the nop counter to the number of cycles we |
| 1237 | * need to loop for, minus 1. |
| 1238 | */ |
| 1239 | writel(rw_wl_nop_cycles - 1, &sdr_rw_load_mgr_regs->load_cntr3); |
| 1240 | if (test_dm) { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1241 | mcc_instruction = seq->rwcfg->lfsr_wr_rd_dm_bank_0; |
| 1242 | writel(seq->rwcfg->lfsr_wr_rd_dm_bank_0_nop, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1243 | &sdr_rw_load_jump_mgr_regs->load_jump_add3); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1244 | } else { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1245 | mcc_instruction = seq->rwcfg->lfsr_wr_rd_bank_0; |
| 1246 | writel(seq->rwcfg->lfsr_wr_rd_bank_0_nop, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1247 | &sdr_rw_load_jump_mgr_regs->load_jump_add3); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | writel(0, SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 1252 | RW_MGR_RESET_READ_DATAPATH_OFFSET); |
| 1253 | |
| 1254 | if (quick_write_mode) |
| 1255 | writel(0x08, &sdr_rw_load_mgr_regs->load_cntr0); |
| 1256 | else |
| 1257 | writel(0x40, &sdr_rw_load_mgr_regs->load_cntr0); |
| 1258 | |
| 1259 | writel(mcc_instruction, &sdr_rw_load_jump_mgr_regs->load_jump_add0); |
| 1260 | |
| 1261 | /* |
| 1262 | * CNTR 1 - This is used to ensure enough time elapses |
| 1263 | * for read data to come back. |
| 1264 | */ |
| 1265 | writel(0x30, &sdr_rw_load_mgr_regs->load_cntr1); |
| 1266 | |
| 1267 | if (test_dm) { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1268 | writel(seq->rwcfg->lfsr_wr_rd_dm_bank_0_wait, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1269 | &sdr_rw_load_jump_mgr_regs->load_jump_add1); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1270 | } else { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1271 | writel(seq->rwcfg->lfsr_wr_rd_bank_0_wait, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1272 | &sdr_rw_load_jump_mgr_regs->load_jump_add1); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1273 | } |
| 1274 | |
Marek Vasut | 8371c2e | 2015-07-21 06:00:36 +0200 | [diff] [blame] | 1275 | writel(mcc_instruction, (SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 1276 | RW_MGR_RUN_SINGLE_GROUP_OFFSET) + |
| 1277 | (group << 2)); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1278 | } |
| 1279 | |
Marek Vasut | 4a82854b | 2015-07-21 05:57:11 +0200 | [diff] [blame] | 1280 | /** |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1281 | * rw_mgr_mem_calibrate_write_test() - Test writes, check for single/multiple |
| 1282 | * pass |
Marek Vasut | 4a82854b | 2015-07-21 05:57:11 +0200 | [diff] [blame] | 1283 | * @rank_bgn: Rank number |
| 1284 | * @write_group: Write Group |
| 1285 | * @use_dm: Use DM |
| 1286 | * @all_correct: All bits must be correct in the mask |
| 1287 | * @bit_chk: Resulting bit mask after the test |
| 1288 | * @all_ranks: Test all ranks |
| 1289 | * |
| 1290 | * Test writes, can check for a single bit pass or multiple bit pass. |
| 1291 | */ |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1292 | static int |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1293 | rw_mgr_mem_calibrate_write_test(struct socfpga_sdrseq *seq, |
| 1294 | const u32 rank_bgn, const u32 write_group, |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1295 | const u32 use_dm, const u32 all_correct, |
| 1296 | u32 *bit_chk, const u32 all_ranks) |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1297 | { |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1298 | const u32 rank_end = all_ranks ? |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1299 | seq->rwcfg->mem_number_of_ranks : |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1300 | (rank_bgn + NUM_RANKS_PER_SHADOW_REG); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1301 | const u32 shift_ratio = seq->rwcfg->mem_dq_per_write_dqs / |
| 1302 | seq->rwcfg->mem_virtual_groups_per_write_dqs; |
| 1303 | const u32 correct_mask_vg = seq->param.write_correct_mask_vg; |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1304 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1305 | u32 tmp_bit_chk, base_rw_mgr, group; |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1306 | int vg, r; |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1307 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1308 | *bit_chk = seq->param.write_correct_mask; |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1309 | |
| 1310 | for (r = rank_bgn; r < rank_end; r++) { |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1311 | /* Set rank */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1312 | set_rank_and_odt_mask(seq, r, RW_MGR_ODT_MODE_READ_WRITE); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1313 | |
| 1314 | tmp_bit_chk = 0; |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1315 | for (vg = seq->rwcfg->mem_virtual_groups_per_write_dqs - 1; |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1316 | vg >= 0; vg--) { |
| 1317 | /* Reset the FIFOs to get pointers to known state. */ |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1318 | writel(0, &phy_mgr_cmd->fifo_reset); |
| 1319 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1320 | group = write_group * |
| 1321 | seq->rwcfg->mem_virtual_groups_per_write_dqs |
| 1322 | + vg; |
| 1323 | rw_mgr_mem_calibrate_write_test_issue(seq, group, |
| 1324 | use_dm); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1325 | |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1326 | base_rw_mgr = readl(SDR_PHYGRP_RWMGRGRP_ADDRESS); |
| 1327 | tmp_bit_chk <<= shift_ratio; |
| 1328 | tmp_bit_chk |= (correct_mask_vg & ~(base_rw_mgr)); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1329 | } |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1330 | |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1331 | *bit_chk &= tmp_bit_chk; |
| 1332 | } |
| 1333 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1334 | set_rank_and_odt_mask(seq, 0, RW_MGR_ODT_MODE_OFF); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1335 | if (all_correct) { |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 1336 | debug_cond(DLEVEL >= 2, |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1337 | "write_test(%u,%u,ALL) : %u == %u => %i\n", |
| 1338 | write_group, use_dm, *bit_chk, |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1339 | seq->param.write_correct_mask, |
| 1340 | *bit_chk == seq->param.write_correct_mask); |
| 1341 | return *bit_chk == seq->param.write_correct_mask; |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1342 | } else { |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 1343 | debug_cond(DLEVEL >= 2, |
Marek Vasut | b9452ea | 2015-07-21 05:54:39 +0200 | [diff] [blame] | 1344 | "write_test(%u,%u,ONE) : %u != %i => %i\n", |
| 1345 | write_group, use_dm, *bit_chk, 0, *bit_chk != 0); |
Marek Vasut | ad64769c | 2015-07-21 05:43:37 +0200 | [diff] [blame] | 1346 | return *bit_chk != 0x00; |
| 1347 | } |
| 1348 | } |
| 1349 | |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1350 | /** |
| 1351 | * rw_mgr_mem_calibrate_read_test_patterns() - Read back test patterns |
| 1352 | * @rank_bgn: Rank number |
| 1353 | * @group: Read/Write Group |
| 1354 | * @all_ranks: Test all ranks |
| 1355 | * |
| 1356 | * Performs a guaranteed read on the patterns we are going to use during a |
| 1357 | * read test to ensure memory works. |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1358 | */ |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1359 | static int |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1360 | rw_mgr_mem_calibrate_read_test_patterns(struct socfpga_sdrseq *seq, |
| 1361 | const u32 rank_bgn, const u32 group, |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1362 | const u32 all_ranks) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1363 | { |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1364 | const u32 addr = SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 1365 | RW_MGR_RUN_SINGLE_GROUP_OFFSET; |
| 1366 | const u32 addr_offset = |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1367 | (group * seq->rwcfg->mem_virtual_groups_per_read_dqs) |
| 1368 | << 2; |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1369 | const u32 rank_end = all_ranks ? |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1370 | seq->rwcfg->mem_number_of_ranks : |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1371 | (rank_bgn + NUM_RANKS_PER_SHADOW_REG); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1372 | const u32 shift_ratio = seq->rwcfg->mem_dq_per_read_dqs / |
| 1373 | seq->rwcfg->mem_virtual_groups_per_read_dqs; |
| 1374 | const u32 correct_mask_vg = seq->param.read_correct_mask_vg; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1375 | |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1376 | u32 tmp_bit_chk, base_rw_mgr, bit_chk; |
| 1377 | int vg, r; |
| 1378 | int ret = 0; |
| 1379 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1380 | bit_chk = seq->param.read_correct_mask; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1381 | |
| 1382 | for (r = rank_bgn; r < rank_end; r++) { |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1383 | /* Set rank */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1384 | set_rank_and_odt_mask(seq, r, RW_MGR_ODT_MODE_READ_WRITE); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1385 | |
| 1386 | /* Load up a constant bursts of read commands */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1387 | writel(0x20, &sdr_rw_load_mgr_regs->load_cntr0); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1388 | writel(seq->rwcfg->guaranteed_read, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1389 | &sdr_rw_load_jump_mgr_regs->load_jump_add0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1390 | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1391 | writel(0x20, &sdr_rw_load_mgr_regs->load_cntr1); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1392 | writel(seq->rwcfg->guaranteed_read_cont, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1393 | &sdr_rw_load_jump_mgr_regs->load_jump_add1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1394 | |
| 1395 | tmp_bit_chk = 0; |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1396 | for (vg = seq->rwcfg->mem_virtual_groups_per_read_dqs - 1; |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1397 | vg >= 0; vg--) { |
| 1398 | /* Reset the FIFOs to get pointers to known state. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1399 | writel(0, &phy_mgr_cmd->fifo_reset); |
| 1400 | writel(0, SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 1401 | RW_MGR_RESET_READ_DATAPATH_OFFSET); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1402 | writel(seq->rwcfg->guaranteed_read, |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1403 | addr + addr_offset + (vg << 2)); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1404 | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1405 | base_rw_mgr = readl(SDR_PHYGRP_RWMGRGRP_ADDRESS); |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1406 | tmp_bit_chk <<= shift_ratio; |
| 1407 | tmp_bit_chk |= correct_mask_vg & ~base_rw_mgr; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1408 | } |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1409 | |
| 1410 | bit_chk &= tmp_bit_chk; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1411 | } |
| 1412 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1413 | writel(seq->rwcfg->clear_dqs_enable, addr + (group << 2)); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1414 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1415 | set_rank_and_odt_mask(seq, 0, RW_MGR_ODT_MODE_OFF); |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1416 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1417 | if (bit_chk != seq->param.read_correct_mask) |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1418 | ret = -EIO; |
| 1419 | |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 1420 | debug_cond(DLEVEL >= 1, |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1421 | "%s:%d test_load_patterns(%u,ALL) => (%u == %u) => %i\n", |
| 1422 | __func__, __LINE__, group, bit_chk, |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1423 | seq->param.read_correct_mask, ret); |
Marek Vasut | d844c7d | 2015-07-18 03:55:07 +0200 | [diff] [blame] | 1424 | |
| 1425 | return ret; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1426 | } |
| 1427 | |
Marek Vasut | b6cb7f9 | 2015-07-18 03:34:22 +0200 | [diff] [blame] | 1428 | /** |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1429 | * rw_mgr_mem_calibrate_read_load_patterns() - Load up the patterns for read |
| 1430 | * test |
Marek Vasut | b6cb7f9 | 2015-07-18 03:34:22 +0200 | [diff] [blame] | 1431 | * @rank_bgn: Rank number |
| 1432 | * @all_ranks: Test all ranks |
| 1433 | * |
| 1434 | * Load up the patterns we are going to use during a read test. |
| 1435 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1436 | static void rw_mgr_mem_calibrate_read_load_patterns(struct socfpga_sdrseq *seq, |
| 1437 | const u32 rank_bgn, |
Marek Vasut | b6cb7f9 | 2015-07-18 03:34:22 +0200 | [diff] [blame] | 1438 | const int all_ranks) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1439 | { |
Marek Vasut | b6cb7f9 | 2015-07-18 03:34:22 +0200 | [diff] [blame] | 1440 | const u32 rank_end = all_ranks ? |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1441 | seq->rwcfg->mem_number_of_ranks : |
Marek Vasut | b6cb7f9 | 2015-07-18 03:34:22 +0200 | [diff] [blame] | 1442 | (rank_bgn + NUM_RANKS_PER_SHADOW_REG); |
| 1443 | u32 r; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1444 | |
| 1445 | debug("%s:%d\n", __func__, __LINE__); |
Marek Vasut | b6cb7f9 | 2015-07-18 03:34:22 +0200 | [diff] [blame] | 1446 | |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1447 | for (r = rank_bgn; r < rank_end; r++) { |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1448 | /* set rank */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1449 | set_rank_and_odt_mask(seq, r, RW_MGR_ODT_MODE_READ_WRITE); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1450 | |
| 1451 | /* Load up a constant bursts */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1452 | writel(0x20, &sdr_rw_load_mgr_regs->load_cntr0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1453 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1454 | writel(seq->rwcfg->guaranteed_write_wait0, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1455 | &sdr_rw_load_jump_mgr_regs->load_jump_add0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1456 | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1457 | writel(0x20, &sdr_rw_load_mgr_regs->load_cntr1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1458 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1459 | writel(seq->rwcfg->guaranteed_write_wait1, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1460 | &sdr_rw_load_jump_mgr_regs->load_jump_add1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1461 | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1462 | writel(0x04, &sdr_rw_load_mgr_regs->load_cntr2); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1463 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1464 | writel(seq->rwcfg->guaranteed_write_wait2, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1465 | &sdr_rw_load_jump_mgr_regs->load_jump_add2); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1466 | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1467 | writel(0x04, &sdr_rw_load_mgr_regs->load_cntr3); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1468 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1469 | writel(seq->rwcfg->guaranteed_write_wait3, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1470 | &sdr_rw_load_jump_mgr_regs->load_jump_add3); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1471 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1472 | writel(seq->rwcfg->guaranteed_write, |
| 1473 | SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 1474 | RW_MGR_RUN_SINGLE_GROUP_OFFSET); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1475 | } |
| 1476 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1477 | set_rank_and_odt_mask(seq, 0, RW_MGR_ODT_MODE_OFF); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1478 | } |
| 1479 | |
Marek Vasut | 783fcf5 | 2015-07-20 03:26:05 +0200 | [diff] [blame] | 1480 | /** |
| 1481 | * rw_mgr_mem_calibrate_read_test() - Perform READ test on single rank |
| 1482 | * @rank_bgn: Rank number |
| 1483 | * @group: Read/Write group |
| 1484 | * @num_tries: Number of retries of the test |
| 1485 | * @all_correct: All bits must be correct in the mask |
| 1486 | * @bit_chk: Resulting bit mask after the test |
| 1487 | * @all_groups: Test all R/W groups |
| 1488 | * @all_ranks: Test all ranks |
| 1489 | * |
| 1490 | * Try a read and see if it returns correct data back. Test has dummy reads |
| 1491 | * inserted into the mix used to align DQS enable. Test has more thorough |
| 1492 | * checks than the regular read test. |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1493 | */ |
Marek Vasut | 3cb8bf3 | 2015-07-19 07:48:58 +0200 | [diff] [blame] | 1494 | static int |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1495 | rw_mgr_mem_calibrate_read_test(struct socfpga_sdrseq *seq, |
| 1496 | const u32 rank_bgn, const u32 group, |
Marek Vasut | 3cb8bf3 | 2015-07-19 07:48:58 +0200 | [diff] [blame] | 1497 | const u32 num_tries, const u32 all_correct, |
| 1498 | u32 *bit_chk, |
| 1499 | const u32 all_groups, const u32 all_ranks) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1500 | { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1501 | const u32 rank_end = all_ranks ? seq->rwcfg->mem_number_of_ranks : |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1502 | (rank_bgn + NUM_RANKS_PER_SHADOW_REG); |
Marek Vasut | 3cb8bf3 | 2015-07-19 07:48:58 +0200 | [diff] [blame] | 1503 | const u32 quick_read_mode = |
| 1504 | ((STATIC_CALIB_STEPS & CALIB_SKIP_DELAY_SWEEPS) && |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1505 | seq->misccfg->enable_super_quick_calibration); |
| 1506 | u32 correct_mask_vg = seq->param.read_correct_mask_vg; |
Marek Vasut | 3cb8bf3 | 2015-07-19 07:48:58 +0200 | [diff] [blame] | 1507 | u32 tmp_bit_chk; |
| 1508 | u32 base_rw_mgr; |
| 1509 | u32 addr; |
| 1510 | |
| 1511 | int r, vg, ret; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1512 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1513 | *bit_chk = seq->param.read_correct_mask; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1514 | |
| 1515 | for (r = rank_bgn; r < rank_end; r++) { |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1516 | /* set rank */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1517 | set_rank_and_odt_mask(seq, r, RW_MGR_ODT_MODE_READ_WRITE); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1518 | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1519 | writel(0x10, &sdr_rw_load_mgr_regs->load_cntr1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1520 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1521 | writel(seq->rwcfg->read_b2b_wait1, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1522 | &sdr_rw_load_jump_mgr_regs->load_jump_add1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1523 | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1524 | writel(0x10, &sdr_rw_load_mgr_regs->load_cntr2); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1525 | writel(seq->rwcfg->read_b2b_wait2, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1526 | &sdr_rw_load_jump_mgr_regs->load_jump_add2); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1527 | |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1528 | if (quick_read_mode) |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1529 | writel(0x1, &sdr_rw_load_mgr_regs->load_cntr0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1530 | /* need at least two (1+1) reads to capture failures */ |
| 1531 | else if (all_groups) |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1532 | writel(0x06, &sdr_rw_load_mgr_regs->load_cntr0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1533 | else |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1534 | writel(0x32, &sdr_rw_load_mgr_regs->load_cntr0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1535 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1536 | writel(seq->rwcfg->read_b2b, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1537 | &sdr_rw_load_jump_mgr_regs->load_jump_add0); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1538 | if (all_groups) |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1539 | writel(seq->rwcfg->mem_if_read_dqs_width * |
| 1540 | seq->rwcfg->mem_virtual_groups_per_read_dqs - 1, |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1541 | &sdr_rw_load_mgr_regs->load_cntr3); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1542 | else |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1543 | writel(0x0, &sdr_rw_load_mgr_regs->load_cntr3); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1544 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1545 | writel(seq->rwcfg->read_b2b, |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1546 | &sdr_rw_load_jump_mgr_regs->load_jump_add3); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1547 | |
| 1548 | tmp_bit_chk = 0; |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1549 | for (vg = seq->rwcfg->mem_virtual_groups_per_read_dqs - 1; |
| 1550 | vg >= 0; vg--) { |
Marek Vasut | ba522c7 | 2015-07-19 07:57:28 +0200 | [diff] [blame] | 1551 | /* Reset the FIFOs to get pointers to known state. */ |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1552 | writel(0, &phy_mgr_cmd->fifo_reset); |
| 1553 | writel(0, SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 1554 | RW_MGR_RESET_READ_DATAPATH_OFFSET); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1555 | |
Marek Vasut | ba522c7 | 2015-07-19 07:57:28 +0200 | [diff] [blame] | 1556 | if (all_groups) { |
| 1557 | addr = SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 1558 | RW_MGR_RUN_ALL_GROUPS_OFFSET; |
| 1559 | } else { |
| 1560 | addr = SDR_PHYGRP_RWMGRGRP_ADDRESS | |
| 1561 | RW_MGR_RUN_SINGLE_GROUP_OFFSET; |
| 1562 | } |
Marek Vasut | c4815f7 | 2015-07-12 19:03:33 +0200 | [diff] [blame] | 1563 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1564 | writel(seq->rwcfg->read_b2b, addr + |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1565 | ((group * |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1566 | seq->rwcfg->mem_virtual_groups_per_read_dqs + |
Marek Vasut | 139823e | 2015-08-02 19:47:01 +0200 | [diff] [blame] | 1567 | vg) << 2)); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1568 | |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1569 | base_rw_mgr = readl(SDR_PHYGRP_RWMGRGRP_ADDRESS); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1570 | tmp_bit_chk <<= |
| 1571 | seq->rwcfg->mem_dq_per_read_dqs / |
| 1572 | seq->rwcfg->mem_virtual_groups_per_read_dqs; |
Marek Vasut | ba522c7 | 2015-07-19 07:57:28 +0200 | [diff] [blame] | 1573 | tmp_bit_chk |= correct_mask_vg & ~(base_rw_mgr); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1574 | } |
Marek Vasut | 7ce23bb | 2015-07-19 07:51:17 +0200 | [diff] [blame] | 1575 | |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1576 | *bit_chk &= tmp_bit_chk; |
| 1577 | } |
| 1578 | |
Marek Vasut | c4815f7 | 2015-07-12 19:03:33 +0200 | [diff] [blame] | 1579 | addr = SDR_PHYGRP_RWMGRGRP_ADDRESS | RW_MGR_RUN_SINGLE_GROUP_OFFSET; |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1580 | writel(seq->rwcfg->clear_dqs_enable, addr + (group << 2)); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1581 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1582 | set_rank_and_odt_mask(seq, 0, RW_MGR_ODT_MODE_OFF); |
Marek Vasut | 3853d65 | 2015-07-19 07:44:21 +0200 | [diff] [blame] | 1583 | |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1584 | if (all_correct) { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1585 | ret = (*bit_chk == seq->param.read_correct_mask); |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 1586 | debug_cond(DLEVEL >= 2, |
Marek Vasut | 3853d65 | 2015-07-19 07:44:21 +0200 | [diff] [blame] | 1587 | "%s:%d read_test(%u,ALL,%u) => (%u == %u) => %i\n", |
| 1588 | __func__, __LINE__, group, all_groups, *bit_chk, |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1589 | seq->param.read_correct_mask, ret); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1590 | } else { |
Marek Vasut | 3853d65 | 2015-07-19 07:44:21 +0200 | [diff] [blame] | 1591 | ret = (*bit_chk != 0x00); |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 1592 | debug_cond(DLEVEL >= 2, |
Marek Vasut | 3853d65 | 2015-07-19 07:44:21 +0200 | [diff] [blame] | 1593 | "%s:%d read_test(%u,ONE,%u) => (%u != %u) => %i\n", |
| 1594 | __func__, __LINE__, group, all_groups, *bit_chk, |
| 1595 | 0, ret); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1596 | } |
Marek Vasut | 3853d65 | 2015-07-19 07:44:21 +0200 | [diff] [blame] | 1597 | |
| 1598 | return ret; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1599 | } |
| 1600 | |
Marek Vasut | 96df603 | 2015-07-19 07:35:36 +0200 | [diff] [blame] | 1601 | /** |
| 1602 | * rw_mgr_mem_calibrate_read_test_all_ranks() - Perform READ test on all ranks |
| 1603 | * @grp: Read/Write group |
| 1604 | * @num_tries: Number of retries of the test |
| 1605 | * @all_correct: All bits must be correct in the mask |
| 1606 | * @all_groups: Test all R/W groups |
| 1607 | * |
| 1608 | * Perform a READ test across all memory ranks. |
| 1609 | */ |
| 1610 | static int |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1611 | rw_mgr_mem_calibrate_read_test_all_ranks(struct socfpga_sdrseq *seq, |
| 1612 | const u32 grp, const u32 num_tries, |
Marek Vasut | 96df603 | 2015-07-19 07:35:36 +0200 | [diff] [blame] | 1613 | const u32 all_correct, |
| 1614 | const u32 all_groups) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1615 | { |
Marek Vasut | 96df603 | 2015-07-19 07:35:36 +0200 | [diff] [blame] | 1616 | u32 bit_chk; |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1617 | return rw_mgr_mem_calibrate_read_test(seq, 0, grp, num_tries, |
| 1618 | all_correct, &bit_chk, all_groups, |
| 1619 | 1); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1620 | } |
| 1621 | |
Marek Vasut | 60bb8a8 | 2015-07-19 06:25:27 +0200 | [diff] [blame] | 1622 | /** |
| 1623 | * rw_mgr_incr_vfifo() - Increase VFIFO value |
| 1624 | * @grp: Read/Write group |
Marek Vasut | 60bb8a8 | 2015-07-19 06:25:27 +0200 | [diff] [blame] | 1625 | * |
| 1626 | * Increase VFIFO value. |
| 1627 | */ |
Marek Vasut | 8c887b6 | 2015-07-19 06:37:51 +0200 | [diff] [blame] | 1628 | static void rw_mgr_incr_vfifo(const u32 grp) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1629 | { |
Marek Vasut | 1273dd9 | 2015-07-12 21:05:08 +0200 | [diff] [blame] | 1630 | writel(grp, &phy_mgr_cmd->inc_vfifo_hard_phy); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1631 | } |
| 1632 | |
Marek Vasut | 60bb8a8 | 2015-07-19 06:25:27 +0200 | [diff] [blame] | 1633 | /** |
| 1634 | * rw_mgr_decr_vfifo() - Decrease VFIFO value |
| 1635 | * @grp: Read/Write group |
Marek Vasut | 60bb8a8 | 2015-07-19 06:25:27 +0200 | [diff] [blame] | 1636 | * |
| 1637 | * Decrease VFIFO value. |
| 1638 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1639 | static void rw_mgr_decr_vfifo(struct socfpga_sdrseq *seq, const u32 grp) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1640 | { |
Marek Vasut | 60bb8a8 | 2015-07-19 06:25:27 +0200 | [diff] [blame] | 1641 | u32 i; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1642 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1643 | for (i = 0; i < seq->misccfg->read_valid_fifo_size - 1; i++) |
Marek Vasut | 8c887b6 | 2015-07-19 06:37:51 +0200 | [diff] [blame] | 1644 | rw_mgr_incr_vfifo(grp); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1645 | } |
| 1646 | |
Marek Vasut | d145ca9 | 2015-07-19 06:45:43 +0200 | [diff] [blame] | 1647 | /** |
| 1648 | * find_vfifo_failing_read() - Push VFIFO to get a failing read |
| 1649 | * @grp: Read/Write group |
| 1650 | * |
| 1651 | * Push VFIFO until a failing read happens. |
| 1652 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1653 | static int find_vfifo_failing_read(struct socfpga_sdrseq *seq, |
| 1654 | const u32 grp) |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1655 | { |
Marek Vasut | 96df603 | 2015-07-19 07:35:36 +0200 | [diff] [blame] | 1656 | u32 v, ret, fail_cnt = 0; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1657 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1658 | for (v = 0; v < seq->misccfg->read_valid_fifo_size; v++) { |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 1659 | debug_cond(DLEVEL >= 2, "%s:%d: vfifo %u\n", |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1660 | __func__, __LINE__, v); |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1661 | ret = rw_mgr_mem_calibrate_read_test_all_ranks(seq, grp, 1, |
| 1662 | PASS_ONE_BIT, 0); |
Marek Vasut | d145ca9 | 2015-07-19 06:45:43 +0200 | [diff] [blame] | 1663 | if (!ret) { |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1664 | fail_cnt++; |
| 1665 | |
| 1666 | if (fail_cnt == 2) |
Marek Vasut | d145ca9 | 2015-07-19 06:45:43 +0200 | [diff] [blame] | 1667 | return v; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1668 | } |
| 1669 | |
Marek Vasut | d145ca9 | 2015-07-19 06:45:43 +0200 | [diff] [blame] | 1670 | /* Fiddle with FIFO. */ |
Marek Vasut | 8c887b6 | 2015-07-19 06:37:51 +0200 | [diff] [blame] | 1671 | rw_mgr_incr_vfifo(grp); |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1672 | } |
| 1673 | |
Marek Vasut | d145ca9 | 2015-07-19 06:45:43 +0200 | [diff] [blame] | 1674 | /* No failing read found! Something must have gone wrong. */ |
Marek Vasut | ea9aa24 | 2016-04-04 21:21:05 +0200 | [diff] [blame] | 1675 | debug_cond(DLEVEL >= 2, "%s:%d: vfifo failed\n", __func__, __LINE__); |
Marek Vasut | d145ca9 | 2015-07-19 06:45:43 +0200 | [diff] [blame] | 1676 | return 0; |
Dinh Nguyen | 3da4285 | 2015-06-02 22:52:49 -0500 | [diff] [blame] | 1677 | } |
| 1678 | |
Marek Vasut | 192d6f9 | 2015-07-19 05:26:49 +0200 | [diff] [blame] | 1679 | /** |
Marek Vasut | 52e8f21 | 2015-07-19 07:27:06 +0200 | [diff] [blame] | 1680 | * sdr_find_phase_delay() - Find DQS enable phase or delay |
| 1681 | * @working: If 1, look for working phase/delay, if 0, look for non-working |
| 1682 | * @delay: If 1, look for delay, if 0, look for phase |
| 1683 | * @grp: Read/Write group |
| 1684 | * @work: Working window position |
| 1685 | * @work_inc: Working window increment |
| 1686 | * @pd: DQS Phase/Delay Iterator |
| 1687 | * |
| 1688 | * Find working or non-working DQS enable phase setting. |
| 1689 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1690 | static int sdr_find_phase_delay(struct socfpga_sdrseq *seq, int working, |
| 1691 | int delay, const u32 grp, u32 *work, |
| 1692 | const u32 work_inc, u32 *pd) |
Marek Vasut | 52e8f21 | 2015-07-19 07:27:06 +0200 | [diff] [blame] | 1693 | { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1694 | const u32 max = delay ? seq->iocfg->dqs_en_delay_max : |
| 1695 | seq->iocfg->dqs_en_phase_max; |
Marek Vasut | 96df603 | 2015-07-19 07:35:36 +0200 | [diff] [blame] | 1696 | u32 ret; |
Marek Vasut | 52e8f21 | 2015-07-19 07:27:06 +0200 | [diff] [blame] | 1697 | |
| 1698 | for (; *pd <= max; (*pd)++) { |
| 1699 | if (delay) |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1700 | scc_mgr_set_dqs_en_delay_all_ranks(seq, grp, *pd); |
Marek Vasut | 52e8f21 | 2015-07-19 07:27:06 +0200 | [diff] [blame] | 1701 | else |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1702 | scc_mgr_set_dqs_en_phase_all_ranks(seq, grp, *pd); |
Marek Vasut | 52e8f21 | 2015-07-19 07:27:06 +0200 | [diff] [blame] | 1703 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1704 | ret = rw_mgr_mem_calibrate_read_test_all_ranks(seq, grp, 1, |
| 1705 | PASS_ONE_BIT, 0); |
Marek Vasut | 52e8f21 | 2015-07-19 07:27:06 +0200 | [diff] [blame] | 1706 | if (!working) |
| 1707 | ret = !ret; |
| 1708 | |
| 1709 | if (ret) |
| 1710 | return 0; |
| 1711 | |
| 1712 | if (work) |
| 1713 | *work += work_inc; |
| 1714 | } |
| 1715 | |
| 1716 | return -EINVAL; |
| 1717 | } |
| 1718 | /** |
Marek Vasut | 192d6f9 | 2015-07-19 05:26:49 +0200 | [diff] [blame] | 1719 | * sdr_find_phase() - Find DQS enable phase |
| 1720 | * @working: If 1, look for working phase, if 0, look for non-working phase |
| 1721 | * @grp: Read/Write group |
Marek Vasut | 192d6f9 | 2015-07-19 05:26:49 +0200 | [diff] [blame] | 1722 | * @work: Working window position |
| 1723 | * @i: Iterator |
| 1724 | * @p: DQS Phase Iterator |
Marek Vasut | 192d6f9 | 2015-07-19 05:26:49 +0200 | [diff] [blame] | 1725 | * |
| 1726 | * Find working or non-working DQS enable phase setting. |
| 1727 | */ |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1728 | static int sdr_find_phase(struct socfpga_sdrseq *seq, int working, |
| 1729 | const u32 grp, u32 *work, u32 *i, u32 *p) |
Marek Vasut | 192d6f9 | 2015-07-19 05:26:49 +0200 | [diff] [blame] | 1730 | { |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1731 | const u32 end = seq->misccfg->read_valid_fifo_size + (working ? 0 : 1); |
Marek Vasut | 52e8f21 | 2015-07-19 07:27:06 +0200 | [diff] [blame] | 1732 | int ret; |
Marek Vasut | 192d6f9 | 2015-07-19 05:26:49 +0200 | [diff] [blame] | 1733 | |
| 1734 | for (; *i < end; (*i)++) { |
| 1735 | if (working) |
| 1736 | *p = 0; |
| 1737 | |
Simon Goldschmidt | 285b3cb | 2019-07-11 21:18:12 +0200 | [diff] [blame] | 1738 | ret = sdr_find_phase_delay(seq, working, 0, grp, work, |
| 1739 | seq->iocfg->delay_per_opa_tap, p); |
Marek Vasut | 52e8f21 | 2015-07-19 07:27:06 +0200 | [diff] [ |