prom.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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_address.h>
  21. #include <linux/of_irq.h>
  22. #include <linux/proc_fs.h>
  23. #include <linux/platform_device.h>
  24. #include <asm/irq.h>
  25. #include <asm/atomic.h>
  26. #define HAVE_ARCH_DEVTREE_FIXUPS
  27. #ifdef CONFIG_PPC32
  28. /*
  29. * PCI <-> OF matching functions
  30. * (XXX should these be here?)
  31. */
  32. struct pci_bus;
  33. struct pci_dev;
  34. extern int pci_device_from_OF_node(struct device_node *node,
  35. u8* bus, u8* devfn);
  36. extern struct device_node* pci_busdev_to_OF_node(struct pci_bus *, int);
  37. extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
  38. extern void pci_create_OF_bus_map(void);
  39. #endif
  40. /*
  41. * OF address retreival & translation
  42. */
  43. /* Translate a DMA address from device space to CPU space */
  44. extern u64 of_translate_dma_address(struct device_node *dev,
  45. const u32 *in_addr);
  46. /* Extract an address from a device, returns the region size and
  47. * the address space flags too. The PCI version uses a BAR number
  48. * instead of an absolute index
  49. */
  50. extern const u32 *of_get_address(struct device_node *dev, int index,
  51. u64 *size, unsigned int *flags);
  52. #ifdef CONFIG_PCI
  53. extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
  54. u64 *size, unsigned int *flags);
  55. #else
  56. static inline const u32 *of_get_pci_address(struct device_node *dev,
  57. int bar_no, u64 *size, unsigned int *flags)
  58. {
  59. return NULL;
  60. }
  61. #endif /* CONFIG_PCI */
  62. #ifdef CONFIG_PCI
  63. extern int of_pci_address_to_resource(struct device_node *dev, int bar,
  64. struct resource *r);
  65. #else
  66. static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
  67. struct resource *r)
  68. {
  69. return -ENOSYS;
  70. }
  71. #endif /* CONFIG_PCI */
  72. #ifdef CONFIG_PCI
  73. extern unsigned long pci_address_to_pio(phys_addr_t address);
  74. #else
  75. static inline unsigned long pci_address_to_pio(phys_addr_t address)
  76. {
  77. return (unsigned long)-1;
  78. }
  79. #endif /* CONFIG_PCI */
  80. /* Parse the ibm,dma-window property of an OF node into the busno, phys and
  81. * size parameters.
  82. */
  83. void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
  84. unsigned long *busno, unsigned long *phys, unsigned long *size);
  85. extern void kdump_move_device_tree(void);
  86. /* CPU OF node matching */
  87. struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
  88. /* cache lookup */
  89. struct device_node *of_find_next_cache_node(struct device_node *np);
  90. /* Get the MAC address */
  91. extern const void *of_get_mac_address(struct device_node *np);
  92. /**
  93. * of_irq_map_pci - Resolve the interrupt for a PCI device
  94. * @pdev: the device whose interrupt is to be resolved
  95. * @out_irq: structure of_irq filled by this function
  96. *
  97. * This function resolves the PCI interrupt for a given PCI device. If a
  98. * device-node exists for a given pci_dev, it will use normal OF tree
  99. * walking. If not, it will implement standard swizzling and walk up the
  100. * PCI tree until an device-node is found, at which point it will finish
  101. * resolving using the OF tree walking.
  102. */
  103. struct pci_dev;
  104. extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
  105. #endif /* __KERNEL__ */
  106. #endif /* _POWERPC_PROM_H */