of_address.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. static inline void __iomem *of_iomap(struct device_node *device, int index)
  42. {
  43. return NULL;
  44. }
  45. static inline const __be32 *of_get_address(struct device_node *dev, int index,
  46. u64 *size, unsigned int *flags)
  47. {
  48. return NULL;
  49. }
  50. #endif /* CONFIG_OF_ADDRESS */
  51. #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
  52. extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
  53. u64 *size, unsigned int *flags);
  54. extern int of_pci_address_to_resource(struct device_node *dev, int bar,
  55. struct resource *r);
  56. #else /* CONFIG_OF_ADDRESS && CONFIG_PCI */
  57. static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
  58. struct resource *r)
  59. {
  60. return -ENOSYS;
  61. }
  62. static inline const __be32 *of_get_pci_address(struct device_node *dev,
  63. int bar_no, u64 *size, unsigned int *flags)
  64. {
  65. return NULL;
  66. }
  67. #endif /* CONFIG_OF_ADDRESS && CONFIG_PCI */
  68. #endif /* __OF_ADDRESS_H */