blob: 161cf81551f9e51a48749092b76c55723b896317 [file] [log] [blame]
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +00001%{
Patrick Georgiea063cb2020-05-08 19:28:13 +02002/* sconfig, coreboot device tree compiler */
Patrick Georgi7333a112020-05-08 20:48:04 +02003/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +00004
Patrick Georgi114e7b22010-05-05 11:19:50 +00005#include "sconfig.h"
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +00006
Stefan Reinauer2e78aa52016-05-07 01:11:14 -07007int yylex();
8void yyerror(const char *s);
9
Furquan Shaikh93198262018-06-03 04:22:17 -070010static struct bus *cur_parent;
Furquan Shaikhc56ae2f2018-05-31 10:33:16 -070011static struct chip_instance *cur_chip_instance;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000012
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000013%}
14%union {
Furquan Shaikh93198262018-06-03 04:22:17 -070015 struct device *dev;
Furquan Shaikhc56ae2f2018-05-31 10:33:16 -070016 struct chip_instance *chip_instance;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000017 char *string;
18 int number;
19}
Sven Schnelle270a9082011-03-01 19:58:15 +000020
Raul E Rangel3f3f53c2020-05-06 11:47:04 -060021%token CHIP DEVICE REGISTER 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
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000022%%
Furquan Shaikh93198262018-06-03 04:22:17 -070023devtree: { cur_parent = root_parent; } chip;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000024
Patrick Georgi8f625f62010-05-05 13:13:47 +000025chipchildren: chipchildren device | chipchildren chip | chipchildren registers | /* empty */ ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000026
Nico Huberd9b2f792020-04-28 16:28:03 +020027devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | devicechildren ioapic_irq | devicechildren smbios_slot_desc | devicechildren registers | /* empty */ ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000028
29chip: CHIP STRING /* == path */ {
Furquan Shaikhc56ae2f2018-05-31 10:33:16 -070030 $<chip_instance>$ = new_chip_instance($<string>2);
31 chip_enqueue_tail(cur_chip_instance);
32 cur_chip_instance = $<chip_instance>$;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000033}
Patrick Georgi8f625f62010-05-05 13:13:47 +000034 chipchildren END {
Furquan Shaikhc56ae2f2018-05-31 10:33:16 -070035 cur_chip_instance = chip_dequeue_tail();
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000036};
37
Hung-Te Lin936dbe12018-09-10 10:51:26 +080038device: DEVICE BUS NUMBER /* == devnum */ status {
Furquan Shaikh93198262018-06-03 04:22:17 -070039 $<dev>$ = new_device(cur_parent, cur_chip_instance, $<number>2, $<string>3, $<number>4);
40 cur_parent = $<dev>$->last_bus;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000041}
Patrick Georgi8f625f62010-05-05 13:13:47 +000042 devicechildren END {
Furquan Shaikh93198262018-06-03 04:22:17 -070043 cur_parent = $<dev>5->parent;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000044};
45
Ronald G. Minnich466ca2c2019-10-22 02:02:24 +000046status: BOOL | STATUS ;
Hung-Te Lin936dbe12018-09-10 10:51:26 +080047
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000048resource: RESOURCE NUMBER /* == resnum */ EQUALS NUMBER /* == resval */
Patrick Georgi68befd52010-05-05 12:05:25 +000049 { add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000050
51registers: REGISTER STRING /* == regname */ EQUALS STRING /* == regval */
Furquan Shaikhc56ae2f2018-05-31 10:33:16 -070052 { add_register(cur_chip_instance, $<string>2, $<string>4); } ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000053
Sven Schnelle270a9082011-03-01 19:58:15 +000054subsystemid: SUBSYSTEMID NUMBER NUMBER
55 { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 0); };
56
57subsystemid: SUBSYSTEMID NUMBER NUMBER INHERIT
58 { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 1); };
59
Sven Schnelle0fa50a12012-06-21 22:19:48 +020060ioapic_irq: IOAPIC_IRQ NUMBER PCIINT NUMBER
61 { add_ioapic_info(cur_parent, strtol($<string>2, NULL, 16), $<string>3, strtol($<string>4, NULL, 16)); };
Patrick Rudolphac24d3c2019-04-12 14:42:17 +020062
63smbios_slot_desc: SLOT_DESC STRING STRING STRING STRING
64 { add_slot_desc(cur_parent, $<string>2, $<string>3, $<string>4, $<string>5); };
65
66smbios_slot_desc: SLOT_DESC STRING STRING STRING
67 { add_slot_desc(cur_parent, $<string>2, $<string>3, $<string>4, NULL); };
68
69smbios_slot_desc: SLOT_DESC STRING STRING
70 { add_slot_desc(cur_parent, $<string>2, $<string>3, NULL, NULL); };
71
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000072%%