coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
isa.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <stdint.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/pci.h>
7 #include <device/pci_ops.h>
8 #include <device/pci_ids.h>
9 #include <pc80/isa-dma.h>
10 #include <pc80/mc146818rtc.h>
11 #include <arch/ioapic.h>
12 #if CONFIG(HAVE_ACPI_TABLES)
13 #include <acpi/acpi.h>
14 #include <acpi/acpigen.h>
15 #endif
16 #include "i82371eb.h"
17 #include "chip.h"
18 
19 static void isa_init(struct device *dev)
20 {
21  u32 reg32;
23 
24  /* Initialize the real time clock (RTC). */
25  cmos_init(0);
26 
27  /*
28  * Enable special cycles, needed for soft poweroff.
29  */
31 
32  /*
33  * The PIIX4 can support the full ISA bus, or the Extended I/O (EIO)
34  * bus, which is a subset of ISA. We select the full ISA bus here.
35  */
36  reg32 = pci_read_config32(dev, GENCFG);
37  reg32 |= ISA; /* Select ISA, not EIO. */
38 
39  /* Some boards use GPO22/23. Select it if configured. */
40  reg32 = ONOFF(sb->gpo22_enable, reg32, GPO2223);
41  pci_write_config32(dev, GENCFG, reg32);
42 
43  /* Initialize ISA DMA. */
44  isa_dma_init();
45 
46  /*
47  * Unlike most other southbridges the 82371EB doesn't have a built-in
48  * IOAPIC. Instead, 82371EB-based boards that support multiple CPUs
49  * have a discrete IOAPIC (Intel 82093AA) soldered onto the board.
50  *
51  * Thus, we can/must only enable the IOAPIC if it actually exists,
52  * i.e. the respective mainboard does "select IOAPIC".
53  */
54  if (CONFIG(IOAPIC)) {
55  u16 reg16;
56  u8 ioapic_id = 2;
57 
58  /* Enable IOAPIC. */
59  reg16 = pci_read_config16(dev, XBCS);
60  reg16 |= (1 << 8); /* APIC Chip Select */
61  pci_write_config16(dev, XBCS, reg16);
62 
63  /* Set and verify the IOAPIC ID. */
64  setup_ioapic(VIO_APIC_VADDR, ioapic_id);
65  if (ioapic_id != get_ioapic_id(VIO_APIC_VADDR))
66  die("IOAPIC error!\n");
67  }
68 }
69 
70 static void sb_read_resources(struct device *dev)
71 {
72  struct resource *res;
73 
75 
76  res = new_resource(dev, 1);
77  res->base = 0x0UL;
78  res->size = 0x1000UL;
79  res->limit = 0xffffUL;
81 
82  res = new_resource(dev, 2);
83  res->base = 0xff800000UL;
84  res->size = 0x00800000UL; /* 8 MB for flash */
87 
88  res = new_resource(dev, 3); /* IOAPIC */
89  res->base = IO_APIC_ADDR;
90  res->size = 0x00001000;
93 }
94 
95 static const struct device_operations isa_ops = {
97  .set_resources = pci_dev_set_resources,
98  .enable_resources = pci_dev_enable_resources,
99 #if CONFIG(HAVE_ACPI_TABLES)
100  .write_acpi_tables = acpi_write_hpet,
101  .acpi_fill_ssdt = generate_cpu_entries,
102 #endif
103  .init = isa_init,
104  .scan_bus = scan_static_bus,
105  .ops_pci = 0, /* No subsystem IDs on 82371EB! */
106 };
107 
108 static const struct pci_driver isa_driver __pci_driver = {
109  .ops = &isa_ops,
110  .vendor = PCI_VID_INTEL,
111  .device = PCI_DID_INTEL_82371AB_ISA,
112 };
113 
114 static const struct pci_driver isa_SB_driver __pci_driver = {
115  .ops = &isa_ops,
116  .vendor = PCI_VID_INTEL,
117  .device = PCI_DID_INTEL_82371SB_ISA,
118 };
unsigned long acpi_write_hpet(const struct device *device, unsigned long current, acpi_rsdp_t *rsdp)
Definition: acpi.c:1141
u8 get_ioapic_id(void *ioapic_base)
Definition: ioapic.c:133
#define VIO_APIC_VADDR
Definition: ioapic.h:7
#define IO_APIC_ADDR
Definition: ioapic.h:6
void setup_ioapic(void *ioapic_base, u8 ioapic_id)
Definition: ioapic.c:160
void __noreturn die(const char *fmt,...)
Definition: die.c:17
void generate_cpu_entries(const struct device *device)
Definition: acpi.c:334
struct resource * new_resource(struct device *dev, unsigned int index)
See if a resource structure already exists for a given index and if not allocate one.
Definition: device_util.c:346
@ CONFIG
Definition: dsi_common.h:201
#define ONOFF(cond, reg, bits)
Definition: i82371eb.h:21
#define ISA
Definition: i82371eb.h:118
#define GENCFG
Definition: i82371eb.h:24
#define XBCS
Definition: i82371eb.h:23
#define GPO2223
Definition: i82371eb.h:25
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
Definition: pci_ops.h:180
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static __always_inline void pci_write_config16(const struct device *dev, u16 reg, u16 val)
Definition: pci_ops.h:70
void isa_dma_init(void)
Definition: isa-dma.c:35
static void isa_init(struct device *dev)
Definition: isa.c:19
static void sb_read_resources(struct device *dev)
Definition: isa.c:70
static const struct device_operations isa_ops
Definition: isa.c:95
static const struct pci_driver isa_driver __pci_driver
Definition: isa.c:108
void cmos_init(bool invalid)
Definition: mc146818rtc.c:156
#define PCI_COMMAND_SPECIAL
Definition: pci_def.h:14
#define PCI_COMMAND
Definition: pci_def.h:10
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721
void pci_dev_read_resources(struct device *dev)
Definition: pci_device.c:534
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
#define PCI_DID_INTEL_82371SB_ISA
Definition: pci_ids.h:2191
#define PCI_DID_INTEL_82371AB_ISA
Definition: pci_ids.h:2203
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
#define IORESOURCE_RESERVE
Definition: resource.h:30
#define IORESOURCE_MEM
Definition: resource.h:10
#define IORESOURCE_ASSIGNED
Definition: resource.h:34
#define IORESOURCE_IO
Definition: resource.h:9
#define IORESOURCE_FIXED
Definition: resource.h:36
void scan_static_bus(struct device *bus)
Definition: root_device.c:89
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107
DEVTREE_CONST void * chip_info
Definition: device.h:164
unsigned long flags
Definition: resource.h:49
resource_t limit
Definition: resource.h:47
resource_t base
Definition: resource.h:45
resource_t size
Definition: resource.h:46