From c0fc38eed8f407d71f714f4d6fe2af0c3501ece4 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 6 Aug 2022 19:02:59 +0200 Subject: sconfig: Allow to specify device operations Currently we only have runtime mechanisms to assign device operations to a node in our devicetree (with one exception: the root device). The most common method is to map PCI IDs to the device operations with a `struct pci_driver`. Another accustomed way is to let a chip driver assign them. For very common drivers, e.g. those in soc/intel/common/blocks/, the PCI ID lists grew very large and are incredibly error-prone. Often, IDs are missing and sometimes IDs are added almost mechanically without checking the code for compatibility. Maintaining these lists in a central place also reduces flexibility. Now, for onboard devices it is actually unnecessary to assign the device operations at runtime. We already know exactly what operations should be assigned. And since we are using chipset devicetrees, we have a perfect place to put that information. This patch adds a simple mechanism to `sconfig`. It allows us to speci- fy operations per device, e.g. device pci 00.0 alias system_agent on ops system_agent_ops end The operations are given as a C identifier. In this example, we simply assume that a global `struct device_operations system_agent_ops` exists. Change-Id: I2833d2f2450fde3206c33393f58b86fd4280b566 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/coreboot/+/66483 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Arthur Heymans Reviewed-by: Felix Held --- util/sconfig/sconfig.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'util/sconfig/sconfig.h') diff --git a/util/sconfig/sconfig.h b/util/sconfig/sconfig.h index 5b50cc0158..c2a43af5cf 100644 --- a/util/sconfig/sconfig.h +++ b/util/sconfig/sconfig.h @@ -57,6 +57,11 @@ struct fw_config_probe { struct fw_config_probe *next; }; +struct identifier { + const char *id; + struct identifier *next; +}; + struct chip; struct chip_instance { /* Monotonically increasing ID for each chip instance. */ @@ -165,6 +170,9 @@ struct device { /* Pointer to last bus under this device. */ struct bus *last_bus; + /* Global identifier of the ops for this device. */ + char *ops_id; + /* SMBIOS slot type */ char *smbios_slot_type; @@ -236,3 +244,5 @@ void add_fw_config_probe(struct bus *bus, const char *field, const char *option) void append_fw_config_bits(struct fw_config_field_bits **bits, unsigned int start_bit, unsigned int end_bit); + +void add_device_ops(struct bus *, char *ops_id); -- cgit v1.2.3