Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35821 )
Change subject: [RFC]arch/x86: Only use BOOTBLOCK_NORMAL with an CMOS option table
......................................................................
[RFC]arch/x86: Only use BOOTBLOCK_NORMAL with an CMOS option table
There is no explicit dependency on an option table since the reboot
counter and the normal/fallback byte is at a fixed offset.
I don't feel strongly about imposing this...
Change-Id: I2126e71c72951d11960f5d27d25eaa838854057d
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/arch/x86/Kconfig
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/21/35821/1
diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig
index 502e774..9d26692 100644
--- a/src/arch/x86/Kconfig
+++ b/src/arch/x86/Kconfig
@@ -255,6 +255,7 @@
bool "Always load fallback"
config BOOTBLOCK_NORMAL
+ depends on USE_OPTION_TABLE
select CONFIGURABLE_CBFS_PREFIX
bool "Switch to normal if CMOS says so"
--
To view, visit https://review.coreboot.org/c/coreboot/+/35821
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I2126e71c72951d11960f5d27d25eaa838854057d
Gerrit-Change-Number: 35821
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-MessageType: newchange
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35823 )
Change subject: [RFC]arch/x86: Only allow normal and fallback cbfs prefixes
......................................................................
[RFC]arch/x86: Only allow normal and fallback cbfs prefixes
Using other cbfsprefixes is errorprone: It requires a properly
formatted cbfs file to be present (an error in the cbfsfile will
render the system unbootable) and to correctly enter the cbfs prefix
in menuconfig. Therefore remove this functionality that merely allows
to use different names.
Change-Id: I7399b144fe122badd53d518543868c6ecb14fe21
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/Kconfig
M src/arch/x86/bootblock_normal.c
2 files changed, 3 insertions(+), 20 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/23/35823/1
diff --git a/src/Kconfig b/src/Kconfig
index 4c71f28..5b2a615 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -48,13 +48,10 @@
config CBFS_PREFIX_NORMAL
bool "normal"
-config CBFS_PREFIX_DIY
- bool "Define your own cbfs prefix"
-
endchoice
config CBFS_PREFIX
- string "CBFS prefix to use" if CBFS_PREFIX_DIY
+ string
default "fallback" if !CONFIGURABLE_CBFS_PREFIX || CBFS_PREFIX_FALLBACK
default "normal" if CBFS_PREFIX_NORMAL
help
diff --git a/src/arch/x86/bootblock_normal.c b/src/arch/x86/bootblock_normal.c
index 905ecb2..c55eda2 100644
--- a/src/arch/x86/bootblock_normal.c
+++ b/src/arch/x86/bootblock_normal.c
@@ -16,18 +16,9 @@
#include <pc80/mc146818rtc.h>
#include <halt.h>
-static const char *get_fallback(const char *stagelist)
-{
- while (*stagelist)
- stagelist++;
- return ++stagelist;
-}
-
static void main(unsigned long bist)
{
u8 boot_mode;
- const char *default_filenames =
- "normal/romstage\0fallback/romstage";
if (boot_cpu()) {
bootblock_mainboard_init();
@@ -44,20 +35,15 @@
boot_mode = boot_use_normal(cmos_read(RTC_BOOT_BYTE));
}
- char *normal_candidate = (char *)walkcbfs("coreboot-stages");
-
- if (!normal_candidate)
- normal_candidate = default_filenames;
-
unsigned long entry;
if (boot_mode) {
- entry = findstage(normal_candidate);
+ entry = findstage("normal/romstage");
if (entry)
call(entry, bist);
}
- entry = findstage(get_fallback(normal_candidate));
+ entry = findstage("fallback/romstage");
if (entry)
call(entry, bist);
--
To view, visit https://review.coreboot.org/c/coreboot/+/35823
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I7399b144fe122badd53d518543868c6ecb14fe21
Gerrit-Change-Number: 35823
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-MessageType: newchange
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/33361
Change subject: soc/intel/block/cpu: Add a MP init choice selection
......................................................................
soc/intel/block/cpu: Add a MP init choice selection
Add a choice to select the MP init method for clarity.
Change-Id: I2a7490948f729f1ae9fd2537bf6cbe9ada51f968
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/soc/intel/common/block/cpu/Kconfig
1 file changed, 21 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/33361/1
diff --git a/src/soc/intel/common/block/cpu/Kconfig b/src/soc/intel/common/block/cpu/Kconfig
index 8cc572d..6082ce3 100644
--- a/src/soc/intel/common/block/cpu/Kconfig
+++ b/src/soc/intel/common/block/cpu/Kconfig
@@ -51,18 +51,34 @@
ENHANCED NEM guarantees that modified data is always
kept in cache while clean data is replaced.
-config USE_INTEL_FSP_MP_INIT
+choice
+ prompt "Multiple Processor (MP) Initialization Options"
+ default MP_USE_COREBOOT_NATIVE_MP_INIT if !PLATFORM_USES_FSP2_1
+ default MP_USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI if PLATFORM_USES_FSP2_1
+
+config MP_USE_COREBOOT_NATIVE_MP_INIT
+ bool "Perform MP Initialization by coreboot"
+
+config MP_USE_INTEL_FSP_MP_INIT
bool "Perform MP Initialization by FSP"
- default n
+ select USE_INTEL_FSP_MP_INIT
+
+config MP_USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI
+ bool "Perform MP Initialization by FSP using coreboot MP PPI service"
+ depends on FSP_USES_MP_SERVICES_PPI
+ select USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI
+
+endchoice
+
+config USE_INTEL_FSP_MP_INIT
+ bool
depends on !USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI
help
This option allows FSP to perform multiprocessor initialization.
config USE_INTEL_FSP_TO_CALL_COREBOOT_PUBLISH_MP_PPI
- bool "Perform MP Initialization by FSP using coreboot MP PPI service"
+ bool
depends on FSP_USES_MP_SERVICES_PPI
- default y if PLATFORM_USES_FSP2_1
- default n
help
This option allows FSP to make use of MP services PPI published by
coreboot to perform multiprocessor initialization.
--
To view, visit https://review.coreboot.org/c/coreboot/+/33361
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I2a7490948f729f1ae9fd2537bf6cbe9ada51f968
Gerrit-Change-Number: 33361
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-MessageType: newchange
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/33555
Change subject: util/cbfstool/fit.c: Bail out when there are not enough FIT entries
......................................................................
util/cbfstool/fit.c: Bail out when there are not enough FIT entries
Bail out when there are not enough empty FIT enties to add all
microcode entries.
Change-Id: If86678a1eaaa0c5ff571f25bd6bfdb26ac93a946
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M util/cbfstool/fit.c
1 file changed, 8 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/55/33555/1
diff --git a/util/cbfstool/fit.c b/util/cbfstool/fit.c
index aeb1755..2fee9e3 100644
--- a/util/cbfstool/fit.c
+++ b/util/cbfstool/fit.c
@@ -238,7 +238,7 @@
static int parse_microcode_blob(struct cbfs_image *image,
struct cbfs_file *mcode_file,
struct microcode_entry *mcus,
- int total_entries, int *mcus_found)
+ int *mcus_found)
{
int num_mcus;
uint32_t current_offset;
@@ -272,9 +272,6 @@
file_length -= mcus[num_mcus].size;
num_mcus++;
- /* Reached limit of FIT entries. */
- if (num_mcus == total_entries)
- break;
if (file_length < sizeof(struct microcode_header))
break;
}
@@ -319,13 +316,18 @@
return 1;
}
- if (parse_microcode_blob(image, mcode_file, mcus, empty_entries,
- &mcus_found)) {
+ if (parse_microcode_blob(image, mcode_file, mcus, &mcus_found)) {
ERROR("Couldn't parse microcode blob.\n");
ret = 1;
goto out;
}
+ if (mcus_found > empty_entries) {
+ ERROR("Not enough empty FIT entries for all microcode update entries.\n");
+ ret = 1;
+ goto out;
+ }
+
add_microcodde_entries(fit, image, mcus_found, mcus, offset_fn, 0);
update_fit_checksum(fit);
--
To view, visit https://review.coreboot.org/c/coreboot/+/33555
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: If86678a1eaaa0c5ff571f25bd6bfdb26ac93a946
Gerrit-Change-Number: 33555
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-MessageType: newchange
Erin Lo has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34382 )
Change subject: WIP: mediatek/mt8183: Add SCP work support
......................................................................
WIP: mediatek/mt8183: Add SCP work support
Load SCP firmware to SCP's sram since buffer size is limited so load splitted binaries.
After SCP works done, disable it
Test=Build pass
Change-Id: I0801eac078aa9d6237142dcd92a3c3e9237a86ee
Signed-off-by: Erin Lo <erin.lo(a)mediatek.com>
---
M src/mainboard/google/kukui/Makefile.inc
M src/mainboard/google/kukui/romstage.c
M src/soc/mediatek/mt8183/Makefile.inc
M src/soc/mediatek/mt8183/include/soc/addressmap.h
A src/soc/mediatek/mt8183/include/soc/scp.h
A src/soc/mediatek/mt8183/scp.c
6 files changed, 123 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/82/34382/1
diff --git a/src/mainboard/google/kukui/Makefile.inc b/src/mainboard/google/kukui/Makefile.inc
index a0556c1..f8a5bab 100644
--- a/src/mainboard/google/kukui/Makefile.inc
+++ b/src/mainboard/google/kukui/Makefile.inc
@@ -25,3 +25,18 @@
ramstage-y += mainboard.c
ramstage-y += memlayout.ld
ramstage-y += reset.c
+
+cbfs-files-y += scp_0.bin
+scp_0.bin-file := 3rdparty/blobs/mainboard/google/kukui/scp_0.bin
+scp_0.bin-type := raw
+scp_0.bin-compression := none
+
+cbfs-files-y += scp_1.bin
+scp_1.bin-file := 3rdparty/blobs/mainboard/google/kukui/scp_1.bin
+scp_1.bin-type := raw
+scp_1.bin-compression := none
+
+cbfs-files-y += scp_2.bin
+scp_2.bin-file := 3rdparty/blobs/mainboard/google/kukui/scp_2.bin
+scp_2.bin-type := raw
+scp_2.bin-compression := none
diff --git a/src/mainboard/google/kukui/romstage.c b/src/mainboard/google/kukui/romstage.c
index 1465243..cf3572d 100644
--- a/src/mainboard/google/kukui/romstage.c
+++ b/src/mainboard/google/kukui/romstage.c
@@ -19,7 +19,7 @@
#include <soc/mt6358.h>
#include <soc/pll.h>
#include <soc/rtc.h>
-
+#include <soc/scp.h>
#include "early_init.h"
void platform_romstage_main(void)
@@ -33,6 +33,7 @@
pmic_set_vsim2_cali(2700);
mt_pll_raise_ca53_freq(1989 * MHz);
rtc_boot();
+ scp_work();
mt_mem_init(get_sdram_config());
mtk_mmu_after_dram();
}
diff --git a/src/soc/mediatek/mt8183/Makefile.inc b/src/soc/mediatek/mt8183/Makefile.inc
index d35a07e..0543552 100644
--- a/src/soc/mediatek/mt8183/Makefile.inc
+++ b/src/soc/mediatek/mt8183/Makefile.inc
@@ -35,6 +35,7 @@
romstage-y += ../common/pll.c pll.c
romstage-y += ../common/pmic_wrap.c pmic_wrap.c mt6358.c
romstage-y += ../common/rtc.c rtc.c
+romstage-y += scp.c
romstage-$(CONFIG_SPI_FLASH) += ../common/spi.c spi.c
romstage-y += ../common/timer.c
romstage-y += ../common/uart.c
diff --git a/src/soc/mediatek/mt8183/include/soc/addressmap.h b/src/soc/mediatek/mt8183/include/soc/addressmap.h
index e9f80d1..affc776 100644
--- a/src/soc/mediatek/mt8183/include/soc/addressmap.h
+++ b/src/soc/mediatek/mt8183/include/soc/addressmap.h
@@ -34,6 +34,9 @@
EMI_BASE = IO_PHYS + 0x00219000,
EMI_MPU_BASE = IO_PHYS + 0x00226000,
DRAMC_CH_BASE = IO_PHYS + 0x00228000,
+ SCP_SRAM_BASE = IO_PHYS + 0x00500000,
+ SCP_CFG_BASE = IO_PHYS + 0x005C0000,
+ SCP_CLK_CTRL_BASE = IO_PHYS + 0x005C4000,
AUXADC_BASE = IO_PHYS + 0x01001000,
UART0_BASE = IO_PHYS + 0x01002000,
SPI0_BASE = IO_PHYS + 0x0100A000,
diff --git a/src/soc/mediatek/mt8183/include/soc/scp.h b/src/soc/mediatek/mt8183/include/soc/scp.h
new file mode 100644
index 0000000..a3003bd
--- /dev/null
+++ b/src/soc/mediatek/mt8183/include/soc/scp.h
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2019 MediaTek Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef SOC_MEDIATEK_MT8183_SCP_H
+#define SOC_MEDIATEK_MT8183_SCP_H
+
+#include <soc/addressmap.h>
+#include <types.h>
+
+struct mt8183_scp_regs {
+ u32 sw_rstn;
+ u32 reserved[19];
+ u32 gpr0;
+};
+
+struct mt8183_scp_clk_ctrl_regs {
+ u32 reserved[11];
+ u32 sram_pdn;
+};
+
+static struct mt8183_scp_regs *const mt8183_scp = (void *)SCP_CFG_BASE;
+static struct mt8183_scp_clk_ctrl_regs *const mt8183_scp_clk_ctrl = (void *)SCP_CLK_CTRL_BASE;
+void scp_work(void);
+#endif /* SOC_MEDIATEK_MT8183_SCP_H */
diff --git a/src/soc/mediatek/mt8183/scp.c b/src/soc/mediatek/mt8183/scp.c
new file mode 100644
index 0000000..150eeba
--- /dev/null
+++ b/src/soc/mediatek/mt8183/scp.c
@@ -0,0 +1,66 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2019 MediaTek Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/barrier.h>
+#include <cbfs.h>
+#include <console/console.h>
+#include <arch/mmio.h>
+#include <soc/scp.h>
+#include <string.h>
+
+#define BUF_SIZE (40 * KiB)
+static uint8_t scp_bin[BUF_SIZE] __aligned(8);
+
+void scp_work(void)
+{
+ size_t fw_size;
+
+ write32(&mt8183_scp_clk_ctrl->sram_pdn, 0x0);
+ mb();
+
+ fw_size = cbfs_boot_load_file("scp_0.bin",
+ scp_bin,
+ sizeof(scp_bin),
+ CBFS_TYPE_RAW);
+ if (fw_size == 0)
+ die("SCP file :scp_0.bin not found.");
+ memcpy((void *)SCP_SRAM_BASE + 0x0, scp_bin, fw_size);
+
+ fw_size = cbfs_boot_load_file("scp_1.bin",
+ scp_bin,
+ sizeof(scp_bin),
+ CBFS_TYPE_RAW);
+ memcpy((void *)SCP_SRAM_BASE + BUF_SIZE, scp_bin, fw_size);
+ if (fw_size == 0)
+ die("SCP file :scp_1.bin not found.");
+
+ fw_size = cbfs_boot_load_file("scp_2.bin",
+ scp_bin,
+ sizeof(scp_bin),
+ CBFS_TYPE_RAW);
+ if (fw_size == 0)
+ die("SCP file :scp_2.bin not found.");
+ memcpy((void *)SCP_SRAM_BASE + BUF_SIZE*2, scp_bin, fw_size);
+
+
+ /* Memory barrier to ensure that all fw code is loaded
+ before we release the reset pin. */
+ mb();
+ write32(&mt8183_scp->sw_rstn, 0x1);
+ while (read32(&mt8183_scp->gpr0) != 0xaaaa){}
+ mb();
+ write32(&mt8183_scp->sw_rstn, 0x0);
+ printk(BIOS_DEBUG, "scp finished \n");
+}
--
To view, visit https://review.coreboot.org/c/coreboot/+/34382
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I0801eac078aa9d6237142dcd92a3c3e9237a86ee
Gerrit-Change-Number: 34382
Gerrit-PatchSet: 1
Gerrit-Owner: Erin Lo <erin.lo(a)mediatek.com>
Gerrit-MessageType: newchange
Jeremy Soller has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35946 )
Change subject: driver/thunderbolt: Driver for allocating hotplug resources
......................................................................
driver/thunderbolt: Driver for allocating hotplug resources
This adds a new driver which can be selected with DRIVERS_THUNDERBOLT
that, by default, adds 32 PCI subordinate numbers, 256 MiB of both
prefetchable and non-prefetchable memory, and 8 KiB of I/O space to
matching devices. It currently supports the JHL7540 Thunderbolt 3
bridge, but other devices can be added easily.
In order to support the allocation of hotplugged PCI buses, a new field
was added to struct device called hotplug_buses. This is defaulted to
zero, but when set, it adds the hotplug_buses value to the subordinate
value of the PCI bridge. This allows devices to be plugged in and
unplugged after boot.
This code was tested on the System76 Darter Pro (darp6). Before this
change, there are not enough resources allocated to the Thunderbolt
PCI bridge to allow plugging in new devices after boot. This can be
worked around in the Linux kernel by passing a boot param such as:
pci=assign-buses,hpbussize=32,realloc
This change makes it possible to use Thunderbolt hotplugging without
kernel parameters, and attempts to match closely what our motherboard
manufacturer's firmware does by default.
Signed-off-by: Jeremy Soller <jeremy(a)system76.com>
Change-Id: I500191626584b83e6a8ae38417fd324b5e803afc
---
M src/device/pci_device.c
A src/drivers/thunderbolt/Kconfig
A src/drivers/thunderbolt/Makefile.inc
A src/drivers/thunderbolt/thunderbolt.c
M src/include/device/device.h
5 files changed, 117 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/46/35946/1
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index c043dd6..1796d81 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -1217,7 +1217,7 @@
if (state == PCI_ROUTE_SCAN) {
link->secondary = parent->subordinate + 1;
- link->subordinate = link->secondary;
+ link->subordinate = link->secondary + dev->hotplug_buses;
}
if (state == PCI_ROUTE_CLOSE) {
diff --git a/src/drivers/thunderbolt/Kconfig b/src/drivers/thunderbolt/Kconfig
new file mode 100644
index 0000000..f64e6cb
--- /dev/null
+++ b/src/drivers/thunderbolt/Kconfig
@@ -0,0 +1,4 @@
+config DRIVERS_THUNDERBOLT
+ bool
+ help
+ Thunderbolt support
diff --git a/src/drivers/thunderbolt/Makefile.inc b/src/drivers/thunderbolt/Makefile.inc
new file mode 100644
index 0000000..623b897
--- /dev/null
+++ b/src/drivers/thunderbolt/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_DRIVERS_THUNDERBOLT) += thunderbolt.c
diff --git a/src/drivers/thunderbolt/thunderbolt.c b/src/drivers/thunderbolt/thunderbolt.c
new file mode 100644
index 0000000..db463e0e
--- /dev/null
+++ b/src/drivers/thunderbolt/thunderbolt.c
@@ -0,0 +1,110 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2019 System76.
+ * Copyright (C) 2017-2018 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <console/console.h>
+#include <device/device.h>
+#include <device/pci.h>
+#include <device/pciexp.h>
+#include <device/pci_def.h>
+#include <device/pci_ids.h>
+#include <device/pci_ops.h>
+
+static void slot_dev_read_resources(struct device *dev)
+{
+ struct resource *resource;
+
+ // Add 256 MiB of memory space
+ resource = new_resource(dev, 0x10);
+ resource->size = 1 << 28;
+ resource->align = 22;
+ resource->gran = 22;
+ resource->limit = 0xffffffff;
+ resource->flags |= IORESOURCE_MEM;
+
+ // Add 256 MiB of prefetchable memory space
+ resource = new_resource(dev, 0x14);
+ resource->size = 1 << 28;
+ resource->align = 22;
+ resource->gran = 22;
+ resource->limit = 0xffffffff;
+ resource->flags |= IORESOURCE_MEM | IORESOURCE_PREFETCH;
+
+ // Add 8 KiB of I/O space
+ resource = new_resource(dev, 0x18);
+ resource->size = 1 << 13;
+ resource->align = 12;
+ resource->gran = 12;
+ resource->limit = 0xffff;
+ resource->flags |= IORESOURCE_IO;
+}
+
+static struct device_operations slot_dev_ops = {
+ .read_resources = slot_dev_read_resources,
+};
+
+static bool tbt_is_hotplug_bridge(struct device *dev) {
+ return PCI_SLOT(dev->path.pci.devfn) == 1;
+}
+
+static void tbt_pciexp_scan_bridge(struct device *dev) {
+ printk(BIOS_DEBUG, "%s: %s: scan bridge\n", __func__, dev_path(dev));
+
+ bool is_hotplug = tbt_is_hotplug_bridge(dev);
+ if (is_hotplug) {
+ /* Add hotplug buses, must happen before bus scan */
+ printk(BIOS_DEBUG, "%s: %s: add hotplug buses\n", __func__, dev_path(dev));
+ dev->hotplug_buses = 32;
+ }
+
+ /* Normal PCIe Scan */
+ pciexp_scan_bridge(dev);
+
+ if (is_hotplug) {
+ /* Add dummy slot to preserve resources, must happen after bus scan */
+ printk(BIOS_DEBUG, "%s: %s: add dummy device\n", __func__, dev_path(dev));
+ struct device *slot;
+ struct device_path slot_path = { .type = DEVICE_PATH_NONE };
+ slot = alloc_dev(dev->link_list, &slot_path);
+ slot->ops = &slot_dev_ops;
+ }
+}
+
+static struct pci_operations pcie_ops = {
+ .set_subsystem = pci_dev_set_subsystem,
+};
+
+static struct device_operations device_ops = {
+ .read_resources = pci_bus_read_resources,
+ .set_resources = pci_dev_set_resources,
+ .enable_resources = pci_bus_enable_resources,
+ .init = 0,
+ .scan_bus = tbt_pciexp_scan_bridge,
+ .enable = 0,
+ .reset_bus = pci_bus_reset,
+ .ops_pci = &pcie_ops,
+};
+
+static const unsigned short pcie_device_ids[] = {
+ // JHL7540 Thunderbolt 3 Bridge
+ 0x15e7,
+ 0
+};
+
+static const struct pci_driver tbt_pcie __pci_driver = {
+ .ops = &device_ops,
+ .vendor = PCI_VENDOR_ID_INTEL,
+ .devices = pcie_device_ids,
+};
diff --git a/src/include/device/device.h b/src/include/device/device.h
index cb37c09..f22bed5 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -129,6 +129,7 @@
unsigned int disable_pcie_aspm : 1;
unsigned int hidden : 1; /* set if we should hide from UI */
u8 command;
+ uint16_t hotplug_buses; /* hotplug buses to allocate */
/* Base registers for this device. I/O, MEM and Expansion ROM */
DEVTREE_CONST struct resource *resource_list;
--
To view, visit https://review.coreboot.org/c/coreboot/+/35946
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I500191626584b83e6a8ae38417fd324b5e803afc
Gerrit-Change-Number: 35946
Gerrit-PatchSet: 1
Gerrit-Owner: Jeremy Soller <jeremy(a)system76.com>
Gerrit-MessageType: newchange