| 1 |
# SPDX-License-Identifier: BSD-2-Clause |
| 2 |
# Copyright 2016,2022 Arm Ltd. |
| 3 |
%YAML 1.2 |
| 4 |
--- |
| 5 |
$id: http://devicetree.org/schemas/pci/pci-iommu.yaml# |
| 6 |
$schema: http://devicetree.org/meta-schemas/core.yaml# |
| 7 |
|
| 8 |
title: PCI IOMMU Mapping Properties |
| 9 |
|
| 10 |
description: | |
| 11 |
This document describes the generic device tree binding for describing the |
| 12 |
relationship between PCI(e) devices and IOMMU(s). |
| 13 |
|
| 14 |
Each PCI(e) device under a root complex is uniquely identified by its Requester |
| 15 |
ID (AKA RID). A Requester ID is a triplet of a Bus number, Device number, and |
| 16 |
Function number. |
| 17 |
|
| 18 |
For the purpose of this document, when treated as a numeric value, a RID is |
| 19 |
formatted such that: |
| 20 |
|
| 21 |
* Bits [15:8] are the Bus number. |
| 22 |
* Bits [7:3] are the Device number. |
| 23 |
* Bits [2:0] are the Function number. |
| 24 |
* Any other bits required for padding must be zero. |
| 25 |
|
| 26 |
IOMMUs may distinguish PCI devices through sideband data derived from the |
| 27 |
Requester ID. While a given PCI device can only master through one IOMMU, a |
| 28 |
root complex may split masters across a set of IOMMUs (e.g. with one IOMMU per |
| 29 |
bus). |
| 30 |
|
| 31 |
The generic 'iommus' property is insufficient to describe this relationship, |
| 32 |
and a mechanism is required to map from a PCI device to its IOMMU and sideband |
| 33 |
data. |
| 34 |
|
| 35 |
maintainers: |
| 36 |
- Rob Herring <[email protected]> |
| 37 |
|
| 38 |
select: true |
| 39 |
|
| 40 |
properties: |
| 41 |
iommu-map: |
| 42 |
description: | |
| 43 |
Maps a Requester ID to an IOMMU and associated IOMMU specifier data. |
| 44 |
|
| 45 |
The property is an arbitrary number of tuples of |
| 46 |
(rid-base,iommu,iommu-base,length). |
| 47 |
|
| 48 |
Any RID r in the interval [rid-base, rid-base + length) is associated with |
| 49 |
the listed IOMMU, with the IOMMU specifier (r - rid-base + iommu-base). |
| 50 |
$ref: /schemas/types.yaml#/definitions/uint32-matrix |
| 51 |
items: |
| 52 |
items: |
| 53 |
- description: RID base |
| 54 |
maximum: 0xffff |
| 55 |
- description: phandle to IOMMU |
| 56 |
- description: IOMMU specifier base (currently always 1 cell) |
| 57 |
- description: Number of RIDs |
| 58 |
maximum: 0x10000 |
| 59 |
|
| 60 |
iommu-map-mask: |
| 61 |
description: |
| 62 |
A mask to be applied to each Requester ID prior to being mapped to an |
| 63 |
IOMMU specifier per the iommu-map property. |
| 64 |
$ref: /schemas/types.yaml#/definitions/uint32 |
| 65 |
maximum: 0xffff |
| 66 |
|
| 67 |
additionalProperties: true |
| 68 |
|
| 69 |
examples: |
| 70 |
- | |
| 71 |
/ { |
| 72 |
#address-cells = <1>; |
| 73 |
#size-cells = <1>; |
| 74 |
|
| 75 |
iommu: iommu@a { |
| 76 |
reg = <0xa 0x1>; |
| 77 |
compatible = "foo,some-iommu"; |
| 78 |
#iommu-cells = <1>; |
| 79 |
}; |
| 80 |
|
| 81 |
pci: pci@f { |
| 82 |
reg = <0xf 0x1>; |
| 83 |
compatible = "foo,pcie-root-complex"; |
| 84 |
device_type = "pci"; |
| 85 |
|
| 86 |
/* |
| 87 |
* The sideband data provided to the IOMMU is the RID, |
| 88 |
* identity-mapped. |
| 89 |
*/ |
| 90 |
iommu-map = <0x0 &iommu 0x0 0x10000>; |
| 91 |
}; |
| 92 |
}; |
| 93 |
|
| 94 |
- | |
| 95 |
/ { |
| 96 |
#address-cells = <1>; |
| 97 |
#size-cells = <1>; |
| 98 |
|
| 99 |
iommu: iommu@a { |
| 100 |
reg = <0xa 0x1>; |
| 101 |
compatible = "foo,some-iommu"; |
| 102 |
#iommu-cells = <1>; |
| 103 |
}; |
| 104 |
|
| 105 |
pci: pci@f { |
| 106 |
reg = <0xf 0x1>; |
| 107 |
compatible = "foo,pcie-root-complex"; |
| 108 |
device_type = "pci"; |
| 109 |
|
| 110 |
/* |
| 111 |
* The sideband data provided to the IOMMU is the RID with the |
| 112 |
* function bits masked out. |
| 113 |
*/ |
| 114 |
iommu-map = <0x0 &iommu 0x0 0x10000>; |
| 115 |
iommu-map-mask = <0xfff8>; |
| 116 |
}; |
| 117 |
}; |
| 118 |
|
| 119 |
- | |
| 120 |
/ { |
| 121 |
#address-cells = <1>; |
| 122 |
#size-cells = <1>; |
| 123 |
|
| 124 |
iommu: iommu@a { |
| 125 |
reg = <0xa 0x1>; |
| 126 |
compatible = "foo,some-iommu"; |
| 127 |
#iommu-cells = <1>; |
| 128 |
}; |
| 129 |
|
| 130 |
pci: pci@f { |
| 131 |
reg = <0xf 0x1>; |
| 132 |
compatible = "foo,pcie-root-complex"; |
| 133 |
device_type = "pci"; |
| 134 |
|
| 135 |
/* |
| 136 |
* The sideband data provided to the IOMMU is the RID, |
| 137 |
* but the high bits of the bus number are flipped. |
| 138 |
*/ |
| 139 |
iommu-map = <0x0000 &iommu 0x8000 0x8000>, |
| 140 |
<0x8000 &iommu 0x0000 0x8000>; |
| 141 |
}; |
| 142 |
}; |
| 143 |
|
| 144 |
- | |
| 145 |
/ { |
| 146 |
#address-cells = <1>; |
| 147 |
#size-cells = <1>; |
| 148 |
|
| 149 |
iommu_a: iommu@a { |
| 150 |
reg = <0xa 0x1>; |
| 151 |
compatible = "foo,some-iommu"; |
| 152 |
#iommu-cells = <1>; |
| 153 |
}; |
| 154 |
|
| 155 |
iommu_b: iommu@b { |
| 156 |
reg = <0xb 0x1>; |
| 157 |
compatible = "foo,some-iommu"; |
| 158 |
#iommu-cells = <1>; |
| 159 |
}; |
| 160 |
|
| 161 |
iommu_c: iommu@c { |
| 162 |
reg = <0xc 0x1>; |
| 163 |
compatible = "foo,some-iommu"; |
| 164 |
#iommu-cells = <1>; |
| 165 |
}; |
| 166 |
|
| 167 |
pci: pci@f { |
| 168 |
reg = <0xf 0x1>; |
| 169 |
compatible = "foo,pcie-root-complex"; |
| 170 |
device_type = "pci"; |
| 171 |
|
| 172 |
/* |
| 173 |
* Devices with bus number 0-127 are mastered via IOMMU |
| 174 |
* a, with sideband data being RID[14:0]. |
| 175 |
* Devices with bus number 128-255 are mastered via |
| 176 |
* IOMMU b, with sideband data being RID[14:0]. |
| 177 |
* No devices master via IOMMU c. |
| 178 |
*/ |
| 179 |
iommu-map = <0x0000 &iommu_a 0x0000 0x8000>, |
| 180 |
<0x8000 &iommu_b 0x0000 0x8000>; |
| 181 |
}; |
| 182 |
}; |
| 183 |
... |