3 * sconfig, coreboot device tree compiler
5 * Copyright (C) 2010 coresystems GmbH
6 * written by Patrick Georgi <patrick.georgi@coresystems.de>
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.
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.
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
24 static struct device *cur_parent, *cur_bus;
28 struct device *device;
33 %token CHIP DEVICE REGISTER BOOL BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC APIC_CLUSTER PCI_DOMAIN IRQ DRQ IO NUMBER SUBSYSTEMID INHERIT
35 devtree: { cur_parent = cur_bus = head; } chip { postprocess_devtree(); } ;
37 chipchildren: chipchildren device | chipchildren chip | chipchildren registers | /* empty */ ;
39 devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | /* empty */ ;
41 chip: CHIP STRING /* == path */ {
42 $<device>$ = new_chip(cur_parent, cur_bus, $<string>2);
43 cur_parent = $<device>$;
46 cur_parent = $<device>3->parent;
48 add_header($<device>3);
51 device: DEVICE BUS NUMBER /* == devnum */ BOOL {
52 $<device>$ = new_device(cur_parent, cur_bus, $<number>2, $<string>3, $<number>4);
53 cur_parent = $<device>$;
57 cur_parent = $<device>5->parent;
58 cur_bus = $<device>5->bus;
60 alias_siblings($<device>5->children);
63 resource: RESOURCE NUMBER /* == resnum */ EQUALS NUMBER /* == resval */
64 { add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ;
66 registers: REGISTER STRING /* == regname */ EQUALS STRING /* == regval */
67 { add_register(cur_parent, $<string>2, $<string>4); } ;
69 subsystemid: SUBSYSTEMID NUMBER NUMBER
70 { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 0); };
72 subsystemid: SUBSYSTEMID NUMBER NUMBER INHERIT
73 { add_pci_subsystem_ids(cur_parent, strtol($<string>2, NULL, 16), strtol($<string>3, NULL, 16), 1); };