162306a36Sopenharmony_ci# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
262306a36Sopenharmony_ci%YAML 1.2
362306a36Sopenharmony_ci---
462306a36Sopenharmony_ci$id: http://devicetree.org/schemas/reserved-memory/reserved-memory.yaml#
562306a36Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/core.yaml#
662306a36Sopenharmony_ci
762306a36Sopenharmony_cititle: /reserved-memory Child Node Common
862306a36Sopenharmony_ci
962306a36Sopenharmony_cimaintainers:
1062306a36Sopenharmony_ci  - devicetree-spec@vger.kernel.org
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cidescription: >
1362306a36Sopenharmony_ci  Reserved memory is specified as a node under the /reserved-memory node. The
1462306a36Sopenharmony_ci  operating system shall exclude reserved memory from normal usage one can
1562306a36Sopenharmony_ci  create child nodes describing particular reserved (excluded from normal use)
1662306a36Sopenharmony_ci  memory regions. Such memory regions are usually designed for the special
1762306a36Sopenharmony_ci  usage by various device drivers.
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci  Each child of the reserved-memory node specifies one or more regions
2062306a36Sopenharmony_ci  of reserved memory. Each child node may either use a 'reg' property to
2162306a36Sopenharmony_ci  specify a specific range of reserved memory, or a 'size' property with
2262306a36Sopenharmony_ci  optional constraints to request a dynamically allocated block of
2362306a36Sopenharmony_ci  memory.
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci  Following the generic-names recommended practice, node names should
2662306a36Sopenharmony_ci  reflect the purpose of the node (ie. "framebuffer" or "dma-pool").
2762306a36Sopenharmony_ci  Unit address (@<address>) should be appended to the name if the node
2862306a36Sopenharmony_ci  is a static allocation.
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ciproperties:
3162306a36Sopenharmony_ci  reg: true
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci  size:
3462306a36Sopenharmony_ci    oneOf:
3562306a36Sopenharmony_ci      - $ref: /schemas/types.yaml#/definitions/uint32
3662306a36Sopenharmony_ci      - $ref: /schemas/types.yaml#/definitions/uint64
3762306a36Sopenharmony_ci    description: >
3862306a36Sopenharmony_ci      Length based on parent's \#size-cells. Size in bytes of memory to
3962306a36Sopenharmony_ci      reserve.
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci  alignment:
4262306a36Sopenharmony_ci    oneOf:
4362306a36Sopenharmony_ci      - $ref: /schemas/types.yaml#/definitions/uint32
4462306a36Sopenharmony_ci      - $ref: /schemas/types.yaml#/definitions/uint64
4562306a36Sopenharmony_ci    description: >
4662306a36Sopenharmony_ci      Length based on parent's \#size-cells. Address boundary for
4762306a36Sopenharmony_ci      alignment of allocation.
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci  alloc-ranges:
5062306a36Sopenharmony_ci    $ref: /schemas/types.yaml#/definitions/uint32-array
5162306a36Sopenharmony_ci    description: >
5262306a36Sopenharmony_ci      Address and Length pairs. Specifies regions of memory that are
5362306a36Sopenharmony_ci      acceptable to allocate from.
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci  iommu-addresses:
5662306a36Sopenharmony_ci    $ref: /schemas/types.yaml#/definitions/phandle-array
5762306a36Sopenharmony_ci    description: >
5862306a36Sopenharmony_ci      A list of phandle and specifier pairs that describe static IO virtual
5962306a36Sopenharmony_ci      address space mappings and carveouts associated with a given reserved
6062306a36Sopenharmony_ci      memory region. The phandle in the first cell refers to the device for
6162306a36Sopenharmony_ci      which the mapping or carveout is to be created.
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci      The specifier consists of an address/size pair and denotes the IO
6462306a36Sopenharmony_ci      virtual address range of the region for the given device. The exact
6562306a36Sopenharmony_ci      format depends on the values of the "#address-cells" and "#size-cells"
6662306a36Sopenharmony_ci      properties of the device referenced via the phandle.
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci      When used in combination with a "reg" property, an IOVA mapping is to
6962306a36Sopenharmony_ci      be established for this memory region. One example where this can be
7062306a36Sopenharmony_ci      useful is to create an identity mapping for physical memory that the
7162306a36Sopenharmony_ci      firmware has configured some hardware to access (such as a bootsplash
7262306a36Sopenharmony_ci      framebuffer).
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci      If no "reg" property is specified, the "iommu-addresses" property
7562306a36Sopenharmony_ci      defines carveout regions in the IOVA space for the given device. This
7662306a36Sopenharmony_ci      can be useful if a certain memory region should not be mapped through
7762306a36Sopenharmony_ci      the IOMMU.
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci  no-map:
8062306a36Sopenharmony_ci    type: boolean
8162306a36Sopenharmony_ci    description: >
8262306a36Sopenharmony_ci      Indicates the operating system must not create a virtual mapping
8362306a36Sopenharmony_ci      of the region as part of its standard mapping of system memory,
8462306a36Sopenharmony_ci      nor permit speculative access to it under any circumstances other
8562306a36Sopenharmony_ci      than under the control of the device driver using the region.
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci  reusable:
8862306a36Sopenharmony_ci    type: boolean
8962306a36Sopenharmony_ci    description: >
9062306a36Sopenharmony_ci      The operating system can use the memory in this region with the
9162306a36Sopenharmony_ci      limitation that the device driver(s) owning the region need to be
9262306a36Sopenharmony_ci      able to reclaim it back. Typically that means that the operating
9362306a36Sopenharmony_ci      system can use that region to store volatile or cached data that
9462306a36Sopenharmony_ci      can be otherwise regenerated or migrated elsewhere.
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ciallOf:
9762306a36Sopenharmony_ci  - if:
9862306a36Sopenharmony_ci      required:
9962306a36Sopenharmony_ci        - no-map
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci    then:
10262306a36Sopenharmony_ci      not:
10362306a36Sopenharmony_ci        required:
10462306a36Sopenharmony_ci          - reusable
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci  - if:
10762306a36Sopenharmony_ci      required:
10862306a36Sopenharmony_ci        - reusable
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci    then:
11162306a36Sopenharmony_ci      not:
11262306a36Sopenharmony_ci        required:
11362306a36Sopenharmony_ci          - no-map
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_cioneOf:
11662306a36Sopenharmony_ci  - oneOf:
11762306a36Sopenharmony_ci      - required:
11862306a36Sopenharmony_ci          - reg
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci      - required:
12162306a36Sopenharmony_ci          - size
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci  - oneOf:
12462306a36Sopenharmony_ci      # IOMMU reservations
12562306a36Sopenharmony_ci      - required:
12662306a36Sopenharmony_ci          - iommu-addresses
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci      # IOMMU mappings
12962306a36Sopenharmony_ci      - required:
13062306a36Sopenharmony_ci          - reg
13162306a36Sopenharmony_ci          - iommu-addresses
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ciadditionalProperties: true
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ciexamples:
13662306a36Sopenharmony_ci  - |
13762306a36Sopenharmony_ci    / {
13862306a36Sopenharmony_ci      compatible = "foo";
13962306a36Sopenharmony_ci      model = "foo";
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci      #address-cells = <2>;
14262306a36Sopenharmony_ci      #size-cells = <2>;
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci      reserved-memory {
14562306a36Sopenharmony_ci        #address-cells = <2>;
14662306a36Sopenharmony_ci        #size-cells = <2>;
14762306a36Sopenharmony_ci        ranges;
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci        adsp_resv: reservation-adsp {
15062306a36Sopenharmony_ci          /*
15162306a36Sopenharmony_ci           * Restrict IOVA mappings for ADSP buffers to the 512 MiB region
15262306a36Sopenharmony_ci           * from 0x40000000 - 0x5fffffff. Anything outside is reserved by
15362306a36Sopenharmony_ci           * the ADSP for I/O memory and private memory allocations.
15462306a36Sopenharmony_ci           */
15562306a36Sopenharmony_ci          iommu-addresses = <&adsp 0x0 0x00000000 0x00 0x40000000>,
15662306a36Sopenharmony_ci                            <&adsp 0x0 0x60000000 0xff 0xa0000000>;
15762306a36Sopenharmony_ci        };
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci        fb: framebuffer@90000000 {
16062306a36Sopenharmony_ci          reg = <0x0 0x90000000 0x0 0x00800000>;
16162306a36Sopenharmony_ci          iommu-addresses = <&dc0 0x0 0x90000000 0x0 0x00800000>;
16262306a36Sopenharmony_ci        };
16362306a36Sopenharmony_ci      };
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci      bus@0 {
16662306a36Sopenharmony_ci        #address-cells = <1>;
16762306a36Sopenharmony_ci        #size-cells = <1>;
16862306a36Sopenharmony_ci        ranges = <0x0 0x0 0x0 0x40000000>;
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci        adsp: adsp@2990000 {
17162306a36Sopenharmony_ci          reg = <0x2990000 0x2000>;
17262306a36Sopenharmony_ci          memory-region = <&adsp_resv>;
17362306a36Sopenharmony_ci        };
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci        dc0: display@15200000 {
17662306a36Sopenharmony_ci          reg = <0x15200000 0x10000>;
17762306a36Sopenharmony_ci          memory-region = <&fb>;
17862306a36Sopenharmony_ci        };
17962306a36Sopenharmony_ci      };
18062306a36Sopenharmony_ci    };
18162306a36Sopenharmony_ci...
182