of_address.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef __OF_ADDRESS_H
  2. #define __OF_ADDRESS_H
  3. #include <linux/ioport.h>
  4. #include <linux/errno.h>
  5. #include <linux/of.h>
  6. #ifdef CONFIG_OF_ADDRESS
  7. extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
  8. extern bool of_can_translate_address(struct device_node *dev);
  9. extern int of_address_to_resource(struct device_node *dev, int index,
  10. struct resource *r);
  11. extern struct device_node *of_find_matching_node_by_address(
  12. struct device_node *from,
  13. const struct of_device_id *matches,
  14. u64 base_address);
  15. extern void __iomem *of_iomap(struct device_node *device, int index);
  16. /* Extract an address from a device, returns the region size and
  17. * the address space flags too. The PCI version uses a BAR number
  18. * instead of an absolute index
  19. */
  20. extern const __be32 *of_get_address(struct device_node *dev, int index,
  21. u64 *size, unsigned int *flags);
  22. #ifndef pci_address_to_pio
  23. static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
  24. #define pci_address_to_pio pci_address_to_pio
  25. #endif
  26. #else /* CONFIG_OF_ADDRESS */
  27. #ifndef of_address_to_resource
  28. static inline int of_address_to_resource(struct device_node *dev, int index,
  29. struct resource *r)
  30. {
  31. return -EINVAL;
  32. }
  33. #endif
  34. static inline struct device_node *of_find_matching_node_by_address(
  35. struct device_node *from,
  36. const struct of_device_id *matches,
  37. u64 base_address)
  38. {
  39. return NULL;
  40. }
  41. #ifndef of_iomap
  42. static inline void __iomem *of_iomap(struct device_node *device, int index)
  43. {
  44. return NULL;
  45. }
  46. #endif
  47. static inline const __be32 *of_get_address(struct device_node *dev, int index,
  48. u64 *size, unsigned int *flags)
  49. {
  50. return NULL;
  51. }
  52. #endif /* CONFIG_OF_ADDRESS */
  53. #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
  54. extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
  55. u64 *size, unsigned int *flags);
  56. extern int of_pci_address_to_resource(struct device_node *dev, int bar,
  57. struct resource *r);
  58. #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
  59. static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
  60. struct resource *r)
  61. {
  62. return -ENOSYS;
  63. }
  64. static inline const __be32 *of_get_pci_address(struct device_node *dev,
  65. int bar_no, u64 *size, unsigned int *flags)
  66. {
  67. return NULL;
  68. }
  69. #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
  70. #endif /* __OF_ADDRESS_H */