blob: 5c15cb1ad32d402f057fd98f60415ad7641e8b8f [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
Angel Ponsdfca1692020-09-14 16:54:42 +020023#include "memmap.h"
Nico Huberbb9469c2015-10-21 11:49:23 +020024
Stefan Reinauer00636b02012-04-04 00:08:51 +020025/* Everything below this line is ignored in the DSDT */
26#ifndef __ACPI__
Elyes HAOUAS1d6484a2020-07-10 11:18:11 +020027#include <stdint.h>
Patrick Rudolph74203de2017-11-20 11:57:01 +010028
29/* Chipset types */
30enum platform_type {
31 PLATFORM_MOBILE = 0,
32 PLATFORM_DESKTOP_SERVER,
33};
Stefan Reinauer00636b02012-04-04 00:08:51 +020034
Nico Huber9d9ce0d2015-10-26 12:59:49 +010035
Stefan Reinauer00636b02012-04-04 00:08:51 +020036/* Device 0:0.0 PCI configuration space (Host Bridge) */
Angel Pons7c49cb82020-03-16 23:17:32 +010037#define HOST_BRIDGE PCI_DEV(0, 0, 0)
Stefan Reinauer00636b02012-04-04 00:08:51 +020038
Angel Pons3447db52020-09-14 18:09:46 +020039#include "registers/host_bridge.h"
Angel Pons7c49cb82020-03-16 23:17:32 +010040
41
42/* Devices 0:1.0, 0:1.1, 0:1.2, 0:6.0 PCI configuration space (PCI Express Graphics) */
43
44#define AFE_PWRON 0xc24 /* PEG Analog Front-End Power-On */
45
Stefan Reinauer00636b02012-04-04 00:08:51 +020046
47/* Device 0:2.0 PCI configuration space (Graphics Device) */
48
49#define MSAC 0x62 /* Multi Size Aperture Control */
Stefan Reinauer00636b02012-04-04 00:08:51 +020050
51/*
52 * MCHBAR
53 */
54
Angel Pons7c49cb82020-03-16 23:17:32 +010055#define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x))))
Felix Heldb9267f02018-07-28 14:49:31 +020056#define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x))))
Angel Pons74315932020-09-14 16:50:49 +020057#define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + (x))))
Angel Pons7c49cb82020-03-16 23:17:32 +010058#define MCHBAR8_AND(x, and) (MCHBAR8(x) = MCHBAR8(x) & (and))
59#define MCHBAR16_AND(x, and) (MCHBAR16(x) = MCHBAR16(x) & (and))
60#define MCHBAR32_AND(x, and) (MCHBAR32(x) = MCHBAR32(x) & (and))
61#define MCHBAR8_OR(x, or) (MCHBAR8(x) = MCHBAR8(x) | (or))
62#define MCHBAR16_OR(x, or) (MCHBAR16(x) = MCHBAR16(x) | (or))
63#define MCHBAR32_OR(x, or) (MCHBAR32(x) = MCHBAR32(x) | (or))
64#define MCHBAR8_AND_OR(x, and, or) (MCHBAR8(x) = (MCHBAR8(x) & (and)) | (or))
65#define MCHBAR16_AND_OR(x, and, or) (MCHBAR16(x) = (MCHBAR16(x) & (and)) | (or))
Angel Pons26be0bd2019-12-31 14:29:48 +010066#define MCHBAR32_AND_OR(x, and, or) (MCHBAR32(x) = (MCHBAR32(x) & (and)) | (or))
Stefan Reinauer00636b02012-04-04 00:08:51 +020067
Angel Pons7c49cb82020-03-16 23:17:32 +010068/* As there are many registers, define them on a separate file */
Angel Pons3447db52020-09-14 18:09:46 +020069#include "registers/mchbar.h"
Stefan Reinauer00636b02012-04-04 00:08:51 +020070
71/*
72 * EPBAR - Egress Port Root Complex Register Block
73 */
74
Angel Pons7c49cb82020-03-16 23:17:32 +010075#define EPBAR8(x) (*((volatile u8 *)(DEFAULT_EPBAR + (x))))
Felix Heldb9267f02018-07-28 14:49:31 +020076#define EPBAR16(x) (*((volatile u16 *)(DEFAULT_EPBAR + (x))))
77#define EPBAR32(x) (*((volatile u32 *)(DEFAULT_EPBAR + (x))))
Stefan Reinauer00636b02012-04-04 00:08:51 +020078
79#define EPPVCCAP1 0x004 /* 32bit */
80#define EPPVCCAP2 0x008 /* 32bit */
81
82#define EPVC0RCAP 0x010 /* 32bit */
83#define EPVC0RCTL 0x014 /* 32bit */
84#define EPVC0RSTS 0x01a /* 16bit */
85
86#define EPVC1RCAP 0x01c /* 32bit */
87#define EPVC1RCTL 0x020 /* 32bit */
88#define EPVC1RSTS 0x026 /* 16bit */
89
Stefan Reinauer00636b02012-04-04 00:08:51 +020090#define EPESD 0x044 /* 32bit */
91
92#define EPLE1D 0x050 /* 32bit */
93#define EPLE1A 0x058 /* 64bit */
94#define EPLE2D 0x060 /* 32bit */
95#define EPLE2A 0x068 /* 64bit */
96
Stefan Reinauer00636b02012-04-04 00:08:51 +020097/*
98 * DMIBAR
99 */
100
Angel Pons7c49cb82020-03-16 23:17:32 +0100101#define DMIBAR8(x) (*((volatile u8 *)(DEFAULT_DMIBAR + (x))))
Felix Heldb9267f02018-07-28 14:49:31 +0200102#define DMIBAR16(x) (*((volatile u16 *)(DEFAULT_DMIBAR + (x))))
103#define DMIBAR32(x) (*((volatile u32 *)(DEFAULT_DMIBAR + (x))))
Stefan Reinauer00636b02012-04-04 00:08:51 +0200104
105#define DMIVCECH 0x000 /* 32bit */
106#define DMIPVCCAP1 0x004 /* 32bit */
107#define DMIPVCCAP2 0x008 /* 32bit */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200108#define DMIPVCCCTL 0x00c /* 16bit */
109
110#define DMIVC0RCAP 0x010 /* 32bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100111#define DMIVC0RCTL 0x014 /* 32bit */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200112#define DMIVC0RSTS 0x01a /* 16bit */
Angel Ponsf950a7e2020-09-14 17:15:37 +0200113#define VC0NP (1 << 1)
Stefan Reinauer00636b02012-04-04 00:08:51 +0200114
115#define DMIVC1RCAP 0x01c /* 32bit */
116#define DMIVC1RCTL 0x020 /* 32bit */
117#define DMIVC1RSTS 0x026 /* 16bit */
Angel Ponsf950a7e2020-09-14 17:15:37 +0200118#define VC1NP (1 << 1)
Patrick Rudolphbf743502019-03-25 17:05:20 +0100119
Angel Ponsf950a7e2020-09-14 17:15:37 +0200120#define DMIVCPRCAP 0x028 /* 32bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100121#define DMIVCPRCTL 0x02c /* 32bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100122#define DMIVCPRSTS 0x032 /* 16bit */
Angel Ponsf950a7e2020-09-14 17:15:37 +0200123#define VCPNP (1 << 1)
Patrick Rudolphbf743502019-03-25 17:05:20 +0100124
Angel Ponsf950a7e2020-09-14 17:15:37 +0200125#define DMIVCMRCAP 0x034 /* 32bit */
126#define DMIVCMRCTL 0x038 /* 32bit */
127#define DMIVCMRSTS 0x03e /* 16bit */
128#define VCMNP (1 << 1)
129
130#define DMIRCLDECH 0x040 /* 32bit */
131#define DMIESD 0x044 /* 32bit */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200132
133#define DMILE1D 0x050 /* 32bit */
134#define DMILE1A 0x058 /* 64bit */
135#define DMILE2D 0x060 /* 32bit */
136#define DMILE2A 0x068 /* 64bit */
137
138#define DMILCAP 0x084 /* 32bit */
139#define DMILCTL 0x088 /* 16bit */
140#define DMILSTS 0x08a /* 16bit */
Patrick Rudolphbf743502019-03-25 17:05:20 +0100141#define TXTRN (1 << 11)
Stefan Reinauer00636b02012-04-04 00:08:51 +0200142
Angel Ponsf950a7e2020-09-14 17:15:37 +0200143#define DMILCTL2 0x098 /* 16bit */
144#define DMILSTS2 0x09a /* 16bit */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200145
Angel Ponsf950a7e2020-09-14 17:15:37 +0200146#define DMIUESTS 0x1c4 /* 32bit */
147#define DMICESTS 0x1d0 /* 32bit */
148
149#define DMIL0SLAT 0x22c /* 32bit */
150#define DMILLTC 0x238 /* 32bit */
Stefan Reinauer00636b02012-04-04 00:08:51 +0200151
152#ifndef __ASSEMBLER__
Stefan Reinauer00636b02012-04-04 00:08:51 +0200153
Stefan Reinauer00636b02012-04-04 00:08:51 +0200154void intel_sandybridge_finalize_smm(void);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200155int bridge_silicon_revision(void);
Patrick Rudolph2cdb65d2019-03-24 18:08:43 +0100156void systemagent_early_init(void);
Nico Huberbb9469c2015-10-21 11:49:23 +0200157void sandybridge_init_iommu(void);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200158void sandybridge_late_initialization(void);
Vladimir Serbinenkoc845b432014-09-05 03:37:44 +0200159void northbridge_romstage_finalize(int s3resume);
Patrick Rudolph6aca7e62019-03-26 18:22:36 +0100160void early_init_dmi(void);
Stefan Reinauer00636b02012-04-04 00:08:51 +0200161
Angel Pons7c49cb82020-03-16 23:17:32 +0100162/* mainboard_early_init: Optional callback, run after console init but before raminit. */
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100163void mainboard_early_init(int s3resume);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100164int mainboard_should_reset_usb(int s3resume);
165void perform_raminit(int s3resume);
Angel Pons064c7992020-03-17 23:09:16 +0100166void report_memory_config(void);
Patrick Rudolph74203de2017-11-20 11:57:01 +0100167enum platform_type get_platform_type(void);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100168
Angel Pons8bf19762020-08-03 14:55:18 +0200169int decode_pcie_bar(u32 *const base, u32 *const len);
170
Nico Huber9d9ce0d2015-10-26 12:59:49 +0100171#include <device/device.h>
172
173struct acpi_rsdp;
Furquan Shaikh0f007d82020-04-24 06:41:18 -0700174unsigned long northbridge_write_acpi_tables(const struct device *device, unsigned long start,
Angel Pons7c49cb82020-03-16 23:17:32 +0100175 struct acpi_rsdp *rsdp);
Nico Huber9d9ce0d2015-10-26 12:59:49 +0100176
Stefan Reinauer00636b02012-04-04 00:08:51 +0200177#endif
178#endif
Edward O'Callaghan089a5102015-01-06 02:48:57 +1100179#endif /* __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ */