- Major update of the dynamic device tree so it can handle
[coreboot.git] / src / southbridge / amd / amd8111 / amd8111_ide.c
1 #include <console/console.h>
2 #include <device/device.h>
3 #include <device/pci.h>
4 #include <device/pci_ids.h>
5 #include <device/pci_ops.h>
6
7 static void ide_init(struct device *dev)
8 {
9
10         /* Enable ide devices so the linux ide driver will work */
11         uint16_t word;
12         int enable_a=1, enable_b=1;
13
14
15         printk_debug("ide_init\n");
16
17         word = pci_read_config16(dev, 0x40);
18         /* Ensure prefetch is disabled */
19         word &= ~((1 << 15) | (1 << 13));
20         if (enable_b) {
21                 /* Enable secondary ide interface */
22                 word |= (1<<0);
23                 printk_debug("IDE1 ");
24         }
25         if (enable_a) {
26                 /* Enable primary ide interface */
27                 word |= (1<<1);
28                 printk_debug("IDE0 ");
29         }
30
31         word |= (1<<12);
32         word |= (1<<14);
33
34         pci_write_config16(dev, 0x40, word);
35
36         word = 0x0f;
37         pci_write_config16(dev, 0x42, word);
38
39         /* The AMD768 has a bug where the BM DMA address must be
40          * 256 byte aligned while it is only 16 bytes long.
41          * Hard code this to a valid address below 0x1000
42          * where automatic port address assignment starts.
43          * FIXME: I assume the 8111 does the same thing. We should
44          * clarify. stepan@suse.de
45          */
46         pci_write_config32(dev, 0x20, 0xf01);
47
48         pci_write_config32(dev, 0x48, 0x205e5e5e);
49         word = 0x06a;
50         pci_write_config16(dev, 0x4c, word);
51 }
52
53 static struct device_operations ide_ops  = {
54         .read_resources   = pci_dev_read_resources,
55         .set_resources    = pci_dev_set_resources,
56         .enable_resources = pci_dev_enable_resources,
57         .init             = ide_init,
58         .scan_bus         = 0,
59 };
60
61 static struct pci_driver ide_driver __pci_driver = {
62         .ops    = &ide_ops,
63         .vendor = PCI_VENDOR_ID_AMD,
64         .device = PCI_DEVICE_ID_AMD_8111_IDE,
65 };
66