soc/intel/cmn/cse: Deprecate CONFIG_SOC_INTEL_CSE_RW_VERSION
[coreboot2.git] / util / sconfig / sconfig.h
blobbb9a98f268b9a2f6dc2ccb13a0ea4dcd7b45293b
1 /* sconfig, coreboot device tree compiler */
2 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <stdint.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <sys/types.h>
9 #include <unistd.h>
10 #include <errno.h>
12 struct resource;
13 struct resource {
14 int type;
15 int index;
16 int base;
17 struct resource *next;
20 struct reg;
21 struct reg {
22 char *key;
23 char *value;
24 struct reg *next;
27 struct fw_config_option;
28 struct fw_config_option {
29 const char *name;
30 uint64_t value;
31 struct fw_config_option *next;
34 struct fw_config_field_bits;
35 struct fw_config_field_bits {
36 unsigned int start_bit;
37 unsigned int end_bit;
38 struct fw_config_field_bits *next;
41 struct fw_config_field;
42 struct fw_config_field {
43 const char *name;
44 struct fw_config_field_bits *bits;
45 struct fw_config_field *next;
46 struct fw_config_option *options;
48 struct fw_config_probe;
49 struct fw_config_probe {
50 const char *field;
51 const char *option;
52 struct fw_config_probe *next;
55 struct identifier {
56 const char *id;
57 struct identifier *next;
60 struct chip;
61 struct chip_instance {
62 /* Monotonically increasing ID for each chip instance. */
63 int id;
65 /* Pointer to registers for this chip. */
66 struct reg *reg;
68 /* Pointer to references for this chip. */
69 struct reg *ref;
71 /* Pointer to chip of which this is instance. */
72 struct chip *chip;
74 /* Pointer to next instance of the same chip. */
75 struct chip_instance *next;
78 * Pointer to corresponding chip instance in base devicetree.
79 * a) If the chip instance belongs to the base devicetree, then this pointer is set to
80 * NULL.
81 * b) If the chip instance belongs to override tree, then this pointer is set to its
82 * corresponding chip instance in base devicetree (if it exists), else to NULL.
84 * This is useful when generating chip instances and chip_ops for a device to determine
85 * if this is the instance to emit or if there is a base chip instance to use instead.
87 struct chip_instance *base_chip_instance;
90 struct chip {
91 /* Indicates if chip header exists for this chip. */
92 int chiph_exists;
94 /* Name of current chip. */
95 char *name;
97 /* Name of current chip normalized to _. */
98 char *name_underscore;
100 /* Pointer to first instance of this chip. */
101 struct chip_instance *instance;
103 /* Pointer to next chip. */
104 struct chip *next;
107 struct device;
108 struct bus {
109 /* Pointer to device to which this bus belongs. */
110 struct device *dev;
112 /* Pointer to list of children. */
113 struct device *children;
116 struct device {
117 /* Indicates device status (enabled / hidden or not). */
118 int enabled;
119 int hidden;
120 /* non-zero if the device should be included in all cases */
121 int mandatory;
123 /* Subsystem IDs for the device. */
124 int subsystem_vendor;
125 int subsystem_device;
126 int inherit_subsystem;
128 /* Name of this device. */
129 char *name;
131 /* Alias of this device (for internal references) */
132 char *alias;
134 /* Path of this device. */
135 char *path;
136 int path_a;
137 int path_b;
139 /* Type of bus that exists under this device. */
140 int bustype;
142 /* Pointer to bus of parent on which this device resides. */
143 struct bus *parent;
145 /* Pointer to next child under the same parent. */
146 struct device *sibling;
148 /* Pointer to resources for this device. */
149 struct resource *res;
151 /* Pointer to chip instance for this device. */
152 struct chip_instance *chip_instance;
154 /* Pointer to the bus under this device. */
155 struct bus *bus;
157 /* Global identifier of the ops for this device. */
158 char *ops_id;
160 /* SMBIOS slot type */
161 char *smbios_slot_type;
163 /* SMBIOS slot data width */
164 char *smbios_slot_data_width;
166 /* SMBIOS slot description for reference designation */
167 char *smbios_slot_designation;
169 /* SMBIOS slot length */
170 char *smbios_slot_length;
172 /* SMBIOS type41 fields */
173 int smbios_instance_id_valid;
174 unsigned int smbios_instance_id;
175 const char *smbios_refdes;
177 /* List of field+option to probe. */
178 struct fw_config_probe *probe;
181 extern struct bus *root_parent;
183 struct device *new_device_raw(struct bus *parent,
184 struct chip_instance *chip_instance,
185 const int bustype, const char *devnum,
186 char *alias, int status);
188 struct device *new_device_reference(struct bus *parent,
189 struct chip_instance *chip_instance,
190 const char *reference, int status);
192 void add_resource(struct bus *bus, int type, int index, int base);
194 void add_pci_subsystem_ids(struct bus *bus, int vendor, int device,
195 int inherit);
197 void add_slot_desc(struct bus *bus, char *type, char *length, char *designation,
198 char *data_width);
200 void add_smbios_dev_info(struct bus *bus, long instance_id, const char *refdes);
202 void yyrestart(FILE *input_file);
204 /* Add chip data to tail of queue. */
205 void chip_enqueue_tail(void *data);
207 /* Retrieve chip data from tail of queue. */
208 void *chip_dequeue_tail(void);
210 struct chip_instance *new_chip_instance(char *path);
211 void add_register(struct chip_instance *chip, char *name, char *val);
212 void add_reference(struct chip_instance *chip, char *name, char *alias);
214 struct fw_config_field *get_fw_config_field(const char *name);
216 void add_fw_config_field_bits(struct fw_config_field *field,
217 unsigned int start_bit, unsigned int end_bit);
219 struct fw_config_field *new_fw_config_field(const char *name, struct fw_config_field_bits *bits);
221 void add_fw_config_option(struct fw_config_field *field, const char *name,
222 uint64_t value);
224 void add_fw_config_probe(struct bus *bus, const char *field, const char *option);
226 void append_fw_config_bits(struct fw_config_field_bits **bits,
227 unsigned int start_bit, unsigned int end_bit);
229 void add_device_ops(struct bus *, char *ops_id);