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> |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame] | 6 | #include "i82801ex.h" |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 7 | |
| 8 | static void ide_init(struct device *dev) |
| 9 | { |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 10 | /* Enable IDE devices and timmings */ |
Stefan Reinauer | 966d0e6 | 2006-04-06 21:37:10 +0000 | [diff] [blame] | 11 | pci_write_config16(dev, 0x40, 0x0a307); // IDE0 |
| 12 | pci_write_config16(dev, 0x42, 0x0a307); // IDE1 |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 13 | pci_write_config8(dev, 0x48, 0x05); |
| 14 | pci_write_config16(dev, 0x4a, 0x0101); |
| 15 | pci_write_config16(dev, 0x54, 0x5055); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 16 | printk(BIOS_DEBUG, "IDE Enabled\n"); |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 17 | } |
| 18 | |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame] | 19 | static void i82801ex_ide_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 20 | { |
| 21 | /* This value is also visible in uchi[0-2] and smbus functions */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 22 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 23 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 24 | } |
| 25 | |
| 26 | static struct pci_operations lops_pci = { |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame] | 27 | .set_subsystem = i82801ex_ide_set_subsystem, |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 28 | }; |
| 29 | static struct device_operations ide_ops = { |
| 30 | .read_resources = pci_dev_read_resources, |
| 31 | .set_resources = pci_dev_set_resources, |
| 32 | .enable_resources = pci_dev_enable_resources, |
| 33 | .init = ide_init, |
| 34 | .scan_bus = 0, |
| 35 | .ops_pci = &lops_pci, |
| 36 | }; |
| 37 | |
Stefan Reinauer | f1cf1f7 | 2007-10-24 09:08:58 +0000 | [diff] [blame] | 38 | static const struct pci_driver ide_driver __pci_driver = { |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 39 | .ops = &ide_ops, |
| 40 | .vendor = PCI_VENDOR_ID_INTEL, |
| 41 | .device = PCI_DEVICE_ID_INTEL_82801ER_IDE, |
| 42 | }; |