1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * JEDEC Standard No. 21-C
5 * Annex J: Annex J: Serial Presence Detects for DDR2 SDRAM (Revision 1.3)
8 #ifndef DEVICE_DRAM_DDR2L_H
9 #define DEVICE_DRAM_DDR2L_H
14 * \brief Utilities for decoding DDR2 SPDs
19 #include <device/dram/common.h>
21 /** Maximum SPD size supported */
22 #define SPD_SIZE_MAX_DDR2 128
24 /* Byte 20 [5:0]: DDR2 Module type information */
25 enum spd_dimm_type_ddr2
{
26 SPD_DDR2_DIMM_TYPE_UNDEFINED
= 0x00,
27 SPD_DDR2_DIMM_TYPE_RDIMM
= 0x01,
28 SPD_DDR2_DIMM_TYPE_UDIMM
= 0x02,
29 SPD_DDR2_DIMM_TYPE_SO_DIMM
= 0x04,
30 SPD_DDR2_DIMM_TYPE_72B_SO_CDIMM
= 0x06,
31 SPD_DDR2_DIMM_TYPE_72B_SO_RDIMM
= 0x07,
32 SPD_DDR2_DIMM_TYPE_MICRO_DIMM
= 0x08,
33 SPD_DDR2_DIMM_TYPE_MINI_RDIMM
= 0x10,
34 SPD_DDR2_DIMM_TYPE_MINI_UDIMM
= 0x20,
35 /* Masks to bits 5:0 to give the dimm type */
36 SPD_DDR2_DIMM_TYPE_MASK
= 0x3f,
42 * Characteristic flags for the DIMM, as presented by the SPD
44 union dimm_flags_ddr2_st
{
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 */
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 */
71 /* Supports burst length 8 */
73 /* Supports burst length 4 */
75 /* DIMM Package is stack */
76 unsigned int stacked
:1;
77 /* the assembly supports self refresh */
78 unsigned int self_refresh
:1;
84 * \brief DIMM characteristics
86 * The characteristics of each DIMM, as presented by the SPD
88 struct dimm_attr_ddr2_st
{
89 enum spd_memory_type dram_type
;
90 enum spd_dimm_type_ddr2 dimm_type
;
91 /* BCD SPD revision */
93 /* Supported CAS mask, bit 0 == CL0 .. bit7 == CL7 */
95 /* Maximum clock 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 */
102 union dimm_flags_ddr2_st flags
;
103 /* Number of banks */
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 */
140 /* Latencies are in units of 1/256 us */
145 /* Manufacturer ID */
147 /* ASCII part number - NULL terminated */
149 /* Year manufactured */
151 /* Week manufactured */
153 /* Unique serial number */
157 int spd_dimm_is_registered_ddr2(enum spd_dimm_type_ddr2 type
);
158 u8
spd_ddr2_calc_checksum(u8
*spd
, int len
);
159 u32
spd_decode_spd_size_ddr2(u8 byte0
);
160 u32
spd_decode_eeprom_size_ddr2(u8 byte1
);
161 int spd_decode_ddr2(struct dimm_attr_ddr2_st
*dimm
, u8 spd
[SPD_SIZE_MAX_DDR2
]);
162 void dram_print_spd_ddr2(const struct dimm_attr_ddr2_st
*dimm
);
163 void normalize_tck(u32
*tclk
);
164 u8
spd_get_msbs(u8 c
);
165 u16
spd_ddr2_calc_unique_crc(const u8
*spd
, int len
);
167 #endif /* DEVICE_DRAM_DDR2L_H */