blob: ea34fe0b7a0b507a39a31fd34b29091a01f4e99b [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Damien Zammit43a1f782015-08-19 15:16:59 +10002
3#ifndef __NORTHBRIDGE_INTEL_X4X_H__
4#define __NORTHBRIDGE_INTEL_X4X_H__
5
Arthur Heymansdc972e12019-11-12 08:35:05 +01006#include <stdint.h>
Angel Pons2a8ceef2020-09-15 12:23:45 +02007#include "memmap.h"
Arthur Heymans6190d0b2019-11-01 18:34:45 +01008
Angel Pons41e66ac2020-09-15 13:17:23 +02009#define BOOT_PATH_NORMAL 0
10#define BOOT_PATH_WARM_RESET 1
11#define BOOT_PATH_RESUME 2
12
Damien Zammit43a1f782015-08-19 15:16:59 +100013/*
14 * D0:F0
15 */
Angel Ponsd1c590a2020-08-03 16:01:39 +020016#define HOST_BRIDGE PCI_DEV(0, 0, 0)
17
Angel Ponsfd190752020-09-15 12:38:17 +020018#include "registers/host_bridge.h"
Damien Zammit43a1f782015-08-19 15:16:59 +100019
20/*
21 * D1:F0 PEG
22 */
Angel Pons6fd9adb2020-09-15 12:34:36 +020023#define PEG_CAP 0xa2
24#define SLOTCAP 0xb4
25#define PEGLC 0xec
26#define D1F0_VCCAP 0x104
27#define D1F0_VC0RCTL 0x114
Damien Zammit43a1f782015-08-19 15:16:59 +100028
29/*
30 * Graphics frequencies
31 */
32#define GCFGC_PCIDEV PCI_DEV(0, 2, 0)
33#define GCFGC_OFFSET 0xf0
34#define GCFGC_CR_SHIFT 0
35#define GCFGC_CR_MASK (0xf << GCFGC_CR_SHIFT)
36#define GCFGC_CS_SHIFT 8
37#define GCFGC_CS_MASK (0xf << GCFGC_CS_SHIFT)
38#define GCFGC_CD_SHIFT 12
39#define GCFGC_CD_MASK (0x1 << GCFGC_CD_SHIFT)
40#define GCFGC_UPDATE_SHIFT 5
41#define GCFGC_UPDATE (0x1 << GCFGC_UPDATE_SHIFT)
42
43/*
44 * MCHBAR
45 */
46
Angel Pons6fd9adb2020-09-15 12:34:36 +020047#define MCHBAR8(x) (*((volatile u8 *)(DEFAULT_MCHBAR + (x))))
Arthur Heymans70a1dda2017-03-09 01:58:24 +010048#define MCHBAR16(x) (*((volatile u16 *)(DEFAULT_MCHBAR + (x))))
49#define MCHBAR32(x) (*((volatile u32 *)(DEFAULT_MCHBAR + (x))))
Angel Pons6fd9adb2020-09-15 12:34:36 +020050#define MCHBAR8_AND(x, and) (MCHBAR8(x) = MCHBAR8(x) & (and))
Felix Held6cd2c2f2018-07-29 18:04:14 +020051#define MCHBAR16_AND(x, and) (MCHBAR16(x) = MCHBAR16(x) & (and))
Felix Held6cd2c2f2018-07-29 18:04:14 +020052#define MCHBAR32_AND(x, and) (MCHBAR32(x) = MCHBAR32(x) & (and))
Angel Pons6fd9adb2020-09-15 12:34:36 +020053#define MCHBAR8_OR(x, or) (MCHBAR8(x) = MCHBAR8(x) | (or))
54#define MCHBAR16_OR(x, or) (MCHBAR16(x) = MCHBAR16(x) | (or))
Felix Held6cd2c2f2018-07-29 18:04:14 +020055#define MCHBAR32_OR(x, or) (MCHBAR32(x) = MCHBAR32(x) | (or))
Angel Pons6fd9adb2020-09-15 12:34:36 +020056#define MCHBAR8_AND_OR(x, and, or) (MCHBAR8(x) = (MCHBAR8(x) & (and)) | (or))
57#define MCHBAR16_AND_OR(x, and, or) (MCHBAR16(x) = (MCHBAR16(x) & (and)) | (or))
58#define MCHBAR32_AND_OR(x, and, or) (MCHBAR32(x) = (MCHBAR32(x) & (and)) | (or))
Damien Zammit43a1f782015-08-19 15:16:59 +100059
Arthur Heymans1994e4482017-11-04 07:52:23 +010060#define CHDECMISC 0x111
61#define STACKED_MEM (1 << 1)
62
63#define C0DRB0 0x200
64#define C0DRB1 0x202
65#define C0DRB2 0x204
66#define C0DRB3 0x206
67#define C0DRA01 0x208
68#define C0DRA23 0x20a
69#define C0CKECTRL 0x260
70
71#define C1DRB0 0x600
72#define C1DRB1 0x602
73#define C1DRB2 0x604
74#define C1DRB3 0x606
75#define C1DRA01 0x608
76#define C1DRA23 0x60a
77#define C1CKECTRL 0x660
78
Damien Zammit43a1f782015-08-19 15:16:59 +100079#define PMSTS_MCHBAR 0x0f14 /* Self refresh channel status */
Arthur Heymans97e13d82016-11-30 18:40:38 +010080#define PMSTS_WARM_RESET (1 << 8)
81#define PMSTS_BOTH_SELFREFRESH (3 << 0)
Damien Zammit43a1f782015-08-19 15:16:59 +100082
83#define CLKCFG_MCHBAR 0x0c00
84#define CLKCFG_FSBCLK_SHIFT 0
85#define CLKCFG_FSBCLK_MASK (7 << CLKCFG_FSBCLK_SHIFT)
86#define CLKCFG_MEMCLK_SHIFT 4
87#define CLKCFG_MEMCLK_MASK (7 << CLKCFG_MEMCLK_SHIFT)
88#define CLKCFG_UPDATE (1 << 12)
89
Arthur Heymans5b30b822016-12-01 18:41:50 +010090#define SSKPD_MCHBAR 0x0c20 /* 64 bit */
Damien Zammit43a1f782015-08-19 15:16:59 +100091
92/*
93 * DMIBAR
94 */
95
Angel Pons6fd9adb2020-09-15 12:34:36 +020096#define DMIBAR8(x) (*((volatile u8 *)(DEFAULT_DMIBAR + (x))))
Arthur Heymans70a1dda2017-03-09 01:58:24 +010097#define DMIBAR16(x) (*((volatile u16 *)(DEFAULT_DMIBAR + (x))))
98#define DMIBAR32(x) (*((volatile u32 *)(DEFAULT_DMIBAR + (x))))
Damien Zammit43a1f782015-08-19 15:16:59 +100099
Angel Ponsa5314b62020-09-15 13:08:26 +0200100#define DMIVCECH 0x000 /* 32bit */
101#define DMIPVCCAP1 0x004 /* 32bit */
102
103#define DMIVC0RCAP 0x010 /* 32bit */
104#define DMIVC0RCTL 0x014 /* 32bit */
105#define DMIVC0RSTS 0x01a /* 16bit */
106#define VC0NP (1 << 1)
107
108#define DMIVC1RCAP 0x01c /* 32bit */
109#define DMIVC1RCTL 0x020 /* 32bit */
110#define DMIVC1RSTS 0x026 /* 16bit */
111#define VC1NP (1 << 1)
112
113#define DMIVCPRCAP 0x028 /* 32bit */
114#define DMIVCPRCTL 0x02c /* 32bit */
115#define DMIVCPRSTS 0x032 /* 16bit */
116#define VCPNP (1 << 1)
117
118#define DMIVCMRCAP 0x034 /* 32bit */
119#define DMIVCMRCTL 0x038 /* 32bit */
120#define DMIVCMRSTS 0x03e /* 16bit */
121#define VCMNP (1 << 1)
122
123#define DMIESD 0x044 /* 32bit */
124
125#define DMILE1D 0x050 /* 32bit */
126#define DMILE1A 0x058 /* 64bit */
127#define DMILE2D 0x060 /* 32bit */
128#define DMILE2A 0x068 /* 64bit */
129
130#define DMILCAP 0x084 /* 32bit */
131#define DMILCTL 0x088 /* 16bit */
132#define DMILSTS 0x08a /* 16bit */
133
134#define DMIUESTS 0x1c4 /* 32bit */
135#define DMICESTS 0x1d0 /* 32bit */
Damien Zammit43a1f782015-08-19 15:16:59 +1000136
137/*
138 * EPBAR
139 */
140
Angel Pons6fd9adb2020-09-15 12:34:36 +0200141#define EPBAR8(x) (*((volatile u8 *)(DEFAULT_EPBAR + (x))))
Arthur Heymans70a1dda2017-03-09 01:58:24 +0100142#define EPBAR16(x) (*((volatile u16 *)(DEFAULT_EPBAR + (x))))
143#define EPBAR32(x) (*((volatile u32 *)(DEFAULT_EPBAR + (x))))
Damien Zammit43a1f782015-08-19 15:16:59 +1000144
Angel Ponsa5314b62020-09-15 13:08:26 +0200145#define EPPVCCAP1 0x004 /* 32bit */
146#define EPPVCCTL 0x00c /* 32bit */
147
148#define EPVC0RCAP 0x010 /* 32bit */
149#define EPVC0RCTL 0x014 /* 32bit */
150#define EPVC0RSTS 0x01a /* 16bit */
151
152#define EPVC1RCAP 0x01c /* 32bit */
153#define EPVC1RCTL 0x020 /* 32bit */
154#define EPVC1RSTS 0x026 /* 16bit */
155
156#define EPVC1MTS 0x028 /* 32bit */
157#define EPVC1ITC 0x02c /* 32bit */
158
159#define EPESD 0x044 /* 32bit */
160
161#define EPLE1D 0x050 /* 32bit */
162#define EPLE1A 0x058 /* 64bit */
163#define EPLE2D 0x060 /* 32bit */
164#define EPLE2A 0x068 /* 64bit */
165
166#define EP_PORTARB(x) (0x100 + 4 * (x)) /* 256bit */
167
Damien Zammit43a1f782015-08-19 15:16:59 +1000168void x4x_early_init(void);
Arthur Heymansef7e98a2016-12-30 21:07:18 +0100169void x4x_late_init(int s3resume);
Arthur Heymansbf53acc2019-11-11 21:14:39 +0100170void mb_get_spd_map(u8 spd_map[4]);
171void mb_pre_raminit_setup(int s3_resume);
Damien Zammit43a1f782015-08-19 15:16:59 +1000172u32 decode_igd_memory_size(u32 gms);
173u32 decode_igd_gtt_size(u32 gsm);
Arthur Heymans4c65bfc2018-04-10 13:34:24 +0200174u32 decode_tseg_size(const u32 esmramc);
Angel Ponsecec9472020-08-03 15:44:27 +0200175int decode_pcie_bar(u32 *const base, u32 *const len);
Arthur Heymans0bf87de2017-11-04 06:15:05 +0100176
Kyösti Mälkkid7205be2019-09-27 07:24:17 +0300177#include <device/device.h>
Damien Zammit43a1f782015-08-19 15:16:59 +1000178struct acpi_rsdp;
Furquan Shaikh0f007d82020-04-24 06:41:18 -0700179unsigned long northbridge_write_acpi_tables(const struct device *device,
Elyes HAOUASfea02e12018-02-08 14:59:03 +0100180 unsigned long start, struct acpi_rsdp *rsdp);
Kyösti Mälkkid7205be2019-09-27 07:24:17 +0300181
Damien Zammit43a1f782015-08-19 15:16:59 +1000182#endif /* __NORTHBRIDGE_INTEL_X4X_H__ */