coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ddr2.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /*
4  * JEDEC Standard No. 21-C
5  * Annex J: Annex J: Serial Presence Detects for DDR2 SDRAM (Revision 1.3)
6  */
7 
8 #ifndef DEVICE_DRAM_DDR2L_H
9 #define DEVICE_DRAM_DDR2L_H
10 
11 /**
12  * @file ddr2.h
13  *
14  * \brief Utilities for decoding DDR2 SPDs
15  */
16 
17 #include <stdint.h>
18 #include <spd.h>
19 #include <device/dram/common.h>
20 
21 /*
22  * Module type (byte 20, bits 5:0) of SPD
23  * This definition is specific to DDR2. DDR3 SPDs have a different structure.
24  */
35  /* Masks to bits 5:0 to give the dimm type */
37 };
38 
39 /**
40  * \brief DIMM flags
41  *
42  * Characteristic flags for the DIMM, as presented by the SPD
43  */
45  /* The whole point of the union/struct construct is to allow us to clear
46  * all the bits with one line: flags.raw = 0.
47  * We do not care how these bits are ordered */
48  struct {
49  /* Module can work at 5.00V */
50  unsigned int operable_5_00V:1;
51  /* Module can work at 3.33V */
52  unsigned int operable_3_33V:1;
53  /* Module can work at 2.50V */
54  unsigned int operable_2_50V:1;
55  /* Module can work at 1.80V - All DIMMS must be 1.8V operable */
56  unsigned int operable_1_80V:1;
57  /* Module can work at 1.50V */
58  unsigned int operable_1_50V:1;
59  /* Module can work at 1.35V */
60  unsigned int operable_1_35V:1;
61  /* Module can work at 1.20V */
62  unsigned int operable_1_25V:1;
63  /* Has an 8-bit bus extension, meaning the DIMM supports ECC */
64  unsigned int is_ecc:1;
65  /* Supports weak driver */
66  unsigned int weak_driver:1;
67  /* Supports terminating at 50 Ohm */
68  unsigned int terminate_50ohms:1;
69  /* Partial Array Self Refresh */
70  unsigned int pasr:1;
71  /* Supports burst length 8 */
72  unsigned int bl8:1;
73  /* Supports burst length 4 */
74  unsigned int bl4:1;
75  /* DIMM Package is stack */
76  unsigned int stacked:1;
77  /* the assembly supports self refresh */
78  unsigned int self_refresh:1;
79  };
80  unsigned int raw;
81 };
82 
83 /**
84  * \brief DIMM characteristics
85  *
86  * The characteristics of each DIMM, as presented by the SPD
87  */
91  /* BCD SPD revision */
93  /* Supported CAS mask, bit 0 == CL0 .. bit7 == CL7 */
95  /* Maximum cloclk to data cycle times for various CAS.
96  * Fields 0 and 1 are unused. */
98  /* Maximum data access times for various CAS.
99  * Fields 0 and 1 are unused. */
101  /* Flags extracted from SPD */
103  /* Number of banks */
105  /* SDRAM width */
107  /* Module width */
109  /* Number of ranks */
111  /* Number or row address bits */
113  /* Number or column address bits */
115  /* Number of PLLs on module */
117  /* Size of module in MiB */
119  /* Size of one rank in MiB */
121  /* Latencies are in units of 1/256 ns */
132 
139 
140  /* Latencies are in units of 1/256 us */
143 
145  /* Manufacturer ID */
147  /* ASCII part number - NULL terminated */
149  /* Year manufactured */
151  /* Week manufactured */
153  /* Unique serial number */
155 };
156 
157 /** Maximum SPD size supported */
158 #define SPD_SIZE_MAX_DDR2 128
159 
161 u8 spd_ddr2_calc_checksum(u8 *spd, int len);
164 int spd_decode_ddr2(struct dimm_attr_ddr2_st *dimm, u8 spd[SPD_SIZE_MAX_DDR2]);
165 void dram_print_spd_ddr2(const struct dimm_attr_ddr2_st *dimm);
166 void normalize_tck(u32 *tclk);
168 u16 spd_ddr2_calc_unique_crc(const u8 *spd, int len);
169 
170 #endif /* DEVICE_DRAM_DDR2L_H */
u8 spd_get_msbs(u8 c)
Return index of MSB set.
Definition: ddr2.c:115
void normalize_tck(u32 *tclk)
Definition: ddr2.c:712
#define SPD_SIZE_MAX_DDR2
Maximum SPD size supported.
Definition: ddr2.h:158
void dram_print_spd_ddr2(const struct dimm_attr_ddr2_st *dimm)
Print the info in DIMM.
Definition: ddr2.c:660
u8 spd_ddr2_calc_checksum(u8 *spd, int len)
Calculate the checksum of a DDR2 SPD unique identifier.
Definition: ddr2.c:45
u16 spd_ddr2_calc_unique_crc(const u8 *spd, int len)
Calculate the CRC of a DDR2 SPD unique identifier.
Definition: ddr2.c:69
spd_dimm_type_ddr2
Definition: ddr2.h:25
@ SPD_DDR2_DIMM_TYPE_UDIMM
Definition: ddr2.h:28
@ SPD_DDR2_DIMM_TYPE_MICRO_DIMM
Definition: ddr2.h:32
@ SPD_DDR2_DIMM_TYPE_MINI_UDIMM
Definition: ddr2.h:34
@ SPD_DDR2_DIMM_TYPE_MASK
Definition: ddr2.h:36
@ SPD_DDR2_DIMM_TYPE_MINI_RDIMM
Definition: ddr2.h:33
@ SPD_DDR2_DIMM_TYPE_72B_SO_RDIMM
Definition: ddr2.h:31
@ SPD_DDR2_DIMM_TYPE_RDIMM
Definition: ddr2.h:27
@ SPD_DDR2_DIMM_TYPE_UNDEFINED
Definition: ddr2.h:26
@ SPD_DDR2_DIMM_TYPE_SO_DIMM
Definition: ddr2.h:29
@ SPD_DDR2_DIMM_TYPE_72B_SO_CDIMM
Definition: ddr2.h:30
int spd_decode_ddr2(struct dimm_attr_ddr2_st *dimm, u8 spd[SPD_SIZE_MAX_DDR2])
Decode the raw SPD data.
Definition: ddr2.c:310
u32 spd_decode_spd_size_ddr2(u8 byte0)
Return size of SPD.
Definition: ddr2.c:89
int spd_dimm_is_registered_ddr2(enum spd_dimm_type_ddr2 type)
Checks if the DIMM is Registered based on byte[20] of the SPD.
Definition: ddr2.c:27
u32 spd_decode_eeprom_size_ddr2(u8 byte1)
Return size of eeprom.
Definition: ddr2.c:99
spd_memory_type
Definition: spd.h:140
unsigned int type
Definition: edid.c:57
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45
DIMM characteristics.
Definition: ddr2.h:88
u32 manufacturer_id
Definition: ddr2.h:146
enum spd_dimm_type_ddr2 dimm_type
Definition: ddr2.h:90
u8 part_number[17]
Definition: ddr2.h:148
u32 access_time[8]
Definition: ddr2.h:100
enum spd_memory_type dram_type
Definition: ddr2.h:89
u16 ranksize_mb
Definition: ddr2.h:120
union dimm_flags_ddr2_st flags
Definition: ddr2.h:102
u8 cas_supported
Definition: ddr2.h:94
u32 cycle_time[8]
Definition: ddr2.h:97
#define c(value, pmcreg, dst_bits)
DIMM flags.
Definition: ddr2.h:44
unsigned int stacked
Definition: ddr2.h:76
unsigned int operable_1_50V
Definition: ddr2.h:58
unsigned int operable_5_00V
Definition: ddr2.h:50
unsigned int is_ecc
Definition: ddr2.h:64
unsigned int operable_1_80V
Definition: ddr2.h:56
unsigned int operable_3_33V
Definition: ddr2.h:52
unsigned int terminate_50ohms
Definition: ddr2.h:68
unsigned int raw
Definition: ddr2.h:80
unsigned int operable_1_25V
Definition: ddr2.h:62
unsigned int weak_driver
Definition: ddr2.h:66
unsigned int self_refresh
Definition: ddr2.h:78
unsigned int bl4
Definition: ddr2.h:74
unsigned int operable_2_50V
Definition: ddr2.h:54
unsigned int operable_1_35V
Definition: ddr2.h:60
unsigned int pasr
Definition: ddr2.h:70
unsigned int bl8
Definition: ddr2.h:72