2 * Copyright 2004 Tyan Computer
6 #include <console/console.h>
7 #include <device/device.h>
8 #include <device/pci.h>
9 #include <device/pci_ids.h>
10 #include <device/pci_ops.h>
13 static void pci_init(struct device *dev)
17 #if CONFIG_PCI_64BIT_PREF_MEM == 1
18 device_t pci_domain_dev;
19 struct resource *mem1, *mem2;
22 /* System error enable */
23 dword = pci_read_config32(dev, 0x04);
24 dword |= (1<<8); /* System error enable */
25 dword |= (1<<30); /* Clear possible errors */
26 pci_write_config32(dev, 0x04, dword);
29 word = pci_read_config16(dev, 0x48);
30 word |= (1<<0); /* MRL2MRM */
31 word |= (1<<2); /* MR2MRM */
32 pci_write_config16(dev, 0x48, word);
36 dword = pci_read_config32(dev, 0x4c);
37 dword |= 0x00440000; /*TABORT_SER_ENABLE Park Last Enable.*/
38 pci_write_config32(dev, 0x4c, dword);
41 #if CONFIG_PCI_64BIT_PREF_MEM == 1
42 pci_domain_dev = dev->bus->dev;
43 while(pci_domain_dev) {
44 if(pci_domain_dev->path.type == DEVICE_PATH_PCI_DOMAIN) break;
45 pci_domain_dev = pci_domain_dev->bus->dev;
48 if(!pci_domain_dev) return; // impossiable
49 mem1 = find_resource(pci_domain_dev, 1); // prefmem, it could be 64bit
50 mem2 = find_resource(pci_domain_dev, 2); // mem
51 if(mem1->base > mem2->base) {
52 dword = mem2->base & (0xffff0000UL);
53 printk_debug("PCI DOMAIN mem2 base = 0x%010Lx\n", mem2->base);
55 dword = mem1->base & (0xffff0000UL);
56 printk_debug("PCI DOMAIN mem1 (prefmem) base = 0x%010Lx\n", mem1->base);
59 dword = dev_root.resource[1].base & (0xffff0000UL);
60 printk_debug("dev_root mem base = 0x%010Lx\n", dev_root.resource[1].base);
63 printk_debug("[0x50] <-- 0x%08x\n", dword);
64 pci_write_config32(dev, 0x50, dword); //TOM
68 static struct pci_operations lops_pci = {
72 static struct device_operations pci_ops = {
73 .read_resources = pci_bus_read_resources,
74 .set_resources = pci_dev_set_resources,
75 .enable_resources = pci_bus_enable_resources,
77 .scan_bus = pci_scan_bridge,
78 // .enable = ck804_enable,
82 static struct pci_driver pci_driver __pci_driver = {
84 .vendor = PCI_VENDOR_ID_NVIDIA,
85 .device = PCI_DEVICE_ID_NVIDIA_CK804_PCI,