summaryrefslogtreecommitdiff
path: root/src/soc/intel/common/block/pcie/pcie.c
blob: e8b1050f4a510ffed6c529cc7782b38697ce6115 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2017-2018 Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <console/console.h>
#include <device/pci.h>
#include <device/pciexp.h>
#include <device/pci_def.h>
#include <device/pci_ids.h>
#include <device/pci_ops.h>

#define CACHE_LINE_SIZE	0x10

static void pch_pcie_init(struct device *dev)
{
	u16 reg16;

	printk(BIOS_DEBUG, "Initializing PCH PCIe bridge.\n");

	/* Enable SERR */
	pci_or_config32(dev, PCI_COMMAND, PCI_COMMAND_SERR);

	/* Enable Bus Master */
	pci_or_config32(dev, PCI_COMMAND, PCI_COMMAND_MASTER);

	/* Set Cache Line Size to 0x10 */
	pci_write_config8(dev, PCI_CACHE_LINE_SIZE, CACHE_LINE_SIZE);

	/* disable parity error response, enable ISA */
	pci_update_config16(dev, PCI_BRIDGE_CONTROL, ~1, 1<<2);

	if (CONFIG(PCIE_DEBUG_INFO)) {
		printk(BIOS_SPEW, "    MBL    = 0x%08x\n",
				pci_read_config32(dev, PCI_MEMORY_BASE));
		printk(BIOS_SPEW, "    PMBL   = 0x%08x\n",
				pci_read_config32(dev, PCI_PREF_MEMORY_BASE));
		printk(BIOS_SPEW, "    PMBU32 = 0x%08x\n",
				pci_read_config32(dev, PCI_PREF_BASE_UPPER32));
		printk(BIOS_SPEW, "    PMLU32 = 0x%08x\n",
				pci_read_config32(dev, PCI_PREF_LIMIT_UPPER32));
	}

	/* Clear errors in status registers */
	reg16 = pci_read_config16(dev, PCI_STATUS);
	pci_write_config16(dev, PCI_STATUS, reg16);
	reg16 = pci_read_config16(dev, PCI_SEC_STATUS);
	pci_write_config16(dev, PCI_SEC_STATUS, reg16);
}

static void pcie_set_L1_ss_max_latency(struct device *dev, unsigned int offset)
{
	/* Set max snoop and non-snoop latency for the SOC */
	pci_write_config32(dev, offset,
		PCIE_LTR_MAX_NO_SNOOP_LATENCY_3146US << 16 |
		PCIE_LTR_MAX_SNOOP_LATENCY_3146US);
}

static struct pci_operations pcie_ops = {
	.set_L1_ss_latency = pcie_set_L1_ss_max_latency,
	.set_subsystem = pci_dev_set_subsystem,
};

static struct device_operations device_ops = {
	.read_resources		= pci_bus_read_resources,
	.set_resources		= pci_dev_set_resources,
	.enable_resources		= pci_bus_enable_resources,
	.init		= pch_pcie_init,
	.scan_bus		= pciexp_scan_bridge,
	.ops_pci		= &pcie_ops,
};

static const unsigned short pcie_device_ids[] = {
	PCI_DEVICE_ID_INTEL_SPT_LP_PCIE_RP1,
	PCI_DEVICE_ID_INTEL_SPT_LP_PCIE_RP2,
	PCI_DEVICE_ID_INTEL_SPT_LP_PCIE_RP3,
	PCI_DEVICE_ID_INTEL_SPT_LP_PCIE_RP4,
	PC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CIE_RP8,
	PCI_DEVICE_ID_INTEL_CMP_LP_PCIE_RP9,
	PCI_DEVICE_ID_INTEL_CMP_LP_PCIE_RP10,
	PCI_DEVICE_ID_INTEL_CMP_LP_PCIE_RP11,
	PCI_DEVICE_ID_INTEL_CMP_LP_PCIE_RP12,
	PCI_DEVICE_ID_INTEL_CMP_LP_PCIE_RP13,
	PCI_DEVICE_ID_INTEL_CMP_LP_PCIE_RP14,
	PCI_DEVICE_ID_INTEL_CMP_LP_PCIE_RP15,
	PCI_DEVICE_ID_INTEL_CMP_LP_PCIE_RP16,
	0
};

static const struct pci_driver pch_pcie __pci_driver = {
	.ops	= &device_ops,
	.vendor	= PCI_VENDOR_ID_INTEL,
	.devices	= pcie_device_ids,
};