fdtdec.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. * See file CREDITS for list of people who contributed to this
  4. * project.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  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., 59 Temple Place, Suite 330, Boston,
  19. * MA 02111-1307 USA
  20. */
  21. #include <common.h>
  22. #include <serial.h>
  23. #include <libfdt.h>
  24. #include <fdtdec.h>
  25. #include <asm/gpio.h>
  26. DECLARE_GLOBAL_DATA_PTR;
  27. /*
  28. * Here are the type we know about. One day we might allow drivers to
  29. * register. For now we just put them here. The COMPAT macro allows us to
  30. * turn this into a sparse list later, and keeps the ID with the name.
  31. */
  32. #define COMPAT(id, name) name
  33. static const char * const compat_names[COMPAT_COUNT] = {
  34. COMPAT(UNKNOWN, "<none>"),
  35. COMPAT(NVIDIA_TEGRA20_USB, "nvidia,tegra20-ehci"),
  36. COMPAT(NVIDIA_TEGRA114_I2C, "nvidia,tegra114-i2c"),
  37. COMPAT(NVIDIA_TEGRA20_I2C, "nvidia,tegra20-i2c"),
  38. COMPAT(NVIDIA_TEGRA20_DVC, "nvidia,tegra20-i2c-dvc"),
  39. COMPAT(NVIDIA_TEGRA20_EMC, "nvidia,tegra20-emc"),
  40. COMPAT(NVIDIA_TEGRA20_EMC_TABLE, "nvidia,tegra20-emc-table"),
  41. COMPAT(NVIDIA_TEGRA20_KBC, "nvidia,tegra20-kbc"),
  42. COMPAT(NVIDIA_TEGRA20_NAND, "nvidia,tegra20-nand"),
  43. COMPAT(NVIDIA_TEGRA20_PWM, "nvidia,tegra20-pwm"),
  44. COMPAT(NVIDIA_TEGRA20_DC, "nvidia,tegra20-dc"),
  45. COMPAT(NVIDIA_TEGRA30_SDMMC, "nvidia,tegra30-sdhci"),
  46. COMPAT(NVIDIA_TEGRA20_SDMMC, "nvidia,tegra20-sdhci"),
  47. COMPAT(NVIDIA_TEGRA20_SFLASH, "nvidia,tegra20-sflash"),
  48. COMPAT(NVIDIA_TEGRA20_SLINK, "nvidia,tegra20-slink"),
  49. COMPAT(NVIDIA_TEGRA114_SPI, "nvidia,tegra114-spi"),
  50. COMPAT(SMSC_LAN9215, "smsc,lan9215"),
  51. COMPAT(SAMSUNG_EXYNOS5_SROMC, "samsung,exynos-sromc"),
  52. COMPAT(SAMSUNG_S3C2440_I2C, "samsung,s3c2440-i2c"),
  53. COMPAT(SAMSUNG_EXYNOS5_SOUND, "samsung,exynos-sound"),
  54. COMPAT(WOLFSON_WM8994_CODEC, "wolfson,wm8994-codec"),
  55. COMPAT(SAMSUNG_EXYNOS_SPI, "samsung,exynos-spi"),
  56. COMPAT(SAMSUNG_EXYNOS_EHCI, "samsung,exynos-ehci"),
  57. COMPAT(SAMSUNG_EXYNOS_USB_PHY, "samsung,exynos-usb-phy"),
  58. COMPAT(SAMSUNG_EXYNOS_TMU, "samsung,exynos-tmu"),
  59. COMPAT(SAMSUNG_EXYNOS_FIMD, "samsung,exynos-fimd"),
  60. COMPAT(SAMSUNG_EXYNOS5_DP, "samsung,exynos5-dp"),
  61. COMPAT(MAXIM_MAX77686_PMIC, "maxim,max77686_pmic"),
  62. COMPAT(GENERIC_SPI_FLASH, "spi-flash"),
  63. COMPAT(MAXIM_98095_CODEC, "maxim,max98095-codec"),
  64. COMPAT(INFINEON_SLB9635_TPM, "infineon,slb9635-tpm"),
  65. COMPAT(INFINEON_SLB9645_TPM, "infineon,slb9645-tpm"),
  66. };
  67. const char *fdtdec_get_compatible(enum fdt_compat_id id)
  68. {
  69. /* We allow reading of the 'unknown' ID for testing purposes */
  70. assert(id >= 0 && id < COMPAT_COUNT);
  71. return compat_names[id];
  72. }
  73. fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
  74. const char *prop_name, fdt_size_t *sizep)
  75. {
  76. const fdt_addr_t *cell;
  77. int len;
  78. debug("%s: %s: ", __func__, prop_name);
  79. cell = fdt_getprop(blob, node, prop_name, &len);
  80. if (cell && ((!sizep && len == sizeof(fdt_addr_t)) ||
  81. len == sizeof(fdt_addr_t) * 2)) {
  82. fdt_addr_t addr = fdt_addr_to_cpu(*cell);
  83. if (sizep) {
  84. const fdt_size_t *size;
  85. size = (fdt_size_t *)((char *)cell +
  86. sizeof(fdt_addr_t));
  87. *sizep = fdt_size_to_cpu(*size);
  88. debug("addr=%p, size=%p\n", (void *)addr,
  89. (void *)*sizep);
  90. } else {
  91. debug("%p\n", (void *)addr);
  92. }
  93. return addr;
  94. }
  95. debug("(not found)\n");
  96. return FDT_ADDR_T_NONE;
  97. }
  98. fdt_addr_t fdtdec_get_addr(const void *blob, int node,
  99. const char *prop_name)
  100. {
  101. return fdtdec_get_addr_size(blob, node, prop_name, NULL);
  102. }
  103. s32 fdtdec_get_int(const void *blob, int node, const char *prop_name,
  104. s32 default_val)
  105. {
  106. const s32 *cell;
  107. int len;
  108. debug("%s: %s: ", __func__, prop_name);
  109. cell = fdt_getprop(blob, node, prop_name, &len);
  110. if (cell && len >= sizeof(s32)) {
  111. s32 val = fdt32_to_cpu(cell[0]);
  112. debug("%#x (%d)\n", val, val);
  113. return val;
  114. }
  115. debug("(not found)\n");
  116. return default_val;
  117. }
  118. uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,
  119. uint64_t default_val)
  120. {
  121. const uint64_t *cell64;
  122. int length;
  123. cell64 = fdt_getprop(blob, node, prop_name, &length);
  124. if (!cell64 || length < sizeof(*cell64))
  125. return default_val;
  126. return fdt64_to_cpu(*cell64);
  127. }
  128. int fdtdec_get_is_enabled(const void *blob, int node)
  129. {
  130. const char *cell;
  131. /*
  132. * It should say "okay", so only allow that. Some fdts use "ok" but
  133. * this is a bug. Please fix your device tree source file. See here
  134. * for discussion:
  135. *
  136. * http://www.mail-archive.com/u-boot@lists.denx.de/msg71598.html
  137. */
  138. cell = fdt_getprop(blob, node, "status", NULL);
  139. if (cell)
  140. return 0 == strcmp(cell, "okay");
  141. return 1;
  142. }
  143. enum fdt_compat_id fdtdec_lookup(const void *blob, int node)
  144. {
  145. enum fdt_compat_id id;
  146. /* Search our drivers */
  147. for (id = COMPAT_UNKNOWN; id < COMPAT_COUNT; id++)
  148. if (0 == fdt_node_check_compatible(blob, node,
  149. compat_names[id]))
  150. return id;
  151. return COMPAT_UNKNOWN;
  152. }
  153. int fdtdec_next_compatible(const void *blob, int node,
  154. enum fdt_compat_id id)
  155. {
  156. return fdt_node_offset_by_compatible(blob, node, compat_names[id]);
  157. }
  158. int fdtdec_next_compatible_subnode(const void *blob, int node,
  159. enum fdt_compat_id id, int *depthp)
  160. {
  161. do {
  162. node = fdt_next_node(blob, node, depthp);
  163. } while (*depthp > 1);
  164. /* If this is a direct subnode, and compatible, return it */
  165. if (*depthp == 1 && 0 == fdt_node_check_compatible(
  166. blob, node, compat_names[id]))
  167. return node;
  168. return -FDT_ERR_NOTFOUND;
  169. }
  170. int fdtdec_next_alias(const void *blob, const char *name,
  171. enum fdt_compat_id id, int *upto)
  172. {
  173. #define MAX_STR_LEN 20
  174. char str[MAX_STR_LEN + 20];
  175. int node, err;
  176. /* snprintf() is not available */
  177. assert(strlen(name) < MAX_STR_LEN);
  178. sprintf(str, "%.*s%d", MAX_STR_LEN, name, *upto);
  179. node = fdt_path_offset(blob, str);
  180. if (node < 0)
  181. return node;
  182. err = fdt_node_check_compatible(blob, node, compat_names[id]);
  183. if (err < 0)
  184. return err;
  185. if (err)
  186. return -FDT_ERR_NOTFOUND;
  187. (*upto)++;
  188. return node;
  189. }
  190. int fdtdec_find_aliases_for_id(const void *blob, const char *name,
  191. enum fdt_compat_id id, int *node_list, int maxcount)
  192. {
  193. memset(node_list, '\0', sizeof(*node_list) * maxcount);
  194. return fdtdec_add_aliases_for_id(blob, name, id, node_list, maxcount);
  195. }
  196. /* TODO: Can we tighten this code up a little? */
  197. int fdtdec_add_aliases_for_id(const void *blob, const char *name,
  198. enum fdt_compat_id id, int *node_list, int maxcount)
  199. {
  200. int name_len = strlen(name);
  201. int nodes[maxcount];
  202. int num_found = 0;
  203. int offset, node;
  204. int alias_node;
  205. int count;
  206. int i, j;
  207. /* find the alias node if present */
  208. alias_node = fdt_path_offset(blob, "/aliases");
  209. /*
  210. * start with nothing, and we can assume that the root node can't
  211. * match
  212. */
  213. memset(nodes, '\0', sizeof(nodes));
  214. /* First find all the compatible nodes */
  215. for (node = count = 0; node >= 0 && count < maxcount;) {
  216. node = fdtdec_next_compatible(blob, node, id);
  217. if (node >= 0)
  218. nodes[count++] = node;
  219. }
  220. if (node >= 0)
  221. debug("%s: warning: maxcount exceeded with alias '%s'\n",
  222. __func__, name);
  223. /* Now find all the aliases */
  224. for (offset = fdt_first_property_offset(blob, alias_node);
  225. offset > 0;
  226. offset = fdt_next_property_offset(blob, offset)) {
  227. const struct fdt_property *prop;
  228. const char *path;
  229. int number;
  230. int found;
  231. node = 0;
  232. prop = fdt_get_property_by_offset(blob, offset, NULL);
  233. path = fdt_string(blob, fdt32_to_cpu(prop->nameoff));
  234. if (prop->len && 0 == strncmp(path, name, name_len))
  235. node = fdt_path_offset(blob, prop->data);
  236. if (node <= 0)
  237. continue;
  238. /* Get the alias number */
  239. number = simple_strtoul(path + name_len, NULL, 10);
  240. if (number < 0 || number >= maxcount) {
  241. debug("%s: warning: alias '%s' is out of range\n",
  242. __func__, path);
  243. continue;
  244. }
  245. /* Make sure the node we found is actually in our list! */
  246. found = -1;
  247. for (j = 0; j < count; j++)
  248. if (nodes[j] == node) {
  249. found = j;
  250. break;
  251. }
  252. if (found == -1) {
  253. debug("%s: warning: alias '%s' points to a node "
  254. "'%s' that is missing or is not compatible "
  255. " with '%s'\n", __func__, path,
  256. fdt_get_name(blob, node, NULL),
  257. compat_names[id]);
  258. continue;
  259. }
  260. /*
  261. * Add this node to our list in the right place, and mark
  262. * it as done.
  263. */
  264. if (fdtdec_get_is_enabled(blob, node)) {
  265. if (node_list[number]) {
  266. debug("%s: warning: alias '%s' requires that "
  267. "a node be placed in the list in a "
  268. "position which is already filled by "
  269. "node '%s'\n", __func__, path,
  270. fdt_get_name(blob, node, NULL));
  271. continue;
  272. }
  273. node_list[number] = node;
  274. if (number >= num_found)
  275. num_found = number + 1;
  276. }
  277. nodes[found] = 0;
  278. }
  279. /* Add any nodes not mentioned by an alias */
  280. for (i = j = 0; i < maxcount; i++) {
  281. if (!node_list[i]) {
  282. for (; j < maxcount; j++)
  283. if (nodes[j] &&
  284. fdtdec_get_is_enabled(blob, nodes[j]))
  285. break;
  286. /* Have we run out of nodes to add? */
  287. if (j == maxcount)
  288. break;
  289. assert(!node_list[i]);
  290. node_list[i] = nodes[j++];
  291. if (i >= num_found)
  292. num_found = i + 1;
  293. }
  294. }
  295. return num_found;
  296. }
  297. int fdtdec_check_fdt(void)
  298. {
  299. /*
  300. * We must have an FDT, but we cannot panic() yet since the console
  301. * is not ready. So for now, just assert(). Boards which need an early
  302. * FDT (prior to console ready) will need to make their own
  303. * arrangements and do their own checks.
  304. */
  305. assert(!fdtdec_prepare_fdt());
  306. return 0;
  307. }
  308. /*
  309. * This function is a little odd in that it accesses global data. At some
  310. * point if the architecture board.c files merge this will make more sense.
  311. * Even now, it is common code.
  312. */
  313. int fdtdec_prepare_fdt(void)
  314. {
  315. if (!gd->fdt_blob || ((uintptr_t)gd->fdt_blob & 3) ||
  316. fdt_check_header(gd->fdt_blob)) {
  317. printf("No valid FDT found - please append one to U-Boot "
  318. "binary, use u-boot-dtb.bin or define "
  319. "CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>\n");
  320. return -1;
  321. }
  322. return 0;
  323. }
  324. int fdtdec_lookup_phandle(const void *blob, int node, const char *prop_name)
  325. {
  326. const u32 *phandle;
  327. int lookup;
  328. debug("%s: %s\n", __func__, prop_name);
  329. phandle = fdt_getprop(blob, node, prop_name, NULL);
  330. if (!phandle)
  331. return -FDT_ERR_NOTFOUND;
  332. lookup = fdt_node_offset_by_phandle(blob, fdt32_to_cpu(*phandle));
  333. return lookup;
  334. }
  335. /**
  336. * Look up a property in a node and check that it has a minimum length.
  337. *
  338. * @param blob FDT blob
  339. * @param node node to examine
  340. * @param prop_name name of property to find
  341. * @param min_len minimum property length in bytes
  342. * @param err 0 if ok, or -FDT_ERR_NOTFOUND if the property is not
  343. found, or -FDT_ERR_BADLAYOUT if not enough data
  344. * @return pointer to cell, which is only valid if err == 0
  345. */
  346. static const void *get_prop_check_min_len(const void *blob, int node,
  347. const char *prop_name, int min_len, int *err)
  348. {
  349. const void *cell;
  350. int len;
  351. debug("%s: %s\n", __func__, prop_name);
  352. cell = fdt_getprop(blob, node, prop_name, &len);
  353. if (!cell)
  354. *err = -FDT_ERR_NOTFOUND;
  355. else if (len < min_len)
  356. *err = -FDT_ERR_BADLAYOUT;
  357. else
  358. *err = 0;
  359. return cell;
  360. }
  361. int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
  362. u32 *array, int count)
  363. {
  364. const u32 *cell;
  365. int i, err = 0;
  366. debug("%s: %s\n", __func__, prop_name);
  367. cell = get_prop_check_min_len(blob, node, prop_name,
  368. sizeof(u32) * count, &err);
  369. if (!err) {
  370. for (i = 0; i < count; i++)
  371. array[i] = fdt32_to_cpu(cell[i]);
  372. }
  373. return err;
  374. }
  375. const u32 *fdtdec_locate_array(const void *blob, int node,
  376. const char *prop_name, int count)
  377. {
  378. const u32 *cell;
  379. int err;
  380. cell = get_prop_check_min_len(blob, node, prop_name,
  381. sizeof(u32) * count, &err);
  382. return err ? NULL : cell;
  383. }
  384. int fdtdec_get_bool(const void *blob, int node, const char *prop_name)
  385. {
  386. const s32 *cell;
  387. int len;
  388. debug("%s: %s\n", __func__, prop_name);
  389. cell = fdt_getprop(blob, node, prop_name, &len);
  390. return cell != NULL;
  391. }
  392. /**
  393. * Decode a list of GPIOs from an FDT. This creates a list of GPIOs with no
  394. * terminating item.
  395. *
  396. * @param blob FDT blob to use
  397. * @param node Node to look at
  398. * @param prop_name Node property name
  399. * @param gpio Array of gpio elements to fill from FDT. This will be
  400. * untouched if either 0 or an error is returned
  401. * @param max_count Maximum number of elements allowed
  402. * @return number of GPIOs read if ok, -FDT_ERR_BADLAYOUT if max_count would
  403. * be exceeded, or -FDT_ERR_NOTFOUND if the property is missing.
  404. */
  405. int fdtdec_decode_gpios(const void *blob, int node, const char *prop_name,
  406. struct fdt_gpio_state *gpio, int max_count)
  407. {
  408. const struct fdt_property *prop;
  409. const u32 *cell;
  410. const char *name;
  411. int len, i;
  412. debug("%s: %s\n", __func__, prop_name);
  413. assert(max_count > 0);
  414. prop = fdt_get_property(blob, node, prop_name, &len);
  415. if (!prop) {
  416. debug("%s: property '%s' missing\n", __func__, prop_name);
  417. return -FDT_ERR_NOTFOUND;
  418. }
  419. /* We will use the name to tag the GPIO */
  420. name = fdt_string(blob, fdt32_to_cpu(prop->nameoff));
  421. cell = (u32 *)prop->data;
  422. len /= sizeof(u32) * 3; /* 3 cells per GPIO record */
  423. if (len > max_count) {
  424. debug(" %s: too many GPIOs / cells for "
  425. "property '%s'\n", __func__, prop_name);
  426. return -FDT_ERR_BADLAYOUT;
  427. }
  428. /* Read out the GPIO data from the cells */
  429. for (i = 0; i < len; i++, cell += 3) {
  430. gpio[i].gpio = fdt32_to_cpu(cell[1]);
  431. gpio[i].flags = fdt32_to_cpu(cell[2]);
  432. gpio[i].name = name;
  433. }
  434. return len;
  435. }
  436. int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
  437. struct fdt_gpio_state *gpio)
  438. {
  439. int err;
  440. debug("%s: %s\n", __func__, prop_name);
  441. gpio->gpio = FDT_GPIO_NONE;
  442. gpio->name = NULL;
  443. err = fdtdec_decode_gpios(blob, node, prop_name, gpio, 1);
  444. return err == 1 ? 0 : err;
  445. }
  446. int fdtdec_get_gpio(struct fdt_gpio_state *gpio)
  447. {
  448. int val;
  449. if (!fdt_gpio_isvalid(gpio))
  450. return -1;
  451. val = gpio_get_value(gpio->gpio);
  452. return gpio->flags & FDT_GPIO_ACTIVE_LOW ? val ^ 1 : val;
  453. }
  454. int fdtdec_set_gpio(struct fdt_gpio_state *gpio, int val)
  455. {
  456. if (!fdt_gpio_isvalid(gpio))
  457. return -1;
  458. val = gpio->flags & FDT_GPIO_ACTIVE_LOW ? val ^ 1 : val;
  459. return gpio_set_value(gpio->gpio, val);
  460. }
  461. int fdtdec_setup_gpio(struct fdt_gpio_state *gpio)
  462. {
  463. /*
  464. * Return success if there is no GPIO defined. This is used for
  465. * optional GPIOs)
  466. */
  467. if (!fdt_gpio_isvalid(gpio))
  468. return 0;
  469. if (gpio_request(gpio->gpio, gpio->name))
  470. return -1;
  471. return 0;
  472. }
  473. int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
  474. u8 *array, int count)
  475. {
  476. const u8 *cell;
  477. int err;
  478. cell = get_prop_check_min_len(blob, node, prop_name, count, &err);
  479. if (!err)
  480. memcpy(array, cell, count);
  481. return err;
  482. }
  483. const u8 *fdtdec_locate_byte_array(const void *blob, int node,
  484. const char *prop_name, int count)
  485. {
  486. const u8 *cell;
  487. int err;
  488. cell = get_prop_check_min_len(blob, node, prop_name, count, &err);
  489. if (err)
  490. return NULL;
  491. return cell;
  492. }
  493. int fdtdec_get_config_int(const void *blob, const char *prop_name,
  494. int default_val)
  495. {
  496. int config_node;
  497. debug("%s: %s\n", __func__, prop_name);
  498. config_node = fdt_path_offset(blob, "/config");
  499. if (config_node < 0)
  500. return default_val;
  501. return fdtdec_get_int(blob, config_node, prop_name, default_val);
  502. }
  503. int fdtdec_get_config_bool(const void *blob, const char *prop_name)
  504. {
  505. int config_node;
  506. const void *prop;
  507. debug("%s: %s\n", __func__, prop_name);
  508. config_node = fdt_path_offset(blob, "/config");
  509. if (config_node < 0)
  510. return 0;
  511. prop = fdt_get_property(blob, config_node, prop_name, NULL);
  512. return prop != NULL;
  513. }
  514. char *fdtdec_get_config_string(const void *blob, const char *prop_name)
  515. {
  516. const char *nodep;
  517. int nodeoffset;
  518. int len;
  519. debug("%s: %s\n", __func__, prop_name);
  520. nodeoffset = fdt_path_offset(blob, "/config");
  521. if (nodeoffset < 0)
  522. return NULL;
  523. nodep = fdt_getprop(blob, nodeoffset, prop_name, &len);
  524. if (!nodep)
  525. return NULL;
  526. return (char *)nodep;
  527. }
  528. int fdtdec_decode_region(const void *blob, int node,
  529. const char *prop_name, void **ptrp, size_t *size)
  530. {
  531. const fdt_addr_t *cell;
  532. int len;
  533. debug("%s: %s\n", __func__, prop_name);
  534. cell = fdt_getprop(blob, node, prop_name, &len);
  535. if (!cell || (len != sizeof(fdt_addr_t) * 2))
  536. return -1;
  537. *ptrp = (void *)fdt_addr_to_cpu(*cell);
  538. *size = fdt_size_to_cpu(cell[1]);
  539. debug("%s: size=%zx\n", __func__, *size);
  540. return 0;
  541. }