blob: 42f9d0fd9ea8fc81b907058c5fef933a382a514c [file] [log] [blame]
Damien Zammit62477932015-05-03 21:34:38 +10001/*
2 * This file is part of the coreboot project.
3 *
Damien Zammit62477932015-05-03 21:34:38 +10004 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef NORTHBRIDGE_INTEL_PINEVIEW_H
17#define NORTHBRIDGE_INTEL_PINEVIEW_H
18
19#include <northbridge/intel/pineview/iomap.h>
20#include <southbridge/intel/i82801gx/i82801gx.h>
21
Damien Zammitf7060f12015-11-14 00:59:21 +110022#define BOOT_PATH_NORMAL 0
23#define BOOT_PATH_RESET 1
24#define BOOT_PATH_RESUME 2
25
26#define SYSINFO_DIMM_NOT_POPULATED 0x00
27#define SYSINFO_DIMM_X16SS 0x01
28#define SYSINFO_DIMM_X16DS 0x02
29#define SYSINFO_DIMM_X8DS 0x05
30#define SYSINFO_DIMM_X8DDS 0x06
31
Damien Zammit62477932015-05-03 21:34:38 +100032/* Device 0:0.0 PCI configuration space (Host Bridge) */
Angel Pons39ff7032020-03-09 21:39:44 +010033#define HOST_BRIDGE PCI_DEV(0, 0, 0)
Damien Zammit62477932015-05-03 21:34:38 +100034
35#define EPBAR 0x40
36#define MCHBAR 0x48
37#define PCIEXBAR 0x60
38#define DMIBAR 0x68
39#define PMIOBAR 0x78
40
Angel Pons39ff7032020-03-09 21:39:44 +010041#define GGC 0x52 /* GMCH Graphics Control */
Damien Zammit62477932015-05-03 21:34:38 +100042
Angel Pons39ff7032020-03-09 21:39:44 +010043#define DEVEN 0x54 /* Device Enable */
Damien Zammit62477932015-05-03 21:34:38 +100044#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 */
Arthur Heymans4bdfebd2018-04-09 22:10:33 +020065#define ESMRAMC 0x9e /* Extended System Management RAM Control */
Damien Zammit62477932015-05-03 21:34:38 +100066
67#define TOM 0xa0
68#define TOUUD 0xa2
69#define GBSM 0xa4
70#define BGSM 0xa8
Damien Zammitf7060f12015-11-14 00:59:21 +110071#define TSEG 0xac
Damien Zammit62477932015-05-03 21:34:38 +100072#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
Angel Pons39ff7032020-03-09 21:39:44 +010087#define PEGSTS 0x214 /* 32 bits */
Damien Zammit62477932015-05-03 21:34:38 +100088
Angel Pons39ff7032020-03-09 21:39:44 +010089/* Device 0:2.0 PCI configuration space (Integrated Graphics Device) */
90#define GMCH_IGD PCI_DEV(0, 2, 0)
Damien Zammit62477932015-05-03 21:34:38 +100091
92#define GMADR 0x18
93#define GTTADR 0x1c
94#define BSM 0x5c
Damien Zammit62477932015-05-03 21:34:38 +100095
Damien Zammitf7060f12015-11-14 00:59:21 +110096#define GPIO32(x) *((volatile u32 *)(DEFAULT_GPIOBASE + x))
Damien Zammit62477932015-05-03 21:34:38 +100097
98/*
99 * MCHBAR
100 */
101
Angel Pons39ff7032020-03-09 21:39:44 +0100102#define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x))))
103#define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x))))
104#define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + x))) /* FIXME: causes changes */
105#define MCHBAR8_AND(x, and) (MCHBAR8(x) = MCHBAR8(x) & (and))
106#define MCHBAR16_AND(x, and) (MCHBAR16(x) = MCHBAR16(x) & (and))
107#define MCHBAR32_AND(x, and) (MCHBAR32(x) = MCHBAR32(x) & (and))
108#define MCHBAR8_OR(x, or) (MCHBAR8(x) = MCHBAR8(x) | (or))
109#define MCHBAR16_OR(x, or) (MCHBAR16(x) = MCHBAR16(x) | (or))
110#define MCHBAR32_OR(x, or) (MCHBAR32(x) = MCHBAR32(x) | (or))
111#define MCHBAR8_AND_OR(x, and, or) (MCHBAR8(x) = (MCHBAR8(x) & (and)) | (or))
112#define MCHBAR16_AND_OR(x, and, or) (MCHBAR16(x) = (MCHBAR16(x) & (and)) | (or))
113#define MCHBAR32_AND_OR(x, and, or) (MCHBAR32(x) = (MCHBAR32(x) & (and)) | (or))
114
115/* As there are many registers, define them on a separate file */
116
117#include "mchbar_regs.h"
Damien Zammit62477932015-05-03 21:34:38 +1000118
119/*
120 * EPBAR - Egress Port Root Complex Register Block
121 */
122
Angel Pons39ff7032020-03-09 21:39:44 +0100123#define EPBAR8(x) *((volatile u8 *)(DEFAULT_EPBAR + x))
Damien Zammit62477932015-05-03 21:34:38 +1000124#define EPBAR16(x) *((volatile u16 *)(DEFAULT_EPBAR + x))
125#define EPBAR32(x) *((volatile u32 *)(DEFAULT_EPBAR + x))
126
127/*
128 * DMIBAR
129 */
130
Angel Pons39ff7032020-03-09 21:39:44 +0100131#define DMIBAR8(x) *((volatile u8 *)(DEFAULT_DMIBAR + x))
Damien Zammit62477932015-05-03 21:34:38 +1000132#define DMIBAR16(x) *((volatile u16 *)(DEFAULT_DMIBAR + x))
133#define DMIBAR32(x) *((volatile u32 *)(DEFAULT_DMIBAR + x))
134
Damien Zammitf7060f12015-11-14 00:59:21 +1100135enum fsb_clk {
136 FSB_CLOCK_667MHz = 0,
137 FSB_CLOCK_800MHz = 1,
138};
139
140enum mem_clk {
141 MEM_CLOCK_667MHz = 0,
142 MEM_CLOCK_800MHz = 1,
143};
144
145enum ddr {
146 DDR2 = 2,
147 DDR3 = 3,
148};
149
150enum chip_width { /* as in DDR3 spd */
151 CHIP_WIDTH_x4 = 0,
152 CHIP_WIDTH_x8 = 1,
153 CHIP_WIDTH_x16 = 2,
154 CHIP_WIDTH_x32 = 3,
155};
156
157enum chip_cap { /* as in DDR3 spd */
158 CHIP_CAP_256M = 0,
159 CHIP_CAP_512M = 1,
160 CHIP_CAP_1G = 2,
161 CHIP_CAP_2G = 3,
162 CHIP_CAP_4G = 4,
163 CHIP_CAP_8G = 5,
164 CHIP_CAP_16G = 6,
165};
166
167struct timings {
168 unsigned int CAS;
169 enum fsb_clk fsb_clock;
170 enum mem_clk mem_clock;
171 unsigned int tRAS;
172 unsigned int tRP;
173 unsigned int tRCD;
174 unsigned int tWR;
175 unsigned int tRFC;
176 unsigned int tWTR;
177 unsigned int tRRD;
178 unsigned int tRTP;
179};
180
181struct dimminfo {
182 unsigned int card_type; /* 0x0: unpopulated,
183 0xa - 0xf: raw card type A - F */
184 u8 type;
185 enum chip_width width;
186 enum chip_cap chip_capacity;
187 unsigned int page_size; /* of whole DIMM in Bytes (4096 or 8192) */
188 unsigned int sides;
189 unsigned int banks;
190 unsigned int ranks;
191 unsigned int rows;
192 unsigned int cols;
193 unsigned int cas_latencies;
194 unsigned int tAAmin;
195 unsigned int tCKmin;
196 unsigned int tWR;
197 unsigned int tRP;
198 unsigned int tRCD;
199 unsigned int tRAS;
Martin Roth128c1042016-11-18 09:29:03 -0700200 unsigned int rank_capacity_mb; /* per rank in Megabytes */
Damien Zammitf7060f12015-11-14 00:59:21 +1100201 u8 spd_data[256];
202};
203
204struct pllparam {
205 u8 kcoarse[2][72];
206 u8 pi[2][72];
207 u8 dben[2][72];
208 u8 dbsel[2][72];
209 u8 clkdelay[2][72];
210};
211
212struct sysinfo {
213 u8 maxpi;
214 u8 pioffset;
215 u8 pi[8];
216 u16 coarsectrl;
217 u16 coarsedelay;
218 u16 mediumphase;
219 u16 readptrdelay;
220
221 int txt_enabled;
222 int cores;
223 int boot_path;
224 int max_ddr2_mhz;
225 int max_ddr3_mt;
226 int max_fsb_mhz;
227 int max_render_mhz;
228 int enable_igd;
229 int enable_peg;
230 u16 ggc;
231
232 int dimm_config[2];
233 int dimms_per_ch;
234 int spd_type;
235 int channel_capacity[2];
236 struct timings selected_timings;
237 struct dimminfo dimms[4];
238 u8 spd_map[4];
239
240 u8 nodll;
241 u8 async;
242 u8 dt0mode;
243 u8 mvco4x; /* 0 (8x) or 1 (4x) */
244};
245
Angel Pons39ff7032020-03-09 21:39:44 +0100246void pineview_early_init(void);
Damien Zammitf7060f12015-11-14 00:59:21 +1100247u32 decode_igd_memory_size(const u32 gms);
248u32 decode_igd_gtt_size(const u32 gsm);
249u8 decode_pciebar(u32 *const base, u32 *const len);
250
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +0100251/* Mainboard romstage callback functions */
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +0100252void get_mb_spd_addrmap(u8 *spd_addr_map);
253void mb_pirq_setup(void); /* optional */
254
Damien Zammitf7060f12015-11-14 00:59:21 +1100255struct acpi_rsdp;
256unsigned long northbridge_write_acpi_tables(unsigned long start, struct acpi_rsdp *rsdp);
257
Damien Zammit62477932015-05-03 21:34:38 +1000258#endif /* NORTHBRIDGE_INTEL_PINEVIEW_H */