summaryrefslogtreecommitdiffstats
path: root/util/spd_tools/ddr4/README.md
blob: 75275441a2d4ccfc77b5dd1f7e4f0574853b8356 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# DDR4 SPD tools README

Tools for generating SPD files for DDR4 memory used in platforms with
memory down configuration. These tools generate SPDs following JESD79-4C
and Jedec 4.1.2.L-5 R29 v103 specifications.

There are two tools provided that assist with generating SPDs and Makefiles
to integrate in coreboot build. These tools can also be used to allocate
DRAM IDs (configure DRAM hardware straps) for any DDR4 memory part used
by the board.

* gen_spd.go: Generates de-duplicated SPD files using a global memory
  part list provided by the mainboard in JSON format. Additionally,
  generates a SPD manifest file(in CSV format) with information about
  what memory part from the global list uses which of the generated
  SPD files.

* gen_part_id.go: Allocates DRAM strap IDs for different DDR4
  memory parts used by the board. Takes as input a list of memory parts
  used (in CSV format) by the board with optional fixed ids and the SPD
  manifest file generated by gen_spd.go. Generates Makefile.inc for
  integrating the generated SPD files in the coreboot build.

## Tool 1 - gen_spd.go

This program takes as input:
* Pointer to directory where the generated SPD files and manifest will
  be placed.
* JSON file containing a global list of memory parts with their
  attributes as per the datasheet. This is the list of all known
  DDR4 memory parts irrespective of their usage on the board.
* SoC platform name for which the SPDs are being generated. Currently
  supported platform names are `TGL`, `PCO` and `PLK`.

Input JSON file requires the following two fields for every memory part:
* `name`: Name of the memory part
* `attribs`: List of attributes of the memory part as per its
  datasheet. These attributes match the part specifications and are
  independent of any SoC expectations. Tool takes care of translating
  the physical attributes of the memory part to match JEDEC and Intel
  MRC expectations.

`attribs` field further contains two types of sub-fields:
* Mandatory: These attributes have to be provided for a memory part.
* Optional: These attributes can be provided by memory part if it wants
  to override the defaults.

### Mandatory `attribs`

* `speedMTps`: Maximum rate supported by the part in MT/s. Valid values:
  `1600, 1866, 2133, 2400, 2666, 2933, 3200` MT/s.

* `CL_nRCD_nRP`: Refers to CAS Latency specified for the part (find
  "CL-nRCD-nRP" in the vendor spec for the DDR4 part).

* `capacityPerDieGb`: Capacity per die in gigabits.  Valid values:
  `2, 4, 8, 16` Gb part.

* `diesPerPackage`: Number of dies on the part.  Valid values:
  `1, 2` dies per package.

* `packageBusWidth`: Number of bits of the device's address bus.  Valid values:
  `8, 16` bit-wide bus. NOTE: Width of x4 is not supported by this tool.

* `ranksPerPackage`: From Jedec doc 4_01_02_AnnexL-1R23:
  “Package ranks per DIMM” refers to the collections of devices on the module
  sharing common chip select signals (across the data width of the DIMM),
  either from the edge connector for unbuffered modules or from the outputs of
  a registering clock driver for RDIMMs and LRDIMMs.Number of bits of the
  device's address bus.  Valid values:
  `1, 2` package ranks.

### Optional `attribs`

