Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 2 | |
| 3 | #ifndef __NORTHBRIDGE_INTEL_X4X_H__ |
| 4 | #define __NORTHBRIDGE_INTEL_X4X_H__ |
| 5 | |
Arthur Heymans | dc972e1 | 2019-11-12 08:35:05 +0100 | [diff] [blame] | 6 | #include <stdint.h> |
Angel Pons | 2a8ceef | 2020-09-15 12:23:45 +0200 | [diff] [blame] | 7 | #include "memmap.h" |
Arthur Heymans | 6190d0b | 2019-11-01 18:34:45 +0100 | [diff] [blame] | 8 | |
Angel Pons | 41e66ac | 2020-09-15 13:17:23 +0200 | [diff] [blame^] | 9 | #define BOOT_PATH_NORMAL 0 |
| 10 | #define BOOT_PATH_WARM_RESET 1 |
| 11 | #define BOOT_PATH_RESUME 2 |
| 12 | |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 13 | /* |
| 14 | * D0:F0 |
| 15 | */ |
Angel Pons | d1c590a | 2020-08-03 16:01:39 +0200 | [diff] [blame] | 16 | #define HOST_BRIDGE PCI_DEV(0, 0, 0) |
| 17 | |
Angel Pons | fd19075 | 2020-09-15 12:38:17 +0200 | [diff] [blame] | 18 | #include "registers/host_bridge.h" |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 19 | |
| 20 | /* |
| 21 | * D1:F0 PEG |
| 22 | */ |
Angel Pons | 6fd9adb | 2020-09-15 12:34:36 +0200 | [diff] [blame] | 23 | #define PEG_CAP 0xa2 |
| 24 | #define SLOTCAP 0xb4 |
| 25 | #define PEGLC 0xec |
| 26 | #define D1F0_VCCAP 0x104 |
| 27 | #define D1F0_VC0RCTL 0x114 |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 28 | |
| 29 | /* |
| 30 | * Graphics frequencies |
| 31 | */ |
| 32 | #define GCFGC_PCIDEV PCI_DEV(0, 2, 0) |
| 33 | #define GCFGC_OFFSET 0xf0 |
| 34 | #define GCFGC_CR_SHIFT 0 |
| 35 | #define GCFGC_CR_MASK (0xf << GCFGC_CR_SHIFT) |
| 36 | #define GCFGC_CS_SHIFT 8 |
| 37 | #define GCFGC_CS_MASK (0xf << GCFGC_CS_SHIFT) |
| 38 | #define GCFGC_CD_SHIFT 12 |
| 39 | #define GCFGC_CD_MASK (0x1 << GCFGC_CD_SHIFT) |
| 40 | #define GCFGC_UPDATE_SHIFT 5 |
| 41 | #define GCFGC_UPDATE (0x1 << GCFGC_UPDATE_SHIFT) |
| 42 | |
| 43 | /* |
| 44 | * MCHBAR |
| 45 | */ |
| 46 | |
Angel Pons | 6fd9adb | 2020-09-15 12:34:36 +0200 | [diff] [blame] | 47 | #define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x)))) |
Arthur Heymans | 70a1dda | 2017-03-09 01:58:24 +0100 | [diff] [blame] | 48 | #define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x)))) |
| 49 | #define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + (x)))) |
Angel Pons | 6fd9adb | 2020-09-15 12:34:36 +0200 | [diff] [blame] | 50 | #define MCHBAR8_AND(x, and) (MCHBAR8(x) = MCHBAR8(x) & (and)) |
Felix Held | 6cd2c2f | 2018-07-29 18:04:14 +0200 | [diff] [blame] | 51 | #define MCHBAR16_AND(x, and) (MCHBAR16(x) = MCHBAR16(x) & (and)) |
Felix Held | 6cd2c2f | 2018-07-29 18:04:14 +0200 | [diff] [blame] | 52 | #define MCHBAR32_AND(x, and) (MCHBAR32(x) = MCHBAR32(x) & (and)) |
Angel Pons | 6fd9adb | 2020-09-15 12:34:36 +0200 | [diff] [blame] | 53 | #define MCHBAR8_OR(x, or) (MCHBAR8(x) = MCHBAR8(x) | (or)) |
| 54 | #define MCHBAR16_OR(x, or) (MCHBAR16(x) = MCHBAR16(x) | (or)) |
Felix Held | 6cd2c2f | 2018-07-29 18:04:14 +0200 | [diff] [blame] | 55 | #define MCHBAR32_OR(x, or) (MCHBAR32(x) = MCHBAR32(x) | (or)) |
Angel Pons | 6fd9adb | 2020-09-15 12:34:36 +0200 | [diff] [blame] | 56 | #define MCHBAR8_AND_OR(x, and, or) (MCHBAR8(x) = (MCHBAR8(x) & (and)) | (or)) |
| 57 | #define MCHBAR16_AND_OR(x, and, or) (MCHBAR16(x) = (MCHBAR16(x) & (and)) | (or)) |
| 58 | #define MCHBAR32_AND_OR(x, and, or) (MCHBAR32(x) = (MCHBAR32(x) & (and)) | (or)) |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 59 | |
Arthur Heymans | 1994e448 | 2017-11-04 07:52:23 +0100 | [diff] [blame] | 60 | #define CHDECMISC 0x111 |
| 61 | #define STACKED_MEM (1 << 1) |
| 62 | |
| 63 | #define C0DRB0 0x200 |
| 64 | #define C0DRB1 0x202 |
| 65 | #define C0DRB2 0x204 |
| 66 | #define C0DRB3 0x206 |
| 67 | #define C0DRA01 0x208 |
| 68 | #define C0DRA23 0x20a |
| 69 | #define C0CKECTRL 0x260 |
| 70 | |
| 71 | #define C1DRB0 0x600 |
| 72 | #define C1DRB1 0x602 |
| 73 | #define C1DRB2 0x604 |
| 74 | #define C1DRB3 0x606 |
| 75 | #define C1DRA01 0x608 |
| 76 | #define C1DRA23 0x60a |
| 77 | #define C1CKECTRL 0x660 |
| 78 | |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 79 | #define PMSTS_MCHBAR 0x0f14 /* Self refresh channel status */ |
Arthur Heymans | 97e13d8 | 2016-11-30 18:40:38 +0100 | [diff] [blame] | 80 | #define PMSTS_WARM_RESET (1 << 8) |
| 81 | #define PMSTS_BOTH_SELFREFRESH (3 << 0) |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 82 | |
| 83 | #define CLKCFG_MCHBAR 0x0c00 |
| 84 | #define CLKCFG_FSBCLK_SHIFT 0 |
| 85 | #define CLKCFG_FSBCLK_MASK (7 << CLKCFG_FSBCLK_SHIFT) |
| 86 | #define CLKCFG_MEMCLK_SHIFT 4 |
| 87 | #define CLKCFG_MEMCLK_MASK (7 << CLKCFG_MEMCLK_SHIFT) |
| 88 | #define CLKCFG_UPDATE (1 << 12) |
| 89 | |
Arthur Heymans | 5b30b82 | 2016-12-01 18:41:50 +0100 | [diff] [blame] | 90 | #define SSKPD_MCHBAR 0x0c20 /* 64 bit */ |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 91 | |
| 92 | /* |
| 93 | * DMIBAR |
| 94 | */ |
| 95 | |
Angel Pons | 6fd9adb | 2020-09-15 12:34:36 +0200 | [diff] [blame] | 96 | #define DMIBAR8(x) (*((volatile u8 *)(DEFAULT_DMIBAR + (x)))) |
Arthur Heymans | 70a1dda | 2017-03-09 01:58:24 +0100 | [diff] [blame] | 97 | #define DMIBAR16(x) (*((volatile u16 *)(DEFAULT_DMIBAR + (x)))) |
| 98 | #define DMIBAR32(x) (*((volatile u32 *)(DEFAULT_DMIBAR + (x)))) |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 99 | |
Angel Pons | a5314b6 | 2020-09-15 13:08:26 +0200 | [diff] [blame] | 100 | #define DMIVCECH 0x000 /* 32bit */ |
| 101 | #define DMIPVCCAP1 0x004 /* 32bit */ |
| 102 | |
| 103 | #define DMIVC0RCAP 0x010 /* 32bit */ |
| 104 | #define DMIVC0RCTL 0x014 /* 32bit */ |
| 105 | #define DMIVC0RSTS 0x01a /* 16bit */ |
| 106 | #define VC0NP (1 << 1) |
| 107 | |
| 108 | #define DMIVC1RCAP 0x01c /* 32bit */ |
| 109 | #define DMIVC1RCTL 0x020 /* 32bit */ |
| 110 | #define DMIVC1RSTS 0x026 /* 16bit */ |
| 111 | #define VC1NP (1 << 1) |
| 112 | |
| 113 | #define DMIVCPRCAP 0x028 /* 32bit */ |
| 114 | #define DMIVCPRCTL 0x02c /* 32bit */ |
| 115 | #define DMIVCPRSTS 0x032 /* 16bit */ |
| 116 | #define VCPNP (1 << 1) |
| 117 | |
| 118 | #define DMIVCMRCAP 0x034 /* 32bit */ |
| 119 | #define DMIVCMRCTL 0x038 /* 32bit */ |
| 120 | #define DMIVCMRSTS 0x03e /* 16bit */ |
| 121 | #define VCMNP (1 << 1) |
| 122 | |
| 123 | #define DMIESD 0x044 /* 32bit */ |
| 124 | |
| 125 | #define DMILE1D 0x050 /* 32bit */ |
| 126 | #define DMILE1A 0x058 /* 64bit */ |
| 127 | #define DMILE2D 0x060 /* 32bit */ |
| 128 | #define DMILE2A 0x068 /* 64bit */ |
| 129 | |
| 130 | #define DMILCAP 0x084 /* 32bit */ |
| 131 | #define DMILCTL 0x088 /* 16bit */ |
| 132 | #define DMILSTS 0x08a /* 16bit */ |
| 133 | |
| 134 | #define DMIUESTS 0x1c4 /* 32bit */ |
| 135 | #define DMICESTS 0x1d0 /* 32bit */ |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 136 | |
| 137 | /* |
| 138 | * EPBAR |
| 139 | */ |
| 140 | |
Angel Pons | 6fd9adb | 2020-09-15 12:34:36 +0200 | [diff] [blame] | 141 | #define EPBAR8(x) (*((volatile u8 *)(DEFAULT_EPBAR + (x)))) |
Arthur Heymans | 70a1dda | 2017-03-09 01:58:24 +0100 | [diff] [blame] | 142 | #define EPBAR16(x) (*((volatile u16 *)(DEFAULT_EPBAR + (x)))) |
| 143 | #define EPBAR32(x) (*((volatile u32 *)(DEFAULT_EPBAR + (x)))) |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 144 | |
Angel Pons | a5314b6 | 2020-09-15 13:08:26 +0200 | [diff] [blame] | 145 | #define EPPVCCAP1 0x004 /* 32bit */ |
| 146 | #define EPPVCCTL 0x00c /* 32bit */ |
| 147 | |
| 148 | #define EPVC0RCAP 0x010 /* 32bit */ |
| 149 | #define EPVC0RCTL 0x014 /* 32bit */ |
| 150 | #define EPVC0RSTS 0x01a /* 16bit */ |
| 151 | |
| 152 | #define EPVC1RCAP 0x01c /* 32bit */ |
| 153 | #define EPVC1RCTL 0x020 /* 32bit */ |
| 154 | #define EPVC1RSTS 0x026 /* 16bit */ |
| 155 | |
| 156 | #define EPVC1MTS 0x028 /* 32bit */ |
| 157 | #define EPVC1ITC 0x02c /* 32bit */ |
| 158 | |
| 159 | #define EPESD 0x044 /* 32bit */ |
| 160 | |
| 161 | #define EPLE1D 0x050 /* 32bit */ |
| 162 | #define EPLE1A 0x058 /* 64bit */ |
| 163 | #define EPLE2D 0x060 /* 32bit */ |
| 164 | #define EPLE2A 0x068 /* 64bit */ |
| 165 | |
| 166 | #define EP_PORTARB(x) (0x100 + 4 * (x)) /* 256bit */ |
| 167 | |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 168 | void x4x_early_init(void); |
Arthur Heymans | ef7e98a | 2016-12-30 21:07:18 +0100 | [diff] [blame] | 169 | void x4x_late_init(int s3resume); |
Arthur Heymans | bf53acc | 2019-11-11 21:14:39 +0100 | [diff] [blame] | 170 | void mb_get_spd_map(u8 spd_map[4]); |
| 171 | void mb_pre_raminit_setup(int s3_resume); |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 172 | u32 decode_igd_memory_size(u32 gms); |
| 173 | u32 decode_igd_gtt_size(u32 gsm); |
Arthur Heymans | 4c65bfc | 2018-04-10 13:34:24 +0200 | [diff] [blame] | 174 | u32 decode_tseg_size(const u32 esmramc); |
Angel Pons | ecec947 | 2020-08-03 15:44:27 +0200 | [diff] [blame] | 175 | int decode_pcie_bar(u32 *const base, u32 *const len); |
Arthur Heymans | 0bf87de | 2017-11-04 06:15:05 +0100 | [diff] [blame] | 176 | |
Kyösti Mälkki | d7205be | 2019-09-27 07:24:17 +0300 | [diff] [blame] | 177 | #include <device/device.h> |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 178 | struct acpi_rsdp; |
Furquan Shaikh | 0f007d8 | 2020-04-24 06:41:18 -0700 | [diff] [blame] | 179 | unsigned long northbridge_write_acpi_tables(const struct device *device, |
Elyes HAOUAS | fea02e1 | 2018-02-08 14:59:03 +0100 | [diff] [blame] | 180 | unsigned long start, struct acpi_rsdp *rsdp); |
Kyösti Mälkki | d7205be | 2019-09-27 07:24:17 +0300 | [diff] [blame] | 181 | |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 182 | #endif /* __NORTHBRIDGE_INTEL_X4X_H__ */ |