2 * Copyright 2004 Tyan Computer
6 #include <console/console.h>
7 #include <device/device.h>
8 #include <device/resource.h>
9 #include <device/pci.h>
10 #include <device/pci_ids.h>
11 #include <device/pci_ops.h>
14 static void pci_init(struct device *dev)
17 device_t pci_domain_dev;
18 struct resource *mem, *pref;
20 dword = pci_read_config32(dev, 0x04);
21 dword |= (1 << 8); /* System error enable */
22 dword |= (1 << 30); /* Clear possible errors */
23 pci_write_config32(dev, 0x04, dword);
26 word = pci_read_config16(dev, 0x48);
27 word |= (1 << 0); /* MRL2MRM */
28 word |= (1 << 2); /* MR2MRM */
29 pci_write_config16(dev, 0x48, word);
33 dword = pci_read_config32(dev, 0x4c);
34 dword |= 0x00440000; /* TABORT_SER_ENABLE Park Last Enable. */
35 pci_write_config32(dev, 0x4c, dword);
38 pci_domain_dev = dev->bus->dev;
39 while (pci_domain_dev) {
40 if (pci_domain_dev->path.type == DEVICE_PATH_PCI_DOMAIN)
42 pci_domain_dev = pci_domain_dev->bus->dev;
46 return; /* Impossible */
48 pref = probe_resource(pci_domain_dev, IOINDEX_SUBTRACTIVE(2,0));
49 mem = probe_resource(pci_domain_dev, IOINDEX_SUBTRACTIVE(1,0));
52 return; /* Impossible */
54 if (!pref || pref->base > mem->base) {
55 dword = mem->base & (0xffff0000UL);
56 printk_debug("PCI DOMAIN mem base = 0x%010Lx\n", mem->base);
58 dword = pref->base & (0xffff0000UL);
59 printk_debug("PCI DOMAIN pref base = 0x%010Lx\n", pref->base);
62 printk_debug("[0x50] <-- 0x%08x\n", dword);
63 pci_write_config32(dev, 0x50, dword); /* TOM */
66 static struct pci_operations lops_pci = {
70 static struct device_operations pci_ops = {
71 .read_resources = pci_bus_read_resources,
72 .set_resources = pci_dev_set_resources,
73 .enable_resources = pci_bus_enable_resources,
75 .scan_bus = pci_scan_bridge,
76 // .enable = ck804_enable,
80 static const struct pci_driver pci_driver __pci_driver = {
82 .vendor = PCI_VENDOR_ID_NVIDIA,
83 .device = PCI_DEVICE_ID_NVIDIA_CK804_PCI,