The following options are calculated by the tool based on the mandatory
attributes described for the part, but there may be cases where a default value
must be overridden, such as when a device appears to be 3200AA, but does not
support all of the CAS latencies typically supported by a speed bin 3200AA part.
Do deal with such a case, the variable can be overridden here and the tool will
use this value instead of calculating one.  All values must be defined in
picosecond units, except for "CASLatencies", which would be represented as a
string like "9 10 11 12 14".

 * `TAAMinPs`: Defines the minimum CAS Latency.
   Table 48 of Jedec doc 4_01_02_AnnexL-5R29 lists tAAmin for each speed grade.

 * `TRASMinPs`: Refers to the minimum active to precharge delay time.
   Table 55 of Jedec doc 4_01_02_AnnexL-5R29 lists tRPmin for each speed grade.

 * `TCKMinPs`: Refers to the minimum clock cycle time.
   Table 42 of Jedec doc 4_01_02_AnnexL-5R29 lists tCKmin for each speed grade.

 * `TCKMaxPs`:Refers to the minimum clock cycle time.
   Table 44 of Jedec doc 4_01_02_AnnexL-5R29 lists tCKmin for each speed grade.

 * `TRFC1MinPs`: Refers to the minimum refresh recovery delay time.
   Table 59 of Jedec doc 4_01_02_AnnexL-5R29 lists tRFC1min for each page size.

 * `TRFC2MinPs`: Refers to the minimum refresh recovery delay time.
   Table 61 of Jedec doc 4_01_02_AnnexL-5R29 lists tRFC2min for each page size.

 * `TRFC4MinPs`: Refers to the minimum refresh recovery delay time.
   Table 63 of Jedec doc 4_01_02_AnnexL-5R29 lists tRFC4min for each page size.

 * `TFAWMinPs`:: Refers to the minimum four activate window delay time.
   Table 66 of Jedec doc 4_01_02_AnnexL-5R29 lists tFAWmin for each speed grade
   and page size combination.

 * `TRRDSMinPs`: Refers to the minimum activate to activate delay time to
   different bank groups.
   Table 68 of Jedec doc 4_01_02_AnnexL-5R29 lists tRRD_Smin for each speed grade
   and page size combination.

 * `TRRDLMinPs`: Refers to the minimum activate to activate delay time to the
   same bank group.
   Table 70 of Jedec doc 4_01_02_AnnexL-5R29 lists tRRD_Lmin for each speed grade
   and page size combination.

 * `TCCDLMinPs`: Refers to the minimum CAS to CAS delay time to same bank group.
   Table 72 of Jedec doc 4_01_02_AnnexL-5R29 lists tCCD_Lmin for each speed grade.

 * `TWRMinPs`: Refers to the minimum write recovery time.
   Table 75 of Jedec doc 4_01_02_AnnexL-5R29 lists tWRmin for each ddr4 type.

 * `TWTRSMinPs`: Refers to minimum write to read time to different bank group.
   Table 78 of Jedec doc 4_01_02_AnnexL-5R29 lists tWTR_Smin for each ddr4 type.

 * `TWTRLMinPs`: Refers to minimum write to read time to same bank group.
   Table 80 of Jedec doc 4_01_02_AnnexL-5R29 lists tWTR_Lmin for each ddr4 type.

 * `CASLatencies`: Refers to the CAS latencies supported by the part.
   The speed bin tables in the back of Jedec doc 4_01_02_AnnexL-5R29 define the
   standard CAS latencies that a speed bin part is supposed to support.
   In cases where a part does not support all of the CAS latencies listed in the
   speed bin tables, this entry should be used to override the default settings.

### Example JSON file
```
{
    "parts": [
        {
            "name": "MEMORY_PART_A",
            "attribs": {
                "speedMTps": 3200,
                "CL_nRCD_nRP": 22
                "capacityPerDieGb": 8,
                "diesPerPackage": 2,
                "packageBusWidth": 16,
                "ranksPerPackage": 1,
            }
        },
        {
            "name": "MEMORY_PART_B",
            "attribs": {
                "speedMTps": 3200,
                "CL_nRCD_nRP": 22
                "capacityPerDieGb": 8,
                "diesPerPackage": 1,
                "packageBusWidth": 16,
                "ranksPerPackage": 2,
                "casLatencies": "9 10 11 12 13 14 15 16 17 18 19 20",
                "tCKMaxPs": "1250"
            }
        }
    ]
}
```

### Output

This tool generates the following files using the global list of
memory parts in JSON format as described above:
  * De-duplicated SPDs required for the different memory parts. These
    SPD files are named (ddr4-spd-1.hex, ddr4-spd-2.hex, and so on)
    and placed in the directory provided as an input to the tool.
  * CSV file representing which of the deduplicated SPD files is used
    by which memory part. This file is named as
    `ddr4_spd_manifest.generated.txt` and placed in the directory provided
    as an input to the tool along with the generated SPD
    files. Example CSV file:
    ```
    MEMORY_PART_A, ddr4-spd-1.hex
    MEMORY_PART_B, ddr4-spd-2.hex
    MEMORY_PART_C, ddr4-spd-3.hex
    MEMORY_PART_D, ddr4-spd-2.hex
    MEMORY_PART_E, ddr4-spd-2.hex
    ```

