- First pass at code for generic link width and size determination
[coreboot.git] / src / southbridge / amd / amd8131 / amd8131_bridge.c
1 /*
2  * (C) 2003 Linux Networx
3  */
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/pci.h>
7 #include <device/pci_ids.h>
8 #include <device/pci_ops.h>
9
10 static void pcix_init(device_t dev)
11 {
12         uint16_t word;
13         uint8_t byte;
14
15         
16         /* Enable memory write and invalidate ??? */
17         byte = pci_read_config8(dev, 0x04);
18         byte |= 0x10;
19         pci_write_config8(dev, 0x04, byte);
20         
21         /* Set drive strength */
22         word = pci_read_config16(dev, 0xe0);
23         word = 0x0404;
24         pci_write_config16(dev, 0xe0, word);
25         word = pci_read_config16(dev, 0xe4);
26         word = 0x0404;
27         pci_write_config16(dev, 0xe4, word);
28         
29         /* Set impedance */
30         word = pci_read_config16(dev, 0xe8);
31         word = 0x0404;
32         pci_write_config16(dev, 0xe8, word);
33
34         return;
35 }
36
37 static struct device_operations pcix_ops  = {
38         .read_resources = pci_bus_read_resources,
39         .set_resources = pci_dev_set_resources,
40         .init = pcix_init,
41         .scan_bus = pci_scan_bridge,
42 };
43
44 static struct pci_driver pcix_driver __pci_driver = {
45         .ops    = &pcix_ops,
46         .vendor = PCI_VENDOR_ID_AMD,
47         .device = 0x7450,
48 };
49
50
51 static void ioapic_enable(device_t dev)
52 {
53         uint32_t value;
54         value = pci_read_config32(dev, 0x44);
55         if (dev->enable) {
56                 value |= ((1 << 1) | (1 << 0));
57         } else {
58                 value &= ~((1 << 1) | (1 << 0));
59         }
60         pci_write_config32(dev, 0x44, value);
61 }
62
63 static struct device_operations ioapic_ops = {
64         .read_resources = pci_dev_read_resources,
65         .set_resources  = pci_dev_set_resources,
66         .init     = 0,
67         .scan_bus = 0,
68         .enable   = ioapic_enable,
69 };
70
71 static struct pci_driver ioapic_driver __pci_driver = {
72         .ops    = &ioapic_ops,
73         .vendor = PCI_VENDOR_ID_AMD,
74         .device = 0x7451,
75         
76 };