blob: 2c35eb3ceab900f245e91ff6ef50e9f122c75092 [file] [log] [blame]
Patrick Georgi114e7b22010-05-05 11:19:50 +00001/*
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 Georgi114e7b22010-05-05 11:19:50 +000015 */
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
25enum devtype { chip, device };
26
27struct resource;
28struct resource {
29 int type;
30 int index;
31 int base;
32 struct resource *next;
33};
34
35struct reg;
36struct reg {
37 char *key;
38 char *value;
39 struct reg *next;
40};
41
Sven Schnelle0fa50a12012-06-21 22:19:48 +020042struct pci_irq_info {
43 int ioapic_irq_pin;
44 int ioapic_dst_id;
45};
Patrick Georgi114e7b22010-05-05 11:19:50 +000046struct device;
47struct device {
48 int id;
49 int enabled;
50 int used;
51 int multidev;
52 int link;
53 int rescnt;
54 int chiph_exists;
Sven Schnelle270a9082011-03-01 19:58:15 +000055 int subsystem_vendor;
56 int subsystem_device;
57 int inherit_subsystem;
Patrick Georgi114e7b22010-05-05 11:19:50 +000058 char *ops;
59 char *name;
Patrick Georgi114e7b22010-05-05 11:19:50 +000060 char *name_underscore;
61 char *path;
62 int path_a;
63 int path_b;
64 int bustype;
Sven Schnelle0fa50a12012-06-21 22:19:48 +020065 struct pci_irq_info pci_irq_info[4];
Patrick Georgi114e7b22010-05-05 11:19:50 +000066 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 Georgi68befd52010-05-05 12:05:25 +000080struct device *head;
Patrick Georgi114e7b22010-05-05 11:19:50 +000081
82struct header;
83struct header {
84 char *name;
Kyösti Mälkkiaada2e12012-10-07 15:08:32 +020085 int chiph_exists;
Patrick Georgi114e7b22010-05-05 11:19:50 +000086 struct header *next;
87};
88
89void fold_in(struct device *parent);
90
91void postprocess_devtree(void);
Patrick Georgi68befd52010-05-05 12:05:25 +000092struct device *new_chip(struct device *parent, struct device *bus, char *path);
Patrick Georgi114e7b22010-05-05 11:19:50 +000093void add_header(struct device *dev);
Patrick Georgi68befd52010-05-05 12:05:25 +000094struct device *new_device(struct device *parent, struct device *busdev, const int bus, const char *devnum, int enabled);
Patrick Georgi114e7b22010-05-05 11:19:50 +000095void alias_siblings(struct device *d);
Patrick Georgi68befd52010-05-05 12:05:25 +000096void add_resource(struct device *dev, int type, int index, int base);
97void add_register(struct device *dev, char *name, char *val);
Sven Schnelle270a9082011-03-01 19:58:15 +000098void add_pci_subsystem_ids(struct device *dev, int vendor, int device, int inherit);