blob: 9d4691c396cda5de2a8bfb78a68db931192aa6b6 [file] [log] [blame]
Angel Ponse67ab182020-04-04 18:51:11 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Peter Kaoda1e02a2015-07-31 17:11:14 +08002
Peter Kaoda1e02a2015-07-31 17:11:14 +08003#include <assert.h>
4#include <console/console.h>
5#include <soc/addressmap.h>
6#include <soc/dramc_register.h>
7#include <soc/dramc_pi_api.h>
8#include <soc/emi.h>
9#include <soc/pll.h>
Tristan Shieh79b990d2018-08-10 14:46:31 +080010#include <symbols.h>
Peter Kaoda1e02a2015-07-31 17:11:14 +080011
12void mt_mem_init(const struct mt8173_sdram_params *sdram_params)
13{
14 int i = 0;
15
16 /* init mempll */
17 mem_pll_init(sdram_params);
18
19 /* memory calibration */
20 mt_set_emi(sdram_params);
21
Julius Wernercd49cce2019-03-05 16:53:33 -080022 if (CONFIG(MEMORY_TEST)) {
Paul Menzel454cfa02017-10-24 15:38:51 +020023 /*
24 * do memory test:
Peter Kaoda1e02a2015-07-31 17:11:14 +080025 * set memory scan range 0x2000
26 * larger test length, longer system boot up time
27 */
Tristan Shieh79b990d2018-08-10 14:46:31 +080028 i = complex_mem_test(_dram, 0x2000);
Peter Kaoda1e02a2015-07-31 17:11:14 +080029
30 printk(BIOS_DEBUG, "[MEM] complex R/W mem test %s : %d\n",
31 (i == 0) ? "pass" : "fail", i);
32
33 ASSERT(i == 0);
34 }
35}