fdtaddr.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2017 Google, Inc
  4. *
  5. * (C) Copyright 2012
  6. * Pavel Herrmann <morpheus.ibis@gmail.com>
  7. * Marek Vasut <marex@denx.de>
  8. */
  9. #ifndef _DM_FDTADDR_H
  10. #define _DM_FDTADDR_H
  11. #include <fdtdec.h>
  12. struct udevice;
  13. /**
  14. * devfdt_get_addr() - Get the reg property of a device
  15. *
  16. * @dev: Pointer to a device
  17. *
  18. * @return addr
  19. */
  20. fdt_addr_t devfdt_get_addr(const struct udevice *dev);
  21. /**
  22. * devfdt_get_addr_ptr() - Return pointer to the address of the reg property
  23. * of a device
  24. *
  25. * @dev: Pointer to a device
  26. *
  27. * @return Pointer to addr, or NULL if there is no such property
  28. */
  29. void *devfdt_get_addr_ptr(const struct udevice *dev);
  30. /**
  31. * devfdt_remap_addr() - Return pointer to the memory-mapped I/O address
  32. * of the reg property of a device
  33. *
  34. * @dev: Pointer to a device
  35. *
  36. * @return Pointer to addr, or NULL if there is no such property
  37. */
  38. void *devfdt_remap_addr(const struct udevice *dev);
  39. /**
  40. * devfdt_remap_addr_index() - Return indexed pointer to the memory-mapped
  41. * I/O address of the reg property of a device
  42. * @index: the 'reg' property can hold a list of <addr, size> pairs
  43. * and @index is used to select which one is required
  44. *
  45. * @dev: Pointer to a device
  46. *
  47. * @return Pointer to addr, or NULL if there is no such property
  48. */
  49. void *devfdt_remap_addr_index(const struct udevice *dev, int index);
  50. /**
  51. * devfdt_remap_addr_name() - Get the reg property of a device, indexed by
  52. * name, as a memory-mapped I/O pointer
  53. * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
  54. * 'reg-names' property providing named-based identification. @index
  55. * indicates the value to search for in 'reg-names'.
  56. *
  57. * @dev: Pointer to a device
  58. *
  59. * @return Pointer to addr, or NULL if there is no such property
  60. */
  61. void *devfdt_remap_addr_name(const struct udevice *dev, const char *name);
  62. /**
  63. * devfdt_map_physmem() - Read device address from reg property of the
  64. * device node and map the address into CPU address
  65. * space.
  66. *
  67. * @dev: Pointer to device
  68. * @size: size of the memory to map
  69. *
  70. * @return mapped address, or NULL if the device does not have reg
  71. * property.
  72. */
  73. void *devfdt_map_physmem(const struct udevice *dev, unsigned long size);
  74. /**
  75. * devfdt_get_addr_index() - Get the indexed reg property of a device
  76. *
  77. * @dev: Pointer to a device
  78. * @index: the 'reg' property can hold a list of <addr, size> pairs
  79. * and @index is used to select which one is required
  80. *
  81. * @return addr
  82. */
  83. fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index);
  84. /**
  85. * devfdt_get_addr_size_index() - Get the indexed reg property of a device
  86. *
  87. * Returns the address and size specified in the 'reg' property of a device.
  88. *
  89. * @dev: Pointer to a device
  90. * @index: the 'reg' property can hold a list of <addr, size> pairs
  91. * and @index is used to select which one is required
  92. * @size: Pointer to size varible - this function returns the size
  93. * specified in the 'reg' property here
  94. *
  95. * @return addr
  96. */
  97. fdt_addr_t devfdt_get_addr_size_index(const struct udevice *dev, int index,
  98. fdt_size_t *size);
  99. /**
  100. * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
  101. *
  102. * @dev: Pointer to a device
  103. * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
  104. * 'reg-names' property providing named-based identification. @index
  105. * indicates the value to search for in 'reg-names'.
  106. *
  107. * @return addr
  108. */
  109. fdt_addr_t devfdt_get_addr_name(const struct udevice *dev, const char *name);
  110. /**
  111. * devfdt_get_addr_size_name() - Get the reg property and its size for a device,
  112. * indexed by name
  113. *
  114. * Returns the address and size specified in the 'reg' property of a device.
  115. *
  116. * @dev: Pointer to a device
  117. * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
  118. * 'reg-names' property providing named-based identification. @index
  119. * indicates the value to search for in 'reg-names'.
  120. * @size: Pointer to size variable - this function returns the size
  121. * specified in the 'reg' property here
  122. *
  123. * @return addr
  124. */
  125. fdt_addr_t devfdt_get_addr_size_name(const struct udevice *dev,
  126. const char *name, fdt_size_t *size);
  127. /**
  128. * devfdt_get_addr_pci() - Read an address and handle PCI address translation
  129. *
  130. * @dev: Device to read from
  131. * @return address or FDT_ADDR_T_NONE if not found
  132. */
  133. fdt_addr_t devfdt_get_addr_pci(const struct udevice *dev);
  134. #endif