13e240c602
Sooner or later, some board was going to need extra FW_CONFIG bits for a field that was already in production, so this patch adds support for adding extra (unused) bits to a field. The extra are appended via a syntax like: `field FIELD_NAME START0 END0 | START1 END1 | START2 END2 ...` and the suffixed bits are all treated as if they are contiguous when defining option values. BUG=b:185190978 TEST=Modified volteer fw_config to the following: field AUDIO 8 10 | 29 29 | 31 31 option NONE 0 option MAX98357_ALC5682I_I2S 1 option MAX98373_ALC5682I_I2S 2 option MAX98373_ALC5682_SNDW 3 option MAX98373_ALC5682I_I2S_UP4 4 option MAX98360_ALC5682I_I2S 5 option RT1011_ALC5682I_I2S 6 option AUDIO_FOO 7 option AUDIO_BAR 8 option AUDIO_QUUX 9 option AUDIO_BLAH1 10 option AUDIO_BLAH2 15 option AUDIO_BLAH3 16 option AUDIO_BLAH4 31 end which yielded (in static_fw_config.h): FW_CONFIG_FIELD_AUDIO_MASK 0xa0000700 FW_CONFIG_FIELD_AUDIO_OPTION_NONE_VALUE 0x0 FW_CONFIG_FIELD_AUDIO_OPTION_MAX98357_ALC5682I_I2S_VALUE 0x100 FW_CONFIG_FIELD_AUDIO_OPTION_MAX98373_ALC5682I_I2S_VALUE 0x200 FW_CONFIG_FIELD_AUDIO_OPTION_MAX98373_ALC5682_SNDW_VALUE 0x300 FW_CONFIG_FIELD_AUDIO_OPTION_MAX98373_ALC5682I_I2S_UP4_VALUE 0x400 FW_CONFIG_FIELD_AUDIO_OPTION_MAX98360_ALC5682I_I2S_VALUE 0x500 FW_CONFIG_FIELD_AUDIO_OPTION_RT1011_ALC5682I_I2S_VALUE 0x600 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_FOO_VALUE 0x700 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_BAR_VALUE 0x20000000 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_QUUX_VALUE 0x20000100 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_BLAH1_VALUE 0x20000200 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_BLAH2_VALUE 0x20000700 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_BLAH3_VALUE 0x80000000 FW_CONFIG_FIELD_AUDIO_OPTION_AUDIO_BLAH4_VALUE 0xa0000700 Change-Id: I5ed76706347ee9642198efc77139abdc3af1b8a6 Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/52747 Reviewed-by: Duncan Laurie <duncan@iceblink.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
135 lines
5 KiB
Text
Executable file
135 lines
5 KiB
Text
Executable file
%{
|
|
/* sconfig, coreboot device tree compiler */
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
#include <stdint.h>
|
|
#include "sconfig.h"
|
|
|
|
int yylex();
|
|
void yyerror(const char *s);
|
|
|
|
static struct bus *cur_parent;
|
|
static struct chip_instance *cur_chip_instance;
|
|
static struct fw_config_field *cur_field;
|
|
static struct fw_config_field_bits *cur_bits;
|
|
|
|
%}
|
|
%union {
|
|
struct device *dev;
|
|
struct chip_instance *chip_instance;
|
|
char *string;
|
|
uint64_t number;
|
|
}
|
|
|
|
%token CHIP DEVICE REGISTER ALIAS REFERENCE ASSOCIATION BOOL STATUS MANDATORY BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ SLOT_DESC IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT GENERIC SPI USB MMIO LPC ESPI GPIO FW_CONFIG_TABLE FW_CONFIG_FIELD FW_CONFIG_OPTION FW_CONFIG_PROBE PIPE
|
|
%%
|
|
devtree: { cur_parent = root_parent; } | devtree chip | devtree fw_config_table;
|
|
|
|
chipchildren: chipchildren device | chipchildren chip | chipchildren registers | chipchildren reference | /* empty */ ;
|
|
|
|
devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | devicechildren ioapic_irq | devicechildren smbios_slot_desc | devicechildren registers | devicechildren fw_config_probe | /* empty */ ;
|
|
|
|
chip: CHIP STRING /* == path */ {
|
|
$<chip_instance>$ = new_chip_instance($<string>2);
|
|
chip_enqueue_tail(cur_chip_instance);
|
|
cur_chip_instance = $<chip_instance>$;
|
|
}
|
|
chipchildren END {
|
|
cur_chip_instance = chip_dequeue_tail();
|
|
};
|
|
|
|
device: DEVICE BUS NUMBER /* == devnum */ alias status {
|
|
$<dev>$ = new_device_raw(cur_parent, cur_chip_instance, $<number>2, $<string>3, $<string>4, $<number>5);
|
|
cur_parent = $<dev>$->last_bus;
|
|
}
|
|
devicechildren END {
|
|
cur_parent = $<dev>6->parent;
|
|
};
|
|
|
|
device: DEVICE REFERENCE STRING status {
|
|
$<dev>$ = new_device_reference(cur_parent, cur_chip_instance, $<string>3, $<number>4);
|
|
cur_parent = $<dev>$->last_bus;
|
|
}
|
|
devicechildren END {
|
|
cur_parent = $<dev>5->parent;
|
|
};
|
|
|
|
alias: /* empty */ {
|
|
$<string>$ = NULL;
|
|
} | ALIAS STRING {
|
|
$<string>$ = $<string>2;
|
|
};
|
|
|
|
status: BOOL | STATUS ;
|
|
|
|
resource: RESOURCE NUMBER /* == resnum */ EQUALS NUMBER /* == resval */
|
|
{ add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ;
|
|
|
|
reference: REFERENCE STRING /* == alias */ ASSOCIATION STRING /* == field in chip config */
|
|
{ add_reference(cur_chip_instance, $<string>4, $<string>2); } ;
|
|
|
|
registers: REGISTER STRING /* == regname */ EQUALS STRING /* == regval */
|
|
{ add_register(cur_chip_instance, $<string>2, $<string>4); } ;
|
|
|
|
subsystemid: SUBSYSTEMID NUMBER NUMBER
|
|
{ add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 0); };
|
|
|
|
subsystemid: SUBSYSTEMID NUMBER NUMBER INHERIT
|
|
{ add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 1); };
|
|
|
|
ioapic_irq: IOAPIC_IRQ NUMBER PCIINT NUMBER
|
|
{ add_ioapic_info(cur_parent, strtol($<string>2, NULL, 16), $<string>3, strtol($<string>4, NULL, 16)); };
|
|
|
|
smbios_slot_desc: SLOT_DESC STRING STRING STRING STRING
|
|
{ add_slot_desc(cur_parent, $<string>2, $<string>3, $<string>4, $<string>5); };
|
|
|
|
smbios_slot_desc: SLOT_DESC STRING STRING STRING
|
|
{ add_slot_desc(cur_parent, $<string>2, $<string>3, $<string>4, NULL); };
|
|
|
|
smbios_slot_desc: SLOT_DESC STRING STRING
|
|
{ add_slot_desc(cur_parent, $<string>2, $<string>3, NULL, NULL); };
|
|
|
|
/* fw_config: firmware configuration table */
|
|
fw_config_table: FW_CONFIG_TABLE fw_config_table_children END { };
|
|
|
|
/* fw_config -> field */
|
|
fw_config_table_children: fw_config_table_children fw_config_field | /* empty */ ;
|
|
|
|
/* field -> option */
|
|
fw_config_field_children: fw_config_field_children fw_config_option | /* empty */ ;
|
|
|
|
/* <start-bit> <end-bit> */
|
|
fw_config_field_bits: NUMBER /* == start bit */ NUMBER /* == end bit */
|
|
{
|
|
append_fw_config_bits(&cur_bits, strtoul($<string>1, NULL, 0), strtoul($<string>2, NULL, 0));
|
|
};
|
|
|
|
/* field <start-bit> <end-bit>(| <start-bit> <end-bit>)* */
|
|
fw_config_field_bits_repeating: PIPE fw_config_field_bits fw_config_field_bits_repeating | /* empty */ ;
|
|
|
|
fw_config_field: FW_CONFIG_FIELD STRING fw_config_field_bits fw_config_field_bits_repeating
|
|
{ cur_field = new_fw_config_field($<string>2, cur_bits); }
|
|
fw_config_field_children END { cur_bits = NULL; };
|
|
|
|
/* field <bit> (for single-bit fields) */
|
|
fw_config_field: FW_CONFIG_FIELD STRING NUMBER /* == bit */ {
|
|
cur_bits = NULL;
|
|
append_fw_config_bits(&cur_bits, strtoul($<string>3, NULL, 0), strtoul($<string>3, NULL, 0));
|
|
cur_field = new_fw_config_field($<string>2, cur_bits);
|
|
}
|
|
fw_config_field_children END { cur_bits = NULL; };
|
|
|
|
/* field (for adding options to an existing field) */
|
|
fw_config_field: FW_CONFIG_FIELD STRING {
|
|
cur_field = get_fw_config_field($<string>2);
|
|
}
|
|
fw_config_field_children END { cur_bits = NULL; };
|
|
|
|
/* option <value> */
|
|
fw_config_option: FW_CONFIG_OPTION STRING NUMBER /* == field value */
|
|
{ add_fw_config_option(cur_field, $<string>2, strtoull($<string>3, NULL, 0)); };
|
|
|
|
/* probe <field> <option> */
|
|
fw_config_probe: FW_CONFIG_PROBE STRING /* == field */ STRING /* == option */
|
|
{ add_fw_config_probe(cur_parent, $<string>2, $<string>3); }
|
|
%%
|