blob: 978fea4c9d72133f7c77e30d3b6f679cf497f959 [file] [log] [blame]
Yinghai Luc65bd562007-02-01 00:10:05 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Yinghai Luc65bd562007-02-01 00:10:05 +00003 *
4 * Copyright (C) 2004 Tyan Computer
5 * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
6 * Copyright (C) 2006,2007 AMD
7 * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
Yinghai Luc65bd562007-02-01 00:10:05 +000018 */
19
20#include <console/console.h>
21#include <device/device.h>
Myles Watson29cc9ed2009-07-02 18:56:24 +000022#include <device/resource.h>
Yinghai Luc65bd562007-02-01 00:10:05 +000023#include <device/pci.h>
24#include <device/pci_ids.h>
25#include <device/pci_ops.h>
26#include "mcp55.h"
27
28static void pci_init(struct device *dev)
29{
Uwe Hermannc7f0c8f2011-01-04 19:51:33 +000030 u32 dword;
31 u16 word;
Yinghai Luc65bd562007-02-01 00:10:05 +000032 device_t pci_domain_dev;
Myles Watson29cc9ed2009-07-02 18:56:24 +000033 struct resource *mem, *pref;
Yinghai Luc65bd562007-02-01 00:10:05 +000034
35 /* System error enable */
36 dword = pci_read_config32(dev, 0x04);
37 dword |= (1<<8); /* System error enable */
38 dword |= (1<<30); /* Clear possible errors */
39 pci_write_config32(dev, 0x04, dword);
40
41#if 1
42 //only need (a01,xx]
43 word = pci_read_config16(dev, 0x48);
44 word |= (1<<0); /* MRL2MRM */
45 word |= (1<<2); /* MR2MRM */
46 pci_write_config16(dev, 0x48, word);
47#endif
48
49#if 1
50 dword = pci_read_config32(dev, 0x4c);
51 dword |= 0x00440000; /*TABORT_SER_ENABLE Park Last Enable.*/
52 pci_write_config32(dev, 0x4c, dword);
53#endif
54
Yinghai Luc65bd562007-02-01 00:10:05 +000055 pci_domain_dev = dev->bus->dev;
Myles Watson29cc9ed2009-07-02 18:56:24 +000056 while (pci_domain_dev) {
Stefan Reinauer4aff4452013-02-12 14:17:15 -080057 if (pci_domain_dev->path.type == DEVICE_PATH_DOMAIN)
Myles Watson29cc9ed2009-07-02 18:56:24 +000058 break;
Yinghai Luc65bd562007-02-01 00:10:05 +000059 pci_domain_dev = pci_domain_dev->bus->dev;
60 }
61
Myles Watson29cc9ed2009-07-02 18:56:24 +000062 if (!pci_domain_dev)
63 return; /* Impossible */
Yinghai Luc65bd562007-02-01 00:10:05 +000064
Myles Watson29cc9ed2009-07-02 18:56:24 +000065 pref = probe_resource(pci_domain_dev, IOINDEX_SUBTRACTIVE(2,0));
66 mem = probe_resource(pci_domain_dev, IOINDEX_SUBTRACTIVE(1,0));
67
68 if (!mem)
69 return; /* Impossible */
70
71 if (!pref || pref->base > mem->base) {
72 dword = mem->base & (0xffff0000UL);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000073 printk(BIOS_DEBUG, "PCI DOMAIN mem base = 0x%010Lx\n", mem->base);
Myles Watson29cc9ed2009-07-02 18:56:24 +000074 } else {
75 dword = pref->base & (0xffff0000UL);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000076 printk(BIOS_DEBUG, "PCI DOMAIN pref base = 0x%010Lx\n", pref->base);
Myles Watson29cc9ed2009-07-02 18:56:24 +000077 }
78
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000079 printk(BIOS_DEBUG, "[0x50] <-- 0x%08x\n", dword);
Myles Watson29cc9ed2009-07-02 18:56:24 +000080 pci_write_config32(dev, 0x50, dword); /* TOM */
Yinghai Luc65bd562007-02-01 00:10:05 +000081}
82
Yinghai Luc65bd562007-02-01 00:10:05 +000083static struct device_operations pci_ops = {
84 .read_resources = pci_bus_read_resources,
85 .set_resources = pci_dev_set_resources,
86 .enable_resources = pci_bus_enable_resources,
87 .init = pci_init,
88 .scan_bus = pci_scan_bridge,
89// .enable = mcp55_enable,
90 .reset_bus = pci_bus_reset,
Yinghai Luc65bd562007-02-01 00:10:05 +000091};
92
Stefan Reinauerf1cf1f72007-10-24 09:08:58 +000093static const struct pci_driver pci_driver __pci_driver = {
Yinghai Luc65bd562007-02-01 00:10:05 +000094 .ops = &pci_ops,
95 .vendor = PCI_VENDOR_ID_NVIDIA,
96 .device = PCI_DEVICE_ID_NVIDIA_MCP55_PCI,
97};