tinyfdt.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2019 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. */
  9. #ifndef __FDT_H__
  10. #define __FDT_H__
  11. #include <sbi/sbi_types.h>
  12. struct fdt_node {
  13. char *data;
  14. const struct fdt_node *parent;
  15. const char *name;
  16. int depth;
  17. int address_cells;
  18. int size_cells;
  19. };
  20. struct fdt_prop {
  21. const struct fdt_node *node;
  22. const char *name;
  23. void *value;
  24. u32 len;
  25. };
  26. /* Reverse byte-order of 32bit number */
  27. u32 fdt_rev32(u32 v);
  28. /* Length of a string */
  29. ulong fdt_strlen(const char *str);
  30. /* Compate two strings */
  31. int fdt_strcmp(const char *a, const char *b);
  32. /* Find index of matching string from a list of strings */
  33. int fdt_prop_string_index(const struct fdt_prop *prop, const char *str);
  34. /* Iterate over each property of matching node */
  35. int fdt_match_node_prop(void *fdt,
  36. int (*match)(const struct fdt_node *node,
  37. const struct fdt_prop *prop, void *priv),
  38. void *match_priv,
  39. void (*fn)(const struct fdt_node *node,
  40. const struct fdt_prop *prop, void *priv),
  41. void *fn_priv);
  42. /* Iterate over each property of compatible node */
  43. int fdt_compat_node_prop(void *fdt, const char *compat,
  44. void (*fn)(const struct fdt_node *node,
  45. const struct fdt_prop *prop, void *priv),
  46. void *fn_priv);
  47. /* Iterate over each node and property */
  48. int fdt_walk(void *fdt,
  49. void (*fn)(const struct fdt_node *node,
  50. const struct fdt_prop *prop, void *priv),
  51. void *fn_priv);
  52. /* Get size of FDT */
  53. u32 fdt_size(void *fdt);
  54. #endif