prom.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef _SPARC_PROM_H
  2. #define _SPARC_PROM_H
  3. #ifdef __KERNEL__
  4. /*
  5. * Definitions for talking to the Open Firmware PROM on
  6. * Power Macintosh computers.
  7. *
  8. * Copyright (C) 1996-2005 Paul Mackerras.
  9. *
  10. * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
  11. * Updates for SPARC32 by David S. Miller
  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/proc_fs.h>
  20. #include <asm/atomic.h>
  21. typedef u32 phandle;
  22. typedef u32 ihandle;
  23. struct property {
  24. char *name;
  25. int length;
  26. void *value;
  27. struct property *next;
  28. unsigned long _flags;
  29. unsigned int unique_id;
  30. };
  31. struct device_node {
  32. char *name;
  33. char *type;
  34. phandle node;
  35. char *path_component_name;
  36. char *full_name;
  37. struct property *properties;
  38. struct property *deadprops; /* removed properties */
  39. struct device_node *parent;
  40. struct device_node *child;
  41. struct device_node *sibling;
  42. struct device_node *next; /* next device of same type */
  43. struct device_node *allnext; /* next in list of all nodes */
  44. struct proc_dir_entry *pde; /* this node's proc directory */
  45. struct kref kref;
  46. unsigned long _flags;
  47. void *data;
  48. unsigned int unique_id;
  49. };
  50. /* flag descriptions */
  51. #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
  52. #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
  53. #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
  54. #define OF_BAD_ADDR ((u64)-1)
  55. static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
  56. {
  57. dn->pde = de;
  58. }
  59. extern struct device_node *of_find_node_by_name(struct device_node *from,
  60. const char *name);
  61. #define for_each_node_by_name(dn, name) \
  62. for (dn = of_find_node_by_name(NULL, name); dn; \
  63. dn = of_find_node_by_name(dn, name))
  64. extern struct device_node *of_find_node_by_type(struct device_node *from,
  65. const char *type);
  66. #define for_each_node_by_type(dn, type) \
  67. for (dn = of_find_node_by_type(NULL, type); dn; \
  68. dn = of_find_node_by_type(dn, type))
  69. extern struct device_node *of_find_compatible_node(struct device_node *from,
  70. const char *type, const char *compat);
  71. extern struct device_node *of_find_node_by_path(const char *path);
  72. extern struct device_node *of_find_node_by_phandle(phandle handle);
  73. extern struct device_node *of_get_parent(const struct device_node *node);
  74. extern struct device_node *of_get_next_child(const struct device_node *node,
  75. struct device_node *prev);
  76. extern struct property *of_find_property(struct device_node *np,
  77. const char *name,
  78. int *lenp);
  79. extern int of_device_is_compatible(struct device_node *device, const char *);
  80. extern void *of_get_property(struct device_node *node, const char *name,
  81. int *lenp);
  82. extern int of_set_property(struct device_node *node, const char *name, void *val, int len);
  83. extern int of_getintprop_default(struct device_node *np,
  84. const char *name,
  85. int def);
  86. extern int of_n_addr_cells(struct device_node *np);
  87. extern int of_n_size_cells(struct device_node *np);
  88. extern void prom_build_devicetree(void);
  89. #endif /* __KERNEL__ */
  90. #endif /* _SPARC_PROM_H */