prom.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #include <linux/of.h> /* linux/of.h gets to determine #include ordering */
  2. #ifndef _POWERPC_PROM_H
  3. #define _POWERPC_PROM_H
  4. #ifdef __KERNEL__
  5. /*
  6. * Definitions for talking to the Open Firmware PROM on
  7. * Power Macintosh computers.
  8. *
  9. * Copyright (C) 1996-2005 Paul Mackerras.
  10. *
  11. * Updates for PPC64 by Peter Bergner & David Engebretsen, 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/of_fdt.h>
  20. #include <linux/of_irq.h>
  21. #include <linux/proc_fs.h>
  22. #include <linux/platform_device.h>
  23. #include <asm/irq.h>
  24. #include <asm/atomic.h>
  25. #define HAVE_ARCH_DEVTREE_FIXUPS
  26. #ifdef CONFIG_PPC32
  27. /*
  28. * PCI <-> OF matching functions
  29. * (XXX should these be here?)
  30. */
  31. struct pci_bus;
  32. struct pci_dev;
  33. extern int pci_device_from_OF_node(struct device_node *node,
  34. u8* bus, u8* devfn);
  35. extern struct device_node* pci_busdev_to_OF_node(struct pci_bus *, int);
  36. extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
  37. extern void pci_create_OF_bus_map(void);
  38. #endif
  39. /*
  40. * OF address retreival & translation
  41. */
  42. /* Translate an OF address block into a CPU physical address
  43. */
  44. extern u64 of_translate_address(struct device_node *np, const u32 *addr);
  45. /* Translate a DMA address from device space to CPU space */
  46. extern u64 of_translate_dma_address(struct device_node *dev,
  47. const u32 *in_addr);
  48. /* Extract an address from a device, returns the region size and
  49. * the address space flags too. The PCI version uses a BAR number
  50. * instead of an absolute index
  51. */
  52. extern const u32 *of_get_address(struct device_node *dev, int index,
  53. u64 *size, unsigned int *flags);
  54. #ifdef CONFIG_PCI
  55. extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
  56. u64 *size, unsigned int *flags);
  57. #else
  58. static inline const u32 *of_get_pci_address(struct device_node *dev,
  59. int bar_no, u64 *size, unsigned int *flags)
  60. {
  61. return NULL;
  62. }
  63. #endif /* CONFIG_PCI */
  64. /* Get an address as a resource. Note that if your address is
  65. * a PIO address, the conversion will fail if the physical address
  66. * can't be internally converted to an IO token with
  67. * pci_address_to_pio(), that is because it's either called to early
  68. * or it can't be matched to any host bridge IO space
  69. */
  70. extern int of_address_to_resource(struct device_node *dev, int index,
  71. struct resource *r);
  72. #ifdef CONFIG_PCI
  73. extern int of_pci_address_to_resource(struct device_node *dev, int bar,
  74. struct resource *r);
  75. #else
  76. static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
  77. struct resource *r)
  78. {
  79. return -ENOSYS;
  80. }
  81. #endif /* CONFIG_PCI */
  82. /* Parse the ibm,dma-window property of an OF node into the busno, phys and
  83. * size parameters.
  84. */
  85. void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
  86. unsigned long *busno, unsigned long *phys, unsigned long *size);
  87. extern void kdump_move_device_tree(void);
  88. /* CPU OF node matching */
  89. struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
  90. /* cache lookup */
  91. struct device_node *of_find_next_cache_node(struct device_node *np);
  92. /* Get the MAC address */
  93. extern const void *of_get_mac_address(struct device_node *np);
  94. /*
  95. * OF interrupt mapping
  96. */
  97. /**
  98. * of_irq_map_init - Initialize the irq remapper
  99. * @flags: flags defining workarounds to enable
  100. *
  101. * Some machines have bugs in the device-tree which require certain workarounds
  102. * to be applied. Call this before any interrupt mapping attempts to enable
  103. * those workarounds.
  104. */
  105. #define OF_IMAP_OLDWORLD_MAC 0x00000001
  106. #define OF_IMAP_NO_PHANDLE 0x00000002
  107. extern void of_irq_map_init(unsigned int flags);
  108. /**
  109. * of_irq_map_raw - Low level interrupt tree parsing
  110. * @parent: the device interrupt parent
  111. * @intspec: interrupt specifier ("interrupts" property of the device)
  112. * @ointsize: size of the passed in interrupt specifier
  113. * @addr: address specifier (start of "reg" property of the device)
  114. * @out_irq: structure of_irq filled by this function
  115. *
  116. * Returns 0 on success and a negative number on error
  117. *
  118. * This function is a low-level interrupt tree walking function. It
  119. * can be used to do a partial walk with synthetized reg and interrupts
  120. * properties, for example when resolving PCI interrupts when no device
  121. * node exist for the parent.
  122. *
  123. */
  124. extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec,
  125. u32 ointsize, const u32 *addr,
  126. struct of_irq *out_irq);
  127. /**
  128. * of_irq_map_pci - Resolve the interrupt for a PCI device
  129. * @pdev: the device whose interrupt is to be resolved
  130. * @out_irq: structure of_irq filled by this function
  131. *
  132. * This function resolves the PCI interrupt for a given PCI device. If a
  133. * device-node exists for a given pci_dev, it will use normal OF tree
  134. * walking. If not, it will implement standard swizzling and walk up the
  135. * PCI tree until an device-node is found, at which point it will finish
  136. * resolving using the OF tree walking.
  137. */
  138. struct pci_dev;
  139. extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
  140. extern int of_irq_to_resource(struct device_node *dev, int index,
  141. struct resource *r);
  142. /**
  143. * of_iomap - Maps the memory mapped IO for a given device_node
  144. * @device: the device whose io range will be mapped
  145. * @index: index of the io range
  146. *
  147. * Returns a pointer to the mapped memory
  148. */
  149. extern void __iomem *of_iomap(struct device_node *device, int index);
  150. #endif /* __KERNEL__ */
  151. #endif /* _POWERPC_PROM_H */