# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: "http://devicetree.org/schemas/arm/msm/qcom_dma_heap.yaml#"
$schema: "http://devicetree.org/meta-schemas/core.yaml#"

title: DMA-BUF Heaps Memory Manager binding

maintainers:
  - Chris Goldsworthy

description: |
  DMA-BUF heaps is a memory manager that allows for sharing of buffers between
  different processes and between user space and kernel space. DMA-BUF heaps
  manages different memory spaces by separating the memory spaces into heaps.

  All child nodes of a qcom,dma-heaps node are interpreted as DMA-BUF heap
  configurations for CMA and secure carveout heaps.

properties:
  $nodename:
    const: qcom,dma-heaps
    description: Container of DMA-BUF heap nodes

  compatible:
    const: qcom,dma-heaps

patternProperties:
  '^qcom,[a-zA-Z]+$':
    type: object
    properties:
      qcom,dma-heap-name:
        $ref: '/schemas/types.yaml#/definitions/string'
        maxItems: 1
        description: The name given to this heap.

      qcom,dma-heap-type:
        $ref: '/schemas/types.yaml#/definitions/uint32'
        enum:
          - HEAP_TYPE_SECURE_CARVEOUT
          - HEAP_TYPE_CARVEOUT
          - HEAP_TYPE_CMA
        description: |
          The heap type to use for this heap.

      qcom,uncached-heap:
        type: boolean
        description: Denotes whether this heap provides uncached memory or not.

      qcom,dynamic-heap:
        type: boolean
        description: Denotes whether a heap can have memory dynamically added and
           subtracted from it. Heaps with this property are assumed to start off
           with no memory, and must have memory added to them prior to any use.

      qcom,token:
        $ref: '/schemas/types.yaml#/definitions/uint32'
        description: |
          Specifies the set of secure domains which will be able to access
          the memory-region.

      qcom,max-align:
        $ref: '/schemas/types.yaml#/definitions/uint32'
        description: |
          Maximum alignment of an allocation, in units of page order.

      memory-region:
        $ref: '/schemas/types.yaml#/definitions/phandle'
        description: |
          Specifies the reserved memory region that this heap will allocate
          memory from. This property is only required for heaps that draw memory
          from a particular reserved memory region. Refer to
          Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
          for more information.

    required:
      - qcom,dma-heap-name
      - qcom,dma-heap-type

required:
  - compatible

additionalProperties: false

examples:
  - |
    #include <dt-bindings/arm/msm/qcom_dma_heap_dt_constants.h>
    qcom,dma-heaps {
        compatible = "qcom,dma-heaps";

        qcom,adsp {
            qcom,dma-heap-name = "qcom,adsp";
            qcom,dma-heap-type = <HEAP_TYPE_CMA>;
            memory-region = <&sdsp_mem>;
        };

        qcom,spss {
            qcom,dma-heap-name = "qcom,secure-spss";
            qcom,dma-heap-type = <HEAP_TYPE_CMA>;
            memory-region = <&sp_mem>;
        };
    };
