xref: /illumos-gate/usr/src/lib/libjedec/common/libjedec.h (revision f7379be0e8a103179bb13516195101c745bd6a30)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright (c) 2018, Joyent, Inc.
14  * Copyright 2024 Oxide Computer Company
15  */
16 
17 #ifndef _LIBJEDEC_H
18 #define	_LIBJEDEC_H
19 
20 /*
21  * Library routines that support various JEDEC standards:
22  *
23  *  o JEDEC JEP-106 vendor data
24  *  o Temperature range and Measurement Standards for Components and Modules
25  *    (JESD402-1)
26  *  o DDR3 Serial Presence Detect (SPD) decoding
27  *  o DDR4 Serial Presence Detect (SPD) decoding
28  *  o LPDDR3/4/4x Serial Presence Detect (SPD) decoding
29  *  o DDR5 Serial Presence Detect (SPD) decoding
30  *  o LPDDR5/x Serial Presence Detect (SPD) decoding
31  */
32 
33 #include <sys/types.h>
34 #include <stdint.h>
35 #include <libnvpair.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * Decode a JEDEC continuation ID (without parity) and a group ID.
43  */
44 extern const char *libjedec_vendor_string(uint_t, uint_t);
45 
46 /*
47  * JEDEC operating temperature ranges. These are defined in JESD402-1B
48  * (September 2024).
49  */
50 typedef enum {
51 	/*
52 	 * Operating Case Temperature Ranges
53 	 */
54 	JEDEC_TEMP_CASE_A1T,
55 	JEDEC_TEMP_CASE_A2T,
56 	JEDEC_TEMP_CASE_A3T,
57 	JEDEC_TEMP_CASE_IT,
58 	JEDEC_TEMP_CASE_ET,
59 	JEDEC_TEMP_CASE_ST,
60 	JEDEC_TEMP_CASE_XT,
61 	JEDEC_TEMP_CASE_NT,
62 	JEDEC_TEMP_CASE_RT,
63 	/*
64 	 * Operating Ambient Temperature Ranges
65 	 */
66 	JEDEC_TEMP_AMB_CT,
67 	JEDEC_TEMP_AMB_IOT,
68 	JEDEC_TEMP_AMB_IPT,
69 	JEDEC_TEMP_AMB_IXT,
70 	JEDEC_TEMP_AMB_AO3T,
71 	JEDEC_TEMP_AMB_AO2T,
72 	JEDEC_TEMP_AMB_AO1T,
73 	/*
74 	 * Storage Temperature Ranges
75 	 */
76 	JEDEC_TEMP_STOR_2,
77 	JEDEC_TEMP_STOR_1B,
78 	JEDEC_TEMP_STOR_1A,
79 	JEDEC_TEMP_STOR_ST,
80 	/*
81 	 * Operating Junction Temperature Ranges
82 	 */
83 	JEDEC_TEMP_JNCT_A135,
84 	JEDEC_TEMP_JNCT_A130,
85 	JEDEC_TEMP_JNCT_A1T,
86 	JEDEC_TEMP_JNCT_A120,
87 	JEDEC_TEMP_JNCT_A115,
88 	JEDEC_TEMP_JNCT_A110,
89 	JEDEC_TEMP_JNCT_A2T,
90 	JEDEC_TEMP_JNCT_A100,
91 	JEDEC_TEMP_JNCT_A95,
92 	JEDEC_TEMP_JNCT_A90,
93 	JEDEC_TEMP_JNCT_A3T,
94 	JEDEC_TEMP_JNCT_LT135,
95 	JEDEC_TEMP_JNCT_LT130,
96 	JEDEC_TEMP_JNCT_LT125,
97 	JEDEC_TEMP_JNCT_LT120,
98 	JEDEC_TEMP_JNCT_LT115,
99 	JEDEC_TEMP_JNCT_LT110,
100 	JEDEC_TEMP_JNCT_LT105,
101 	JEDEC_TEMP_JNCT_LT100,
102 	JEDEC_TEMP_JNCT_IT,
103 	JEDEC_TEMP_JNCT_LT90,
104 	JEDEC_TEMP_JNCT_LT85,
105 	JEDEC_TEMP_JNCT_ET120,
106 	JEDEC_TEMP_JNCT_ET115,
107 	JEDEC_TEMP_JNCT_ET110,
108 	JEDEC_TEMP_JNCT_ET,
109 	JEDEC_TEMP_JNCT_ET100,
110 	JEDEC_TEMP_JNCT_ET95,
111 	JEDEC_TEMP_JNCT_ET90,
112 	JEDEC_TEMP_JNCT_ST,
113 	JEDEC_TEMP_JNCT_120,
114 	JEDEC_TEMP_JNCT_115,
115 	JEDEC_TEMP_JNCT_110,
116 	JEDEC_TEMP_JNCT_105,
117 	JEDEC_TEMP_JNCT_100,
118 	JEDEC_TEMP_JNCT_XT,
119 	JEDEC_TEMP_JNCT_90,
120 	JEDEC_TEMP_JNCT_NT
121 } libjedec_temp_range_t;
122 extern boolean_t libjedec_temp_range(libjedec_temp_range_t, int32_t *,
123     int32_t *);
124 
125 /*
126  * This is a series of error codes that libjedec may produce while trying to
127  * parse the overall SPD data structure. These represent a top-level failure and
128  * have meaning when no nvlist_t is returned.
129  */
130 typedef enum {
131 	/*
132 	 * Indicates that we didn't encounter a fatal error; however, we may
133 	 * have a specific parsing error that relates to a key in the nvlist.
134 	 */
135 	LIBJEDEC_SPD_OK	= 0,
136 	/*
137 	 * Indicates that we did not have enough memory while trying to
138 	 * construct the generated nvlist_t.
139 	 */
140 	LIBJEDEC_SPD_NOMEM,
141 	/*
142 	 * Indicates that the data that we found was insufficient to
143 	 * successfully parse basic information. The required size varies per
144 	 * SPD key byte type.
145 	 */
146 	LIBJEDEC_SPD_TOOSHORT,
147 	/*
148 	 * Indicates that we found an unsupported type of SPD data and therefore
149 	 * cannot parse this.
150 	 */
151 	LIBJEDEC_SPD_UNSUP_TYPE,
152 	/*
153 	 * Indicates that while we found a supported type of SPD data, we do not
154 	 * understand its revision.
155 	 */
156 	LIBJEDEC_SPD_UNSUP_REV
157 } spd_error_t;
158 
159 /*
160  * Decode a binary payload of SPD data, if possible. The returned nvlist is made
161  * up of a series of keys described below. Parsing errors are broken into two
162  * categories. Fatal errors set a value in the spd_error_t below. Non-fatal
163  * errors, such as encountering a value which we don't have a translation for,
164  * are in a nested errors nvlist_t indexed by key.
165  *
166  * The keys are all dot delineated to create a few different top-level
167  * namespaces. These include:
168  *
169  * "meta" -- Which includes information about the SPD, encoding, and things like
170  * the type of module.
171  *
172  * "dram" -- Parameters that are specific to the SDRAM dies present. What one
173  * thinks of as a stick of DRAM consists of several different SDRAM dies on the
174  * PCB. This includes things like the row and columns bits and timing
175  * information.
176  *
177  * "channel" -- Parameters that are tied to an implementation of a channel. DDR4
178  * has a single channel where as DDR5 and LPDDR[345] have some number of
179  * sub-channels.
180  *
181  * "ddr4", "ddr5" -- These include information which is specific to the general
182  * DDR standard. While we have tried to consolidate information between them
183  * where applicable, some things are specific to the standard.
184  *
185  * "lp" -- These are parameters that are currently specific to one of the
186  * low-power DDR specifications such as LPDDR5.
187  *
188  * "module" -- Parameters that are specific to the broader module and PCB
189  * itself. This includes information like the height or devices present.
190  *
191  * "ddr4.rdimm", "ddr4.lrdimm", "ddr5.rdimm", etc. -- These are parameter that
192  * are specific to a module being both the combination of a specific DDR
193  * standard and a specific type of module. Common parameters are often in the
194  * "module" section.
195  *
196  * "ddr3.mb", "ddr4.rcd", etc. -- These are generation-specific parameters that
197  * refer to a specific component like the rcd found on RDIMMs and LRDIMMs or the
198  * mb on LRDIMMs.
199  *
200  * "mfg" -- Manufacturing related information.
201  *
202  * "errors" -- The key for the errors nvlist_t. See the spd_error_kind_t
203  * definition later on. Each error has both a numeric code and a string message.
204  */
205 extern nvlist_t *libjedec_spd(const uint8_t *, size_t, spd_error_t *);
206 
207 /*
208  * The following are keys in the metadata nvlist_t. The SPD_KEY_NBYTES_TOTAL is
209  * present in DDR4 and DDR5. The SPD_KEY_NBYTES_USED is only present on DDR4
210  * right now. All supported SPD encodings have the raw revision information. If
211  * the values for the total bytes or used bytes are set to undefined, then they
212  * will not be present.
213  *
214  * DDR5 introduces an idea of a public beta level that gets reset between
215  * external releases. It theoretically modifies every scion. DDR5 also
216  * introduces a second revision that is for the module information. This will
217  * not be present on systems prior to DDR5.
218  */
219 #define	SPD_KEY_NBYTES_TOTAL	"meta.total-bytes"	/* uint32_t */
220 #define	SPD_KEY_NBYTES_USED	"meta.used-bytes"	/* uint32_t */
221 #define	SPD_KEY_REV_ENC	"meta.revision-encoding"	/* uint32_t */
222 #define	SPD_KEY_REV_ADD	"meta.revision-additions"	/* uint32_t */
223 #define	SPD_KEY_BETA	"meta.beta-version"		/* uint32_t */
224 #define	SPD_KEY_MOD_REV_ENC	"meta.module-revision-encoding"	/* uint32_t */
225 #define	SPD_KEY_MOD_REV_ADD	"meta.module-revision-additions" /* uint32_t */
226 
227 /*
228  * DRAM Type information. This indicates the standard that the device conforms
229  * to. This enumeration's values match the JEDEC specification's values. This is
230  * present for everything.
231  */
232 typedef enum {
233 	SPD_DT_FAST_PAGE_MODE		= 0x01,
234 	SPD_DT_EDO			= 0x02,
235 	SPD_DT_PIPE_NIBBLE		= 0x03,
236 	SPD_DT_SDRAM			= 0x04,
237 	SPD_DT_ROM			= 0x05,
238 	SPD_DT_DDR_SGRAM		= 0x06,
239 	SPD_DT_DDR_SDRAM		= 0x07,
240 	SPD_DT_DDR2_SDRAM		= 0x08,
241 	SPD_DT_DDR2_SDRAM_FBDIMM	= 0x09,
242 	SPD_DT_DDR2_SDRAM_FDIMM_P	= 0x0a,
243 	SPD_DT_DDR3_SDRAM		= 0x0b,
244 	SPD_DT_DDR4_SDRAM		= 0x0c,
245 	SPD_DT_DDR4E_SDRAM		= 0x0e,
246 	SPD_DT_LPDDR3_SDRAM		= 0x0f,
247 	SPD_DT_LPDDR4_SDRAM		= 0x10,
248 	SPD_DT_LPDDR4X_SDRAM		= 0x11,
249 	SPD_DT_DDR5_SDRAM		= 0x12,
250 	SPD_DT_LPDDR5_SDRAM		= 0x13,
251 	SPD_DT_DDR5_NVDIMM_P		= 0x14,
252 	SPD_DT_LPDDR5X_SDRAM		= 0x15
253 } spd_dram_type_t;
254 #define	SPD_KEY_DRAM_TYPE	"meta.dram-type"	/* uint32_t (enum) */
255 
256 typedef enum {
257 	SPD_MOD_TYPE_RDIMM,
258 	SPD_MOD_TYPE_UDIMM,
259 	SPD_MOD_TYPE_SODIMM,
260 	SPD_MOD_TYPE_LRDIMM,
261 	SPD_MOD_TYPE_MRDIMM,
262 	SPD_MOD_TYPE_DDIMM,
263 	SPD_MOD_TYPE_SOLDER,
264 	SPD_MOD_TYPE_MINI_RDIMM,
265 	SPD_MOD_TYPE_MINI_UDIMM,
266 	SPD_MOD_TYPE_MINI_CDIMM,
267 	SPD_MOD_TYPE_72b_SO_RDIMM,
268 	SPD_MOD_TYPE_72b_SO_UDIMM,
269 	SPD_MOD_TYPE_72b_SO_CDIMM,
270 	SPD_MOD_TYPE_16b_SO_DIMM,
271 	SPD_MOD_TYPE_32b_SO_DIMM,
272 	SPD_MOD_TYPE_CUDIMM,
273 	SPD_MOD_TYPE_CSODIMM,
274 	SPD_MOD_TYPE_CAMM2,
275 	SPD_MOD_TYPE_LPDIMM,
276 	SPD_MOD_TYPE_MICRO_DIMM
277 } spd_module_type_t;
278 #define	SPD_KEY_MOD_TYPE	"meta.module-type"	/* uint32_t (enum) */
279 typedef enum {
280 	SPD_MOD_NOT_HYBRID,
281 	SPD_MOD_HYBRID_NVDIMMM
282 } spd_module_hybrid_t;
283 #define	SPD_KEY_MOD_HYBRID_TYPE	"meta.hybrid-type"	/* uint32_t */
284 
285 typedef enum {
286 	SPD_MOD_TYPE_NVDIMM_N,
287 	SPD_MOD_TYPE_NVDIMM_P,
288 	SPD_MOD_TYPE_NVDIMM_H
289 } spd_module_nvdimm_type_t;
290 #define	SPD_KEY_MOD_NVDIMM_TYPE	"meta.nvdimm-type"	/* uint32_t */
291 
292 /*
293  * Different SPD standards have different integrity rules. The regions covered
294  * by the CRCs also vary. We end up with per-spec keys. All data types for these
295  * are uint32_t's so that way we can record the expected CRC. We use a uint32_t
296  * for consistency even though the data only fits in a uint16_t. Note, callers
297  * must check to see if these exist. If there are keys with these names in the
298  * errors object, then the rest of the data should be considered suspect, but we
299  * will have attempted to parse everything we can. The DDR4 values are shared
300  * across LPDDR3/4/4X. The DDR5 values are shared across LPDDR5/5X.
301  */
302 #define	SPD_KEY_CRC_DDR3	"meta.crc-ddr3"		/* uint32_t */
303 #define	SPD_KEY_CRC_DDR3_LEN	"meta.crc-ddr3-len"	/* uint32_t */
304 #define	SPD_KEY_CRC_DDR4_BASE	"meta.crc-ddr4-base"	/* uint32_t */
305 #define	SPD_KEY_CRC_DDR4_BLK1	"meta.crc-ddr4-block1"	/* uint32_t */
306 #define	SPD_KEY_CRC_DDR5	"meta.crc-ddr5"		/* uint32_t */
307 
308 /*
309  * DDR5 adds a field in the SPD to describe how data should be hashed to compute
310  * and compare to an attribute certification to authenticate modules. This is
311  * only present in DDR5. We only add a value here if this is actually supported.
312  */
313 typedef enum {
314 	SPD_HASH_SEQ_ALG_1
315 } spd_hash_seq_alg_t;
316 #define	SPD_KEY_HASH_SEQ	"meta.hash-sequence-algorithm"	/* uint32_t */
317 
318 /*
319  * This section contains information related to DRAM technology.
320  */
321 
322 /*
323  * Bank, bank group, row, and column bits. These are all present in both DDR4
324  * and DDR5. DDR4 allows cases where there are no bank groups. If no bits are
325  * used, then this item is empty.
326  */
327 #define	SPD_KEY_NROW_BITS	"dram.num-row-bits"	/* uint32_t */
328 #define	SPD_KEY_NCOL_BITS	"dram.num-column-bits"	/* uint32_t */
329 #define	SPD_KEY_NBANK_BITS	"dram.num-bank-bits"	/* uint32_t */
330 #define	SPD_KEY_NBGRP_BITS	"dram.num-bank-group-bits"	/* uint32_t */
331 #define	SPD_KEY_SEC_NROW_BITS	"dram.sec-num-row-bits"		/* uint32_t */
332 #define	SPD_KEY_SEC_NCOL_BITS	"dram.sec-num-column-bits"	/* uint32_t */
333 #define	SPD_KEY_SEC_NBANK_BITS	"dram.sec-num-bank-bits"	/* uint32_t */
334 #define	SPD_KEY_SEC_NBGRP_BITS	"dram.sec-num-bank-group-bits"	/* uint32_t */
335 
336 /*
337  * Die Density. This is the capacity that each die contains in bits.
338  */
339 #define	SPD_KEY_DIE_SIZE	"dram.die-bit-size"	/* uint64_t */
340 #define	SPD_KEY_SEC_DIE_SIZE	"dram.sec-die-bit-size"	/* uint64_t */
341 
342 /*
343  * Package information. DRAM may be made up of a monolithic package type or
344  * several different types. There is a boolean property present to indicate that
345  * it is not monolithic. For these there is a die count and then a separate
346  * notion of what the signal loading type is. If the property is present then we
347  * will also have the die count and loading type for the secondary. Note, these
348  * loading parameters are considered at the device balls as opposed to specific
349  * signals.
350  */
351 #define	SPD_KEY_PKG_NOT_MONO	"meta.non-monolithic-package"	/* key only */
352 #define	SPD_KEY_PKG_NDIE	"dram.package-die-count"	/* uint32_t */
353 #define	SPD_KEY_SEC_PKG_NDIE	"dram.sec-package-die-count"	/* uint32_t */
354 typedef enum {
355 	SPD_SL_UNSPECIFIED,
356 	SPD_SL_MUTLI_STACK,
357 	SPD_SL_3DS
358 } spd_signal_loading_t;
359 #define	SPD_KEY_PKG_SL		"dram.package-sig-loading"	/* uint32_t */
360 #define	SPD_KEY_SEC_PKG_SL	"dram.sec-package-sig-loading"	/* uint32_t */
361 
362 /*
363  * Post-package Repair. PPR is supported in DDR4, DDR5. LPDDR4, and LPDDR5. PPR
364  * support is indicated by the presence of the spd_ppr_flags_t structure. If it
365  * is not supported, then there will be no PPR related keys present. In some
366  * cases the PPR granularity may not be known, in which case it is not present.
367  */
368 typedef enum {
369 	SPD_PPR_F_HARD_PPR		= 1 << 0,
370 	SPD_PPR_F_SOFT_PPR		= 1 << 1,
371 	SPD_PPR_F_MBIST_PPR		= 1 << 2,
372 	SPD_PPR_F_PPR_UNDO		= 1 << 3
373 } spd_ppr_flags_t;
374 
375 typedef enum {
376 	SPD_PPR_GRAN_BANK_GROUP,
377 	SPD_PPR_GRAN_BANK
378 } spd_ppr_gran_t;
379 #define	SPD_KEY_PPR		"dram.ppr-flags"	/* uint32_t (enum) */
380 #define	SPD_KEY_PPR_GRAN	"dram.ppr-gran"		/* uint32_t (enum) */
381 
382 /*
383  * Voltages in mV. This is an array of nominal voltages that are supported. DDR3
384  * defines multiple voltages, but DDR4 and DDR5 only have a single voltage
385  * (specific to the supply). DDR3 and DDR4 only defined V~DD~ in SPD. While
386  * V~DQ~ and V~PP~ are defined in DDR5.
387  */
388 #define	SPD_KEY_NOM_VDD		"dram.nominal-vdd"	/* uint32_t[] */
389 #define	SPD_KEY_NOM_VDDQ	"dram.nominal-vddq"	/* uint32_t[] */
390 #define	SPD_KEY_NOM_VPP		"dram.nominal-vpp"	/* uint32_t[] */
391 
392 /*
393  * DRAM module organization.
394  *
395  * This describes the number of ranks that exist on a per-channel basis. In
396  * DDR4, there is only one channel and so this effectively covers the entire
397  * module. In DDR5 and LPDDR there are multiple channels or sub-channels. The
398  * rank mix may be symmetrical or asymmetrical. A key will be set if that's the
399  * case.
400  */
401 #define	SPD_KEY_RANK_ASYM	"dram.asymmetrical-ranks"	/* key */
402 #define	SPD_KEY_NRANKS		"channel.num-ranks"	/* uint32_t */
403 
404 /*
405  * DRAM and Module/Channel widths.
406  *
407  * A 'channel' refers to the entire interface between a memory
408  * controller and memory. In DDR4 there is only a single channel that covers the
409  * entire 72-bit (64-bit data, 8-bit ECC) bus. In DDR5 and LPDDR5 this is made
410  * up of a pair of sub-channels. In LPDDR3/4 the device exposed a number of
411  * channels, that are effecitvely similar in spirit to the DDR5 sub-channel. The
412  * channel keys below cover whatever the smallest defined unit is. For DDR4 (and
413  * earlier) this is the entire channel. For LPDDR3/4 these are the independent
414  * channels in the SPD spec and for DDR5 and LPDDR5 these are sub-channels. The
415  * channel width is split between a primary data and ECC size.
416  *
417  * In LPDDR3/4 a given DRAM die may support a varying number of channels. That
418  * is stored in the num-channels calculation and otherwise set to 1 for all
419  * other types of memory.
420  *
421  * Separately the individual DRAM dies themselves have a width which is
422  * SPD_KEY_DRAM_WIDTH. This is the portion of each die that contributes to the
423  * given channel.
424  */
425 #define	SPD_KEY_DRAM_WIDTH	"dram.width"		/* uint32_t */
426 #define	SPD_KEY_SEC_DRAM_WIDTH	"dram.sec-width"	/* uint32_t */
427 #define	SPD_KEY_DRAM_NCHAN	"dram.num-channels"	/* uint32_t */
428 #define	SPD_KEY_NSUBCHAN	"module.num-subchan"	/* uint32_t */
429 #define	SPD_KEY_DATA_WIDTH	"channel.data-width"	/* uint32_t */
430 #define	SPD_KEY_ECC_WIDTH	"channel.ecc-width"	/* uint32_t */
431 
432 /*
433  * LPDDR offers a notion of a 'byte mode' where half of the I/Os can be shared
434  * between multiple dies. This key is set when tihs is true.
435  */
436 #define	SPD_KEY_LP_BYTE_MODE	"lp.byte-mode"	/* key */
437 
438 /*
439  * LPDDR3-5 have a signal loading matrix that indicates the amount of load that
440  * is on different groups of signals. All values are a uint32_t of the count of
441  * loads.
442  */
443 #define	SPD_KEY_LP_LOAD_DSM	"lp.load-data-strobe-mask"
444 #define	SPD_KEY_LP_LOAD_CAC	"lp.load-command-address-clock"
445 #define	SPD_KEY_LP_LOAD_CS	"lp.load-chip-select"
446 
447 /*
448  * DDR3, DDR4, and LPDDR3-5/x specify specific timebases in the SPD data. DDR5
449  * just requires a specific timebase and therefore does not define these keys.
450  * This like all other time values is explicitly in ps.
451  */
452 #define	SPD_KEY_MTB	"dram.median-time-base"		/* uint32_t */
453 #define	SPD_KEY_FTB	"dram.fine-time-base"		/* uint32_t */
454 
455 /*
456  * Supported CAS Latencies. This is an array of integers to indicate which index
457  * CAS latencies are possible.
458  */
459 #define	SPD_KEY_CAS	"dram.cas-latencies"		/* uint32_t [] */
460 
461 /*
462  * Time parameters. These are all in picoseconds. All values are uint64_t.
463  */
464 #define	SPD_KEY_TCKAVG_MIN	"dram.t~CKAVG~min"
465 #define	SPD_KEY_TCKAVG_MAX	"dram.t~CKAVG~max"
466 #define	SPD_KEY_TAA_MIN		"dram.t~AA~min"
467 #define	SPD_KEY_TRCD_MIN	"dram.t~RCD~min"
468 #define	SPD_KEY_TRP_MIN		"dram.t~RP~min"
469 #define	SPD_KEY_TRAS_MIN	"dram.t~RAS~min"
470 #define	SPD_KEY_TRC_MIN		"dram.t~RC~min"
471 #define	SPD_KEY_TRFC1_MIN	"dram.t~RFC1~min"
472 #define	SPD_KEY_TRFC2_MIN	"dram.t~RFC2~min"
473 #define	SPD_KEY_TFAW		"dram.t~FAW~"
474 #define	SPD_KEY_TRRD_L_MIN	"dram.t~RRD_L~min"
475 #define	SPD_KEY_TCCD_L_MIN	"dram.t~CCD_S~min"
476 #define	SPD_KEY_TWR_MIN		"dram.t~WR~min"
477 
478 /*
479  * The following time are only used in DDR4. While some of the DDR4 and DDR5
480  * write to read or write to write parameters are similar, because they use
481  * different names for times, we distinguish them as different values.
482  */
483 #define	SPD_KEY_TRFC4_MIN	"dram.t~RFC4~min"
484 #define	SPD_KEY_TRRD_S_MIN	"dram.t~RRD_S~min"
485 #define	SPD_KEY_TWTRS_MIN	"dram.t~WTR_S~min"
486 #define	SPD_KEY_TWTRL_MIN	"dram.t~WTR_L~min"
487 
488 /*
489  * The following times are specific to DDR5. t~CCD_L_WTR~ in DDR5 is the
490  * equivalent to t~WTRS_L~min, same with t~CCD_S_WTR~.
491  */
492 #define	SPD_KEY_TCCDLWR		"dram.t~CCD_L_WR"
493 #define	SPD_KEY_TCCDLWR2	"dram.t~CCD_L_WR2"
494 #define	SPD_KEY_TCCDLWTR	"dram.t~CCD_L_WTR"
495 #define	SPD_KEY_TCCDSWTR	"dram.t~CCD_S_WTR"
496 #define	SPD_KEY_TRTP		"dram.t~RTP~"
497 #define	SPD_KEY_TCCDM		"dram.t~CCD_M~"
498 #define	SPD_KEY_TCCDMWR		"dram.t~CCD_M_WR~"
499 #define	SPD_KEY_TCCDMWTR	"dram.t~CCD_M_WTR~"
500 
501 /*
502  * While prior DDR standards did have minimum clock times for certain
503  * activities, these were first added to the SPD data in DDR5. All values for
504  * these are uint32_t's and are in clock cycles.
505  */
506 #define	SPD_KEY_TRRD_L_NCK	"dram.t~RRD_L~nCK"
507 #define	SPD_KEY_TCCD_L_NCK	"dram.t~CCD_L~nCK"
508 #define	SPD_KEY_TCCDLWR_NCK	"dram.t~CCD_L_WR~nCK"
509 #define	SPD_KEY_TCCDLWR2_NCK	"dram.t~CCD_L_WR2~nCK"
510 #define	SPD_KEY_TFAW_NCK	"dram.t~FAW~nCK"
511 #define	SPD_KEY_TCCDLWTR_NCK	"dram.t~CCD_L_WTR~nCK"
512 #define	SPD_KEY_TCCDSWTR_NCK	"dram.t~CCD_S_WTR~nCK"
513 #define	SPD_KEY_TRTP_NCK	"dram.t~RTP~nCK"
514 #define	SPD_KEY_TCCDM_NCK	"dram.t~CCD_M~nCK"
515 #define	SPD_KEY_TCCDMWR_NCK	"dram.t~CCD_M_WR~nCK"
516 #define	SPD_KEY_TCCDMWTR_NCK	"dram.t~CCD_M_WTR~nCK"
517 
518 /*
519  * The following times are only used in DDR5. The RFCx_dlr values are for 3DS
520  * RDIMMs.
521  */
522 #define	SPD_KEY_TRFCSB		"dram.t~RFCsb~"
523 #define	SPD_KEY_TRFC1_DLR	"dram.3ds-t~RFC1_dlr~"
524 #define	SPD_KEY_TRFC2_DLR	"dram.3ds-t~RFC2_dlr~"
525 #define	SPD_KEY_TRFCSB_DLR	"dram.3ds-t~RFCsb_dlr~"
526 
527 /*
528  * The following times are only used by LPDDR3-5, but like other variable timing
529  * entries, we still use the "dram" prefix. These are per-bank and all bank row
530  * precharges and minimum refresh recovery times.
531  */
532 #define	SPD_KEY_TRPAB_MIN	"dram.t~RPab~"
533 #define	SPD_KEY_TRPPB_MIN	"dram.t~RPpb~"
534 #define	SPD_KEY_TRFCAB_MIN	"dram.t~RFCab~"
535 #define	SPD_KEY_TRFCPB_MIN	"dram.t~RFCpb~"
536 
537 /*
538  * These refer to the maximum activate window and the maximum activate count. In
539  * cases where the MAC is unknown no key will be present. This was present in
540  * DDR and LPDDR 3 and 4. It is no longer present in DDR and LPDDR4 5 and
541  * therefore will not be present for those.
542  */
543 #define	SPD_KEY_MAW	"dram.maw"		/* uint32_t */
544 #define	SPD_KEY_MAC	"dram.mac"		/* uint32_t */
545 #define	SPD_KEY_MAC_UNLIMITED	UINT32_MAX
546 
547 /*
548  * LPDDR3/4/4X have specific latency sets. The following enum, stored as a u32
549  * contains these options.
550  */
551 typedef enum {
552 	SPD_LP_RWLAT_WRITE_A	= 1 << 0,
553 	SPD_LP_RWLAT_WRITE_B	= 1 << 1,
554 	SPD_LP_RWLAT_DBIRD_EN	= 1 << 2
555 } spd_lp_rwlat_t;
556 #define	SPD_KEY_LP_RWLAT	"lp.read-write-latency"	/* uint32_t */
557 
558 /*
559  * Partial Automatic self-refresh (PASR) was introduced in DDR3 and continued in
560  * DDR5. Automatic self-refresh (ASR) was only in DDR3. We treat it as a part of
561  * the other DDR3 assorted features. The last DDR3 specific thing is the
562  * extended temperature fresh rate.
563  */
564 #define	SPD_KEY_DDR_PASR	"dram.pasr"		/* key */
565 typedef enum {
566 	SPD_DDR3_FEAT_ASR	= 1 << 0,
567 	SPD_DDR3_FEAT_DLL_OFF	= 1 << 1,
568 	SPD_DDR3_FEAT_RZQ_7	= 1 << 2,
569 	SPD_DDR3_FEAT_RZQ_6	= 1 << 3
570 } spd_ddr3_feat_t;
571 #define	SPD_KEY_DDR3_FEAT	"ddr3.asr"		/* uint32_t */
572 #define	SPD_KEY_DDR3_XTRR	"ddr3.xt-refresh-rate"	/* uint32_t */
573 
574 /*
575  * The following are DDR5 specific properties. BL32 indicates whether burst
576  * length 32 mode is supported, which is a key. Along with the partial array
577  * self refresh. The Duty Cycle Adjuster is an enumeration because there are
578  * multiple modes. The wide temperature sensing is another DDR5 bit represented
579  * as a key as well as an enum of fault handling.
580  */
581 #define	SPD_KEY_DDR5_BL32	"ddr5.bl32"		/* key */
582 typedef enum {
583 	SPD_DCA_UNSPPORTED,
584 	SPD_DCA_1_OR_2_PHASE,
585 	SPD_DCA_4_PHASE
586 } spd_dca_t;
587 #define	SPD_KEY_DDR5_DCA	"ddr5.dca"		/* uint32_t */
588 #define	SPD_KEY_DDR5_WIDE_TS	"ddr5.wide-temp-sense"	/* key */
589 typedef enum {
590 	SPD_FLT_BOUNDED		= 1 << 0,
591 	SPD_FLT_WRSUP_MR9	= 1 << 1,
592 	SPD_FLT_WRSUP_MR15	= 1 << 2
593 } spd_fault_t;
594 #define	SPD_KEY_DDR5_FLT	"ddr5.fault-handling"	/* uint32_t */
595 
596 /*
597  * DDR5 allows for non-standard core timing options. This is indicated by a
598  * single key that acts as a flag.
599  */
600 #define	SPD_KEY_DDR5_NONSTD_TIME	"ddr5.non-standard-timing" /* key */
601 
602 /*
603  * DDR5 adds information about refresh management. This is split into
604  * information about general refresh management and then optional adaptive
605  * refresh management. There are three levels of adaptive refresh management
606  * titled A, B, and C. Both the general refresh management and the adaptive
607  * refresh management exist for both the primary and secondary types in
608  * asymmetrical modules. Information about the RAAIMT and RAAMMT is only present
609  * if refresh management is required. Similarly, BRC information is only present
610  * if DRFM is supported. All values here are uint32_t's.
611  */
612 typedef enum {
613 	SPD_RFM_F_REQUIRED	= 1 << 0,
614 	SPD_RFM_F_DRFM_SUP	= 1 << 1,
615 } spd_rfm_flags_t;
616 #define	SPD_KEY_DDR5_RFM_FLAGS_PRI	"ddr5.rfm.flags"
617 #define	SPD_KEY_DDR5_RFM_RAAIMT_PRI	"ddr5.rfm.raaimt"
618 #define	SPD_KEY_DDR5_RFM_RAAIMT_FGR_PRI	"ddr5.rfm.raaimt-fgr"
619 #define	SPD_KEY_DDR5_RFM_RAAMMT_PRI	"ddr5.rfm.raammt"
620 #define	SPD_KEY_DDR5_RFM_RAAMMT_FGR_PRI	"ddr5.rfm.raammt-fgr"
621 #define	SPD_KEY_DDR5_RFM_BRC_CFG_PRI	"ddr5.rfm.brc-config"
622 
623 typedef enum {
624 	SPD_BRC_F_LVL_2		= 1 << 0,
625 	SPD_BRC_F_LVL_3		= 1 << 1,
626 	SPD_BRC_F_LVL_4		= 1 << 2
627 } spd_brc_flags_t;
628 #define	SPD_KEY_DDR5_RFM_BRC_SUP_PRI	"ddr5.rfm.brc-level"
629 #define	SPD_KEY_DDR5_RFM_RAA_DEC_PRI	"ddr5.rfm.raa-dec"
630 #define	SPD_KEY_DDR5_RFM_FLAGS_SEC	"ddr5.rfm.sec-flags"
631 #define	SPD_KEY_DDR5_RFM_RAAIMT_SEC	"ddr5.rfm.sec-raaimt"
632 #define	SPD_KEY_DDR5_RFM_RAAIMT_FGR_SEC	"ddr5.rfm.sec-raaimt-fgr"
633 #define	SPD_KEY_DDR5_RFM_RAAMMT_SEC	"ddr5.rfm.sec-raammt"
634 #define	SPD_KEY_DDR5_RFM_RAAMMT_FGR_SEC	"ddr5.rfm.sec-raammt-fgr"
635 #define	SPD_KEY_DDR5_RFM_BRC_CFG_SEC	"ddr5.rfm.sec-brc-config"
636 #define	SPD_KEY_DDR5_RFM_BRC_SUP_SEC	"ddr5.rfm.sec-brc-level"
637 #define	SPD_KEY_DDR5_RFM_RAA_DEC_SEC	"ddr5.rfm.sec-raa-dec"
638 
639 #define	SPD_KEY_DDR5_ARFMA_FLAGS_PRI		"ddr5.arfm-a.flags"
640 #define	SPD_KEY_DDR5_ARFMA_RAAIMT_PRI		"ddr5.arfm-a.raaimt"
641 #define	SPD_KEY_DDR5_ARFMA_RAAIMT_FGR_PRI	"ddr5.arfm-a.raaimt-fgr"
642 #define	SPD_KEY_DDR5_ARFMA_RAAMMT_PRI		"ddr5.arfm-a.raammt"
643 #define	SPD_KEY_DDR5_ARFMA_RAAMMT_FGR_PRI	"ddr5.arfm-a.raammt-fgr"
644 #define	SPD_KEY_DDR5_ARFMA_BRC_CFG_PRI		"ddr5.arfm-a.brc-config"
645 #define	SPD_KEY_DDR5_ARFMA_BRC_SUP_PRI		"ddr5.arfm-a.brc-level"
646 #define	SPD_KEY_DDR5_ARFMA_RAA_DEC_PRI		"ddr5.arfm-a.raa-dec"
647 #define	SPD_KEY_DDR5_ARFMA_FLAGS_SEC		"ddr5.arfm-a.sec-flags"
648 #define	SPD_KEY_DDR5_ARFMA_RAAIMT_SEC		"ddr5.arfm-a.sec-raaimt"
649 #define	SPD_KEY_DDR5_ARFMA_RAAIMT_FGR_SEC	"ddr5.arfm-a.sec-raaimt-fgr"
650 #define	SPD_KEY_DDR5_ARFMA_RAAMMT_SEC		"ddr5.arfm-a.sec-raammt"
651 #define	SPD_KEY_DDR5_ARFMA_RAAMMT_FGR_SEC	"ddr5.arfm-a.sec-raammt-fgr"
652 #define	SPD_KEY_DDR5_ARFMA_BRC_CFG_SEC		"ddr5.arfm-a.sec-brc-config"
653 #define	SPD_KEY_DDR5_ARFMA_BRC_SUP_SEC		"ddr5.arfm-a.sec-brc-level"
654 #define	SPD_KEY_DDR5_ARFMA_RAA_DEC_SEC		"ddr5.arfm-a.sec-raa-dec"
655 
656 #define	SPD_KEY_DDR5_ARFMB_FLAGS_PRI		"ddr5.arfm-b.flags"
657 #define	SPD_KEY_DDR5_ARFMB_RAAIMT_PRI		"ddr5.arfm-b.raaimt"
658 #define	SPD_KEY_DDR5_ARFMB_RAAIMT_FGR_PRI	"ddr5.arfm-b.raaimt-fgr"
659 #define	SPD_KEY_DDR5_ARFMB_RAAMMT_PRI		"ddr5.arfm-b.raammt"
660 #define	SPD_KEY_DDR5_ARFMB_RAAMMT_FGR_PRI	"ddr5.arfm-b.raammt-fgr"
661 #define	SPD_KEY_DDR5_ARFMB_BRC_CFG_PRI		"ddr5.arfm-b.brc-config"
662 #define	SPD_KEY_DDR5_ARFMB_BRC_SUP_PRI		"ddr5.arfm-b.brc-level"
663 #define	SPD_KEY_DDR5_ARFMB_RAA_DEC_PRI		"ddr5.arfm-b.raa-dec"
664 #define	SPD_KEY_DDR5_ARFMB_FLAGS_SEC		"ddr5.arfm-b.sec-flags"
665 #define	SPD_KEY_DDR5_ARFMB_RAAIMT_SEC		"ddr5.arfm-b.sec-raaimt"
666 #define	SPD_KEY_DDR5_ARFMB_RAAIMT_FGR_SEC	"ddr5.arfm-b.sec-raaimt-fgr"
667 #define	SPD_KEY_DDR5_ARFMB_RAAMMT_SEC		"ddr5.arfm-b.sec-raammt"
668 #define	SPD_KEY_DDR5_ARFMB_RAAMMT_FGR_SEC	"ddr5.arfm-b.sec-raammt-fgr"
669 #define	SPD_KEY_DDR5_ARFMB_BRC_CFG_SEC		"ddr5.arfm-b.sec-brc-config"
670 #define	SPD_KEY_DDR5_ARFMB_BRC_SUP_SEC		"ddr5.arfm-b.sec-brc-level"
671 #define	SPD_KEY_DDR5_ARFMB_RAA_DEC_SEC		"ddr5.arfm-b.sec-raa-dec"
672 
673 #define	SPD_KEY_DDR5_ARFMC_FLAGS_PRI		"ddr5.arfm-c.flags"
674 #define	SPD_KEY_DDR5_ARFMC_RAAIMT_PRI		"ddr5.arfm-c.raaimt"
675 #define	SPD_KEY_DDR5_ARFMC_RAAIMT_FGR_PRI	"ddr5.arfm-c.raaimt-fgr"
676 #define	SPD_KEY_DDR5_ARFMC_RAAMMT_PRI		"ddr5.arfm-c.raammt"
677 #define	SPD_KEY_DDR5_ARFMC_RAAMMT_FGR_PRI	"ddr5.arfm-c.raammt-fgr"
678 #define	SPD_KEY_DDR5_ARFMC_BRC_CFG_PRI		"ddr5.arfm-c.brc-config"
679 #define	SPD_KEY_DDR5_ARFMC_BRC_SUP_PRI		"ddr5.arfm-c.brc-level"
680 #define	SPD_KEY_DDR5_ARFMC_RAA_DEC_PRI		"ddr5.arfm-c.raa-dec"
681 #define	SPD_KEY_DDR5_ARFMC_FLAGS_SEC		"ddr5.arfm-c.sec-flags"
682 #define	SPD_KEY_DDR5_ARFMC_RAAIMT_SEC		"ddr5.arfm-c.sec-raaimt"
683 #define	SPD_KEY_DDR5_ARFMC_RAAIMT_FGR_SEC	"ddr5.arfm-c.sec-raaimt-fgr"
684 #define	SPD_KEY_DDR5_ARFMC_RAAMMT_SEC		"ddr5.arfm-c.sec-raammt"
685 #define	SPD_KEY_DDR5_ARFMC_RAAMMT_FGR_SEC	"ddr5.arfm-c.sec-raammt-fgr"
686 #define	SPD_KEY_DDR5_ARFMC_BRC_CFG_SEC		"ddr5.arfm-c.sec-brc-config"
687 #define	SPD_KEY_DDR5_ARFMC_BRC_SUP_SEC		"ddr5.arfm-c.sec-brc-level"
688 #define	SPD_KEY_DDR5_ARFMC_RAA_DEC_SEC		"ddr5.arfm-c.sec-raa-dec"
689 /*
690  * Module-type specific keys and values. These are often the intersection of
691  * both the DDR standard and the module type. That is, a DDR4 and DDR5 RDIMM
692  * expose some information that isn't quite the same. These often contain things
693  * that are drive strengths and slew rates. These kinds of items fall into two
694  * categories. Ones where there is a fixed resistance and one where there is a
695  * qualitative range that depends on things like the specific parts present.
696  */
697 typedef enum {
698 	SPD_DRIVE_LIGHT,
699 	SPD_DRIVE_MODERATE,
700 	SPD_DRIVE_STRONG,
701 	SPD_DRIVE_VERY_STRONG,
702 	SPD_DRIVE_WEAK
703 } spd_drive_t;
704 
705 typedef enum {
706 	SPD_SLEW_SLOW,
707 	SPD_SLEW_MODERATE,
708 	SPD_SLEW_FAST
709 } spd_slew_t;
710 
711 /*
712  * DDR4 RDIMM and LRDIMM drive strengths. These all use the spd_drive_t. These
713  * are all on the RCD. There is also a key for whether or not slew-control is
714  * supported.
715  *
716  * DDR3 has similar, but not identical drive strengths. Rather than trying to
717  * combine them awkwardly, we just have a separate set of definitions. These may
718  * be made more uniform in the future. In DDR3 the LRDIMM does not incorporate a
719  * register like in DDR4, therefore the MB has overlapping drive strength keys.
720  */
721 #define	SPD_KEY_DDR3_RCD_DS_CAA	"ddr3.rcd.ca-a-drive-strength"
722 #define	SPD_KEY_DDR3_RCD_DS_CAB	"ddr3.rcd.ca-b-drive-strength"
723 #define	SPD_KEY_DDR3_RCD_DS_CTLA	"ddr3.rcd.cs-a-drive-strength"
724 #define	SPD_KEY_DDR3_RCD_DS_CTLB	"ddr3.rcd.cs-b-drive-strength"
725 #define	SPD_KEY_DDR3_RCD_DS_Y0	"ddr3.rcd.y0-drive-strength"
726 #define	SPD_KEY_DDR3_RCD_DS_Y1	"ddr3.rcd.y1-drive-strength"
727 
728 #define	SPD_KEY_DDR3_MB_DS_Y0	"ddr3.mb.y0-drive-strength"
729 #define	SPD_KEY_DDR3_MB_DS_Y1	"ddr3.mb.y1-drive-strength"
730 #define	SPD_KEY_DDR3_MB_DS_CKE	"ddr3.mb.cke-drive-strength"
731 #define	SPD_KEY_DDR3_MB_DS_ODT	"ddr3.mb.cke-drive-strength"
732 #define	SPD_KEY_DDR3_MB_DS_CS	"ddr3.mb.cs-drive-strength"
733 #define	SPD_KEY_DDR3_MB_DS_CA	"ddr3.mb.ca-drive-strength"
734 
735 #define	SPD_KEY_DDR4_RCD_SLEW	"ddr4.rcd.rcd-slew-control"	/* key */
736 #define	SPD_KEY_DDR4_RCD_DS_CKE	"ddr4.rcd.cke-drive-strength"
737 #define	SPD_KEY_DDR4_RCD_DS_ODT	"ddr4.rcd.odt-drive-strength"
738 #define	SPD_KEY_DDR4_RCD_DS_CA	"ddr4.rcd.ca-drive-strength"
739 #define	SPD_KEY_DDR4_RCD_DS_CS	"ddr4.rcd.cs-drive-strength"
740 #define	SPD_KEY_DDR4_RCD_DS_Y0	"ddr4.rcd.y0-drive-strength"
741 #define	SPD_KEY_DDR4_RCD_DS_Y1	"ddr4.rcd.y1-drive-strength"
742 #define	SPD_KEY_DDR4_RCD_DS_BCOM	"ddr4.rcd.bcom-drive-strength"
743 #define	SPD_KEY_DDR4_RCD_DS_BCK	"ddr4.rcd.bck-drive-strength"
744 
745 /*
746  * DDR3 LRDIMMs have the ability to specify the orientation of the memory
747  * buffer. These describe the physical orientation relative to the edge
748  * connector.
749  */
750 typedef enum {
751 	SPD_ORNT_HORIZONTAL,
752 	SPD_ORNT_VERTICAL
753 } spd_orientation_t;
754 #define	SPD_KEY_DDR3_MB_ORIENT	"ddr3.mb.orientation"		/* uint32_t */
755 
756 /*
757  * DDR3 LRDIMMs have various extended and additive clock delays for various
758  * signals. The extended delay is x/128 * tCK while the additive delay is x/32 *
759  * tCK. We store these all as uint32_t keys where the value is the value of x
760  * above. If there is no delay or the delay is not enabled, then the key will
761  * not exist.
762  */
763 #define	SPD_KEY_DDR3_MB_EXTD_Y		"ddr4.mb.y-extended-delay"
764 #define	SPD_KEY_DDR3_MB_EXTD_CS		"ddr4.mb.cs-extended-delay"
765 #define	SPD_KEY_DDR3_MB_EXTD_ODT	"ddr4.mb.odt-extended-delay"
766 #define	SPD_KEY_DDR3_MB_EXTD_CKE	"ddr4.mb.cke-extended-delay"
767 #define	SPD_KEY_DDR3_MB_ADDD_Y		"ddr4.mb.y-additive-delay"
768 #define	SPD_KEY_DDR3_MB_ADDD_CS		"ddr4.mb.cs-additive-delay"
769 #define	SPD_KEY_DDR3_MB_ADDD_ODT	"ddr4.mb.odt-additive-delay"
770 #define	SPD_KEY_DDR3_MB_ADDD_CKE	"ddr4.mb.cke-additive-delay"
771 
772 /*
773  * DDR3 LRDIMMs have the ability to control whether or not QxODT[1:0] is
774  * asserted during reads or writes on each rank. There is a value for each of
775  * the three primary speed buckets in DDR3: 800/1066, 1333/1600, and
776  * 1866/2133. This is organized as a series of boolean_t[3] entries where each
777  * entry corresponds to one of the three speeds.
778  */
779 #define	SPD_KEY_DDR3_MB_R0_ODT0_RD	"ddr3.mb.r0-qxodt0-read-assert"
780 #define	SPD_KEY_DDR3_MB_R0_ODT1_RD	"ddr3.mb.r0-qxodt1-read-assert"
781 #define	SPD_KEY_DDR3_MB_R0_ODT0_WR	"ddr3.mb.r0-qxodt0-write-assert"
782 #define	SPD_KEY_DDR3_MB_R0_ODT1_WR	"ddr3.mb.r0-qxodt1-write-assert"
783 #define	SPD_KEY_DDR3_MB_R1_ODT0_RD	"ddr3.mb.r1-qxodt0-read-assert"
784 #define	SPD_KEY_DDR3_MB_R1_ODT1_RD	"ddr3.mb.r1-qxodt1-read-assert"
785 #define	SPD_KEY_DDR3_MB_R1_ODT0_WR	"ddr3.mb.r1-qxodt0-write-assert"
786 #define	SPD_KEY_DDR3_MB_R1_ODT1_WR	"ddr3.mb.r1-qxodt1-write-assert"
787 #define	SPD_KEY_DDR3_MB_R2_ODT0_RD	"ddr3.mb.r2-qxodt0-read-assert"
788 #define	SPD_KEY_DDR3_MB_R2_ODT1_RD	"ddr3.mb.r2-qxodt1-read-assert"
789 #define	SPD_KEY_DDR3_MB_R2_ODT0_WR	"ddr3.mb.r2-qxodt0-write-assert"
790 #define	SPD_KEY_DDR3_MB_R2_ODT1_WR	"ddr3.mb.r2-qxodt1-write-assert"
791 #define	SPD_KEY_DDR3_MB_R3_ODT0_RD	"ddr3.mb.r3-qxodt0-read-assert"
792 #define	SPD_KEY_DDR3_MB_R3_ODT1_RD	"ddr3.mb.r3-qxodt1-read-assert"
793 #define	SPD_KEY_DDR3_MB_R3_ODT0_WR	"ddr3.mb.r3-qxodt0-write-assert"
794 #define	SPD_KEY_DDR3_MB_R3_ODT1_WR	"ddr3.mb.r3-qxodt1-write-assert"
795 #define	SPD_KEY_DDR3_MB_R4_ODT0_RD	"ddr3.mb.r4-qxodt0-read-assert"
796 #define	SPD_KEY_DDR3_MB_R4_ODT1_RD	"ddr3.mb.r4-qxodt1-read-assert"
797 #define	SPD_KEY_DDR3_MB_R4_ODT0_WR	"ddr3.mb.r4-qxodt0-write-assert"
798 #define	SPD_KEY_DDR3_MB_R4_ODT1_WR	"ddr3.mb.r4-qxodt1-write-assert"
799 #define	SPD_KEY_DDR3_MB_R5_ODT0_RD	"ddr3.mb.r5-qxodt0-read-assert"
800 #define	SPD_KEY_DDR3_MB_R5_ODT1_RD	"ddr3.mb.r5-qxodt1-read-assert"
801 #define	SPD_KEY_DDR3_MB_R5_ODT0_WR	"ddr3.mb.r5-qxodt0-write-assert"
802 #define	SPD_KEY_DDR3_MB_R5_ODT1_WR	"ddr3.mb.r5-qxodt1-write-assert"
803 #define	SPD_KEY_DDR3_MB_R6_ODT0_RD	"ddr3.mb.r6-qxodt0-read-assert"
804 #define	SPD_KEY_DDR3_MB_R6_ODT1_RD	"ddr3.mb.r6-qxodt1-read-assert"
805 #define	SPD_KEY_DDR3_MB_R6_ODT0_WR	"ddr3.mb.r6-qxodt0-write-assert"
806 #define	SPD_KEY_DDR3_MB_R6_ODT1_WR	"ddr3.mb.r6-qxodt1-write-assert"
807 #define	SPD_KEY_DDR3_MB_R7_ODT0_RD	"ddr3.mb.r7-qxodt0-read-assert"
808 #define	SPD_KEY_DDR3_MB_R7_ODT1_RD	"ddr3.mb.r7-qxodt1-read-assert"
809 #define	SPD_KEY_DDR3_MB_R7_ODT0_WR	"ddr3.mb.r7-qxodt0-write-assert"
810 #define	SPD_KEY_DDR3_MB_R7_ODT1_WR	"ddr3.mb.r7-qxodt1-write-assert"
811 
812 /*
813  * DDR4 LRDIMMs specify the VrefDQ for each package rank. These are communicated
814  * in terms of the DDR4 spec which specifies them as a percentage of the actual
815  * voltage. This is always phrased in the spec as AB.CD%, so for example 60.25%.
816  * We treat this percentage as a four digit unsigned value rather than trying to
817  * play games with whether or not the value can be represented in floating
818  * point. Divide the value by 100 to get the percentage. That is, 47.60% will be
819  * encoded as 4760. All of these values are a uint32_t.
820  */
821 #define	SPD_KEY_DDR4_VREFDQ_R0	"ddr4.lrdimm.VrefDQ-rank0"
822 #define	SPD_KEY_DDR4_VREFDQ_R1	"ddr4.lrdimm.VrefDQ-rank1"
823 #define	SPD_KEY_DDR4_VREFDQ_R2	"ddr4.lrdimm.VrefDQ-rank2"
824 #define	SPD_KEY_DDR4_VREFDQ_R3	"ddr4.lrdimm.VrefDQ-rank3"
825 #define	SPD_KEY_DDR4_VREFDQ_DB	"ddr4.lrdimm.VrefDQ-db"
826 
827 /*
828  * DDR4 LRDIMMs define the data buffer drive strength and termination in terms
829  * of various data rate ranges. Specifically (0, 1866], (1866, 2400], and (2400,
830  * 3200]. All of these values are measured in terms of Ohms. As such, all of
831  * these values are an array of three uint32_t's whose values correspond to each
832  * of those ranges. We define a few additional values for these to represent
833  * cases where they are disabled or high-impedance.
834  *
835  * DDR3 LRDIMMs are similar, but their groups are 800/1066, 1333/1600, and
836  * 1866/2133.
837  */
838 #define	SPD_TERM_DISABLED	0
839 #define	SPD_TERM_HIZ		UINT32_MAX
840 #define	SPD_KEY_DDR4_MDQ_RTT	"ddr4.lrdimm.mdq-read-termination"
841 #define	SPD_KEY_DDR4_MDQ_DS	"ddr4.lrdimm.mdq-drive-strength"
842 #define	SPD_KEY_DDR4_DRAM_DS	"ddr4.lrdimm.dram-drive-strength"
843 #define	SPD_KEY_DDR4_RTT_WR	"ddr4.lrdimm.odt-read-termination-wr"
844 #define	SPD_KEY_DDR4_RTT_NOM	"ddr4.lrdimm.odt-read-termination-nom"
845 #define	SPD_KEY_DDR4_RTT_PARK_R0	"ddr4.lrdimm.odt-r0_1-rtt-park"
846 #define	SPD_KEY_DDR4_RTT_PARK_R2	"ddr4.lrdimm.odt-r2_3-rtt-park"
847 
848 #define	SPD_KEY_DDR3_MDQ_DS	"ddr3.lrdimm.mdq-drive-strength"
849 #define	SPD_KEY_DDR3_MDQ_ODT	"ddr3.lrdimm.mdq-odt-strength"
850 #define	SPD_KEY_DDR3_RTT_WRT	"ddr3.lrdimm.mdq-odt-read-termination-wr"
851 #define	SPD_KEY_DDR3_RTT_NOM	"ddr3.lrdimm.mdq-odt-read-termination-nom"
852 #define	SPD_KEY_DDR3_DRAM_DS	"ddr3.lrdimm.dram-drive-strength"
853 
854 /*
855  * DDR3 LRDIMMs specify a minimum and maximum delay for the various supported
856  * voltage types. These are stored as two uint64_t[3] arrays ordered as 1.25,
857  * 1.35, and 1.5V. These are times in ps.
858  */
859 #define	SPD_KEY_DDR3_MOD_MIN_DELAY	"ddr3.lrdimm.minimum-module-delay"
860 #define	SPD_KEY_DDR3_MOD_MAX_DELAY	"ddr3.lrdimm.maximum-module-delay"
861 
862 /*
863  * DDR3 LRDIMMs also have personality bytes that are loaded directly into the
864  * memory buffer control words. We pass these through as a uint8_t[15].
865  */
866 #define	SPD_KEY_DDR3_MB_PERS	"ddr3.lrdimm.personality"
867 
868 /*
869  * The last DDR4 LRDIMM specific component is whether or not the data buffer's
870  * gain and decision feedback equalization are supported. These both are keys.
871  */
872 #define	SPD_KEY_DDR4_DB_GAIN	"ddr4.lrdimm.db-gain-adjustment"
873 #define	SPD_KEY_DDR4_DB_DFE	"ddr4.lrdimm.decision-feedback-eq"
874 
875 /*
876  * DDR5 RDIMMs and LRDIMMs have specific enables for groups of pins. There are
877  * then drive strength values which are encoded as a spd_drive_t. Note, prior to
878  * DDR5 RDIMMs v1.1, these were differential impedance values measured in Ohms.
879  * These have been normalized to the general drive strength enums. Separately
880  * there are slew rates, those use the spd_slew_t. Because these use different
881  * units between DDR4 and DDR5, we treat them as different keys.
882  */
883 #define	SPD_KEY_DDR5_RCD_QACK_EN	"ddr5.rcd.qack-enabled"
884 #define	SPD_KEY_DDR5_RCD_QBCK_EN	"ddr5.rcd.qbck-enabled"
885 #define	SPD_KEY_DDR5_RCD_QCCK_EN	"ddr5.rcd.qcck-enabled"
886 #define	SPD_KEY_DDR5_RCD_QDCK_EN	"ddr5.rcd.qdck-enabled"
887 #define	SPD_KEY_DDR5_RCD_BCK_EN		"ddr5.rcd.bck-enabled"
888 #define	SPD_KEY_DDR5_RCD_QACA_EN	"ddr5.rcd.qaca-enabled"
889 #define	SPD_KEY_DDR5_RCD_QBCA_EN	"ddr5.rcd.qbca-enabled"
890 #define	SPD_KEY_DDR5_RCD_QxCS_EN	"ddr5.rcd.qxcs-enabled"
891 #define	SPD_KEY_DDR5_RCD_QxCA13_EN	"ddr5.rcd.qxca13-enabled"
892 #define	SPD_KEY_DDR5_RCD_QACS_EN	"ddr5.rcd.qacs-enabled"
893 #define	SPD_KEY_DDR5_RCD_QBCS_EN	"ddr5.rcd.qbcs-enabled"
894 
895 /* Drive strengths use the spd_drive_t encoded as a uint32_t */
896 #define	SPD_KEY_DDR5_RCD_QACK_DS	"ddr5.rcd.qack-drive-strength"
897 #define	SPD_KEY_DDR5_RCD_QBCK_DS	"ddr5.rcd.qbck-drive-strength"
898 #define	SPD_KEY_DDR5_RCD_QCCK_DS	"ddr5.rcd.qcck-drive-strength"
899 #define	SPD_KEY_DDR5_RCD_QDCK_DS	"ddr5.rcd.qdck-drive-strength"
900 #define	SPD_KEY_DDR5_RCD_QxCS_DS	"ddr5.rcd.qxcs-drive-strength"
901 #define	SPD_KEY_DDR5_RCD_CA_DS		"ddr5.rcd.ca-drive-strength"
902 
903 /* Slew rates use the spd_rate_t encoded as a uint32_t */
904 #define	SPD_KEY_DDR5_RCD_QCK_SLEW	"ddr5.rcd.qck-slew"
905 #define	SPD_KEY_DDR5_RCD_QCA_SLEW	"ddr5.rcd.qca-slew"
906 #define	SPD_KEY_DDR5_RCD_QCS_SLEW	"ddr5.rcd.qcs-slew"
907 
908 /*
909  * These are all specific to DDR5 LRDIMMs. The values are the same as above. The
910  * RTT value is a value in Ohms. If RTT termination is disabled then the key
911  * will not be present.
912  */
913 #define	SPD_KEY_DDR5_RCD_BCS_EN		"ddr5.rcd.bcs-enabled" /* key */
914 #define	SPD_KEY_DDR5_RCD_BCOM_DS	"ddr5.rcd.bcom-drive-strength"
915 #define	SPD_KEY_DDR5_RCD_BCK_DS		"ddr5.rcd.bck-drive-strength"
916 #define	SPD_KEY_DDR5_RCD_RTT_TERM	"ddr5.rcd.dqs-rtt"
917 #define	SPD_KEY_DDR5_RCD_BCOM_SLEW	"ddr5.rcd.bcom-slew"
918 #define	SPD_KEY_DDR5_RCD_BCK_SLEW	"ddr5.rcd.bck-slew"
919 
920 /*
921  * DDR5 UDIMM specific values. Note, these are only present in UDIMM v1.1 and
922  * therefore may be missing in older revisions.
923  */
924 
925 /*
926  * Unbuffered clock configuration, drivers, and slew rates. The various -enabled
927  * values are keys. The drive strengths and slew rates use the spd_drive_t and
928  * spd_slew_t respectively encoded as uint32_t values.
929  */
930 #define	SPD_KEY_DDR5_CKD_CHAQCK0_EN	"ddr5.ckd.cha-qck0_A-enabled"
931 #define	SPD_KEY_DDR5_CKD_CHAQCK1_EN	"ddr5.ckd.cha-qck1_A-enabled"
932 #define	SPD_KEY_DDR5_CKD_CHBQCK0_EN	"ddr5.ckd.chb-qck0_B-enabled"
933 #define	SPD_KEY_DDR5_CKD_CHBQCK1_EN	"ddr5.ckd.chb-qck1_B-enabled"
934 #define	SPD_KEY_DDR5_CKD_CHAQCK0_DS	"ddr5.ckd.cha-qck0_A-drive-strength"
935 #define	SPD_KEY_DDR5_CKD_CHAQCK1_DS	"ddr5.ckd.cha-qck1_A-drive-strength"
936 #define	SPD_KEY_DDR5_CKD_CHBQCK0_DS	"ddr5.ckd.chb-qck0_B-drive-strength"
937 #define	SPD_KEY_DDR5_CKD_CHBQCK1_DS	"ddr5.ckd.chb-qck1_B-drive-strength"
938 #define	SPD_KEY_DDR5_CKD_CHAQCK_SLEW	"ddr5.ckd.cha-qck_slew"
939 #define	SPD_KEY_DDR5_CKD_CHBQCK_SLEW	"ddr5.ckd.chb-qck_slew"
940 
941 /*
942  * DDR5 MRDIMM specific values. Note, these are only present in MRDIMM v1.1 and
943  * therefore may be missing in older revisions. While these values are really
944  * similar to the RDIMM variants, because they are taken from the MRCD instead
945  * of the RCD specification, we define different keys.
946  */
947 #define	SPD_KEY_DDR5_MRCD_QACK_EN	"ddr5.mrcd.qack-enabled"
948 #define	SPD_KEY_DDR5_MRCD_QBCK_EN	"ddr5.mrcd.qbck-enabled"
949 #define	SPD_KEY_DDR5_MRCD_QCCK_EN	"ddr5.mrcd.qcck-enabled"
950 #define	SPD_KEY_DDR5_MRCD_QDCK_EN	"ddr5.mrcd.qdck-enabled"
951 #define	SPD_KEY_DDR5_MRCD_BCK_EN	"ddr5.mrcd.bck-enabled"
952 #define	SPD_KEY_DDR5_MRCD_QACA_EN	"ddr5.mrcd.qaca-enabled"
953 #define	SPD_KEY_DDR5_MRCD_QBCA_EN	"ddr5.mrcd.qbca-enabled"
954 #define	SPD_KEY_DDR5_MRCD_BCS_EN	"ddr5.mrcd.bcs-enabled"
955 #define	SPD_KEY_DDR5_MRCD_QxCS_EN	"ddr5.mrcd.qxcs-enabled"
956 #define	SPD_KEY_DDR5_MRCD_QxCA13_EN	"ddr5.mrcd.qxca13-enabled"
957 #define	SPD_KEY_DDR5_MRCD_QACS_EN	"ddr5.mrcd.qacs-enabled"
958 #define	SPD_KEY_DDR5_MRCD_QBCS_EN	"ddr5.mrcd.qbcs-enabled"
959 #define	SPD_KEY_DDR5_MRCD_DCS1_EN	"ddr5.mrcd.dcs1-enabled"
960 
961 /* Drive strengths use the spd_drive_t encoded as a uint32_t */
962 #define	SPD_KEY_DDR5_MRCD_QACK_DS	"ddr5.mrcd.qack-drive-strength"
963 #define	SPD_KEY_DDR5_MRCD_QBCK_DS	"ddr5.mrcd.qbck-drive-strength"
964 #define	SPD_KEY_DDR5_MRCD_QCCK_DS	"ddr5.mrcd.qcck-drive-strength"
965 #define	SPD_KEY_DDR5_MRCD_QDCK_DS	"ddr5.mrcd.qdck-drive-strength"
966 #define	SPD_KEY_DDR5_MRCD_QxCS_DS	"ddr5.mrcd.qxcs-drive-strength"
967 #define	SPD_KEY_DDR5_MRCD_CA_DS		"ddr5.mrcd.ca-drive-strength"
968 #define	SPD_KEY_DDR5_MRCD_BCOM_DS	"ddr5.mrcd.bcom-drive-strength"
969 #define	SPD_KEY_DDR5_MRCD_BCK_DS	"ddr5.mrcd.bck-drive-strength"
970 
971 /* Slew rates use the spd_rate_t encoded as a uint32_t */
972 #define	SPD_KEY_DDR5_MRCD_QCK_SLEW	"ddr5.mrcd.qck-slew"
973 #define	SPD_KEY_DDR5_MRCD_QCA_SLEW	"ddr5.mrcd.qca-slew"
974 #define	SPD_KEY_DDR5_MRCD_QCS_SLEW	"ddr5.mrcd.qcs-slew"
975 #define	SPD_KEY_DDR5_MRCD_BCOM_SLEW	"ddr5.mrcd.bcom-slew"
976 #define	SPD_KEY_DDR5_MRCD_BCK_SLEW	"ddr5.mrcd.bck-slew"
977 
978 typedef enum {
979 	SPD_MRCD_OUT_NORMAL,
980 	SPD_MRCD_OUT_DISABLED,
981 	SPD_MRCD_OUT_LOW
982 } spd_mrcd_output_ctrl_t;
983 #define	SPD_KEY_DDR5_MRCD_QxCS_OUT	"ddr5.mrcd.qxcs-output-control"
984 
985 typedef enum {
986 	SPD_MRCD_DCA_CFG_0,
987 	SPD_MRCD_DCA_CFG_1
988 } spd_mrcd_dca_cfg_t;
989 #define	SPD_KEY_DDR5_MRCD_DCA_CFG	"ddr5.mrcd.dca-configuration"
990 
991 typedef enum {
992 	SPD_MRDIMM_IRXT_UNMATCHED,
993 	SPD_MRDIMM_IRXT_MATCHED
994 } spd_mrdimm_irxt_t;
995 #define	SPD_KEY_DDR5_MRDIMM_IRXT	"ddr5.mrdimm.interface-rx-type"
996 
997 /*
998  * Module Properties. These are items that generally relate to the module as a
999  * whole.
1000  */
1001 
1002 /*
1003  * Connection Mapping. In DDR4 there is the ability to remap groups of pins from
1004  * the connector to the various package SDRAMs. Every 4 bits can be remapped to
1005  * either another upper or lower nibble in a package. Separately bits can also
1006  * be flipped between packages. These exist for all 64-bits of DQ and 8 bits of
1007  * CBs. If mirroring is set, then a key will be added for that pin group. For
1008  * each pin group, the mapping to a specific type of rewriting will be done. We
1009  * conventionally use 0, 1, 2, and 3 as the lower nibble and 4, 5, 6, 7 as the
1010  * upper nibble, though the actual pins will vary based on where they are.
1011  */
1012 #define	SPD_KEY_DDR4_MAP_DQ0	"module.dq0-map"	/* uint32_t [4] */
1013 #define	SPD_KEY_DDR4_MAP_DQ4	"module.dq4-map"	/* uint32_t [4] */
1014 #define	SPD_KEY_DDR4_MAP_DQ8	"module.dq8-map"	/* uint32_t [4] */
1015 #define	SPD_KEY_DDR4_MAP_DQ12	"module.dq12-map"	/* uint32_t [4] */
1016 #define	SPD_KEY_DDR4_MAP_DQ16	"module.dq16-map"	/* uint32_t [4] */
1017 #define	SPD_KEY_DDR4_MAP_DQ20	"module.dq20-map"	/* uint32_t [4] */
1018 #define	SPD_KEY_DDR4_MAP_DQ24	"module.dq24-map"	/* uint32_t [4] */
1019 #define	SPD_KEY_DDR4_MAP_DQ28	"module.dq28-map"	/* uint32_t [4] */
1020 #define	SPD_KEY_DDR4_MAP_DQ32	"module.dq32-map"	/* uint32_t [4] */
1021 #define	SPD_KEY_DDR4_MAP_DQ36	"module.dq36-map"	/* uint36_t [4] */
1022 #define	SPD_KEY_DDR4_MAP_DQ40	"module.dq40-map"	/* uint32_t [4] */
1023 #define	SPD_KEY_DDR4_MAP_DQ44	"module.dq44-map"	/* uint32_t [4] */
1024 #define	SPD_KEY_DDR4_MAP_DQ48	"module.dq48-map"	/* uint32_t [4] */
1025 #define	SPD_KEY_DDR4_MAP_DQ52	"module.dq52-map"	/* uint32_t [4] */
1026 #define	SPD_KEY_DDR4_MAP_DQ56	"module.dq56-map"	/* uint32_t [4] */
1027 #define	SPD_KEY_DDR4_MAP_DQ60	"module.dq60-map"	/* uint32_t [4] */
1028 #define	SPD_KEY_DDR4_MAP_CB0	"module.cb0-map"	/* uint32_t [4] */
1029 #define	SPD_KEY_DDR4_MAP_CB4	"module.cb4-map"	/* uint32_t [4] */
1030 
1031 /*
1032  * In addition, there is module level mapping in DDR3/DDR4 that is used to
1033  * indicate that odd ranks are mirrored. This is between the edge connector and
1034  * the DRAM itself. We only add a key when it is mirrored.
1035  */
1036 #define	SPD_KEY_MOD_EDGE_MIRROR	"module.edge-odd-mirror"	/* key */
1037 
1038 /*
1039  * Present devices. Modules often have multiple additional types of devices
1040  * present like temperature sensors, voltage regulators, registers, etc. The
1041  * following key indicates what all is present on this DIMM. Depending on the
1042  * DDR revision, we will then have additional keys with its ID, revision, name,
1043  * and compliant type. In a few cases we will define the type and presence based
1044  * on information. For example, DDR4 only allows a single type of temperature
1045  * sensor or SPD device. Even though we don't know the manufacturer, we will
1046  * still note this.
1047  *
1048  * Each of these items will have four keys. One for the manufacturer ID, one for
1049  * their string name, one for the device type, and one for the revision. Note,
1050  * while TS1 and TS2 are both flags in DDR5, they share common manufacturer
1051  * information, which is why there is only one entry here.
1052  *
1053  * For each device type there is a separate enum with supported types of devices
1054  * that can be present for these.
1055  */
1056 typedef enum {
1057 	SPD_DEVICE_TEMP_1	= 1 << 0,
1058 	SPD_DEVICE_TEMP_2	= 1 << 1,
1059 	SPD_DEVICE_HS		= 1 << 2,
1060 	SPD_DEVICE_PMIC_0	= 1 << 3,
1061 	SPD_DEVICE_PMIC_1	= 1 << 4,
1062 	SPD_DEVICE_PMIC_2	= 1 << 5,
1063 	SPD_DEVICE_CD_0		= 1 << 6,
1064 	SPD_DEVICE_CD_1		= 1 << 7,
1065 	SPD_DEVICE_RCD		= 1 << 8,
1066 	SPD_DEVICE_DB		= 1 << 9,
1067 	SPD_DEVICE_MRCD		= 1 << 10,
1068 	SPD_DEVICE_MDB		= 1 << 11,
1069 	SPD_DEVICE_DMB		= 1 << 12,
1070 	SPD_DEVICE_SPD		= 1 << 13
1071 } spd_device_t;
1072 #define	SPD_KEY_DEVS		"module.devices"	/* uint32_t */
1073 
1074 typedef enum {
1075 	/* DDR3 */
1076 	SPD_TEMP_T_TSE2002,
1077 	/* DDR4 and LPDDR4 */
1078 	SPD_TEMP_T_TSE2004av,
1079 	/* DDR5 */
1080 	SPD_TEMP_T_TS5111,
1081 	SPD_TEMP_T_TS5110,
1082 	SPD_TEMP_T_TS5211,
1083 	SPD_TEMP_T_TS5210
1084 } spd_temp_type_t;
1085 
1086 typedef enum {
1087 	/* DDR5 */
1088 	SPD_PMIC_T_PMIC5000,
1089 	SPD_PMIC_T_PMIC5010,
1090 	SPD_PMIC_T_PMIC5100,
1091 	SPD_PMIC_T_PMIC5020,
1092 	SPD_PMIC_T_PMIC5120,
1093 	SPD_PMIC_T_PMIC5200,
1094 	SPD_PMIC_T_PMIC5030
1095 } spd_pmic_type_t;
1096 
1097 typedef enum {
1098 	/* DDR5 */
1099 	SPD_CD_T_DDR5CK01
1100 } spd_cd_type_t;
1101 
1102 typedef enum {
1103 	/* DDR3 */
1104 	SPD_RCD_T_SSTE32882,
1105 	/* DDR4 */
1106 	SPD_RCD_T_DDR4RCD01,
1107 	SPD_RCD_T_DDR4RCD02,
1108 	/* DDR5 */
1109 	SPD_RCD_T_DDR5RCD01,
1110 	SPD_RCD_T_DDR5RCD02,
1111 	SPD_RCD_T_DDR5RCD03,
1112 	SPD_RCD_T_DDR5RCD04,
1113 	SPD_RCD_T_DDR5RCD05
1114 } spd_rcd_type_t;
1115 
1116 typedef enum {
1117 	/* DDR4 */
1118 	SPD_DB_T_DDR4DB01,
1119 	SPD_DB_T_DDR4DB02,
1120 	/* DDR5 */
1121 	SPD_DB_T_DDR5DB01,
1122 	SPD_DB_T_DDR5DB02,
1123 	/*
1124 	 * DDR3 LRDIMMs had a memory buffer that did not have a full
1125 	 * desgination. We count them here.
1126 	 */
1127 	SPD_DB_T_DDR3MB
1128 } spd_db_type_t;
1129 
1130 typedef enum {
1131 	/* DDR5 */
1132 	SPD_MRCD_T_DDR5MRCD01,
1133 	SPD_MRCD_T_DDR5MRCD02,
1134 } spd_mrcd_type_t;
1135 
1136 typedef enum {
1137 	/* DDR5 */
1138 	SPD_MDB_T_DDR5MDB01,
1139 	SPD_MDB_T_DDR5MDB02
1140 } spd_mdb_type_t;
1141 
1142 typedef enum {
1143 	/* DDR5 */
1144 	SPD_DMB_T_DMB5011
1145 } spd_dmb_type_t;
1146 
1147 typedef enum {
1148 	/* DDR4 */
1149 	SPD_SPD_T_EE1004,
1150 	/* DDR5 */
1151 	SPD_SPD_T_SPD5118,
1152 	SPD_SPD_T_ESPD5216,
1153 	/* DDR3 */
1154 	SPD_SPD_T_EE1002
1155 } spd_spd_type_t;
1156 
1157 #define	SPD_KEY_DEV_TEMP_MFG	"module.temp.mfg-id"	/* uint32_t [2] */
1158 #define	SPD_KEY_DEV_TEMP_MFG_NAME	"module.temp.mfg-name"	/* string */
1159 #define	SPD_KEY_DEV_TEMP_TYPE	"module.temp.type"	/* uint32_t */
1160 #define	SPD_KEY_DEV_TEMP_REV	"module.temp.revision"	/* string */
1161 
1162 #define	SPD_KEY_DEV_PMIC0_MFG	"module.pmic0.mfg-id"	/* uint32_t [2] */
1163 #define	SPD_KEY_DEV_PMIC0_MFG_NAME	"module.pmic0.mfg-name"	/* string */
1164 #define	SPD_KEY_DEV_PMIC0_TYPE	"module.pmic0.type"	/* uint32_t */
1165 #define	SPD_KEY_DEV_PMIC0_REV	"module.pmic0.revision"	/* string */
1166 #define	SPD_KEY_DEV_PMIC1_MFG	"module.pmic1.mfg-id"	/* uint32_t [2] */
1167 #define	SPD_KEY_DEV_PMIC1_MFG_NAME	"module.pmic1.mfg-name"	/* string */
1168 #define	SPD_KEY_DEV_PMIC1_TYPE	"module.pmic1.type"	/* uint32_t */
1169 #define	SPD_KEY_DEV_PMIC1_REV	"module.pmic1.revision"	/* string */
1170 #define	SPD_KEY_DEV_PMIC2_MFG	"module.pmic2.mfg-id"	/* uint32_t [2] */
1171 #define	SPD_KEY_DEV_PMIC2_MFG_NAME	"module.pmic2.mfg-name"	/* string */
1172 #define	SPD_KEY_DEV_PMIC2_TYPE	"module.pmic2.type"	/* uint32_t */
1173 #define	SPD_KEY_DEV_PMIC2_REV	"module.pmic2.revision"	/* string */
1174 
1175 #define	SPD_KEY_DEV_CD0_MFG	"module.cd0.mfg-id"	/* uint32_t [2] */
1176 #define	SPD_KEY_DEV_CD0_MFG_NAME	"module.cd0.mfg-name"	/* string */
1177 #define	SPD_KEY_DEV_CD0_TYPE	"module.cd0.type"	/* uint32_t */
1178 #define	SPD_KEY_DEV_CD0_REV	"module.cd0.revision"	/* string */
1179 #define	SPD_KEY_DEV_CD1_MFG	"module.cd1.mfg-id"	/* uint32_t [2] */
1180 #define	SPD_KEY_DEV_CD1_MFG_NAME	"module.cd1.mfg-name"	/* string */
1181 #define	SPD_KEY_DEV_CD1_TYPE	"module.cd1.type"	/* uint32_t */
1182 #define	SPD_KEY_DEV_CD1_REV	"module.cd1.revision"	/* string */
1183 
1184 #define	SPD_KEY_DEV_RCD_MFG	"module.rcd.mfg-id"	/* uint32_t [2] */
1185 #define	SPD_KEY_DEV_RCD_MFG_NAME	"module.rcd.mfg-name"	/* string */
1186 #define	SPD_KEY_DEV_RCD_TYPE	"module.rcd.type"	/* uint32_t */
1187 #define	SPD_KEY_DEV_RCD_REV	"module.rcd.revision"	/* string */
1188 
1189 #define	SPD_KEY_DEV_DB_MFG	"module.db.mfg-id"	/* uint32_t [2] */
1190 #define	SPD_KEY_DEV_DB_MFG_NAME	"module.db.mfg-name"	/* string */
1191 #define	SPD_KEY_DEV_DB_TYPE	"module.db.type"	/* uint32_t */
1192 #define	SPD_KEY_DEV_DB_REV	"module.db.revision"	/* string */
1193 
1194 #define	SPD_KEY_DEV_MRCD_MFG	"module.mrcd.mfg-id"	/* uint32_t [2] */
1195 #define	SPD_KEY_DEV_MRCD_MFG_NAME	"module.mrcd.mfg-name"	/* string */
1196 #define	SPD_KEY_DEV_MRCD_TYPE	"module.mrcd.type"	/* uint32_t */
1197 #define	SPD_KEY_DEV_MRCD_REV	"module.mrcd.revision"	/* string */
1198 
1199 #define	SPD_KEY_DEV_MDB_MFG	"module.mdb.mfg-id"	/* uint32_t [2] */
1200 #define	SPD_KEY_DEV_MDB_MFG_NAME	"module.mdb.mfg-name"	/* string */
1201 #define	SPD_KEY_DEV_MDB_TYPE	"module.mdb.type"	/* uint32_t */
1202 #define	SPD_KEY_DEV_MDB_REV	"module.mdb.revision"	/* string */
1203 
1204 #define	SPD_KEY_DEV_DMB_MFG	"module.dmb.mfg-id"	/* uint32_t [2] */
1205 #define	SPD_KEY_DEV_DMB_MFG_NAME	"module.dmb.mfg-name"	/* string */
1206 #define	SPD_KEY_DEV_DMB_TYPE	"module.dmb.type"	/* uint32_t */
1207 #define	SPD_KEY_DEV_DMB_REV	"module.dmb.revision"	/* string */
1208 
1209 #define	SPD_KEY_DEV_SPD_MFG	"module.spd.mfg-id"	/* uint32_t [2] */
1210 #define	SPD_KEY_DEV_SPD_MFG_NAME	"module.spd.mfg-name"	/* string */
1211 #define	SPD_KEY_DEV_SPD_TYPE	"module.spd.type"	/* uint32_t */
1212 #define	SPD_KEY_DEV_SPD_REV	"module.spd.revision"	/* string */
1213 
1214 /*
1215  * Module physical dimensions. DRAM modules provide information about their
1216  * height and their front and back thicknesses. All values are in millimeters.
1217  * In general, values are defined as 1 mm ranges in the form such as 18mm <
1218  * height <= 19mm or 2mm < thickness <= 3mm. As such in all these ranges we
1219  * encode it as the less than or equal to side of the thickness or height.
1220  *
1221  * However, at the extremes of thickness and height, it can be arbitrary. The
1222  * minimum height can be any value <= 15mm and the maximum is just > 45mm.
1223  * Similarly the maximum thickness is just any value greater than 15mm. For
1224  * these values, we define aliases that can be used to indicate we're in these
1225  * conditions for the height and thickness, allowing this to otherwise be the
1226  * common well understood value.
1227  */
1228 #define	SPD_MOD_HEIGHT_LT15MM	15
1229 #define	SPD_MOD_HEIGHT_GT45MM	46
1230 #define	SPD_KEY_MOD_HEIGHT	"module.height"		/* uint32_t */
1231 #define	SPD_MOD_THICK_GT15MM	16
1232 #define	SPD_KEY_MOD_FRONT_THICK	"module.front-thickness"	/* uint32_t */
1233 #define	SPD_KEY_MOD_BACK_THICK	"module.back-thickness"	/* uint32_t */
1234 
1235 /*
1236  * This is the number of rows of DRAM dies on the module. In addition, DDR3 and
1237  * DDR4 provides the number of registers present on the device. This is not
1238  * present in DDR5.
1239  */
1240 #define	SPD_KEY_MOD_NROWS	"module.dram-die-rows"		/* uint32_t */
1241 #define	SPD_KEY_MOD_NREGS	"module.total-registers"	/* uint32_t */
1242 
1243 /*
1244  * Operating temperature ranges. These ranges are defined by JEDEC. The code can
1245  * be translated with libjedec_temp_range() to transform it into a pair of
1246  * values.
1247  */
1248 #define	SPD_KEY_MOD_OPER_TEMP	"module.operating-temperature"	/* uint32_t */
1249 
1250 /*
1251  * Module reference card and design revision. JEDEC provides various reference
1252  * designs for modules and revisions of those.
1253  */
1254 #define	SPD_KEY_MOD_REF_DESIGN	"module.reference-design"	/* string */
1255 #define	SPD_KEY_MOD_DESIGN_REV	"module.design-revision"	/* uint32_t */
1256 
1257 /*
1258  * Manufacturing Section. These keys are present if manufacturing related
1259  * information is made available. This space is not DIMM-revision specific. All
1260  * fields are defined in DDR4 and DDR5. Note, the SPD_KEY_MFG_DRAM_STEP is
1261  * optional and therefore an invalid value will result in this not being
1262  * present.
1263  */
1264 #define	SPD_KEY_MFG_MOD_MFG_ID	"mfg.module-mfg-id"	/* uint32[2] */
1265 #define	SPD_KEY_MFG_MOD_MFG_NAME	"mfg.module-mfg-name"	/* string */
1266 #define	SPD_KEY_MFG_DRAM_MFG_ID	"mfg.dram-mfg-id"	/* uint32[2] */
1267 #define	SPD_KEY_MFG_DRAM_MFG_NAME	"mfg.dram-mfg-name"	/* string */
1268 #define	SPD_KEY_MFG_MOD_LOC_ID	"mfg.module-loc-id"	/* uint32 */
1269 #define	SPD_KEY_MFG_MOD_YEAR	"mfg.module-year"	/* string */
1270 #define	SPD_KEY_MFG_MOD_WEEK	"mfg.module-week"	/* string */
1271 #define	SPD_KEY_MFG_MOD_PN	"mfg.module-pn"		/* string */
1272 #define	SPD_KEY_MFG_MOD_SN	"mfg.module-sn"		/* string */
1273 #define	SPD_KEY_MFG_MOD_REV	"mfg.module-rev"	/* string */
1274 #define	SPD_KEY_MFG_DRAM_STEP	"mfg.dram-step"		/* string */
1275 
1276 /*
1277  * The errors nvlist_t is designed such that it is a nested nvlist_t in the
1278  * returned data. Each key in that nvlist_t corresponds to a key that we would
1279  * otherwise produce. Each key is an nvlist_t that has two keys, a 'code' and a
1280  * 'message'.
1281  *
1282  * There is currently an additional top-level special key. This is the
1283  * 'incomplete' key. When data is too short to process an entry, rather than
1284  * flag every possible missing key (as most times the consumer will know the
1285  * amount of data they have), for the time being we will insert a single
1286  * incomplete key with a uint32_t whose value indicates the starting offset of
1287  * the key that we could not process. Note, this may not be the first byte that
1288  * was missing (if we had 100 bytes and a 20 byte key at offset 90, we would
1289  * insert 90).
1290  */
1291 typedef enum {
1292 	/*
1293 	 * Indicates that the error occurred because we could not translate a
1294 	 * given piece of information. For example, a value that we didn't know
1295 	 * or a failure to look up something in a string table.
1296 	 */
1297 	SPD_ERROR_NO_XLATE,
1298 	/*
1299 	 * This indicates that we encountered an non-ASCII or unprintable
1300 	 * character in an SPD string which should not be allowed per se.
1301 	 */
1302 	SPD_ERROR_UNPRINT,
1303 	/*
1304 	 * This indicates that there was no data for a given key. For example, a
1305 	 * string that was all padded spaces.
1306 	 */
1307 	SPD_ERROR_NO_DATA,
1308 	/*
1309 	 * Indicates that some kind of internal error occurred.
1310 	 */
1311 	SPD_ERROR_INTERNAL,
1312 	/*
1313 	 * This indicates that there's something suspicious or weird to us about
1314 	 * the data in question. The most common case is a bad CRC.
1315 	 */
1316 	SPD_ERROR_BAD_DATA
1317 } spd_error_kind_t;
1318 #define	SPD_KEY_INCOMPLETE	"incomplete"	/* uint32_t */
1319 #define	SPD_KEY_ERRS		"errors"	/* nvlist_t */
1320 #define	SPD_KEY_ERRS_CODE	"code"		/* uint32_t */
1321 #define	SPD_KEY_ERRS_MSG	"message"	/* string */
1322 
1323 #ifdef __cplusplus
1324 }
1325 #endif
1326 
1327 #endif /* _LIBJEDEC_H */
1328