blob: 542c5944e15533a0c2220d5e1cdb9ed2c666f1ab [file] [log] [blame]
Yinghai Lu13f1c2a2005-07-08 02:49:49 +00001#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 Reinauer138be832010-02-27 01:50:21 +00006#include "i82801ex.h"
Yinghai Lu13f1c2a2005-07-08 02:49:49 +00007
8static void ide_init(struct device *dev)
9{
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000010 /* Enable IDE devices and timmings */
Stefan Reinauer966d0e62006-04-06 21:37:10 +000011 pci_write_config16(dev, 0x40, 0x0a307); // IDE0
12 pci_write_config16(dev, 0x42, 0x0a307); // IDE1
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000013 pci_write_config8(dev, 0x48, 0x05);
14 pci_write_config16(dev, 0x4a, 0x0101);
15 pci_write_config16(dev, 0x54, 0x5055);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000016 printk(BIOS_DEBUG, "IDE Enabled\n");
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000017}
18
Stefan Reinauer138be832010-02-27 01:50:21 +000019static void i82801ex_ide_set_subsystem(device_t dev, unsigned vendor, unsigned device)
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000020{
21 /* This value is also visible in uchi[0-2] and smbus functions */
Stefan Reinauer14e22772010-04-27 06:56:47 +000022 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000023 ((device & 0xffff) << 16) | (vendor & 0xffff));
24}
25
26static struct pci_operations lops_pci = {
Stefan Reinauer138be832010-02-27 01:50:21 +000027 .set_subsystem = i82801ex_ide_set_subsystem,
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000028};
29static 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 Reinauerf1cf1f72007-10-24 09:08:58 +000038static const struct pci_driver ide_driver __pci_driver = {
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000039 .ops = &ide_ops,
40 .vendor = PCI_VENDOR_ID_INTEL,
41 .device = PCI_DEVICE_ID_INTEL_82801ER_IDE,
42};