prom.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Definitions for talking to the Open Firmware PROM on
  3. * Power Macintosh computers.
  4. *
  5. * Copyright (C) 1996-2005 Paul Mackerras.
  6. *
  7. * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <linux/of.h> /* linux/of.h gets to determine #include ordering */
  15. #ifndef _ASM_MICROBLAZE_PROM_H
  16. #define _ASM_MICROBLAZE_PROM_H
  17. #ifdef __KERNEL__
  18. #ifndef __ASSEMBLY__
  19. #include <linux/types.h>
  20. #include <linux/of_fdt.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 OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
  26. #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
  27. #define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l))
  28. #define of_prop_cmp(s1, s2) strcmp((s1), (s2))
  29. #define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
  30. extern struct device_node *of_chosen;
  31. #define HAVE_ARCH_DEVTREE_FIXUPS
  32. extern rwlock_t devtree_lock; /* temporary while merging */
  33. /* Other Prototypes */
  34. extern int early_uartlite_console(void);
  35. extern struct resource *request_OF_resource(struct device_node *node,
  36. int index, const char *name_postfix);
  37. extern int release_OF_resource(struct device_node *node, int index);
  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. /* Extract an address from a device, returns the region size and
  45. * the address space flags too. The PCI version uses a BAR number
  46. * instead of an absolute index
  47. */
  48. extern const u32 *of_get_address(struct device_node *dev, int index,
  49. u64 *size, unsigned int *flags);
  50. extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
  51. u64 *size, unsigned int *flags);
  52. /* Get an address as a resource. Note that if your address is
  53. * a PIO address, the conversion will fail if the physical address
  54. * can't be internally converted to an IO token with
  55. * pci_address_to_pio(), that is because it's either called to early
  56. * or it can't be matched to any host bridge IO space
  57. */
  58. extern int of_address_to_resource(struct device_node *dev, int index,
  59. struct resource *r);
  60. extern int of_pci_address_to_resource(struct device_node *dev, int bar,
  61. struct resource *r);
  62. /* Parse the ibm,dma-window property of an OF node into the busno, phys and
  63. * size parameters.
  64. */
  65. void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
  66. unsigned long *busno, unsigned long *phys, unsigned long *size);
  67. extern void kdump_move_device_tree(void);
  68. /* CPU OF node matching */
  69. struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
  70. /* Get the MAC address */
  71. extern const void *of_get_mac_address(struct device_node *np);
  72. /*
  73. * OF interrupt mapping
  74. */
  75. /* This structure is returned when an interrupt is mapped. The controller
  76. * field needs to be put() after use
  77. */
  78. #define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */
  79. struct of_irq {
  80. struct device_node *controller; /* Interrupt controller node */
  81. u32 size; /* Specifier size */
  82. u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
  83. };
  84. /**
  85. * of_irq_map_init - Initialize the irq remapper
  86. * @flags: flags defining workarounds to enable
  87. *
  88. * Some machines have bugs in the device-tree which require certain workarounds
  89. * to be applied. Call this before any interrupt mapping attempts to enable
  90. * those workarounds.
  91. */
  92. #define OF_IMAP_OLDWORLD_MAC 0x00000001
  93. #define OF_IMAP_NO_PHANDLE 0x00000002
  94. extern void of_irq_map_init(unsigned int flags);
  95. /**
  96. * of_irq_map_raw - Low level interrupt tree parsing
  97. * @parent: the device interrupt parent
  98. * @intspec: interrupt specifier ("interrupts" property of the device)
  99. * @ointsize: size of the passed in interrupt specifier
  100. * @addr: address specifier (start of "reg" property of the device)
  101. * @out_irq: structure of_irq filled by this function
  102. *
  103. * Returns 0 on success and a negative number on error
  104. *
  105. * This function is a low-level interrupt tree walking function. It
  106. * can be used to do a partial walk with synthetized reg and interrupts
  107. * properties, for example when resolving PCI interrupts when no device
  108. * node exist for the parent.
  109. *
  110. */
  111. extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec,
  112. u32 ointsize, const u32 *addr,
  113. struct of_irq *out_irq);
  114. /**
  115. * of_irq_map_one - Resolve an interrupt for a device
  116. * @device: the device whose interrupt is to be resolved
  117. * @index: index of the interrupt to resolve
  118. * @out_irq: structure of_irq filled by this function
  119. *
  120. * This function resolves an interrupt, walking the tree, for a given
  121. * device-tree node. It's the high level pendant to of_irq_map_raw().
  122. * It also implements the workarounds for OldWolrd Macs.
  123. */
  124. extern int of_irq_map_one(struct device_node *device, int index,
  125. struct of_irq *out_irq);
  126. /**
  127. * of_irq_map_pci - Resolve the interrupt for a PCI device
  128. * @pdev: the device whose interrupt is to be resolved
  129. * @out_irq: structure of_irq filled by this function
  130. *
  131. * This function resolves the PCI interrupt for a given PCI device. If a
  132. * device-node exists for a given pci_dev, it will use normal OF tree
  133. * walking. If not, it will implement standard swizzling and walk up the
  134. * PCI tree until an device-node is found, at which point it will finish
  135. * resolving using the OF tree walking.
  136. */
  137. struct pci_dev;
  138. extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
  139. extern int of_irq_to_resource(struct device_node *dev, int index,
  140. struct resource *r);
  141. /**
  142. * of_iomap - Maps the memory mapped IO for a given device_node
  143. * @device: the device whose io range will be mapped
  144. * @index: index of the io range
  145. *
  146. * Returns a pointer to the mapped memory
  147. */
  148. extern void __iomem *of_iomap(struct device_node *device, int index);
  149. #endif /* __ASSEMBLY__ */
  150. #endif /* __KERNEL__ */
  151. #endif /* _ASM_MICROBLAZE_PROM_H */