## Tool 2 - gen_part_id.go

This program takes as input:
* Pointer to directory where the SPD files and the manifest file
  `ddr4_spd_manifest.generated.txt` (in CSV format) are placed by
  gen_spd.go
* CSV file containing list of memory parts used by the board and optional
  fixed id. Each line of the file is supposed to contain one memory part `name`
  as present in the global list of memory parts provided to gen_spd.go.
  Optionally a fixed id may also be assigned to the part if required.
  NOTE: Only assign a fixed ID if required for legacy reasons.

* Pointer to directory where the generated Makefile.inc should be
  placed by the tool.

Sample input (mem_parts_used_file.txt):
```
K4AAG165WA-BCWE,1
MT40A512M16TB-062E:J
MT40A1G16KD-062E:E
K4A8G165WC-BCWE
H5AN8G6NDJR-XNC,8
H5ANAG6NCMR-XNC
```
NOTE: This will ensure SPDs compatible with K4AAG165WA-BCWE and H5AN8G6NDJR-XNC
are assigned to ID 1 and 8 respectively. All other memory parts will be
assigned to the first compatible ID. Assigning fixed IDs may result in
duplicate SPD entries or gaps in the ID mapping.

### Output

This program provides the following:

* Prints out the list of DRAM hardware strap IDs that should be
  allocated to each memory part listed in the input file.
* Makefile.inc is generated in the provided directory to integrate
  SPDs generated by gen_spd.go with the coreboot build for the board.
* dram_id.generated.txt is generated in the same directory as
  Makefile. This contains the part IDs assigned to the different
  memory parts. (Useful to integrate in board schematics).

Sample output (dram_id.generated.txt):
```
DRAM Part Name                 ID to assign
MEMORY_PART_A                  0 (0000)
MEMORY_PART_B                  1 (0001)
MEMORY_PART_C                  2 (0010)
MEMORY_PART_D                  1 (0001)
```

Sample Makefile.inc:
```
## SPDX-License-Identifier: GPL-2.0-or-later
## This is an auto-generated file. Do not edit!!

SPD_SOURCES =
SPD_SOURCES += ddr4-spd-1.hex      # ID = 0(0b0000)  Parts = MEMORY_PART_A
SPD_SOURCES += ddr4-spd-2.hex      # ID = 1(0b0001)  Parts = MEMORY_PART_B, MEMORY_PART_D
SPD_SOURCES += ddr4-spd-empty.hex  # ID = 2(0b0010)
SPD_SOURCES += ddr4-spd-3.hex      # ID = 2(0b0010)  Parts = MEMORY_PART_C
```
NOTE: Empty entries may be required if there is a gap created by a memory part
with a fixed id.

### Note of caution

This program assigns DRAM IDs using the order of DRAM part names
provided in the input file. Thus, when adding a new memory part to the
list, it should always go to the end of the input text file. This
guarantees that the memory parts that were already assigned IDs do not
change.

## How to build the tools?
```
# go build gen_spd.go
# go build gen_part_id.go
```

## How to use the tools?
```
# ./gen_spd <spd_dir> <mem_parts_list_json> <platform>
# ./gen_part_id <spd_dir> <makefile_dir> <mem_parts_used_file>
```

## Example Usage
```
# ./gen_spd ../../../../src/soc/intel/tigerlake/spd/ddr4 ./global_ddr4_mem_parts.json.txt 'TGL'

```

### Need to add a new memory part for a board?

* If the memory part is not present in the global list of memory
  parts, then add the memory part name and attributes as per the
  datasheet to the file containing the global list.
  * Use `gen_spd.go` with input as the file containing the global list
    of memory parts to generate de-duplicated SPDs.
  * If a new SPD file is generated, use `git add` to add it to the
    tree and push a CL for review.
* Update the file containing memory parts used by board (variant) to
  add the new memory part name at the end of the file.
  * Use gen_part_id.go providing it pointer to the location where SPD
    files are stored and file containing the list of memory parts used
    by the board(variant).
  * Use `git add` to add `Makefile.inc` and `dram_id.generated.txt`
    with updated changes and push a CL for review.