Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 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 "esb6300.h" |
| 7 | |
| 8 | static void sata_init(struct device *dev) |
| 9 | { |
| 10 | |
| 11 | /* Enable sata devices so the linux sata driver will work */ |
| 12 | uint16_t word; |
| 13 | |
| 14 | /* Enable SATA devices */ |
| 15 | |
| 16 | printk_debug("SATA init\n"); |
| 17 | /* SATA configuration */ |
| 18 | pci_write_config8(dev, 0x04, 0x07); |
| 19 | pci_write_config8(dev, 0x09, 0x8f); |
| 20 | |
| 21 | /* Set timmings */ |
| 22 | pci_write_config16(dev, 0x40, 0x0a307); |
| 23 | pci_write_config16(dev, 0x42, 0x0a307); |
| 24 | |
| 25 | /* Sync DMA */ |
| 26 | pci_write_config16(dev, 0x48, 0x000f); |
| 27 | pci_write_config16(dev, 0x4a, 0x1111); |
| 28 | |
| 29 | /* 66 mhz */ |
| 30 | pci_write_config16(dev, 0x54, 0xf00f); |
| 31 | |
| 32 | /* Combine ide - sata configuration */ |
| 33 | pci_write_config8(dev, 0x90, 0x0); |
| 34 | |
| 35 | /* port 0 & 1 enable */ |
| 36 | pci_write_config8(dev, 0x92, 0x33); |
| 37 | |
| 38 | /* initialize SATA */ |
| 39 | pci_write_config16(dev, 0xa0, 0x0018); |
| 40 | pci_write_config32(dev, 0xa4, 0x00000264); |
| 41 | pci_write_config16(dev, 0xa0, 0x0040); |
| 42 | pci_write_config32(dev, 0xa4, 0x00220043); |
| 43 | |
| 44 | printk_debug("SATA Enabled\n"); |
| 45 | } |
| 46 | |
| 47 | static void esb6300_sata_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 48 | { |
| 49 | /* This value is also visible in usb1, usb2 and smbus functions */ |
| 50 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 51 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 52 | } |
| 53 | |
| 54 | static struct pci_operations lops_pci = { |
| 55 | .set_subsystem = esb6300_sata_set_subsystem, |
| 56 | }; |
| 57 | static struct device_operations sata_ops = { |
| 58 | .read_resources = pci_dev_read_resources, |
| 59 | .set_resources = pci_dev_set_resources, |
| 60 | .enable_resources = pci_dev_enable_resources, |
| 61 | .init = sata_init, |
| 62 | .scan_bus = 0, |
| 63 | .ops_pci = &lops_pci, |
| 64 | }; |
| 65 | |
Stefan Reinauer | f1cf1f7 | 2007-10-24 09:08:58 +0000 | [diff] [blame] | 66 | static const struct pci_driver sata_driver __pci_driver = { |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 67 | .ops = &sata_ops, |
| 68 | .vendor = PCI_VENDOR_ID_INTEL, |
| 69 | .device = PCI_DEVICE_ID_INTEL_6300ESB_SATA, |
| 70 | }; |
| 71 | |
Stefan Reinauer | f1cf1f7 | 2007-10-24 09:08:58 +0000 | [diff] [blame] | 72 | static const struct pci_driver sata_driver_nr __pci_driver = { |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 73 | .ops = &sata_ops, |
| 74 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | b294582 | 2007-11-07 00:19:42 +0000 | [diff] [blame] | 75 | .device = PCI_DEVICE_ID_INTEL_6300ESB_SATA_RAID, |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 76 | }; |
| 77 | |