Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2015 Damien Zammit <damien@zamaudio.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; either version 2 of |
| 9 | * the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #ifndef NORTHBRIDGE_INTEL_PINEVIEW_H |
| 18 | #define NORTHBRIDGE_INTEL_PINEVIEW_H |
| 19 | |
| 20 | #include <northbridge/intel/pineview/iomap.h> |
| 21 | #include <southbridge/intel/i82801gx/i82801gx.h> |
| 22 | |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 23 | #define BOOT_PATH_NORMAL 0 |
| 24 | #define BOOT_PATH_RESET 1 |
| 25 | #define BOOT_PATH_RESUME 2 |
| 26 | |
| 27 | #define SYSINFO_DIMM_NOT_POPULATED 0x00 |
| 28 | #define SYSINFO_DIMM_X16SS 0x01 |
| 29 | #define SYSINFO_DIMM_X16DS 0x02 |
| 30 | #define SYSINFO_DIMM_X8DS 0x05 |
| 31 | #define SYSINFO_DIMM_X8DDS 0x06 |
| 32 | |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 33 | /* Device 0:0.0 PCI configuration space (Host Bridge) */ |
| 34 | |
| 35 | #define EPBAR 0x40 |
| 36 | #define MCHBAR 0x48 |
| 37 | #define PCIEXBAR 0x60 |
| 38 | #define DMIBAR 0x68 |
| 39 | #define PMIOBAR 0x78 |
| 40 | |
| 41 | #define GGC 0x52 /* GMCH Graphics Control */ |
| 42 | |
| 43 | #define DEVEN 0x54 /* Device Enable */ |
| 44 | #define DEVEN_D0F0 (1 << 0) |
| 45 | #define DEVEN_D1F0 (1 << 1) |
| 46 | #define DEVEN_D2F0 (1 << 3) |
| 47 | #define DEVEN_D2F1 (1 << 4) |
| 48 | |
| 49 | #ifndef BOARD_DEVEN |
| 50 | #define BOARD_DEVEN ( DEVEN_D0F0 | DEVEN_D2F0 | DEVEN_D2F1 ) |
| 51 | #endif /* BOARD_DEVEN */ |
| 52 | |
| 53 | #define PAM0 0x90 |
| 54 | #define PAM1 0x91 |
| 55 | #define PAM2 0x92 |
| 56 | #define PAM3 0x93 |
| 57 | #define PAM4 0x94 |
| 58 | #define PAM5 0x95 |
| 59 | #define PAM6 0x96 |
| 60 | |
| 61 | #define LAC 0x97 /* Legacy Access Control */ |
| 62 | #define REMAPBASE 0x98 |
| 63 | #define REMAPLIMIT 0x9a |
| 64 | #define SMRAM 0x9d /* System Management RAM Control */ |
| 65 | #define ESMRAM 0x9e /* Extended System Management RAM Control */ |
| 66 | |
| 67 | #define TOM 0xa0 |
| 68 | #define TOUUD 0xa2 |
| 69 | #define GBSM 0xa4 |
| 70 | #define BGSM 0xa8 |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 71 | #define TSEG 0xac |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 72 | #define TOLUD 0xb0 /* Top of Low Used Memory */ |
| 73 | #define ERRSTS 0xc8 |
| 74 | #define ERRCMD 0xca |
| 75 | #define SMICMD 0xcc |
| 76 | #define SCICMD 0xce |
| 77 | #define CGDIS 0xd8 |
| 78 | #define SKPAD 0xdc /* Scratchpad Data */ |
| 79 | #define CAPID0 0xe0 |
| 80 | #define DEV0T 0xf0 |
| 81 | #define MSLCK 0xf4 |
| 82 | #define MID0 0xf8 |
| 83 | #define DEBUP0 0xfc |
| 84 | |
| 85 | /* Device 0:1.0 PCI configuration space (PCI Express) */ |
| 86 | |
| 87 | #define BCTRL1 0x3e /* 16bit */ |
| 88 | #define PEGSTS 0x214 /* 32bit */ |
| 89 | |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 90 | /* Device 0:2.0 PCI configuration space (Graphics Device) */ |
| 91 | |
| 92 | #define GMADR 0x18 |
| 93 | #define GTTADR 0x1c |
| 94 | #define BSM 0x5c |
| 95 | #define GCFC 0xf0 /* Graphics Clock Frequency & Gating Control */ |
| 96 | |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 97 | #define GPIO32(x) *((volatile u32 *)(DEFAULT_GPIOBASE + x)) |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 98 | |
| 99 | /* |
| 100 | * MCHBAR |
| 101 | */ |
| 102 | |
| 103 | #define MCHBAR8(x) *((volatile u8 *)(DEFAULT_MCHBAR + x)) |
| 104 | #define MCHBAR16(x) *((volatile u16 *)(DEFAULT_MCHBAR + x)) |
| 105 | #define MCHBAR32(x) *((volatile u32 *)(DEFAULT_MCHBAR + x)) |
| 106 | |
| 107 | /* |
| 108 | * EPBAR - Egress Port Root Complex Register Block |
| 109 | */ |
| 110 | |
| 111 | #define EPBAR8(x) *((volatile u8 *)(DEFAULT_EPBAR + x)) |
| 112 | #define EPBAR16(x) *((volatile u16 *)(DEFAULT_EPBAR + x)) |
| 113 | #define EPBAR32(x) *((volatile u32 *)(DEFAULT_EPBAR + x)) |
| 114 | |
| 115 | /* |
| 116 | * DMIBAR |
| 117 | */ |
| 118 | |
| 119 | #define DMIBAR8(x) *((volatile u8 *)(DEFAULT_DMIBAR + x)) |
| 120 | #define DMIBAR16(x) *((volatile u16 *)(DEFAULT_DMIBAR + x)) |
| 121 | #define DMIBAR32(x) *((volatile u32 *)(DEFAULT_DMIBAR + x)) |
| 122 | |
Damien Zammit | f7060f1 | 2015-11-14 00:59:21 +1100 | [diff] [blame] | 123 | enum fsb_clk { |
| 124 | FSB_CLOCK_667MHz = 0, |
| 125 | FSB_CLOCK_800MHz = 1, |
| 126 | }; |
| 127 | |
| 128 | enum mem_clk { |
| 129 | MEM_CLOCK_667MHz = 0, |
| 130 | MEM_CLOCK_800MHz = 1, |
| 131 | }; |
| 132 | |
| 133 | enum ddr { |
| 134 | DDR2 = 2, |
| 135 | DDR3 = 3, |
| 136 | }; |
| 137 | |
| 138 | enum chip_width { /* as in DDR3 spd */ |
| 139 | CHIP_WIDTH_x4 = 0, |
| 140 | CHIP_WIDTH_x8 = 1, |
| 141 | CHIP_WIDTH_x16 = 2, |
| 142 | CHIP_WIDTH_x32 = 3, |
| 143 | }; |
| 144 | |
| 145 | enum chip_cap { /* as in DDR3 spd */ |
| 146 | CHIP_CAP_256M = 0, |
| 147 | CHIP_CAP_512M = 1, |
| 148 | CHIP_CAP_1G = 2, |
| 149 | CHIP_CAP_2G = 3, |
| 150 | CHIP_CAP_4G = 4, |
| 151 | CHIP_CAP_8G = 5, |
| 152 | CHIP_CAP_16G = 6, |
| 153 | }; |
| 154 | |
| 155 | struct timings { |
| 156 | unsigned int CAS; |
| 157 | enum fsb_clk fsb_clock; |
| 158 | enum mem_clk mem_clock; |
| 159 | unsigned int tRAS; |
| 160 | unsigned int tRP; |
| 161 | unsigned int tRCD; |
| 162 | unsigned int tWR; |
| 163 | unsigned int tRFC; |
| 164 | unsigned int tWTR; |
| 165 | unsigned int tRRD; |
| 166 | unsigned int tRTP; |
| 167 | }; |
| 168 | |
| 169 | struct dimminfo { |
| 170 | unsigned int card_type; /* 0x0: unpopulated, |
| 171 | 0xa - 0xf: raw card type A - F */ |
| 172 | u8 type; |
| 173 | enum chip_width width; |
| 174 | enum chip_cap chip_capacity; |
| 175 | unsigned int page_size; /* of whole DIMM in Bytes (4096 or 8192) */ |
| 176 | unsigned int sides; |
| 177 | unsigned int banks; |
| 178 | unsigned int ranks; |
| 179 | unsigned int rows; |
| 180 | unsigned int cols; |
| 181 | unsigned int cas_latencies; |
| 182 | unsigned int tAAmin; |
| 183 | unsigned int tCKmin; |
| 184 | unsigned int tWR; |
| 185 | unsigned int tRP; |
| 186 | unsigned int tRCD; |
| 187 | unsigned int tRAS; |
| 188 | unsigned int rank_capacity_mb; /* per rank in Mega Bytes */ |
| 189 | u8 spd_data[256]; |
| 190 | }; |
| 191 | |
| 192 | struct pllparam { |
| 193 | u8 kcoarse[2][72]; |
| 194 | u8 pi[2][72]; |
| 195 | u8 dben[2][72]; |
| 196 | u8 dbsel[2][72]; |
| 197 | u8 clkdelay[2][72]; |
| 198 | }; |
| 199 | |
| 200 | struct sysinfo { |
| 201 | u8 maxpi; |
| 202 | u8 pioffset; |
| 203 | u8 pi[8]; |
| 204 | u16 coarsectrl; |
| 205 | u16 coarsedelay; |
| 206 | u16 mediumphase; |
| 207 | u16 readptrdelay; |
| 208 | |
| 209 | int txt_enabled; |
| 210 | int cores; |
| 211 | int boot_path; |
| 212 | int max_ddr2_mhz; |
| 213 | int max_ddr3_mt; |
| 214 | int max_fsb_mhz; |
| 215 | int max_render_mhz; |
| 216 | int enable_igd; |
| 217 | int enable_peg; |
| 218 | u16 ggc; |
| 219 | |
| 220 | int dimm_config[2]; |
| 221 | int dimms_per_ch; |
| 222 | int spd_type; |
| 223 | int channel_capacity[2]; |
| 224 | struct timings selected_timings; |
| 225 | struct dimminfo dimms[4]; |
| 226 | u8 spd_map[4]; |
| 227 | |
| 228 | u8 nodll; |
| 229 | u8 async; |
| 230 | u8 dt0mode; |
| 231 | u8 mvco4x; /* 0 (8x) or 1 (4x) */ |
| 232 | }; |
| 233 | |
| 234 | void pineview_early_initialization(void); |
| 235 | u32 decode_igd_memory_size(const u32 gms); |
| 236 | u32 decode_igd_gtt_size(const u32 gsm); |
| 237 | u8 decode_pciebar(u32 *const base, u32 *const len); |
| 238 | |
Damien Zammit | 6247793 | 2015-05-03 21:34:38 +1000 | [diff] [blame] | 239 | /* provided by mainboard code */ |
| 240 | void setup_ich7_gpios(void); |
| 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 */ |