Ever wondered where those "setting incorrect section attributes for
[coreboot.git] / src / southbridge / nvidia / ck804 / ck804_ide.c
1 /*
2  * Copyright 2004 Tyan Computer
3  *  by yhlu@tyan.com
4  */
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 "ck804.h"
12
13 static void ide_init(struct device *dev)
14 {
15         struct southbridge_nvidia_ck804_config *conf;
16         /* Enable ide devices so the linux ide driver will work */
17         uint32_t dword;
18         uint16_t word;
19         uint8_t byte;
20         conf = dev->chip_info;
21
22         word = pci_read_config16(dev, 0x50);
23         /* Ensure prefetch is disabled */
24         word &= ~((1 << 15) | (1 << 13));
25         if (conf->ide1_enable) {
26                 /* Enable secondary ide interface */
27                 word |= (1<<0);
28                 printk_debug("IDE1 \t");
29         }
30         if (conf->ide0_enable) {
31                 /* Enable primary ide interface */
32                 word |= (1<<1);
33                 printk_debug("IDE0\n");
34         }
35
36         word |= (1<<12);
37         word |= (1<<14);
38
39         pci_write_config16(dev, 0x50, word);
40
41
42         byte = 0x20 ; // Latency: 64-->32
43         pci_write_config8(dev, 0xd, byte);
44
45         dword = pci_read_config32(dev, 0xf8);
46         dword |= 12; 
47         pci_write_config32(dev, 0xf8, dword);
48 #if CONFIG_PCI_ROM_RUN == 1
49         pci_dev_init(dev);
50 #endif
51
52 }
53
54 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
55 {
56         pci_write_config32(dev, 0x40,
57                 ((device & 0xffff) << 16) | (vendor & 0xffff));
58 }
59 static struct pci_operations lops_pci = {
60         .set_subsystem = lpci_set_subsystem,
61 };
62
63 static struct device_operations ide_ops  = {
64         .read_resources   = pci_dev_read_resources,
65         .set_resources    = pci_dev_set_resources,
66         .enable_resources = pci_dev_enable_resources,
67         .init             = ide_init,
68         .scan_bus         = 0,
69 //      .enable           = ck804_enable,
70         .ops_pci          = &lops_pci,
71 };
72
73 static const struct pci_driver ide_driver __pci_driver = {
74         .ops    = &ide_ops,
75         .vendor = PCI_VENDOR_ID_NVIDIA,
76         .device = PCI_DEVICE_ID_NVIDIA_CK804_IDE,
77 };
78