]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sys/dev/jedec_dimm/jedec_dimm.h
MFC r329843:
[FreeBSD/stable/10.git] / sys / dev / jedec_dimm / jedec_dimm.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Authors: Ravi Pokala (rpokala@freebsd.org)
5  *
6  * Copyright (c) 2018 Panasas
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $FreeBSD$
31  */
32
33 #ifndef _DEV__JEDEC_DIMM__JEDEC_DIMM_H_
34 #define _DEV__JEDEC_DIMM__JEDEC_DIMM_H_
35
36 /* JEDEC DIMMs include one or more SMBus devices.
37  *
38  * At a minimum, they have an EEPROM containing either 256 bytes (DDR3) or 512
39  * bytes (DDR4) of "Serial Presence Detect" (SPD) information. The SPD contains
40  * data used by the memory controller to configure itself, and it also includes
41  * asset information. The layout of SPD data is defined in:
42  *
43  * JEDEC Standard 21-C, Annex K (DDR3)
44  * JEDEC Standard 21-C, Annex L (DDR4)
45  *
46  * DIMMs may also include a "Thermal Sensor on DIMM" (TSOD), which reports
47  * temperature data. While not strictly required, the TSOD is so often included
48  * that JEDEC defined standards for single chips which include both SPD and TSOD
49  * functions. They respond on multiple SMBus addresses, depending on the
50  * function.
51  *
52  * JEDEC Standard 21-C, TSE2002av (DDR3)
53  * JEDEC Standard 21-C, TSE2004av (DDR4)
54  */
55
56 /* TSE2004av defines several Device Type Identifiers (DTIs), which are the high
57  * nybble of the SMBus address. Addresses with DTIs of PROTECT (or PAGE, which
58  * has the same value) are essentially "broadcast" addresses; all SPD devices
59  * respond to them, changing their mode based on the Logical Serial Address
60  * (LSA) encoded in bits [3:1]. For normal SPD access, bits [3:1] encode the
61  * DIMM slot number.
62  */
63 #define JEDEC_SPD_PAGE_SIZE     256
64 #define JEDEC_DTI_SPD           0xa0
65 #define JEDEC_DTI_TSOD          0x30
66 #define JEDEC_DTI_PROTECT       0x60
67 #define JEDEC_LSA_PROTECT_SET0  0x02
68 #define JEDEC_LSA_PROTECT_SET1  0x08
69 #define JEDEC_LSA_PROTECT_SET2  0x0a
70 #define JEDEC_LSA_PROTECT_SET3  0x00
71 #define JEDEC_LSA_PROTECT_CLR   0x06
72 #define JEDEC_LSA_PROTECT_GET0  0x03
73 #define JEDEC_LSA_PROTECT_GET1  0x09
74 #define JEDEC_LSA_PROTECT_GET2  0x0b
75 #define JEDEC_LSA_PROTECT_GET3  0x01
76 #define JEDEC_DTI_PAGE          0x60
77 #define JEDEC_LSA_PAGE_SET0     0x0c
78 #define JEDEC_LSA_PAGE_SET1     0x0e
79 #define JEDEC_LSA_PAGE_GET      0x0d
80
81 /* The offsets and lengths of various SPD bytes are defined in Annex K (DDR3)
82  * and Annex L (DDR4). Conveniently, the DRAM type is at the same offset for
83  * both versions.
84  *
85  * This list only includes information needed to get the asset information and
86  * calculate the DIMM capacity.
87  */
88 #define SPD_OFFSET_DRAM_TYPE            2
89 #define SPD_OFFSET_DDR3_SDRAM_CAPACITY  4
90 #define SPD_OFFSET_DDR3_DIMM_RANKS      7
91 #define SPD_OFFSET_DDR3_SDRAM_WIDTH     7
92 #define SPD_OFFSET_DDR3_BUS_WIDTH       8
93 #define SPD_OFFSET_DDR3_TSOD_PRESENT    32
94 #define SPD_OFFSET_DDR3_SERIAL          122
95 #define SPD_LEN_DDR3_SERIAL             4
96 #define SPD_OFFSET_DDR3_PARTNUM         128
97 #define SPD_LEN_DDR3_PARTNUM            18
98 #define SPD_OFFSET_DDR4_SDRAM_CAPACITY  4
99 #define SPD_OFFSET_DDR4_SDRAM_PKG_TYPE  6
100 #define SPD_OFFSET_DDR4_DIMM_RANKS      12
101 #define SPD_OFFSET_DDR4_SDRAM_WIDTH     12
102 #define SPD_OFFSET_DDR4_BUS_WIDTH       13
103 #define SPD_OFFSET_DDR4_TSOD_PRESENT    14
104 #define SPD_OFFSET_DDR4_SERIAL          325
105 #define SPD_LEN_DDR4_SERIAL             4
106 #define SPD_OFFSET_DDR4_PARTNUM         329
107 #define SPD_LEN_DDR4_PARTNUM            20
108
109 /* The "DRAM Type" field of the SPD enumerates various memory technologies which
110  * have been used over the years. The list is append-only, so we need only refer
111  * to the latest SPD specification. In this case, Annex L for DDR4.
112  */
113 enum dram_type {
114         DRAM_TYPE_RESERVED =                    0x00,
115         DRAM_TYPE_FAST_PAGE_MODE =              0x01,
116         DRAM_TYPE_EDO =                         0x02,
117         DRAM_TYPE_PIPLEINED_NYBBLE =            0x03,
118         DRAM_TYPE_SDRAM =                       0x04,
119         DRAM_TYPE_ROM =                         0x05,
120         DRAM_TYPE_DDR_SGRAM =                   0x06,
121         DRAM_TYPE_DDR_SDRAM =                   0x07,
122         DRAM_TYPE_DDR2_SDRAM =                  0x08,
123         DRAM_TYPE_DDR2_SDRAM_FBDIMM =           0x09,
124         DRAM_TYPE_DDR2_SDRAM_FBDIMM_PROBE =     0x0a,
125         DRAM_TYPE_DDR3_SDRAM =                  0x0b,
126         DRAM_TYPE_DDR4_SDRAM =                  0x0c,
127         DRAM_TYPE_RESERVED_0D =                 0x0d,
128         DRAM_TYPE_DDR4E_SDRAM =                 0x0e,
129         DRAM_TYPE_LPDDR3_SDRAM =                0x0f,
130         DRAM_TYPE_LPDDR4_SDRAM =                0x10,
131 };
132
133 /* The TSOD is accessed using a simple word interface, which is identical
134  * between TSE2002av (DDR3) and TSE2004av (DDR4).
135  */
136 #define TSOD_REG_CAPABILITES    0
137 #define TSOD_REG_CONFIG         1
138 #define TSOD_REG_LIM_HIGH       2
139 #define TSOD_REG_LIM_LOW        3
140 #define TSOD_REG_LIM_CRIT       4
141 #define TSOD_REG_TEMPERATURE    5
142 #define TSOD_REG_MANUFACTURER   6
143 #define TSOD_REG_DEV_REV        7
144
145 #endif /* _DEV__JEDEC_DIMM__JEDEC_DIMM_H_ */
146
147 /* vi: set ts=8 sw=4 sts=8 noet: */