small fixes
[coreboot.git] / src / northbridge / amd / amdk8 / misc_control.c
1 /* Turn off machine check triggers when reading
2  * pci space where there are no devices.
3  * This is necessary when scaning the bus for
4  * devices which is done by the kernel */
5
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>
11 #include "./cpu_rev.c"
12
13 static void misc_control_init(struct device *dev)
14 {
15         uint32_t cmd;
16         
17         printk_debug("NB: Function 3 Misc Control.. ");
18         
19         /* disable error reporting */
20         cmd = pci_read_config32(dev, 0x44);
21         cmd |= (1<<6) | (1<<25);
22         pci_write_config32(dev, 0x44, cmd );
23         if (is_cpu_pre_c0()) {
24                 /* errata 58 */
25                 cmd = pci_read_config32(dev, 0x80);
26                 cmd &= ~(1<<0);
27                 pci_write_config32(dev, 0x80, cmd );
28                 cmd = pci_read_config32(dev, 0x84);
29                 cmd &= ~(1<<24);
30                 cmd &= ~(1<<8);
31                 pci_write_config32(dev, 0x84, cmd );
32                 /* errata 66 */
33                 cmd = pci_read_config32(dev, 0x70);
34                 cmd &= ~(1<<0);
35                 cmd |= (1<<1);
36                 pci_write_config32(dev, 0x70, cmd );
37                 cmd = pci_read_config32(dev, 0x7c);
38                 cmd &= ~(3<<4);
39                 pci_write_config32(dev, 0x7c, cmd );
40         }
41         else {
42                 /* errata 98 */
43 #if 0           
44                 cmd = pci_read_config32(dev, 0xd4);
45                 if(cmd != 0x04e20707) {
46                         cmd = 0x04e20707;
47                         pci_write_config32(dev, 0xd4, cmd );
48                         hard_reset();
49                 }
50 #endif
51
52                 cmd = 0x04e20707;
53                 pci_write_config32(dev, 0xd4, cmd );
54         }
55
56 /*
57  * FIXME: This preprocessor check is a mere workaround. 
58  * The right fix is to walk over all links on all nodes
59  * and set the FIFO read pointer optimization value to
60  * 0x25 for each link connected to an AMD HT device.
61  *
62  * The reason this is only enabled for machines with more 
63  * than one CPU is that Athlon64 machines don't have the
64  * link at all that is optimized in the code.
65  */
66
67 #if CONFIG_MAX_CPUS > 1 
68         cmd = pci_read_config32(dev, 0xdc);
69         if((cmd & 0x0000ff00) != 0x02500) {
70                 cmd &= 0xffff00ff;
71                 cmd |= 0x00002500;
72                 pci_write_config32(dev, 0xdc, cmd );
73                 printk_debug("resetting cpu\n");
74                 hard_reset();
75         }
76 #endif  
77         printk_debug("done.\n");
78 }
79
80 static struct device_operations mcf3_ops  = {
81         .read_resources   = pci_dev_read_resources,
82         .set_resources    = pci_dev_set_resources,
83         .enable_resources = pci_dev_enable_resources,
84         .init             = misc_control_init,
85         .scan_bus         = 0,
86 };
87
88 static struct pci_driver mcf3_driver __pci_driver = {
89         .ops    = &mcf3_ops,
90         .vendor = PCI_VENDOR_ID_AMD,
91         .device = 0x1103,
92 };
93