summaryrefslogtreecommitdiff
path: root/plat/marvell/a8k-p/a8xxy/board/dram_port.c
blob: 673b10bde0d5ed177c479bebbd20ed028ae5a22c (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
 * Copyright (C) 2017 Marvell International Ltd.
 *
 * SPDX-License-Identifier:	BSD-3-Clause
 * https://spdx.org/licenses
 */

#include <plat_marvell.h>
#include <mv_ddr_if.h>
#include <plat_def.h>

/* DB-88F8160-MODULAR has 4 DIMMs on board that are connected to
 * AP2 I2C bus-0 at the following addresses:
 * AP0 DIMM0 - 0x53
 * AP0 DIMM1 - 0x54
 * AP1 DIMM0 - 0x55
 * AP1 DIMM1 - 0x56
 */
#define I2C_SPD_BASE_ADDR		0x53
#define I2C_SPD_DATA_ADDR(ap_id, iface)	(I2C_SPD_BASE_ADDR + (ap_id * DDR_MAX_UNIT_PER_AP) + (iface))
#define I2C_SPD_P0_SEL_ADDR		0x36	/* Select SPD data page 0 */

#define MC_RAR_INTERLEAVE_SZ		(128) /* Also possible to set to 4Kb */

uint32_t dram_rar_interleave(void)
{
	return MC_RAR_INTERLEAVE_SZ;
}

/*
 * This struct provides the DRAM training code with
 * the appropriate board DRAM configuration
 */
struct mv_ddr_iface dram_iface_ap0[DDR_MAX_UNIT_PER_AP] = {
	{
		.state = MV_DDR_IFACE_NRDY,
		.id = 0,
		.spd_data_addr = I2C_SPD_DATA_ADDR(0, 0),
		.spd_page_sel_addr = I2C_SPD_P0_SEL_ADDR,
		.tm = {
			/* MISL board with 1CS 8Gb x4 devices of Micron 2400T */
			DEBUG_LEVEL_ERROR,
			0x1, /* active interfaces */
			/* cs_mask, mirror, dqs_swap, ck_swap X subphys */
			{ { { {0x1, 0x0, 0, 0},	/* FIXME: change the cs mask for all 64 bit */
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0} },
			/* TODO: double check if the speed bin is 2400T */
			SPEED_BIN_DDR_2400T,		/* speed_bin */
			MV_DDR_DEV_WIDTH_8BIT,	/* sdram device width */
			MV_DDR_DIE_CAP_8GBIT,	/* die capacity */
			MV_DDR_FREQ_SAR,		/* frequency */
			0, 0,			/* cas_l, cas_wl */
			MV_DDR_TEMP_LOW} },		/* temperature */
			MV_DDR_64BIT_ECC_PUP8_BUS_MASK, /* subphys mask */
			MV_DDR_CFG_SPD,			/* ddr configuration data source */
			{ {0} },			/* raw spd data */
			{0}				/* timing parameters */
		},
	},
	{
		.state = MV_DDR_IFACE_NRDY,
		.id = 1,
		.spd_data_addr = I2C_SPD_DATA_ADDR(0, 1),
		.spd_page_sel_addr = I2C_SPD_P0_SEL_ADDR,
		.tm = {
			/* MISL board with 1CS 8Gb x4 devices of Micron 2400T */
			DEBUG_LEVEL_ERROR,
			0x1, /* active interfaces */
			/* cs_mask, mirror, dqs_swap, ck_swap X subphys */
			{ { { {0x1, 0x0, 0, 0},	/* FIXME: change the cs mask for all 64 bit */
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0} },
			/* TODO: double check if the speed bin is 2400T */
			SPEED_BIN_DDR_2400T,		/* speed_bin */
			MV_DDR_DEV_WIDTH_8BIT,	/* sdram device width */
			MV_DDR_DIE_CAP_8GBIT,	/* die capacity */
			MV_DDR_FREQ_SAR,		/* frequency */
			0, 0,			/* cas_l, cas_wl */
			MV_DDR_TEMP_LOW} },		/* temperature */
			MV_DDR_64BIT_ECC_PUP8_BUS_MASK, /* subphys mask */
			MV_DDR_CFG_SPD,			/* ddr configuration data source */
			{ {0} },			/* raw spd data */
			{0}				/* timing parameters */
		},
	},
};
struct mv_ddr_iface dram_iface_ap1[DDR_MAX_UNIT_PER_AP] = {
	{
		.state = MV_DDR_IFACE_NRDY,
		.id = 0,
		.spd_data_addr = I2C_SPD_DATA_ADDR(1, 0),
		.spd_page_sel_addr = I2C_SPD_P0_SEL_ADDR,
		.tm = {
			/* MISL board with 1CS 8Gb x4 devices of Micron 2400T */
			DEBUG_LEVEL_ERROR,
			0x1, /* active interfaces */
			/* cs_mask, mirror, dqs_swap, ck_swap X subphys */
			{ { { {0x1, 0x0, 0, 0},	/* FIXME: change the cs mask for all 64 bit */
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0} },
			/* TODO: double check if the speed bin is 2400T */
			SPEED_BIN_DDR_2400T,		/* speed_bin */
			MV_DDR_DEV_WIDTH_8BIT,	/* sdram device width */
			MV_DDR_DIE_CAP_8GBIT,	/* die capacity */
			MV_DDR_FREQ_SAR,		/* frequency */
			0, 0,			/* cas_l, cas_wl */
			MV_DDR_TEMP_LOW} },		/* temperature */
			MV_DDR_64BIT_ECC_PUP8_BUS_MASK, /* subphys mask */
			MV_DDR_CFG_SPD,			/* ddr configuration data source */
			{ {0} },			/* raw spd data */
			{0}				/* timing parameters */
		},
	},
	{
		.state = MV_DDR_IFACE_NRDY,
		.id = 1,
		.spd_data_addr = I2C_SPD_DATA_ADDR(1, 1),
		.spd_page_sel_addr = I2C_SPD_P0_SEL_ADDR,
		.tm = {
			/* MISL board with 1CS 8Gb x4 devices of Micron 2400T */
			DEBUG_LEVEL_ERROR,
			0x1, /* active interfaces */
			/* cs_mask, mirror, dqs_swap, ck_swap X subphys */
			{ { { {0x1, 0x0, 0, 0},	/* FIXME: change the cs mask for all 64 bit */
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0},
				    {0x1, 0x0, 0, 0} },
			/* TODO: double check if the speed bin is 2400T */
			SPEED_BIN_DDR_2400T,		/* speed_bin */
			MV_DDR_DEV_WIDTH_8BIT,	/* sdram device width */
			MV_DDR_DIE_CAP_8GBIT,	/* die capacity */
			MV_DDR_FREQ_SAR,		/* frequency */
			0, 0,			/* cas_l, cas_wl */
			MV_DDR_TEMP_LOW} },		/* temperature */
			MV_DDR_64BIT_ECC_PUP8_BUS_MASK, /* subphys mask */
			MV_DDR_CFG_SPD,			/* ddr configuration data source */
			{ {0} },			/* raw spd data */
			{0}				/* timing parameters */
		},
	},
};

/* Pointer to the first DRAM interface in the system */
struct mv_ddr_iface *ptr_iface = &dram_iface_ap0[0];