prom.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 interrupt_info {
  24. int line;
  25. int sense; /* +ve/-ve logic, edge or level, etc. */
  26. };
  27. struct property {
  28. char *name;
  29. int length;
  30. void *value;
  31. struct property *next;
  32. };
  33. struct device_node {
  34. char *name;
  35. char *type;
  36. phandle node;
  37. phandle linux_phandle;
  38. int n_intrs;
  39. struct interrupt_info *intrs;
  40. char *path_component_name;
  41. char *full_name;
  42. struct property *properties;
  43. struct property *deadprops; /* removed properties */
  44. struct device_node *parent;
  45. struct device_node *child;
  46. struct device_node *sibling;
  47. struct device_node *next; /* next device of same type */
  48. struct device_node *allnext; /* next in list of all nodes */
  49. struct proc_dir_entry *pde; /* this node's proc directory */
  50. struct kref kref;
  51. unsigned long _flags;
  52. void *data;
  53. };
  54. static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
  55. {
  56. dn->pde = de;
  57. }
  58. extern struct device_node *of_find_node_by_name(struct device_node *from,
  59. const char *name);
  60. #define for_each_node_by_name(dn, name) \
  61. for (dn = of_find_node_by_name(NULL, name); dn; \
  62. dn = of_find_node_by_name(dn, name))
  63. extern struct device_node *of_find_node_by_type(struct device_node *from,
  64. const char *type);
  65. #define for_each_node_by_type(dn, type) \
  66. for (dn = of_find_node_by_type(NULL, type); dn; \
  67. dn = of_find_node_by_type(dn, type))
  68. extern struct device_node *of_find_compatible_node(struct device_node *from,
  69. const char *type, const char *compat);
  70. extern struct device_node *of_find_node_by_path(const char *path);
  71. extern struct device_node *of_find_node_by_phandle(phandle handle);
  72. extern struct device_node *of_get_parent(const struct device_node *node);
  73. extern struct device_node *of_get_next_child(const struct device_node *node,
  74. struct device_node *prev);
  75. extern struct property *of_find_property(struct device_node *np,
  76. const char *name,
  77. int *lenp);
  78. extern int of_device_is_compatible(struct device_node *device, const char *);
  79. extern void *of_get_property(struct device_node *node, const char *name,
  80. int *lenp);
  81. extern int of_getintprop_default(struct device_node *np,
  82. const char *name,
  83. int def);
  84. extern void prom_build_devicetree(void);
  85. #endif /* __KERNEL__ */
  86. #endif /* _SPARC_PROM_H */