blob: 7b008e8354750233e63d0aca38f1183b493e3fcd [file] [log] [blame]
Angel Pons6e5aabd2020-03-23 23:44:42 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer00636b02012-04-04 00:08:51 +02002
3#ifndef __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__
Edward O'Callaghan089a5102015-01-06 02:48:57 +11004#define __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__
Stefan Reinauer00636b02012-04-04 00:08:51 +02005
Stefan Reinauer00636b02012-04-04 00:08:51 +02006/* Device ID for SandyBridge and IvyBridge */
7#define BASE_REV_SNB 0x00
8#define BASE_REV_IVB 0x50
9#define BASE_REV_MASK 0x50
10
11/* SandyBridge CPU stepping */
12#define SNB_STEP_D0 (BASE_REV_SNB + 5) /* Also J0 */
13#define SNB_STEP_D1 (BASE_REV_SNB + 6)
14#define SNB_STEP_D2 (BASE_REV_SNB + 7) /* Also J1/Q0 */
15
16/* IvyBridge CPU stepping */
17#define IVB_STEP_A0 (BASE_REV_IVB + 0)
18#define IVB_STEP_B0 (BASE_REV_IVB + 2)
19#define IVB_STEP_C0 (BASE_REV_IVB + 4)
20#define IVB_STEP_K0 (BASE_REV_IVB + 5)
21#define IVB_STEP_D0 (BASE_REV_IVB + 6)
22
Stefan Reinauer00636b02012-04-04 00:08:51 +020023/* Northbridge BARs */
Stefan Reinauer00636b02012-04-04 00:08:51 +020024#define DEFAULT_MCHBAR 0xfed10000 /* 16 KB */
25#define DEFAULT_DMIBAR 0xfed18000 /* 4 KB */
26#define DEFAULT_EPBAR 0xfed19000 /* 4 KB */
Stefan Reinauer00636b02012-04-04 00:08:51 +020027
Angel Pons7c49cb82020-03-16 23:17:32 +010028#define GFXVT_BASE 0xfed90000ULL
29#define VTVC0_BASE 0xfed91000ULL
Nico Huberbb9469c2015-10-21 11:49:23 +020030
Stefan Reinauer00636b02012-04-04 00:08:51 +020031/* Everything below this line is ignored in the DSDT */
32#ifndef __ACPI__
Elyes HAOUAS1d6484a2020-07-10 11:18:11 +020033#include <stdint.h>
Patrick Rudolph74203de2017-11-20 11:57:01 +010034
35/* Chipset types */
36enum platform_type {
37 PLATFORM_MOBILE = 0,
38 PLATFORM_DESKTOP_SERVER,
39};
Stefan Reinauer00636b02012-04-04 00:08:51 +020040
Nico Huber9d9ce0d2015-10-26 12:59:49 +010041
Stefan Reinauer00636b02012-04-04 00:08:51 +020042/* Device 0:0.0 PCI configuration space (Host Bridge) */
Angel Pons7c49cb82020-03-16 23:17:32 +010043#define HOST_BRIDGE PCI_DEV(0, 0, 0)
Stefan Reinauer00636b02012-04-04 00:08:51 +020044
Angel Pons579e0962020-07-22 11:11:50 +020045#include "hostbridge_regs.h"
Angel Pons7c49cb82020-03-16 23:17:32 +010046
47
48/* Devices 0:1.0, 0:1.1, 0:1.2, 0:6.0 PCI configuration space (PCI Express Graphics) */
49
50#define AFE_PWRON 0xc24 /* PEG Analog Front-End Power-On */
51
Stefan Reinauer00636b02012-04-04 00:08:51 +020052
53/* Device 0:2.0 PCI configuration space (Graphics Device) */
54
55#define MSAC 0x62 /* Multi Size Aperture Control */
Stefan Reinauer00636b02012-04-04 00:08:51 +020056
57/*
58 * MCHBAR
59 */
60
Angel Pons7c49cb82020-03-16 23:17:32 +010061#define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x))))
Felix Heldb9267f02018-07-28 14:49:31 +020062#define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x))))
Angel Pons74315932020-09-14 16:50:49 +020063#define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + (x))))
Angel Pons7c49cb82020-03-16 23:17:32 +010064#define MCHBAR8_AND(x, and) (MCHBAR8(x) = MCHBAR8(x) & (and))
65#define MCHBAR16_AND(x, and) (MCHBAR16(x) = MCHBAR16(x) & (and))
66#define MCHBAR32_AND(x, and) (MCHBAR32(x) = MCHBAR32(x) & (and))
67#define MCHBAR8_OR(x, or) (MCHBAR8(x) = MCHBAR8(x) | (or))
68#define MCHBAR16_OR(x, or) (MCHBAR16(x) = MCHBAR16(x) | (or))
69#define MCHBAR32_OR(x, or) (MCHBAR32(x) = MCHBAR32(x) | (or))
70#define MCHBAR8_AND_OR(x, and, or) (MCHBAR8(x) = (MCHBAR8(x) & (and)) | (or))
71#define MCHBAR16_AND_OR(x, and, or) (MCHBAR16(x) = (MCHBAR16(x) & (and)) | (or))
Angel Pons26be0bd2019-12-31 14:29:48 +010072#define MCHBAR32_AND_OR(x, and, or) (MCHBAR32(x) = (MCHBAR32(x) & (and)) | (or))
Stefan Reinauer00636b02012-04-04 00:08:51 +020073
Angel Pons7c49cb82020-03-16 23:17:32 +010074/* As there are many registers, define them on a separate file */
75#include "mchbar_regs.h"
Stefan Reinauer00636b02012-04-04 00:08:51 +020076
77/*
78 * EPBAR - Egress Port Root Complex Register Block
79 */
80
Angel Pons7c49cb82020-03-16 23:17:32 +010081#define EPBAR8(x) (*((volatile u8 *)(DEFAULT_EPBAR + (x))))
Felix Heldb9267f02018-07-28 14:49:31 +020082#define EPBAR16(x) (*((volatile u16 *)(DEFAULT_EPBAR + (x))))
83#define EPBAR32(x) (*((volatile u32 *)(DEFAULT_EPBAR + (x))))
Stefan Reinauer00636b02012-04-04 00:08:51 +020084
85#define EPPVCCAP1 0x004 /* 32bit */
86#define EPPVCCAP2 0x008 /* 32bit */
87
88#define EPVC0RCAP 0x010 /* 32bit */
89#define EPVC0RCTL 0x014 /* 32bit */
90#define EPVC0RSTS 0x01a /* 16bit */
91
92#define EPVC1RCAP 0x01c /* 32bit */
93#define EPVC1RCTL 0x020 /* 32bit */
94#define EPVC1RSTS 0x026 /* 16bit */
95
96#define EPVC1MTS 0x028 /* 32bit */
97#define EPVC1IST 0x038 /* 64bit */
98
99#define EPESD 0x044 /* 32bit */
100
101#define EPLE1D 0x050 /* 32bit */
102#define EPLE1A 0x058 /* 64bit */
103#define EPLE2D 0x060 /* 32bit */
104#define EPLE2A 0x068 /* 64bit */
105
106#define PORTARB 0x100 /* 256bit */
107
108/*
109 * DMIBAR
110 */
111
Angel Pons7c49cb82020-03-16 23:17:32 +0100112#define DMIBAR8(x) (*((volatile u8 *)(DEFAULT_DMIBAR + (x))))
Felix Heldb9267f02018-07-28 14:49:31 +0200113#define DMIBAR16(x) (*((volatile u16 *)(DEFAULT_DMIBAR + (x))))
114#define DMIBAR32(x) (*((volatile u32 *)(DEFAULT_DMIBAR + (x))))
Stefan Reinauer00636b02012-04-04 00:08:51 +0200115
116#define DMIVCECH 0x000 /* 32bit */
117#define DMIPVCCAP1 0x004 /* 32bit */
118#define DMIPVCCAP2 0x008 /* 32bit */
119
120#define DMIPVCCCTL 0x00c /* 16bit */
121
122#define DMIVC0RCAP 0x010 /* 32bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100123#define DMIVC0RCTL 0x014 /* 32bit */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200124#define DMIVC0RSTS 0x01a /* 16bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100125#define VC0NP 0x2
Stefan Reinauer00636b02012-04-04 00:08:51 +0200126
127#define DMIVC1RCAP 0x01c /* 32bit */
128#define DMIVC1RCTL 0x020 /* 32bit */
129#define DMIVC1RSTS 0x026 /* 16bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100130#define VC1NP 0x2
131
132#define DMIVCPRCTL 0x02c /* 32bit */
133
134#define DMIVCPRSTS 0x032 /* 16bit */
135#define VCPNP 0x2
136
137#define DMIVCMRCTL 0x0038 /* 32 bit */
138#define DMIVCMRSTS 0x003e /* 16 bit */
139#define VCMNP 0x2
Stefan Reinauer00636b02012-04-04 00:08:51 +0200140
141#define DMILE1D 0x050 /* 32bit */
142#define DMILE1A 0x058 /* 64bit */
143#define DMILE2D 0x060 /* 32bit */
144#define DMILE2A 0x068 /* 64bit */
145
146#define DMILCAP 0x084 /* 32bit */
147#define DMILCTL 0x088 /* 16bit */
148#define DMILSTS 0x08a /* 16bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100149#define TXTRN (1 << 11)
Stefan Reinauer00636b02012-04-04 00:08:51 +0200150#define DMICTL1 0x0f0 /* 32bit */
151#define DMICTL2 0x0fc /* 32bit */
152
153#define DMICC 0x208 /* 32bit */
154
155#define DMIDRCCFG 0xeb4 /* 32bit */
156
157#ifndef __ASSEMBLER__
Stefan Reinauer00636b02012-04-04 00:08:51 +0200158
Stefan Reinauer00636b02012-04-04 00:08:51 +0200159void intel_sandybridge_finalize_smm(void);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200160int bridge_silicon_revision(void);
Patrick Rudolph2cdb65d2019-03-24 18:08:43 +0100161void systemagent_early_init(void);
Nico Huberbb9469c2015-10-21 11:49:23 +0200162void sandybridge_init_iommu(void);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200163void sandybridge_late_initialization(void);
Vladimir Serbinenkoc845b432014-09-05 03:37:44 +0200164void northbridge_romstage_finalize(int s3resume);
Patrick Rudolph6aca7e62019-03-26 18:22:36 +0100165void early_init_dmi(void);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200166
Angel Pons7c49cb82020-03-16 23:17:32 +0100167/* mainboard_early_init: Optional callback, run after console init but before raminit. */
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100168void mainboard_early_init(int s3resume);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100169int mainboard_should_reset_usb(int s3resume);
170void perform_raminit(int s3resume);
Angel Pons064c7992020-03-17 23:09:16 +0100171void report_memory_config(void);
Patrick Rudolph74203de2017-11-20 11:57:01 +0100172enum platform_type get_platform_type(void);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100173
Angel Pons8bf19762020-08-03 14:55:18 +0200174int decode_pcie_bar(u32 *const base, u32 *const len);
175
Nico Huber9d9ce0d2015-10-26 12:59:49 +0100176#include <device/device.h>
177
178struct acpi_rsdp;
Furquan Shaikh0f007d82020-04-24 06:41:18 -0700179unsigned long northbridge_write_acpi_tables(const struct device *device, unsigned long start,
Angel Pons7c49cb82020-03-16 23:17:32 +0100180 struct acpi_rsdp *rsdp);
Nico Huber9d9ce0d2015-10-26 12:59:49 +0100181
Stefan Reinauer00636b02012-04-04 00:08:51 +0200182#endif
183#endif
Edward O'Callaghan089a5102015-01-06 02:48:57 +1100184#endif /* __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ */