printk_foo -> printk(BIOS_FOO, ...)
[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         struct southbridge_amd_amd8111_config *conf;
11         /* Enable ide devices so the linux ide driver will work */
12         uint16_t word;
13         uint8_t byte;
14         conf = dev->chip_info;
15
16         word = pci_read_config16(dev, 0x40);
17         /* Ensure prefetch is disabled */
18         word &= ~((1 << 15) | (1 << 13));
19         if (conf->ide1_enable) {
20                 /* Enable secondary ide interface */
21                 word |= (1<<0);
22                 printk(BIOS_DEBUG, "IDE1 ");
23         }
24         if (conf->ide0_enable) {
25                 /* Enable primary ide interface */
26                 word |= (1<<1);
27                 printk(BIOS_DEBUG, "IDE0 ");
28         }
29
30         word |= (1<<12);
31         word |= (1<<14);
32
33         pci_write_config16(dev, 0x40, word);
34
35
36         byte = 0x20 ; // Latency: 64-->32
37         pci_write_config8(dev, 0xd, byte);
38
39         word = 0x0f;
40         pci_write_config16(dev, 0x42, word);
41 }
42
43 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
44 {
45         pci_write_config32(dev, 0x70, 
46                 ((device & 0xffff) << 16) | (vendor & 0xffff));
47 }
48 static struct pci_operations lops_pci = {
49         .set_subsystem = lpci_set_subsystem,
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         .enable           = amd8111_enable,
58         .ops_pci          = &lops_pci
59 };
60
61 static const 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