blob: 6ad5345f8ae3dedaba0ff5f0b0670b880f452ae4 [file] [log] [blame]
Patrick Georgibe61a172010-12-18 07:48:43 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2009-2010 iWave Systems
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
10 * the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Patrick Georgibe61a172010-12-18 07:48:43 +000016 */
17
18#include <console/console.h>
19#include <device/device.h>
20#include <device/pci.h>
21#include <device/pci_ids.h>
22
23static void pci_init(struct device *dev)
24{
25 u16 reg16;
26 u32 reg32;
27
28 printk(BIOS_DEBUG, "Initializing SCH PCIe bridge.\n");
29
30 /* Enable Bus Master */
31 reg32 = pci_read_config32(dev, PCI_COMMAND);
32 reg32 |= PCI_COMMAND_MASTER;
33 pci_write_config32(dev, PCI_COMMAND, reg32);
34
35 /* Set Cache Line Size to 0x10 */
36 // This has no effect but the OS might expect it
37 pci_write_config8(dev, 0x0c, 0x10);
38 //pci_write_config32(dev, 0x18, 0x11);
39
40 //reg16 = pci_read_config16(dev, 0x3e);
41 //reg16 &= ~(1 << 0); /* disable parity error response */
42 // reg16 &= ~(1 << 1); /* disable SERR */
43 //reg16 |= (1 << 2); /* ISA enable */
44 //pci_write_config16(dev, 0x3e, reg16);
Uwe Hermann405721d2010-12-18 13:22:37 +000045 /* Slot implemented. */
Patrick Georgibe61a172010-12-18 07:48:43 +000046 reg16 = pci_read_config16(dev, 0x42);
47 reg16 |= (1 << 8);
48 pci_write_config16(dev, 0x42, reg16);
49
50 reg16 = pci_read_config16(dev, 0x48);
51 reg16 |= 0xf;
52 pci_write_config16(dev, 0x48, reg16);
Patrick Georgibe61a172010-12-18 07:48:43 +000053}
54
55static void pcie_set_subsystem(device_t dev, unsigned vendor, unsigned device)
56{
57 /* NOTE: This is not the default position! */
58 if (!vendor || !device) {
Uwe Hermann405721d2010-12-18 13:22:37 +000059 pci_write_config32(dev, 0x94, pci_read_config32(dev, 0));
Patrick Georgibe61a172010-12-18 07:48:43 +000060 } else {
61 pci_write_config32(dev, 0x94,
62 ((device & 0xffff) << 16) | (vendor & 0xffff));
63 }
64}
65
66static struct pci_operations pci_ops = {
67 .set_subsystem = pcie_set_subsystem,
68};
69
70static struct device_operations device_ops = {
71 .read_resources = pci_bus_read_resources,
72 .set_resources = pci_dev_set_resources,
73 .enable_resources = pci_bus_enable_resources,
74 .init = pci_init,
75 .scan_bus = pci_scan_bridge,
76 .ops_pci = &pci_ops,
77};
78
79/* Port 1 */
80static const struct pci_driver sch_pcie_port1 __pci_driver = {
81 .ops = &device_ops,
82 .vendor = PCI_VENDOR_ID_INTEL,
83 .device = 0x8110,
84};
85
86/*Port 2 */
87static const struct pci_driver sch_pcie_port2 __pci_driver = {
88 .ops = &device_ops,
89 .vendor = PCI_VENDOR_ID_INTEL,
90 .device = 0x8112,
91};