Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de> |
| 5 | * |
| 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. |
| 10 | * |
| 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. |
| 15 | * |
| 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 |
| 19 | */ |
| 20 | |
| 21 | #include <stdint.h> |
| 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> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 28 | #include <arch/ioapic.h> |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 29 | #include "i82371eb.h" |
| 30 | |
Uwe Hermann | b34ff66 | 2010-10-28 14:22:20 +0000 | [diff] [blame^] | 31 | #if CONFIG_IOAPIC |
Uwe Hermann | 7718054 | 2010-10-28 08:19:22 +0000 | [diff] [blame] | 32 | static void enable_intel_82093aa_ioapic(void) |
| 33 | { |
| 34 | u16 reg16; |
| 35 | u32 reg32; |
| 36 | u8 ioapic_id = 2; |
| 37 | volatile u32 *ioapic_index = (volatile u32 *)(IO_APIC_ADDR); |
| 38 | volatile u32 *ioapic_data = (volatile u32 *)(IO_APIC_ADDR + 0x10); |
| 39 | device_t dev; |
| 40 | |
| 41 | dev = dev_find_device(PCI_VENDOR_ID_INTEL, |
| 42 | PCI_DEVICE_ID_INTEL_82371AB_ISA, 0); |
| 43 | |
| 44 | /* Enable IOAPIC. */ |
| 45 | reg16 = pci_read_config16(dev, XBCS); |
| 46 | reg16 |= (1 << 8); /* APIC Chip Select */ |
| 47 | pci_write_config16(dev, XBCS, reg16); |
| 48 | |
| 49 | /* Set the IOAPIC ID. */ |
| 50 | *ioapic_index = 0; |
| 51 | *ioapic_data = ioapic_id << 24; |
| 52 | |
| 53 | /* Read back and verify the IOAPIC ID. */ |
| 54 | *ioapic_index = 0; |
| 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"); |
| 59 | } |
Uwe Hermann | b34ff66 | 2010-10-28 14:22:20 +0000 | [diff] [blame^] | 60 | #endif |
Uwe Hermann | 7718054 | 2010-10-28 08:19:22 +0000 | [diff] [blame] | 61 | |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 62 | static void isa_init(struct device *dev) |
| 63 | { |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 64 | u32 reg32; |
| 65 | |
| 66 | /* Initialize the real time clock (RTC). */ |
| 67 | rtc_init(0); |
| 68 | |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 69 | /* |
| 70 | * The PIIX4 can support the full ISA bus, or the Extended I/O (EIO) |
| 71 | * bus, which is a subset of ISA. We select the full ISA bus here. |
| 72 | */ |
| 73 | reg32 = pci_read_config32(dev, GENCFG); |
| 74 | reg32 |= ISA; /* Select ISA, not EIO. */ |
| 75 | pci_write_config16(dev, GENCFG, reg32); |
| 76 | |
| 77 | /* Initialize ISA DMA. */ |
| 78 | isa_dma_init(); |
Uwe Hermann | 7718054 | 2010-10-28 08:19:22 +0000 | [diff] [blame] | 79 | |
| 80 | #if CONFIG_IOAPIC |
| 81 | /* |
| 82 | * Unlike most other southbridges the 82371EB doesn't have a built-in |
| 83 | * IOAPIC. Instead, 82371EB-based boards that support multiple CPUs |
| 84 | * have a discrete IOAPIC (Intel 82093AA) soldered onto the board. |
| 85 | * |
| 86 | * Thus, we can/must only enable the IOAPIC if it actually exists, |
| 87 | * i.e. the respective mainboard does "select IOAPIC". |
| 88 | */ |
| 89 | enable_intel_82093aa_ioapic(); |
| 90 | #endif |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 93 | static void sb_read_resources(struct device *dev) |
| 94 | { |
| 95 | struct resource *res; |
| 96 | |
| 97 | pci_dev_read_resources(dev); |
| 98 | |
| 99 | res = new_resource(dev, 1); |
| 100 | res->base = 0x0UL; |
| 101 | res->size = 0x1000UL; |
| 102 | res->limit = 0xffffUL; |
| 103 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 104 | |
| 105 | res = new_resource(dev, 2); |
| 106 | res->base = 0xff800000UL; |
| 107 | res->size = 0x00800000UL; /* 8 MB for flash */ |
| 108 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 109 | |
| 110 | res = new_resource(dev, 3); /* IOAPIC */ |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 111 | res->base = IO_APIC_ADDR; |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 112 | res->size = 0x00001000; |
| 113 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 114 | } |
| 115 | |
Uwe Hermann | 312673c | 2009-10-27 21:49:33 +0000 | [diff] [blame] | 116 | static const struct device_operations isa_ops = { |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 117 | .read_resources = sb_read_resources, |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 118 | .set_resources = pci_dev_set_resources, |
| 119 | .enable_resources = pci_dev_enable_resources, |
| 120 | .init = isa_init, |
| 121 | .scan_bus = scan_static_bus, /* TODO: Needed? */ |
| 122 | .enable = 0, |
| 123 | .ops_pci = 0, /* No subsystem IDs on 82371EB! */ |
| 124 | }; |
| 125 | |
| 126 | static const struct pci_driver isa_driver __pci_driver = { |
| 127 | .ops = &isa_ops, |
| 128 | .vendor = PCI_VENDOR_ID_INTEL, |
| 129 | .device = PCI_DEVICE_ID_INTEL_82371AB_ISA, |
| 130 | }; |
Myles Watson | 0520d55 | 2009-05-11 22:44:14 +0000 | [diff] [blame] | 131 | |
| 132 | static const struct pci_driver isa_SB_driver __pci_driver = { |
| 133 | .ops = &isa_ops, |
| 134 | .vendor = PCI_VENDOR_ID_INTEL, |
| 135 | .device = PCI_DEVICE_ID_INTEL_82371SB_ISA, |
| 136 | }; |