prom.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef _SPARC64_PROM_H
  2. #define _SPARC64_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 SPARC64 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 of_irq_controller;
  32. struct device_node {
  33. char *name;
  34. char *type;
  35. phandle node;
  36. char *path_component_name;
  37. char *full_name;
  38. struct property *properties;
  39. struct property *deadprops; /* removed properties */
  40. struct device_node *parent;
  41. struct device_node *child;
  42. struct device_node *sibling;
  43. struct device_node *next; /* next device of same type */
  44. struct device_node *allnext; /* next in list of all nodes */
  45. struct proc_dir_entry *pde; /* this node's proc directory */
  46. struct kref kref;
  47. unsigned long _flags;
  48. void *data;
  49. unsigned int unique_id;
  50. struct of_irq_controller *irq_trans;
  51. };
  52. struct of_irq_controller {
  53. unsigned int (*irq_build)(struct device_node *, unsigned int, void *);
  54. void *data;
  55. };
  56. /* flag descriptions */
  57. #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
  58. #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
  59. #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
  60. #define OF_BAD_ADDR ((u64)-1)
  61. static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
  62. {
  63. dn->pde = de;
  64. }
  65. extern struct device_node *of_find_node_by_name(struct device_node *from,
  66. const char *name);
  67. #define for_each_node_by_name(dn, name) \
  68. for (dn = of_find_node_by_name(NULL, name); dn; \
  69. dn = of_find_node_by_name(dn, name))
  70. extern struct device_node *of_find_node_by_type(struct device_node *from,
  71. const char *type);
  72. #define for_each_node_by_type(dn, type) \
  73. for (dn = of_find_node_by_type(NULL, type); dn; \
  74. dn = of_find_node_by_type(dn, type))
  75. extern struct device_node *of_find_compatible_node(struct device_node *from,
  76. const char *type, const char *compat);
  77. extern struct device_node *of_find_node_by_path(const char *path);
  78. extern struct device_node *of_find_node_by_phandle(phandle handle);
  79. extern struct device_node *of_get_parent(const struct device_node *node);
  80. extern struct device_node *of_get_next_child(const struct device_node *node,
  81. struct device_node *prev);
  82. extern struct property *of_find_property(struct device_node *np,
  83. const char *name,
  84. int *lenp);
  85. extern int of_device_is_compatible(struct device_node *device, const char *);
  86. extern void *of_get_property(struct device_node *node, const char *name,
  87. int *lenp);
  88. extern int of_set_property(struct device_node *node, const char *name, void *val, int len);
  89. extern int of_getintprop_default(struct device_node *np,
  90. const char *name,
  91. int def);
  92. extern int of_n_addr_cells(struct device_node *np);
  93. extern int of_n_size_cells(struct device_node *np);
  94. extern void prom_build_devicetree(void);
  95. #endif /* __KERNEL__ */
  96. #endif /* _SPARC64_PROM_H */