of_address.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 u32 *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. static inline int of_address_to_resource(struct device_node *dev, int index,
  28. struct resource *r)
  29. {
  30. return -EINVAL;
  31. }
  32. static inline struct device_node *of_find_matching_node_by_address(
  33. struct device_node *from,
  34. const struct of_device_id *matches,
  35. u64 base_address)
  36. {
  37. return NULL;
  38. }
  39. static inline void __iomem *of_iomap(struct device_node *device, int index)
  40. {
  41. return NULL;
  42. }
  43. static inline const u32 *of_get_address(struct device_node *dev, int index,
  44. u64 *size, unsigned int *flags)
  45. {
  46. return NULL;
  47. }
  48. #endif /* CONFIG_OF_ADDRESS */
  49. #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
  50. extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
  51. u64 *size, unsigned int *flags);
  52. extern int of_pci_address_to_resource(struct device_node *dev, int bar,
  53. struct resource *r);
  54. #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
  55. static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
  56. struct resource *r)
  57. {
  58. return -ENOSYS;
  59. }
  60. static inline const __be32 *of_get_pci_address(struct device_node *dev,
  61. int bar_no, u64 *size, unsigned int *flags)
  62. {
  63. return NULL;
  64. }
  65. #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
  66. #endif /* __OF_ADDRESS_H */