blob: 6bfe88b814c2d4032d2b603c374bd6c59b567e1f [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
Stefan Reinauer00636b02012-04-04 00:08:51 +020020/* Device ID for SandyBridge and IvyBridge */
21#define BASE_REV_SNB 0x00
22#define BASE_REV_IVB 0x50
23#define BASE_REV_MASK 0x50
24
25/* SandyBridge CPU stepping */
26#define SNB_STEP_D0 (BASE_REV_SNB + 5) /* Also J0 */
27#define SNB_STEP_D1 (BASE_REV_SNB + 6)
28#define SNB_STEP_D2 (BASE_REV_SNB + 7) /* Also J1/Q0 */
29
30/* IvyBridge CPU stepping */
31#define IVB_STEP_A0 (BASE_REV_IVB + 0)
32#define IVB_STEP_B0 (BASE_REV_IVB + 2)
33#define IVB_STEP_C0 (BASE_REV_IVB + 4)
34#define IVB_STEP_K0 (BASE_REV_IVB + 5)
35#define IVB_STEP_D0 (BASE_REV_IVB + 6)
36
Stefan Reinauer00636b02012-04-04 00:08:51 +020037/* Northbridge BARs */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080038#ifndef __ACPI__
39#define DEFAULT_MCHBAR ((u8 *)0xfed10000) /* 16 KB */
40#define DEFAULT_DMIBAR ((u8 *)0xfed18000) /* 4 KB */
41#else
Stefan Reinauer00636b02012-04-04 00:08:51 +020042#define DEFAULT_MCHBAR 0xfed10000 /* 16 KB */
43#define DEFAULT_DMIBAR 0xfed18000 /* 4 KB */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080044#endif
Stefan Reinauer00636b02012-04-04 00:08:51 +020045#define DEFAULT_EPBAR 0xfed19000 /* 4 KB */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080046#define DEFAULT_RCBABASE ((u8 *)0xfed1c000)
Stefan Reinauer00636b02012-04-04 00:08:51 +020047
Nico Huberbb9469c2015-10-21 11:49:23 +020048#define IOMMU_BASE1 0xfed90000ULL
49#define IOMMU_BASE2 0xfed91000ULL
50
Stefan Reinauer00636b02012-04-04 00:08:51 +020051/* Everything below this line is ignored in the DSDT */
52#ifndef __ACPI__
Patrick Rudolph74203de2017-11-20 11:57:01 +010053#include <cpu/intel/model_206ax/model_206ax.h>
54
55/* Chipset types */
56enum platform_type {
57 PLATFORM_MOBILE = 0,
58 PLATFORM_DESKTOP_SERVER,
59};
Stefan Reinauer00636b02012-04-04 00:08:51 +020060
Nico Huber9d9ce0d2015-10-26 12:59:49 +010061
Stefan Reinauer00636b02012-04-04 00:08:51 +020062/* Device 0:0.0 PCI configuration space (Host Bridge) */
63
64#define EPBAR 0x40
65#define MCHBAR 0x48
66#define PCIEXBAR 0x60
67#define DMIBAR 0x68
68#define X60BAR 0x60
69
70#define GGC 0x50 /* GMCH Graphics Control */
71
72#define DEVEN 0x54 /* Device Enable */
Patrick Rudolphecd4be82017-05-14 12:40:50 +020073#define DEVEN_D7EN (1 << 14)
Stefan Reinauer00636b02012-04-04 00:08:51 +020074#define DEVEN_PEG60 (1 << 13)
Patrick Rudolphecd4be82017-05-14 12:40:50 +020075#define DEVEN_D4EN (1 << 7)
Stefan Reinauer00636b02012-04-04 00:08:51 +020076#define DEVEN_IGD (1 << 4)
77#define DEVEN_PEG10 (1 << 3)
78#define DEVEN_PEG11 (1 << 2)
79#define DEVEN_PEG12 (1 << 1)
80#define DEVEN_HOST (1 << 0)
81
Felix Held4902fee2019-12-28 18:09:47 +010082#define PAVPC 0x58 /* Protected Audio Video Path Control */
83#define DPR 0x5c /* DMA Protected Range */
84
Felix Heldbc3668a2019-12-28 18:44:06 +010085#define MEBASE 0x70
86#define MEMASK 0x78
87
Stefan Reinauer00636b02012-04-04 00:08:51 +020088#define PAM0 0x80
89#define PAM1 0x81
90#define PAM2 0x82
91#define PAM3 0x83
92#define PAM4 0x84
93#define PAM5 0x85
94#define PAM6 0x86
95
96#define LAC 0x87 /* Legacy Access Control */
97#define SMRAM 0x88 /* System Management RAM Control */
Stefan Reinauer00636b02012-04-04 00:08:51 +020098
Felix Held4902fee2019-12-28 18:09:47 +010099#define REMAPBASE 0x90
100#define REMAPLIMIT 0x98
Stefan Reinauer00636b02012-04-04 00:08:51 +0200101#define TOM 0xa0
102#define TOUUD 0xa8 /* Top of Upper Usable DRAM */
Felix Held4902fee2019-12-28 18:09:47 +0100103#define BDSM 0xb0 /* Base Data of Stolen Memory */
Vladimir Serbinenkoa3e41c02015-05-28 16:04:17 +0200104#define BGSM 0xb4 /* Base GTT Stolen Memory */
Felix Held4902fee2019-12-28 18:09:47 +0100105#define TSEGMB 0xb8 /* TSEG Memory Base */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200106#define TOLUD 0xbc /* Top of Low Used Memory */
107
Patrick Rudolph9f3f9152016-01-26 20:02:14 +0100108#define CAPID0_A 0xe4 /* Capabilities Register A */
109#define CAPID0_B 0xe8 /* Capabilities Register B */
110
Stefan Reinauer00636b02012-04-04 00:08:51 +0200111#define SKPAD 0xdc /* Scratchpad Data */
112
Stefan Reinauer00636b02012-04-04 00:08:51 +0200113
114/* Device 0:2.0 PCI configuration space (Graphics Device) */
115
116#define MSAC 0x62 /* Multi Size Aperture Control */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200117
118/*
119 * MCHBAR
120 */
121
Felix Heldb9267f02018-07-28 14:49:31 +0200122#define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x))))
123#define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x))))
124#define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + (x))))
Felix Heldfe68a772018-07-29 21:30:54 +0200125#define MCHBAR32_OR(x, or) (MCHBAR32(x) = (MCHBAR32(x) | (or)))
126#define MCHBAR32_AND(x, and) (MCHBAR32(x) = (MCHBAR32(x) & (and)))
127#define MCHBAR32_AND_OR(x, and, or) \
128 (MCHBAR32(x) = (MCHBAR32(x) & (and)) | (or))
Stefan Reinauer00636b02012-04-04 00:08:51 +0200129
130#define SSKPD 0x5d14 /* 16bit (scratchpad) */
131#define BIOS_RESET_CPL 0x5da8 /* 8bit */
132
133/*
134 * EPBAR - Egress Port Root Complex Register Block
135 */
136
Felix Heldb9267f02018-07-28 14:49:31 +0200137#define EPBAR8(x) (*((volatile u8 *)(DEFAULT_EPBAR + (x))))
138#define EPBAR16(x) (*((volatile u16 *)(DEFAULT_EPBAR + (x))))
139#define EPBAR32(x) (*((volatile u32 *)(DEFAULT_EPBAR + (x))))
Stefan Reinauer00636b02012-04-04 00:08:51 +0200140
141#define EPPVCCAP1 0x004 /* 32bit */
142#define EPPVCCAP2 0x008 /* 32bit */
143
144#define EPVC0RCAP 0x010 /* 32bit */
145#define EPVC0RCTL 0x014 /* 32bit */
146#define EPVC0RSTS 0x01a /* 16bit */
147
148#define EPVC1RCAP 0x01c /* 32bit */
149#define EPVC1RCTL 0x020 /* 32bit */
150#define EPVC1RSTS 0x026 /* 16bit */
151
152#define EPVC1MTS 0x028 /* 32bit */
153#define EPVC1IST 0x038 /* 64bit */
154
155#define EPESD 0x044 /* 32bit */
156
157#define EPLE1D 0x050 /* 32bit */
158#define EPLE1A 0x058 /* 64bit */
159#define EPLE2D 0x060 /* 32bit */
160#define EPLE2A 0x068 /* 64bit */
161
162#define PORTARB 0x100 /* 256bit */
163
164/*
165 * DMIBAR
166 */
167
Felix Heldb9267f02018-07-28 14:49:31 +0200168#define DMIBAR8(x) (*((volatile u8 *)(DEFAULT_DMIBAR + (x))))
169#define DMIBAR16(x) (*((volatile u16 *)(DEFAULT_DMIBAR + (x))))
170#define DMIBAR32(x) (*((volatile u32 *)(DEFAULT_DMIBAR + (x))))
Stefan Reinauer00636b02012-04-04 00:08:51 +0200171
172#define DMIVCECH 0x000 /* 32bit */
173#define DMIPVCCAP1 0x004 /* 32bit */
174#define DMIPVCCAP2 0x008 /* 32bit */
175
176#define DMIPVCCCTL 0x00c /* 16bit */
177
178#define DMIVC0RCAP 0x010 /* 32bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100179#define DMIVC0RCTL 0x014 /* 32bit */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200180#define DMIVC0RSTS 0x01a /* 16bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100181#define VC0NP 0x2
Stefan Reinauer00636b02012-04-04 00:08:51 +0200182
183#define DMIVC1RCAP 0x01c /* 32bit */
184#define DMIVC1RCTL 0x020 /* 32bit */
185#define DMIVC1RSTS 0x026 /* 16bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100186#define VC1NP 0x2
187
188#define DMIVCPRCTL 0x02c /* 32bit */
189
190#define DMIVCPRSTS 0x032 /* 16bit */
191#define VCPNP 0x2
192
193#define DMIVCMRCTL 0x0038 /* 32 bit */
194#define DMIVCMRSTS 0x003e /* 16 bit */
195#define VCMNP 0x2
Stefan Reinauer00636b02012-04-04 00:08:51 +0200196
197#define DMILE1D 0x050 /* 32bit */
198#define DMILE1A 0x058 /* 64bit */
199#define DMILE2D 0x060 /* 32bit */
200#define DMILE2A 0x068 /* 64bit */
201
202#define DMILCAP 0x084 /* 32bit */
203#define DMILCTL 0x088 /* 16bit */
204#define DMILSTS 0x08a /* 16bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100205#define TXTRN (1 << 11)
Stefan Reinauer00636b02012-04-04 00:08:51 +0200206#define DMICTL1 0x0f0 /* 32bit */
207#define DMICTL2 0x0fc /* 32bit */
208
209#define DMICC 0x208 /* 32bit */
210
211#define DMIDRCCFG 0xeb4 /* 32bit */
212
213#ifndef __ASSEMBLER__
Stefan Reinauer00636b02012-04-04 00:08:51 +0200214
Stefan Reinauer00636b02012-04-04 00:08:51 +0200215void intel_sandybridge_finalize_smm(void);
Kyösti Mälkki82c0e7e2019-11-05 19:06:56 +0200216
Stefan Reinauer00636b02012-04-04 00:08:51 +0200217int bridge_silicon_revision(void);
Patrick Rudolph2cdb65d2019-03-24 18:08:43 +0100218void systemagent_early_init(void);
Nico Huberbb9469c2015-10-21 11:49:23 +0200219void sandybridge_init_iommu(void);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200220void sandybridge_late_initialization(void);
Vladimir Serbinenkoc845b432014-09-05 03:37:44 +0200221void northbridge_romstage_finalize(int s3resume);
Patrick Rudolph6aca7e62019-03-26 18:22:36 +0100222void early_init_dmi(void);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200223
Arthur Heymansdc2e7c62019-11-12 16:17:26 +0100224/* mainboard_early_init: Optional mainboard callback run after console init
225 but before raminit. */
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100226void mainboard_early_init(int s3resume);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100227int mainboard_should_reset_usb(int s3resume);
228void perform_raminit(int s3resume);
Patrick Rudolph74203de2017-11-20 11:57:01 +0100229enum platform_type get_platform_type(void);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100230
Nico Huber9d9ce0d2015-10-26 12:59:49 +0100231#include <device/device.h>
232
233struct acpi_rsdp;
Elyes HAOUASab8743c2018-02-09 08:21:40 +0100234unsigned long northbridge_write_acpi_tables(struct device *device, unsigned long start, struct acpi_rsdp *rsdp);
Nico Huber9d9ce0d2015-10-26 12:59:49 +0100235
Stefan Reinauer00636b02012-04-04 00:08:51 +0200236#endif
237#endif
Edward O'Callaghan089a5102015-01-06 02:48:57 +1100238#endif /* __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ */