Angel Pons | 585495e | 2020-04-03 01:21:38 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | b28f466 | 2018-05-26 17:58:47 -0600 | [diff] [blame] | 2 | |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 3 | #include <console/console.h> |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 4 | #include <cpu/cpu.h> |
Patrick Georgi | c8feedd | 2012-02-16 18:43:25 +0100 | [diff] [blame] | 5 | #include <cpu/x86/lapic_def.h> |
Arthur Heymans | a75a2fa | 2020-12-01 15:20:10 +0100 | [diff] [blame] | 6 | #include <cpu/x86/mp.h> |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 7 | #include <arch/io.h> |
Elyes HAOUAS | ed69de3 | 2019-12-19 17:36:53 +0100 | [diff] [blame] | 8 | #include <device/pci_def.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 9 | #include <device/pci_ops.h> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 10 | #include <arch/ioapic.h> |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 11 | #include <stdint.h> |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 12 | #include <device/device.h> |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 13 | #include <stdlib.h> |
| 14 | #include <string.h> |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 15 | #include <smbios.h> |
Patrick Rudolph | 69d5ef9 | 2018-11-11 12:43:48 +0100 | [diff] [blame] | 16 | #include "memory.h" |
Myles Watson | 0520d55 | 2009-05-11 22:44:14 +0000 | [diff] [blame] | 17 | |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 18 | #include "fw_cfg.h" |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 19 | #include "fw_cfg_if.h" |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 20 | |
Vladimir Serbinenko | 41877d8 | 2014-09-01 22:18:01 +0200 | [diff] [blame] | 21 | #include "acpi.h" |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 22 | |
Gerd Hoffmann | 05d3f49 | 2013-08-06 10:48:41 +0200 | [diff] [blame] | 23 | static void qemu_reserve_ports(struct device *dev, unsigned int idx, |
| 24 | unsigned int base, unsigned int size, |
| 25 | const char *name) |
| 26 | { |
| 27 | unsigned int end = base + size -1; |
| 28 | struct resource *res; |
| 29 | |
| 30 | printk(BIOS_DEBUG, "QEMU: reserve ioports 0x%04x-0x%04x [%s]\n", |
| 31 | base, end, name); |
| 32 | res = new_resource(dev, idx); |
| 33 | res->base = base; |
| 34 | res->size = size; |
| 35 | res->limit = 0xffff; |
| 36 | res->flags = IORESOURCE_IO | IORESOURCE_FIXED | IORESOURCE_STORED | |
| 37 | IORESOURCE_ASSIGNED; |
| 38 | } |
| 39 | |
Kyösti Mälkki | ccb9502 | 2018-05-22 00:16:23 +0300 | [diff] [blame] | 40 | static void cpu_pci_domain_set_resources(struct device *dev) |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 41 | { |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 42 | assign_resources(dev->link_list); |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 43 | } |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 44 | |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 45 | static void cpu_pci_domain_read_resources(struct device *dev) |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 46 | { |
Kyösti Mälkki | 98a9174 | 2018-05-21 21:29:16 +0300 | [diff] [blame] | 47 | u16 nbid = pci_read_config16(pcidev_on_root(0x0, 0), PCI_DEVICE_ID); |
Gerd Hoffmann | a4e7057 | 2013-08-09 10:02:22 +0200 | [diff] [blame] | 48 | int i440fx = (nbid == 0x1237); |
Gerd Hoffmann | ad690f2 | 2013-09-17 10:35:43 +0200 | [diff] [blame] | 49 | int q35 = (nbid == 0x29c0); |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 50 | struct resource *res; |
Gerd Hoffmann | 9839a38 | 2013-06-17 12:26:17 +0200 | [diff] [blame] | 51 | unsigned long tomk = 0, high; |
Gerd Hoffmann | 44b11f2 | 2013-06-17 13:30:50 +0200 | [diff] [blame] | 52 | int idx = 10; |
Thomas Heijligen | bcd84fe | 2019-01-10 16:53:34 +0100 | [diff] [blame] | 53 | FWCfgFile f; |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 54 | |
| 55 | pci_domain_read_resources(dev); |
| 56 | |
Thomas Heijligen | bcd84fe | 2019-01-10 16:53:34 +0100 | [diff] [blame] | 57 | if (!fw_cfg_check_file(&f, "etc/e820") && f.size > 0) { |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 58 | /* supported by qemu 1.7+ */ |
Thomas Heijligen | bcd84fe | 2019-01-10 16:53:34 +0100 | [diff] [blame] | 59 | FwCfgE820Entry *list = malloc(f.size); |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 60 | int i; |
Thomas Heijligen | bcd84fe | 2019-01-10 16:53:34 +0100 | [diff] [blame] | 61 | fw_cfg_get(f.select, list, f.size); |
| 62 | for (i = 0; i < f.size / sizeof(*list); i++) { |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 63 | switch (list[i].type) { |
Elyes HAOUAS | 8ab989e | 2016-07-30 17:46:17 +0200 | [diff] [blame] | 64 | case 1: /* RAM */ |
Himanshu Sahdev | 660ff20 | 2019-09-10 16:15:41 +0530 | [diff] [blame] | 65 | printk(BIOS_DEBUG, "QEMU: e820/ram: 0x%08llx + 0x%08llx\n", |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 66 | list[i].address, list[i].length); |
| 67 | if (list[i].address == 0) { |
| 68 | tomk = list[i].length / 1024; |
| 69 | ram_resource(dev, idx++, 0, 640); |
| 70 | ram_resource(dev, idx++, 768, tomk - 768); |
| 71 | } else { |
| 72 | ram_resource(dev, idx++, |
| 73 | list[i].address / 1024, |
| 74 | list[i].length / 1024); |
| 75 | } |
| 76 | break; |
| 77 | case 2: /* reserved */ |
| 78 | printk(BIOS_DEBUG, "QEMU: e820/res: 0x%08llx +0x%08llx\n", |
| 79 | list[i].address, list[i].length); |
| 80 | res = new_resource(dev, idx++); |
| 81 | res->base = list[i].address; |
| 82 | res->size = list[i].length; |
| 83 | res->limit = 0xffffffff; |
| 84 | res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | |
| 85 | IORESOURCE_STORED | IORESOURCE_ASSIGNED; |
| 86 | break; |
| 87 | default: |
| 88 | /* skip unknown */ |
| 89 | break; |
| 90 | } |
| 91 | } |
| 92 | free(list); |
| 93 | } |
Gerd Hoffmann | 44b11f2 | 2013-06-17 13:30:50 +0200 | [diff] [blame] | 94 | |
Gerd Hoffmann | baa7820 | 2013-11-06 14:36:17 +0100 | [diff] [blame] | 95 | if (!tomk) { |
| 96 | /* qemu older than 1.7, or reading etc/e820 failed. Fallback to cmos. */ |
| 97 | tomk = qemu_get_memory_size(); |
| 98 | high = qemu_get_high_memory_size(); |
| 99 | printk(BIOS_DEBUG, "QEMU: cmos: %lu MiB RAM below 4G.\n", tomk / 1024); |
| 100 | printk(BIOS_DEBUG, "QEMU: cmos: %lu MiB RAM above 4G.\n", high / 1024); |
| 101 | |
| 102 | /* Report the memory regions. */ |
| 103 | ram_resource(dev, idx++, 0, 640); |
| 104 | ram_resource(dev, idx++, 768, tomk - 768); |
| 105 | if (high) |
| 106 | ram_resource(dev, idx++, 4 * 1024 * 1024, high); |
| 107 | } |
Gerd Hoffmann | 44b11f2 | 2013-06-17 13:30:50 +0200 | [diff] [blame] | 108 | |
Gerd Hoffmann | 05d3f49 | 2013-08-06 10:48:41 +0200 | [diff] [blame] | 109 | /* Reserve I/O ports used by QEMU */ |
| 110 | qemu_reserve_ports(dev, idx++, 0x0510, 0x02, "firmware-config"); |
| 111 | qemu_reserve_ports(dev, idx++, 0x5658, 0x01, "vmware-port"); |
| 112 | if (i440fx) { |
| 113 | qemu_reserve_ports(dev, idx++, 0xae00, 0x10, "pci-hotplug"); |
| 114 | qemu_reserve_ports(dev, idx++, 0xaf00, 0x20, "cpu-hotplug"); |
| 115 | qemu_reserve_ports(dev, idx++, 0xafe0, 0x04, "piix4-gpe0"); |
| 116 | } |
| 117 | if (inb(CONFIG_CONSOLE_QEMU_DEBUGCON_PORT) == 0xe9) { |
| 118 | qemu_reserve_ports(dev, idx++, CONFIG_CONSOLE_QEMU_DEBUGCON_PORT, 1, |
| 119 | "debugcon"); |
| 120 | } |
| 121 | |
Duncan Laurie | ddd4f9a | 2020-03-17 18:46:28 -0700 | [diff] [blame] | 122 | /* A segment is legacy VGA region */ |
| 123 | mmio_resource(dev, idx++, 0xa0000 / KiB, (0xc0000 - 0xa0000) / KiB); |
| 124 | |
| 125 | /* C segment to 1MB is reserved RAM (low tables) */ |
| 126 | reserved_ram_resource(dev, idx++, 0xc0000 / KiB, (1 * MiB - 0xc0000) / KiB); |
| 127 | |
Gerd Hoffmann | ad690f2 | 2013-09-17 10:35:43 +0200 | [diff] [blame] | 128 | if (q35 && ((tomk * 1024) < 0xb0000000)) { |
| 129 | /* |
| 130 | * Reserve the region between top-of-ram and the |
| 131 | * mmconf xbar (ar 0xb0000000), so coreboot doesn't |
| 132 | * place pci bars there. The region isn't declared as |
Elyes HAOUAS | 8ab989e | 2016-07-30 17:46:17 +0200 | [diff] [blame] | 133 | * pci io window in the ACPI tables (\_SB.PCI0._CRS). |
Gerd Hoffmann | ad690f2 | 2013-09-17 10:35:43 +0200 | [diff] [blame] | 134 | */ |
| 135 | res = new_resource(dev, idx++); |
| 136 | res->base = tomk * 1024; |
| 137 | res->size = 0xb0000000 - tomk * 1024; |
| 138 | res->limit = 0xffffffff; |
| 139 | res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | |
| 140 | IORESOURCE_STORED | IORESOURCE_ASSIGNED; |
| 141 | } |
| 142 | |
Gerd Hoffmann | a4e7057 | 2013-08-09 10:02:22 +0200 | [diff] [blame] | 143 | if (i440fx) { |
| 144 | /* Reserve space for the IOAPIC. This should be in |
Patrick Georgi | 3f34fc4 | 2013-08-15 20:41:15 +0200 | [diff] [blame] | 145 | * the southbridge, but I couldn't tell which device |
Gerd Hoffmann | a4e7057 | 2013-08-09 10:02:22 +0200 | [diff] [blame] | 146 | * to put it in. */ |
| 147 | res = new_resource(dev, 2); |
| 148 | res->base = IO_APIC_ADDR; |
| 149 | res->size = 0x100000UL; |
| 150 | res->limit = 0xffffffffUL; |
| 151 | res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | |
| 152 | IORESOURCE_STORED | IORESOURCE_ASSIGNED; |
| 153 | } |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 154 | |
| 155 | /* Reserve space for the LAPIC. There's one in every processor, but |
| 156 | * the space only needs to be reserved once, so we do it here. */ |
| 157 | res = new_resource(dev, 3); |
Patrick Georgi | c8feedd | 2012-02-16 18:43:25 +0100 | [diff] [blame] | 158 | res->base = LOCAL_APIC_ADDR; |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 159 | res->size = 0x10000UL; |
| 160 | res->limit = 0xffffffffUL; |
| 161 | res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED | |
| 162 | IORESOURCE_ASSIGNED; |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 163 | } |
| 164 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 165 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 166 | static int qemu_get_smbios_data16(int handle, unsigned long *current) |
| 167 | { |
| 168 | struct smbios_type16 *t = (struct smbios_type16 *)*current; |
| 169 | int len = sizeof(struct smbios_type16); |
| 170 | |
| 171 | memset(t, 0, sizeof(struct smbios_type16)); |
| 172 | t->type = SMBIOS_PHYS_MEMORY_ARRAY; |
| 173 | t->handle = handle; |
| 174 | t->length = len - 2; |
Paul Menzel | b4d0757 | 2017-03-12 18:18:06 +0100 | [diff] [blame] | 175 | t->location = MEMORY_ARRAY_LOCATION_SYSTEM_BOARD; |
| 176 | t->use = MEMORY_ARRAY_USE_SYSTEM; |
| 177 | t->memory_error_correction = MEMORY_ARRAY_ECC_NONE; |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 178 | t->maximum_capacity = qemu_get_memory_size(); |
| 179 | *current += len; |
| 180 | return len; |
| 181 | } |
| 182 | |
| 183 | static int qemu_get_smbios_data17(int handle, int parent_handle, unsigned long *current) |
| 184 | { |
| 185 | struct smbios_type17 *t = (struct smbios_type17 *)*current; |
| 186 | int len; |
| 187 | |
| 188 | memset(t, 0, sizeof(struct smbios_type17)); |
| 189 | t->type = SMBIOS_MEMORY_DEVICE; |
| 190 | t->handle = handle; |
| 191 | t->phys_memory_array_handle = parent_handle; |
| 192 | t->length = sizeof(struct smbios_type17) - 2; |
| 193 | t->size = qemu_get_memory_size() / 1024; |
| 194 | t->data_width = 64; |
| 195 | t->total_width = 64; |
Elyes HAOUAS | a92acec | 2020-07-19 10:20:55 +0200 | [diff] [blame] | 196 | t->form_factor = MEMORY_FORMFACTOR_DIMM; |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 197 | t->device_locator = smbios_add_string(t->eos, "Virtual"); |
Elyes HAOUAS | a92acec | 2020-07-19 10:20:55 +0200 | [diff] [blame] | 198 | t->memory_type = MEMORY_TYPE_DDR; |
| 199 | t->type_detail = MEMORY_TYPE_DETAIL_SYNCHRONOUS; |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 200 | t->speed = 200; |
| 201 | t->clock_speed = 200; |
| 202 | t->manufacturer = smbios_add_string(t->eos, CONFIG_MAINBOARD_VENDOR); |
| 203 | len = t->length + smbios_string_table_len(t->eos); |
| 204 | *current += len; |
| 205 | return len; |
| 206 | } |
| 207 | |
Kyösti Mälkki | ccb9502 | 2018-05-22 00:16:23 +0300 | [diff] [blame] | 208 | static int qemu_get_smbios_data(struct device *dev, int *handle, unsigned long *current) |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 209 | { |
| 210 | int len; |
Gerd Hoffmann | db9d169 | 2014-08-27 11:25:13 +0200 | [diff] [blame] | 211 | |
| 212 | len = fw_cfg_smbios_tables(handle, current); |
| 213 | if (len != 0) |
| 214 | return len; |
| 215 | |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 216 | len = qemu_get_smbios_data16(*handle, current); |
| 217 | len += qemu_get_smbios_data17(*handle+1, *handle, current); |
| 218 | *handle += 2; |
| 219 | return len; |
| 220 | } |
| 221 | #endif |
Duncan Laurie | b40e780 | 2020-03-17 18:47:36 -0700 | [diff] [blame] | 222 | |
| 223 | #if CONFIG(HAVE_ACPI_TABLES) |
| 224 | static const char *qemu_acpi_name(const struct device *dev) |
| 225 | { |
| 226 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 227 | return "PCI0"; |
| 228 | |
| 229 | if (dev->path.type != DEVICE_PATH_PCI || dev->bus->secondary != 0) |
| 230 | return NULL; |
| 231 | |
| 232 | return NULL; |
| 233 | } |
| 234 | #endif |
| 235 | |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 236 | static struct device_operations pci_domain_ops = { |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 237 | .read_resources = cpu_pci_domain_read_resources, |
| 238 | .set_resources = cpu_pci_domain_set_resources, |
Myles Watson | 032a965 | 2009-05-11 22:24:53 +0000 | [diff] [blame] | 239 | .scan_bus = pci_domain_scan_bus, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 240 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
Sven Schnelle | 164bcfd | 2011-08-14 20:56:34 +0200 | [diff] [blame] | 241 | .get_smbios_data = qemu_get_smbios_data, |
| 242 | #endif |
Duncan Laurie | b40e780 | 2020-03-17 18:47:36 -0700 | [diff] [blame] | 243 | #if CONFIG(HAVE_ACPI_TABLES) |
| 244 | .acpi_name = qemu_acpi_name, |
| 245 | #endif |
Myles Watson | 032a965 | 2009-05-11 22:24:53 +0000 | [diff] [blame] | 246 | }; |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 247 | |
Arthur Heymans | a75a2fa | 2020-12-01 15:20:10 +0100 | [diff] [blame] | 248 | static const struct mp_ops mp_ops_no_smm = { |
| 249 | .get_cpu_count = fw_cfg_max_cpus, |
| 250 | }; |
| 251 | |
| 252 | void mp_init_cpus(struct bus *cpu_bus) |
| 253 | { |
| 254 | if (mp_init_with_smm(cpu_bus, &mp_ops_no_smm)) |
| 255 | printk(BIOS_ERR, "MP initialization failure.\n"); |
| 256 | } |
| 257 | |
Kyösti Mälkki | ccb9502 | 2018-05-22 00:16:23 +0300 | [diff] [blame] | 258 | static void cpu_bus_init(struct device *dev) |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 259 | { |
Arthur Heymans | a75a2fa | 2020-12-01 15:20:10 +0100 | [diff] [blame] | 260 | if (CONFIG(PARALLEL_MP)) |
| 261 | mp_cpu_bus_init(dev); |
| 262 | else |
| 263 | initialize_cpus(dev->link_list); |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 264 | } |
| 265 | |
Kyösti Mälkki | ccb9502 | 2018-05-22 00:16:23 +0300 | [diff] [blame] | 266 | static void cpu_bus_scan(struct device *bus) |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 267 | { |
| 268 | int max_cpus = fw_cfg_max_cpus(); |
Kyösti Mälkki | ccb9502 | 2018-05-22 00:16:23 +0300 | [diff] [blame] | 269 | struct device *cpu; |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 270 | int i; |
| 271 | |
| 272 | if (max_cpus < 0) |
Kyösti Mälkki | 580e722 | 2015-03-19 21:04:23 +0200 | [diff] [blame] | 273 | return; |
Patrick Rudolph | cfa0225 | 2021-02-02 18:14:24 +0100 | [diff] [blame] | 274 | /* |
| 275 | * Do not install more CPUs than supported by coreboot. |
| 276 | * This will cause a buffer overflow where fixed arrays of CONFIG_MAX_CPUS |
| 277 | * are used and might result in a boot failure. |
| 278 | */ |
| 279 | max_cpus = MIN(max_cpus, CONFIG_MAX_CPUS); |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 280 | |
| 281 | /* |
| 282 | * TODO: This only handles the simple "qemu -smp $nr" case |
| 283 | * correctly. qemu also allows to specify the number of |
| 284 | * cores, threads & sockets. |
| 285 | */ |
| 286 | printk(BIOS_INFO, "QEMU: max_cpus is %d\n", max_cpus); |
| 287 | for (i = 0; i < max_cpus; i++) { |
| 288 | cpu = add_cpu_device(bus->link_list, i, 1); |
| 289 | if (cpu) |
| 290 | set_cpu_topology(cpu, 1, 0, i, 0); |
| 291 | } |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 292 | } |
| 293 | |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 294 | static struct device_operations cpu_bus_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 295 | .read_resources = noop_read_resources, |
| 296 | .set_resources = noop_set_resources, |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 297 | .init = cpu_bus_init, |
| 298 | .scan_bus = cpu_bus_scan, |
| 299 | }; |
| 300 | |
Paul Menzel | 5f20b35 | 2013-02-24 14:27:03 +0100 | [diff] [blame] | 301 | static void northbridge_enable(struct device *dev) |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 302 | { |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 303 | /* Set the operations if it is a special bus type */ |
Stefan Reinauer | 4aff445 | 2013-02-12 14:17:15 -0800 | [diff] [blame] | 304 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 305 | dev->ops = &pci_domain_ops; |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 306 | } |
Gerd Hoffmann | aa588e0 | 2013-05-31 09:26:55 +0200 | [diff] [blame] | 307 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
| 308 | dev->ops = &cpu_bus_ops; |
| 309 | } |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 310 | } |
| 311 | |
Gerd Hoffmann | 00cc7f43 | 2013-06-07 15:46:23 +0200 | [diff] [blame] | 312 | struct chip_operations mainboard_emulation_qemu_i440fx_ops = { |
| 313 | CHIP_NAME("QEMU Northbridge i440fx") |
Paul Menzel | 5f20b35 | 2013-02-24 14:27:03 +0100 | [diff] [blame] | 314 | .enable_dev = northbridge_enable, |
Stefan Reinauer | e2b53e1 | 2004-06-28 11:59:45 +0000 | [diff] [blame] | 315 | }; |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 316 | |
| 317 | struct chip_operations mainboard_emulation_qemu_q35_ops = { |
| 318 | CHIP_NAME("QEMU Northbridge q35") |
| 319 | .enable_dev = northbridge_enable, |
| 320 | }; |