2 * This file is part of the coreboot project.
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 /* IBV defined Structure */ /* IBV Specific Options */
23 #define MAX_TOTAL_DIMMS 8 /* Maximum Number of DIMMs in systems */
25 #define MAX_DIMMS 4 /* Maximum Number of DIMMs on each DCT */
26 #define MAX_LDIMMS 4 /* Maximum number of Logial DIMMs per DCT */
28 /*MCT Max variables */
29 #define MAX_ERRORS 32 /* Maximum number of Errors Reported */
30 #define MAX_STATUS 32 /* Maximum number of Status variables*/
31 #define MAX_BYTE_LANES (8+1) /* Maximum number of Byte Lanes - include ECC */
33 #define C_MAX_DIMMS 4 /* Maximum Number of DIMMs on each DCT */
35 /* STATUS Definition */
36 #define DCT_STATUS_REGISTERED 3 /* Registered DIMMs support */
37 #define DCT_STATUS_OnDimmMirror 24 /* OnDimmMirror support */
40 #define FUN_HT 0 /* Funtion 0 Access */
41 #define FUN_MAP 1 /* Funtion 1 Access */
42 #define FUN_DCT 2 /* Funtion 2 Access */
43 #define FUN_MISC 3 /* Funtion 3 Access */
44 #define FUN_ADD_DCT 0xF /* Funtion 2 Additional Register Access */
45 #define BOTH_DCTS 2 /* The access is independent of DCTs */
46 #define PCI_MIN_LOW 0 /* Lowest possible PCI register location */
47 #define PCI_MAX_HIGH 31 /* Highest possible PCI register location */
50 /* #define DRAM_INIT 0x7C */
51 #define DRAM_MRS_REGISTER 0x84
52 #define DRAM_CONFIG_HIGH 0x94
53 #define DRAM_CONTROLLER_ADD_DATA_OFFSET_REG 0x98
54 #define DRAM_CONTROLLER_ADD_DATA_PORT_REG 0x9C
56 /*Function 2 Additional DRAM control registers */
57 #define DRAM_ADD_DCT_PHY_CONTROL_REG 0x8
58 #define DRAM_CONT_ADD_DQS_TIMING_CTRL_BL_01 0x30
59 #define DRAM_CONT_ADD_DQS_TIMING_CTRL_BL_45 0x40
60 #define DRAM_CONT_ADD_PHASE_REC_CTRL_LOW 0x50
61 #define DRAM_CONT_ADD_PHASE_REC_CTRL_HIGH 0x51
62 #define DRAM_CONT_ADD_ECC_PHASE_REC_CTRL 0x52
63 #define DRAM_CONT_ADD_WRITE_LEV_ERROR_REG 0x53
65 /* CPU Register defintions */
67 /* Register Bit Location */
68 #define DctAccessDone 31
69 #define DctAccessWrite 30
71 #define TrDimmSelStart 4
72 #define TrDimmSelEnd 5
76 #define WrLvErrStart 0
81 #define MrsAddressStart 0
82 #define MrsAddressEnd 15
83 #define MrsBankStart 16
85 #define MrsChipSelStart 20
86 #define MrsChipSelEnd 22
89 #define DramTermDynStart 10
90 #define DramTermDynEnd 11
93 #define TrDimmSelStart 4
94 #define TrDimmSelEnd 5
96 #define DrvImpCtrlStart 2
97 #define DrvImpCtrlEnd 3
98 #define DramTermNbStart 7
99 #define DramTermNbEnd 9
100 #define onDimmMirror 3
102 typedef struct _sMCTStruct
104 u8 PlatMaxTotalDimms; /* IBV defined total number of DIMMs */
105 /* on a particular node */
106 u8 PlatMaxDimmsDct; /* IBV defined maximum number of */
108 void (*AgesaDelay)(u32 delayval); /* IBV defined Delay Function */
111 /* DCT 0 and DCT 1 Data structure */
112 typedef struct _sDCTStruct
114 u8 NodeId; /* Node ID */
115 u8 DctTrain; /* Current DCT being trained */
116 u8 CurrDct; /* Current DCT number (0 or 1) */
117 u8 DctCSPresent; /* Current DCT CS mapping */
118 u8 WLGrossDelay[MAX_BYTE_LANES*MAX_LDIMMS]; /* Write Levelization Gross Delay */
119 /* per byte Lane Per Logical DIMM*/
120 u8 WLFineDelay[MAX_BYTE_LANES*MAX_LDIMMS]; /* Write Levelization Fine Delay */
121 /* per byte Lane Per Logical DIMM*/
123 u8 DimmPresent[MAX_TOTAL_DIMMS];/* Indicates which DIMMs are present */
124 /* from Total Number of DIMMs(per Node)*/
125 u8 DimmX8Present[MAX_TOTAL_DIMMS]; /* Which DIMMs x8 devices */
126 u8 Status[MAX_STATUS]; /* Status for DCT0 and 1 */
127 u8 ErrCode[MAX_ERRORS]; /* Major Error codes for DCT0 and 1 */
128 u8 ErrStatus[MAX_ERRORS]; /* Minor Error codes for DCT0 and 1 */
129 u8 DimmValid[MAX_TOTAL_DIMMS]; /* Indicates which DIMMs are valid for */
130 /* Total Number of DIMMs(per Node) */
131 u8 WLTotalDelay[MAX_BYTE_LANES];/* Write Levelization Toral Delay */
133 u8 MaxDimmsInstalled; /* Max Dimms Installed for current DCT */
134 u8 DimmRanks[MAX_TOTAL_DIMMS]; /* Total Number of Ranks(per Dimm) */