fdtaddr.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (c) 2017 Google, Inc
  3. *
  4. * (C) Copyright 2012
  5. * Pavel Herrmann <morpheus.ibis@gmail.com>
  6. * Marek Vasut <marex@denx.de>
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #ifndef _DM_ADDR_H
  11. #define _DM_ADDR_H
  12. #include <fdtdec.h>
  13. struct udevice;
  14. /**
  15. * dev_get_addr() - Get the reg property of a device
  16. *
  17. * @dev: Pointer to a device
  18. *
  19. * @return addr
  20. */
  21. fdt_addr_t dev_get_addr(struct udevice *dev);
  22. /**
  23. * dev_get_addr_ptr() - Return pointer to the address of the reg property
  24. * of a device
  25. *
  26. * @dev: Pointer to a device
  27. *
  28. * @return Pointer to addr, or NULL if there is no such property
  29. */
  30. void *dev_get_addr_ptr(struct udevice *dev);
  31. /**
  32. * dev_map_physmem() - Read device address from reg property of the
  33. * device node and map the address into CPU address
  34. * space.
  35. *
  36. * @dev: Pointer to device
  37. * @size: size of the memory to map
  38. *
  39. * @return mapped address, or NULL if the device does not have reg
  40. * property.
  41. */
  42. void *dev_map_physmem(struct udevice *dev, unsigned long size);
  43. /**
  44. * dev_get_addr_index() - Get the indexed reg property of a device
  45. *
  46. * @dev: Pointer to a device
  47. * @index: the 'reg' property can hold a list of <addr, size> pairs
  48. * and @index is used to select which one is required
  49. *
  50. * @return addr
  51. */
  52. fdt_addr_t dev_get_addr_index(struct udevice *dev, int index);
  53. /**
  54. * dev_get_addr_size_index() - Get the indexed reg property of a device
  55. *
  56. * Returns the address and size specified in the 'reg' property of a device.
  57. *
  58. * @dev: Pointer to a device
  59. * @index: the 'reg' property can hold a list of <addr, size> pairs
  60. * and @index is used to select which one is required
  61. * @size: Pointer to size varible - this function returns the size
  62. * specified in the 'reg' property here
  63. *
  64. * @return addr
  65. */
  66. fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
  67. fdt_size_t *size);
  68. /**
  69. * dev_get_addr_name() - Get the reg property of a device, indexed by name
  70. *
  71. * @dev: Pointer to a device
  72. * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
  73. * 'reg-names' property providing named-based identification. @index
  74. * indicates the value to search for in 'reg-names'.
  75. *
  76. * @return addr
  77. */
  78. fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name);
  79. /**
  80. * dm_set_translation_offset() - Set translation offset
  81. * @offs: Translation offset
  82. *
  83. * Some platforms need a special address translation. Those
  84. * platforms (e.g. mvebu in SPL) can configure a translation
  85. * offset in the DM by calling this function. It will be
  86. * added to all addresses returned in dev_get_addr().
  87. */
  88. void dm_set_translation_offset(fdt_addr_t offs);
  89. /**
  90. * dm_get_translation_offset() - Get translation offset
  91. *
  92. * This function returns the translation offset that can
  93. * be configured by calling dm_set_translation_offset().
  94. *
  95. * @return translation offset for the device address (0 as default).
  96. */
  97. fdt_addr_t dm_get_translation_offset(void);
  98. #endif