Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <assert.h> |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 4 | #include <cbfs.h> |
Xi Chen | 555c2ae | 2022-01-21 11:43:53 +0800 | [diff] [blame] | 5 | #include <cbmem.h> |
| 6 | #include <commonlib/bsd/mem_chip_info.h> |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 7 | #include <console/console.h> |
Xi Chen | 5c7a923 | 2022-01-04 19:00:44 +0800 | [diff] [blame] | 8 | #include <soc/dramc_common.h> |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 9 | #include <ip_checksum.h> |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 10 | #include <mrc_cache.h> |
| 11 | #include <soc/dramc_param.h> |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 12 | #include <soc/emi.h> |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 13 | #include <soc/mmu_operations.h> |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 14 | #include <symbols.h> |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 15 | #include <timer.h> |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 16 | |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 17 | /* This must be defined in chromeos.fmd in same name and size. */ |
Martin Roth | b6a0b26 | 2022-09-05 14:51:34 -0600 | [diff] [blame] | 18 | #define CAL_REGION_RW_MRC_CACHE "RW_MRC_CACHE" |
| 19 | #define CAL_REGION_RW_MRC_CACHE_SIZE 0x2000 |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 20 | |
Martin Roth | b6a0b26 | 2022-09-05 14:51:34 -0600 | [diff] [blame] | 21 | _Static_assert(sizeof(struct dramc_param) <= CAL_REGION_RW_MRC_CACHE_SIZE, |
| 22 | "sizeof(struct dramc_param) exceeds " CAL_REGION_RW_MRC_CACHE); |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 23 | |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 24 | const char *get_dram_geometry_str(u32 ddr_geometry); |
| 25 | const char *get_dram_type_str(u32 ddr_type); |
| 26 | |
Xi Chen | 555c2ae | 2022-01-21 11:43:53 +0800 | [diff] [blame] | 27 | static const struct ddr_base_info *curr_ddr_info; |
| 28 | |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 29 | static int mt_mem_test(const struct dramc_data *dparam) |
| 30 | { |
| 31 | if (CONFIG(MEMORY_TEST)) { |
| 32 | u8 *addr = _dram; |
| 33 | const struct ddr_base_info *ddr_info = &dparam->ddr_info; |
| 34 | |
| 35 | for (u8 rank = RANK_0; rank < ddr_info->support_ranks; rank++) { |
Xi Chen | 3827f56 | 2020-10-20 17:55:14 +0800 | [diff] [blame] | 36 | int result = complex_mem_test(addr, 0x2000); |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 37 | |
Xi Chen | 3827f56 | 2020-10-20 17:55:14 +0800 | [diff] [blame] | 38 | if (result != 0) { |
| 39 | printk(BIOS_ERR, |
| 40 | "[MEM] complex R/W mem test failed: %d\n", result); |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 41 | return -1; |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 42 | } |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 43 | printk(BIOS_DEBUG, "[MEM] rank %u complex R/W mem test passed\n", rank); |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 44 | |
| 45 | addr += ddr_info->rank_size[rank]; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return 0; |
| 50 | } |
| 51 | |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 52 | const char *get_dram_geometry_str(u32 ddr_geometry) |
| 53 | { |
| 54 | const char *s; |
| 55 | |
| 56 | switch (ddr_geometry) { |
| 57 | case DDR_TYPE_2CH_2RK_4GB_2_2: |
| 58 | s = "2CH_2RK_4GB_2_2"; |
| 59 | break; |
| 60 | case DDR_TYPE_2CH_2RK_6GB_3_3: |
| 61 | s = "2CH_2RK_6GB_3_3"; |
| 62 | break; |
| 63 | case DDR_TYPE_2CH_2RK_8GB_4_4: |
| 64 | s = "2CH_2RK_8GB_4_4"; |
| 65 | break; |
| 66 | case DDR_TYPE_2CH_2RK_8GB_4_4_BYTE: |
| 67 | s = "2CH_2RK_8GB_4_4_BYTE"; |
| 68 | break; |
| 69 | case DDR_TYPE_2CH_1RK_4GB_4_0: |
| 70 | s = "2CH_1RK_4GB_4_0"; |
| 71 | break; |
| 72 | case DDR_TYPE_2CH_2RK_6GB_2_4: |
| 73 | s = "2CH_2RK_6GB_2_4"; |
| 74 | break; |
| 75 | default: |
| 76 | s = ""; |
| 77 | break; |
| 78 | } |
| 79 | |
| 80 | return s; |
| 81 | } |
| 82 | |
| 83 | const char *get_dram_type_str(u32 ddr_type) |
| 84 | { |
| 85 | const char *s; |
| 86 | |
| 87 | switch (ddr_type) { |
| 88 | case DDR_TYPE_DISCRETE: |
| 89 | s = "DSC"; |
| 90 | break; |
| 91 | case DDR_TYPE_EMCP: |
| 92 | s = "EMCP"; |
| 93 | break; |
| 94 | default: |
| 95 | s = ""; |
| 96 | break; |
| 97 | } |
| 98 | |
| 99 | return s; |
| 100 | } |
| 101 | |
Xi Chen | 555c2ae | 2022-01-21 11:43:53 +0800 | [diff] [blame] | 102 | size_t mtk_dram_size(void) |
| 103 | { |
| 104 | size_t size = 0; |
| 105 | |
| 106 | if (!curr_ddr_info) |
| 107 | return 0; |
| 108 | for (unsigned int i = 0; i < RANK_MAX; ++i) |
| 109 | size += curr_ddr_info->mrr_info.mr8_density[i]; |
| 110 | return size; |
| 111 | } |
| 112 | |
| 113 | static void fill_dram_info(struct mem_chip_info *mc, const struct ddr_base_info *ddr) |
| 114 | { |
Julius Werner | 3460aa3 | 2022-10-24 19:06:03 -0700 | [diff] [blame] | 115 | unsigned int c, r; |
Xi Chen | 555c2ae | 2022-01-21 11:43:53 +0800 | [diff] [blame] | 116 | |
Julius Werner | 3460aa3 | 2022-10-24 19:06:03 -0700 | [diff] [blame] | 117 | mc->num_entries = CHANNEL_MAX * ddr->mrr_info.rank_nums; |
| 118 | mc->struct_version = MEM_CHIP_STRUCT_VERSION; |
Xi Chen | 555c2ae | 2022-01-21 11:43:53 +0800 | [diff] [blame] | 119 | |
Julius Werner | 3460aa3 | 2022-10-24 19:06:03 -0700 | [diff] [blame] | 120 | struct mem_chip_entry *entry = mc->entries; |
| 121 | for (c = 0; c < CHANNEL_MAX; c++) { |
| 122 | for (r = 0; r < ddr->mrr_info.rank_nums; r++) { |
| 123 | entry->channel = c; |
| 124 | entry->rank = r; |
| 125 | entry->type = MEM_CHIP_LPDDR4X; |
| 126 | entry->channel_io_width = DQ_DATA_WIDTH_LP4; |
| 127 | entry->density_mbits = ddr->mrr_info.mr8_density[r] / CHANNEL_MAX / |
| 128 | (MiB / 8); |
| 129 | entry->io_width = DQ_DATA_WIDTH_LP4; |
| 130 | entry->manufacturer_id = ddr->mrr_info.mr5_vendor_id; |
| 131 | entry->revision_id[0] = ddr->mrr_info.mr6_revision_id; |
| 132 | entry->revision_id[1] = ddr->mrr_info.mr7_revision_id; |
| 133 | entry++; |
| 134 | } |
Xi Chen | 555c2ae | 2022-01-21 11:43:53 +0800 | [diff] [blame] | 135 | } |
| 136 | } |
| 137 | |
| 138 | static void add_mem_chip_info(int unused) |
| 139 | { |
| 140 | struct mem_chip_info *mc; |
| 141 | size_t size; |
| 142 | |
Rex-BC Chen | c69ea24 | 2022-03-25 15:53:22 +0800 | [diff] [blame] | 143 | if (!CONFIG(USE_CBMEM_DRAM_INFO)) { |
| 144 | printk(BIOS_DEBUG, |
| 145 | "DRAM-K: CBMEM DRAM info is unsupported (USE_CBMEM_DRAM_INFO)\n"); |
| 146 | return; |
| 147 | } |
| 148 | |
Julius Werner | 3460aa3 | 2022-10-24 19:06:03 -0700 | [diff] [blame] | 149 | size = mem_chip_info_size(CHANNEL_MAX * curr_ddr_info->mrr_info.rank_nums); |
Xi Chen | 555c2ae | 2022-01-21 11:43:53 +0800 | [diff] [blame] | 150 | mc = cbmem_add(CBMEM_ID_MEM_CHIP_INFO, size); |
| 151 | assert(mc); |
Julius Werner | 3460aa3 | 2022-10-24 19:06:03 -0700 | [diff] [blame] | 152 | memset(mc, 0, size); |
Xi Chen | 555c2ae | 2022-01-21 11:43:53 +0800 | [diff] [blame] | 153 | |
| 154 | fill_dram_info(mc, curr_ddr_info); |
| 155 | } |
Kyösti Mälkki | fa3bc04 | 2022-03-31 07:40:10 +0300 | [diff] [blame] | 156 | CBMEM_CREATION_HOOK(add_mem_chip_info); |
Xi Chen | 555c2ae | 2022-01-21 11:43:53 +0800 | [diff] [blame] | 157 | |
Xi Chen | 5c7a923 | 2022-01-04 19:00:44 +0800 | [diff] [blame] | 158 | static int run_dram_blob(struct dramc_param *dparam) |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 159 | { |
| 160 | /* Load and run the provided blob for full-calibration if available */ |
| 161 | struct prog dram = PROG_INIT(PROG_REFCODE, CONFIG_CBFS_PREFIX "/dram"); |
| 162 | |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 163 | dump_param_header(dparam); |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 164 | |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 165 | if (cbfs_prog_stage_load(&dram)) { |
| 166 | printk(BIOS_ERR, "DRAM-K: CBFS load program failed\n"); |
| 167 | return -2; |
| 168 | } |
| 169 | |
| 170 | dparam->do_putc = do_putchar; |
| 171 | |
| 172 | prog_set_entry(&dram, prog_entry(&dram), dparam); |
| 173 | prog_run(&dram); |
| 174 | if (dparam->header.status != DRAMC_SUCCESS) { |
Xi Chen | 5c7a923 | 2022-01-04 19:00:44 +0800 | [diff] [blame] | 175 | printk(BIOS_ERR, "DRAM-K: calibration failed: status = %d\n", |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 176 | dparam->header.status); |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 177 | return -3; |
| 178 | } |
| 179 | |
Xi Chen | 5c7a923 | 2022-01-04 19:00:44 +0800 | [diff] [blame] | 180 | if (!(dparam->header.config & DRAMC_CONFIG_FAST_K) |
| 181 | && !(dparam->header.flags & DRAMC_FLAG_HAS_SAVED_DATA)) { |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 182 | printk(BIOS_ERR, |
| 183 | "DRAM-K: Full calibration executed without saving parameters. " |
| 184 | "Please ensure the blob is built properly.\n"); |
| 185 | return -4; |
| 186 | } |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
Xi Chen | 5c7a923 | 2022-01-04 19:00:44 +0800 | [diff] [blame] | 191 | static int dram_run_fast_calibration(struct dramc_param *dparam) |
| 192 | { |
| 193 | const u16 config = CONFIG(MEDIATEK_DRAM_DVFS) ? DRAMC_ENABLE_DVFS : DRAMC_DISABLE_DVFS; |
| 194 | |
| 195 | if (dparam->dramc_datas.ddr_info.config_dvfs != config) { |
| 196 | printk(BIOS_WARNING, |
| 197 | "DRAM-K: Incompatible config for calibration data from flash " |
| 198 | "(expected: %#x, saved: %#x)\n", |
| 199 | config, dparam->dramc_datas.ddr_info.config_dvfs); |
| 200 | return -1; |
| 201 | } |
| 202 | |
| 203 | printk(BIOS_INFO, "DRAM-K: DRAM calibration data valid pass\n"); |
| 204 | |
| 205 | if (CONFIG(MEDIATEK_BLOB_FAST_INIT)) { |
| 206 | printk(BIOS_INFO, "DRAM-K: Run fast calibration run in blob mode\n"); |
| 207 | |
| 208 | /* |
| 209 | * The loaded config should not contain FAST_K (done in full calibration), |
| 210 | * so we have to set that now to indicate the blob taking the config instead |
| 211 | * of generating a new config. |
| 212 | */ |
| 213 | dparam->header.config |= DRAMC_CONFIG_FAST_K; |
| 214 | |
| 215 | if (run_dram_blob(dparam) < 0) |
| 216 | return -3; |
| 217 | } else { |
| 218 | init_dram_by_params(dparam); |
| 219 | } |
| 220 | |
| 221 | if (mt_mem_test(&dparam->dramc_datas) < 0) |
| 222 | return -4; |
| 223 | |
| 224 | return 0; |
| 225 | } |
| 226 | |
| 227 | static int dram_run_full_calibration(struct dramc_param *dparam) |
| 228 | { |
| 229 | initialize_dramc_param(dparam); |
| 230 | |
| 231 | return run_dram_blob(dparam); |
| 232 | } |
| 233 | |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 234 | static void mem_init_set_default_config(struct dramc_param *dparam, |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 235 | const struct sdram_info *dram_info) |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 236 | { |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 237 | u32 type, geometry; |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 238 | memset(dparam, 0, sizeof(*dparam)); |
| 239 | |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 240 | type = dram_info->ddr_type; |
| 241 | geometry = dram_info->ddr_geometry; |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 242 | |
Yu-Ping Wu | c074f61 | 2021-04-12 11:03:57 +0800 | [diff] [blame] | 243 | dparam->dramc_datas.ddr_info.sdram.ddr_type = type; |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 244 | |
| 245 | if (CONFIG(MEDIATEK_DRAM_DVFS)) |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 246 | dparam->dramc_datas.ddr_info.config_dvfs = DRAMC_ENABLE_DVFS; |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 247 | |
Yu-Ping Wu | c074f61 | 2021-04-12 11:03:57 +0800 | [diff] [blame] | 248 | dparam->dramc_datas.ddr_info.sdram.ddr_geometry = geometry; |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 249 | |
| 250 | printk(BIOS_INFO, "DRAM-K: ddr_type: %s, config_dvfs: %d, ddr_geometry: %s\n", |
| 251 | get_dram_type_str(type), |
| 252 | dparam->dramc_datas.ddr_info.config_dvfs, |
| 253 | get_dram_geometry_str(geometry)); |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 254 | } |
| 255 | |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 256 | static void mt_mem_init_run(struct dramc_param *dparam, |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 257 | const struct sdram_info *dram_info) |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 258 | { |
Xi Chen | f4bb77b | 2022-01-21 17:18:45 +0800 | [diff] [blame] | 259 | const ssize_t mrc_cache_size = sizeof(*dparam); |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 260 | ssize_t data_size; |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 261 | struct stopwatch sw; |
| 262 | int ret; |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 263 | |
| 264 | /* Load calibration params from flash and run fast calibration */ |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 265 | data_size = mrc_cache_load_current(MRC_TRAINING_DATA, |
| 266 | DRAMC_PARAM_HEADER_VERSION, |
Xi Chen | f4bb77b | 2022-01-21 17:18:45 +0800 | [diff] [blame] | 267 | dparam, mrc_cache_size); |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 268 | if (data_size == mrc_cache_size) { |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 269 | printk(BIOS_INFO, "DRAM-K: Running fast calibration\n"); |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 270 | stopwatch_init(&sw); |
| 271 | |
| 272 | ret = dram_run_fast_calibration(dparam); |
| 273 | if (ret != 0) { |
| 274 | printk(BIOS_ERR, "DRAM-K: Failed to run fast calibration " |
Rob Barnes | d522f38 | 2022-09-12 06:31:47 -0600 | [diff] [blame] | 275 | "in %lld msecs, error: %d\n", |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 276 | stopwatch_duration_msecs(&sw), ret); |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 277 | |
| 278 | /* Erase flash data after fast calibration failed */ |
Xi Chen | f4bb77b | 2022-01-21 17:18:45 +0800 | [diff] [blame] | 279 | memset(dparam, 0xa5, mrc_cache_size); |
Yu-Ping Wu | ba49444 | 2021-04-15 10:06:27 +0800 | [diff] [blame] | 280 | mrc_cache_stash_data(MRC_TRAINING_DATA, |
| 281 | DRAMC_PARAM_HEADER_VERSION, |
Xi Chen | f4bb77b | 2022-01-21 17:18:45 +0800 | [diff] [blame] | 282 | dparam, mrc_cache_size); |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 283 | } else { |
Rob Barnes | d522f38 | 2022-09-12 06:31:47 -0600 | [diff] [blame] | 284 | printk(BIOS_INFO, "DRAM-K: Fast calibration passed in %lld msecs\n", |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 285 | stopwatch_duration_msecs(&sw)); |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 286 | return; |
| 287 | } |
| 288 | } else { |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 289 | printk(BIOS_WARNING, "DRAM-K: Invalid data in flash (size: %#zx, expected: %#zx)\n", |
| 290 | data_size, mrc_cache_size); |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | /* Run full calibration */ |
| 294 | printk(BIOS_INFO, "DRAM-K: Running full calibration\n"); |
Xi Chen | e8c681c | 2021-03-03 17:58:07 +0800 | [diff] [blame] | 295 | mem_init_set_default_config(dparam, dram_info); |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 296 | |
| 297 | stopwatch_init(&sw); |
| 298 | int err = dram_run_full_calibration(dparam); |
| 299 | if (err == 0) { |
Rob Barnes | d522f38 | 2022-09-12 06:31:47 -0600 | [diff] [blame] | 300 | printk(BIOS_INFO, "DRAM-K: Full calibration passed in %lld msecs\n", |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 301 | stopwatch_duration_msecs(&sw)); |
Yu-Ping Wu | ba49444 | 2021-04-15 10:06:27 +0800 | [diff] [blame] | 302 | mrc_cache_stash_data(MRC_TRAINING_DATA, |
| 303 | DRAMC_PARAM_HEADER_VERSION, |
Xi Chen | f4bb77b | 2022-01-21 17:18:45 +0800 | [diff] [blame] | 304 | dparam, mrc_cache_size); |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 305 | } else { |
Rob Barnes | d522f38 | 2022-09-12 06:31:47 -0600 | [diff] [blame] | 306 | printk(BIOS_ERR, "DRAM-K: Full calibration failed in %lld msecs\n", |
Huayang Duan | 68e597d | 2020-06-22 19:59:40 +0800 | [diff] [blame] | 307 | stopwatch_duration_msecs(&sw)); |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 311 | void mt_mem_init(struct dramc_param *dparam) |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 312 | { |
| 313 | const struct sdram_info *sdram_param = get_sdram_config(); |
| 314 | |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 315 | mt_mem_init_run(dparam, sdram_param); |
| 316 | } |
| 317 | |
| 318 | void mtk_dram_init(void) |
| 319 | { |
| 320 | /* dramc_param is too large to fit in stack. */ |
| 321 | static struct dramc_param dramc_parameter; |
| 322 | mt_mem_init(&dramc_parameter); |
Xi Chen | 555c2ae | 2022-01-21 11:43:53 +0800 | [diff] [blame] | 323 | curr_ddr_info = &dramc_parameter.dramc_datas.ddr_info; |
Yu-Ping Wu | 71c5ca7 | 2021-01-13 10:29:18 +0800 | [diff] [blame] | 324 | mtk_mmu_after_dram(); |
Huayang Duan | c90a9e6 | 2020-06-22 19:52:45 +0800 | [diff] [blame] | 325 | } |