prom.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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_irq_map_pci - Resolve the interrupt for a PCI device
  96. * @pdev: the device whose interrupt is to be resolved
  97. * @out_irq: structure of_irq filled by this function
  98. *
  99. * This function resolves the PCI interrupt for a given PCI device. If a
  100. * device-node exists for a given pci_dev, it will use normal OF tree
  101. * walking. If not, it will implement standard swizzling and walk up the
  102. * PCI tree until an device-node is found, at which point it will finish
  103. * resolving using the OF tree walking.
  104. */
  105. struct pci_dev;
  106. extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
  107. /**
  108. * of_iomap - Maps the memory mapped IO for a given device_node
  109. * @device: the device whose io range will be mapped
  110. * @index: index of the io range
  111. *
  112. * Returns a pointer to the mapped memory
  113. */
  114. extern void __iomem *of_iomap(struct device_node *device, int index);
  115. #endif /* __KERNEL__ */
  116. #endif /* _POWERPC_PROM_H */