blob: d55b18bda97bc6ff744a4b3cf6d0b0592ac94bd0 [file] [log] [blame]
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +00001%{
2/*
3 * sconfig, coreboot device tree compiler
4 *
5 * Copyright (C) 2010 coresystems GmbH
Stefan Reinauer2e78aa52016-05-07 01:11:14 -07006 * written by Patrick Georgi <patrick@georgi-clan.de>
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +00007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000016 */
17
Patrick Georgi114e7b22010-05-05 11:19:50 +000018#include "sconfig.h"
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000019
Stefan Reinauer2e78aa52016-05-07 01:11:14 -070020int yylex();
21void yyerror(const char *s);
22
Furquan Shaikh93198262018-06-03 04:22:17 -070023static struct bus *cur_parent;
Furquan Shaikhc56ae2f2018-05-31 10:33:16 -070024static struct chip_instance *cur_chip_instance;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000025
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000026%}
27%union {
Furquan Shaikh93198262018-06-03 04:22:17 -070028 struct device *dev;
Furquan Shaikhc56ae2f2018-05-31 10:33:16 -070029 struct chip_instance *chip_instance;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000030 char *string;
31 int number;
32}
Sven Schnelle270a9082011-03-01 19:58:15 +000033
Ronald G. Minnich466ca2c2019-10-22 02:02:24 +000034%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
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000035%%
Furquan Shaikh93198262018-06-03 04:22:17 -070036devtree: { cur_parent = root_parent; } chip;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000037
Patrick Georgi8f625f62010-05-05 13:13:47 +000038chipchildren: chipchildren device | chipchildren chip | chipchildren registers | /* empty */ ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000039
Patrick Rudolphac24d3c2019-04-12 14:42:17 +020040devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | devicechildren ioapic_irq | devicechildren smbios_slot_desc | /* empty */ ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000041
42chip: CHIP STRING /* == path */ {
Furquan Shaikhc56ae2f2018-05-31 10:33:16 -070043 $<chip_instance>$ = new_chip_instance($<string>2);
44 chip_enqueue_tail(cur_chip_instance);
45 cur_chip_instance = $<chip_instance>$;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000046}
Patrick Georgi8f625f62010-05-05 13:13:47 +000047 chipchildren END {
Furquan Shaikhc56ae2f2018-05-31 10:33:16 -070048 cur_chip_instance = chip_dequeue_tail();
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000049};
50
Hung-Te Lin936dbe12018-09-10 10:51:26 +080051device: DEVICE BUS NUMBER /* == devnum */ status {
Furquan Shaikh93198262018-06-03 04:22:17 -070052 $<dev>$ = new_device(cur_parent, cur_chip_instance, $<number>2, $<string>3, $<number>4);
53 cur_parent = $<dev>$->last_bus;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000054}
Patrick Georgi8f625f62010-05-05 13:13:47 +000055 devicechildren END {
Furquan Shaikh93198262018-06-03 04:22:17 -070056 cur_parent = $<dev>5->parent;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000057};
58
Ronald G. Minnich466ca2c2019-10-22 02:02:24 +000059status: BOOL | STATUS ;
Hung-Te Lin936dbe12018-09-10 10:51:26 +080060
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000061resource: RESOURCE NUMBER /* == resnum */ EQUALS NUMBER /* == resval */
Patrick Georgi68befd52010-05-05 12:05:25 +000062 { add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000063
64registers: REGISTER STRING /* == regname */ EQUALS STRING /* == regval */
Furquan Shaikhc56ae2f2018-05-31 10:33:16 -070065 { add_register(cur_chip_instance, $<string>2, $<string>4); } ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000066
Sven Schnelle270a9082011-03-01 19:58:15 +000067subsystemid: SUBSYSTEMID NUMBER NUMBER
68 { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 0); };
69
70subsystemid: SUBSYSTEMID NUMBER NUMBER INHERIT
71 { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 1); };
72
Sven Schnelle0fa50a12012-06-21 22:19:48 +020073ioapic_irq: IOAPIC_IRQ NUMBER PCIINT NUMBER
74 { add_ioapic_info(cur_parent, strtol($<string>2, NULL, 16), $<string>3, strtol($<string>4, NULL, 16)); };
Patrick Rudolphac24d3c2019-04-12 14:42:17 +020075
76smbios_slot_desc: SLOT_DESC STRING STRING STRING STRING
77 { add_slot_desc(cur_parent, $<string>2, $<string>3, $<string>4, $<string>5); };
78
79smbios_slot_desc: SLOT_DESC STRING STRING STRING
80 { add_slot_desc(cur_parent, $<string>2, $<string>3, $<string>4, NULL); };
81
82smbios_slot_desc: SLOT_DESC STRING STRING
83 { add_slot_desc(cur_parent, $<string>2, $<string>3, NULL, NULL); };
84
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000085%%