- O2, enums, and switch statements work in romcc
[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         /* Enable memory write and invalidate ??? */
16         byte = pci_read_config8(dev, 0x04);
17         byte |= 0x10;
18         pci_write_config8(dev, 0x04, byte);
19         
20         /* Set drive strength */
21         word = pci_read_config16(dev, 0xe0);
22         word = 0x0404;
23         pci_write_config16(dev, 0xe0, word);
24         word = pci_read_config16(dev, 0xe4);
25         word = 0x0404;
26         pci_write_config16(dev, 0xe4, word);
27         
28         /* Set impedance */
29         word = pci_read_config16(dev, 0xe8);
30         word = 0x0404;
31         pci_write_config16(dev, 0xe8, word);
32
33         /* Set discard unrequested prefetch data */
34         word = pci_read_config16(dev, 0x4c);
35         word |= 1;
36         pci_write_config16(dev, 0x4c, word);
37         
38         /* Set split transaction limits */
39         word = pci_read_config16(dev, 0xa8);
40         pci_write_config16(dev, 0xaa, word);
41         word = pci_read_config16(dev, 0xac);
42         pci_write_config16(dev, 0xae, word);
43         
44         return;
45 }
46
47 static struct device_operations pcix_ops  = {
48         .read_resources   = pci_bus_read_resources,
49         .set_resources    = pci_dev_set_resources,
50         .enable_resources = pci_bus_enable_resources,
51         .init             = pcix_init,
52         .scan_bus         = pci_scan_bridge,
53 };
54
55 static struct pci_driver pcix_driver __pci_driver = {
56         .ops    = &pcix_ops,
57         .vendor = PCI_VENDOR_ID_AMD,
58         .device = 0x7450,
59 };
60
61
62 static void ioapic_enable(device_t dev)
63 {
64         uint32_t value;
65         value = pci_read_config32(dev, 0x44);
66         if (dev->enable) {
67                 value |= ((1 << 1) | (1 << 0));
68         } else {
69                 value &= ~((1 << 1) | (1 << 0));
70         }
71         pci_write_config32(dev, 0x44, value);
72 }
73
74 static struct device_operations ioapic_ops = {
75         .read_resources   = pci_dev_read_resources,
76         .set_resources    = pci_dev_set_resources,
77         .enable_resources = pci_dev_enable_resources,
78         .init     = 0,
79         .scan_bus = 0,
80         .enable   = ioapic_enable,
81 };
82
83 static struct pci_driver ioapic_driver __pci_driver = {
84         .ops    = &ioapic_ops,
85         .vendor = PCI_VENDOR_ID_AMD,
86         .device = 0x7451,
87         
88 };