summaryrefslogtreecommitdiff
path: root/plat/imx/imx8m/include/dram.h
blob: 161820545e760ae6e29284f2812fafb6ab7d4ac6 (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
/*
 * Copyright 2019 NXP
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#ifndef DRAM_H
#define DRAM_H

#include <lib/utils_def.h>
#include <arch_helpers.h>
#include <assert.h>

#include <ddrc.h>
#include <platform_def.h>

#define DDRC_LPDDR4		BIT(5)
#define DDRC_DDR4		BIT(4)
#define DDRC_DDR3L		BIT(0)
#define DDR_TYPE_MASK		U(0x3f)
#define ACTIVE_RANK_MASK	U(0x3)

/* reg & config param */
struct dram_cfg_param {
	unsigned int reg;
	unsigned int val;
};

struct dram_timing_info {
	/* umctl2 config */
	struct dram_cfg_param *ddrc_cfg;
	unsigned int ddrc_cfg_num;
	/* ddrphy config */
	struct dram_cfg_param *ddrphy_cfg;
	unsigned int ddrphy_cfg_num;
	/* ddr fsp train info */
	struct dram_fsp_msg *fsp_msg;
	unsigned int fsp_msg_num;
	/* ddr phy trained CSR */
	struct dram_cfg_param *ddrphy_trained_csr;
	unsigned int ddrphy_trained_csr_num;
	/* ddr phy PIE */
	struct dram_cfg_param *ddrphy_pie;
	unsigned int ddrphy_pie_num;
	/* initialized fsp table */
	unsigned int fsp_table[4];
};

struct dram_info {
	int dram_type;
	unsigned int num_rank;
	int current_fsp;
	int boot_fsp;
	struct dram_timing_info *timing_info;
};

extern struct dram_info dram_info;

void dram_info_init(unsigned long dram_timing_base);
void dram_umctl2_init(struct dram_timing_info *timing);
void dram_phy_init(struct dram_timing_info *timing);

/* dram retention */
void dram_enter_retention(void);
void dram_exit_retention(void);

#endif /* DRAM_H */