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 | |
Patrick Georgi | 2dbfcb7 | 2012-05-30 16:26:30 +0200 | [diff] [blame] | 21 | #include <ctype.h> |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 22 | #include "sconfig.h" |
| 23 | #include "sconfig.tab.h" |
| 24 | |
Patrick Georgi | 7fc9e29 | 2010-07-15 15:59:07 +0000 | [diff] [blame] | 25 | extern int linenum; |
| 26 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 27 | struct device *head, *lastdev; |
| 28 | |
| 29 | struct header headers; |
| 30 | |
| 31 | static int devcount = 0; |
| 32 | |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 33 | typedef enum { |
| 34 | STATIC_MODE, |
| 35 | BOOTBLOCK_MODE, |
| 36 | KCONFIG_MODE |
| 37 | } scan_t; |
| 38 | |
| 39 | static scan_t scan_mode = STATIC_MODE; |
| 40 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 41 | static struct device root; |
| 42 | static struct device mainboard = { |
| 43 | .name = "mainboard", |
| 44 | .name_underscore = "mainboard", |
| 45 | .id = 0, |
| 46 | .chip = &mainboard, |
| 47 | .type = chip, |
Stefan Reinauer | 188e3c2 | 2012-07-26 12:46:48 -0700 | [diff] [blame] | 48 | #ifdef MAINBOARDS_HAVE_CHIP_H |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 49 | .chiph_exists = 1, |
Stefan Reinauer | 188e3c2 | 2012-07-26 12:46:48 -0700 | [diff] [blame] | 50 | #else |
| 51 | .chiph_exists = 0, |
| 52 | #endif |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 53 | .children = &root |
| 54 | }; |
| 55 | |
| 56 | static struct device root = { |
| 57 | .name = "dev_root", |
| 58 | .name_underscore = "dev_root", |
| 59 | .id = 0, |
| 60 | .chip = &mainboard, |
| 61 | .type = device, |
| 62 | .path = " .type = DEVICE_PATH_ROOT ", |
| 63 | .ops = "&default_dev_ops_root", |
| 64 | .parent = &root, |
| 65 | .bus = &root, |
| 66 | .enabled = 1 |
| 67 | }; |
| 68 | |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 69 | static struct device *new_dev(struct device *parent, struct device *bus) { |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 70 | struct device *dev = malloc(sizeof(struct device)); |
| 71 | memset(dev, 0, sizeof(struct device)); |
| 72 | dev->id = ++devcount; |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 73 | dev->parent = parent; |
| 74 | dev->bus = bus; |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 75 | dev->subsystem_vendor = -1; |
| 76 | dev->subsystem_device = -1; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 77 | head->next = dev; |
| 78 | head = dev; |
| 79 | return dev; |
| 80 | } |
| 81 | |
| 82 | static int device_match(struct device *a, struct device *b) { |
| 83 | if ((a->bustype == b->bustype) && (a->bus == b->bus) && (a->path_a == b->path_a) && (a->path_b == b->path_b)) |
| 84 | return 1; |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | void fold_in(struct device *parent) { |
| 89 | struct device *child = parent->children; |
| 90 | struct device *latest = 0; |
| 91 | while (child != latest) { |
| 92 | if (child->children) { |
| 93 | if (!latest) latest = child->children; |
| 94 | parent->latestchild->next_sibling = child->children; |
| 95 | parent->latestchild = child->latestchild; |
| 96 | } |
| 97 | child = child->next_sibling; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | int yywrap(void) { |
| 102 | return 1; |
| 103 | } |
| 104 | |
| 105 | void yyerror (char const *str) |
| 106 | { |
Stefan Reinauer | 7c1f6b8 | 2010-08-16 18:21:56 +0000 | [diff] [blame] | 107 | extern char *yytext; |
| 108 | fprintf (stderr, "line %d: %s: %s\n", linenum + 1, yytext, str); |
| 109 | exit(1); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | void postprocess_devtree(void) { |
| 113 | root.next_sibling = root.children; |
| 114 | root.next_sibling->next_sibling = root.next_sibling->children; |
| 115 | |
| 116 | struct device *dev = &root; |
| 117 | while (dev) { |
| 118 | /* skip "chip" elements in children chain */ |
| 119 | while (dev->children && (dev->children->type == chip)) dev->children = dev->children->children; |
| 120 | /* skip "chip" elements and functions of the same device in sibling chain */ |
| 121 | while (dev->sibling && dev->sibling->used) dev->sibling = dev->sibling->sibling; |
| 122 | /* If end of chain, and parent is a chip, move on */ |
| 123 | if (!dev->sibling && (dev->parent->type == chip)) dev->sibling = dev->parent->sibling; |
| 124 | /* skip chips */ |
| 125 | while (dev->sibling && dev->sibling->type == chip) dev->sibling = dev->sibling->children; |
| 126 | /* skip duplicate function elements in nextdev chain */ |
| 127 | while (dev->nextdev && dev->nextdev->used) dev->nextdev = dev->nextdev->nextdev; |
| 128 | dev = dev->next_sibling; |
| 129 | } |
| 130 | } |
| 131 | |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 132 | void translate_name(char *str, int uppercase) |
| 133 | { |
| 134 | char *c; |
| 135 | for (c = str; *c; c++) { |
| 136 | if (*c == '/') *c = '_'; |
| 137 | if (*c == '-') *c = '_'; |
| 138 | if (uppercase) |
| 139 | *c = toupper(*c); |
| 140 | } |
| 141 | } |
| 142 | |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 143 | struct device *new_chip(struct device *parent, struct device *bus, char *path) { |
| 144 | struct device *new_chip = new_dev(parent, bus); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 145 | new_chip->chiph_exists = 1; |
| 146 | new_chip->name = path; |
| 147 | new_chip->name_underscore = strdup(new_chip->name); |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 148 | translate_name(new_chip->name_underscore, 0); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 149 | new_chip->type = chip; |
| 150 | new_chip->chip = new_chip; |
| 151 | |
| 152 | struct stat st; |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 153 | char *chip_h = malloc(strlen(path)+18); |
Stefan Reinauer | 76c44ae | 2011-10-14 12:41:46 -0700 | [diff] [blame] | 154 | sprintf(chip_h, "src/%s", path); |
| 155 | if ((stat(chip_h, &st) == -1) && (errno == ENOENT)) { |
| 156 | fprintf(stderr, "ERROR: Chip component %s does not exist.\n", |
| 157 | path); |
| 158 | exit(1); |
| 159 | } |
| 160 | |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 161 | if (scan_mode == STATIC_MODE) |
| 162 | sprintf(chip_h, "src/%s/chip.h", path); |
| 163 | else if (scan_mode == BOOTBLOCK_MODE) |
| 164 | sprintf(chip_h, "src/%s/bootblock.c", path); |
| 165 | |
| 166 | if ((scan_mode == STATIC_MODE) || (scan_mode == BOOTBLOCK_MODE)) { |
| 167 | if ((stat(chip_h, &st) == -1) && (errno == ENOENT)) |
| 168 | new_chip->chiph_exists = 0; |
| 169 | } |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 170 | |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 171 | if (parent->latestchild) { |
| 172 | parent->latestchild->next_sibling = new_chip; |
| 173 | parent->latestchild->sibling = new_chip; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 174 | } |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 175 | parent->latestchild = new_chip; |
| 176 | if (!parent->children) |
| 177 | parent->children = new_chip; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 178 | return new_chip; |
| 179 | } |
| 180 | |
| 181 | void add_header(struct device *dev) { |
Kyösti Mälkki | aada2e1 | 2012-10-07 15:08:32 +0200 | [diff] [blame] | 182 | int include_exists = 0; |
| 183 | struct header *h = &headers; |
| 184 | while (h->next) { |
| 185 | int result = strcmp(dev->name, h->next->name); |
| 186 | if (result == 0) { |
| 187 | include_exists = 1; |
| 188 | break; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 189 | } |
Kyösti Mälkki | aada2e1 | 2012-10-07 15:08:32 +0200 | [diff] [blame] | 190 | if (result < 0) break; |
| 191 | h = h->next; |
| 192 | } |
| 193 | if (!include_exists) { |
| 194 | struct header *tmp = h->next; |
| 195 | h->next = malloc(sizeof(struct header)); |
| 196 | memset(h->next, 0, sizeof(struct header)); |
| 197 | h->next->chiph_exists = dev->chiph_exists; |
| 198 | h->next->name = dev->name; |
| 199 | h->next->next = tmp; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 200 | } |
| 201 | } |
| 202 | |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 203 | struct device *new_device(struct device *parent, struct device *busdev, const int bus, const char *devnum, int enabled) { |
| 204 | struct device *new_d = new_dev(parent, busdev); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 205 | new_d->bustype = bus; |
| 206 | |
| 207 | char *tmp; |
| 208 | new_d->path_a = strtol(strdup(devnum), &tmp, 16); |
| 209 | if (*tmp == '.') { |
| 210 | tmp++; |
| 211 | new_d->path_b = strtol(tmp, NULL, 16); |
| 212 | } |
| 213 | |
| 214 | char *name = malloc(10); |
| 215 | sprintf(name, "_dev%d", new_d->id); |
| 216 | new_d->name = name; |
| 217 | new_d->name_underscore = name; // shouldn't be necessary, but avoid 0-ptr |
| 218 | new_d->type = device; |
| 219 | new_d->enabled = enabled; |
| 220 | new_d->chip = new_d->parent->chip; |
| 221 | |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 222 | if (parent->latestchild) { |
| 223 | parent->latestchild->next_sibling = new_d; |
| 224 | parent->latestchild->sibling = new_d; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 225 | } |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 226 | parent->latestchild = new_d; |
| 227 | if (!parent->children) |
| 228 | parent->children = new_d; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 229 | |
| 230 | lastdev->nextdev = new_d; |
| 231 | lastdev = new_d; |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 232 | |
| 233 | switch(bus) { |
| 234 | case PCI: |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 235 | new_d->path = ".type=DEVICE_PATH_PCI,{.pci={ .devfn = PCI_DEVFN(0x%x,%d)}}"; |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 236 | break; |
| 237 | |
| 238 | case PNP: |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 239 | new_d->path = ".type=DEVICE_PATH_PNP,{.pnp={ .port = 0x%x, .device = 0x%x }}"; |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 240 | break; |
| 241 | |
| 242 | case I2C: |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 243 | new_d->path = ".type=DEVICE_PATH_I2C,{.i2c={ .device = 0x%x }}"; |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 244 | break; |
| 245 | |
| 246 | case APIC: |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 247 | new_d->path = ".type=DEVICE_PATH_APIC,{.apic={ .apic_id = 0x%x }}"; |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 248 | break; |
| 249 | |
| 250 | case APIC_CLUSTER: |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 251 | new_d->path = ".type=DEVICE_PATH_APIC_CLUSTER,{.apic_cluster={ .cluster = 0x%x }}"; |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 252 | break; |
| 253 | |
| 254 | case PCI_DOMAIN: |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 255 | new_d->path = ".type=DEVICE_PATH_PCI_DOMAIN,{.pci_domain={ .domain = 0x%x }}"; |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 256 | break; |
| 257 | |
| 258 | case IOAPIC: |
| 259 | new_d->path = ".type=DEVICE_PATH_IOAPIC,{.ioapic={ .ioapic_id = 0x%x }}"; |
| 260 | break; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 261 | } |
| 262 | return new_d; |
| 263 | } |
| 264 | |
| 265 | void alias_siblings(struct device *d) { |
| 266 | while (d) { |
| 267 | int link = 0; |
| 268 | struct device *cmp = d->next_sibling; |
| 269 | while (cmp && (cmp->bus == d->bus) && (cmp->path_a == d->path_a) && (cmp->path_b == d->path_b)) { |
| 270 | if (cmp->type==device && !cmp->used) { |
| 271 | if (device_match(d, cmp)) { |
| 272 | d->multidev = 1; |
| 273 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 274 | cmp->id = d->id; |
| 275 | cmp->name = d->name; |
| 276 | cmp->used = 1; |
| 277 | cmp->link = ++link; |
| 278 | } |
| 279 | } |
| 280 | cmp = cmp->next_sibling; |
| 281 | } |
| 282 | d = d->next_sibling; |
| 283 | } |
| 284 | } |
| 285 | |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 286 | void add_resource(struct device *dev, int type, int index, int base) { |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 287 | struct resource *r = malloc(sizeof(struct resource)); |
| 288 | memset (r, 0, sizeof(struct resource)); |
| 289 | r->type = type; |
| 290 | r->index = index; |
| 291 | r->base = base; |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 292 | if (dev->res) { |
| 293 | struct resource *head = dev->res; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 294 | while (head->next) head = head->next; |
| 295 | head->next = r; |
| 296 | } else { |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 297 | dev->res = r; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 298 | } |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 299 | dev->rescnt++; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 300 | } |
| 301 | |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 302 | void add_register(struct device *dev, char *name, char *val) { |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 303 | struct reg *r = malloc(sizeof(struct reg)); |
| 304 | memset (r, 0, sizeof(struct reg)); |
| 305 | r->key = name; |
| 306 | r->value = val; |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 307 | if (dev->reg) { |
| 308 | struct reg *head = dev->reg; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 309 | // sorting to be equal to sconfig's behaviour |
| 310 | int sort = strcmp(r->key, head->key); |
| 311 | if (sort == 0) { |
| 312 | printf("ERROR: duplicate 'register' key.\n"); |
| 313 | exit(1); |
| 314 | } |
| 315 | if (sort<0) { |
| 316 | r->next = head; |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 317 | dev->reg = r; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 318 | } else { |
| 319 | while ((head->next) && (strcmp(head->next->key, r->key)<0)) head = head->next; |
| 320 | r->next = head->next; |
| 321 | head->next = r; |
| 322 | } |
| 323 | } else { |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 324 | dev->reg = r; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 328 | void add_pci_subsystem_ids(struct device *dev, int vendor, int device, int inherit) |
| 329 | { |
| 330 | if (dev->bustype != PCI && dev->bustype != PCI_DOMAIN) { |
| 331 | printf("ERROR: 'subsystem' only allowed for PCI devices\n"); |
| 332 | exit(1); |
| 333 | } |
| 334 | |
| 335 | dev->subsystem_vendor = vendor; |
| 336 | dev->subsystem_device = device; |
| 337 | dev->inherit_subsystem = inherit; |
| 338 | } |
| 339 | |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 340 | void add_ioapic_info(struct device *dev, int apicid, const char *_srcpin, int irqpin) |
| 341 | { |
| 342 | |
| 343 | int srcpin; |
| 344 | |
| 345 | if (!_srcpin || strlen(_srcpin) < 4 ||strncasecmp(_srcpin, "INT", 3) || |
| 346 | _srcpin[3] < 'A' || _srcpin[3] > 'D') { |
| 347 | printf("ERROR: malformed ioapic_irq args: %s\n", _srcpin); |
| 348 | exit(1); |
| 349 | } |
| 350 | |
| 351 | srcpin = _srcpin[3] - 'A'; |
| 352 | |
| 353 | if (dev->bustype != PCI && dev->bustype != PCI_DOMAIN) { |
| 354 | printf("ERROR: ioapic config only allowed for PCI devices\n"); |
| 355 | exit(1); |
| 356 | } |
| 357 | |
| 358 | if (srcpin > 3) { |
Patrick Georgi | 116327e | 2012-07-20 12:47:06 +0200 | [diff] [blame] | 359 | printf("ERROR: srcpin '%d' invalid\n", srcpin); |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 360 | exit(1); |
| 361 | } |
| 362 | dev->pci_irq_info[srcpin].ioapic_irq_pin = irqpin; |
| 363 | dev->pci_irq_info[srcpin].ioapic_dst_id = apicid; |
| 364 | } |
| 365 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 366 | static void pass0(FILE *fil, struct device *ptr) { |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 367 | if (ptr->type == device && ptr->id == 0) |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 368 | fprintf(fil, "ROMSTAGE_CONST struct bus %s_links[];\n", ptr->name); |
| 369 | |
Myles Watson | c25cc11 | 2010-05-21 14:33:48 +0000 | [diff] [blame] | 370 | if ((ptr->type == device) && (ptr->id != 0) && (!ptr->used)) { |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 371 | fprintf(fil, "ROMSTAGE_CONST static struct device %s;\n", ptr->name); |
Myles Watson | c25cc11 | 2010-05-21 14:33:48 +0000 | [diff] [blame] | 372 | if (ptr->rescnt > 0) |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 373 | fprintf(fil, "ROMSTAGE_CONST struct resource %s_res[];\n", ptr->name); |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 374 | if (ptr->children || ptr->multidev) |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 375 | fprintf(fil, "ROMSTAGE_CONST struct bus %s_links[];\n", |
| 376 | ptr->name); |
Myles Watson | c25cc11 | 2010-05-21 14:33:48 +0000 | [diff] [blame] | 377 | } |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 378 | } |
| 379 | |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 380 | static void pass1(FILE *fil, struct device *ptr) |
| 381 | { |
| 382 | int pin; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 383 | if (!ptr->used && (ptr->type == device)) { |
Stefan Reinauer | df61dd2 | 2010-08-09 12:02:00 +0000 | [diff] [blame] | 384 | if (ptr->id != 0) |
Patrick Georgi | 2dbfcb7 | 2012-05-30 16:26:30 +0200 | [diff] [blame] | 385 | fprintf(fil, "static "); |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 386 | fprintf(fil, "ROMSTAGE_CONST struct device %s = {\n", ptr->name); |
| 387 | fprintf(fil, "#ifndef __PRE_RAM__\n"); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 388 | fprintf(fil, "\t.ops = %s,\n", (ptr->ops)?(ptr->ops):"0"); |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 389 | fprintf(fil, "#endif\n"); |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 390 | fprintf(fil, "\t.bus = &%s_links[%d],\n", ptr->bus->name, ptr->bus->link); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 391 | fprintf(fil, "\t.path = {"); |
| 392 | fprintf(fil, ptr->path, ptr->path_a, ptr->path_b); |
| 393 | fprintf(fil, "},\n"); |
| 394 | fprintf(fil, "\t.enabled = %d,\n", ptr->enabled); |
| 395 | fprintf(fil, "\t.on_mainboard = 1,\n"); |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 396 | if (ptr->subsystem_vendor > 0) |
| 397 | fprintf(fil, "\t.subsystem_vendor = 0x%04x,\n", ptr->subsystem_vendor); |
| 398 | |
Sven Schnelle | 0fa50a1 | 2012-06-21 22:19:48 +0200 | [diff] [blame] | 399 | for(pin = 0; pin < 4; pin++) { |
| 400 | if (ptr->pci_irq_info[pin].ioapic_irq_pin > 0) |
| 401 | fprintf(fil, "\t.pci_irq_info[%d].ioapic_irq_pin = %d,\n", pin, ptr->pci_irq_info[pin].ioapic_irq_pin); |
| 402 | |
| 403 | if (ptr->pci_irq_info[pin].ioapic_dst_id > 0) |
| 404 | fprintf(fil, "\t.pci_irq_info[%d].ioapic_dst_id = %d,\n", pin, ptr->pci_irq_info[pin].ioapic_dst_id); |
| 405 | } |
| 406 | |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 407 | if (ptr->subsystem_device > 0) |
| 408 | fprintf(fil, "\t.subsystem_device = 0x%04x,\n", ptr->subsystem_device); |
| 409 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 410 | if (ptr->rescnt > 0) { |
Myles Watson | c25cc11 | 2010-05-21 14:33:48 +0000 | [diff] [blame] | 411 | fprintf(fil, "\t.resource_list = &%s_res[0],\n", ptr->name); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 412 | } |
| 413 | int link = 0; |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 414 | if (ptr->children || ptr->multidev) |
| 415 | fprintf(fil, "\t.link_list = &%s_links[0],\n", ptr->name); |
| 416 | else |
Patrick Georgi | 2dbfcb7 | 2012-05-30 16:26:30 +0200 | [diff] [blame] | 417 | fprintf(fil, "\t.link_list = NULL,\n"); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 418 | if (ptr->sibling) |
| 419 | fprintf(fil, "\t.sibling = &%s,\n", ptr->sibling->name); |
Kyösti Mälkki | aada2e1 | 2012-10-07 15:08:32 +0200 | [diff] [blame] | 420 | fprintf(fil, "#ifndef __PRE_RAM__\n"); |
| 421 | fprintf(fil, "\t.chip_ops = &%s_ops,\n", ptr->chip->name_underscore); |
| 422 | fprintf(fil, "#endif\n"); |
| 423 | if (ptr->chip->chiph_exists) |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 424 | fprintf(fil, "\t.chip_info = &%s_info_%d,\n", ptr->chip->name_underscore, ptr->chip->id); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 425 | if (ptr->nextdev) |
| 426 | fprintf(fil, "\t.next=&%s\n", ptr->nextdev->name); |
| 427 | fprintf(fil, "};\n"); |
| 428 | } |
Myles Watson | c25cc11 | 2010-05-21 14:33:48 +0000 | [diff] [blame] | 429 | if (ptr->rescnt > 0) { |
| 430 | int i=1; |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 431 | fprintf(fil, "ROMSTAGE_CONST struct resource %s_res[] = {\n", |
| 432 | ptr->name); |
Myles Watson | c25cc11 | 2010-05-21 14:33:48 +0000 | [diff] [blame] | 433 | struct resource *r = ptr->res; |
| 434 | while (r) { |
| 435 | fprintf(fil, "\t\t{ .flags=IORESOURCE_FIXED | IORESOURCE_ASSIGNED | IORESOURCE_"); |
| 436 | if (r->type == IRQ) fprintf(fil, "IRQ"); |
| 437 | if (r->type == DRQ) fprintf(fil, "DRQ"); |
| 438 | if (r->type == IO) fprintf(fil, "IO"); |
| 439 | fprintf(fil, ", .index=0x%x, .base=0x%x,", r->index, r->base); |
| 440 | if (r->next) |
| 441 | fprintf(fil, ".next=&%s_res[%d]},\n", ptr->name, i++); |
| 442 | else |
| 443 | fprintf(fil, ".next=NULL },\n"); |
| 444 | r = r->next; |
| 445 | } |
| 446 | fprintf(fil, "\t };\n"); |
| 447 | } |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 448 | if (!ptr->used && ptr->type == device && (ptr->children || ptr->multidev)) { |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 449 | fprintf(fil, "ROMSTAGE_CONST struct bus %s_links[] = {\n", ptr->name); |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 450 | if (ptr->multidev) { |
| 451 | struct device *d = ptr; |
| 452 | while (d) { |
| 453 | if (device_match(d, ptr)) { |
| 454 | fprintf(fil, "\t\t[%d] = {\n", d->link); |
| 455 | fprintf(fil, "\t\t\t.link_num = %d,\n", d->link); |
| 456 | fprintf(fil, "\t\t\t.dev = &%s,\n", d->name); |
| 457 | if (d->children) |
| 458 | fprintf(fil, "\t\t\t.children = &%s,\n", d->children->name); |
Myles Watson | 1965a23 | 2010-06-10 04:06:52 +0000 | [diff] [blame] | 459 | if (d->next_sibling && device_match(d->next_sibling, ptr)) |
Myles Watson | 894a347 | 2010-06-09 22:41:35 +0000 | [diff] [blame] | 460 | fprintf(fil, "\t\t\t.next=&%s_links[%d],\n", d->name, d->link+1); |
| 461 | else |
| 462 | fprintf(fil, "\t\t\t.next = NULL,\n"); |
| 463 | fprintf(fil, "\t\t},\n"); |
| 464 | } |
| 465 | d = d->next_sibling; |
| 466 | } |
| 467 | } else { |
| 468 | if (ptr->children) { |
| 469 | fprintf(fil, "\t\t[0] = {\n"); |
| 470 | fprintf(fil, "\t\t\t.link_num = 0,\n"); |
| 471 | fprintf(fil, "\t\t\t.dev = &%s,\n", ptr->name); |
| 472 | fprintf(fil, "\t\t\t.children = &%s,\n", ptr->children->name); |
| 473 | fprintf(fil, "\t\t\t.next = NULL,\n"); |
| 474 | fprintf(fil, "\t\t},\n"); |
| 475 | } |
| 476 | } |
| 477 | fprintf(fil, "\t};\n"); |
| 478 | } |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 479 | if ((ptr->type == chip) && (ptr->chiph_exists)) { |
| 480 | if (ptr->reg) { |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 481 | fprintf(fil, "ROMSTAGE_CONST struct %s_config ROMSTAGE_CONST %s_info_%d = {\n", |
| 482 | ptr->name_underscore, ptr->name_underscore, |
| 483 | ptr->id); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 484 | struct reg *r = ptr->reg; |
| 485 | while (r) { |
| 486 | fprintf(fil, "\t.%s = %s,\n", r->key, r->value); |
| 487 | r = r->next; |
| 488 | } |
| 489 | fprintf(fil, "};\n\n"); |
| 490 | } else { |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 491 | fprintf(fil, "ROMSTAGE_CONST struct %s_config ROMSTAGE_CONST %s_info_%d = { };\n", |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 492 | ptr->name_underscore, ptr->name_underscore, ptr->id); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 493 | } |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | static void walk_device_tree(FILE *fil, struct device *ptr, void (*func)(FILE *, struct device*), struct device *chips) { |
| 498 | do { |
| 499 | func(fil, ptr); |
| 500 | ptr = ptr->next_sibling; |
| 501 | } while (ptr); |
| 502 | } |
| 503 | |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 504 | static void inherit_subsystem_ids(FILE *file, struct device *dev) |
| 505 | { |
| 506 | struct device *p; |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 507 | |
| 508 | if (dev->subsystem_vendor != -1 && dev->subsystem_device != -1) { |
| 509 | /* user already gave us a subsystem vendor/device */ |
| 510 | return; |
| 511 | } |
| 512 | |
Sylvain "ythier" Hitier | 5325a48 | 2011-03-01 21:57:11 +0000 | [diff] [blame] | 513 | for(p = dev; p && p != p->parent; p = p->parent) { |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 514 | |
| 515 | if (p->bustype != PCI && p->bustype != PCI_DOMAIN) |
| 516 | continue; |
| 517 | |
| 518 | if (p->inherit_subsystem) { |
| 519 | dev->subsystem_vendor = p->subsystem_vendor; |
| 520 | dev->subsystem_device = p->subsystem_device; |
| 521 | break; |
| 522 | } |
| 523 | } |
| 524 | } |
| 525 | |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 526 | static void usage(void) |
| 527 | { |
| 528 | printf("usage: sconfig vendor/mainboard outputdir [-{s|b|k} outputfile]\n"); |
| 529 | printf("\t-s file\tcreate ramstage static device map\n"); |
| 530 | printf("\t-b file\tcreate bootblock init_mainboard()\n"); |
| 531 | printf("\t-k file\tcreate Kconfig devicetree section\n"); |
| 532 | printf("Defaults to \"-s static.c\" if no {s|b|k} specified.\n"); |
| 533 | exit (1); |
| 534 | } |
| 535 | |
| 536 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 537 | int main(int argc, char** argv) { |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 538 | if (argc < 3) |
| 539 | usage(); |
| 540 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 541 | char *mainboard=argv[1]; |
| 542 | char *outputdir=argv[2]; |
| 543 | char *devtree=malloc(strlen(mainboard)+30); |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 544 | sprintf(devtree, "src/mainboard/%s/devicetree.cb", mainboard); |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 545 | char *outputc; |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 546 | |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 547 | if (argc == 3) { |
| 548 | scan_mode = STATIC_MODE; |
| 549 | outputc=malloc(strlen(outputdir)+20); |
| 550 | sprintf(outputc, "%s/static.c", outputdir); |
| 551 | } else if ((argc == 5) && (argv[3][0] == '-') && (argv[3][2] == 0)) { |
| 552 | |
| 553 | switch (argv[3][1]) { |
| 554 | case 's': |
| 555 | scan_mode = STATIC_MODE; |
| 556 | break; |
| 557 | case 'b': |
| 558 | scan_mode = BOOTBLOCK_MODE; |
| 559 | break; |
| 560 | case 'k': |
| 561 | scan_mode = KCONFIG_MODE; |
| 562 | break; |
| 563 | default: |
| 564 | usage(); |
| 565 | break; |
| 566 | } |
| 567 | char *outputfile=argv[4]; |
| 568 | |
| 569 | outputc=malloc(strlen(outputdir)+strlen(outputfile)+2); |
| 570 | sprintf(outputc, "%s/%s", outputdir, outputfile); |
| 571 | } |
| 572 | |
| 573 | headers.next = 0; |
Stefan Reinauer | 188e3c2 | 2012-07-26 12:46:48 -0700 | [diff] [blame] | 574 | #ifdef MAINBOARDS_HAVE_CHIP_H |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 575 | if (scan_mode == STATIC_MODE) { |
| 576 | headers.next = malloc(sizeof(struct header)); |
| 577 | headers.next->name = malloc(strlen(mainboard)+12); |
| 578 | headers.next->next = 0; |
| 579 | sprintf(headers.next->name, "mainboard/%s", mainboard); |
| 580 | } |
Stefan Reinauer | 188e3c2 | 2012-07-26 12:46:48 -0700 | [diff] [blame] | 581 | #endif |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 582 | |
| 583 | FILE *filec = fopen(devtree, "r"); |
Stefan Reinauer | 7c1f6b8 | 2010-08-16 18:21:56 +0000 | [diff] [blame] | 584 | if (!filec) { |
| 585 | fprintf(stderr, "Could not open file '%s' for reading: ", devtree); |
| 586 | perror(NULL); |
| 587 | exit(1); |
| 588 | } |
| 589 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 590 | yyrestart(filec); |
| 591 | |
Patrick Georgi | 68befd5 | 2010-05-05 12:05:25 +0000 | [diff] [blame] | 592 | lastdev = head = &root; |
Stefan Reinauer | 7c1f6b8 | 2010-08-16 18:21:56 +0000 | [diff] [blame] | 593 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 594 | yyparse(); |
Stefan Reinauer | 7c1f6b8 | 2010-08-16 18:21:56 +0000 | [diff] [blame] | 595 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 596 | fclose(filec); |
| 597 | |
| 598 | if ((head->type == chip) && (!head->chiph_exists)) { |
| 599 | struct device *tmp = head; |
| 600 | head = &root; |
| 601 | while (head->next != tmp) head = head->next; |
| 602 | } |
| 603 | |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 604 | FILE *autogen = fopen(outputc, "w"); |
| 605 | if (!autogen) { |
Stefan Reinauer | 7c1f6b8 | 2010-08-16 18:21:56 +0000 | [diff] [blame] | 606 | fprintf(stderr, "Could not open file '%s' for writing: ", outputc); |
| 607 | perror(NULL); |
| 608 | exit(1); |
| 609 | } |
| 610 | |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 611 | struct header *h; |
| 612 | if (scan_mode == STATIC_MODE) { |
| 613 | |
| 614 | fprintf(autogen, "#include <device/device.h>\n"); |
| 615 | fprintf(autogen, "#include <device/pci.h>\n"); |
| 616 | h = &headers; |
| 617 | while (h->next) { |
| 618 | h = h->next; |
Kyösti Mälkki | aada2e1 | 2012-10-07 15:08:32 +0200 | [diff] [blame] | 619 | if (h->chiph_exists) |
| 620 | fprintf(autogen, "#include \"%s/chip.h\"\n", h->name); |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 621 | } |
Kyösti Mälkki | aada2e1 | 2012-10-07 15:08:32 +0200 | [diff] [blame] | 622 | fprintf(autogen, "\n#ifndef __PRE_RAM__\n"); |
Kyösti Mälkki | fee73df | 2012-08-21 11:37:11 +0300 | [diff] [blame] | 623 | h = &headers; |
| 624 | while (h->next) { |
| 625 | h = h->next; |
| 626 | char *name_underscore = strdup(h->name); |
| 627 | translate_name(name_underscore, 0); |
| 628 | fprintf(autogen, "extern struct chip_operations %s_ops;\n", name_underscore); |
| 629 | free(name_underscore); |
| 630 | } |
Kyösti Mälkki | aada2e1 | 2012-10-07 15:08:32 +0200 | [diff] [blame] | 631 | fprintf(autogen, "#endif\n"); |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 632 | |
| 633 | walk_device_tree(autogen, &root, inherit_subsystem_ids, NULL); |
| 634 | fprintf(autogen, "\n/* pass 0 */\n"); |
| 635 | walk_device_tree(autogen, &root, pass0, NULL); |
Stefan Reinauer | 188e3c2 | 2012-07-26 12:46:48 -0700 | [diff] [blame] | 636 | fprintf(autogen, "\n/* pass 1 */\n" |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 637 | "ROMSTAGE_CONST struct device * ROMSTAGE_CONST last_dev = &%s;\n", lastdev->name); |
Stefan Reinauer | 188e3c2 | 2012-07-26 12:46:48 -0700 | [diff] [blame] | 638 | #ifdef MAINBOARDS_HAVE_CHIP_H |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 639 | fprintf(autogen, "static ROMSTAGE_CONST struct mainboard_config ROMSTAGE_CONST mainboard_info_0;\n"); |
Stefan Reinauer | a675d49 | 2012-08-07 14:50:47 -0700 | [diff] [blame] | 640 | #else |
| 641 | fprintf(autogen, "extern struct chip_operations mainboard_ops;\n"); |
Stefan Reinauer | 188e3c2 | 2012-07-26 12:46:48 -0700 | [diff] [blame] | 642 | #endif |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 643 | walk_device_tree(autogen, &root, pass1, NULL); |
| 644 | |
| 645 | } else if (scan_mode == BOOTBLOCK_MODE) { |
| 646 | h = &headers; |
| 647 | while (h->next) { |
| 648 | h = h->next; |
| 649 | fprintf(autogen, "#include \"%s/bootblock.c\"\n", h->name); |
| 650 | } |
| 651 | |
| 652 | fprintf(autogen, "\n#if CONFIG_HAS_MAINBOARD_BOOTBLOCK\n"); |
| 653 | fprintf(autogen, "#include \"mainboard/%s/bootblock.c\"\n", mainboard); |
| 654 | fprintf(autogen, "#else\n"); |
| 655 | fprintf(autogen, "static unsigned long init_mainboard(int bsp_cpu)\n{\n"); |
| 656 | fprintf(autogen, "\tif (! bsp_cpu) return 0;\n"); |
| 657 | h = &headers; |
| 658 | while (h->next) { |
| 659 | h = h->next; |
| 660 | translate_name(h->name, 0); |
| 661 | fprintf(autogen, "\tinit_%s();\n", h->name); |
| 662 | } |
| 663 | |
| 664 | fprintf(autogen, "\treturn 0;\n}\n"); |
| 665 | fprintf(autogen, "#endif\n"); |
| 666 | |
| 667 | } else if (scan_mode == KCONFIG_MODE) { |
| 668 | fprintf(autogen, "\nconfig MAINBOARD_DIR\n\tstring\n"); |
| 669 | fprintf(autogen, "\tdefault %s\n", mainboard); |
| 670 | |
| 671 | fprintf(autogen, "\nconfig MAINBOARD_DEVTREE\n\tdef_bool y\n"); |
| 672 | h = &headers; |
| 673 | while (h->next) { |
| 674 | h = h->next; |
| 675 | translate_name(h->name, 1); |
| 676 | fprintf(autogen, "\tselect %s\n", h->name); |
| 677 | } |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 678 | } |
Sven Schnelle | 270a908 | 2011-03-01 19:58:15 +0000 | [diff] [blame] | 679 | |
Kyösti Mälkki | 472d902 | 2011-12-05 20:33:55 +0200 | [diff] [blame] | 680 | fclose(autogen); |
Stefan Reinauer | 7c1f6b8 | 2010-08-16 18:21:56 +0000 | [diff] [blame] | 681 | |
Patrick Georgi | 114e7b2 | 2010-05-05 11:19:50 +0000 | [diff] [blame] | 682 | return 0; |
| 683 | } |