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 
3 #include <gpio.h>
4 #include <soc/meminit.h>
5 #include <soc/romstage.h>
6 #include <string.h>
7 
8 static const struct lpddr4_sku skus[] = {
9  [0] = {
11  .ch0_rank_density = LP4_8Gb_DENSITY,
12  .ch1_rank_density = LP4_8Gb_DENSITY,
13  .ch0_dual_rank = 1,
14  .ch1_dual_rank = 1,
15  .part_num = "D9SKJ",
16  },
17 };
18 
19 static const struct lpddr4_cfg lp4cfg = {
20  .skus = skus,
21  .num_skus = ARRAY_SIZE(skus),
22 };
23 
24 static const uint8_t ch0_bit_swizzling[] = {
25  0x0f, 0x0b, 0x0d, 0x0e, 0x09, 0x0c, 0x0a, 0x08,
26  0x06, 0x04, 0x05, 0x07, 0x03, 0x02, 0x01, 0x00,
27  0x1e, 0x19, 0x18, 0x1c, 0x1d, 0x1b, 0x1f, 0x1a,
28  0x14, 0x15, 0x17, 0x10, 0x16, 0x12, 0x11, 0x13
29 };
30 
31 static const uint8_t ch1_bit_swizzling[] = {
32  0x03, 0x05, 0x06, 0x07, 0x01, 0x04, 0x02, 0x00,
33  0x0c, 0x0d, 0x0e, 0x0b, 0x0a, 0x08, 0x09, 0x0f,
34  0x10, 0x16, 0x15, 0x13, 0x14, 0x17, 0x12, 0x11,
35  0x1f, 0x1e, 0x1b, 0x19, 0x18, 0x1d, 0x1c, 0x1a
36 };
37 
38 static const uint8_t ch2_bit_swizzling[] = {
39  0x08, 0x0d, 0x0b, 0x0e, 0x09, 0x0f, 0x0c, 0x0a,
40  0x04, 0x00, 0x02, 0x06, 0x05, 0x07, 0x03, 0x01,
41  0x1b, 0x1c, 0x1f, 0x1d, 0x1a, 0x18, 0x19, 0x1e,
42  0x17, 0x12, 0x15, 0x16, 0x13, 0x10, 0x14, 0x11
43 };
44 
45 static const uint8_t ch3_bit_swizzling[] = {
46  0x03, 0x07, 0x06, 0x05, 0x01, 0x04, 0x02, 0x00,
47  0x0c, 0x0f, 0x0d, 0x0e, 0x0a, 0x08, 0x09, 0x0b,
48  0x10, 0x11, 0x12, 0x13, 0x16, 0x14, 0x17, 0x15,
49  0x1c, 0x1e, 0x1d, 0x19, 0x1f, 0x18, 0x1b, 0x1a
50 };
51 
52 void mainboard_memory_init_params(FSPM_UPD *memupd)
53 {
54  FSP_M_CONFIG *config = &memupd->FspmConfig;
55 
56  config->Package = 0x01,
57  config->Profile = 0x06,
58  config->MemoryDown = 0x01,
59  config->DDR3LPageSize = 0x01,
60  config->DDR3LASR = 0x00,
61  config->ScramblerSupport = 0x01,
62  config->ChannelHashMask = 0x36,
63  config->SliceHashMask = 0x09,
64  config->InterleavedMode = 0x02,
65  config->ChannelsSlicesEnable = 0x00,
66  config->MinRefRate2xEnable = 0x00,
67  config->DualRankSupportEnable = 0x01,
68  config->RmtMode = 0x00,
69  config->MemorySizeLimit = 0x00,
70  config->LowMemoryMaxValue = 0x00,
71  config->DisableFastBoot = 0x00,
72  config->HighMemoryMaxValue = 0x00,
73  config->DIMM0SPDAddress = 0x00,
74  config->DIMM1SPDAddress = 0x00,
75 
76  config->Ch0_RankEnable = 0x03,
77  config->Ch0_DeviceWidth = 0x01,
78  config->Ch0_DramDensity = 0x02,
79  config->Ch0_Option = 0x03,
80  config->Ch0_OdtConfig = 0x02,
81  config->Ch0_TristateClk1 = 0x00,
82  config->Ch0_Mode2N = 0x00,
83  config->Ch0_OdtLevels = 0x00,
84 
85  config->Ch1_RankEnable = 0x03,
86  config->Ch1_DeviceWidth = 0x01,
87  config->Ch1_DramDensity = 0x02,
88  config->Ch1_Option = 0x03,
89  config->Ch1_OdtConfig = 0x02,
90  config->Ch1_TristateClk1 = 0x00,
91  config->Ch1_Mode2N = 0x00,
92  config->Ch1_OdtLevels = 0x00,
93 
94  config->Ch2_RankEnable = 0x03,
95  config->Ch2_DeviceWidth = 0x01,
96  config->Ch2_DramDensity = 0x02,
97  config->Ch2_Option = 0x03,
98  config->Ch2_OdtConfig = 0x00,
99  config->Ch2_TristateClk1 = 0x00,
100  config->Ch2_Mode2N = 0x00,
101  config->Ch2_OdtLevels = 0x00,
102 
103  config->Ch3_RankEnable = 0x03,
104  config->Ch3_DeviceWidth = 0x01,
105  config->Ch3_DramDensity = 0x02,
106  config->Ch3_Option = 0x03,
107  config->Ch3_OdtConfig = 0x00,
108  config->Ch3_TristateClk1 = 0x00,
109  config->Ch3_Mode2N = 0x00,
110  config->Ch3_OdtLevels = 0x00,
111 
112  config->RmtCheckRun = 0x00,
113  config->RmtMarginCheckScaleHighThreshold = 0x00;
114  config->MsgLevelMask = 0x00;
115 
116  memcpy(config->Ch0_Bit_swizzling, &ch0_bit_swizzling,
117  sizeof(ch0_bit_swizzling));
118  memcpy(config->Ch1_Bit_swizzling, &ch1_bit_swizzling,
119  sizeof(ch1_bit_swizzling));
120  memcpy(config->Ch2_Bit_swizzling, &ch2_bit_swizzling,
121  sizeof(ch2_bit_swizzling));
122  memcpy(config->Ch3_Bit_swizzling, &ch3_bit_swizzling,
123  sizeof(ch3_bit_swizzling));
124 }
125 
127 {
129 }
void save_lpddr4_dimm_info(const struct lpddr4_cfg *lpcfg, size_t mem_sku)
@ LP4_SPEED_2133
Definition: meminit.h:48
@ LP4_8Gb_DENSITY
Definition: meminit.h:56
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
#define ARRAY_SIZE(a)
Definition: helpers.h:12
__weak void mainboard_save_dimm_info(struct romstage_params *params)
Definition: romstage.c:138
#define FSP_M_CONFIG
Definition: fsp_upd.h:8
void mainboard_memory_init_params(FSPM_UPD *mupd)
Definition: romstage.c:22
enum board_config config
Definition: memory.c:448
static const struct lpddr4_cfg lp4cfg
Definition: romstage.c:19
static const struct lpddr4_sku skus[]
Definition: romstage.c:8
static const uint8_t ch1_bit_swizzling[]
Definition: romstage.c:31
static const uint8_t ch3_bit_swizzling[]
Definition: romstage.c:45
static const uint8_t ch0_bit_swizzling[]
Definition: romstage.c:24
static const uint8_t ch2_bit_swizzling[]
Definition: romstage.c:38
unsigned char uint8_t
Definition: stdint.h:8
const struct lpddr4_sku * skus
Definition: meminit.h:112
int speed
Definition: meminit.h:102