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