blob: ba450b89c5f21ed452b3d8402c0fcc7eb97da51c [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
6 * written by Patrick Georgi <patrick.georgi@coresystems.de>
7 *
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.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
20 */
21
Patrick Georgi114e7b22010-05-05 11:19:50 +000022#include "sconfig.h"
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000023
Patrick Georgi68befd52010-05-05 12:05:25 +000024static struct device *cur_parent, *cur_bus;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000025
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000026%}
27%union {
28 struct device *device;
29 char *string;
30 int number;
31}
Sven Schnelle270a9082011-03-01 19:58:15 +000032
Aaron Durbinffda804b2014-09-03 12:40:15 -050033%token CHIP DEVICE REGISTER BOOL BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000034%%
Patrick Georgi8f625f62010-05-05 13:13:47 +000035devtree: { cur_parent = cur_bus = head; } chip { postprocess_devtree(); } ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000036
Patrick Georgi8f625f62010-05-05 13:13:47 +000037chipchildren: chipchildren device | chipchildren chip | chipchildren registers | /* empty */ ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000038
Sven Schnelle0fa50a12012-06-21 22:19:48 +020039devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | devicechildren ioapic_irq | /* empty */ ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000040
41chip: CHIP STRING /* == path */ {
Patrick Georgi68befd52010-05-05 12:05:25 +000042 $<device>$ = new_chip(cur_parent, cur_bus, $<string>2);
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000043 cur_parent = $<device>$;
44}
Patrick Georgi8f625f62010-05-05 13:13:47 +000045 chipchildren END {
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000046 cur_parent = $<device>3->parent;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000047 fold_in($<device>3);
Patrick Georgi114e7b22010-05-05 11:19:50 +000048 add_header($<device>3);
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000049};
50
51device: DEVICE BUS NUMBER /* == devnum */ BOOL {
Patrick Georgi68befd52010-05-05 12:05:25 +000052 $<device>$ = new_device(cur_parent, cur_bus, $<number>2, $<string>3, $<number>4);
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000053 cur_parent = $<device>$;
54 cur_bus = $<device>$;
55}
Patrick Georgi8f625f62010-05-05 13:13:47 +000056 devicechildren END {
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000057 cur_parent = $<device>5->parent;
58 cur_bus = $<device>5->bus;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000059 fold_in($<device>5);
Patrick Georgi114e7b22010-05-05 11:19:50 +000060 alias_siblings($<device>5->children);
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000061};
62
63resource: RESOURCE NUMBER /* == resnum */ EQUALS NUMBER /* == resval */
Patrick Georgi68befd52010-05-05 12:05:25 +000064 { add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000065
66registers: REGISTER STRING /* == regname */ EQUALS STRING /* == regval */
Patrick Georgi68befd52010-05-05 12:05:25 +000067 { add_register(cur_parent, $<string>2, $<string>4); } ;
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000068
Sven Schnelle270a9082011-03-01 19:58:15 +000069subsystemid: SUBSYSTEMID NUMBER NUMBER
70 { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 0); };
71
72subsystemid: SUBSYSTEMID NUMBER NUMBER INHERIT
73 { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 1); };
74
Sven Schnelle0fa50a12012-06-21 22:19:48 +020075ioapic_irq: IOAPIC_IRQ NUMBER PCIINT NUMBER
76 { add_ioapic_info(cur_parent, strtol($<string>2, NULL, 16), $<string>3, strtol($<string>4, NULL, 16)); };
Patrick Georgi7e8c9aa2010-04-08 11:37:43 +000077%%