Grant Likely | e169cfb | 2009-11-23 14:53:09 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Functions for working with the Flattened Device Tree data format |
| 3 | * |
| 4 | * Copyright 2009 Benjamin Herrenschmidt, IBM Corp |
| 5 | * benh@kernel.crashing.org |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * version 2 as published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
Grant Likely | 41f8800 | 2009-11-23 20:07:01 -0700 | [diff] [blame] | 12 | #include <linux/kernel.h> |
Grant Likely | f7b3a83 | 2009-11-24 03:26:58 -0700 | [diff] [blame] | 13 | #include <linux/initrd.h> |
Grant Likely | a1727da | 2013-08-28 21:18:32 +0100 | [diff] [blame] | 14 | #include <linux/memblock.h> |
Grant Likely | e169cfb | 2009-11-23 14:53:09 -0700 | [diff] [blame] | 15 | #include <linux/of.h> |
| 16 | #include <linux/of_fdt.h> |
Marek Szyprowski | 3f0c820 | 2014-02-28 14:42:48 +0100 | [diff] [blame] | 17 | #include <linux/of_reserved_mem.h> |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 18 | #include <linux/sizes.h> |
Jeremy Kerr | 4ef7b37 | 2010-02-14 07:13:47 -0700 | [diff] [blame] | 19 | #include <linux/string.h> |
| 20 | #include <linux/errno.h> |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 21 | #include <linux/slab.h> |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 22 | #include <linux/libfdt.h> |
Rob Herring | b0a6fb3 | 2014-04-02 16:56:48 -0500 | [diff] [blame] | 23 | #include <linux/debugfs.h> |
Rob Herring | fb11ffe | 2014-03-27 08:07:01 -0500 | [diff] [blame] | 24 | #include <linux/serial_core.h> |
Grant Likely | 51975db | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 25 | |
Fabio Estevam | c89810a | 2012-01-02 14:19:03 -0200 | [diff] [blame] | 26 | #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ |
Jeremy Kerr | 4ef7b37 | 2010-02-14 07:13:47 -0700 | [diff] [blame] | 27 | #include <asm/page.h> |
| 28 | |
Laura Abbott | 704033c | 2014-07-15 10:03:35 -0700 | [diff] [blame] | 29 | /* |
| 30 | * of_fdt_limit_memory - limit the number of regions in the /memory node |
| 31 | * @limit: maximum entries |
| 32 | * |
| 33 | * Adjust the flattened device tree to have at most 'limit' number of |
| 34 | * memory entries in the /memory node. This function may be called |
| 35 | * any time after initial_boot_param is set. |
| 36 | */ |
| 37 | void of_fdt_limit_memory(int limit) |
| 38 | { |
| 39 | int memory; |
| 40 | int len; |
| 41 | const void *val; |
| 42 | int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; |
| 43 | int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; |
| 44 | const uint32_t *addr_prop; |
| 45 | const uint32_t *size_prop; |
| 46 | int root_offset; |
| 47 | int cell_size; |
| 48 | |
| 49 | root_offset = fdt_path_offset(initial_boot_params, "/"); |
| 50 | if (root_offset < 0) |
| 51 | return; |
| 52 | |
| 53 | addr_prop = fdt_getprop(initial_boot_params, root_offset, |
| 54 | "#address-cells", NULL); |
| 55 | if (addr_prop) |
| 56 | nr_address_cells = fdt32_to_cpu(*addr_prop); |
| 57 | |
| 58 | size_prop = fdt_getprop(initial_boot_params, root_offset, |
| 59 | "#size-cells", NULL); |
| 60 | if (size_prop) |
| 61 | nr_size_cells = fdt32_to_cpu(*size_prop); |
| 62 | |
| 63 | cell_size = sizeof(uint32_t)*(nr_address_cells + nr_size_cells); |
| 64 | |
| 65 | memory = fdt_path_offset(initial_boot_params, "/memory"); |
| 66 | if (memory > 0) { |
| 67 | val = fdt_getprop(initial_boot_params, memory, "reg", &len); |
| 68 | if (len > limit*cell_size) { |
| 69 | len = limit*cell_size; |
| 70 | pr_debug("Limiting number of entries to %d\n", limit); |
| 71 | fdt_setprop(initial_boot_params, memory, "reg", val, |
| 72 | len); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
Stephen Neuendorffer | 9706a36 | 2010-11-18 15:54:59 -0800 | [diff] [blame] | 77 | /** |
| 78 | * of_fdt_is_compatible - Return true if given node from the given blob has |
| 79 | * compat in its compatible list |
| 80 | * @blob: A device tree blob |
| 81 | * @node: node to test |
| 82 | * @compat: compatible string to compare with compatible list. |
Grant Likely | a4f740c | 2010-10-30 11:49:09 -0400 | [diff] [blame] | 83 | * |
| 84 | * On match, returns a non-zero value with smaller values returned for more |
| 85 | * specific compatible values. |
Stephen Neuendorffer | 9706a36 | 2010-11-18 15:54:59 -0800 | [diff] [blame] | 86 | */ |
Rob Herring | c972de1 | 2014-04-01 22:48:01 -0500 | [diff] [blame] | 87 | int of_fdt_is_compatible(const void *blob, |
Stephen Neuendorffer | 9706a36 | 2010-11-18 15:54:59 -0800 | [diff] [blame] | 88 | unsigned long node, const char *compat) |
| 89 | { |
| 90 | const char *cp; |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 91 | int cplen; |
| 92 | unsigned long l, score = 0; |
Stephen Neuendorffer | 9706a36 | 2010-11-18 15:54:59 -0800 | [diff] [blame] | 93 | |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 94 | cp = fdt_getprop(blob, node, "compatible", &cplen); |
Stephen Neuendorffer | 9706a36 | 2010-11-18 15:54:59 -0800 | [diff] [blame] | 95 | if (cp == NULL) |
| 96 | return 0; |
| 97 | while (cplen > 0) { |
Grant Likely | a4f740c | 2010-10-30 11:49:09 -0400 | [diff] [blame] | 98 | score++; |
Stephen Neuendorffer | 9706a36 | 2010-11-18 15:54:59 -0800 | [diff] [blame] | 99 | if (of_compat_cmp(cp, compat, strlen(compat)) == 0) |
Grant Likely | a4f740c | 2010-10-30 11:49:09 -0400 | [diff] [blame] | 100 | return score; |
Stephen Neuendorffer | 9706a36 | 2010-11-18 15:54:59 -0800 | [diff] [blame] | 101 | l = strlen(cp) + 1; |
| 102 | cp += l; |
| 103 | cplen -= l; |
| 104 | } |
| 105 | |
| 106 | return 0; |
| 107 | } |
| 108 | |
Grant Likely | a4f740c | 2010-10-30 11:49:09 -0400 | [diff] [blame] | 109 | /** |
| 110 | * of_fdt_match - Return true if node matches a list of compatible values |
| 111 | */ |
Rob Herring | c972de1 | 2014-04-01 22:48:01 -0500 | [diff] [blame] | 112 | int of_fdt_match(const void *blob, unsigned long node, |
Uwe Kleine-König | 7b482c8 | 2011-12-20 22:56:45 +0100 | [diff] [blame] | 113 | const char *const *compat) |
Grant Likely | a4f740c | 2010-10-30 11:49:09 -0400 | [diff] [blame] | 114 | { |
| 115 | unsigned int tmp, score = 0; |
| 116 | |
| 117 | if (!compat) |
| 118 | return 0; |
| 119 | |
| 120 | while (*compat) { |
| 121 | tmp = of_fdt_is_compatible(blob, node, *compat); |
| 122 | if (tmp && (score == 0 || (tmp < score))) |
| 123 | score = tmp; |
| 124 | compat++; |
| 125 | } |
| 126 | |
| 127 | return score; |
| 128 | } |
| 129 | |
Grant Likely | 4485681 | 2013-08-29 13:30:35 +0100 | [diff] [blame] | 130 | static void *unflatten_dt_alloc(void **mem, unsigned long size, |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 131 | unsigned long align) |
| 132 | { |
| 133 | void *res; |
| 134 | |
Grant Likely | 4485681 | 2013-08-29 13:30:35 +0100 | [diff] [blame] | 135 | *mem = PTR_ALIGN(*mem, align); |
| 136 | res = *mem; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 137 | *mem += size; |
| 138 | |
| 139 | return res; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * unflatten_dt_node - Alloc and populate a device_node from the flat tree |
Stephen Neuendorffer | a40d6c4 | 2010-11-18 15:55:00 -0800 | [diff] [blame] | 144 | * @blob: The parent device tree blob |
Andres Salomon | a7006c9 | 2011-03-17 17:32:35 -0700 | [diff] [blame] | 145 | * @mem: Memory chunk to use for allocating device nodes and properties |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 146 | * @p: pointer to node in flat tree |
| 147 | * @dad: Parent struct device_node |
| 148 | * @allnextpp: pointer to ->allnext from last allocated device_node |
| 149 | * @fpsize: Size of the node path up at the current depth. |
| 150 | */ |
Rob Herring | c972de1 | 2014-04-01 22:48:01 -0500 | [diff] [blame] | 151 | static void * unflatten_dt_node(void *blob, |
Grant Likely | 4485681 | 2013-08-29 13:30:35 +0100 | [diff] [blame] | 152 | void *mem, |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 153 | int *poffset, |
Stephen Neuendorffer | a40d6c4 | 2010-11-18 15:55:00 -0800 | [diff] [blame] | 154 | struct device_node *dad, |
| 155 | struct device_node ***allnextpp, |
| 156 | unsigned long fpsize) |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 157 | { |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 158 | const __be32 *p; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 159 | struct device_node *np; |
| 160 | struct property *pp, **prev_pp = NULL; |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 161 | const char *pathp; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 162 | unsigned int l, allocl; |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 163 | static int depth = 0; |
| 164 | int old_depth; |
| 165 | int offset; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 166 | int has_name = 0; |
| 167 | int new_format = 0; |
| 168 | |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 169 | pathp = fdt_get_name(blob, *poffset, &l); |
| 170 | if (!pathp) |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 171 | return mem; |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 172 | |
| 173 | allocl = l++; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 174 | |
| 175 | /* version 0x10 has a more compact unit name here instead of the full |
| 176 | * path. we accumulate the full path size using "fpsize", we'll rebuild |
| 177 | * it later. We detect this because the first character of the name is |
| 178 | * not '/'. |
| 179 | */ |
| 180 | if ((*pathp) != '/') { |
| 181 | new_format = 1; |
| 182 | if (fpsize == 0) { |
| 183 | /* root node: special case. fpsize accounts for path |
| 184 | * plus terminating zero. root node only has '/', so |
| 185 | * fpsize should be 2, but we want to avoid the first |
| 186 | * level nodes to have two '/' so we use fpsize 1 here |
| 187 | */ |
| 188 | fpsize = 1; |
| 189 | allocl = 2; |
Catalin Marinas | 0fca5de | 2012-11-16 15:14:38 +0000 | [diff] [blame] | 190 | l = 1; |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 191 | pathp = ""; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 192 | } else { |
| 193 | /* account for '/' and path size minus terminal 0 |
| 194 | * already in 'l' |
| 195 | */ |
| 196 | fpsize += l; |
| 197 | allocl = fpsize; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl, |
| 202 | __alignof__(struct device_node)); |
| 203 | if (allnextpp) { |
Grant Likely | c22618a | 2012-11-14 22:37:12 +0000 | [diff] [blame] | 204 | char *fn; |
Pantelis Antoniou | 0829f6d | 2013-12-13 20:08:59 +0200 | [diff] [blame] | 205 | of_node_init(np); |
Grant Likely | c22618a | 2012-11-14 22:37:12 +0000 | [diff] [blame] | 206 | np->full_name = fn = ((char *)np) + sizeof(*np); |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 207 | if (new_format) { |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 208 | /* rebuild full path for new format */ |
| 209 | if (dad && dad->parent) { |
| 210 | strcpy(fn, dad->full_name); |
| 211 | #ifdef DEBUG |
| 212 | if ((strlen(fn) + l + 1) != allocl) { |
| 213 | pr_debug("%s: p: %d, l: %d, a: %d\n", |
| 214 | pathp, (int)strlen(fn), |
| 215 | l, allocl); |
| 216 | } |
| 217 | #endif |
| 218 | fn += strlen(fn); |
| 219 | } |
| 220 | *(fn++) = '/'; |
Grant Likely | c22618a | 2012-11-14 22:37:12 +0000 | [diff] [blame] | 221 | } |
| 222 | memcpy(fn, pathp, l); |
| 223 | |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 224 | prev_pp = &np->properties; |
| 225 | **allnextpp = np; |
| 226 | *allnextpp = &np->allnext; |
| 227 | if (dad != NULL) { |
| 228 | np->parent = dad; |
| 229 | /* we temporarily use the next field as `last_child'*/ |
| 230 | if (dad->next == NULL) |
| 231 | dad->child = np; |
| 232 | else |
| 233 | dad->next->sibling = np; |
| 234 | dad->next = np; |
| 235 | } |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 236 | } |
Andres Salomon | a7006c9 | 2011-03-17 17:32:35 -0700 | [diff] [blame] | 237 | /* process properties */ |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 238 | for (offset = fdt_first_property_offset(blob, *poffset); |
| 239 | (offset >= 0); |
| 240 | (offset = fdt_next_property_offset(blob, offset))) { |
| 241 | const char *pname; |
| 242 | u32 sz; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 243 | |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 244 | if (!(p = fdt_getprop_by_offset(blob, offset, &pname, &sz))) { |
| 245 | offset = -FDT_ERR_INTERNAL; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 246 | break; |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 247 | } |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 248 | |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 249 | if (pname == NULL) { |
| 250 | pr_info("Can't find property name in list !\n"); |
| 251 | break; |
| 252 | } |
| 253 | if (strcmp(pname, "name") == 0) |
| 254 | has_name = 1; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 255 | pp = unflatten_dt_alloc(&mem, sizeof(struct property), |
| 256 | __alignof__(struct property)); |
| 257 | if (allnextpp) { |
David Gibson | 04b954a | 2010-02-01 21:34:15 -0700 | [diff] [blame] | 258 | /* We accept flattened tree phandles either in |
| 259 | * ePAPR-style "phandle" properties, or the |
| 260 | * legacy "linux,phandle" properties. If both |
| 261 | * appear and have different values, things |
| 262 | * will get weird. Don't do that. */ |
| 263 | if ((strcmp(pname, "phandle") == 0) || |
| 264 | (strcmp(pname, "linux,phandle") == 0)) { |
Grant Likely | 6016a36 | 2010-01-28 14:06:53 -0700 | [diff] [blame] | 265 | if (np->phandle == 0) |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 266 | np->phandle = be32_to_cpup(p); |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 267 | } |
David Gibson | 04b954a | 2010-02-01 21:34:15 -0700 | [diff] [blame] | 268 | /* And we process the "ibm,phandle" property |
| 269 | * used in pSeries dynamic device tree |
| 270 | * stuff */ |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 271 | if (strcmp(pname, "ibm,phandle") == 0) |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 272 | np->phandle = be32_to_cpup(p); |
| 273 | pp->name = (char *)pname; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 274 | pp->length = sz; |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 275 | pp->value = (__be32 *)p; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 276 | *prev_pp = pp; |
| 277 | prev_pp = &pp->next; |
| 278 | } |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 279 | } |
| 280 | /* with version 0x10 we may not have the name property, recreate |
| 281 | * it here from the unit name if absent |
| 282 | */ |
| 283 | if (!has_name) { |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 284 | const char *p1 = pathp, *ps = pathp, *pa = NULL; |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 285 | int sz; |
| 286 | |
| 287 | while (*p1) { |
| 288 | if ((*p1) == '@') |
| 289 | pa = p1; |
| 290 | if ((*p1) == '/') |
| 291 | ps = p1 + 1; |
| 292 | p1++; |
| 293 | } |
| 294 | if (pa < ps) |
| 295 | pa = p1; |
| 296 | sz = (pa - ps) + 1; |
| 297 | pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz, |
| 298 | __alignof__(struct property)); |
| 299 | if (allnextpp) { |
| 300 | pp->name = "name"; |
| 301 | pp->length = sz; |
| 302 | pp->value = pp + 1; |
| 303 | *prev_pp = pp; |
| 304 | prev_pp = &pp->next; |
| 305 | memcpy(pp->value, ps, sz - 1); |
| 306 | ((char *)pp->value)[sz - 1] = 0; |
| 307 | pr_debug("fixed up name for %s -> %s\n", pathp, |
| 308 | (char *)pp->value); |
| 309 | } |
| 310 | } |
| 311 | if (allnextpp) { |
| 312 | *prev_pp = NULL; |
| 313 | np->name = of_get_property(np, "name", NULL); |
| 314 | np->type = of_get_property(np, "device_type", NULL); |
| 315 | |
| 316 | if (!np->name) |
| 317 | np->name = "<NULL>"; |
| 318 | if (!np->type) |
| 319 | np->type = "<NULL>"; |
| 320 | } |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 321 | |
| 322 | old_depth = depth; |
| 323 | *poffset = fdt_next_node(blob, *poffset, &depth); |
| 324 | if (depth < 0) |
| 325 | depth = 0; |
| 326 | while (*poffset > 0 && depth > old_depth) |
| 327 | mem = unflatten_dt_node(blob, mem, poffset, np, allnextpp, |
| 328 | fpsize); |
| 329 | |
| 330 | if (*poffset < 0 && *poffset != -FDT_ERR_NOTFOUND) |
| 331 | pr_err("unflatten: error %d processing FDT\n", *poffset); |
| 332 | |
Grant Likely | bbd3393 | 2009-11-23 20:07:00 -0700 | [diff] [blame] | 333 | return mem; |
| 334 | } |
Grant Likely | 41f8800 | 2009-11-23 20:07:01 -0700 | [diff] [blame] | 335 | |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 336 | /** |
| 337 | * __unflatten_device_tree - create tree of device_nodes from flat blob |
| 338 | * |
| 339 | * unflattens a device-tree, creating the |
| 340 | * tree of struct device_node. It also fills the "name" and "type" |
| 341 | * pointers of the nodes so the normal device-tree walking functions |
| 342 | * can be used. |
| 343 | * @blob: The blob to expand |
| 344 | * @mynodes: The device_node tree created by the call |
| 345 | * @dt_alloc: An allocator that provides a virtual address to memory |
| 346 | * for the resulting tree |
| 347 | */ |
Rob Herring | c972de1 | 2014-04-01 22:48:01 -0500 | [diff] [blame] | 348 | static void __unflatten_device_tree(void *blob, |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 349 | struct device_node **mynodes, |
| 350 | void * (*dt_alloc)(u64 size, u64 align)) |
| 351 | { |
Grant Likely | 4485681 | 2013-08-29 13:30:35 +0100 | [diff] [blame] | 352 | unsigned long size; |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 353 | int start; |
| 354 | void *mem; |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 355 | struct device_node **allnextp = mynodes; |
| 356 | |
| 357 | pr_debug(" -> unflatten_device_tree()\n"); |
| 358 | |
| 359 | if (!blob) { |
| 360 | pr_debug("No device tree pointer\n"); |
| 361 | return; |
| 362 | } |
| 363 | |
| 364 | pr_debug("Unflattening device tree:\n"); |
Rob Herring | c972de1 | 2014-04-01 22:48:01 -0500 | [diff] [blame] | 365 | pr_debug("magic: %08x\n", fdt_magic(blob)); |
| 366 | pr_debug("size: %08x\n", fdt_totalsize(blob)); |
| 367 | pr_debug("version: %08x\n", fdt_version(blob)); |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 368 | |
Rob Herring | c972de1 | 2014-04-01 22:48:01 -0500 | [diff] [blame] | 369 | if (fdt_check_header(blob)) { |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 370 | pr_err("Invalid device tree blob header\n"); |
| 371 | return; |
| 372 | } |
| 373 | |
| 374 | /* First pass, scan for size */ |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 375 | start = 0; |
Thierry Reding | d2d3d7c | 2014-04-02 09:47:01 +0200 | [diff] [blame] | 376 | size = (unsigned long)unflatten_dt_node(blob, NULL, &start, NULL, NULL, 0); |
Grant Likely | 4485681 | 2013-08-29 13:30:35 +0100 | [diff] [blame] | 377 | size = ALIGN(size, 4); |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 378 | |
| 379 | pr_debug(" size is %lx, allocating...\n", size); |
| 380 | |
| 381 | /* Allocate memory for the expanded device tree */ |
Grant Likely | 4485681 | 2013-08-29 13:30:35 +0100 | [diff] [blame] | 382 | mem = dt_alloc(size + 4, __alignof__(struct device_node)); |
| 383 | memset(mem, 0, size); |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 384 | |
Grant Likely | 4485681 | 2013-08-29 13:30:35 +0100 | [diff] [blame] | 385 | *(__be32 *)(mem + size) = cpu_to_be32(0xdeadbeef); |
Wladislav Wiebe | 9e40127 | 2013-08-12 13:06:53 +0200 | [diff] [blame] | 386 | |
Grant Likely | 4485681 | 2013-08-29 13:30:35 +0100 | [diff] [blame] | 387 | pr_debug(" unflattening %p...\n", mem); |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 388 | |
| 389 | /* Second pass, do actual unflattening */ |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 390 | start = 0; |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 391 | unflatten_dt_node(blob, mem, &start, NULL, &allnextp, 0); |
Grant Likely | 4485681 | 2013-08-29 13:30:35 +0100 | [diff] [blame] | 392 | if (be32_to_cpup(mem + size) != 0xdeadbeef) |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 393 | pr_warning("End of tree marker overwritten: %08x\n", |
Grant Likely | 4485681 | 2013-08-29 13:30:35 +0100 | [diff] [blame] | 394 | be32_to_cpup(mem + size)); |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 395 | *allnextp = NULL; |
| 396 | |
| 397 | pr_debug(" <- unflatten_device_tree()\n"); |
| 398 | } |
| 399 | |
| 400 | static void *kernel_tree_alloc(u64 size, u64 align) |
| 401 | { |
| 402 | return kzalloc(size, GFP_KERNEL); |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * of_fdt_unflatten_tree - create tree of device_nodes from flat blob |
| 407 | * |
| 408 | * unflattens the device-tree passed by the firmware, creating the |
| 409 | * tree of struct device_node. It also fills the "name" and "type" |
| 410 | * pointers of the nodes so the normal device-tree walking functions |
| 411 | * can be used. |
| 412 | */ |
| 413 | void of_fdt_unflatten_tree(unsigned long *blob, |
| 414 | struct device_node **mynodes) |
| 415 | { |
Rob Herring | c972de1 | 2014-04-01 22:48:01 -0500 | [diff] [blame] | 416 | __unflatten_device_tree(blob, mynodes, &kernel_tree_alloc); |
Stephen Neuendorffer | fe14042 | 2010-11-18 15:55:02 -0800 | [diff] [blame] | 417 | } |
| 418 | EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree); |
| 419 | |
Stephen Neuendorffer | 57d00ec | 2010-11-18 15:55:01 -0800 | [diff] [blame] | 420 | /* Everything below here references initial_boot_params directly. */ |
| 421 | int __initdata dt_root_addr_cells; |
| 422 | int __initdata dt_root_size_cells; |
| 423 | |
Rob Herring | 1daa0c4 | 2014-03-31 15:25:04 -0500 | [diff] [blame] | 424 | void *initial_boot_params; |
Stephen Neuendorffer | 57d00ec | 2010-11-18 15:55:01 -0800 | [diff] [blame] | 425 | |
| 426 | #ifdef CONFIG_OF_EARLY_FLATTREE |
| 427 | |
| 428 | /** |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 429 | * res_mem_reserve_reg() - reserve all memory described in 'reg' property |
| 430 | */ |
| 431 | static int __init __reserved_mem_reserve_reg(unsigned long node, |
| 432 | const char *uname) |
| 433 | { |
| 434 | int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); |
| 435 | phys_addr_t base, size; |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 436 | int len; |
| 437 | const __be32 *prop; |
Marek Szyprowski | 3f0c820 | 2014-02-28 14:42:48 +0100 | [diff] [blame] | 438 | int nomap, first = 1; |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 439 | |
| 440 | prop = of_get_flat_dt_prop(node, "reg", &len); |
| 441 | if (!prop) |
| 442 | return -ENOENT; |
| 443 | |
| 444 | if (len && len % t_len != 0) { |
| 445 | pr_err("Reserved memory: invalid reg property in '%s', skipping node.\n", |
| 446 | uname); |
| 447 | return -EINVAL; |
| 448 | } |
| 449 | |
| 450 | nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL; |
| 451 | |
| 452 | while (len >= t_len) { |
| 453 | base = dt_mem_next_cell(dt_root_addr_cells, &prop); |
| 454 | size = dt_mem_next_cell(dt_root_size_cells, &prop); |
| 455 | |
Al Cooper | b5f2a8c | 2014-08-06 16:30:04 -0400 | [diff] [blame] | 456 | if (size && |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 457 | early_init_dt_reserve_memory_arch(base, size, nomap) == 0) |
| 458 | pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %ld MiB\n", |
| 459 | uname, &base, (unsigned long)size / SZ_1M); |
| 460 | else |
| 461 | pr_info("Reserved memory: failed to reserve memory for node '%s': base %pa, size %ld MiB\n", |
| 462 | uname, &base, (unsigned long)size / SZ_1M); |
| 463 | |
| 464 | len -= t_len; |
Marek Szyprowski | 3f0c820 | 2014-02-28 14:42:48 +0100 | [diff] [blame] | 465 | if (first) { |
| 466 | fdt_reserved_mem_save_node(node, uname, base, size); |
| 467 | first = 0; |
| 468 | } |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 469 | } |
| 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * __reserved_mem_check_root() - check if #size-cells, #address-cells provided |
| 475 | * in /reserved-memory matches the values supported by the current implementation, |
| 476 | * also check if ranges property has been provided |
| 477 | */ |
Xiubo Li | 5b62411 | 2014-04-08 13:48:07 +0800 | [diff] [blame] | 478 | static int __init __reserved_mem_check_root(unsigned long node) |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 479 | { |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 480 | const __be32 *prop; |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 481 | |
| 482 | prop = of_get_flat_dt_prop(node, "#size-cells", NULL); |
| 483 | if (!prop || be32_to_cpup(prop) != dt_root_size_cells) |
| 484 | return -EINVAL; |
| 485 | |
| 486 | prop = of_get_flat_dt_prop(node, "#address-cells", NULL); |
| 487 | if (!prop || be32_to_cpup(prop) != dt_root_addr_cells) |
| 488 | return -EINVAL; |
| 489 | |
| 490 | prop = of_get_flat_dt_prop(node, "ranges", NULL); |
| 491 | if (!prop) |
| 492 | return -EINVAL; |
| 493 | return 0; |
| 494 | } |
| 495 | |
| 496 | /** |
| 497 | * fdt_scan_reserved_mem() - scan a single FDT node for reserved memory |
| 498 | */ |
| 499 | static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname, |
| 500 | int depth, void *data) |
| 501 | { |
| 502 | static int found; |
| 503 | const char *status; |
Marek Szyprowski | 3f0c820 | 2014-02-28 14:42:48 +0100 | [diff] [blame] | 504 | int err; |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 505 | |
| 506 | if (!found && depth == 1 && strcmp(uname, "reserved-memory") == 0) { |
| 507 | if (__reserved_mem_check_root(node) != 0) { |
| 508 | pr_err("Reserved memory: unsupported node format, ignoring\n"); |
| 509 | /* break scan */ |
| 510 | return 1; |
| 511 | } |
| 512 | found = 1; |
| 513 | /* scan next node */ |
| 514 | return 0; |
| 515 | } else if (!found) { |
| 516 | /* scan next node */ |
| 517 | return 0; |
| 518 | } else if (found && depth < 2) { |
| 519 | /* scanning of /reserved-memory has been finished */ |
| 520 | return 1; |
| 521 | } |
| 522 | |
| 523 | status = of_get_flat_dt_prop(node, "status", NULL); |
| 524 | if (status && strcmp(status, "okay") != 0 && strcmp(status, "ok") != 0) |
| 525 | return 0; |
| 526 | |
Marek Szyprowski | 3f0c820 | 2014-02-28 14:42:48 +0100 | [diff] [blame] | 527 | err = __reserved_mem_reserve_reg(node, uname); |
| 528 | if (err == -ENOENT && of_get_flat_dt_prop(node, "size", NULL)) |
| 529 | fdt_reserved_mem_save_node(node, uname, 0, 0); |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 530 | |
| 531 | /* scan next node */ |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | /** |
| 536 | * early_init_fdt_scan_reserved_mem() - create reserved memory regions |
| 537 | * |
| 538 | * This function grabs memory from early allocator for device exclusive use |
| 539 | * defined in device tree structures. It should be called by arch specific code |
| 540 | * once the early allocator (i.e. memblock) has been fully activated. |
| 541 | */ |
| 542 | void __init early_init_fdt_scan_reserved_mem(void) |
| 543 | { |
Rob Herring | d1552ce | 2014-04-01 22:46:48 -0500 | [diff] [blame] | 544 | int n; |
| 545 | u64 base, size; |
| 546 | |
Josh Cartwright | 2040b52 | 2014-03-13 16:36:36 -0500 | [diff] [blame] | 547 | if (!initial_boot_params) |
| 548 | return; |
| 549 | |
Rob Herring | d1552ce | 2014-04-01 22:46:48 -0500 | [diff] [blame] | 550 | /* Reserve the dtb region */ |
| 551 | early_init_dt_reserve_memory_arch(__pa(initial_boot_params), |
| 552 | fdt_totalsize(initial_boot_params), |
| 553 | 0); |
| 554 | |
| 555 | /* Process header /memreserve/ fields */ |
| 556 | for (n = 0; ; n++) { |
| 557 | fdt_get_mem_rsv(initial_boot_params, n, &base, &size); |
| 558 | if (!size) |
| 559 | break; |
| 560 | early_init_dt_reserve_memory_arch(base, size, 0); |
| 561 | } |
| 562 | |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 563 | of_scan_flat_dt(__fdt_scan_reserved_mem, NULL); |
Marek Szyprowski | 3f0c820 | 2014-02-28 14:42:48 +0100 | [diff] [blame] | 564 | fdt_init_reserved_mem(); |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | /** |
Stephen Neuendorffer | 57d00ec | 2010-11-18 15:55:01 -0800 | [diff] [blame] | 568 | * of_scan_flat_dt - scan flattened tree blob and call callback on each. |
| 569 | * @it: callback function |
| 570 | * @data: context data pointer |
| 571 | * |
| 572 | * This function is used to scan the flattened device-tree, it is |
| 573 | * used to extract the memory information at boot before we can |
| 574 | * unflatten the tree |
| 575 | */ |
| 576 | int __init of_scan_flat_dt(int (*it)(unsigned long node, |
| 577 | const char *uname, int depth, |
| 578 | void *data), |
| 579 | void *data) |
| 580 | { |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 581 | const void *blob = initial_boot_params; |
| 582 | const char *pathp; |
| 583 | int offset, rc = 0, depth = -1; |
Stephen Neuendorffer | 57d00ec | 2010-11-18 15:55:01 -0800 | [diff] [blame] | 584 | |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 585 | for (offset = fdt_next_node(blob, -1, &depth); |
| 586 | offset >= 0 && depth >= 0 && !rc; |
| 587 | offset = fdt_next_node(blob, offset, &depth)) { |
Stephen Neuendorffer | 57d00ec | 2010-11-18 15:55:01 -0800 | [diff] [blame] | 588 | |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 589 | pathp = fdt_get_name(blob, offset, NULL); |
Andy Shevchenko | 375da3a | 2012-12-17 16:01:28 -0800 | [diff] [blame] | 590 | if (*pathp == '/') |
| 591 | pathp = kbasename(pathp); |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 592 | rc = it(offset, pathp, depth, data); |
| 593 | } |
Stephen Neuendorffer | 57d00ec | 2010-11-18 15:55:01 -0800 | [diff] [blame] | 594 | return rc; |
| 595 | } |
| 596 | |
| 597 | /** |
| 598 | * of_get_flat_dt_root - find the root node in the flat blob |
| 599 | */ |
| 600 | unsigned long __init of_get_flat_dt_root(void) |
| 601 | { |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 602 | return 0; |
Stephen Neuendorffer | 57d00ec | 2010-11-18 15:55:01 -0800 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | /** |
Rob Herring | c0556d3 | 2014-04-22 12:55:10 -0500 | [diff] [blame] | 606 | * of_get_flat_dt_size - Return the total size of the FDT |
| 607 | */ |
| 608 | int __init of_get_flat_dt_size(void) |
| 609 | { |
| 610 | return fdt_totalsize(initial_boot_params); |
| 611 | } |
| 612 | |
| 613 | /** |
Stephen Neuendorffer | 57d00ec | 2010-11-18 15:55:01 -0800 | [diff] [blame] | 614 | * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr |
| 615 | * |
| 616 | * This function can be used within scan_flattened_dt callback to get |
| 617 | * access to properties |
| 618 | */ |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 619 | const void *__init of_get_flat_dt_prop(unsigned long node, const char *name, |
| 620 | int *size) |
Stephen Neuendorffer | 57d00ec | 2010-11-18 15:55:01 -0800 | [diff] [blame] | 621 | { |
Rob Herring | e6a6928 | 2014-04-02 15:10:14 -0500 | [diff] [blame] | 622 | return fdt_getprop(initial_boot_params, node, name, size); |
Stephen Neuendorffer | 57d00ec | 2010-11-18 15:55:01 -0800 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | /** |
| 626 | * of_flat_dt_is_compatible - Return true if given node has compat in compatible list |
| 627 | * @node: node to test |
| 628 | * @compat: compatible string to compare with compatible list. |
| 629 | */ |
| 630 | int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) |
| 631 | { |
| 632 | return of_fdt_is_compatible(initial_boot_params, node, compat); |
| 633 | } |
| 634 | |
Grant Likely | a4f740c | 2010-10-30 11:49:09 -0400 | [diff] [blame] | 635 | /** |
| 636 | * of_flat_dt_match - Return true if node matches a list of compatible values |
| 637 | */ |
Uwe Kleine-König | 7b482c8 | 2011-12-20 22:56:45 +0100 | [diff] [blame] | 638 | int __init of_flat_dt_match(unsigned long node, const char *const *compat) |
Grant Likely | a4f740c | 2010-10-30 11:49:09 -0400 | [diff] [blame] | 639 | { |
| 640 | return of_fdt_match(initial_boot_params, node, compat); |
| 641 | } |
| 642 | |
Marek Szyprowski | 57d74bc | 2013-08-26 14:41:56 +0200 | [diff] [blame] | 643 | struct fdt_scan_status { |
| 644 | const char *name; |
| 645 | int namelen; |
| 646 | int depth; |
| 647 | int found; |
| 648 | int (*iterator)(unsigned long node, const char *uname, int depth, void *data); |
| 649 | void *data; |
| 650 | }; |
| 651 | |
Rob Herring | 6a903a2 | 2013-08-27 21:41:56 -0500 | [diff] [blame] | 652 | const char * __init of_flat_dt_get_machine_name(void) |
| 653 | { |
| 654 | const char *name; |
| 655 | unsigned long dt_root = of_get_flat_dt_root(); |
| 656 | |
| 657 | name = of_get_flat_dt_prop(dt_root, "model", NULL); |
| 658 | if (!name) |
| 659 | name = of_get_flat_dt_prop(dt_root, "compatible", NULL); |
| 660 | return name; |
| 661 | } |
| 662 | |
| 663 | /** |
| 664 | * of_flat_dt_match_machine - Iterate match tables to find matching machine. |
| 665 | * |
| 666 | * @default_match: A machine specific ptr to return in case of no match. |
| 667 | * @get_next_compat: callback function to return next compatible match table. |
| 668 | * |
| 669 | * Iterate through machine match tables to find the best match for the machine |
| 670 | * compatible string in the FDT. |
| 671 | */ |
| 672 | const void * __init of_flat_dt_match_machine(const void *default_match, |
| 673 | const void * (*get_next_compat)(const char * const**)) |
| 674 | { |
| 675 | const void *data = NULL; |
| 676 | const void *best_data = default_match; |
| 677 | const char *const *compat; |
| 678 | unsigned long dt_root; |
| 679 | unsigned int best_score = ~1, score = 0; |
| 680 | |
| 681 | dt_root = of_get_flat_dt_root(); |
| 682 | while ((data = get_next_compat(&compat))) { |
| 683 | score = of_flat_dt_match(dt_root, compat); |
| 684 | if (score > 0 && score < best_score) { |
| 685 | best_data = data; |
| 686 | best_score = score; |
| 687 | } |
| 688 | } |
| 689 | if (!best_data) { |
| 690 | const char *prop; |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 691 | int size; |
Rob Herring | 6a903a2 | 2013-08-27 21:41:56 -0500 | [diff] [blame] | 692 | |
| 693 | pr_err("\n unrecognized device tree list:\n[ "); |
| 694 | |
| 695 | prop = of_get_flat_dt_prop(dt_root, "compatible", &size); |
| 696 | if (prop) { |
| 697 | while (size > 0) { |
| 698 | printk("'%s' ", prop); |
| 699 | size -= strlen(prop) + 1; |
| 700 | prop += strlen(prop) + 1; |
| 701 | } |
| 702 | } |
| 703 | printk("]\n\n"); |
| 704 | return NULL; |
| 705 | } |
| 706 | |
| 707 | pr_info("Machine model: %s\n", of_flat_dt_get_machine_name()); |
| 708 | |
| 709 | return best_data; |
| 710 | } |
| 711 | |
Grant Likely | f7b3a83 | 2009-11-24 03:26:58 -0700 | [diff] [blame] | 712 | #ifdef CONFIG_BLK_DEV_INITRD |
| 713 | /** |
| 714 | * early_init_dt_check_for_initrd - Decode initrd location from flat tree |
| 715 | * @node: reference to node containing initrd location ('chosen') |
| 716 | */ |
Rob Herring | 29eb45a | 2013-08-30 17:06:53 -0500 | [diff] [blame] | 717 | static void __init early_init_dt_check_for_initrd(unsigned long node) |
Grant Likely | f7b3a83 | 2009-11-24 03:26:58 -0700 | [diff] [blame] | 718 | { |
Santosh Shilimkar | 374d5c9 | 2013-07-01 14:20:35 -0400 | [diff] [blame] | 719 | u64 start, end; |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 720 | int len; |
| 721 | const __be32 *prop; |
Grant Likely | f7b3a83 | 2009-11-24 03:26:58 -0700 | [diff] [blame] | 722 | |
| 723 | pr_debug("Looking for initrd properties... "); |
| 724 | |
| 725 | prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len); |
Jeremy Kerr | 1406bc2 | 2010-01-30 01:31:21 -0700 | [diff] [blame] | 726 | if (!prop) |
| 727 | return; |
Santosh Shilimkar | 374d5c9 | 2013-07-01 14:20:35 -0400 | [diff] [blame] | 728 | start = of_read_number(prop, len/4); |
Grant Likely | f7b3a83 | 2009-11-24 03:26:58 -0700 | [diff] [blame] | 729 | |
Jeremy Kerr | 1406bc2 | 2010-01-30 01:31:21 -0700 | [diff] [blame] | 730 | prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len); |
| 731 | if (!prop) |
| 732 | return; |
Santosh Shilimkar | 374d5c9 | 2013-07-01 14:20:35 -0400 | [diff] [blame] | 733 | end = of_read_number(prop, len/4); |
Grant Likely | f7b3a83 | 2009-11-24 03:26:58 -0700 | [diff] [blame] | 734 | |
Rob Herring | 29eb45a | 2013-08-30 17:06:53 -0500 | [diff] [blame] | 735 | initrd_start = (unsigned long)__va(start); |
| 736 | initrd_end = (unsigned long)__va(end); |
| 737 | initrd_below_start_ok = 1; |
| 738 | |
Santosh Shilimkar | 374d5c9 | 2013-07-01 14:20:35 -0400 | [diff] [blame] | 739 | pr_debug("initrd_start=0x%llx initrd_end=0x%llx\n", |
| 740 | (unsigned long long)start, (unsigned long long)end); |
Grant Likely | f7b3a83 | 2009-11-24 03:26:58 -0700 | [diff] [blame] | 741 | } |
| 742 | #else |
Rob Herring | 29eb45a | 2013-08-30 17:06:53 -0500 | [diff] [blame] | 743 | static inline void early_init_dt_check_for_initrd(unsigned long node) |
Grant Likely | f7b3a83 | 2009-11-24 03:26:58 -0700 | [diff] [blame] | 744 | { |
| 745 | } |
| 746 | #endif /* CONFIG_BLK_DEV_INITRD */ |
| 747 | |
Rob Herring | fb11ffe | 2014-03-27 08:07:01 -0500 | [diff] [blame] | 748 | #ifdef CONFIG_SERIAL_EARLYCON |
| 749 | extern struct of_device_id __earlycon_of_table[]; |
| 750 | |
| 751 | int __init early_init_dt_scan_chosen_serial(void) |
| 752 | { |
| 753 | int offset; |
| 754 | const char *p; |
| 755 | int l; |
| 756 | const struct of_device_id *match = __earlycon_of_table; |
| 757 | const void *fdt = initial_boot_params; |
| 758 | |
| 759 | offset = fdt_path_offset(fdt, "/chosen"); |
| 760 | if (offset < 0) |
| 761 | offset = fdt_path_offset(fdt, "/chosen@0"); |
| 762 | if (offset < 0) |
| 763 | return -ENOENT; |
| 764 | |
| 765 | p = fdt_getprop(fdt, offset, "stdout-path", &l); |
| 766 | if (!p) |
| 767 | p = fdt_getprop(fdt, offset, "linux,stdout-path", &l); |
| 768 | if (!p || !l) |
| 769 | return -ENOENT; |
| 770 | |
| 771 | /* Get the node specified by stdout-path */ |
| 772 | offset = fdt_path_offset(fdt, p); |
| 773 | if (offset < 0) |
| 774 | return -ENODEV; |
| 775 | |
| 776 | while (match->compatible) { |
| 777 | unsigned long addr; |
| 778 | if (fdt_node_check_compatible(fdt, offset, match->compatible)) { |
| 779 | match++; |
| 780 | continue; |
| 781 | } |
| 782 | |
| 783 | addr = fdt_translate_address(fdt, offset); |
| 784 | if (!addr) |
| 785 | return -ENXIO; |
| 786 | |
| 787 | of_setup_earlycon(addr, match->data); |
| 788 | return 0; |
| 789 | } |
| 790 | return -ENODEV; |
| 791 | } |
| 792 | |
| 793 | static int __init setup_of_earlycon(char *buf) |
| 794 | { |
| 795 | if (buf) |
| 796 | return 0; |
| 797 | |
| 798 | return early_init_dt_scan_chosen_serial(); |
| 799 | } |
| 800 | early_param("earlycon", setup_of_earlycon); |
| 801 | #endif |
| 802 | |
Grant Likely | 41f8800 | 2009-11-23 20:07:01 -0700 | [diff] [blame] | 803 | /** |
Grant Likely | f00abd9 | 2009-11-24 03:27:10 -0700 | [diff] [blame] | 804 | * early_init_dt_scan_root - fetch the top level address and size cells |
| 805 | */ |
| 806 | int __init early_init_dt_scan_root(unsigned long node, const char *uname, |
| 807 | int depth, void *data) |
| 808 | { |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 809 | const __be32 *prop; |
Grant Likely | f00abd9 | 2009-11-24 03:27:10 -0700 | [diff] [blame] | 810 | |
| 811 | if (depth != 0) |
| 812 | return 0; |
| 813 | |
Jeremy Kerr | 3371488 | 2010-01-30 01:45:26 -0700 | [diff] [blame] | 814 | dt_root_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; |
| 815 | dt_root_addr_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; |
| 816 | |
Grant Likely | f00abd9 | 2009-11-24 03:27:10 -0700 | [diff] [blame] | 817 | prop = of_get_flat_dt_prop(node, "#size-cells", NULL); |
Jeremy Kerr | 3371488 | 2010-01-30 01:45:26 -0700 | [diff] [blame] | 818 | if (prop) |
| 819 | dt_root_size_cells = be32_to_cpup(prop); |
Grant Likely | f00abd9 | 2009-11-24 03:27:10 -0700 | [diff] [blame] | 820 | pr_debug("dt_root_size_cells = %x\n", dt_root_size_cells); |
| 821 | |
| 822 | prop = of_get_flat_dt_prop(node, "#address-cells", NULL); |
Jeremy Kerr | 3371488 | 2010-01-30 01:45:26 -0700 | [diff] [blame] | 823 | if (prop) |
| 824 | dt_root_addr_cells = be32_to_cpup(prop); |
Grant Likely | f00abd9 | 2009-11-24 03:27:10 -0700 | [diff] [blame] | 825 | pr_debug("dt_root_addr_cells = %x\n", dt_root_addr_cells); |
| 826 | |
| 827 | /* break now */ |
| 828 | return 1; |
| 829 | } |
| 830 | |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 831 | u64 __init dt_mem_next_cell(int s, const __be32 **cellp) |
Grant Likely | 83f7a06 | 2009-11-24 03:37:56 -0700 | [diff] [blame] | 832 | { |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 833 | const __be32 *p = *cellp; |
Grant Likely | 83f7a06 | 2009-11-24 03:37:56 -0700 | [diff] [blame] | 834 | |
| 835 | *cellp = p + s; |
| 836 | return of_read_number(p, s); |
| 837 | } |
| 838 | |
Grant Likely | 51975db | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 839 | /** |
| 840 | * early_init_dt_scan_memory - Look for an parse memory nodes |
| 841 | */ |
| 842 | int __init early_init_dt_scan_memory(unsigned long node, const char *uname, |
| 843 | int depth, void *data) |
| 844 | { |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 845 | const char *type = of_get_flat_dt_prop(node, "device_type", NULL); |
| 846 | const __be32 *reg, *endp; |
| 847 | int l; |
Grant Likely | 51975db | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 848 | |
| 849 | /* We are scanning "memory" nodes only */ |
| 850 | if (type == NULL) { |
| 851 | /* |
| 852 | * The longtrail doesn't have a device_type on the |
| 853 | * /memory node, so look for the node called /memory@0. |
| 854 | */ |
Leif Lindholm | b44aa25 | 2014-04-17 18:42:01 +0100 | [diff] [blame] | 855 | if (!IS_ENABLED(CONFIG_PPC32) || depth != 1 || strcmp(uname, "memory@0") != 0) |
Grant Likely | 51975db | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 856 | return 0; |
| 857 | } else if (strcmp(type, "memory") != 0) |
| 858 | return 0; |
| 859 | |
| 860 | reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); |
| 861 | if (reg == NULL) |
| 862 | reg = of_get_flat_dt_prop(node, "reg", &l); |
| 863 | if (reg == NULL) |
| 864 | return 0; |
| 865 | |
| 866 | endp = reg + (l / sizeof(__be32)); |
| 867 | |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 868 | pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n", |
Grant Likely | 51975db | 2010-02-01 21:34:14 -0700 | [diff] [blame] | 869 | uname, l, reg[0], reg[1], reg[2], reg[3]); |
| 870 | |
| 871 | while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { |
| 872 | u64 base, size; |
| 873 | |
| 874 | base = dt_mem_next_cell(dt_root_addr_cells, ®); |
| 875 | size = dt_mem_next_cell(dt_root_size_cells, ®); |
| 876 | |
| 877 | if (size == 0) |
| 878 | continue; |
| 879 | pr_debug(" - %llx , %llx\n", (unsigned long long)base, |
| 880 | (unsigned long long)size); |
| 881 | |
| 882 | early_init_dt_add_memory_arch(base, size); |
| 883 | } |
| 884 | |
| 885 | return 0; |
| 886 | } |
| 887 | |
Grant Likely | 86e0322 | 2009-12-10 23:42:21 -0700 | [diff] [blame] | 888 | int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, |
| 889 | int depth, void *data) |
| 890 | { |
Rob Herring | 9d0c4df | 2014-04-01 23:49:03 -0500 | [diff] [blame] | 891 | int l; |
| 892 | const char *p; |
Grant Likely | 86e0322 | 2009-12-10 23:42:21 -0700 | [diff] [blame] | 893 | |
| 894 | pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); |
| 895 | |
Grant Likely | 85f60ae | 2011-04-29 00:18:16 -0600 | [diff] [blame] | 896 | if (depth != 1 || !data || |
Grant Likely | 86e0322 | 2009-12-10 23:42:21 -0700 | [diff] [blame] | 897 | (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) |
| 898 | return 0; |
| 899 | |
| 900 | early_init_dt_check_for_initrd(node); |
| 901 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 902 | /* Retrieve command line */ |
Grant Likely | 86e0322 | 2009-12-10 23:42:21 -0700 | [diff] [blame] | 903 | p = of_get_flat_dt_prop(node, "bootargs", &l); |
| 904 | if (p != NULL && l > 0) |
Grant Likely | 85f60ae | 2011-04-29 00:18:16 -0600 | [diff] [blame] | 905 | strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE)); |
Grant Likely | 86e0322 | 2009-12-10 23:42:21 -0700 | [diff] [blame] | 906 | |
Benjamin Herrenschmidt | 78b782c | 2011-09-19 18:50:15 +0000 | [diff] [blame] | 907 | /* |
| 908 | * CONFIG_CMDLINE is meant to be a default in case nothing else |
| 909 | * managed to set the command line, unless CONFIG_CMDLINE_FORCE |
| 910 | * is set in which case we override whatever was found earlier. |
| 911 | */ |
Grant Likely | 86e0322 | 2009-12-10 23:42:21 -0700 | [diff] [blame] | 912 | #ifdef CONFIG_CMDLINE |
| 913 | #ifndef CONFIG_CMDLINE_FORCE |
Benjamin Herrenschmidt | 78b782c | 2011-09-19 18:50:15 +0000 | [diff] [blame] | 914 | if (!((char *)data)[0]) |
Grant Likely | 86e0322 | 2009-12-10 23:42:21 -0700 | [diff] [blame] | 915 | #endif |
Grant Likely | 85f60ae | 2011-04-29 00:18:16 -0600 | [diff] [blame] | 916 | strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE); |
Grant Likely | 86e0322 | 2009-12-10 23:42:21 -0700 | [diff] [blame] | 917 | #endif /* CONFIG_CMDLINE */ |
| 918 | |
Grant Likely | 85f60ae | 2011-04-29 00:18:16 -0600 | [diff] [blame] | 919 | pr_debug("Command line is: %s\n", (char*)data); |
Grant Likely | 86e0322 | 2009-12-10 23:42:21 -0700 | [diff] [blame] | 920 | |
| 921 | /* break now */ |
| 922 | return 1; |
| 923 | } |
| 924 | |
Grant Likely | a1727da | 2013-08-28 21:18:32 +0100 | [diff] [blame] | 925 | #ifdef CONFIG_HAVE_MEMBLOCK |
Laura Abbott | 3069f0c | 2014-07-07 17:45:43 -0700 | [diff] [blame] | 926 | #define MAX_PHYS_ADDR ((phys_addr_t)~0) |
| 927 | |
Rob Herring | 068f631 | 2013-09-24 22:20:01 -0500 | [diff] [blame] | 928 | void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) |
| 929 | { |
| 930 | const u64 phys_offset = __pa(PAGE_OFFSET); |
| 931 | base &= PAGE_MASK; |
| 932 | size &= PAGE_MASK; |
Laura Abbott | a67a6ed | 2014-06-19 20:13:38 -0700 | [diff] [blame] | 933 | |
Laura Abbott | 3069f0c | 2014-07-07 17:45:43 -0700 | [diff] [blame] | 934 | if (base > MAX_PHYS_ADDR) { |
| 935 | pr_warning("Ignoring memory block 0x%llx - 0x%llx\n", |
| 936 | base, base + size); |
| 937 | return; |
| 938 | } |
Laura Abbott | a67a6ed | 2014-06-19 20:13:38 -0700 | [diff] [blame] | 939 | |
Laura Abbott | 3069f0c | 2014-07-07 17:45:43 -0700 | [diff] [blame] | 940 | if (base + size > MAX_PHYS_ADDR) { |
| 941 | pr_warning("Ignoring memory range 0x%lx - 0x%llx\n", |
| 942 | ULONG_MAX, base + size); |
| 943 | size = MAX_PHYS_ADDR - base; |
Laura Abbott | a67a6ed | 2014-06-19 20:13:38 -0700 | [diff] [blame] | 944 | } |
| 945 | |
Rob Herring | 068f631 | 2013-09-24 22:20:01 -0500 | [diff] [blame] | 946 | if (base + size < phys_offset) { |
| 947 | pr_warning("Ignoring memory block 0x%llx - 0x%llx\n", |
| 948 | base, base + size); |
| 949 | return; |
| 950 | } |
| 951 | if (base < phys_offset) { |
| 952 | pr_warning("Ignoring memory range 0x%llx - 0x%llx\n", |
| 953 | base, phys_offset); |
| 954 | size -= phys_offset - base; |
| 955 | base = phys_offset; |
| 956 | } |
| 957 | memblock_add(base, size); |
| 958 | } |
| 959 | |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 960 | int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, |
| 961 | phys_addr_t size, bool nomap) |
| 962 | { |
| 963 | if (memblock_is_region_reserved(base, size)) |
| 964 | return -EBUSY; |
| 965 | if (nomap) |
| 966 | return memblock_remove(base, size); |
| 967 | return memblock_reserve(base, size); |
| 968 | } |
| 969 | |
Grant Likely | a1727da | 2013-08-28 21:18:32 +0100 | [diff] [blame] | 970 | /* |
| 971 | * called from unflatten_device_tree() to bootstrap devicetree itself |
| 972 | * Architectures can override this definition if memblock isn't used |
| 973 | */ |
| 974 | void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) |
| 975 | { |
| 976 | return __va(memblock_alloc(size, align)); |
| 977 | } |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 978 | #else |
| 979 | int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, |
| 980 | phys_addr_t size, bool nomap) |
| 981 | { |
Rob Herring | 1d1a661 | 2014-04-22 12:50:24 -0500 | [diff] [blame] | 982 | pr_err("Reserved memory not supported, ignoring range 0x%pa - 0x%pa%s\n", |
| 983 | &base, &size, nomap ? " (nomap)" : ""); |
Marek Szyprowski | e8d9d1f | 2014-02-28 14:42:47 +0100 | [diff] [blame] | 984 | return -ENOSYS; |
| 985 | } |
Grant Likely | a1727da | 2013-08-28 21:18:32 +0100 | [diff] [blame] | 986 | #endif |
| 987 | |
Laura Abbott | 4972a74 | 2014-07-15 10:03:34 -0700 | [diff] [blame] | 988 | bool __init early_init_dt_verify(void *params) |
Rob Herring | 0288ffcb | 2013-08-26 09:47:40 -0500 | [diff] [blame] | 989 | { |
| 990 | if (!params) |
| 991 | return false; |
| 992 | |
| 993 | /* Setup flat device-tree pointer */ |
| 994 | initial_boot_params = params; |
| 995 | |
| 996 | /* check device tree validity */ |
Rob Herring | c972de1 | 2014-04-01 22:48:01 -0500 | [diff] [blame] | 997 | if (fdt_check_header(params)) { |
Rob Herring | 0288ffcb | 2013-08-26 09:47:40 -0500 | [diff] [blame] | 998 | initial_boot_params = NULL; |
| 999 | return false; |
| 1000 | } |
| 1001 | |
Laura Abbott | 4972a74 | 2014-07-15 10:03:34 -0700 | [diff] [blame] | 1002 | return true; |
| 1003 | } |
| 1004 | |
| 1005 | |
| 1006 | void __init early_init_dt_scan_nodes(void) |
| 1007 | { |
Rob Herring | 0288ffcb | 2013-08-26 09:47:40 -0500 | [diff] [blame] | 1008 | /* Retrieve various information from the /chosen node */ |
| 1009 | of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); |
| 1010 | |
| 1011 | /* Initialize {size,address}-cells info */ |
| 1012 | of_scan_flat_dt(early_init_dt_scan_root, NULL); |
| 1013 | |
| 1014 | /* Setup memory, calling early_init_dt_add_memory_arch */ |
| 1015 | of_scan_flat_dt(early_init_dt_scan_memory, NULL); |
Laura Abbott | 4972a74 | 2014-07-15 10:03:34 -0700 | [diff] [blame] | 1016 | } |
Rob Herring | 0288ffcb | 2013-08-26 09:47:40 -0500 | [diff] [blame] | 1017 | |
Laura Abbott | 4972a74 | 2014-07-15 10:03:34 -0700 | [diff] [blame] | 1018 | bool __init early_init_dt_scan(void *params) |
| 1019 | { |
| 1020 | bool status; |
| 1021 | |
| 1022 | status = early_init_dt_verify(params); |
| 1023 | if (!status) |
| 1024 | return false; |
| 1025 | |
| 1026 | early_init_dt_scan_nodes(); |
Rob Herring | 0288ffcb | 2013-08-26 09:47:40 -0500 | [diff] [blame] | 1027 | return true; |
| 1028 | } |
| 1029 | |
Grant Likely | f00abd9 | 2009-11-24 03:27:10 -0700 | [diff] [blame] | 1030 | /** |
Grant Likely | 41f8800 | 2009-11-23 20:07:01 -0700 | [diff] [blame] | 1031 | * unflatten_device_tree - create tree of device_nodes from flat blob |
| 1032 | * |
| 1033 | * unflattens the device-tree passed by the firmware, creating the |
| 1034 | * tree of struct device_node. It also fills the "name" and "type" |
| 1035 | * pointers of the nodes so the normal device-tree walking functions |
| 1036 | * can be used. |
| 1037 | */ |
| 1038 | void __init unflatten_device_tree(void) |
| 1039 | { |
Randy Dunlap | 465aac6 | 2012-11-30 10:01:51 +0000 | [diff] [blame] | 1040 | __unflatten_device_tree(initial_boot_params, &of_allnodes, |
Grant Likely | 672c544 | 2011-01-13 15:36:09 -0700 | [diff] [blame] | 1041 | early_init_dt_alloc_memory_arch); |
Grant Likely | 41f8800 | 2009-11-23 20:07:01 -0700 | [diff] [blame] | 1042 | |
Robert P. J. Day | 4c7d636 | 2013-05-30 05:38:08 -0400 | [diff] [blame] | 1043 | /* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */ |
Shawn Guo | 611cad7 | 2011-08-15 15:28:14 +0800 | [diff] [blame] | 1044 | of_alias_scan(early_init_dt_alloc_memory_arch); |
Grant Likely | 41f8800 | 2009-11-23 20:07:01 -0700 | [diff] [blame] | 1045 | } |
Stephen Neuendorffer | e6ce132 | 2010-11-18 15:54:56 -0800 | [diff] [blame] | 1046 | |
Rob Herring | a8bf752 | 2013-08-26 11:22:45 -0500 | [diff] [blame] | 1047 | /** |
| 1048 | * unflatten_and_copy_device_tree - copy and create tree of device_nodes from flat blob |
| 1049 | * |
| 1050 | * Copies and unflattens the device-tree passed by the firmware, creating the |
| 1051 | * tree of struct device_node. It also fills the "name" and "type" |
| 1052 | * pointers of the nodes so the normal device-tree walking functions |
| 1053 | * can be used. This should only be used when the FDT memory has not been |
| 1054 | * reserved such is the case when the FDT is built-in to the kernel init |
| 1055 | * section. If the FDT memory is reserved already then unflatten_device_tree |
| 1056 | * should be used instead. |
| 1057 | */ |
| 1058 | void __init unflatten_and_copy_device_tree(void) |
| 1059 | { |
James Hogan | 6f041e9 | 2013-11-21 13:44:14 +0000 | [diff] [blame] | 1060 | int size; |
| 1061 | void *dt; |
| 1062 | |
| 1063 | if (!initial_boot_params) { |
| 1064 | pr_warn("No valid device tree found, continuing without\n"); |
| 1065 | return; |
| 1066 | } |
| 1067 | |
Rob Herring | c972de1 | 2014-04-01 22:48:01 -0500 | [diff] [blame] | 1068 | size = fdt_totalsize(initial_boot_params); |
James Hogan | 6f041e9 | 2013-11-21 13:44:14 +0000 | [diff] [blame] | 1069 | dt = early_init_dt_alloc_memory_arch(size, |
Rob Herring | c972de1 | 2014-04-01 22:48:01 -0500 | [diff] [blame] | 1070 | roundup_pow_of_two(FDT_V17_SIZE)); |
Rob Herring | a8bf752 | 2013-08-26 11:22:45 -0500 | [diff] [blame] | 1071 | |
| 1072 | if (dt) { |
| 1073 | memcpy(dt, initial_boot_params, size); |
| 1074 | initial_boot_params = dt; |
| 1075 | } |
| 1076 | unflatten_device_tree(); |
| 1077 | } |
| 1078 | |
Rob Herring | b0a6fb3 | 2014-04-02 16:56:48 -0500 | [diff] [blame] | 1079 | #if defined(CONFIG_DEBUG_FS) && defined(DEBUG) |
| 1080 | static struct debugfs_blob_wrapper flat_dt_blob; |
| 1081 | |
| 1082 | static int __init of_flat_dt_debugfs_export_fdt(void) |
| 1083 | { |
| 1084 | struct dentry *d = debugfs_create_dir("device-tree", NULL); |
| 1085 | |
| 1086 | if (!d) |
| 1087 | return -ENOENT; |
| 1088 | |
| 1089 | flat_dt_blob.data = initial_boot_params; |
| 1090 | flat_dt_blob.size = fdt_totalsize(initial_boot_params); |
| 1091 | |
| 1092 | d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR, |
| 1093 | d, &flat_dt_blob); |
| 1094 | if (!d) |
| 1095 | return -ENOENT; |
| 1096 | |
| 1097 | return 0; |
| 1098 | } |
| 1099 | module_init(of_flat_dt_debugfs_export_fdt); |
| 1100 | #endif |
| 1101 | |
Stephen Neuendorffer | e6ce132 | 2010-11-18 15:54:56 -0800 | [diff] [blame] | 1102 | #endif /* CONFIG_OF_EARLY_FLATTREE */ |