summaryrefslogtreecommitdiffstats
path: root/util/sconfig
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2021-01-06 22:36:59 -0800
committerPatrick Georgi <pgeorgi@google.com>2021-01-11 07:42:28 +0000
commitfceca9259b969098809935fc61dddcc1a0b65b51 (patch)
treee67426060f7c14f6841311e96a10af8135250741 /util/sconfig
parent696f4ea0f52b37a299197edfc71acb422151834a (diff)
downloadcoreboot-fceca9259b969098809935fc61dddcc1a0b65b51.tar.gz
coreboot-fceca9259b969098809935fc61dddcc1a0b65b51.tar.bz2
coreboot-fceca9259b969098809935fc61dddcc1a0b65b51.zip
util/sconfig: Emit chip config pointers for PCI devices on root bus
This change emits chip config pointers for PCI devices on root bus in static_devices.h so that the config structure can be accessed directly without having to reference the device structure. This allows the linker to optimize out unused parts of the device tree from early stages like bootblock. Change-Id: I1d42e926dbfae14b889ade6dda363d8607974cae Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/49214 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/sconfig')
-rw-r--r--util/sconfig/main.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/util/sconfig/main.c b/util/sconfig/main.c
index 1af55ac31026..99e76adbff61 100644
--- a/util/sconfig/main.c
+++ b/util/sconfig/main.c
@@ -1085,12 +1085,9 @@ static void emit_dev_links(FILE *fil, struct device *ptr)
fprintf(fil, "\t};\n");
}
-static void pass1(FILE *fil, FILE *head, struct device *ptr, struct device *next)
+static struct chip_instance *get_chip_instance(const struct device *dev)
{
- int pin;
- struct chip_instance *chip_ins = ptr->chip_instance;
- int has_children = dev_has_children(ptr);
-
+ struct chip_instance *chip_ins = dev->chip_instance;
/*
* If the chip instance of device has base_chip_instance pointer set, then follow that
* to update the chip instance for current device.
@@ -1098,6 +1095,15 @@ static void pass1(FILE *fil, FILE *head, struct device *ptr, struct device *next
if (chip_ins->base_chip_instance)
chip_ins = chip_ins->base_chip_instance;
+ return chip_ins;
+}
+
+static void pass1(FILE *fil, FILE *head, struct device *ptr, struct device *next)
+{
+ int pin;
+ struct chip_instance *chip_ins = get_chip_instance(ptr);
+ int has_children = dev_has_children(ptr);
+
/* Emit probe structures. */
if (ptr->probe && (emit_fw_config_probe(fil, ptr) < 0)) {
if (head)
@@ -1209,12 +1215,21 @@ static void pass1(FILE *fil, FILE *head, struct device *ptr, struct device *next
static void expose_device_names(FILE *fil, FILE *head, struct device *ptr, struct device *next)
{
+ struct chip_instance *chip_ins = get_chip_instance(ptr);
+
/* Only devices on root bus here. */
if (ptr->bustype == PCI && ptr->parent->dev->bustype == DOMAIN) {
fprintf(head, "extern DEVTREE_CONST struct device *const __pci_0_%02x_%d;\n",
ptr->path_a, ptr->path_b);
fprintf(fil, "DEVTREE_CONST struct device *const __pci_0_%02x_%d = &%s;\n",
ptr->path_a, ptr->path_b, ptr->name);
+
+ if (chip_ins->chip->chiph_exists) {
+ fprintf(head, "extern DEVTREE_CONST void *const __pci_0_%02x_%d_config;\n",
+ ptr->path_a, ptr->path_b);
+ fprintf(fil, "DEVTREE_CONST void *const __pci_0_%02x_%d_config = &%s_info_%d;\n",
+ ptr->path_a, ptr->path_b, chip_ins->chip->name_underscore, chip_ins->id);
+ }
}
if (ptr->bustype == PNP) {