Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * sconfig, coreboot device tree compiler |
| 3 | * |
| 4 | * Copyright (C) 2010 coresystems GmbH |
| 5 | * written by Patrick Georgi <patrick.georgi@coresystems.de> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> |
| 23 | #include <string.h> |
| 24 | #include <sys/types.h> |
| 25 | #include <sys/stat.h> |
| 26 | #include <unistd.h> |
| 27 | #include <errno.h> |
| 28 | |
| 29 | enum devtype { chip, device }; |
| 30 | |
| 31 | struct resource; |
| 32 | struct resource { |
| 33 | int type; |
| 34 | int index; |
| 35 | int base; |
| 36 | struct resource *next; |
| 37 | }; |
| 38 | |
| 39 | struct reg; |
| 40 | struct reg { |
| 41 | char *key; |
| 42 | char *value; |
| 43 | struct reg *next; |
| 44 | }; |
| 45 | |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 46 | struct pci_irq_info { |
| 47 | int ioapic_irq_pin; |
| 48 | int ioapic_dst_id; |
| 49 | }; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 50 | struct device; |
| 51 | struct device { |
| 52 | int id; |
| 53 | int enabled; |
| 54 | int used; |
| 55 | int multidev; |
| 56 | int link; |
| 57 | int rescnt; |
| 58 | int chiph_exists; |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 59 | int subsystem_vendor; |
| 60 | int subsystem_device; |
| 61 | int inherit_subsystem; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 62 | char *ops; |
| 63 | char *name; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 64 | char *name_underscore; |
| 65 | char *path; |
| 66 | int path_a; |
| 67 | int path_b; |
| 68 | int bustype; |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 69 | struct pci_irq_info pci_irq_info[4]; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 70 | enum devtype type; |
| 71 | struct device *parent; |
| 72 | struct device *bus; |
| 73 | struct device *next; |
| 74 | struct device *nextdev; |
| 75 | struct device *children; |
| 76 | struct device *latestchild; |
| 77 | struct device *next_sibling; |
| 78 | struct device *sibling; |
| 79 | struct device *chip; |
| 80 | struct resource *res; |
| 81 | struct reg *reg; |
| 82 | }; |
| 83 | |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 84 | struct device *head; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 85 | |
| 86 | struct header; |
| 87 | struct header { |
| 88 | char *name; |
Kyösti Mälkki | aada2e1 | 2012-10-07 15:08:32 +0200 | [diff] [blame] | 89 | int chiph_exists; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 90 | struct header *next; |
| 91 | }; |
| 92 | |
| 93 | void fold_in(struct device *parent); |
| 94 | |
| 95 | void postprocess_devtree(void); |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 96 | struct device *new_chip(struct device *parent, struct device *bus, char *path); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 97 | void add_header(struct device *dev); |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 98 | struct device *new_device(struct device *parent, struct device *busdev, const int bus, const char *devnum, int enabled); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 99 | void alias_siblings(struct device *d); |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 100 | void add_resource(struct device *dev, int type, int index, int base); |
| 101 | void add_register(struct device *dev, char *name, char *val); |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 102 | void add_pci_subsystem_ids(struct device *dev, int vendor, int device, int inherit); |