- Moved hlt() to it's own header.
[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 #include <pc80/mc146818rtc.h>
10
11 #define NMI_OFF 0
12
13 static void pcix_init(device_t dev)
14 {
15         uint32_t dword;
16         uint16_t word;
17         uint8_t byte;
18         int nmi_option;
19
20         /* Enable memory write and invalidate ??? */
21         byte = pci_read_config8(dev, 0x04);
22         byte |= 0x10;
23         pci_write_config8(dev, 0x04, byte);
24         
25         /* Set drive strength */
26         word = pci_read_config16(dev, 0xe0);
27         word = 0x0404;
28         pci_write_config16(dev, 0xe0, word);
29         word = pci_read_config16(dev, 0xe4);
30         word = 0x0404;
31         pci_write_config16(dev, 0xe4, word);
32         
33         /* Set impedance */
34         word = pci_read_config16(dev, 0xe8);
35         word = 0x0404;
36         pci_write_config16(dev, 0xe8, word);
37
38         /* Set discard unrequested prefetch data */
39         word = pci_read_config16(dev, 0x4c);
40         word |= 1;
41         pci_write_config16(dev, 0x4c, word);
42         
43         /* Set split transaction limits */
44         word = pci_read_config16(dev, 0xa8);
45         pci_write_config16(dev, 0xaa, word);
46         word = pci_read_config16(dev, 0xac);
47         pci_write_config16(dev, 0xae, word);
48
49         /* Set up error reporting, enable all */
50         /* system error enable */
51         dword = pci_read_config32(dev, 0x04);
52         dword |= (1<<8);
53         pci_write_config32(dev, 0x04, dword);
54         
55         /* system and error parity enable */
56         dword = pci_read_config32(dev, 0x3c);
57         dword |= (3<<16);
58         pci_write_config32(dev, 0x3c, dword);
59         
60         /* NMI enable */
61         nmi_option = NMI_OFF;
62         get_option(&nmi_option, "nmi");
63         if(nmi_option) {
64                 dword = pci_read_config32(dev, 0x44);
65                 dword |= (1<<0);
66                 pci_write_config32(dev, 0x44, dword);
67         }
68         
69         /* Set up CRC flood enable */
70         dword = pci_read_config32(dev, 0xc0);
71         if(dword) {  /* do device A only */
72                 dword = pci_read_config32(dev, 0xc4);
73                 dword |= (1<<1);
74                 pci_write_config32(dev, 0xc4, dword);
75                 dword = pci_read_config32(dev, 0xc8);
76                 dword |= (1<<1);
77                 pci_write_config32(dev, 0xc8, dword);
78         }
79         
80         return;
81 }
82
83 static struct device_operations pcix_ops  = {
84         .read_resources   = pci_bus_read_resources,
85         .set_resources    = pci_dev_set_resources,
86         .enable_resources = pci_bus_enable_resources,
87         .init             = pcix_init,
88         .scan_bus         = pci_scan_bridge,
89 };
90
91 static struct pci_driver pcix_driver __pci_driver = {
92         .ops    = &pcix_ops,
93         .vendor = PCI_VENDOR_ID_AMD,
94         .device = 0x7450,
95 };
96
97
98 static void ioapic_enable(device_t dev)
99 {
100         uint32_t value;
101         value = pci_read_config32(dev, 0x44);
102         if (dev->enable) {
103                 value |= ((1 << 1) | (1 << 0));
104         } else {
105                 value &= ~((1 << 1) | (1 << 0));
106         }
107         pci_write_config32(dev, 0x44, value);
108 }
109
110 static struct device_operations ioapic_ops = {
111         .read_resources   = pci_dev_read_resources,
112         .set_resources    = pci_dev_set_resources,
113         .enable_resources = pci_dev_enable_resources,
114         .init     = 0,
115         .scan_bus = 0,
116         .enable   = ioapic_enable,
117 };
118
119 static struct pci_driver ioapic_driver __pci_driver = {
120         .ops    = &ioapic_ops,
121         .vendor = PCI_VENDOR_ID_AMD,
122         .device = 0x7451,
123         
124 };