blob: 6854b73cf9f68cead305baf0314398031be5567c [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgi2efc8802012-11-06 11:03:53 +01002
3#ifndef __NORTHBRIDGE_INTEL_GM45_GM45_H__
Edward O'Callaghan089a5102015-01-06 02:48:57 +11004#define __NORTHBRIDGE_INTEL_GM45_GM45_H__
Patrick Georgi2efc8802012-11-06 11:03:53 +01005
Patrick Georgi2efc8802012-11-06 11:03:53 +01006#include <stdint.h>
7
8typedef enum {
Angel Ponsac4e4b42020-09-16 01:13:00 +02009 FSB_CLOCK_1067MHz = 0,
10 FSB_CLOCK_800MHz = 1,
11 FSB_CLOCK_667MHz = 2,
Patrick Georgi2efc8802012-11-06 11:03:53 +010012} fsb_clock_t;
13
14typedef enum { /* Steppings below B1 were pre-production,
Angel Ponsc88a4792020-09-16 13:11:52 +020015 conversion stepping A1 is a newer GL40 with support for 800 MT/s on FSB/DDR.
Patrick Georgi2efc8802012-11-06 11:03:53 +010016 We'll support B1, B2, B3, and conversion stepping A1. */
17 STEPPING_A0 = 0,
18 STEPPING_A1 = 1,
19 STEPPING_A2 = 2,
20 STEPPING_A3 = 3,
21 STEPPING_B0 = 4,
22 STEPPING_B1 = 5,
23 STEPPING_B2 = 6,
24 STEPPING_B3 = 7,
25 STEPPING_CONVERSION_A1 = 9,
26} stepping_t;
27
28typedef enum {
29 GMCH_GM45 = 0,
30 GMCH_GM47,
31 GMCH_GM49,
32 GMCH_GE45,
33 GMCH_GL40,
34 GMCH_GL43,
35 GMCH_GS40,
36 GMCH_GS45,
37 GMCH_PM45,
38 GMCH_UNKNOWN
39} gmch_gfx_t;
40
41typedef enum {
Angel Ponsac4e4b42020-09-16 01:13:00 +020042 MEM_CLOCK_533MHz = 0,
43 MEM_CLOCK_400MHz = 1,
44 MEM_CLOCK_333MHz = 2,
45 MEM_CLOCK_1067MT = 0,
46 MEM_CLOCK_800MT = 1,
47 MEM_CLOCK_667MT = 2,
Patrick Georgi2efc8802012-11-06 11:03:53 +010048} mem_clock_t;
49
50typedef enum {
51 DDR1 = 1,
52 DDR2 = 2,
53 DDR3 = 3,
54} ddr_t;
55
56typedef enum {
57 CHANNEL_MODE_SINGLE,
58 CHANNEL_MODE_DUAL_ASYNC,
59 CHANNEL_MODE_DUAL_INTERLEAVED,
60} channel_mode_t;
61
62typedef enum { /* as in DDR3 spd */
63 CHIP_WIDTH_x4 = 0,
64 CHIP_WIDTH_x8 = 1,
65 CHIP_WIDTH_x16 = 2,
66 CHIP_WIDTH_x32 = 3,
67} chip_width_t;
68
69typedef enum { /* as in DDR3 spd */
70 CHIP_CAP_256M = 0,
71 CHIP_CAP_512M = 1,
72 CHIP_CAP_1G = 2,
73 CHIP_CAP_2G = 3,
74 CHIP_CAP_4G = 4,
75 CHIP_CAP_8G = 5,
76 CHIP_CAP_16G = 6,
77} chip_capacity_t;
78
79typedef struct {
80 unsigned int CAS;
81 fsb_clock_t fsb_clock;
82 mem_clock_t mem_clock;
83 channel_mode_t channel_mode;
84 unsigned int tRAS;
85 unsigned int tRP;
86 unsigned int tRCD;
87 unsigned int tRFC;
88 unsigned int tWR;
89 unsigned int tRD;
90 unsigned int tRRD;
91 unsigned int tFAW;
92 unsigned int tWL;
93} timings_t;
94
95typedef struct {
96 unsigned int card_type; /* 0x0: unpopulated,
97 0xa - 0xf: raw card type A - F */
98 chip_width_t chip_width;
99 chip_capacity_t chip_capacity;
100 unsigned int page_size; /* of whole DIMM in Bytes (4096 or 8192) */
101 unsigned int banks;
102 unsigned int ranks;
Martin Roth128c1042016-11-18 09:29:03 -0700103 unsigned int rank_capacity_mb; /* per rank in Megabytes */
Patrick Georgi2efc8802012-11-06 11:03:53 +0100104} dimminfo_t;
105
106/* The setup is one DIMM per channel, so there's no need to find a
107 common timing setup between multiple chips (but chip and controller
108 still need to be coordinated */
109typedef struct {
110 stepping_t stepping;
111 int txt_enabled;
112 int cores;
113 gmch_gfx_t gfx_type;
Patrick Georgi2efc8802012-11-06 11:03:53 +0100114 int max_ddr2_mhz;
115 int max_ddr3_mt;
116 fsb_clock_t max_fsb;
117 int max_fsb_mhz;
118 int max_render_mhz;
Vladimir Serbinenko56ae8a02014-08-16 10:59:02 +0200119 int enable_igd;
120 int enable_peg;
121 u16 ggc;
Patrick Georgi2efc8802012-11-06 11:03:53 +0100122
Nico Huber5aaeb272015-12-30 00:17:27 +0100123 /* to be filled in romstage main: */
Patrick Georgi2efc8802012-11-06 11:03:53 +0100124 int spd_type;
125 timings_t selected_timings;
126 dimminfo_t dimms[2];
Vladimir Serbinenkoc4d89482014-06-05 09:14:48 +0200127 u8 spd_map[4];
Nico Huber5aaeb272015-12-30 00:17:27 +0100128 int gs45_low_power_mode; /* low power mode of GMCH_GS45 */
129 int sff; /* small form factor option (soldered down DIMM) */
Patrick Georgi2efc8802012-11-06 11:03:53 +0100130} sysinfo_t;
Angel Ponsac4e4b42020-09-16 01:13:00 +0200131
Patrick Georgi2efc8802012-11-06 11:03:53 +0100132#define TOTAL_CHANNELS 2
133#define CHANNEL_IS_POPULATED(dimms, idx) (dimms[idx].card_type != 0)
134#define CHANNEL_IS_CARDF(dimms, idx) (dimms[idx].card_type == 0xf)
135#define IF_CHANNEL_POPULATED(dimms, idx) if (dimms[idx].card_type != 0)
136#define FOR_EACH_CHANNEL(idx) \
137 for (idx = 0; idx < TOTAL_CHANNELS; ++idx)
138#define FOR_EACH_POPULATED_CHANNEL(dimms, idx) \
139 FOR_EACH_CHANNEL(idx) IF_CHANNEL_POPULATED(dimms, idx)
140
141#define RANKS_PER_CHANNEL 4 /* Only two may be populated */
142#define IF_RANK_POPULATED(dimms, ch, r) \
143 if (dimms[ch].card_type && ((r) < dimms[ch].ranks))
144#define FOR_EACH_RANK_IN_CHANNEL(r) \
145 for (r = 0; r < RANKS_PER_CHANNEL; ++r)
146#define FOR_EACH_POPULATED_RANK_IN_CHANNEL(dimms, ch, r) \
147 FOR_EACH_RANK_IN_CHANNEL(r) IF_RANK_POPULATED(dimms, ch, r)
148#define FOR_EACH_RANK(ch, r) \
149 FOR_EACH_CHANNEL(ch) FOR_EACH_RANK_IN_CHANNEL(r)
150#define FOR_EACH_POPULATED_RANK(dimms, ch, r) \
151 FOR_EACH_RANK(ch, r) IF_RANK_POPULATED(dimms, ch, r)
152
153#define DDR3_MAX_CAS 18
154
155enum {
156 VCO_2666 = 4,
157 VCO_3200 = 0,
158 VCO_4000 = 1,
159 VCO_5333 = 2,
160};
161
Patrick Georgi2efc8802012-11-06 11:03:53 +0100162/* Offsets of read/write training results in CMOS.
163 They will be restored upon S3 resumes. */
164#define CMOS_READ_TRAINING 0x80 /* 16 bytes */
Angel Ponsac4e4b42020-09-16 01:13:00 +0200165#define CMOS_WRITE_TRAINING 0x90 /* 16 bytes (could be reduced to 10 bytes) */
Patrick Georgi2efc8802012-11-06 11:03:53 +0100166
Angel Ponsae2a5222020-09-16 13:25:02 +0200167#include "memmap.h"
Patrick Georgi2efc8802012-11-06 11:03:53 +0100168
169/*
170 * D0:F0
171 */
Angel Ponsac4e4b42020-09-16 01:13:00 +0200172#define D0F0_EPBAR_LO 0x40
173#define D0F0_EPBAR_HI 0x44
174#define D0F0_MCHBAR_LO 0x48
175#define D0F0_MCHBAR_HI 0x4c
176#define D0F0_GGC 0x52
177#define D0F0_DEVEN 0x54
178#define D0F0_PCIEXBAR_LO 0x60
179#define D0F0_PCIEXBAR_HI 0x64
180#define D0F0_DMIBAR_LO 0x68
181#define D0F0_DMIBAR_HI 0x6c
182#define D0F0_PMBASE 0x78
183#define D0F0_PAM(x) (0x90 + (x)) /* 0-6 */
184#define D0F0_REMAPBASE 0x98
185#define D0F0_REMAPLIMIT 0x9a
186#define D0F0_SMRAM 0x9d
187#define D0F0_ESMRAMC 0x9e
188#define D0F0_TOM 0xa0
189#define D0F0_TOUUD 0xa2
190#define D0F0_TOLUD 0xb0
191#define D0F0_SKPD 0xdc /* Scratchpad Data */
192#define D0F0_CAPID0 0xe0
Patrick Georgi2efc8802012-11-06 11:03:53 +0100193
194/*
195 * D1:F0 PEG
196 */
Angel Ponsac4e4b42020-09-16 01:13:00 +0200197#define PEG_CAP 0xa2
198#define SLOTCAP 0xb4
199#define PEGLC 0xec
200#define D1F0_VCCAP 0x104
201#define D1F0_VC0RCTL 0x114
Patrick Georgi2efc8802012-11-06 11:03:53 +0100202
203/*
204 * Graphics frequencies
205 */
206#define GCFGC_PCIDEV PCI_DEV(0, 2, 0)
207#define GCFGC_OFFSET 0xf0
208#define GCFGC_CR_SHIFT 0
209#define GCFGC_CR_MASK (0xf << GCFGC_CR_SHIFT)
210#define GCFGC_CS_SHIFT 8
211#define GCFGC_CS_MASK (0xf << GCFGC_CS_SHIFT)
212#define GCFGC_CD_SHIFT 12
213#define GCFGC_CD_MASK (0x1 << GCFGC_CD_SHIFT)
214#define GCFGC_UPDATE_SHIFT 5
215#define GCFGC_UPDATE (0x1 << GCFGC_UPDATE_SHIFT)
216
217/*
218 * MCHBAR
219 */
220
Angel Ponsa93cb112020-09-16 01:16:04 +0200221#define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x))))
222#define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x))))
223#define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + (x))))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100224
Nico Huberd85a71a2016-11-27 14:43:12 +0100225#define HPLLVCO_MCHBAR 0x0c0f
226
Patrick Georgi2efc8802012-11-06 11:03:53 +0100227#define PMSTS_MCHBAR 0x0f14 /* Self refresh channel status */
228#define PMSTS_WARM_RESET (1 << 1)
229#define PMSTS_BOTH_SELFREFRESH (1 << 0)
230
231#define CLKCFG_MCHBAR 0x0c00
232#define CLKCFG_FSBCLK_SHIFT 0
233#define CLKCFG_FSBCLK_MASK (7 << CLKCFG_FSBCLK_SHIFT)
234#define CLKCFG_MEMCLK_SHIFT 4
235#define CLKCFG_MEMCLK_MASK (7 << CLKCFG_MEMCLK_SHIFT)
236#define CLKCFG_UPDATE (1 << 12)
237
238#define SSKPD_MCHBAR 0x0c1c
239#define SSKPD_CLK_SHIFT 0
240#define SSKPD_CLK_MASK (7 << SSKPD_CLK_SHIFT)
241
242#define DCC_MCHBAR 0x200
243#define DCC_NO_CHANXOR (1 << 10)
244#define DCC_INTERLEAVED (1 << 1)
245#define DCC_CMD_SHIFT 16
246#define DCC_CMD_MASK (7 << DCC_CMD_SHIFT)
247#define DCC_CMD_NOP (1 << DCC_CMD_SHIFT)
248 /* For mode register mr0: */
249#define DCC_SET_MREG (3 << DCC_CMD_SHIFT)
250 /* For extended mode registers mr1 to mr3: */
251#define DCC_SET_EREG (4 << DCC_CMD_SHIFT)
252#define DCC_SET_EREG_SHIFT 21
253#define DCC_SET_EREG_MASK (DCC_CMD_MASK | (3 << DCC_SET_EREG_SHIFT))
Angel Ponsa93cb112020-09-16 01:16:04 +0200254#define DCC_SET_EREGx(x) ((DCC_SET_EREG | \
255 (((x) - 1) << DCC_SET_EREG_SHIFT)) & \
Patrick Georgi2efc8802012-11-06 11:03:53 +0100256 DCC_SET_EREG_MASK)
257
258/* Per channel DRAM Row Attribute registers (32-bit) */
Angel Ponsa93cb112020-09-16 01:16:04 +0200259#define CxDRA_MCHBAR(x) (0x1208 + ((x) * 0x0100))
260#define CxDRA_PAGESIZE_SHIFT(r) ((r) * 4) /* Per rank r */
Patrick Georgi2efc8802012-11-06 11:03:53 +0100261#define CxDRA_PAGESIZE_MASKr(r) (0x7 << CxDRA_PAGESIZE_SHIFT(r))
262#define CxDRA_PAGESIZE_MASK 0x0000ffff
263#define CxDRA_PAGESIZE(r, p) /* for log2(dimm page size in bytes) p */ \
Angel Ponsa93cb112020-09-16 01:16:04 +0200264 ((((p) - 10) << CxDRA_PAGESIZE_SHIFT(r)) & CxDRA_PAGESIZE_MASKr(r))
265#define CxDRA_BANKS_SHIFT(r) (((r) * 3) + 16)
Patrick Georgi2efc8802012-11-06 11:03:53 +0100266#define CxDRA_BANKS_MASKr(r) (0x3 << CxDRA_BANKS_SHIFT(r))
267#define CxDRA_BANKS_MASK 0x07ff0000
268#define CxDRA_BANKS(r, b) /* for number of banks b */ \
Angel Ponsa93cb112020-09-16 01:16:04 +0200269 (((b) << (CxDRA_BANKS_SHIFT(r) - 3)) & CxDRA_BANKS_MASKr(r))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100270
271/*
272 * Per channel DRAM Row Boundary registers (32-bit)
273 * Every two ranks share one register and must be programmed at the same time.
274 * All registers (4 ranks per channel) have to be set.
275 */
Angel Ponsa93cb112020-09-16 01:16:04 +0200276#define CxDRBy_MCHBAR(x, r) (0x1200 + ((x) * 0x0100) + (((r) / 2) * 4))
Angel Pons08ba81b2021-01-09 16:52:19 +0100277#define CxDRBy_BOUND_SHIFT(r) (((r) % 2) * 16)
Patrick Georgi2efc8802012-11-06 11:03:53 +0100278#define CxDRBy_BOUND_MASK(r) (0x1fc << CxDRBy_BOUND_SHIFT(r))
279#define CxDRBy_BOUND_MB(r, b) /* for boundary in MB b */ \
Angel Ponsa93cb112020-09-16 01:16:04 +0200280 ((((b) >> 5) << CxDRBy_BOUND_SHIFT(r)) & CxDRBy_BOUND_MASK(r))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100281
Angel Ponsa93cb112020-09-16 01:16:04 +0200282#define CxDRC0_MCHBAR(x) (0x1230 + ((x) * 0x0100))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100283#define CxDRC0_RANKEN0 (1 << 24) /* Rank Enable */
284#define CxDRC0_RANKEN1 (1 << 25)
285#define CxDRC0_RANKEN2 (1 << 26)
286#define CxDRC0_RANKEN3 (1 << 27)
Angel Ponsa93cb112020-09-16 01:16:04 +0200287#define CxDRC0_RANKEN(r) (1 << (24 + (r)))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100288#define CxDRC0_RANKEN_MASK (0xf << 24)
289#define CxDRC0_RMS_SHIFT 8 /* Refresh Mode Select */
290#define CxDRC0_RMS_MASK (7 << CxDRC0_RMS_SHIFT)
291#define CxDRC0_RMS_78US (2 << CxDRC0_RMS_SHIFT)
292#define CxDRC0_RMS_39US (3 << CxDRC0_RMS_SHIFT)
293
Angel Ponsa93cb112020-09-16 01:16:04 +0200294#define CxDRC1_MCHBAR(x) (0x1234 + ((x) * 0x0100))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100295#define CxDRC1_SSDS_SHIFT 24
296#define CxDRC1_SSDS_MASK (0xff << CxDRC1_SSDS_SHIFT)
297#define CxDRC1_DS (0x91 << CxDRC1_SSDS_SHIFT)
298#define CxDRC1_SS (0xb1 << CxDRC1_SSDS_SHIFT)
299#define CxDRC1_NOTPOP(r) (1 << (16 + r)) /* Write 1 for Not Populated */
300#define CxDRC1_NOTPOP_MASK (0xf << 16)
301#define CxDRC1_MUSTWR (3 << 11)
302
Angel Ponsa93cb112020-09-16 01:16:04 +0200303#define CxDRC2_MCHBAR(x) (0x1238 + ((x) * 0x0100))
304#define CxDRC2_NOTPOP(r) (1 << (24 + (r))) /* Write 1 for Not Populated */
Patrick Georgi2efc8802012-11-06 11:03:53 +0100305#define CxDRC2_NOTPOP_MASK (0xf << 24)
306#define CxDRC2_MUSTWR (1 << 12)
307#define CxDRC2_CLK1067MT (1 << 0)
308
309/* DRAM Timing registers (32-bit each) */
Angel Ponsa93cb112020-09-16 01:16:04 +0200310#define CxDRT0_MCHBAR(x) (0x1210 + ((x) * 0x0100))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100311#define CxDRT0_BtB_WtP_SHIFT 26
312#define CxDRT0_BtB_WtP_MASK (0x1f << CxDRT0_BtB_WtP_SHIFT)
313#define CxDRT0_BtB_WtR_SHIFT 20
314#define CxDRT0_BtB_WtR_MASK (0x1f << CxDRT0_BtB_WtR_SHIFT)
Angel Ponsa93cb112020-09-16 01:16:04 +0200315#define CxDRT1_MCHBAR(x) (0x1214 + ((x) * 0x0100))
316#define CxDRT2_MCHBAR(x) (0x1218 + ((x) * 0x0100))
317#define CxDRT3_MCHBAR(x) (0x121c + ((x) * 0x0100))
318#define CxDRT4_MCHBAR(x) (0x1220 + ((x) * 0x0100))
319#define CxDRT5_MCHBAR(x) (0x1224 + ((x) * 0x0100))
320#define CxDRT6_MCHBAR(x) (0x1228 + ((x) * 0x0100))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100321
322/* Clock disable registers (32-bit each) */
Angel Ponsa93cb112020-09-16 01:16:04 +0200323#define CxDCLKDIS_MCHBAR(x) (0x120c + ((x) * 0x0100))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100324#define CxDCLKDIS_MASK 3
325#define CxDCLKDIS_ENABLE 3 /* Always enable both clock pairs. */
326
327/* On-Die-Termination registers (2x 32-bit per channel) */
Angel Ponsa93cb112020-09-16 01:16:04 +0200328#define CxODT_HIGH(x) (0x124c + ((x) * 0x0100))
329#define CxODT_LOW(x) (0x1248 + ((x) * 0x0100))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100330
331/* Write Training registers. */
Angel Ponsa93cb112020-09-16 01:16:04 +0200332#define CxWRTy_MCHBAR(ch, s) (0x1470 + ((ch) * 0x0100) + ((3 - (s)) * 4))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100333
Angel Ponsa93cb112020-09-16 01:16:04 +0200334#define CxGTEW(x) (0x1270 + ((x) * 0x100))
335#define CxGTC(x) (0x1274 + ((x) * 0x100))
336#define CxDTPEW(x) (0x1278 + ((x) * 0x100))
337#define CxDTAEW(x) (0x1280 + ((x) * 0x100))
338#define CxDTC(x) (0x1288 + ((x) * 0x100))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100339
Angel Pons3378de12020-09-15 14:30:13 +0200340
Patrick Georgi2efc8802012-11-06 11:03:53 +0100341/*
342 * DMIBAR
343 */
344
Angel Ponsa93cb112020-09-16 01:16:04 +0200345#define DMIBAR8(x) (*((volatile u8 *)(DEFAULT_DMIBAR + (x))))
346#define DMIBAR16(x) (*((volatile u16 *)(DEFAULT_DMIBAR + (x))))
347#define DMIBAR32(x) (*((volatile u32 *)(DEFAULT_DMIBAR + (x))))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100348
Angel Pons3e33be22020-09-16 12:50:59 +0200349#define DMIVCECH 0x000 /* 32bit */
350#define DMIPVCCAP1 0x004 /* 32bit */
351
352#define DMIVC0RCAP 0x010 /* 32bit */
353#define DMIVC0RCTL 0x014 /* 32bit */
354#define DMIVC0RSTS 0x01a /* 16bit */
355#define VC0NP (1 << 1)
356
357#define DMIVC1RCAP 0x01c /* 32bit */
358#define DMIVC1RCTL 0x020 /* 32bit */
359#define DMIVC1RSTS 0x026 /* 16bit */
360#define VC1NP (1 << 1)
361
362#define DMIESD 0x044 /* 32bit */
363
364#define DMILE1D 0x050 /* 32bit */
365#define DMILE1A 0x058 /* 64bit */
366#define DMILE2D 0x060 /* 32bit */
367#define DMILE2A 0x068 /* 64bit */
368
369#define DMILCAP 0x084 /* 32bit */
370#define DMILCTL 0x088 /* 16bit */
371#define DMILSTS 0x08a /* 16bit */
Patrick Georgi2efc8802012-11-06 11:03:53 +0100372
Patrick Georgi2efc8802012-11-06 11:03:53 +0100373/*
374 * EPBAR
375 */
376
Angel Ponsa93cb112020-09-16 01:16:04 +0200377#define EPBAR8(x) (*((volatile u8 *)(DEFAULT_EPBAR + (x))))
378#define EPBAR16(x) (*((volatile u16 *)(DEFAULT_EPBAR + (x))))
379#define EPBAR32(x) (*((volatile u32 *)(DEFAULT_EPBAR + (x))))
Patrick Georgi2efc8802012-11-06 11:03:53 +0100380
Angel Pons3e33be22020-09-16 12:50:59 +0200381#define EPPVCCAP1 0x004 /* 32bit */
382#define EPPVCCTL 0x00c /* 32bit */
383
384#define EPVC0RCAP 0x010 /* 32bit */
385#define EPVC0RCTL 0x014 /* 32bit */
386#define EPVC0RSTS 0x01a /* 16bit */
387
388#define EPVC1RCAP 0x01c /* 32bit */
389#define EPVC1RCTL 0x020 /* 32bit */
390#define EPVC1RSTS 0x026 /* 16bit */
391
392#define EPVC1MTS 0x028 /* 32bit */
393#define EPVC1ITC 0x02c /* 32bit */
394
395#define EPVC1IST 0x038 /* 64bit */
396
397#define EPESD 0x044 /* 32bit */
398
399#define EPLE1D 0x050 /* 32bit */
400#define EPLE1A 0x058 /* 64bit */
401#define EPLE2D 0x060 /* 32bit */
402#define EPLE2A 0x068 /* 64bit */
403
404#define EP_PORTARB(x) (0x100 + 4 * (x)) /* 256bit */
Patrick Georgi2efc8802012-11-06 11:03:53 +0100405
Patrick Georgi2efc8802012-11-06 11:03:53 +0100406void gm45_early_init(void);
407void gm45_early_reset(void);
408
409void enter_raminit_or_reset(void);
410void get_gmch_info(sysinfo_t *);
411void raminit(sysinfo_t *, int s3resume);
412void raminit_thermal(const sysinfo_t *);
Vladimir Serbinenko56ae8a02014-08-16 10:59:02 +0200413void init_igd(const sysinfo_t *const);
Vladimir Serbinenko020dc0e2014-08-12 22:50:40 +0200414void init_pm(const sysinfo_t *, int do_freq_scaling_cfg);
Vladimir Serbinenko56ae8a02014-08-16 10:59:02 +0200415void igd_compute_ggc(sysinfo_t *const sysinfo);
Patrick Georgi2efc8802012-11-06 11:03:53 +0100416
417int raminit_read_vco_index(void);
418u32 raminit_get_rank_addr(unsigned int channel, unsigned int rank);
419
420void raminit_rcomp_calibration(stepping_t stepping);
421void raminit_reset_readwrite_pointers(void);
422void raminit_receive_enable_calibration(const timings_t *, const dimminfo_t *);
423void raminit_write_training(const mem_clock_t, const dimminfo_t *, int s3resume);
424void raminit_read_training(const dimminfo_t *, int s3resume);
425
426void gm45_late_init(stepping_t);
427
428u32 decode_igd_memory_size(u32 gms);
429u32 decode_igd_gtt_size(u32 gsm);
Arthur Heymans8b766052018-01-24 23:25:13 +0100430u32 decode_tseg_size(u8 esmramc);
Patrick Georgi2efc8802012-11-06 11:03:53 +0100431
432void init_iommu(void);
Vladimir Serbinenko33769a52014-08-30 22:39:20 +0200433
Arthur Heymans3b0eb602019-01-31 22:47:09 +0100434/* romstage mainboard hookups */
Arthur Heymans3b0eb602019-01-31 22:47:09 +0100435void mb_setup_superio(void); /* optional */
436void get_mb_spd_addrmap(u8 spd_addrmap[4]);
437void mb_pre_raminit_setup(sysinfo_t *); /* optional */
438void mb_post_raminit_setup(void); /* optional */
439
Arthur Heymans20cb85f2017-04-29 14:31:32 +0200440struct blc_pwm_t {
441 char ascii_string[13];
442 int pwm_freq; /* In Hz */
443};
444int get_blc_values(const struct blc_pwm_t **entries);
Arthur Heymans4d2d1712018-11-29 12:25:31 +0100445u16 get_blc_pwm_freq_value(const char *edid_ascii_string);
Arthur Heymans20cb85f2017-04-29 14:31:32 +0200446
Angel Ponsc0c95162020-08-03 13:55:18 +0200447int decode_pcie_bar(u32 *const base, u32 *const len);
Arthur Heymans20cb85f2017-04-29 14:31:32 +0200448
Alexander Couzens83fc32f2015-04-12 22:28:37 +0200449#include <device/device.h>
450
Vladimir Serbinenko33769a52014-08-30 22:39:20 +0200451struct acpi_rsdp;
Furquan Shaikh0f007d82020-04-24 06:41:18 -0700452unsigned long northbridge_write_acpi_tables(const struct device *device, unsigned long start,
453 struct acpi_rsdp *rsdp);
Patrick Georgi2efc8802012-11-06 11:03:53 +0100454
Edward O'Callaghan089a5102015-01-06 02:48:57 +1100455#endif /* __NORTHBRIDGE_INTEL_GM45_GM45_H__ */