# RISC-V IOMMU Architecture Implementation

_Peios Kernel / Hardware and drivers / Device-tree binding reference / Iommu bindings_

> Device-tree binding reference for RISC-V IOMMU Architecture Implementation.

<!-- SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) -->


<a id="dt-root"></a>

**Schema identifier (<code>&#36;id</code>):** <span id="dt-09f478f44eb202ea573e"><code>&#34;http&#58;&#47;&#47;devicetree&#46;org&#47;schemas&#47;iommu&#47;riscv&#44;iommu&#46;yaml&#35;&#34;</code></span>

**Schema dialect (<code>&#36;schema</code>):** <span id="dt-dcb375baab6014763a68"><code>&#34;http&#58;&#47;&#47;devicetree&#46;org&#47;meta&#45;schemas&#47;core&#46;yaml&#35;&#34;</code></span>

<a id="dt-e46b5a5dd81dbd751c9f"></a>

**Maintainers (<code>maintainers</code>):** <a id="dt-fbc39820abb8bb999095"></a> <span id="dt-fb78ddfc22abfc6fe56d"><code>&#34;Tomasz Jeznach &#60;tjeznach&#64;rivosinc&#46;com&#62;&#34;</code></span>

<div id="dt-6d1c5ef59f0239d38c02">
<p style="white-space: pre-wrap">The RISC-V IOMMU provides memory address translation and isolation for
input and output devices, supporting per-device translation context,
shared process address spaces including the ATS and PRI components of
the PCIe specification, two stage address translation and MSI remapping.
It supports identical translation table format to the RISC-V address
translation tables with page level access and protection attributes.
Hardware uses in-memory command and fault reporting queues with wired
interrupt or MSI notifications.</p>
<p style="white-space: pre-wrap">Visit https://github.com/riscv-non-isa/riscv-iommu for more details.</p>
<p style="white-space: pre-wrap">For information on assigning RISC-V IOMMU to its peripheral devices,
see generic IOMMU bindings.</p>
</div>

<a id="dt-e1f655ed0ff4d595dadc"></a>

## Properties and child nodes (<code>properties</code>)

<a id="dt-5c1d81699dcbe840de83"></a>

### <code>compatible</code> — required here

<a id="dt-39566f01414e34c67b85"></a>

#### Exactly one of these rules must match (<code>oneOf</code>)

<a id="dt-fe13e24e5c9612880f47"></a>

**Rule 1**

> <a id="dt-07409cc9508405f48983"></a>
>
> **Array item rules (<code>items</code>)**
>
> <a id="dt-822691c82c9797f7b1f9"></a>
>
> **Item 1**
>
> > **Allowed values (<code>enum</code>):** <a id="dt-3b212051dcd0fc641cd8"></a> <span id="dt-bd6e6716d05ec45653db"><code>&#34;qemu&#44;riscv&#45;iommu&#34;</code></span>
>
> <a id="dt-bc83d1191bdc72da8559"></a>
>
> **Item 2**
>
> > **Exact value (<code>const</code>):** <span id="dt-1da74b37131fdcec1073"><code>&#34;riscv&#44;iommu&#34;</code></span>

<a id="dt-7482b6e745c4f056161a"></a>

**Rule 2**

> <a id="dt-4c3e118873fbaedb5de2"></a>
>
> **Array item rules (<code>items</code>)**
>
> <a id="dt-b02d8860067795c00ae4"></a>
>
> **Item 1**
>
> > **Allowed values (<code>enum</code>):** <a id="dt-aa1230b5a2b80f9fb387"></a> <span id="dt-49b534c9c8948cfc8034"><code>&#34;pci1efd&#44;edf1&#34;</code></span>
>
> <a id="dt-bdc26de0ccb1d52bb6a4"></a>
>
> **Item 2**
>
> > **Exact value (<code>const</code>):** <span id="dt-cc26fa5d96bc7cf0a818"><code>&#34;riscv&#44;pci&#45;iommu&#34;</code></span>

<a id="dt-9c1635fdb65d87e33d77"></a>

### <code>reg</code> — required here

**Maximum number of items (<code>maxItems</code>):** <span id="dt-71421d35675d9a533ad2"><code>1</code></span>

<div id="dt-571d87f60678ead6c5ff">
<p style="white-space: pre-wrap">For non-PCI devices this represents base address and size of for the IOMMU memory mapped registers interface. For PCI IOMMU hardware implementation this should represent an address of the IOMMU, as defined in the PCI Bus Binding reference.</p>
</div>

<a id="dt-1b52f12b0719e235c45f"></a>

### <code>&#35;iommu&#45;cells</code> — required here

**Exact value (<code>const</code>):** <span id="dt-1a3bbfcf9f14a0ead311"><code>1</code></span>

<div id="dt-79e1a09ede04917530e1">
<p style="white-space: pre-wrap">The single cell describes the requester id emitted by a master to the IOMMU.</p>
</div>

<a id="dt-c2de09e7f7fd211b679d"></a>

### <code>interrupts</code> — not listed as required here

**Minimum number of items (<code>minItems</code>):** <span id="dt-1691b9edf145244244a0"><code>1</code></span>

**Maximum number of items (<code>maxItems</code>):** <span id="dt-b7823fb65b2f27642d26"><code>4</code></span>

<div id="dt-b3ddec0f69e9f0c0dc40">
<p style="white-space: pre-wrap">Wired interrupt vectors available for RISC-V IOMMU to notify the RISC-V HARTS. The cause to interrupt vector is software defined using IVEC IOMMU register.</p>
</div>

<a id="dt-7f9784704b6acffabda3"></a>

### <code>msi&#45;parent</code> — not listed as required here

<code>true</code> — No constraints added by this property rule.

<a id="dt-030bda573e8c53177f1a"></a>

### <code>power&#45;domains</code> — not listed as required here

**Maximum number of items (<code>maxItems</code>):** <span id="dt-74e4e6f1d3f2a860fdb9"><code>1</code></span>

**Required in this object (<code>required</code>):** <a id="dt-8313173ff1c9b300d560"></a> <span id="dt-048b70ee865d6847aa3d"><code>&#34;compatible&#34;</code></span>, <span id="dt-ee7433925c1528c16b99"><code>&#34;reg&#34;</code></span>, <span id="dt-f3765998c4e103e45f2f"><code>&#34;&#35;iommu&#45;cells&#34;</code></span>

<a id="dt-738c4b4f9e483441138b"></a>

## Properties not matched by properties or patternProperties in this schema (<code>additionalProperties</code>)

<code>false</code>

Not allowed by this rule.

<a id="dt-1a130cabaa8a47b058bf"></a>

## Examples (<code>examples</code>)

<pre id="dt-0bd6510295af0c95ff2d"><code class="language-dts">/* Example 1 (IOMMU device with wired interrupts) */
#include &lt;dt-bindings/interrupt-controller/irq.h&gt;

iommu1: iommu@1bccd000 {
    compatible = "qemu,riscv-iommu", "riscv,iommu";
    reg = &lt;0x1bccd000 0x1000&gt;;
    interrupt-parent = &lt;&amp;aplic_smode&gt;;
    interrupts = &lt;32 IRQ_TYPE_LEVEL_HIGH&gt;,
                 &lt;33 IRQ_TYPE_LEVEL_HIGH&gt;,
                 &lt;34 IRQ_TYPE_LEVEL_HIGH&gt;,
                 &lt;35 IRQ_TYPE_LEVEL_HIGH&gt;;
    #iommu-cells = &lt;1&gt;;
};

/* Device with two IOMMU device IDs, 0 and 7 */
master1 {
    iommus = &lt;&amp;iommu1 0&gt;, &lt;&amp;iommu1 7&gt;;
};

</code></pre>

<pre id="dt-bae0d43ea48e35208b4a"><code class="language-dts">/* Example 2 (IOMMU device with shared wired interrupt) */
#include &lt;dt-bindings/interrupt-controller/irq.h&gt;

iommu2: iommu@1bccd000 {
    compatible = "qemu,riscv-iommu", "riscv,iommu";
    reg = &lt;0x1bccd000 0x1000&gt;;
    interrupt-parent = &lt;&amp;aplic_smode&gt;;
    interrupts = &lt;32 IRQ_TYPE_LEVEL_HIGH&gt;;
    #iommu-cells = &lt;1&gt;;
};

</code></pre>

<pre id="dt-d0212a4cd671f89a0b40"><code class="language-dts">/* Example 3 (IOMMU device with MSIs) */
iommu3: iommu@1bcdd000 {
    compatible = "qemu,riscv-iommu", "riscv,iommu";
    reg = &lt;0x1bccd000 0x1000&gt;;
    msi-parent = &lt;&amp;imsics_smode&gt;;
    #iommu-cells = &lt;1&gt;;
};

</code></pre>

<pre id="dt-cf8a683b5a963eb1c566"><code class="language-dts">/* Example 4 (IOMMU PCIe device with MSIs) */
bus {
    #address-cells = &lt;2&gt;;
    #size-cells = &lt;2&gt;;

    pcie@30000000 {
        device_type = "pci";
        #address-cells = &lt;3&gt;;
        #size-cells = &lt;2&gt;;
        reg = &lt;0x0 0x30000000  0x0 0x1000000&gt;;
        ranges = &lt;0x02000000 0x0 0x41000000  0x0 0x41000000  0x0 0x0f000000&gt;;

        /*
         * The IOMMU manages all functions in this PCI domain except
         * itself. Omit BDF 00:01.0.
         */
        iommu-map = &lt;0x0 &amp;iommu0 0x0 0x8&gt;,
                    &lt;0x9 &amp;iommu0 0x9 0xfff7&gt;;

        /* The IOMMU programming interface uses slot 00:01.0 */
        iommu0: iommu@1,0 {
            compatible = "pci1efd,edf1", "riscv,pci-iommu";
            reg = &lt;0x800 0 0 0 0&gt;;
            #iommu-cells = &lt;1&gt;;
        };
    };
};
</code></pre>

## Source notes

<details>
<summary>Annotations retained from the schema source</summary>

<p id="dt-comment-0"><strong>Line 1:</strong> <span> SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)</span></p>

<p id="dt-comment-1"><strong>Line 28:</strong> <span> For PCIe IOMMU hardware compatible property should contain the vendor</span></p>

<p id="dt-comment-2"><strong>Line 29:</strong> <span> and device ID according to the PCI Bus Binding specification.</span></p>

<p id="dt-comment-3"><strong>Line 30:</strong> <span> Since PCI provides built-in identification methods, compatible is not</span></p>

<p id="dt-comment-4"><strong>Line 31:</strong> <span> actually required. For non-PCIe hardware implementations 'riscv,iommu'</span></p>

<p id="dt-comment-5"><strong>Line 32:</strong> <span> should be specified along with 'reg' property providing MMIO location.</span></p>

</details>
