blob: 41ef5d9628f8daae06ab57927717041c5685744f [file] [log] [blame]
Damien Zammit62477932015-05-03 21:34:38 +10001/*
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 Zammitf7060f12015-11-14 00:59:21 +110023#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 Zammit62477932015-05-03 21:34:38 +100033/* Device 0:0.0 PCI configuration space (Host Bridge) */
Angel Pons39ff7032020-03-09 21:39:44 +010034#define HOST_BRIDGE PCI_DEV(0, 0, 0)
Damien Zammit62477932015-05-03 21:34:38 +100035
36#define EPBAR 0x40
37#define MCHBAR 0x48
38#define PCIEXBAR 0x60
39#define DMIBAR 0x68
40#define PMIOBAR 0x78
41
Angel Pons39ff7032020-03-09 21:39:44 +010042#define GGC 0x52 /* GMCH Graphics Control */
Damien Zammit62477932015-05-03 21:34:38 +100043
Angel Pons39ff7032020-03-09 21:39:44 +010044#define DEVEN 0x54 /* Device Enable */
Damien Zammit62477932015-05-03 21:34:38 +100045#define DEVEN_D0F0 (1 << 0)
46#define DEVEN_D1F0 (1 << 1)
47#define DEVEN_D2F0 (1 << 3)
48#define DEVEN_D2F1 (1 << 4)
49
50#ifndef BOARD_DEVEN
51#define BOARD_DEVEN ( DEVEN_D0F0 | DEVEN_D2F0 | DEVEN_D2F1 )
52#endif /* BOARD_DEVEN */
53
54#define PAM0 0x90
55#define PAM1 0x91
56#define PAM2 0x92
57#define PAM3 0x93
58#define PAM4 0x94
59#define PAM5 0x95
60#define PAM6 0x96
61
62#define LAC 0x97 /* Legacy Access Control */
63#define REMAPBASE 0x98
64#define REMAPLIMIT 0x9a
65#define SMRAM 0x9d /* System Management RAM Control */
Arthur Heymans4bdfebd2018-04-09 22:10:33 +020066#define ESMRAMC 0x9e /* Extended System Management RAM Control */
Damien Zammit62477932015-05-03 21:34:38 +100067
68#define TOM 0xa0
69#define TOUUD 0xa2
70#define GBSM 0xa4
71#define BGSM 0xa8
Damien Zammitf7060f12015-11-14 00:59:21 +110072#define TSEG 0xac
Damien Zammit62477932015-05-03 21:34:38 +100073#define TOLUD 0xb0 /* Top of Low Used Memory */
74#define ERRSTS 0xc8
75#define ERRCMD 0xca
76#define SMICMD 0xcc
77#define SCICMD 0xce
78#define CGDIS 0xd8
79#define SKPAD 0xdc /* Scratchpad Data */
80#define CAPID0 0xe0
81#define DEV0T 0xf0
82#define MSLCK 0xf4
83#define MID0 0xf8
84#define DEBUP0 0xfc
85
86/* Device 0:1.0 PCI configuration space (PCI Express) */
87
Angel Pons39ff7032020-03-09 21:39:44 +010088#define PEGSTS 0x214 /* 32 bits */
Damien Zammit62477932015-05-03 21:34:38 +100089
Angel Pons39ff7032020-03-09 21:39:44 +010090/* Device 0:2.0 PCI configuration space (Integrated Graphics Device) */
91#define GMCH_IGD PCI_DEV(0, 2, 0)
Damien Zammit62477932015-05-03 21:34:38 +100092
93#define GMADR 0x18
94#define GTTADR 0x1c
95#define BSM 0x5c
Damien Zammit62477932015-05-03 21:34:38 +100096
Damien Zammitf7060f12015-11-14 00:59:21 +110097#define GPIO32(x) *((volatile u32 *)(DEFAULT_GPIOBASE + x))
Damien Zammit62477932015-05-03 21:34:38 +100098
99/*
100 * MCHBAR
101 */
102
Angel Pons39ff7032020-03-09 21:39:44 +0100103#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))) /* FIXME: causes changes */
106#define MCHBAR8_AND(x, and) (MCHBAR8(x) = MCHBAR8(x) & (and))
107#define MCHBAR16_AND(x, and) (MCHBAR16(x) = MCHBAR16(x) & (and))
108#define MCHBAR32_AND(x, and) (MCHBAR32(x) = MCHBAR32(x) & (and))
109#define MCHBAR8_OR(x, or) (MCHBAR8(x) = MCHBAR8(x) | (or))
110#define MCHBAR16_OR(x, or) (MCHBAR16(x) = MCHBAR16(x) | (or))
111#define MCHBAR32_OR(x, or) (MCHBAR32(x) = MCHBAR32(x) | (or))
112#define MCHBAR8_AND_OR(x, and, or) (MCHBAR8(x) = (MCHBAR8(x) & (and)) | (or))
113#define MCHBAR16_AND_OR(x, and, or) (MCHBAR16(x) = (MCHBAR16(x) & (and)) | (or))
114#define MCHBAR32_AND_OR(x, and, or) (MCHBAR32(x) = (MCHBAR32(x) & (and)) | (or))
115
116/* As there are many registers, define them on a separate file */
117
118#include "mchbar_regs.h"
Damien Zammit62477932015-05-03 21:34:38 +1000119
120/*
121 * EPBAR - Egress Port Root Complex Register Block
122 */
123
Angel Pons39ff7032020-03-09 21:39:44 +0100124#define EPBAR8(x) *((volatile u8 *)(DEFAULT_EPBAR + x))
Damien Zammit62477932015-05-03 21:34:38 +1000125#define EPBAR16(x) *((volatile u16 *)(DEFAULT_EPBAR + x))
126#define EPBAR32(x) *((volatile u32 *)(DEFAULT_EPBAR + x))
127
128/*
129 * DMIBAR
130 */
131
Angel Pons39ff7032020-03-09 21:39:44 +0100132#define DMIBAR8(x) *((volatile u8 *)(DEFAULT_DMIBAR + x))
Damien Zammit62477932015-05-03 21:34:38 +1000133#define DMIBAR16(x) *((volatile u16 *)(DEFAULT_DMIBAR + x))
134#define DMIBAR32(x) *((volatile u32 *)(DEFAULT_DMIBAR + x))
135
Damien Zammitf7060f12015-11-14 00:59:21 +1100136enum fsb_clk {
137 FSB_CLOCK_667MHz = 0,
138 FSB_CLOCK_800MHz = 1,
139};
140
141enum mem_clk {
142 MEM_CLOCK_667MHz = 0,
143 MEM_CLOCK_800MHz = 1,
144};
145
146enum ddr {
147 DDR2 = 2,
148 DDR3 = 3,
149};
150
151enum chip_width { /* as in DDR3 spd */
152 CHIP_WIDTH_x4 = 0,
153 CHIP_WIDTH_x8 = 1,
154 CHIP_WIDTH_x16 = 2,
155 CHIP_WIDTH_x32 = 3,
156};
157
158enum chip_cap { /* as in DDR3 spd */
159 CHIP_CAP_256M = 0,
160 CHIP_CAP_512M = 1,
161 CHIP_CAP_1G = 2,
162 CHIP_CAP_2G = 3,
163 CHIP_CAP_4G = 4,
164 CHIP_CAP_8G = 5,
165 CHIP_CAP_16G = 6,
166};
167
168struct timings {
169 unsigned int CAS;
170 enum fsb_clk fsb_clock;
171 enum mem_clk mem_clock;
172 unsigned int tRAS;
173 unsigned int tRP;
174 unsigned int tRCD;
175 unsigned int tWR;
176 unsigned int tRFC;
177 unsigned int tWTR;
178 unsigned int tRRD;
179 unsigned int tRTP;
180};
181
182struct dimminfo {
183 unsigned int card_type; /* 0x0: unpopulated,
184 0xa - 0xf: raw card type A - F */
185 u8 type;
186 enum chip_width width;
187 enum chip_cap chip_capacity;
188 unsigned int page_size; /* of whole DIMM in Bytes (4096 or 8192) */
189 unsigned int sides;
190 unsigned int banks;
191 unsigned int ranks;
192 unsigned int rows;
193 unsigned int cols;
194 unsigned int cas_latencies;
195 unsigned int tAAmin;
196 unsigned int tCKmin;
197 unsigned int tWR;
198 unsigned int tRP;
199 unsigned int tRCD;
200 unsigned int tRAS;
Martin Roth128c1042016-11-18 09:29:03 -0700201 unsigned int rank_capacity_mb; /* per rank in Megabytes */
Damien Zammitf7060f12015-11-14 00:59:21 +1100202 u8 spd_data[256];
203};
204
205struct pllparam {
206 u8 kcoarse[2][72];
207 u8 pi[2][72];
208 u8 dben[2][72];
209 u8 dbsel[2][72];
210 u8 clkdelay[2][72];
211};
212
213struct sysinfo {
214 u8 maxpi;
215 u8 pioffset;
216 u8 pi[8];
217 u16 coarsectrl;
218 u16 coarsedelay;
219 u16 mediumphase;
220 u16 readptrdelay;
221
222 int txt_enabled;
223 int cores;
224 int boot_path;
225 int max_ddr2_mhz;
226 int max_ddr3_mt;
227 int max_fsb_mhz;
228 int max_render_mhz;
229 int enable_igd;
230 int enable_peg;
231 u16 ggc;
232
233 int dimm_config[2];
234 int dimms_per_ch;
235 int spd_type;
236 int channel_capacity[2];
237 struct timings selected_timings;
238 struct dimminfo dimms[4];
239 u8 spd_map[4];
240
241 u8 nodll;
242 u8 async;
243 u8 dt0mode;
244 u8 mvco4x; /* 0 (8x) or 1 (4x) */
245};
246
Angel Pons39ff7032020-03-09 21:39:44 +0100247void pineview_early_init(void);
Damien Zammitf7060f12015-11-14 00:59:21 +1100248u32 decode_igd_memory_size(const u32 gms);
249u32 decode_igd_gtt_size(const u32 gsm);
250u8 decode_pciebar(u32 *const base, u32 *const len);
251
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +0100252/* Mainboard romstage callback functions */
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +0100253void get_mb_spd_addrmap(u8 *spd_addr_map);
254void mb_pirq_setup(void); /* optional */
255
Damien Zammitf7060f12015-11-14 00:59:21 +1100256struct acpi_rsdp;
257unsigned long northbridge_write_acpi_tables(unsigned long start, struct acpi_rsdp *rsdp);
258
Damien Zammit62477932015-05-03 21:34:38 +1000259#endif /* NORTHBRIDGE_INTEL_PINEVIEW_H */