PageRenderTime 71ms CodeModel.GetById 18ms RepoModel.GetById 2ms app.codeStats 0ms

/arch/powerpc/include/asm/prom.h

https://bitbucket.org/abioy/linux
C Header | 198 lines | 74 code | 27 blank | 97 comment | 0 complexity | 94d7eaa42a892a7143106b5688fb6260 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, GPL-2.0, LGPL-2.0, AGPL-1.0
  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/proc_fs.h>
  21. #include <linux/platform_device.h>
  22. #include <asm/irq.h>
  23. #include <asm/atomic.h>
  24. #define HAVE_ARCH_DEVTREE_FIXUPS
  25. #ifdef CONFIG_PPC32
  26. /*
  27. * PCI <-> OF matching functions
  28. * (XXX should these be here?)
  29. */
  30. struct pci_bus;
  31. struct pci_dev;
  32. extern int pci_device_from_OF_node(struct device_node *node,
  33. u8* bus, u8* devfn);
  34. extern struct device_node* pci_busdev_to_OF_node(struct pci_bus *, int);
  35. extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
  36. extern void pci_create_OF_bus_map(void);
  37. #endif
  38. /*
  39. * OF address retreival & translation
  40. */
  41. /* Translate an OF address block into a CPU physical address
  42. */
  43. extern u64 of_translate_address(struct device_node *np, const u32 *addr);
  44. /* Translate a DMA address from device space to CPU space */
  45. extern u64 of_translate_dma_address(struct device_node *dev,
  46. const u32 *in_addr);
  47. /* Extract an address from a device, returns the region size and
  48. * the address space flags too. The PCI version uses a BAR number
  49. * instead of an absolute index
  50. */
  51. extern const u32 *of_get_address(struct device_node *dev, int index,
  52. u64 *size, unsigned int *flags);
  53. #ifdef CONFIG_PCI
  54. extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
  55. u64 *size, unsigned int *flags);
  56. #else
  57. static inline const u32 *of_get_pci_address(struct device_node *dev,
  58. int bar_no, u64 *size, unsigned int *flags)
  59. {
  60. return NULL;
  61. }
  62. #endif /* CONFIG_PCI */
  63. /* Get an address as a resource. Note that if your address is
  64. * a PIO address, the conversion will fail if the physical address
  65. * can't be internally converted to an IO token with
  66. * pci_address_to_pio(), that is because it's either called to early
  67. * or it can't be matched to any host bridge IO space
  68. */
  69. extern int of_address_to_resource(struct device_node *dev, int index,
  70. struct resource *r);
  71. #ifdef CONFIG_PCI
  72. extern int of_pci_address_to_resource(struct device_node *dev, int bar,
  73. struct resource *r);
  74. #else
  75. static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
  76. struct resource *r)
  77. {
  78. return -ENOSYS;
  79. }
  80. #endif /* CONFIG_PCI */
  81. /* Parse the ibm,dma-window property of an OF node into the busno, phys and
  82. * size parameters.
  83. */
  84. void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
  85. unsigned long *busno, unsigned long *phys, unsigned long *size);
  86. extern void kdump_move_device_tree(void);
  87. /* CPU OF node matching */
  88. struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
  89. /* cache lookup */
  90. struct device_node *of_find_next_cache_node(struct device_node *np);
  91. /* Get the MAC address */
  92. extern const void *of_get_mac_address(struct device_node *np);
  93. /*
  94. * OF interrupt mapping
  95. */
  96. /* This structure is returned when an interrupt is mapped. The controller
  97. * field needs to be put() after use
  98. */
  99. #define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */
  100. struct of_irq {
  101. struct device_node *controller; /* Interrupt controller node */
  102. u32 size; /* Specifier size */
  103. u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
  104. };
  105. /**
  106. * of_irq_map_init - Initialize the irq remapper
  107. * @flags: flags defining workarounds to enable
  108. *
  109. * Some machines have bugs in the device-tree which require certain workarounds
  110. * to be applied. Call this before any interrupt mapping attempts to enable
  111. * those workarounds.
  112. */
  113. #define OF_IMAP_OLDWORLD_MAC 0x00000001
  114. #define OF_IMAP_NO_PHANDLE 0x00000002
  115. extern void of_irq_map_init(unsigned int flags);
  116. /**
  117. * of_irq_map_raw - Low level interrupt tree parsing
  118. * @parent: the device interrupt parent
  119. * @intspec: interrupt specifier ("interrupts" property of the device)
  120. * @ointsize: size of the passed in interrupt specifier
  121. * @addr: address specifier (start of "reg" property of the device)
  122. * @out_irq: structure of_irq filled by this function
  123. *
  124. * Returns 0 on success and a negative number on error
  125. *
  126. * This function is a low-level interrupt tree walking function. It
  127. * can be used to do a partial walk with synthetized reg and interrupts
  128. * properties, for example when resolving PCI interrupts when no device
  129. * node exist for the parent.
  130. *
  131. */
  132. extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec,
  133. u32 ointsize, const u32 *addr,
  134. struct of_irq *out_irq);
  135. /**
  136. * of_irq_map_one - Resolve an interrupt for a device
  137. * @device: the device whose interrupt is to be resolved
  138. * @index: index of the interrupt to resolve
  139. * @out_irq: structure of_irq filled by this function
  140. *
  141. * This function resolves an interrupt, walking the tree, for a given
  142. * device-tree node. It's the high level pendant to of_irq_map_raw().
  143. * It also implements the workarounds for OldWolrd Macs.
  144. */
  145. extern int of_irq_map_one(struct device_node *device, int index,
  146. struct of_irq *out_irq);
  147. /**
  148. * of_irq_map_pci - Resolve the interrupt for a PCI device
  149. * @pdev: the device whose interrupt is to be resolved
  150. * @out_irq: structure of_irq filled by this function
  151. *
  152. * This function resolves the PCI interrupt for a given PCI device. If a
  153. * device-node exists for a given pci_dev, it will use normal OF tree
  154. * walking. If not, it will implement standard swizzling and walk up the
  155. * PCI tree until an device-node is found, at which point it will finish
  156. * resolving using the OF tree walking.
  157. */
  158. struct pci_dev;
  159. extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
  160. extern int of_irq_to_resource(struct device_node *dev, int index,
  161. struct resource *r);
  162. /**
  163. * of_iomap - Maps the memory mapped IO for a given device_node
  164. * @device: the device whose io range will be mapped
  165. * @index: index of the io range
  166. *
  167. * Returns a pointer to the mapped memory
  168. */
  169. extern void __iomem *of_iomap(struct device_node *device, int index);
  170. #endif /* __KERNEL__ */
  171. #endif /* _POWERPC_PROM_H */