2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <console/console.h>
23 #include <device/device.h>
24 #include <device/pci.h>
25 #include <device/pci_ids.h>
26 #include <pc80/isa-dma.h>
27 #include <pc80/mc146818rtc.h>
28 #include <arch/ioapic.h>
32 static void enable_intel_82093aa_ioapic(void)
37 volatile u32 *ioapic_index = (volatile u32 *)(IO_APIC_ADDR);
38 volatile u32 *ioapic_data = (volatile u32 *)(IO_APIC_ADDR + 0x10);
41 dev = dev_find_device(PCI_VENDOR_ID_INTEL,
42 PCI_DEVICE_ID_INTEL_82371AB_ISA, 0);
45 reg16 = pci_read_config16(dev, XBCS);
46 reg16 |= (1 << 8); /* APIC Chip Select */
47 pci_write_config16(dev, XBCS, reg16);
49 /* Set the IOAPIC ID. */
51 *ioapic_data = ioapic_id << 24;
53 /* Read back and verify the IOAPIC ID. */
55 reg32 = (*ioapic_data >> 24) & 0x0f;
56 printk(BIOS_DEBUG, "IOAPIC ID = %x\n", reg32);
57 if (reg32 != ioapic_id)
58 die("IOAPIC error!\n");
62 static void isa_init(struct device *dev)
66 /* Initialize the real time clock (RTC). */
70 * Enable special cycles, needed for soft poweroff.
72 reg32 = pci_read_config16(dev, PCI_COMMAND);
73 reg32 |= PCI_COMMAND_SPECIAL;
74 pci_write_config16(dev, PCI_COMMAND, reg32);
77 * The PIIX4 can support the full ISA bus, or the Extended I/O (EIO)
78 * bus, which is a subset of ISA. We select the full ISA bus here.
80 reg32 = pci_read_config32(dev, GENCFG);
81 reg32 |= ISA; /* Select ISA, not EIO. */
82 pci_write_config16(dev, GENCFG, reg32);
84 /* Initialize ISA DMA. */
89 * Unlike most other southbridges the 82371EB doesn't have a built-in
90 * IOAPIC. Instead, 82371EB-based boards that support multiple CPUs
91 * have a discrete IOAPIC (Intel 82093AA) soldered onto the board.
93 * Thus, we can/must only enable the IOAPIC if it actually exists,
94 * i.e. the respective mainboard does "select IOAPIC".
96 enable_intel_82093aa_ioapic();
100 static void sb_read_resources(struct device *dev)
102 struct resource *res;
104 pci_dev_read_resources(dev);
106 res = new_resource(dev, 1);
108 res->size = 0x1000UL;
109 res->limit = 0xffffUL;
110 res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
112 res = new_resource(dev, 2);
113 res->base = 0xff800000UL;
114 res->size = 0x00800000UL; /* 8 MB for flash */
115 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED |
119 res = new_resource(dev, 3); /* IOAPIC */
120 res->base = IO_APIC_ADDR;
121 res->size = 0x00001000;
122 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED |
127 static const struct device_operations isa_ops = {
128 .read_resources = sb_read_resources,
129 .set_resources = pci_dev_set_resources,
130 .enable_resources = pci_dev_enable_resources,
132 .scan_bus = scan_static_bus, /* TODO: Needed? */
134 .ops_pci = 0, /* No subsystem IDs on 82371EB! */
137 static const struct pci_driver isa_driver __pci_driver = {
139 .vendor = PCI_VENDOR_ID_INTEL,
140 .device = PCI_DEVICE_ID_INTEL_82371AB_ISA,
143 static const struct pci_driver isa_SB_driver __pci_driver = {
145 .vendor = PCI_VENDOR_ID_INTEL,
146 .device = PCI_DEVICE_ID_INTEL_82371SB_ISA,