* Memory binding

The /memory node provides basic information about the address and size
of the physical memory. This node is usually filled or updated by the
bootloader, depending on the actual memory configuration of the given
hardware.

The memory layout is described by the folllowing node:

memory {
	reg =  <(baseaddr1) (size1)
		(baseaddr2) (size2)
		...
		(baseaddrN) (sizeN)>;
};

baseaddrX:	the base address of the defined memory bank
sizeX:		the size of the defined memory bank

More than one memory bank can be defined.


* Memory regions

In /memory node one can create additional nodes describing particular
memory regions, usually for the special usage by various device drivers.
A good example are contiguous memory allocations or memory sharing with
other operating system on the same hardware board. Those special memory
regions might depend on the board configuration and devices used on the
target system.

Parameters for each memory region can be encoded into the device tree
with the following convention:

(name): region@(base-address) {
	reg = <(baseaddr) (size)>;
	(linux,reserve-contiguous-region);
	(linux,default-contiguous-region);
	(linux,reserve-region);
	(linux,fixup-reserve-region);
	(linux,memory-limit);
	(linux,remove-completely);
        label = (unique_name);
};

name:		an name given to the defined region.
base-address:	the base address of the defined region.
size:		the size of the memory region.
linux,reserve-contiguous-region: property indicating that the defined memory
		region is used for contiguous memory allocations,
		Linux specific (optional)
linux,default-contiguous-region: property indicating that the region
		is the default region for all contiguous memory
		allocations, Linux specific (optional)
linux,reserve-region: property indicating that the contiguous memory will
		not be given back to the system allocator. The memory be
		always be available for contiguous use.
linux,fixup-reserve-region: optional property that goes along with
		"linux,reserve-region", which shrinks and fits the
		corresponding cma region to the max pfn allocated on the very
		first allocation attempt. One would like to use this property
		where he is not sure about how much cma region size must be
		reserved, so he gives it a max size which then is shrink once
		(first) allocation is done. The remaining pages are returned
		back to the system. Please note that this feature requires the
		base and size to be SECTION_SIZE aligned which is 2 MB for both
		aarch32 and aarch64. If the alignment need fails then we simply
		fallback to linux,remove-completely. Linux specific (optional)
linux,memory-limit: property specifying an upper bound on the physical address
		of the region if the region is placed dynamically. If no limit
		is specificed, the region may be placed anywhere in the physical
		address space. 0 may be used to specify lowmem (i.e. the region
		will be placed in the direct mapped lowmem region)
linux,remove-completely: property indicating the memory will be removed from the
		linux page allocator completely. This means that page structures
		associated with the memory will not be valid. This binding is
		expected to be used in conjunction with linux,reserve-region.
label:		an internal name used for automatically associating the
		cma region with a given device. The label is optional;
		if the label is not given the client is responsible for
		calling the appropriate functions to associate the region
		with a device.

* Device nodes

Once the regions in the /memory node are defined, they can be assigned
to device some device nodes for their special use. The following
properties are defined:

linux,contiguous-region = <&phandle>;
	This property indicates that the device driver should use the
	memory region pointed by the given phandle.


* Example:

This example defines a memory consisting of 4 memory banks. 2 contiguous
regions are defined for Linux kernel, one default of all device drivers
(named contig_mem, placed at 0x72000000, 64MiB) and one dedicated to the
framebuffer device (named display_mem, placed at 0x78000000, 16MiB). The
display_mem region is then assigned to fb@12300000 device for contiguous
memory allocation with Linux kernel drivers.

The reason for creating a separate region for framebuffer device is to
match the framebuffer address of from configuration done by bootloader,
so once Linux kernel drivers starts, no glitches on the displayed boot
logo appears.

/ {
	/* ... */
	memory {
		reg =  <0x40000000 0x10000000
			0x50000000 0x10000000
			0x60000000 0x10000000
			0x70000000 0x10000000>;

		contig_mem: region@72000000 {
			linux,reserve-contiguous-region;
			linux,default-contiguous-region;
			reg = <0x72000000 0x4000000>;
		};

		display_mem: region@78000000 {
			linux,reserve-contiguous-region;
			reg = <0x78000000 0x1000000>;
		};
	};

	fb@12300000 {
		linux,contiguous-region = <&display_mem>;
		status = "okay";
	};
};
