Asus H61 boards: Align dsdt.asl with other boards
[coreboot.git] / util / sconfig / sconfig.h
blobe6bd5aadd3a9a5981880e432a260fdffa1fb4a0f
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 pci_irq_info {
28 int ioapic_irq_pin;
29 int ioapic_dst_id;
32 struct fw_config_option;
33 struct fw_config_option {
34 const char *name;
35 uint64_t value;
36 struct fw_config_option *next;
39 struct fw_config_field_bits;
40 struct fw_config_field_bits {
41 unsigned int start_bit;
42 unsigned int end_bit;
43 struct fw_config_field_bits *next;
46 struct fw_config_field;
47 struct fw_config_field {
48 const char *name;
49 struct fw_config_field_bits *bits;
50 struct fw_config_field *next;
51 struct fw_config_option *options;
53 struct fw_config_probe;
54 struct fw_config_probe {
55 const char *field;
56 const char *option;
57 struct fw_config_probe *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 /* Instance/ID of the bus under the device. */
110 int id;
112 /* Pointer to device to which this bus belongs. */
113 struct device *dev;
115 /* Pointer to list of children. */
116 struct device *children;
118 /* Pointer to next bus for the device. */
119 struct bus *next_bus;
122 struct device {
123 /* Indicates device status (enabled / hidden or not). */
124 int enabled;
125 int hidden;
126 /* non-zero if the device should be included in all cases */
127 int mandatory;
129 /* Subsystem IDs for the device. */
130 int subsystem_vendor;
131 int subsystem_device;
132 int inherit_subsystem;
134 /* Name of this device. */
135 char *name;
137 /* Alias of this device (for internal references) */
138 char *alias;
140 /* Path of this device. */
141 char *path;
142 int path_a;
143 int path_b;
145 /* Type of bus that exists under this device. */
146 int bustype;
148 /* PCI IRQ info. */
149 struct pci_irq_info pci_irq_info[4];
151 /* Pointer to bus of parent on which this device resides. */
152 struct bus *parent;
154 /* Pointer to next child under the same parent. */
155 struct device *sibling;
157 /* Pointer to resources for this device. */
158 struct resource *res;
160 /* Pointer to chip instance for this device. */
161 struct chip_instance *chip_instance;
163 /* Pointer to list of buses under this device. */
164 struct bus *bus;
165 /* Pointer to last bus under this device. */
166 struct bus *last_bus;
168 /* SMBIOS slot type */
169 char *smbios_slot_type;
171 /* SMBIOS slot data width */
172 char *smbios_slot_data_width;
174 /* SMBIOS slot description for reference designation */
175 char *smbios_slot_designation;
177 /* SMBIOS slot length */
178 char *smbios_slot_length;
180 /* List of field+option to probe. */
181 struct fw_config_probe *probe;
184 extern struct bus *root_parent;
186 struct device *new_device_raw(struct bus *parent,
187 struct chip_instance *chip_instance,
188 const int bustype, const char *devnum,
189 char *alias, int status);
191 struct device *new_device_reference(struct bus *parent,
192 struct chip_instance *chip_instance,
193 const char *reference, int status);
195 void add_resource(struct bus *bus, int type, int index, int base);
197 void add_pci_subsystem_ids(struct bus *bus, int vendor, int device,
198 int inherit);
200 void add_ioapic_info(struct bus *bus, int apicid, const char *_srcpin,
201 int irqpin);
203 void add_slot_desc(struct bus *bus, char *type, char *length, char *designation,
204 char *data_width);
206 void yyrestart(FILE *input_file);
208 /* Add chip data to tail of queue. */
209 void chip_enqueue_tail(void *data);
211 /* Retrieve chip data from tail of queue. */
212 void *chip_dequeue_tail(void);
214 struct chip_instance *new_chip_instance(char *path);
215 void add_register(struct chip_instance *chip, char *name, char *val);
216 void add_reference(struct chip_instance *chip, char *name, char *alias);
218 struct fw_config_field *get_fw_config_field(const char *name);
220 void add_fw_config_field_bits(struct fw_config_field *field,
221 unsigned int start_bit, unsigned int end_bit);
223 struct fw_config_field *new_fw_config_field(const char *name, struct fw_config_field_bits *bits);
225 void add_fw_config_option(struct fw_config_field *field, const char *name,
226 uint64_t value);
228 void add_fw_config_probe(struct bus *bus, const char *field, const char *option);
230 void append_fw_config_bits(struct fw_config_field_bits **bits,
231 unsigned int start_bit, unsigned int end_bit);