blob: bf549bfa9f0c0a2a050b2d7433f71b635f8c96cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* This file is part of the coreboot project.
*
* Copyright 2016 Philipp Hug <philipp@hug.cx>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <soc/sdram.h>
#include <soc/addressmap.h>
#include "regconfig-phy.h"
#include "regconfig-ctl.h"
#include "ux00ddr.h"
#define DENALI_PHY_DATA ddr_phy_settings
#define DENALI_CTL_DATA ddr_ctl_settings
#include "ddrregs.h"
#define DDR_SIZE (8UL * 1024UL * 1024UL * 1024UL)
void sdram_init(void)
{
ux00ddr_writeregmap(FU540_DDRCTRL, ddr_ctl_settings, ddr_phy_settings);
ux00ddr_disableaxireadinterleave(FU540_DDRCTRL);
ux00ddr_disableoptimalrmodw(FU540_DDRCTRL);
ux00ddr_enablewriteleveling(FU540_DDRCTRL);
ux00ddr_enablereadleveling(FU540_DDRCTRL);
ux00ddr_enablereadlevelinggate(FU540_DDRCTRL);
if (ux00ddr_getdramclass(FU540_DDRCTRL) == DRAM_CLASS_DDR4)
ux00ddr_enablevreftraining(FU540_DDRCTRL);
//mask off interrupts for leveling completion
ux00ddr_mask_leveling_completed_interrupt(FU540_DDRCTRL);
ux00ddr_mask_mc_init_complete_interrupt(FU540_DDRCTRL);
ux00ddr_mask_outofrange_interrupts(FU540_DDRCTRL);
ux00ddr_setuprangeprotection(FU540_DDRCTRL, DDR_SIZE);
ux00ddr_mask_port_command_error_interrupt(FU540_DDRCTRL);
const uint64_t ddr_size = DDR_SIZE;
const uint64_t ddr_end = FU540_DRAM + ddr_size;
ux00ddr_start(FU540_DDRCTRL, FU540_DDRBUSBLOCKER, ddr_end);
ux00ddr_phy_fixup(FU540_DDRCTRL);
}
size_t sdram_size_mb(void)
{
static size_t size_mb = 0;
if (!size_mb) {
// TODO: implement
size_mb = 8 * 1024;
}
return size_mb;
}
|