d9eba3c5a116d8cd8cf74591ca5d6685afeb3afa
[coreboot.git] / src / southbridge / intel / i82801er / i82801er_sata.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 "i82801er.h"
7
8 static void sata_init(struct device *dev)
9 {
10
11         uint16_t word;
12
13   printk_debug("SATA init\n");
14         /* SATA configuration */
15         pci_write_config8(dev, 0x04, 0x07);
16         pci_write_config8(dev, 0x09, 0x8f);
17         
18         /* Set timmings */
19         pci_write_config16(dev, 0x40, 0x0a307);
20         pci_write_config16(dev, 0x42, 0x0a307);
21
22         /* Sync DMA */
23         pci_write_config16(dev, 0x48, 0x000f);
24         pci_write_config16(dev, 0x4a, 0x1111);
25
26         /* 66 mhz */
27         pci_write_config16(dev, 0x54, 0xf00f);
28
29         /* Combine ide - sata configuration */
30         pci_write_config8(dev, 0x90, 0x0);
31         
32         /* port 0 & 1 enable */
33         pci_write_config8(dev, 0x92, 0x33);
34         
35         /* initialize SATA  */
36         pci_write_config16(dev, 0xa0, 0x0018);
37         pci_write_config32(dev, 0xa4, 0x00000264);
38         pci_write_config16(dev, 0xa0, 0x0040);
39         pci_write_config32(dev, 0xa4, 0x00220043);
40
41 }
42
43 static struct device_operations sata_ops  = {
44         .read_resources   = pci_dev_read_resources,
45         .set_resources    = pci_dev_set_resources,
46         .enable_resources = pci_dev_enable_resources,
47         .init             = sata_init,
48         .scan_bus         = 0,
49         .ops_pci          = 0,
50 };
51
52 static struct pci_driver sata_driver __pci_driver = {
53         .ops    = &sata_ops,
54         .vendor = PCI_VENDOR_ID_INTEL,
55         .device = PCI_DEVICE_ID_INTEL_82801ER_1F2_R,
56 };
57
58 static struct pci_driver sata_driver_nr __pci_driver = {
59         .ops    = &sata_ops,
60         .vendor = PCI_VENDOR_ID_INTEL,
61         .device = PCI_DEVICE_ID_INTEL_82801ER_1F2,
62 };
63