blob: e1e4524ea739bf065a2f20e4b76e35d1e03a2f47 [file] [log] [blame]
Daisuke Nojiria6712f32015-01-23 10:06:19 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2015 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Daisuke Nojiria6712f32015-01-23 10:06:19 -080014 */
15#include <console/console.h>
Icarus Chaud5f551a2015-02-13 15:16:37 -080016#include <symbols.h>
Daisuke Nojiria6712f32015-01-23 10:06:19 -080017#include <soc/sdram.h>
18
Icarus Chaud5f551a2015-02-13 15:16:37 -080019#define DRAM_TEST_LEN 0x8000000
20
21static void test_ddr(void)
22{
23 if (IS_ENABLED(CONFIG_CYGNUS_SDRAM_TEST_DDR)) {
24 uint32_t *test_buffer = (uint32_t *) _dram;
25 uint32_t len = DRAM_TEST_LEN;
26 uint32_t i;
27 uint32_t fail_count = 0;
28
29 printk(BIOS_INFO, "test ddr start from 0x%p to 0x%p\n", test_buffer,
30 test_buffer + len);
31
32 for (i = 0; i < len; i++)
33 *(test_buffer + i) = i;
34
35 for (i = 0; i < len; i++) {
36 int val = *(test_buffer + i);
37
38 if ((i % 0x10000) == 0)
39 printk(BIOS_INFO, "#");
40
41 if (i != val) {
42 printk(BIOS_ERR, "\ntest_ddr: @ 0x%p: %d != %d\n",
43 test_buffer + i, i, val);
44 fail_count++;
45 }
46 }
47 printk(BIOS_INFO, "\ntest ddr end: fail=%d\n", fail_count);
48 }
49}
50
Daisuke Nojiria6712f32015-01-23 10:06:19 -080051void sdram_init(void)
52{
Icarus Chaud5f551a2015-02-13 15:16:37 -080053 printk(BIOS_INFO, "sdram initialization is in progress...\n");
54 ddr_init2();
55 printk(BIOS_INFO, "sdram initialization is completed.\n");
56
57 test_ddr();
Daisuke Nojiria6712f32015-01-23 10:06:19 -080058}
Daisuke Nojiri99d39562015-03-02 14:38:37 -080059
60uint32_t sdram_size_mb(void)
61{
62 return CONFIG_DRAM_SIZE_MB;
63}