memory.txt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. *** Memory binding ***
  2. The /memory node provides basic information about the address and size
  3. of the physical memory. This node is usually filled or updated by the
  4. bootloader, depending on the actual memory configuration of the given
  5. hardware.
  6. The memory layout is described by the following node:
  7. / {
  8. #address-cells = <(n)>;
  9. #size-cells = <(m)>;
  10. memory {
  11. device_type = "memory";
  12. reg = <(baseaddr1) (size1)
  13. (baseaddr2) (size2)
  14. ...
  15. (baseaddrN) (sizeN)>;
  16. };
  17. ...
  18. };
  19. A memory node follows the typical device tree rules for "reg" property:
  20. n: number of cells used to store base address value
  21. m: number of cells used to store size value
  22. baseaddrX: defines a base address of the defined memory bank
  23. sizeX: the size of the defined memory bank
  24. More than one memory bank can be defined.
  25. *** Reserved memory regions ***
  26. In /memory/reserved-memory node one can create child nodes describing
  27. particular reserved (excluded from normal use) memory regions. Such
  28. memory regions are usually designed for the special usage by various
  29. device drivers. A good example are contiguous memory allocations or
  30. memory sharing with other operating system on the same hardware board.
  31. Those special memory regions might depend on the board configuration and
  32. devices used on the target system.
  33. Parameters for each memory region can be encoded into the device tree
  34. with the following convention:
  35. [(label):] (name) {
  36. compatible = "linux,contiguous-memory-region", "reserved-memory-region";
  37. reg = <(address) (size)>;
  38. (linux,default-contiguous-region);
  39. };
  40. compatible: one or more of:
  41. - "linux,contiguous-memory-region" - enables binding of this
  42. region to Contiguous Memory Allocator (special region for
  43. contiguous memory allocations, shared with movable system
  44. memory, Linux kernel-specific).
  45. - "reserved-memory-region" - compatibility is defined, given
  46. region is assigned for exclusive usage for by the respective
  47. devices.
  48. reg: standard property defining the base address and size of
  49. the memory region
  50. linux,default-contiguous-region: property indicating that the region
  51. is the default region for all contiguous memory
  52. allocations, Linux specific (optional)
  53. It is optional to specify the base address, so if one wants to use
  54. autoconfiguration of the base address, '0' can be specified as a base
  55. address in the 'reg' property.
  56. The /memory/reserved-memory node must contain the same #address-cells
  57. and #size-cells value as the root node.
  58. *** Device node's properties ***
  59. Once regions in the /memory/reserved-memory node have been defined, they
  60. may be referenced by other device nodes. Bindings that wish to reference
  61. memory regions should explicitly document their use of the following
  62. property:
  63. memory-region = <&phandle_to_defined_region>;
  64. This property indicates that the device driver should use the memory
  65. region pointed by the given phandle.
  66. *** Example ***
  67. This example defines a memory consisting of 4 memory banks. 3 contiguous
  68. regions are defined for Linux kernel, one default of all device drivers
  69. (named contig_mem, placed at 0x72000000, 64MiB), one dedicated to the
  70. framebuffer device (labelled display_mem, placed at 0x78000000, 8MiB)
  71. and one for multimedia processing (labelled multimedia_mem, placed at
  72. 0x77000000, 64MiB). 'display_mem' region is then assigned to fb@12300000
  73. device for DMA memory allocations (Linux kernel drivers will use CMA is
  74. available or dma-exclusive usage otherwise). 'multimedia_mem' is
  75. assigned to scaler@12500000 and codec@12600000 devices for contiguous
  76. memory allocations when CMA driver is enabled.
  77. The reason for creating a separate region for framebuffer device is to
  78. match the framebuffer base address to the one configured by bootloader,
  79. so once Linux kernel drivers starts no glitches on the displayed boot
  80. logo appears. Scaller and codec drivers should share the memory
  81. allocations.
  82. / {
  83. #address-cells = <1>;
  84. #size-cells = <1>;
  85. /* ... */
  86. memory {
  87. reg = <0x40000000 0x10000000
  88. 0x50000000 0x10000000
  89. 0x60000000 0x10000000
  90. 0x70000000 0x10000000>;
  91. reserved-memory {
  92. #address-cells = <1>;
  93. #size-cells = <1>;
  94. /*
  95. * global autoconfigured region for contiguous allocations
  96. * (used only with Contiguous Memory Allocator)
  97. */
  98. contig_region@0 {
  99. compatible = "linux,contiguous-memory-region";
  100. reg = <0x0 0x4000000>;
  101. linux,default-contiguous-region;
  102. };
  103. /*
  104. * special region for framebuffer
  105. */
  106. display_region: region@78000000 {
  107. compatible = "linux,contiguous-memory-region", "reserved-memory-region";
  108. reg = <0x78000000 0x800000>;
  109. };
  110. /*
  111. * special region for multimedia processing devices
  112. */
  113. multimedia_region: region@77000000 {
  114. compatible = "linux,contiguous-memory-region";
  115. reg = <0x77000000 0x4000000>;
  116. };
  117. };
  118. };
  119. /* ... */
  120. fb0: fb@12300000 {
  121. status = "okay";
  122. memory-region = <&display_region>;
  123. };
  124. scaler: scaler@12500000 {
  125. status = "okay";
  126. memory-region = <&multimedia_region>;
  127. };
  128. codec: codec@12600000 {
  129. status = "okay";
  130. memory-region = <&multimedia_region>;
  131. };
  132. };