9b20699224ad5b61a5286f532cc27ac5c674f320
[coreboot.git] / src / northbridge / amd / amdmct / mct_ddr3 / mwlc_d.h
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2010 Advanced Micro Devices, Inc.
5  *
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.
9  *
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.
14  *
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
18  */
19 /* IBV defined Structure */ /* IBV Specific Options */
20 #ifndef MWLC_D_H
21 #define MWLC_D_H
22
23 #define MAX_TOTAL_DIMMS 8       /* Maximum Number of DIMMs in systems */
24                                 /* (DCT0 + DCT1) */
25 #define MAX_DIMMS 4             /* Maximum Number of DIMMs on each DCT */
26 #define MAX_LDIMMS 4            /* Maximum number of Logial DIMMs per DCT */
27
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 */
32
33 #define C_MAX_DIMMS 4           /* Maximum Number of DIMMs on each DCT */
34
35 /* STATUS Definition */
36 #define DCT_STATUS_REGISTERED 3 /* Registered DIMMs support */
37 #define DCT_STATUS_OnDimmMirror 24      /* OnDimmMirror support */
38
39 /* PCI Defintions */
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 */
48
49 /*Function 2 */
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
55
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
64
65 /* CPU Register defintions */
66
67 /* Register Bit Location */
68 #define DctAccessDone 31
69 #define DctAccessWrite 30
70 #define RDqsEn 12
71 #define TrDimmSelStart 4
72 #define TrDimmSelEnd 5
73 #define WrLvTrMode 1
74 #define TrNibbleSel 2
75 #define WrLvOdtEn 12
76 #define WrLvErrStart 0
77 #define WrLvErrEnd 8
78 #define SendMrsCmd 26
79 #define Qoff 12
80 #define MRS_Level 7
81 #define MrsAddressStart 0
82 #define MrsAddressEnd 15
83 #define MrsBankStart 16
84 #define MrsBankEnd 18
85 #define MrsChipSelStart 20
86 #define MrsChipSelEnd 22
87 #define ASR 18
88 #define SRT 19
89 #define DramTermDynStart 10
90 #define DramTermDynEnd 11
91 #define WrtLvTrMode 1
92 #define TrNibbleSel 2
93 #define TrDimmSelStart 4
94 #define TrDimmSelEnd 5
95 #define WrtLvTrEn 0
96 #define DrvImpCtrlStart 2
97 #define DrvImpCtrlEnd 3
98 #define DramTermNbStart 7
99 #define DramTermNbEnd 9
100 #define onDimmMirror 3
101
102 typedef struct _sMCTStruct
103 {
104         u8 PlatMaxTotalDimms;                   /* IBV defined total number of DIMMs */
105                                                 /* on a particular node */
106         u8 PlatMaxDimmsDct;                     /* IBV defined maximum number of */
107                                                 /* DIMMs on a DCT */
108         void (*AgesaDelay)(u32 delayval);       /* IBV defined Delay Function */
109 } sMCTStruct;
110
111 /* DCT 0 and DCT 1 Data structure */
112 typedef struct _sDCTStruct
113 {
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*/
122         u16 RegMan1Present;
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 */
132                                         /* per byte lane */
133         u8 MaxDimmsInstalled;           /* Max Dimms Installed for current DCT */
134         u8 DimmRanks[MAX_TOTAL_DIMMS];  /* Total Number of Ranks(per Dimm) */
135         u32 LogicalCPUID;
136         u8 WLPass;
137 } sDCTStruct;
138
139 #endif