coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
romstage.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #include <string.h>
3 #include <baseboard/variants.h>
4 #include <soc/meminit.h>
5 #include <soc/romstage.h>
6 
7 #define BOARD_ID_GLK_RVP1_DDR4 0x5 /* GLK RVP1 - DDR4 */
8 #define BOARD_ID_GLK_RVP2_LP4SD 0x7 /* GLK RVP2 - LP4 Solder Down */
9 #define BOARD_ID_GLK_RVP2_LP4 0x8 /* RVP2 - LP4 Socket */
10 
11 /* DDR4 specific swizzling data start */
12 
13 /* Channel 0 PHY 0 to DUnit DQ mapping */
14 static const uint8_t swizzling_ch0_ddr4[] = {
15  15, 14, 10, 11, 8, 9, 13, 12, 2, 7, 3, 6, 4, 0, 1, 5,
16  29, 31, 27, 26, 24, 28, 25, 30, 19, 22, 18, 21, 23, 16, 17, 20,
17 };
18 
19 /* Channel 1 PHY 0 to DUnit DQ mapping */
20 static const uint8_t swizzling_ch1_ddr4[] = {
21  1, 0, 4, 5, 7, 2, 6, 3, 24, 25, 28, 30, 26, 27, 31, 29,
22  21, 20, 17, 16, 23, 22, 19, 18, 8, 12, 11, 15, 10, 9, 13, 14,
23 };
24 
25 /* Channel 1 PHY 1 to DUnit DQ mapping */
26 static const uint8_t swizzling_ch2_ddr4[] = {
27  14, 12, 9, 13, 10, 15, 11, 8, 1, 3, 7, 5, 2, 6, 0, 4,
28  27, 24, 29, 28, 30, 26, 31, 25, 19, 20, 18, 22, 16, 21, 23, 17,
29 };
30 
31 /* Channel 0 PHY 1 to DUnit DQ mapping */
32 static const uint8_t swizzling_ch3_ddr4[] = {
33  12, 8, 13, 9, 15, 11, 14, 10, 0, 5, 1, 4, 7, 2, 6, 3,
34  20, 16, 21, 17, 19, 18, 22, 23, 29, 24, 28, 26, 25, 30, 31, 27
35 };
36 /* DDR4 specific swizzling data end*/
37 
38 /* LPDD4 specific swizzling data start */
39 
40 /* Channel 0 PHY 0 to DUnit DQ mapping */
41 static const uint8_t swizzling_ch0_lpddr4[] = {
42  10, 8, 12, 11, 9, 13, 14, 15, 1, 3, 2, 0, 5, 4, 6, 7,
43  30, 26, 24, 25, 28, 29, 31, 27, 20, 21, 22, 16, 23, 17, 18, 19,
44 };
45 
46 /* Channel 1 PHY 0 to DUnit DQ mapping */
47 static const uint8_t swizzling_ch1_lpddr4[] = {
48  0, 6, 7, 5, 3, 2, 1, 4, 12, 15, 13, 8, 9, 10, 11, 14,
49  17, 18, 19, 16, 23, 20, 21, 22, 30, 31, 25, 27, 26, 29, 28, 24,
50 };
51 
52 /* Channel 1 PHY 1 to DUnit DQ mapping */
53 static const uint8_t swizzling_ch2_lpddr4[] = {
54  15, 8, 11, 10, 14, 12, 13, 9, 5, 1, 0, 6, 2, 3, 7, 4,
55  31, 25, 24, 27, 30, 29, 28, 26, 21, 18, 20, 23, 16, 17, 22, 19,
56 };
57 
58 /* Channel 0 PHY 1 to DUnit DQ mapping */
59 static const uint8_t swizzling_ch3_lpddr4[] = {
60  15, 9, 8, 10, 13, 14, 12, 11, 7, 6, 5, 0, 4, 2, 1, 3,
61  20, 21, 23, 22, 19, 17, 18, 16, 24, 27, 26, 30, 25, 31, 28, 29
62 };
63 /* LPDD4 specific swizzling data end */
64 
66 {
67  cfg->Package = 1;
68  cfg->MemoryDown = 1;
69  cfg->DDR3LPageSize = 0;
70  cfg->DDR3LASR = 0;
71  cfg->ScramblerSupport = 1;
72  cfg->ChannelHashMask = 0x36;
73  cfg->SliceHashMask = 0x9;
74  cfg->InterleavedMode = 2;
75  cfg->ChannelsSlicesEnable = 0;
76  cfg->MinRefRate2xEnable = 0;
77  cfg->DualRankSupportEnable = 0;
78  cfg->DisableFastBoot = 0;
79  cfg->RmtMode = 0;
80  cfg->RmtCheckRun = 0;
81  cfg->RmtMarginCheckScaleHighThreshold = 0;
82  cfg->MemorySizeLimit = 0;
83  cfg->LowMemoryMaxValue = 0;
84  cfg->HighMemoryMaxValue = 0;
85  cfg->Profile = 7;
86  cfg->DIMM0SPDAddress = 0x00;
87  cfg->DIMM1SPDAddress = 0x00;
88  cfg->Ch0_RankEnable = 0x1;
89  cfg->Ch0_DeviceWidth = 0x1;
90  cfg->Ch0_DramDensity = 0x2;
91  cfg->Ch0_Option = 0x3;
92  cfg->Ch0_TristateClk1 = 0;
93  cfg->Ch0_Mode2N = 0;
94  cfg->Ch0_OdtLevels = 0;
95  cfg->Ch1_RankEnable = 0x1;
96  cfg->Ch1_DeviceWidth = 0x1;
97  cfg->Ch1_DramDensity = 0x2;
98  cfg->Ch1_Option = 0x3;
99  cfg->Ch1_TristateClk1 = 0;
100  cfg->Ch1_Mode2N = 0;
101  cfg->Ch1_OdtLevels = 0;
102  cfg->Ch2_RankEnable = 0x1;
103  cfg->Ch2_DeviceWidth = 0x1;
104  cfg->Ch2_DramDensity = 0x2;
105  cfg->Ch2_Option = 0x3;
106  cfg->Ch2_TristateClk1 = 0;
107  cfg->Ch2_Mode2N = 0;
108  cfg->Ch2_OdtLevels = 0;
109  cfg->Ch3_RankEnable = 0x1;
110  cfg->Ch3_DeviceWidth = 0x1;
111  cfg->Ch3_DramDensity = 0x2;
112  cfg->Ch3_Option = 0x3;
113  cfg->Ch3_TristateClk1 = 0;
114  cfg->Ch3_Mode2N = 0;
115  cfg->Ch3_OdtLevels = 0;
116  /* phy0 ch0 */
117  memcpy(cfg->Ch0_Bit_swizzling, swizzling_ch0_lpddr4,
118  sizeof(swizzling_ch0_lpddr4));
119  /* phy0 ch1 */
120  memcpy(cfg->Ch1_Bit_swizzling, swizzling_ch1_lpddr4,
121  sizeof(swizzling_ch1_lpddr4));
122  /* phy1 ch1 */
123  memcpy(cfg->Ch2_Bit_swizzling, swizzling_ch2_lpddr4,
124  sizeof(swizzling_ch2_lpddr4));
125  /* phy1 ch0 */
126  memcpy(cfg->Ch3_Bit_swizzling, swizzling_ch3_lpddr4,
127  sizeof(swizzling_ch3_lpddr4));
128 }
129 
131 {
132  cfg->Package = 0; /* 0x1:BGA */
133  cfg->MemoryDown = 0;
134  cfg->DDR3LPageSize = 1;
135  cfg->DDR3LASR = 0;
136  cfg->ScramblerSupport = 0;
137  cfg->ChannelHashMask = 0x36;
138  cfg->SliceHashMask = 0x9;
139  cfg->InterleavedMode = 0;
140  cfg->ChannelsSlicesEnable = 0;
141  cfg->MinRefRate2xEnable = 0;
142  cfg->DualRankSupportEnable = 1;
143  cfg->DisableFastBoot = 0;
144  cfg->RmtMode = 0;
145  cfg->RmtCheckRun = 0;
146  cfg->RmtMarginCheckScaleHighThreshold = 0;
147  cfg->MemorySizeLimit = 0;
148  cfg->LowMemoryMaxValue = 0;
149  cfg->HighMemoryMaxValue = 0;
150  cfg->Profile = 11;
151  cfg->DIMM0SPDAddress = 0xA0;
152  cfg->DIMM1SPDAddress = 0xA4;
153  cfg->Ch0_RankEnable = 0x3;
154  cfg->Ch0_DeviceWidth = 0x1;
155  cfg->Ch0_DramDensity = 0x0;
156  cfg->Ch0_Option = 0x3; /* Bank Address Hashing enabled */
157  cfg->Ch0_TristateClk1 = 0;
158  cfg->Ch0_Mode2N = 0;
159  cfg->Ch0_OdtLevels = 0;
160  cfg->Ch1_RankEnable = 0x3;
161  cfg->Ch1_DeviceWidth = 0x1;
162  cfg->Ch1_DramDensity = 0x2;
163  cfg->Ch1_Option = 0x3; /* Bank Address Hashing enabled */
164  cfg->Ch1_TristateClk1 = 0;
165  cfg->Ch1_Mode2N = 0;
166  cfg->Ch1_OdtLevels = 0;
167  cfg->Ch2_RankEnable = 0x0;
168  cfg->Ch2_DeviceWidth = 0x1;
169  cfg->Ch2_DramDensity = 0x2;
170  cfg->Ch2_Option = 0x3; /* Bank Address Hashing enabled */
171  cfg->Ch2_TristateClk1 = 0;
172  cfg->Ch2_Mode2N = 0;
173  cfg->Ch2_OdtLevels = 0;
174  cfg->Ch3_RankEnable = 0x0;
175  cfg->Ch3_DeviceWidth = 0x1;
176  cfg->Ch3_DramDensity = 0x2;
177  cfg->Ch3_Option = 0x3; /* Bank Address Hashing enabled */
178  cfg->Ch3_TristateClk1 = 0;
179  cfg->Ch3_Mode2N = 0;
180  cfg->Ch3_OdtLevels = 0;
181 
182  /* phy0 ch0 */
183  memcpy(cfg->Ch0_Bit_swizzling, swizzling_ch0_ddr4,
184  sizeof(swizzling_ch0_ddr4));
185  /* phy0 ch1 */
186  memcpy(cfg->Ch1_Bit_swizzling, swizzling_ch1_ddr4,
187  sizeof(swizzling_ch1_ddr4));
188  /* phy1 ch1 */
189  memcpy(cfg->Ch2_Bit_swizzling, swizzling_ch2_ddr4,
190  sizeof(swizzling_ch2_ddr4));
191  /* phy1 ch0 */
192  memcpy(cfg->Ch3_Bit_swizzling, swizzling_ch3_ddr4,
193  sizeof(swizzling_ch3_ddr4));
194 }
195 
197 {
198  uint8_t boardid;
199 
200  if (CONFIG(IS_GLK_RVP_1))
201  boardid = BOARD_ID_GLK_RVP1_DDR4;
202  else
203  boardid = BOARD_ID_GLK_RVP2_LP4;
204 
205  switch (boardid) {
207  fill_ddr4_params(cfg);
208  break;
211  fill_lpddr4_params(cfg);
212  break;
213  }
214 }
215 
216 void mainboard_memory_init_params(FSPM_UPD *memupd)
217 {
218  FSP_M_CONFIG *cfg = &memupd->FspmConfig;
219  fill_memory_params(cfg);
220 }
221 
223 {
225 }
void save_lpddr4_dimm_info(const struct lpddr4_cfg *lpcfg, size_t mem_sku)
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
__weak void mainboard_save_dimm_info(struct romstage_params *params)
Definition: romstage.c:138
@ CONFIG
Definition: dsi_common.h:201
#define FSP_M_CONFIG
Definition: fsp_upd.h:8
const struct lpddr4_cfg * variant_lpddr4_config(void)
Definition: memory.c:190
void mainboard_memory_init_params(FSPM_UPD *mupd)
Definition: romstage.c:22
int __weak variant_memory_sku(void)
Definition: memory.c:74
static void fill_memory_params(FSP_M_CONFIG *cfg)
Definition: romstage.c:196
static const uint8_t swizzling_ch3_lpddr4[]
Definition: romstage.c:59
#define BOARD_ID_GLK_RVP1_DDR4
Definition: romstage.c:7
static void fill_ddr4_params(FSP_M_CONFIG *cfg)
Definition: romstage.c:130
static const uint8_t swizzling_ch3_ddr4[]
Definition: romstage.c:32
static const uint8_t swizzling_ch2_ddr4[]
Definition: romstage.c:26
static const uint8_t swizzling_ch1_lpddr4[]
Definition: romstage.c:47
#define BOARD_ID_GLK_RVP2_LP4SD
Definition: romstage.c:8
static const uint8_t swizzling_ch0_ddr4[]
Definition: romstage.c:14
static const uint8_t swizzling_ch1_ddr4[]
Definition: romstage.c:20
static const uint8_t swizzling_ch0_lpddr4[]
Definition: romstage.c:41
#define BOARD_ID_GLK_RVP2_LP4
Definition: romstage.c:9
static const uint8_t swizzling_ch2_lpddr4[]
Definition: romstage.c:53
static void fill_lpddr4_params(FSP_M_CONFIG *cfg)
Definition: romstage.c:65
unsigned char uint8_t
Definition: stdint.h:8