blob: 9ff6555fb55c853d77ea24794778b66496d39d76 [file] [log] [blame]
Stefan Reinauer00636b02012-04-04 00:08:51 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2008 coresystems GmbH
5 * Copyright (C) 2011 Google Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__
22#define __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ 1
23
24/* Chipset types */
25#define SANDYBRIDGE_MOBILE 0
26#define SANDYBRIDGE_DESKTOP 1
27#define SANDYBRIDGE_SERVER 2
28
29/* Device ID for SandyBridge and IvyBridge */
30#define BASE_REV_SNB 0x00
31#define BASE_REV_IVB 0x50
32#define BASE_REV_MASK 0x50
33
34/* SandyBridge CPU stepping */
35#define SNB_STEP_D0 (BASE_REV_SNB + 5) /* Also J0 */
36#define SNB_STEP_D1 (BASE_REV_SNB + 6)
37#define SNB_STEP_D2 (BASE_REV_SNB + 7) /* Also J1/Q0 */
38
39/* IvyBridge CPU stepping */
40#define IVB_STEP_A0 (BASE_REV_IVB + 0)
41#define IVB_STEP_B0 (BASE_REV_IVB + 2)
42#define IVB_STEP_C0 (BASE_REV_IVB + 4)
43#define IVB_STEP_K0 (BASE_REV_IVB + 5)
44#define IVB_STEP_D0 (BASE_REV_IVB + 6)
45
46/* Intel Enhanced Debug region must be 4MB */
47#define IED_SIZE 0x400000
48
49/* Northbridge BARs */
50#define DEFAULT_PCIEXBAR CONFIG_MMCONF_BASE_ADDRESS /* 4 KB per PCIe device */
51#define DEFAULT_MCHBAR 0xfed10000 /* 16 KB */
52#define DEFAULT_DMIBAR 0xfed18000 /* 4 KB */
53#define DEFAULT_EPBAR 0xfed19000 /* 4 KB */
54
55#include "../../../southbridge/intel/bd82x6x/pch.h"
56
57/* Everything below this line is ignored in the DSDT */
58#ifndef __ACPI__
59
60/* Device 0:0.0 PCI configuration space (Host Bridge) */
61
62#define EPBAR 0x40
63#define MCHBAR 0x48
64#define PCIEXBAR 0x60
65#define DMIBAR 0x68
66#define X60BAR 0x60
67
68#define GGC 0x50 /* GMCH Graphics Control */
69
70#define DEVEN 0x54 /* Device Enable */
71#define DEVEN_PEG60 (1 << 13)
72#define DEVEN_IGD (1 << 4)
73#define DEVEN_PEG10 (1 << 3)
74#define DEVEN_PEG11 (1 << 2)
75#define DEVEN_PEG12 (1 << 1)
76#define DEVEN_HOST (1 << 0)
77
78#define PAM0 0x80
79#define PAM1 0x81
80#define PAM2 0x82
81#define PAM3 0x83
82#define PAM4 0x84
83#define PAM5 0x85
84#define PAM6 0x86
85
86#define LAC 0x87 /* Legacy Access Control */
87#define SMRAM 0x88 /* System Management RAM Control */
88#define D_OPEN (1 << 6)
89#define D_CLS (1 << 5)
90#define D_LCK (1 << 4)
91#define G_SMRAME (1 << 3)
92#define C_BASE_SEG ((0 << 2) | (1 << 1) | (0 << 0))
93
94#define TOM 0xa0
95#define TOUUD 0xa8 /* Top of Upper Usable DRAM */
96#define TSEG 0xb8 /* TSEG base */
97#define TOLUD 0xbc /* Top of Low Used Memory */
98
99#define SKPAD 0xdc /* Scratchpad Data */
100
101/* Device 0:1.0 PCI configuration space (PCI Express) */
102
103#define BCTRL1 0x3e /* 16bit */
104
105
106/* Device 0:2.0 PCI configuration space (Graphics Device) */
107
108#define MSAC 0x62 /* Multi Size Aperture Control */
109
110
111/*
112 * MCHBAR
113 */
114
115#define MCHBAR8(x) *((volatile u8 *)(DEFAULT_MCHBAR + x))
116#define MCHBAR16(x) *((volatile u16 *)(DEFAULT_MCHBAR + x))
117#define MCHBAR32(x) *((volatile u32 *)(DEFAULT_MCHBAR + x))
118#define MCHBAR32_OR(x, or) MCHBAR32(x) = (MCHBAR32(x) | (or))
119
120#define SSKPD 0x5d14 /* 16bit (scratchpad) */
121#define BIOS_RESET_CPL 0x5da8 /* 8bit */
122
123/*
124 * EPBAR - Egress Port Root Complex Register Block
125 */
126
127#define EPBAR8(x) *((volatile u8 *)(DEFAULT_EPBAR + x))
128#define EPBAR16(x) *((volatile u16 *)(DEFAULT_EPBAR + x))
129#define EPBAR32(x) *((volatile u32 *)(DEFAULT_EPBAR + x))
130
131#define EPPVCCAP1 0x004 /* 32bit */
132#define EPPVCCAP2 0x008 /* 32bit */
133
134#define EPVC0RCAP 0x010 /* 32bit */
135#define EPVC0RCTL 0x014 /* 32bit */
136#define EPVC0RSTS 0x01a /* 16bit */
137
138#define EPVC1RCAP 0x01c /* 32bit */
139#define EPVC1RCTL 0x020 /* 32bit */
140#define EPVC1RSTS 0x026 /* 16bit */
141
142#define EPVC1MTS 0x028 /* 32bit */
143#define EPVC1IST 0x038 /* 64bit */
144
145#define EPESD 0x044 /* 32bit */
146
147#define EPLE1D 0x050 /* 32bit */
148#define EPLE1A 0x058 /* 64bit */
149#define EPLE2D 0x060 /* 32bit */
150#define EPLE2A 0x068 /* 64bit */
151
152#define PORTARB 0x100 /* 256bit */
153
154/*
155 * DMIBAR
156 */
157
158#define DMIBAR8(x) *((volatile u8 *)(DEFAULT_DMIBAR + x))
159#define DMIBAR16(x) *((volatile u16 *)(DEFAULT_DMIBAR + x))
160#define DMIBAR32(x) *((volatile u32 *)(DEFAULT_DMIBAR + x))
161
162#define DMIVCECH 0x000 /* 32bit */
163#define DMIPVCCAP1 0x004 /* 32bit */
164#define DMIPVCCAP2 0x008 /* 32bit */
165
166#define DMIPVCCCTL 0x00c /* 16bit */
167
168#define DMIVC0RCAP 0x010 /* 32bit */
169#define DMIVC0RCTL0 0x014 /* 32bit */
170#define DMIVC0RSTS 0x01a /* 16bit */
171
172#define DMIVC1RCAP 0x01c /* 32bit */
173#define DMIVC1RCTL 0x020 /* 32bit */
174#define DMIVC1RSTS 0x026 /* 16bit */
175
176#define DMILE1D 0x050 /* 32bit */
177#define DMILE1A 0x058 /* 64bit */
178#define DMILE2D 0x060 /* 32bit */
179#define DMILE2A 0x068 /* 64bit */
180
181#define DMILCAP 0x084 /* 32bit */
182#define DMILCTL 0x088 /* 16bit */
183#define DMILSTS 0x08a /* 16bit */
184
185#define DMICTL1 0x0f0 /* 32bit */
186#define DMICTL2 0x0fc /* 32bit */
187
188#define DMICC 0x208 /* 32bit */
189
190#define DMIDRCCFG 0xeb4 /* 32bit */
191
192#ifndef __ASSEMBLER__
193static inline void barrier(void) { asm("" ::: "memory"); }
194
195struct ied_header {
196 char signature[10];
197 u32 size;
198 u8 reserved[34];
199} __attribute__ ((packed));
200
201#if CONFIG_NORTHBRIDGE_INTEL_SANDYBRIDGE
202#define PCI_DEVICE_ID_NB 0x0104
203#endif
204#if CONFIG_NORTHBRIDGE_INTEL_IVYBRIDGE
205#define PCI_DEVICE_ID_NB 0x0154
206#endif
207
208#ifdef __SMM__
209void intel_sandybridge_finalize_smm(void);
210#else /* !__SMM__ */
211int bridge_silicon_revision(void);
212void sandybridge_early_initialization(int chipset_type);
213void sandybridge_late_initialization(void);
214
215/* debugging functions */
216void print_pci_devices(void);
217void dump_pci_device(unsigned dev);
218void dump_pci_devices(void);
219void dump_spd_registers(void);
220void dump_mem(unsigned start, unsigned end);
221#endif /* !__SMM__ */
222#endif
223#endif
224#endif