of_address.h 2.2 KB

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