prom.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 SPARC 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 <linux/mutex.h>
  21. #include <asm/atomic.h>
  22. #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2
  23. #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
  24. #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l))
  25. #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2))
  26. #define of_node_cmp(s1, s2) strcmp((s1), (s2))
  27. typedef u32 phandle;
  28. typedef u32 ihandle;
  29. struct property {
  30. char *name;
  31. int length;
  32. void *value;
  33. struct property *next;
  34. unsigned long _flags;
  35. unsigned int unique_id;
  36. };
  37. struct of_irq_controller;
  38. struct device_node {
  39. const char *name;
  40. const char *type;
  41. phandle node;
  42. char *path_component_name;
  43. char *full_name;
  44. struct property *properties;
  45. struct property *deadprops; /* removed properties */
  46. struct device_node *parent;
  47. struct device_node *child;
  48. struct device_node *sibling;
  49. struct device_node *next; /* next device of same type */
  50. struct device_node *allnext; /* next in list of all nodes */
  51. struct proc_dir_entry *pde; /* this node's proc directory */
  52. struct kref kref;
  53. unsigned long _flags;
  54. void *data;
  55. unsigned int unique_id;
  56. struct of_irq_controller *irq_trans;
  57. };
  58. struct of_irq_controller {
  59. unsigned int (*irq_build)(struct device_node *, unsigned int, void *);
  60. void *data;
  61. };
  62. #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
  63. #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
  64. extern struct device_node *of_find_node_by_cpuid(int cpuid);
  65. extern int of_set_property(struct device_node *node, const char *name, void *val, int len);
  66. extern struct mutex of_set_property_mutex;
  67. extern int of_getintprop_default(struct device_node *np,
  68. const char *name,
  69. int def);
  70. extern int of_find_in_proplist(const char *list, const char *match, int len);
  71. #ifdef CONFIG_NUMA
  72. extern int of_node_to_nid(struct device_node *dp);
  73. #else
  74. #define of_node_to_nid(dp) (-1)
  75. #endif
  76. extern void prom_build_devicetree(void);
  77. extern void of_populate_present_mask(void);
  78. extern void of_fill_in_cpu_data(void);
  79. /* Dummy ref counting routines - to be implemented later */
  80. static inline struct device_node *of_node_get(struct device_node *node)
  81. {
  82. return node;
  83. }
  84. static inline void of_node_put(struct device_node *node)
  85. {
  86. }
  87. /* These routines are here to provide compatibility with how powerpc
  88. * handles IRQ mapping for OF device nodes. We precompute and permanently
  89. * register them in the of_device objects, whereas powerpc computes them
  90. * on request.
  91. */
  92. extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
  93. static inline void irq_dispose_mapping(unsigned int virq)
  94. {
  95. }
  96. /*
  97. * NB: This is here while we transition from using asm/prom.h
  98. * to linux/of.h
  99. */
  100. #include <linux/of.h>
  101. extern struct device_node *of_console_device;
  102. extern char *of_console_path;
  103. extern char *of_console_options;
  104. #endif /* __KERNEL__ */
  105. #endif /* _SPARC_PROM_H */