We define IO_APIC_ADDR in <arch/ioapic.h>, let's use it.
[coreboot.git] / src / southbridge / intel / esb6300 / esb6300_pic.c
1 /*
2  * (C) 2004 Linux Networx
3  */
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/pci.h>
7 #include <device/pci_ids.h>
8 #include <device/pci_ops.h>
9 #include <arch/ioapic.h>
10 #include "esb6300.h"
11
12 static void pic_init(struct device *dev)
13 {
14
15         uint16_t word;
16
17         /* Clear system errors */
18         word = pci_read_config16(dev, 0x06);
19         word |= 0xf900; /* Clear possible errors */
20         pci_write_config16(dev, 0x06, word);
21
22         /* enable interrupt lines */
23         pci_write_config8(dev, 0x3c, 0xff);
24
25         /* Setup the ioapic */
26         clear_ioapic(IO_APIC_ADDR + 0x10000);
27 }
28
29 static void pic_read_resources(device_t dev)
30 {
31         struct resource *res;
32
33         /* Get the normal pci resources of this device */
34         pci_dev_read_resources(dev);
35
36         /* Report the pic1 mbar resource */
37         res = new_resource(dev, 0x44);
38         res->base  = IO_APIC_ADDR + 0x10000;
39         res->size  = 256;
40         res->limit = res->base + res->size -1;
41         res->align = 8;
42         res->gran  = 8;
43         res->flags = IORESOURCE_MEM | IORESOURCE_FIXED |
44                 IORESOURCE_STORED | IORESOURCE_ASSIGNED;
45         dev->command |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
46 }
47
48 static struct pci_operations lops_pci = {
49         /* Can we set the pci subsystem and device id? */
50         .set_subsystem = 0,
51 };
52
53 static struct device_operations pci_ops  = {
54         .read_resources   = pic_read_resources,
55         .set_resources    = pci_dev_set_resources,
56         .enable_resources = pci_dev_enable_resources,
57         .init             = pic_init,
58         .scan_bus         = 0,
59         .enable           = esb6300_enable,
60         .ops_pci          = &lops_pci,
61 };
62
63 static const struct pci_driver pci_driver __pci_driver = {
64         .ops    = &pci_ops,
65         .vendor = PCI_VENDOR_ID_INTEL,
66         .device = PCI_DEVICE_ID_INTEL_6300ESB_APIC1,
67 };
68