coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
meminit.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _SOC_APOLLOLAKE_MEMINIT_H_
4 #define _SOC_APOLLOLAKE_MEMINIT_H_
5 
6 #include <stddef.h>
7 #include <stdint.h>
8 #include <fsp/soc_binding.h>
9 
10 /*
11  * LPDDR4 helper routines for configuring the memory UPD for LPDDR4 operation.
12  * There are 4 physical LPDDR4 channels each 32-bits wide. There are 2 logical
13  * channels using 2 physical channels together to form a 64-bit interface to
14  * memory for each logical channel.
15  */
16 
17 enum {
23 };
24 
25 /* Logical channel identification. */
26 enum {
29 };
30 
31 /*
32  * The DQs within a physical channel can be bit-swizzled within each byte.
33  * Within a channel the bytes can be swapped, but the DQs need to be routed
34  * with the corresponding DQS (strobe).
35  */
36 enum {
43 };
44 
45 enum {
46  /* RL-tRCD-tRP */
47  LP4_SPEED_1600 = 1600, /* 14-15-15 */
48  LP4_SPEED_2133 = 2133, /* 20-20-20 */
49  LP4_SPEED_2400 = 2400, /* 24-22-22 */
50 };
51 
52 /* LPDDR4 module density in bits. */
53 enum {
59 };
60 
61 /*
62  * ODT settings :
63  * If ODT PIN to LP4 DRAM is pulled HIGH for ODT_A, and HIGH for ODT_B,
64  * choose ODT_AB_HIGH_HIGH. If ODT PIN to LP4 DRAM is pulled HIGH for ODT_A,
65  * and LOW for ODT_B, choose ODT_AB_HIGH_LOW.
66  *
67  * Note that the enum values correspond to the interpreted UPD fields
68  * within Ch[3:0]_OdtConfig parameters.
69 */
70 enum {
71  ODT_A_B_HIGH_LOW = 0 << 1,
73  nWR_24 = 1 << 5,
74 };
75 
76 /* Provide bit swizzling per DQS and byte swapping within a channel. */
79 };
80 
83 };
84 
85 /*
86  * Initialize default LPDDR4 settings with provided speed. No logical channels
87  * are enabled. Subsequent calls to logical channel enabling are required.
88  */
89 void meminit_lpddr4(FSP_M_CONFIG *cfg, int speed);
90 
91 /*
92  * Enable logical channel providing the full lpddr4_swizzle_config to
93  * fill in per channel swizzle definitions. This assumes a 64-bit wide
94  * memory width per logical channel -- i.e. 2 physical channels are configured
95  * to the memory reference code.
96  */
97 void meminit_lpddr4_enable_channel(FSP_M_CONFIG *cfg, int logical_chan,
98  int rank_density_gb, int dual_rank,
99  const struct lpddr4_swizzle_cfg *scfg);
100 
101 struct lpddr4_sku {
102  int speed;
107  const char *part_num;
109 };
110 
111 struct lpddr4_cfg {
112  const struct lpddr4_sku *skus;
113  size_t num_skus;
115 };
116 
117 /*
118  * Initialize LPDDR4 settings by the provided lpddr4_cfg information and sku id.
119  * The sku id is an index into the sku array within the lpddr4_cfg struct.
120  */
122  const struct lpddr4_cfg *lpcfg, size_t sku_id);
123 /* One of the two below needs to be called. If one is obtaining the part
124  * number out of band from the lpddr_cfg then the part_num variant will
125  * suffice. */
126 void save_lpddr4_dimm_info(const struct lpddr4_cfg *lpcfg, size_t mem_sku);
127 void save_lpddr4_dimm_info_part_num(const char *dram_part_num);
128 
129 /* Retrieve the amount of memory configured in the system in MiB. It's only
130  * valid during romstage. */
131 size_t memory_in_system_in_mib(void);
132 /* Retrieve the requested i/o hole in MiB. Only valid in romstage. */
133 size_t iohole_in_mib(void);
134 
135 #endif /* _SOC_APOLLOLAKE_MEMINIT_H_ */
@ LP4_PHYS_CH0B
Definition: meminit.h:19
@ LP4_NUM_PHYS_CHANNELS
Definition: meminit.h:22
@ LP4_PHYS_CH0A
Definition: meminit.h:18
@ LP4_PHYS_CH1A
Definition: meminit.h:20
@ LP4_PHYS_CH1B
Definition: meminit.h:21
@ LP4_LCH0
Definition: meminit.h:27
@ LP4_LCH1
Definition: meminit.h:28
size_t memory_in_system_in_mib(void)
Definition: meminit.c:12
@ LP4_DQS3
Definition: meminit.h:40
@ LP4_DQS1
Definition: meminit.h:38
@ LP4_DQS0
Definition: meminit.h:37
@ LP4_NUM_BYTE_LANES
Definition: meminit.h:41
@ DQ_BITS_PER_DQS
Definition: meminit.h:42
@ LP4_DQS2
Definition: meminit.h:39
void save_lpddr4_dimm_info(const struct lpddr4_cfg *lpcfg, size_t mem_sku)
void meminit_lpddr4_enable_channel(FSP_M_CONFIG *cfg, int logical_chan, int rank_density_gb, int dual_rank, const struct lpddr4_swizzle_cfg *scfg)
Definition: meminit.c:274
@ ODT_A_B_HIGH_LOW
Definition: meminit.h:71
@ nWR_24
Definition: meminit.h:73
@ ODT_A_B_HIGH_HIGH
Definition: meminit.h:72
@ LP4_SPEED_1600
Definition: meminit.h:47
@ LP4_SPEED_2133
Definition: meminit.h:48
@ LP4_SPEED_2400
Definition: meminit.h:49
void meminit_lpddr4(FSP_M_CONFIG *cfg, int speed)
Definition: meminit.c:174
@ LP4_16Gb_DENSITY
Definition: meminit.h:58
@ LP4_6Gb_DENSITY
Definition: meminit.h:55
@ LP4_4Gb_DENSITY
Definition: meminit.h:54
@ LP4_8Gb_DENSITY
Definition: meminit.h:56
@ LP4_12Gb_DENSITY
Definition: meminit.h:57
void save_lpddr4_dimm_info_part_num(const char *dram_part_num)
size_t iohole_in_mib(void)
Definition: meminit.c:36
void meminit_lpddr4_by_sku(FSP_M_CONFIG *cfg, const struct lpddr4_cfg *lpcfg, size_t sku_id)
Definition: meminit.c:315
uint32_t sku_id(void)
#define FSP_M_CONFIG
Definition: fsp_upd.h:8
unsigned char uint8_t
Definition: stdint.h:8
size_t num_skus
Definition: meminit.h:113
const struct lpddr4_sku * skus
Definition: meminit.h:112
const struct lpddr4_swizzle_cfg * swizzle_config
Definition: meminit.h:114
uint8_t dqs[LP4_NUM_BYTE_LANES][DQ_BITS_PER_DQS]
Definition: meminit.h:78
const char * part_num
Definition: meminit.h:107
int speed
Definition: meminit.h:102
int ch1_dual_rank
Definition: meminit.h:106
bool disable_periodic_retraining
Definition: meminit.h:108
int ch0_rank_density
Definition: meminit.h:103
int ch1_rank_density
Definition: meminit.h:104
int ch0_dual_rank
Definition: meminit.h:105
struct lpddr4_chan_swizzle_cfg phys[LP4_NUM_PHYS_CHANNELS]
Definition: meminit.h:82