blob: 0790ae8fd23f98bd07f279197d41005f03caad02 [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
Paul Menzela46a7122013-02-23 18:37:27 +010018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Stefan Reinauer00636b02012-04-04 00:08:51 +020019 */
20
21#ifndef __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__
Edward O'Callaghan089a5102015-01-06 02:48:57 +110022#define __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__
Stefan Reinauer00636b02012-04-04 00:08:51 +020023
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 */
Stefan Reinauere6063fe2012-04-30 14:57:51 -070054#define DEFAULT_RCBABASE 0xfed1c000
Stefan Reinauer00636b02012-04-04 00:08:51 +020055
Stefan Reinauere5a0a5d2012-09-19 10:51:48 -070056#include <southbridge/intel/bd82x6x/pch.h>
Stefan Reinauer00636b02012-04-04 00:08:51 +020057
58/* Everything below this line is ignored in the DSDT */
59#ifndef __ACPI__
60
61/* Device 0:0.0 PCI configuration space (Host Bridge) */
62
63#define EPBAR 0x40
64#define MCHBAR 0x48
65#define PCIEXBAR 0x60
66#define DMIBAR 0x68
67#define X60BAR 0x60
68
69#define GGC 0x50 /* GMCH Graphics Control */
70
71#define DEVEN 0x54 /* Device Enable */
72#define DEVEN_PEG60 (1 << 13)
73#define DEVEN_IGD (1 << 4)
74#define DEVEN_PEG10 (1 << 3)
75#define DEVEN_PEG11 (1 << 2)
76#define DEVEN_PEG12 (1 << 1)
77#define DEVEN_HOST (1 << 0)
78
79#define PAM0 0x80
80#define PAM1 0x81
81#define PAM2 0x82
82#define PAM3 0x83
83#define PAM4 0x84
84#define PAM5 0x85
85#define PAM6 0x86
86
87#define LAC 0x87 /* Legacy Access Control */
88#define SMRAM 0x88 /* System Management RAM Control */
89#define D_OPEN (1 << 6)
90#define D_CLS (1 << 5)
91#define D_LCK (1 << 4)
92#define G_SMRAME (1 << 3)
93#define C_BASE_SEG ((0 << 2) | (1 << 1) | (0 << 0))
94
95#define TOM 0xa0
96#define TOUUD 0xa8 /* Top of Upper Usable DRAM */
97#define TSEG 0xb8 /* TSEG base */
98#define TOLUD 0xbc /* Top of Low Used Memory */
99
100#define SKPAD 0xdc /* Scratchpad Data */
101
102/* Device 0:1.0 PCI configuration space (PCI Express) */
103
104#define BCTRL1 0x3e /* 16bit */
105
106
107/* Device 0:2.0 PCI configuration space (Graphics Device) */
108
109#define MSAC 0x62 /* Multi Size Aperture Control */
Stefan Reinauere5a0a5d2012-09-19 10:51:48 -0700110#define SWSCI 0xe8 /* SWSCI enable */
111#define ASLS 0xfc /* OpRegion Base */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200112
113/*
114 * MCHBAR
115 */
116
117#define MCHBAR8(x) *((volatile u8 *)(DEFAULT_MCHBAR + x))
118#define MCHBAR16(x) *((volatile u16 *)(DEFAULT_MCHBAR + x))
119#define MCHBAR32(x) *((volatile u32 *)(DEFAULT_MCHBAR + x))
120#define MCHBAR32_OR(x, or) MCHBAR32(x) = (MCHBAR32(x) | (or))
121
122#define SSKPD 0x5d14 /* 16bit (scratchpad) */
123#define BIOS_RESET_CPL 0x5da8 /* 8bit */
124
125/*
126 * EPBAR - Egress Port Root Complex Register Block
127 */
128
129#define EPBAR8(x) *((volatile u8 *)(DEFAULT_EPBAR + x))
130#define EPBAR16(x) *((volatile u16 *)(DEFAULT_EPBAR + x))
131#define EPBAR32(x) *((volatile u32 *)(DEFAULT_EPBAR + x))
132
133#define EPPVCCAP1 0x004 /* 32bit */
134#define EPPVCCAP2 0x008 /* 32bit */
135
136#define EPVC0RCAP 0x010 /* 32bit */
137#define EPVC0RCTL 0x014 /* 32bit */
138#define EPVC0RSTS 0x01a /* 16bit */
139
140#define EPVC1RCAP 0x01c /* 32bit */
141#define EPVC1RCTL 0x020 /* 32bit */
142#define EPVC1RSTS 0x026 /* 16bit */
143
144#define EPVC1MTS 0x028 /* 32bit */
145#define EPVC1IST 0x038 /* 64bit */
146
147#define EPESD 0x044 /* 32bit */
148
149#define EPLE1D 0x050 /* 32bit */
150#define EPLE1A 0x058 /* 64bit */
151#define EPLE2D 0x060 /* 32bit */
152#define EPLE2A 0x068 /* 64bit */
153
154#define PORTARB 0x100 /* 256bit */
155
156/*
157 * DMIBAR
158 */
159
160#define DMIBAR8(x) *((volatile u8 *)(DEFAULT_DMIBAR + x))
161#define DMIBAR16(x) *((volatile u16 *)(DEFAULT_DMIBAR + x))
162#define DMIBAR32(x) *((volatile u32 *)(DEFAULT_DMIBAR + x))
163
164#define DMIVCECH 0x000 /* 32bit */
165#define DMIPVCCAP1 0x004 /* 32bit */
166#define DMIPVCCAP2 0x008 /* 32bit */
167
168#define DMIPVCCCTL 0x00c /* 16bit */
169
170#define DMIVC0RCAP 0x010 /* 32bit */
171#define DMIVC0RCTL0 0x014 /* 32bit */
172#define DMIVC0RSTS 0x01a /* 16bit */
173
174#define DMIVC1RCAP 0x01c /* 32bit */
175#define DMIVC1RCTL 0x020 /* 32bit */
176#define DMIVC1RSTS 0x026 /* 16bit */
177
178#define DMILE1D 0x050 /* 32bit */
179#define DMILE1A 0x058 /* 64bit */
180#define DMILE2D 0x060 /* 32bit */
181#define DMILE2A 0x068 /* 64bit */
182
183#define DMILCAP 0x084 /* 32bit */
184#define DMILCTL 0x088 /* 16bit */
185#define DMILSTS 0x08a /* 16bit */
186
187#define DMICTL1 0x0f0 /* 32bit */
188#define DMICTL2 0x0fc /* 32bit */
189
190#define DMICC 0x208 /* 32bit */
191
192#define DMIDRCCFG 0xeb4 /* 32bit */
193
194#ifndef __ASSEMBLER__
195static inline void barrier(void) { asm("" ::: "memory"); }
196
197struct ied_header {
198 char signature[10];
199 u32 size;
200 u8 reserved[34];
201} __attribute__ ((packed));
202
Stefan Reinauer6097e192012-06-11 15:38:15 -0700203#define PCI_DEVICE_ID_SB 0x0104
204#define PCI_DEVICE_ID_IB 0x0154
Stefan Reinauer00636b02012-04-04 00:08:51 +0200205
206#ifdef __SMM__
207void intel_sandybridge_finalize_smm(void);
208#else /* !__SMM__ */
209int bridge_silicon_revision(void);
210void sandybridge_early_initialization(int chipset_type);
211void sandybridge_late_initialization(void);
Vladimir Serbinenkoc845b432014-09-05 03:37:44 +0200212void northbridge_romstage_finalize(int s3resume);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200213
214/* debugging functions */
215void print_pci_devices(void);
216void dump_pci_device(unsigned dev);
217void dump_pci_devices(void);
218void dump_spd_registers(void);
219void dump_mem(unsigned start, unsigned end);
Vadim Bendebury7a3f36a2012-04-18 15:47:32 -0700220void report_platform_info(void);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200221#endif /* !__SMM__ */
Stefan Reinauer1244f4b2012-05-10 11:31:40 -0700222
223
224#define MRC_DATA_ALIGN 0x1000
225#define MRC_DATA_SIGNATURE (('M'<<0)|('R'<<8)|('C'<<16)|('D'<<24))
226
227struct mrc_data_container {
228 u32 mrc_signature; // "MRCD"
229 u32 mrc_data_size; // Actual total size of this structure
230 u32 mrc_checksum; // IP style checksum
231 u32 reserved; // For header alignment
232 u8 mrc_data[0]; // Variable size, platform/run time dependent.
233} __attribute__ ((packed));
234
Stefan Reinauer1244f4b2012-05-10 11:31:40 -0700235struct mrc_data_container *find_current_mrc_cache(void);
236#if !defined(__PRE_RAM__)
Stefan Reinauere5a0a5d2012-09-19 10:51:48 -0700237#include "gma.h"
238int init_igd_opregion(igd_opregion_t *igd_opregion);
Stefan Reinauer1244f4b2012-05-10 11:31:40 -0700239#endif
240
Stefan Reinauer00636b02012-04-04 00:08:51 +0200241#endif
242#endif
Edward O'Callaghan089a5102015-01-06 02:48:57 +1100243#endif /* __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ */