blob: 570e1f7864f3ee9bd07c4d123fdef00746678410 [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.
Stefan Reinauer00636b02012-04-04 00:08:51 +020015 */
16
17#ifndef __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__
Edward O'Callaghan089a5102015-01-06 02:48:57 +110018#define __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__
Stefan Reinauer00636b02012-04-04 00:08:51 +020019
20/* Chipset types */
21#define SANDYBRIDGE_MOBILE 0
22#define SANDYBRIDGE_DESKTOP 1
23#define SANDYBRIDGE_SERVER 2
24
25/* Device ID for SandyBridge and IvyBridge */
26#define BASE_REV_SNB 0x00
27#define BASE_REV_IVB 0x50
28#define BASE_REV_MASK 0x50
29
30/* SandyBridge CPU stepping */
31#define SNB_STEP_D0 (BASE_REV_SNB + 5) /* Also J0 */
32#define SNB_STEP_D1 (BASE_REV_SNB + 6)
33#define SNB_STEP_D2 (BASE_REV_SNB + 7) /* Also J1/Q0 */
34
35/* IvyBridge CPU stepping */
36#define IVB_STEP_A0 (BASE_REV_IVB + 0)
37#define IVB_STEP_B0 (BASE_REV_IVB + 2)
38#define IVB_STEP_C0 (BASE_REV_IVB + 4)
39#define IVB_STEP_K0 (BASE_REV_IVB + 5)
40#define IVB_STEP_D0 (BASE_REV_IVB + 6)
41
42/* Intel Enhanced Debug region must be 4MB */
43#define IED_SIZE 0x400000
44
45/* Northbridge BARs */
46#define DEFAULT_PCIEXBAR CONFIG_MMCONF_BASE_ADDRESS /* 4 KB per PCIe device */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080047#ifndef __ACPI__
48#define DEFAULT_MCHBAR ((u8 *)0xfed10000) /* 16 KB */
49#define DEFAULT_DMIBAR ((u8 *)0xfed18000) /* 4 KB */
50#else
Stefan Reinauer00636b02012-04-04 00:08:51 +020051#define DEFAULT_MCHBAR 0xfed10000 /* 16 KB */
52#define DEFAULT_DMIBAR 0xfed18000 /* 4 KB */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080053#endif
Stefan Reinauer00636b02012-04-04 00:08:51 +020054#define DEFAULT_EPBAR 0xfed19000 /* 4 KB */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080055#define DEFAULT_RCBABASE ((u8 *)0xfed1c000)
Stefan Reinauer00636b02012-04-04 00:08:51 +020056
Nico Huberbb9469c2015-10-21 11:49:23 +020057#define IOMMU_BASE1 0xfed90000ULL
58#define IOMMU_BASE2 0xfed91000ULL
59
Stefan Reinauere5a0a5d2012-09-19 10:51:48 -070060#include <southbridge/intel/bd82x6x/pch.h>
Stefan Reinauer00636b02012-04-04 00:08:51 +020061
62/* Everything below this line is ignored in the DSDT */
63#ifndef __ACPI__
64
Nico Huber9d9ce0d2015-10-26 12:59:49 +010065#include <rules.h>
66
Stefan Reinauer00636b02012-04-04 00:08:51 +020067/* Device 0:0.0 PCI configuration space (Host Bridge) */
68
69#define EPBAR 0x40
70#define MCHBAR 0x48
71#define PCIEXBAR 0x60
72#define DMIBAR 0x68
73#define X60BAR 0x60
74
75#define GGC 0x50 /* GMCH Graphics Control */
76
77#define DEVEN 0x54 /* Device Enable */
78#define DEVEN_PEG60 (1 << 13)
79#define DEVEN_IGD (1 << 4)
80#define DEVEN_PEG10 (1 << 3)
81#define DEVEN_PEG11 (1 << 2)
82#define DEVEN_PEG12 (1 << 1)
83#define DEVEN_HOST (1 << 0)
84
85#define PAM0 0x80
86#define PAM1 0x81
87#define PAM2 0x82
88#define PAM3 0x83
89#define PAM4 0x84
90#define PAM5 0x85
91#define PAM6 0x86
92
93#define LAC 0x87 /* Legacy Access Control */
94#define SMRAM 0x88 /* System Management RAM Control */
Stefan Reinauer00636b02012-04-04 00:08:51 +020095
96#define TOM 0xa0
97#define TOUUD 0xa8 /* Top of Upper Usable DRAM */
Vladimir Serbinenkoa3e41c02015-05-28 16:04:17 +020098#define BGSM 0xb4 /* Base GTT Stolen Memory */
Stefan Reinauer00636b02012-04-04 00:08:51 +020099#define TSEG 0xb8 /* TSEG base */
100#define TOLUD 0xbc /* Top of Low Used Memory */
101
102#define SKPAD 0xdc /* Scratchpad Data */
103
104/* Device 0:1.0 PCI configuration space (PCI Express) */
105
106#define BCTRL1 0x3e /* 16bit */
107
108
109/* Device 0:2.0 PCI configuration space (Graphics Device) */
110
111#define MSAC 0x62 /* Multi Size Aperture Control */
Stefan Reinauere5a0a5d2012-09-19 10:51:48 -0700112#define SWSCI 0xe8 /* SWSCI enable */
113#define ASLS 0xfc /* OpRegion Base */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200114
115/*
116 * MCHBAR
117 */
118
119#define MCHBAR8(x) *((volatile u8 *)(DEFAULT_MCHBAR + x))
120#define MCHBAR16(x) *((volatile u16 *)(DEFAULT_MCHBAR + x))
121#define MCHBAR32(x) *((volatile u32 *)(DEFAULT_MCHBAR + x))
122#define MCHBAR32_OR(x, or) MCHBAR32(x) = (MCHBAR32(x) | (or))
123
124#define SSKPD 0x5d14 /* 16bit (scratchpad) */
125#define BIOS_RESET_CPL 0x5da8 /* 8bit */
126
127/*
128 * EPBAR - Egress Port Root Complex Register Block
129 */
130
131#define EPBAR8(x) *((volatile u8 *)(DEFAULT_EPBAR + x))
132#define EPBAR16(x) *((volatile u16 *)(DEFAULT_EPBAR + x))
133#define EPBAR32(x) *((volatile u32 *)(DEFAULT_EPBAR + x))
134
135#define EPPVCCAP1 0x004 /* 32bit */
136#define EPPVCCAP2 0x008 /* 32bit */
137
138#define EPVC0RCAP 0x010 /* 32bit */
139#define EPVC0RCTL 0x014 /* 32bit */
140#define EPVC0RSTS 0x01a /* 16bit */
141
142#define EPVC1RCAP 0x01c /* 32bit */
143#define EPVC1RCTL 0x020 /* 32bit */
144#define EPVC1RSTS 0x026 /* 16bit */
145
146#define EPVC1MTS 0x028 /* 32bit */
147#define EPVC1IST 0x038 /* 64bit */
148
149#define EPESD 0x044 /* 32bit */
150
151#define EPLE1D 0x050 /* 32bit */
152#define EPLE1A 0x058 /* 64bit */
153#define EPLE2D 0x060 /* 32bit */
154#define EPLE2A 0x068 /* 64bit */
155
156#define PORTARB 0x100 /* 256bit */
157
158/*
159 * DMIBAR
160 */
161
162#define DMIBAR8(x) *((volatile u8 *)(DEFAULT_DMIBAR + x))
163#define DMIBAR16(x) *((volatile u16 *)(DEFAULT_DMIBAR + x))
164#define DMIBAR32(x) *((volatile u32 *)(DEFAULT_DMIBAR + x))
165
166#define DMIVCECH 0x000 /* 32bit */
167#define DMIPVCCAP1 0x004 /* 32bit */
168#define DMIPVCCAP2 0x008 /* 32bit */
169
170#define DMIPVCCCTL 0x00c /* 16bit */
171
172#define DMIVC0RCAP 0x010 /* 32bit */
173#define DMIVC0RCTL0 0x014 /* 32bit */
174#define DMIVC0RSTS 0x01a /* 16bit */
175
176#define DMIVC1RCAP 0x01c /* 32bit */
177#define DMIVC1RCTL 0x020 /* 32bit */
178#define DMIVC1RSTS 0x026 /* 16bit */
179
180#define DMILE1D 0x050 /* 32bit */
181#define DMILE1A 0x058 /* 64bit */
182#define DMILE2D 0x060 /* 32bit */
183#define DMILE2A 0x068 /* 64bit */
184
185#define DMILCAP 0x084 /* 32bit */
186#define DMILCTL 0x088 /* 16bit */
187#define DMILSTS 0x08a /* 16bit */
188
189#define DMICTL1 0x0f0 /* 32bit */
190#define DMICTL2 0x0fc /* 32bit */
191
192#define DMICC 0x208 /* 32bit */
193
194#define DMIDRCCFG 0xeb4 /* 32bit */
195
196#ifndef __ASSEMBLER__
197static inline void barrier(void) { asm("" ::: "memory"); }
198
Stefan Reinauer6097e192012-06-11 15:38:15 -0700199#define PCI_DEVICE_ID_SB 0x0104
200#define PCI_DEVICE_ID_IB 0x0154
Stefan Reinauer00636b02012-04-04 00:08:51 +0200201
202#ifdef __SMM__
203void intel_sandybridge_finalize_smm(void);
204#else /* !__SMM__ */
205int bridge_silicon_revision(void);
206void sandybridge_early_initialization(int chipset_type);
Nico Huberbb9469c2015-10-21 11:49:23 +0200207void sandybridge_init_iommu(void);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200208void sandybridge_late_initialization(void);
Vladimir Serbinenkoc845b432014-09-05 03:37:44 +0200209void northbridge_romstage_finalize(int s3resume);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200210
211/* debugging functions */
212void print_pci_devices(void);
213void dump_pci_device(unsigned dev);
214void dump_pci_devices(void);
215void dump_spd_registers(void);
216void dump_mem(unsigned start, unsigned end);
Vadim Bendebury7a3f36a2012-04-18 15:47:32 -0700217void report_platform_info(void);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100218
Stefan Reinauer00636b02012-04-04 00:08:51 +0200219#endif /* !__SMM__ */
Stefan Reinauer1244f4b2012-05-10 11:31:40 -0700220
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100221void rcba_config(void);
222void pch_enable_lpc(void);
223void mainboard_early_init(int s3resume);
224void mainboard_config_superio(void);
225int mainboard_should_reset_usb(int s3resume);
226void perform_raminit(int s3resume);
227
Nico Huber9d9ce0d2015-10-26 12:59:49 +0100228#if ENV_RAMSTAGE
229#include <device/device.h>
230
231struct acpi_rsdp;
232unsigned long northbridge_write_acpi_tables(device_t device, unsigned long start, struct acpi_rsdp *rsdp);
233#endif
234
Stefan Reinauer1244f4b2012-05-10 11:31:40 -0700235
236#define MRC_DATA_ALIGN 0x1000
237#define MRC_DATA_SIGNATURE (('M'<<0)|('R'<<8)|('C'<<16)|('D'<<24))
238
239struct mrc_data_container {
240 u32 mrc_signature; // "MRCD"
241 u32 mrc_data_size; // Actual total size of this structure
242 u32 mrc_checksum; // IP style checksum
243 u32 reserved; // For header alignment
244 u8 mrc_data[0]; // Variable size, platform/run time dependent.
245} __attribute__ ((packed));
246
Stefan Reinauer1244f4b2012-05-10 11:31:40 -0700247struct mrc_data_container *find_current_mrc_cache(void);
248#if !defined(__PRE_RAM__)
Stefan Reinauere5a0a5d2012-09-19 10:51:48 -0700249#include "gma.h"
250int init_igd_opregion(igd_opregion_t *igd_opregion);
Stefan Reinauer1244f4b2012-05-10 11:31:40 -0700251#endif
252
Stefan Reinauer00636b02012-04-04 00:08:51 +0200253#endif
254#endif
Edward O'Callaghan089a5102015-01-06 02:48:57 +1100255#endif /* __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ */