of.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef _LINUX_OF_H
  2. #define _LINUX_OF_H
  3. /*
  4. * Definitions for talking to the Open Firmware PROM on
  5. * Power Macintosh and other computers.
  6. *
  7. * Copyright (C) 1996-2005 Paul Mackerras.
  8. *
  9. * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
  10. * Updates for SPARC64 by David S. Miller
  11. * Derived from PowerPC and Sparc prom.h files by Stephen Rothwell, IBM Corp.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version
  16. * 2 of the License, or (at your option) any later version.
  17. */
  18. #include <linux/types.h>
  19. #include <linux/bitops.h>
  20. #include <linux/mod_devicetable.h>
  21. #include <asm/prom.h>
  22. /* flag descriptions */
  23. #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
  24. #define OF_DETACHED 2 /* node has been detached from the device tree */
  25. #define OF_BAD_ADDR ((u64)-1)
  26. extern struct device_node *of_find_node_by_name(struct device_node *from,
  27. const char *name);
  28. #define for_each_node_by_name(dn, name) \
  29. for (dn = of_find_node_by_name(NULL, name); dn; \
  30. dn = of_find_node_by_name(dn, name))
  31. extern struct device_node *of_find_node_by_type(struct device_node *from,
  32. const char *type);
  33. #define for_each_node_by_type(dn, type) \
  34. for (dn = of_find_node_by_type(NULL, type); dn; \
  35. dn = of_find_node_by_type(dn, type))
  36. extern struct device_node *of_find_compatible_node(struct device_node *from,
  37. const char *type, const char *compat);
  38. #define for_each_compatible_node(dn, type, compatible) \
  39. for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
  40. dn = of_find_compatible_node(dn, type, compatible))
  41. extern struct device_node *of_find_matching_node(struct device_node *from,
  42. const struct of_device_id *matches);
  43. #define for_each_matching_node(dn, matches) \
  44. for (dn = of_find_matching_node(NULL, matches); dn; \
  45. dn = of_find_matching_node(dn, matches))
  46. extern struct device_node *of_find_node_by_path(const char *path);
  47. extern struct device_node *of_find_node_by_phandle(phandle handle);
  48. extern struct device_node *of_get_parent(const struct device_node *node);
  49. extern struct device_node *of_get_next_parent(struct device_node *node);
  50. extern struct device_node *of_get_next_child(const struct device_node *node,
  51. struct device_node *prev);
  52. #define for_each_child_of_node(parent, child) \
  53. for (child = of_get_next_child(parent, NULL); child != NULL; \
  54. child = of_get_next_child(parent, child))
  55. extern struct property *of_find_property(const struct device_node *np,
  56. const char *name,
  57. int *lenp);
  58. extern int of_device_is_compatible(const struct device_node *device,
  59. const char *);
  60. extern int of_device_is_available(const struct device_node *device);
  61. extern const void *of_get_property(const struct device_node *node,
  62. const char *name,
  63. int *lenp);
  64. extern int of_n_addr_cells(struct device_node *np);
  65. extern int of_n_size_cells(struct device_node *np);
  66. extern const struct of_device_id *of_match_node(
  67. const struct of_device_id *matches, const struct device_node *node);
  68. extern int of_modalias_node(struct device_node *node, char *modalias, int len);
  69. #endif /* _LINUX_OF_H */