Angel Pons | 6e5aabd | 2020-03-23 23:44:42 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 2 | |
| 3 | #ifndef __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ |
Edward O'Callaghan | 089a510 | 2015-01-06 02:48:57 +1100 | [diff] [blame] | 4 | #define __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 5 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 6 | /* 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 Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 23 | /* Northbridge BARs */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 24 | #ifndef __ACPI__ |
| 25 | #define DEFAULT_MCHBAR ((u8 *)0xfed10000) /* 16 KB */ |
| 26 | #define DEFAULT_DMIBAR ((u8 *)0xfed18000) /* 4 KB */ |
| 27 | #else |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 28 | #define DEFAULT_MCHBAR 0xfed10000 /* 16 KB */ |
| 29 | #define DEFAULT_DMIBAR 0xfed18000 /* 4 KB */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 30 | #endif |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 31 | #define DEFAULT_EPBAR 0xfed19000 /* 4 KB */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 32 | #define DEFAULT_RCBABASE ((u8 *)0xfed1c000) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 33 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 34 | #define GFXVT_BASE 0xfed90000ULL |
| 35 | #define VTVC0_BASE 0xfed91000ULL |
Nico Huber | bb9469c | 2015-10-21 11:49:23 +0200 | [diff] [blame] | 36 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 37 | /* Everything below this line is ignored in the DSDT */ |
| 38 | #ifndef __ACPI__ |
Elyes HAOUAS | 1d6484a | 2020-07-10 11:18:11 +0200 | [diff] [blame] | 39 | #include <stdint.h> |
Patrick Rudolph | 74203de | 2017-11-20 11:57:01 +0100 | [diff] [blame] | 40 | |
| 41 | /* Chipset types */ |
| 42 | enum platform_type { |
| 43 | PLATFORM_MOBILE = 0, |
| 44 | PLATFORM_DESKTOP_SERVER, |
| 45 | }; |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 46 | |
Nico Huber | 9d9ce0d | 2015-10-26 12:59:49 +0100 | [diff] [blame] | 47 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 48 | /* Device 0:0.0 PCI configuration space (Host Bridge) */ |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 49 | #define HOST_BRIDGE PCI_DEV(0, 0, 0) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 50 | |
Angel Pons | 579e096 | 2020-07-22 11:11:50 +0200 | [diff] [blame] | 51 | #include "hostbridge_regs.h" |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 52 | |
| 53 | |
| 54 | /* Devices 0:1.0, 0:1.1, 0:1.2, 0:6.0 PCI configuration space (PCI Express Graphics) */ |
| 55 | |
| 56 | #define AFE_PWRON 0xc24 /* PEG Analog Front-End Power-On */ |
| 57 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 58 | |
| 59 | /* Device 0:2.0 PCI configuration space (Graphics Device) */ |
| 60 | |
| 61 | #define MSAC 0x62 /* Multi Size Aperture Control */ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | * MCHBAR |
| 65 | */ |
| 66 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 67 | #define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x)))) |
Felix Held | b9267f0 | 2018-07-28 14:49:31 +0200 | [diff] [blame] | 68 | #define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x)))) |
| 69 | #define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + (x)))) |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 70 | #define MCHBAR8_AND(x, and) (MCHBAR8(x) = MCHBAR8(x) & (and)) |
| 71 | #define MCHBAR16_AND(x, and) (MCHBAR16(x) = MCHBAR16(x) & (and)) |
| 72 | #define MCHBAR32_AND(x, and) (MCHBAR32(x) = MCHBAR32(x) & (and)) |
| 73 | #define MCHBAR8_OR(x, or) (MCHBAR8(x) = MCHBAR8(x) | (or)) |
| 74 | #define MCHBAR16_OR(x, or) (MCHBAR16(x) = MCHBAR16(x) | (or)) |
| 75 | #define MCHBAR32_OR(x, or) (MCHBAR32(x) = MCHBAR32(x) | (or)) |
| 76 | #define MCHBAR8_AND_OR(x, and, or) (MCHBAR8(x) = (MCHBAR8(x) & (and)) | (or)) |
| 77 | #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] | 78 | #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] | 79 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 80 | /* As there are many registers, define them on a separate file */ |
| 81 | #include "mchbar_regs.h" |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 82 | |
| 83 | /* |
| 84 | * EPBAR - Egress Port Root Complex Register Block |
| 85 | */ |
| 86 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 87 | #define EPBAR8(x) (*((volatile u8 *)(DEFAULT_EPBAR + (x)))) |
Felix Held | b9267f0 | 2018-07-28 14:49:31 +0200 | [diff] [blame] | 88 | #define EPBAR16(x) (*((volatile u16 *)(DEFAULT_EPBAR + (x)))) |
| 89 | #define EPBAR32(x) (*((volatile u32 *)(DEFAULT_EPBAR + (x)))) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 90 | |
| 91 | #define EPPVCCAP1 0x004 /* 32bit */ |
| 92 | #define EPPVCCAP2 0x008 /* 32bit */ |
| 93 | |
| 94 | #define EPVC0RCAP 0x010 /* 32bit */ |
| 95 | #define EPVC0RCTL 0x014 /* 32bit */ |
| 96 | #define EPVC0RSTS 0x01a /* 16bit */ |
| 97 | |
| 98 | #define EPVC1RCAP 0x01c /* 32bit */ |
| 99 | #define EPVC1RCTL 0x020 /* 32bit */ |
| 100 | #define EPVC1RSTS 0x026 /* 16bit */ |
| 101 | |
| 102 | #define EPVC1MTS 0x028 /* 32bit */ |
| 103 | #define EPVC1IST 0x038 /* 64bit */ |
| 104 | |
| 105 | #define EPESD 0x044 /* 32bit */ |
| 106 | |
| 107 | #define EPLE1D 0x050 /* 32bit */ |
| 108 | #define EPLE1A 0x058 /* 64bit */ |
| 109 | #define EPLE2D 0x060 /* 32bit */ |
| 110 | #define EPLE2A 0x068 /* 64bit */ |
| 111 | |
| 112 | #define PORTARB 0x100 /* 256bit */ |
| 113 | |
| 114 | /* |
| 115 | * DMIBAR |
| 116 | */ |
| 117 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 118 | #define DMIBAR8(x) (*((volatile u8 *)(DEFAULT_DMIBAR + (x)))) |
Felix Held | b9267f0 | 2018-07-28 14:49:31 +0200 | [diff] [blame] | 119 | #define DMIBAR16(x) (*((volatile u16 *)(DEFAULT_DMIBAR + (x)))) |
| 120 | #define DMIBAR32(x) (*((volatile u32 *)(DEFAULT_DMIBAR + (x)))) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 121 | |
| 122 | #define DMIVCECH 0x000 /* 32bit */ |
| 123 | #define DMIPVCCAP1 0x004 /* 32bit */ |
| 124 | #define DMIPVCCAP2 0x008 /* 32bit */ |
| 125 | |
| 126 | #define DMIPVCCCTL 0x00c /* 16bit */ |
| 127 | |
| 128 | #define DMIVC0RCAP 0x010 /* 32bit */ |
Patrick Rudolph | bf74350 | 2019-03-25 17:05:20 +0100 | [diff] [blame] | 129 | #define DMIVC0RCTL 0x014 /* 32bit */ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 130 | #define DMIVC0RSTS 0x01a /* 16bit */ |
Patrick Rudolph | bf74350 | 2019-03-25 17:05:20 +0100 | [diff] [blame] | 131 | #define VC0NP 0x2 |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 132 | |
| 133 | #define DMIVC1RCAP 0x01c /* 32bit */ |
| 134 | #define DMIVC1RCTL 0x020 /* 32bit */ |
| 135 | #define DMIVC1RSTS 0x026 /* 16bit */ |
Patrick Rudolph | bf74350 | 2019-03-25 17:05:20 +0100 | [diff] [blame] | 136 | #define VC1NP 0x2 |
| 137 | |
| 138 | #define DMIVCPRCTL 0x02c /* 32bit */ |
| 139 | |
| 140 | #define DMIVCPRSTS 0x032 /* 16bit */ |
| 141 | #define VCPNP 0x2 |
| 142 | |
| 143 | #define DMIVCMRCTL 0x0038 /* 32 bit */ |
| 144 | #define DMIVCMRSTS 0x003e /* 16 bit */ |
| 145 | #define VCMNP 0x2 |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 146 | |
| 147 | #define DMILE1D 0x050 /* 32bit */ |
| 148 | #define DMILE1A 0x058 /* 64bit */ |
| 149 | #define DMILE2D 0x060 /* 32bit */ |
| 150 | #define DMILE2A 0x068 /* 64bit */ |
| 151 | |
| 152 | #define DMILCAP 0x084 /* 32bit */ |
| 153 | #define DMILCTL 0x088 /* 16bit */ |
| 154 | #define DMILSTS 0x08a /* 16bit */ |
Patrick Rudolph | bf74350 | 2019-03-25 17:05:20 +0100 | [diff] [blame] | 155 | #define TXTRN (1 << 11) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 156 | #define DMICTL1 0x0f0 /* 32bit */ |
| 157 | #define DMICTL2 0x0fc /* 32bit */ |
| 158 | |
| 159 | #define DMICC 0x208 /* 32bit */ |
| 160 | |
| 161 | #define DMIDRCCFG 0xeb4 /* 32bit */ |
| 162 | |
| 163 | #ifndef __ASSEMBLER__ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 164 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 165 | void intel_sandybridge_finalize_smm(void); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 166 | int bridge_silicon_revision(void); |
Patrick Rudolph | 2cdb65d | 2019-03-24 18:08:43 +0100 | [diff] [blame] | 167 | void systemagent_early_init(void); |
Nico Huber | bb9469c | 2015-10-21 11:49:23 +0200 | [diff] [blame] | 168 | void sandybridge_init_iommu(void); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 169 | void sandybridge_late_initialization(void); |
Vladimir Serbinenko | c845b43 | 2014-09-05 03:37:44 +0200 | [diff] [blame] | 170 | void northbridge_romstage_finalize(int s3resume); |
Patrick Rudolph | 6aca7e6 | 2019-03-26 18:22:36 +0100 | [diff] [blame] | 171 | void early_init_dmi(void); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 172 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 173 | /* mainboard_early_init: Optional callback, run after console init but before raminit. */ |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 174 | void mainboard_early_init(int s3resume); |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 175 | int mainboard_should_reset_usb(int s3resume); |
| 176 | void perform_raminit(int s3resume); |
Angel Pons | 064c799 | 2020-03-17 23:09:16 +0100 | [diff] [blame] | 177 | void report_memory_config(void); |
Patrick Rudolph | 74203de | 2017-11-20 11:57:01 +0100 | [diff] [blame] | 178 | enum platform_type get_platform_type(void); |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 179 | |
Angel Pons | 8bf1976 | 2020-08-03 14:55:18 +0200 | [diff] [blame^] | 180 | int decode_pcie_bar(u32 *const base, u32 *const len); |
| 181 | |
Nico Huber | 9d9ce0d | 2015-10-26 12:59:49 +0100 | [diff] [blame] | 182 | #include <device/device.h> |
| 183 | |
| 184 | struct acpi_rsdp; |
Furquan Shaikh | 0f007d8 | 2020-04-24 06:41:18 -0700 | [diff] [blame] | 185 | unsigned long northbridge_write_acpi_tables(const struct device *device, unsigned long start, |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 186 | struct acpi_rsdp *rsdp); |
Nico Huber | 9d9ce0d | 2015-10-26 12:59:49 +0100 | [diff] [blame] | 187 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 188 | #endif |
| 189 | #endif |
Edward O'Callaghan | 089a510 | 2015-01-06 02:48:57 +1100 | [diff] [blame] | 190 | #endif /* __NORTHBRIDGE_INTEL_SANDYBRIDGE_SANDYBRIDGE_H__ */ |