Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 2 | |
| 3 | #ifndef NORTHBRIDGE_INTEL_PINEVIEW_H |
| 4 | #define NORTHBRIDGE_INTEL_PINEVIEW_H |
| 5 | |
| 6 | #include <northbridge/intel/pineview/iomap.h> |
| 7 | #include <southbridge/intel/i82801gx/i82801gx.h> |
| 8 | |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 9 | #define BOOT_PATH_NORMAL 0 |
| 10 | #define BOOT_PATH_RESET 1 |
| 11 | #define BOOT_PATH_RESUME 2 |
| 12 | |
| 13 | #define SYSINFO_DIMM_NOT_POPULATED 0x00 |
| 14 | #define SYSINFO_DIMM_X16SS 0x01 |
| 15 | #define SYSINFO_DIMM_X16DS 0x02 |
| 16 | #define SYSINFO_DIMM_X8DS 0x05 |
| 17 | #define SYSINFO_DIMM_X8DDS 0x06 |
| 18 | |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 19 | /* Device 0:0.0 PCI configuration space (Host Bridge) */ |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 20 | #define HOST_BRIDGE PCI_DEV(0, 0, 0) |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 21 | |
| 22 | #define EPBAR 0x40 |
| 23 | #define MCHBAR 0x48 |
| 24 | #define PCIEXBAR 0x60 |
| 25 | #define DMIBAR 0x68 |
| 26 | #define PMIOBAR 0x78 |
| 27 | |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 28 | #define GGC 0x52 /* GMCH Graphics Control */ |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 29 | |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 30 | #define DEVEN 0x54 /* Device Enable */ |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 31 | #define DEVEN_D0F0 (1 << 0) |
| 32 | #define DEVEN_D1F0 (1 << 1) |
| 33 | #define DEVEN_D2F0 (1 << 3) |
| 34 | #define DEVEN_D2F1 (1 << 4) |
| 35 | |
| 36 | #ifndef BOARD_DEVEN |
| 37 | #define BOARD_DEVEN ( DEVEN_D0F0 | DEVEN_D2F0 | DEVEN_D2F1 ) |
| 38 | #endif /* BOARD_DEVEN */ |
| 39 | |
| 40 | #define PAM0 0x90 |
| 41 | #define PAM1 0x91 |
| 42 | #define PAM2 0x92 |
| 43 | #define PAM3 0x93 |
| 44 | #define PAM4 0x94 |
| 45 | #define PAM5 0x95 |
| 46 | #define PAM6 0x96 |
| 47 | |
| 48 | #define LAC 0x97 /* Legacy Access Control */ |
| 49 | #define REMAPBASE 0x98 |
| 50 | #define REMAPLIMIT 0x9a |
| 51 | #define SMRAM 0x9d /* System Management RAM Control */ |
Arthur Heymans | 4bdfebd | 2018-04-09 22:10:33 +0200 | [diff] [blame] | 52 | #define ESMRAMC 0x9e /* Extended System Management RAM Control */ |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 53 | |
| 54 | #define TOM 0xa0 |
| 55 | #define TOUUD 0xa2 |
| 56 | #define GBSM 0xa4 |
| 57 | #define BGSM 0xa8 |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 58 | #define TSEG 0xac |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 59 | #define TOLUD 0xb0 /* Top of Low Used Memory */ |
| 60 | #define ERRSTS 0xc8 |
| 61 | #define ERRCMD 0xca |
| 62 | #define SMICMD 0xcc |
| 63 | #define SCICMD 0xce |
| 64 | #define CGDIS 0xd8 |
| 65 | #define SKPAD 0xdc /* Scratchpad Data */ |
| 66 | #define CAPID0 0xe0 |
| 67 | #define DEV0T 0xf0 |
| 68 | #define MSLCK 0xf4 |
| 69 | #define MID0 0xf8 |
| 70 | #define DEBUP0 0xfc |
| 71 | |
| 72 | /* Device 0:1.0 PCI configuration space (PCI Express) */ |
| 73 | |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 74 | #define PEGSTS 0x214 /* 32 bits */ |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 75 | |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 76 | /* Device 0:2.0 PCI configuration space (Integrated Graphics Device) */ |
| 77 | #define GMCH_IGD PCI_DEV(0, 2, 0) |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 78 | |
| 79 | #define GMADR 0x18 |
| 80 | #define GTTADR 0x1c |
| 81 | #define BSM 0x5c |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 82 | |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 83 | #define GPIO32(x) *((volatile u32 *)(DEFAULT_GPIOBASE + x)) |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 84 | |
| 85 | /* |
| 86 | * MCHBAR |
| 87 | */ |
| 88 | |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 89 | #define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x)))) |
| 90 | #define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x)))) |
| 91 | #define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + x))) /* FIXME: causes changes */ |
| 92 | #define MCHBAR8_AND(x, and) (MCHBAR8(x) = MCHBAR8(x) & (and)) |
| 93 | #define MCHBAR16_AND(x, and) (MCHBAR16(x) = MCHBAR16(x) & (and)) |
| 94 | #define MCHBAR32_AND(x, and) (MCHBAR32(x) = MCHBAR32(x) & (and)) |
| 95 | #define MCHBAR8_OR(x, or) (MCHBAR8(x) = MCHBAR8(x) | (or)) |
| 96 | #define MCHBAR16_OR(x, or) (MCHBAR16(x) = MCHBAR16(x) | (or)) |
| 97 | #define MCHBAR32_OR(x, or) (MCHBAR32(x) = MCHBAR32(x) | (or)) |
| 98 | #define MCHBAR8_AND_OR(x, and, or) (MCHBAR8(x) = (MCHBAR8(x) & (and)) | (or)) |
| 99 | #define MCHBAR16_AND_OR(x, and, or) (MCHBAR16(x) = (MCHBAR16(x) & (and)) | (or)) |
| 100 | #define MCHBAR32_AND_OR(x, and, or) (MCHBAR32(x) = (MCHBAR32(x) & (and)) | (or)) |
| 101 | |
| 102 | /* As there are many registers, define them on a separate file */ |
| 103 | |
| 104 | #include "mchbar_regs.h" |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 105 | |
| 106 | /* |
| 107 | * EPBAR - Egress Port Root Complex Register Block |
| 108 | */ |
| 109 | |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 110 | #define EPBAR8(x) *((volatile u8 *)(DEFAULT_EPBAR + x)) |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 111 | #define EPBAR16(x) *((volatile u16 *)(DEFAULT_EPBAR + x)) |
| 112 | #define EPBAR32(x) *((volatile u32 *)(DEFAULT_EPBAR + x)) |
| 113 | |
| 114 | /* |
| 115 | * DMIBAR |
| 116 | */ |
| 117 | |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 118 | #define DMIBAR8(x) *((volatile u8 *)(DEFAULT_DMIBAR + x)) |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 119 | #define DMIBAR16(x) *((volatile u16 *)(DEFAULT_DMIBAR + x)) |
| 120 | #define DMIBAR32(x) *((volatile u32 *)(DEFAULT_DMIBAR + x)) |
| 121 | |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 122 | enum fsb_clk { |
| 123 | FSB_CLOCK_667MHz = 0, |
| 124 | FSB_CLOCK_800MHz = 1, |
| 125 | }; |
| 126 | |
| 127 | enum mem_clk { |
| 128 | MEM_CLOCK_667MHz = 0, |
| 129 | MEM_CLOCK_800MHz = 1, |
| 130 | }; |
| 131 | |
| 132 | enum ddr { |
| 133 | DDR2 = 2, |
| 134 | DDR3 = 3, |
| 135 | }; |
| 136 | |
| 137 | enum chip_width { /* as in DDR3 spd */ |
| 138 | CHIP_WIDTH_x4 = 0, |
| 139 | CHIP_WIDTH_x8 = 1, |
| 140 | CHIP_WIDTH_x16 = 2, |
| 141 | CHIP_WIDTH_x32 = 3, |
| 142 | }; |
| 143 | |
| 144 | enum chip_cap { /* as in DDR3 spd */ |
| 145 | CHIP_CAP_256M = 0, |
| 146 | CHIP_CAP_512M = 1, |
| 147 | CHIP_CAP_1G = 2, |
| 148 | CHIP_CAP_2G = 3, |
| 149 | CHIP_CAP_4G = 4, |
| 150 | CHIP_CAP_8G = 5, |
| 151 | CHIP_CAP_16G = 6, |
| 152 | }; |
| 153 | |
| 154 | struct timings { |
| 155 | unsigned int CAS; |
| 156 | enum fsb_clk fsb_clock; |
| 157 | enum mem_clk mem_clock; |
| 158 | unsigned int tRAS; |
| 159 | unsigned int tRP; |
| 160 | unsigned int tRCD; |
| 161 | unsigned int tWR; |
| 162 | unsigned int tRFC; |
| 163 | unsigned int tWTR; |
| 164 | unsigned int tRRD; |
| 165 | unsigned int tRTP; |
| 166 | }; |
| 167 | |
| 168 | struct dimminfo { |
| 169 | unsigned int card_type; /* 0x0: unpopulated, |
| 170 | 0xa - 0xf: raw card type A - F */ |
| 171 | u8 type; |
| 172 | enum chip_width width; |
| 173 | enum chip_cap chip_capacity; |
| 174 | unsigned int page_size; /* of whole DIMM in Bytes (4096 or 8192) */ |
| 175 | unsigned int sides; |
| 176 | unsigned int banks; |
| 177 | unsigned int ranks; |
| 178 | unsigned int rows; |
| 179 | unsigned int cols; |
| 180 | unsigned int cas_latencies; |
| 181 | unsigned int tAAmin; |
| 182 | unsigned int tCKmin; |
| 183 | unsigned int tWR; |
| 184 | unsigned int tRP; |
| 185 | unsigned int tRCD; |
| 186 | unsigned int tRAS; |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 187 | unsigned int rank_capacity_mb; /* per rank in Megabytes */ |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 188 | u8 spd_data[256]; |
| 189 | }; |
| 190 | |
| 191 | struct pllparam { |
| 192 | u8 kcoarse[2][72]; |
| 193 | u8 pi[2][72]; |
| 194 | u8 dben[2][72]; |
| 195 | u8 dbsel[2][72]; |
| 196 | u8 clkdelay[2][72]; |
| 197 | }; |
| 198 | |
| 199 | struct sysinfo { |
| 200 | u8 maxpi; |
| 201 | u8 pioffset; |
| 202 | u8 pi[8]; |
| 203 | u16 coarsectrl; |
| 204 | u16 coarsedelay; |
| 205 | u16 mediumphase; |
| 206 | u16 readptrdelay; |
| 207 | |
| 208 | int txt_enabled; |
| 209 | int cores; |
| 210 | int boot_path; |
| 211 | int max_ddr2_mhz; |
| 212 | int max_ddr3_mt; |
| 213 | int max_fsb_mhz; |
| 214 | int max_render_mhz; |
| 215 | int enable_igd; |
| 216 | int enable_peg; |
| 217 | u16 ggc; |
| 218 | |
| 219 | int dimm_config[2]; |
| 220 | int dimms_per_ch; |
| 221 | int spd_type; |
| 222 | int channel_capacity[2]; |
| 223 | struct timings selected_timings; |
| 224 | struct dimminfo dimms[4]; |
| 225 | u8 spd_map[4]; |
| 226 | |
| 227 | u8 nodll; |
| 228 | u8 async; |
| 229 | u8 dt0mode; |
| 230 | u8 mvco4x; /* 0 (8x) or 1 (4x) */ |
| 231 | }; |
| 232 | |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 233 | void pineview_early_init(void); |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 234 | u32 decode_igd_memory_size(const u32 gms); |
| 235 | u32 decode_igd_gtt_size(const u32 gsm); |
| 236 | u8 decode_pciebar(u32 *const base, u32 *const len); |
| 237 | |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 238 | /* Mainboard romstage callback functions */ |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 239 | void get_mb_spd_addrmap(u8 *spd_addr_map); |
| 240 | void mb_pirq_setup(void); /* optional */ |
| 241 | |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 242 | struct acpi_rsdp; |
| 243 | unsigned long northbridge_write_acpi_tables(unsigned long start, struct acpi_rsdp *rsdp); |
| 244 | |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 245 | #endif /* NORTHBRIDGE_INTEL_PINEVIEW_H */ |