Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; version 2 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #ifndef __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ |
Edward O'Callaghan | 089a510 | 2015-01-06 02:48:57 +1100 | [diff] [blame] | 16 | #define __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 17 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 18 | /* Device ID for SandyBridge and IvyBridge */ |
| 19 | #define BASE_REV_SNB 0x00 |
| 20 | #define BASE_REV_IVB 0x50 |
| 21 | #define BASE_REV_MASK 0x50 |
| 22 | |
| 23 | /* SandyBridge CPU stepping */ |
| 24 | #define SNB_STEP_D0 (BASE_REV_SNB + 5) /* Also J0 */ |
| 25 | #define SNB_STEP_D1 (BASE_REV_SNB + 6) |
| 26 | #define SNB_STEP_D2 (BASE_REV_SNB + 7) /* Also J1/Q0 */ |
| 27 | |
| 28 | /* IvyBridge CPU stepping */ |
| 29 | #define IVB_STEP_A0 (BASE_REV_IVB + 0) |
| 30 | #define IVB_STEP_B0 (BASE_REV_IVB + 2) |
| 31 | #define IVB_STEP_C0 (BASE_REV_IVB + 4) |
| 32 | #define IVB_STEP_K0 (BASE_REV_IVB + 5) |
| 33 | #define IVB_STEP_D0 (BASE_REV_IVB + 6) |
| 34 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 35 | /* Northbridge BARs */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 36 | #ifndef __ACPI__ |
| 37 | #define DEFAULT_MCHBAR ((u8 *)0xfed10000) /* 16 KB */ |
| 38 | #define DEFAULT_DMIBAR ((u8 *)0xfed18000) /* 4 KB */ |
| 39 | #else |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 40 | #define DEFAULT_MCHBAR 0xfed10000 /* 16 KB */ |
| 41 | #define DEFAULT_DMIBAR 0xfed18000 /* 4 KB */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 42 | #endif |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 43 | #define DEFAULT_EPBAR 0xfed19000 /* 4 KB */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 44 | #define DEFAULT_RCBABASE ((u8 *)0xfed1c000) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 45 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 46 | #define GFXVT_BASE 0xfed90000ULL |
| 47 | #define VTVC0_BASE 0xfed91000ULL |
Nico Huber | bb9469c | 2015-10-21 11:49:23 +0200 | [diff] [blame] | 48 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 49 | /* Everything below this line is ignored in the DSDT */ |
| 50 | #ifndef __ACPI__ |
Patrick Rudolph | 74203de | 2017-11-20 11:57:01 +0100 | [diff] [blame] | 51 | #include <cpu/intel/model_206ax/model_206ax.h> |
| 52 | |
| 53 | /* Chipset types */ |
| 54 | enum platform_type { |
| 55 | PLATFORM_MOBILE = 0, |
| 56 | PLATFORM_DESKTOP_SERVER, |
| 57 | }; |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 58 | |
Nico Huber | 9d9ce0d | 2015-10-26 12:59:49 +0100 | [diff] [blame] | 59 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 60 | /* Device 0:0.0 PCI configuration space (Host Bridge) */ |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 61 | #define HOST_BRIDGE PCI_DEV(0, 0, 0) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 62 | |
| 63 | #define EPBAR 0x40 |
| 64 | #define MCHBAR 0x48 |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 65 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 66 | #define GGC 0x50 /* GMCH Graphics Control */ |
| 67 | #define DEVEN 0x54 /* Device Enable */ |
Patrick Rudolph | ecd4be8 | 2017-05-14 12:40:50 +0200 | [diff] [blame] | 68 | #define DEVEN_D7EN (1 << 14) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 69 | #define DEVEN_PEG60 (1 << 13) |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 70 | #define DEVEN_D4EN (1 << 7) |
| 71 | #define DEVEN_IGD (1 << 4) |
| 72 | #define DEVEN_PEG10 (1 << 3) |
| 73 | #define DEVEN_PEG11 (1 << 2) |
| 74 | #define DEVEN_PEG12 (1 << 1) |
| 75 | #define DEVEN_HOST (1 << 0) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 76 | |
Felix Held | 4902fee | 2019-12-28 18:09:47 +0100 | [diff] [blame] | 77 | #define PAVPC 0x58 /* Protected Audio Video Path Control */ |
| 78 | #define DPR 0x5c /* DMA Protected Range */ |
| 79 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 80 | #define PCIEXBAR 0x60 |
| 81 | #define DMIBAR 0x68 |
| 82 | |
Felix Held | 651f99f | 2019-12-30 16:28:48 +0100 | [diff] [blame] | 83 | #define MESEG_BASE 0x70 |
| 84 | #define MESEG_MASK 0x78 |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 85 | #define MELCK (1 << 10) /* ME Range Lock */ |
| 86 | #define ME_STLEN_EN (1 << 11) /* ME Stolen Memory Enable */ |
Felix Held | bc3668a | 2019-12-28 18:44:06 +0100 | [diff] [blame] | 87 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 88 | #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 Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 98 | |
Felix Held | 4902fee | 2019-12-28 18:09:47 +0100 | [diff] [blame] | 99 | #define REMAPBASE 0x90 |
| 100 | #define REMAPLIMIT 0x98 |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 101 | #define TOM 0xa0 |
| 102 | #define TOUUD 0xa8 /* Top of Upper Usable DRAM */ |
Felix Held | 4902fee | 2019-12-28 18:09:47 +0100 | [diff] [blame] | 103 | #define BDSM 0xb0 /* Base Data of Stolen Memory */ |
Vladimir Serbinenko | a3e41c0 | 2015-05-28 16:04:17 +0200 | [diff] [blame] | 104 | #define BGSM 0xb4 /* Base GTT Stolen Memory */ |
Felix Held | 4902fee | 2019-12-28 18:09:47 +0100 | [diff] [blame] | 105 | #define TSEGMB 0xb8 /* TSEG Memory Base */ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 106 | #define TOLUD 0xbc /* Top of Low Used Memory */ |
| 107 | |
Patrick Rudolph | 9f3f915 | 2016-01-26 20:02:14 +0100 | [diff] [blame] | 108 | #define CAPID0_A 0xe4 /* Capabilities Register A */ |
| 109 | #define CAPID0_B 0xe8 /* Capabilities Register B */ |
| 110 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 111 | #define SKPAD 0xdc /* Scratchpad Data */ |
| 112 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 113 | #define DIDOR 0xf3 /* Device ID override, for debug and samples only */ |
| 114 | |
| 115 | |
| 116 | /* Devices 0:1.0, 0:1.1, 0:1.2, 0:6.0 PCI configuration space (PCI Express Graphics) */ |
| 117 | |
| 118 | #define AFE_PWRON 0xc24 /* PEG Analog Front-End Power-On */ |
| 119 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 120 | |
| 121 | /* Device 0:2.0 PCI configuration space (Graphics Device) */ |
| 122 | |
| 123 | #define MSAC 0x62 /* Multi Size Aperture Control */ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 124 | |
| 125 | /* |
| 126 | * MCHBAR |
| 127 | */ |
| 128 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 129 | #define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x)))) |
Felix Held | b9267f0 | 2018-07-28 14:49:31 +0200 | [diff] [blame] | 130 | #define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x)))) |
| 131 | #define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + (x)))) |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 132 | #define MCHBAR8_AND(x, and) (MCHBAR8(x) = MCHBAR8(x) & (and)) |
| 133 | #define MCHBAR16_AND(x, and) (MCHBAR16(x) = MCHBAR16(x) & (and)) |
| 134 | #define MCHBAR32_AND(x, and) (MCHBAR32(x) = MCHBAR32(x) & (and)) |
| 135 | #define MCHBAR8_OR(x, or) (MCHBAR8(x) = MCHBAR8(x) | (or)) |
| 136 | #define MCHBAR16_OR(x, or) (MCHBAR16(x) = MCHBAR16(x) | (or)) |
| 137 | #define MCHBAR32_OR(x, or) (MCHBAR32(x) = MCHBAR32(x) | (or)) |
| 138 | #define MCHBAR8_AND_OR(x, and, or) (MCHBAR8(x) = (MCHBAR8(x) & (and)) | (or)) |
| 139 | #define MCHBAR16_AND_OR(x, and, or) (MCHBAR16(x) = (MCHBAR16(x) & (and)) | (or)) |
Angel Pons | 26be0bd | 2019-12-31 14:29:48 +0100 | [diff] [blame] | 140 | #define MCHBAR32_AND_OR(x, and, or) (MCHBAR32(x) = (MCHBAR32(x) & (and)) | (or)) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 141 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 142 | /* As there are many registers, define them on a separate file */ |
| 143 | #include "mchbar_regs.h" |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 144 | |
| 145 | /* |
| 146 | * EPBAR - Egress Port Root Complex Register Block |
| 147 | */ |
| 148 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 149 | #define EPBAR8(x) (*((volatile u8 *)(DEFAULT_EPBAR + (x)))) |
Felix Held | b9267f0 | 2018-07-28 14:49:31 +0200 | [diff] [blame] | 150 | #define EPBAR16(x) (*((volatile u16 *)(DEFAULT_EPBAR + (x)))) |
| 151 | #define EPBAR32(x) (*((volatile u32 *)(DEFAULT_EPBAR + (x)))) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 152 | |
| 153 | #define EPPVCCAP1 0x004 /* 32bit */ |
| 154 | #define EPPVCCAP2 0x008 /* 32bit */ |
| 155 | |
| 156 | #define EPVC0RCAP 0x010 /* 32bit */ |
| 157 | #define EPVC0RCTL 0x014 /* 32bit */ |
| 158 | #define EPVC0RSTS 0x01a /* 16bit */ |
| 159 | |
| 160 | #define EPVC1RCAP 0x01c /* 32bit */ |
| 161 | #define EPVC1RCTL 0x020 /* 32bit */ |
| 162 | #define EPVC1RSTS 0x026 /* 16bit */ |
| 163 | |
| 164 | #define EPVC1MTS 0x028 /* 32bit */ |
| 165 | #define EPVC1IST 0x038 /* 64bit */ |
| 166 | |
| 167 | #define EPESD 0x044 /* 32bit */ |
| 168 | |
| 169 | #define EPLE1D 0x050 /* 32bit */ |
| 170 | #define EPLE1A 0x058 /* 64bit */ |
| 171 | #define EPLE2D 0x060 /* 32bit */ |
| 172 | #define EPLE2A 0x068 /* 64bit */ |
| 173 | |
| 174 | #define PORTARB 0x100 /* 256bit */ |
| 175 | |
| 176 | /* |
| 177 | * DMIBAR |
| 178 | */ |
| 179 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 180 | #define DMIBAR8(x) (*((volatile u8 *)(DEFAULT_DMIBAR + (x)))) |
Felix Held | b9267f0 | 2018-07-28 14:49:31 +0200 | [diff] [blame] | 181 | #define DMIBAR16(x) (*((volatile u16 *)(DEFAULT_DMIBAR + (x)))) |
| 182 | #define DMIBAR32(x) (*((volatile u32 *)(DEFAULT_DMIBAR + (x)))) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 183 | |
| 184 | #define DMIVCECH 0x000 /* 32bit */ |
| 185 | #define DMIPVCCAP1 0x004 /* 32bit */ |
| 186 | #define DMIPVCCAP2 0x008 /* 32bit */ |
| 187 | |
| 188 | #define DMIPVCCCTL 0x00c /* 16bit */ |
| 189 | |
| 190 | #define DMIVC0RCAP 0x010 /* 32bit */ |
Patrick Rudolph | bf74350 | 2019-03-25 17:05:20 +0100 | [diff] [blame] | 191 | #define DMIVC0RCTL 0x014 /* 32bit */ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 192 | #define DMIVC0RSTS 0x01a /* 16bit */ |
Patrick Rudolph | bf74350 | 2019-03-25 17:05:20 +0100 | [diff] [blame] | 193 | #define VC0NP 0x2 |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 194 | |
| 195 | #define DMIVC1RCAP 0x01c /* 32bit */ |
| 196 | #define DMIVC1RCTL 0x020 /* 32bit */ |
| 197 | #define DMIVC1RSTS 0x026 /* 16bit */ |
Patrick Rudolph | bf74350 | 2019-03-25 17:05:20 +0100 | [diff] [blame] | 198 | #define VC1NP 0x2 |
| 199 | |
| 200 | #define DMIVCPRCTL 0x02c /* 32bit */ |
| 201 | |
| 202 | #define DMIVCPRSTS 0x032 /* 16bit */ |
| 203 | #define VCPNP 0x2 |
| 204 | |
| 205 | #define DMIVCMRCTL 0x0038 /* 32 bit */ |
| 206 | #define DMIVCMRSTS 0x003e /* 16 bit */ |
| 207 | #define VCMNP 0x2 |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 208 | |
| 209 | #define DMILE1D 0x050 /* 32bit */ |
| 210 | #define DMILE1A 0x058 /* 64bit */ |
| 211 | #define DMILE2D 0x060 /* 32bit */ |
| 212 | #define DMILE2A 0x068 /* 64bit */ |
| 213 | |
| 214 | #define DMILCAP 0x084 /* 32bit */ |
| 215 | #define DMILCTL 0x088 /* 16bit */ |
| 216 | #define DMILSTS 0x08a /* 16bit */ |
Patrick Rudolph | bf74350 | 2019-03-25 17:05:20 +0100 | [diff] [blame] | 217 | #define TXTRN (1 << 11) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 218 | #define DMICTL1 0x0f0 /* 32bit */ |
| 219 | #define DMICTL2 0x0fc /* 32bit */ |
| 220 | |
| 221 | #define DMICC 0x208 /* 32bit */ |
| 222 | |
| 223 | #define DMIDRCCFG 0xeb4 /* 32bit */ |
| 224 | |
| 225 | #ifndef __ASSEMBLER__ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 226 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 227 | void intel_sandybridge_finalize_smm(void); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 228 | int bridge_silicon_revision(void); |
Patrick Rudolph | 2cdb65d | 2019-03-24 18:08:43 +0100 | [diff] [blame] | 229 | void systemagent_early_init(void); |
Nico Huber | bb9469c | 2015-10-21 11:49:23 +0200 | [diff] [blame] | 230 | void sandybridge_init_iommu(void); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 231 | void sandybridge_late_initialization(void); |
Vladimir Serbinenko | c845b43 | 2014-09-05 03:37:44 +0200 | [diff] [blame] | 232 | void northbridge_romstage_finalize(int s3resume); |
Patrick Rudolph | 6aca7e6 | 2019-03-26 18:22:36 +0100 | [diff] [blame] | 233 | void early_init_dmi(void); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 234 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 235 | /* mainboard_early_init: Optional callback, run after console init but before raminit. */ |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 236 | void mainboard_early_init(int s3resume); |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 237 | int mainboard_should_reset_usb(int s3resume); |
| 238 | void perform_raminit(int s3resume); |
Angel Pons | 064c799 | 2020-03-17 23:09:16 +0100 | [diff] [blame] | 239 | void report_memory_config(void); |
Patrick Rudolph | 74203de | 2017-11-20 11:57:01 +0100 | [diff] [blame] | 240 | enum platform_type get_platform_type(void); |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 241 | |
Nico Huber | 9d9ce0d | 2015-10-26 12:59:49 +0100 | [diff] [blame] | 242 | #include <device/device.h> |
| 243 | |
| 244 | struct acpi_rsdp; |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 245 | unsigned long northbridge_write_acpi_tables(struct device *device, unsigned long start, |
| 246 | struct acpi_rsdp *rsdp); |
Nico Huber | 9d9ce0d | 2015-10-26 12:59:49 +0100 | [diff] [blame] | 247 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 248 | #endif |
| 249 | #endif |
Edward O'Callaghan | 089a510 | 2015-01-06 02:48:57 +1100 | [diff] [blame] | 250 | #endif /* __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ */ |