blob: 0b29e1705ebfeec558861c7c279c3d35ab0c4652 [file] [log] [blame]
Angel Pons6e5aabd2020-03-23 23:44:42 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Stefan Reinauer00636b02012-04-04 00:08:51 +02003
4#ifndef __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__
Edward O'Callaghan089a5102015-01-06 02:48:57 +11005#define __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__
Stefan Reinauer00636b02012-04-04 00:08:51 +02006
Stefan Reinauer00636b02012-04-04 00:08:51 +02007/* Device ID for SandyBridge and IvyBridge */
8#define BASE_REV_SNB 0x00
9#define BASE_REV_IVB 0x50
10#define BASE_REV_MASK 0x50
11
12/* SandyBridge CPU stepping */
13#define SNB_STEP_D0 (BASE_REV_SNB + 5) /* Also J0 */
14#define SNB_STEP_D1 (BASE_REV_SNB + 6)
15#define SNB_STEP_D2 (BASE_REV_SNB + 7) /* Also J1/Q0 */
16
17/* IvyBridge CPU stepping */
18#define IVB_STEP_A0 (BASE_REV_IVB + 0)
19#define IVB_STEP_B0 (BASE_REV_IVB + 2)
20#define IVB_STEP_C0 (BASE_REV_IVB + 4)
21#define IVB_STEP_K0 (BASE_REV_IVB + 5)
22#define IVB_STEP_D0 (BASE_REV_IVB + 6)
23
Stefan Reinauer00636b02012-04-04 00:08:51 +020024/* Northbridge BARs */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080025#ifndef __ACPI__
26#define DEFAULT_MCHBAR ((u8 *)0xfed10000) /* 16 KB */
27#define DEFAULT_DMIBAR ((u8 *)0xfed18000) /* 4 KB */
28#else
Stefan Reinauer00636b02012-04-04 00:08:51 +020029#define DEFAULT_MCHBAR 0xfed10000 /* 16 KB */
30#define DEFAULT_DMIBAR 0xfed18000 /* 4 KB */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080031#endif
Stefan Reinauer00636b02012-04-04 00:08:51 +020032#define DEFAULT_EPBAR 0xfed19000 /* 4 KB */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080033#define DEFAULT_RCBABASE ((u8 *)0xfed1c000)
Stefan Reinauer00636b02012-04-04 00:08:51 +020034
Angel Pons7c49cb82020-03-16 23:17:32 +010035#define GFXVT_BASE 0xfed90000ULL
36#define VTVC0_BASE 0xfed91000ULL
Nico Huberbb9469c2015-10-21 11:49:23 +020037
Stefan Reinauer00636b02012-04-04 00:08:51 +020038/* Everything below this line is ignored in the DSDT */
39#ifndef __ACPI__
Patrick Rudolph74203de2017-11-20 11:57:01 +010040#include <cpu/intel/model_206ax/model_206ax.h>
41
42/* Chipset types */
43enum platform_type {
44 PLATFORM_MOBILE = 0,
45 PLATFORM_DESKTOP_SERVER,
46};
Stefan Reinauer00636b02012-04-04 00:08:51 +020047
Nico Huber9d9ce0d2015-10-26 12:59:49 +010048
Stefan Reinauer00636b02012-04-04 00:08:51 +020049/* Device 0:0.0 PCI configuration space (Host Bridge) */
Angel Pons7c49cb82020-03-16 23:17:32 +010050#define HOST_BRIDGE PCI_DEV(0, 0, 0)
Stefan Reinauer00636b02012-04-04 00:08:51 +020051
52#define EPBAR 0x40
53#define MCHBAR 0x48
Stefan Reinauer00636b02012-04-04 00:08:51 +020054
Angel Pons7c49cb82020-03-16 23:17:32 +010055#define GGC 0x50 /* GMCH Graphics Control */
56#define DEVEN 0x54 /* Device Enable */
Patrick Rudolphecd4be82017-05-14 12:40:50 +020057#define DEVEN_D7EN (1 << 14)
Stefan Reinauer00636b02012-04-04 00:08:51 +020058#define DEVEN_PEG60 (1 << 13)
Angel Pons7c49cb82020-03-16 23:17:32 +010059#define DEVEN_D4EN (1 << 7)
60#define DEVEN_IGD (1 << 4)
61#define DEVEN_PEG10 (1 << 3)
62#define DEVEN_PEG11 (1 << 2)
63#define DEVEN_PEG12 (1 << 1)
64#define DEVEN_HOST (1 << 0)
Stefan Reinauer00636b02012-04-04 00:08:51 +020065
Felix Held4902fee2019-12-28 18:09:47 +010066#define PAVPC 0x58 /* Protected Audio Video Path Control */
67#define DPR 0x5c /* DMA Protected Range */
68
Angel Pons7c49cb82020-03-16 23:17:32 +010069#define PCIEXBAR 0x60
70#define DMIBAR 0x68
71
Felix Held651f99f2019-12-30 16:28:48 +010072#define MESEG_BASE 0x70
73#define MESEG_MASK 0x78
Angel Pons7c49cb82020-03-16 23:17:32 +010074#define MELCK (1 << 10) /* ME Range Lock */
75#define ME_STLEN_EN (1 << 11) /* ME Stolen Memory Enable */
Felix Heldbc3668a2019-12-28 18:44:06 +010076
Stefan Reinauer00636b02012-04-04 00:08:51 +020077#define PAM0 0x80
78#define PAM1 0x81
79#define PAM2 0x82
80#define PAM3 0x83
81#define PAM4 0x84
82#define PAM5 0x85
83#define PAM6 0x86
84
85#define LAC 0x87 /* Legacy Access Control */
86#define SMRAM 0x88 /* System Management RAM Control */
Stefan Reinauer00636b02012-04-04 00:08:51 +020087
Felix Held4902fee2019-12-28 18:09:47 +010088#define REMAPBASE 0x90
89#define REMAPLIMIT 0x98
Stefan Reinauer00636b02012-04-04 00:08:51 +020090#define TOM 0xa0
91#define TOUUD 0xa8 /* Top of Upper Usable DRAM */
Felix Held4902fee2019-12-28 18:09:47 +010092#define BDSM 0xb0 /* Base Data of Stolen Memory */
Vladimir Serbinenkoa3e41c02015-05-28 16:04:17 +020093#define BGSM 0xb4 /* Base GTT Stolen Memory */
Felix Held4902fee2019-12-28 18:09:47 +010094#define TSEGMB 0xb8 /* TSEG Memory Base */
Stefan Reinauer00636b02012-04-04 00:08:51 +020095#define TOLUD 0xbc /* Top of Low Used Memory */
96
Patrick Rudolph9f3f9152016-01-26 20:02:14 +010097#define CAPID0_A 0xe4 /* Capabilities Register A */
98#define CAPID0_B 0xe8 /* Capabilities Register B */
99
Stefan Reinauer00636b02012-04-04 00:08:51 +0200100#define SKPAD 0xdc /* Scratchpad Data */
101
Angel Pons7c49cb82020-03-16 23:17:32 +0100102#define DIDOR 0xf3 /* Device ID override, for debug and samples only */
103
104
105/* Devices 0:1.0, 0:1.1, 0:1.2, 0:6.0 PCI configuration space (PCI Express Graphics) */
106
107#define AFE_PWRON 0xc24 /* PEG Analog Front-End Power-On */
108
Stefan Reinauer00636b02012-04-04 00:08:51 +0200109
110/* Device 0:2.0 PCI configuration space (Graphics Device) */
111
112#define MSAC 0x62 /* Multi Size Aperture Control */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200113
114/*
115 * MCHBAR
116 */
117
Angel Pons7c49cb82020-03-16 23:17:32 +0100118#define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x))))
Felix Heldb9267f02018-07-28 14:49:31 +0200119#define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x))))
120#define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + (x))))
Angel Pons7c49cb82020-03-16 23:17:32 +0100121#define MCHBAR8_AND(x, and) (MCHBAR8(x) = MCHBAR8(x) & (and))
122#define MCHBAR16_AND(x, and) (MCHBAR16(x) = MCHBAR16(x) & (and))
123#define MCHBAR32_AND(x, and) (MCHBAR32(x) = MCHBAR32(x) & (and))
124#define MCHBAR8_OR(x, or) (MCHBAR8(x) = MCHBAR8(x) | (or))
125#define MCHBAR16_OR(x, or) (MCHBAR16(x) = MCHBAR16(x) | (or))
126#define MCHBAR32_OR(x, or) (MCHBAR32(x) = MCHBAR32(x) | (or))
127#define MCHBAR8_AND_OR(x, and, or) (MCHBAR8(x) = (MCHBAR8(x) & (and)) | (or))
128#define MCHBAR16_AND_OR(x, and, or) (MCHBAR16(x) = (MCHBAR16(x) & (and)) | (or))
Angel Pons26be0bd2019-12-31 14:29:48 +0100129#define MCHBAR32_AND_OR(x, and, or) (MCHBAR32(x) = (MCHBAR32(x) & (and)) | (or))
Stefan Reinauer00636b02012-04-04 00:08:51 +0200130
Angel Pons7c49cb82020-03-16 23:17:32 +0100131/* As there are many registers, define them on a separate file */
132#include "mchbar_regs.h"
Stefan Reinauer00636b02012-04-04 00:08:51 +0200133
134/*
135 * EPBAR - Egress Port Root Complex Register Block
136 */
137
Angel Pons7c49cb82020-03-16 23:17:32 +0100138#define EPBAR8(x) (*((volatile u8 *)(DEFAULT_EPBAR + (x))))
Felix Heldb9267f02018-07-28 14:49:31 +0200139#define EPBAR16(x) (*((volatile u16 *)(DEFAULT_EPBAR + (x))))
140#define EPBAR32(x) (*((volatile u32 *)(DEFAULT_EPBAR + (x))))
Stefan Reinauer00636b02012-04-04 00:08:51 +0200141
142#define EPPVCCAP1 0x004 /* 32bit */
143#define EPPVCCAP2 0x008 /* 32bit */
144
145#define EPVC0RCAP 0x010 /* 32bit */
146#define EPVC0RCTL 0x014 /* 32bit */
147#define EPVC0RSTS 0x01a /* 16bit */
148
149#define EPVC1RCAP 0x01c /* 32bit */
150#define EPVC1RCTL 0x020 /* 32bit */
151#define EPVC1RSTS 0x026 /* 16bit */
152
153#define EPVC1MTS 0x028 /* 32bit */
154#define EPVC1IST 0x038 /* 64bit */
155
156#define EPESD 0x044 /* 32bit */
157
158#define EPLE1D 0x050 /* 32bit */
159#define EPLE1A 0x058 /* 64bit */
160#define EPLE2D 0x060 /* 32bit */
161#define EPLE2A 0x068 /* 64bit */
162
163#define PORTARB 0x100 /* 256bit */
164
165/*
166 * DMIBAR
167 */
168
Angel Pons7c49cb82020-03-16 23:17:32 +0100169#define DMIBAR8(x) (*((volatile u8 *)(DEFAULT_DMIBAR + (x))))
Felix Heldb9267f02018-07-28 14:49:31 +0200170#define DMIBAR16(x) (*((volatile u16 *)(DEFAULT_DMIBAR + (x))))
171#define DMIBAR32(x) (*((volatile u32 *)(DEFAULT_DMIBAR + (x))))
Stefan Reinauer00636b02012-04-04 00:08:51 +0200172
173#define DMIVCECH 0x000 /* 32bit */
174#define DMIPVCCAP1 0x004 /* 32bit */
175#define DMIPVCCAP2 0x008 /* 32bit */
176
177#define DMIPVCCCTL 0x00c /* 16bit */
178
179#define DMIVC0RCAP 0x010 /* 32bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100180#define DMIVC0RCTL 0x014 /* 32bit */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200181#define DMIVC0RSTS 0x01a /* 16bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100182#define VC0NP 0x2
Stefan Reinauer00636b02012-04-04 00:08:51 +0200183
184#define DMIVC1RCAP 0x01c /* 32bit */
185#define DMIVC1RCTL 0x020 /* 32bit */
186#define DMIVC1RSTS 0x026 /* 16bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100187#define VC1NP 0x2
188
189#define DMIVCPRCTL 0x02c /* 32bit */
190
191#define DMIVCPRSTS 0x032 /* 16bit */
192#define VCPNP 0x2
193
194#define DMIVCMRCTL 0x0038 /* 32 bit */
195#define DMIVCMRSTS 0x003e /* 16 bit */
196#define VCMNP 0x2
Stefan Reinauer00636b02012-04-04 00:08:51 +0200197
198#define DMILE1D 0x050 /* 32bit */
199#define DMILE1A 0x058 /* 64bit */
200#define DMILE2D 0x060 /* 32bit */
201#define DMILE2A 0x068 /* 64bit */
202
203#define DMILCAP 0x084 /* 32bit */
204#define DMILCTL 0x088 /* 16bit */
205#define DMILSTS 0x08a /* 16bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100206#define TXTRN (1 << 11)
Stefan Reinauer00636b02012-04-04 00:08:51 +0200207#define DMICTL1 0x0f0 /* 32bit */
208#define DMICTL2 0x0fc /* 32bit */
209
210#define DMICC 0x208 /* 32bit */
211
212#define DMIDRCCFG 0xeb4 /* 32bit */
213
214#ifndef __ASSEMBLER__
Stefan Reinauer00636b02012-04-04 00:08:51 +0200215
Stefan Reinauer00636b02012-04-04 00:08:51 +0200216void intel_sandybridge_finalize_smm(void);
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
Angel Pons7c49cb82020-03-16 23:17:32 +0100224/* mainboard_early_init: Optional callback, run after console init but before raminit. */
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100225void mainboard_early_init(int s3resume);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100226int mainboard_should_reset_usb(int s3resume);
227void perform_raminit(int s3resume);
Angel Pons064c7992020-03-17 23:09:16 +0100228void report_memory_config(void);
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;
Furquan Shaikh0f007d82020-04-24 06:41:18 -0700234unsigned long northbridge_write_acpi_tables(const struct device *device, unsigned long start,
Angel Pons7c49cb82020-03-16 23:17:32 +0100235 struct acpi_rsdp *rsdp);
Nico Huber9d9ce0d2015-10-26 12:59:49 +0100236
Stefan Reinauer00636b02012-04-04 00:08:51 +0200237#endif
238#endif
Edward O'Callaghan089a5102015-01-06 02:48:57 +1100239#endif /* __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ */