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. |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <stdio.h> |
| 18 | #include <stdlib.h> |
| 19 | #include <string.h> |
| 20 | #include <sys/types.h> |
| 21 | #include <sys/stat.h> |
| 22 | #include <unistd.h> |
| 23 | #include <errno.h> |
| 24 | |
| 25 | enum devtype { chip, device }; |
| 26 | |
| 27 | struct resource; |
| 28 | struct resource { |
| 29 | int type; |
| 30 | int index; |
| 31 | int base; |
| 32 | struct resource *next; |
| 33 | }; |
| 34 | |
| 35 | struct reg; |
| 36 | struct reg { |
| 37 | char *key; |
| 38 | char *value; |
| 39 | struct reg *next; |
| 40 | }; |
| 41 | |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 42 | struct pci_irq_info { |
| 43 | int ioapic_irq_pin; |
| 44 | int ioapic_dst_id; |
| 45 | }; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 46 | struct device; |
| 47 | struct device { |
| 48 | int id; |
| 49 | int enabled; |
| 50 | int used; |
| 51 | int multidev; |
| 52 | int link; |
| 53 | int rescnt; |
| 54 | int chiph_exists; |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 55 | int subsystem_vendor; |
| 56 | int subsystem_device; |
| 57 | int inherit_subsystem; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 58 | char *ops; |
| 59 | char *name; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 60 | char *name_underscore; |
| 61 | char *path; |
| 62 | int path_a; |
| 63 | int path_b; |
| 64 | int bustype; |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 65 | struct pci_irq_info pci_irq_info[4]; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 66 | enum devtype type; |
| 67 | struct device *parent; |
| 68 | struct device *bus; |
| 69 | struct device *next; |
| 70 | struct device *nextdev; |
| 71 | struct device *children; |
| 72 | struct device *latestchild; |
| 73 | struct device *next_sibling; |
| 74 | struct device *sibling; |
| 75 | struct device *chip; |
| 76 | struct resource *res; |
| 77 | struct reg *reg; |
| 78 | }; |
| 79 | |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 80 | struct device *head; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 81 | |
| 82 | struct header; |
| 83 | struct header { |
| 84 | char *name; |
Kyösti Mälkki | aada2e1 | 2012-10-07 15:08:32 +0200 | [diff] [blame] | 85 | int chiph_exists; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 86 | struct header *next; |
| 87 | }; |
| 88 | |
| 89 | void fold_in(struct device *parent); |
| 90 | |
| 91 | void postprocess_devtree(void); |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 92 | struct device *new_chip(struct device *parent, struct device *bus, char *path); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 93 | void add_header(struct device *dev); |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 94 | 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] | 95 | void alias_siblings(struct device *d); |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 96 | void add_resource(struct device *dev, int type, int index, int base); |
| 97 | void add_register(struct device *dev, char *name, char *val); |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 98 | void add_pci_subsystem_ids(struct device *dev, int vendor, int device, int inherit); |