Skip to content

Commit 32c96cd

Browse files
bebarinorobherring
authored andcommitted
Document nexus nodes/specifier remapping
Document the generic nexus node properties. This can be used by any specifier that conforms to #<specifier>-cells where they want to support remapping phandle lists through nexus nodes. This is similar to interrupt remapping, but slightly different because we don't consider unit addresses when doing mappings. This is mostly a copy/paste of the interrupt specification, with the unit address parts removed and generalized to any specifier. There's also the addition of a pass through mechanism to make things more compact if desired in the mapping table. Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Rob Herring <[email protected]>
1 parent f7afac6 commit 32c96cd

File tree

1 file changed

+206
-0
lines changed

1 file changed

+206
-0
lines changed

source/devicetree-basics.rst

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,3 +1284,209 @@ performed:
12841284
* That result is looked up in the *interrupt-map* table, which maps to
12851285
the parent interrupt specifier ``<4 1>``.
12861286

1287+
.. _sect-nexus:
1288+
1289+
Nexus Nodes and Specifier Mapping
1290+
---------------------------------
1291+
1292+
Nexus Node Properties
1293+
~~~~~~~~~~~~~~~~~~~~~
1294+
1295+
A nexus node shall have a *#<specifier>-cells* property, where <specifier> is
1296+
some specifier space such as 'gpio', 'clock', 'reset', etc.
1297+
1298+
<specifier>-map
1299+
^^^^^^^^^^^^^^^
1300+
1301+
Property: ``<specifier>-map``
1302+
1303+
Value type: ``<prop-encoded-array>`` encoded as an arbitrary number of
1304+
specifier mapping entries.
1305+
1306+
Description:
1307+
1308+
A *<specifier>-map* is a property in a nexus node that bridges one
1309+
specifier domain with a set of parent specifier domains and describes
1310+
how specifiers in the child domain are mapped to their respective parent
1311+
domains.
1312+
1313+
The map is a table where each row is a mapping entry
1314+
consisting of three components: *child specifier*, *specifier parent*, and
1315+
*parent specifier*.
1316+
1317+
child specifier
1318+
The specifier of the child node being mapped. The number
1319+
of 32-bit cells required to specify this component is described by
1320+
the *#<specifier>-cells* property of this node—the nexus node
1321+
containing the *<specifier>-map* property.
1322+
1323+
specifier parent
1324+
A single *<phandle>* value that points to the specifier parent to
1325+
which the child domain is being mapped.
1326+
1327+
parent specifier
1328+
The specifier in the parent domain. The number of 32-bit
1329+
cells required to specify this component is described by the
1330+
*#<specifier>-cells* property of the specifier parent node.
1331+
1332+
Lookups are performed on the mapping table by matching a specifier against
1333+
the child specifier in the map. Because some fields in the specifier may
1334+
not be relevant or need to be modified, a mask is applied before the lookup
1335+
is done. This mask is defined in the *<specifier>-map-mask* property (see
1336+
section :ref:`sect-specifier-map-mask`).
1337+
1338+
Similarly, when the specifier is mapped, some fields in the unit specifier
1339+
may need to be kept unmodified and passed through from the child node to the
1340+
parent node. In this case, a *<specifier>-map-pass-thru* property (see
1341+
section :ref:`sect-specifier-map-pass-thru`) may be specified to apply
1342+
a mask to the child specifier and copy any bits that match to the parent
1343+
unit specifier.
1344+
1345+
.. _sect-specifier-map-mask:
1346+
1347+
<specifier>-map-mask
1348+
^^^^^^^^^^^^^^^^^^^^
1349+
1350+
Property: ``<specifier>-map-mask``
1351+
1352+
Value type: ``<prop-encoded-array>`` encoded as a bit mask
1353+
1354+
Description:
1355+
1356+
A *<specifier>-map-mask* property may be specified for a nexus node.
1357+
This property specifies a mask that is applied to the child unit
1358+
specifier being looked up in the table specified in the *<specifier>-map*
1359+
property. If this property is not specified, the mask is assumed to be
1360+
a mask with all bits set.
1361+
1362+
.. _sect-specifier-map-pass-thru:
1363+
1364+
<specifier>-map-pass-thru
1365+
^^^^^^^^^^^^^^^^^^^^^^^^^
1366+
1367+
Property: ``<specifier>-map-pass-thru``
1368+
1369+
Value type: ``<prop-encoded-array>`` encoded as a bit mask
1370+
1371+
Description:
1372+
1373+
A *<specifier>-map-pass-thru* property may be specified for a nexus node.
1374+
This property specifies a mask that is applied to the child unit
1375+
specifier being looked up in the table specified in the *<specifier>-map*
1376+
property. Any matching bits in the child unit specifier are copied over
1377+
to the parent specifier. If this property is not specified, the mask is
1378+
assumed to be a mask with no bits set.
1379+
1380+
#<specifier>-cells
1381+
^^^^^^^^^^^^^^^^^^
1382+
1383+
Property: ``#<specifier>-cells``
1384+
1385+
Value type: ``<u32>``
1386+
1387+
Description:
1388+
1389+
The *#<specifier>-cells* property defines the number of cells required to
1390+
encode a specifier for a domain.
1391+
1392+
Specifier Mapping Example
1393+
~~~~~~~~~~~~~~~~~~~~~~~~~
1394+
1395+
The following shows the representation of a fragment of a devicetree with
1396+
two GPIO controllers and a sample specifier map for describing the
1397+
GPIO routing of a few gpios on both of the controllers through a connector
1398+
on a board to a device. The expansion device node is one one side of the
1399+
connector node and the SoC with the two GPIO controllers is on the other
1400+
side of the connector.
1401+
1402+
.. _example-specifier-mapping:
1403+
1404+
.. code-block:: dts
1405+
1406+
soc {
1407+
soc_gpio1: gpio-controller1 {
1408+
#gpio-cells = <2>;
1409+
};
1410+
1411+
soc_gpio2: gpio-controller2 {
1412+
#gpio-cells = <2>;
1413+
};
1414+
};
1415+
1416+
connector: connector {
1417+
#gpio-cells = <2>;
1418+
gpio-map = <0 0 &soc_gpio1 1 0>,
1419+
<1 0 &soc_gpio2 4 0>,
1420+
<2 0 &soc_gpio1 3 0>,
1421+
<3 0 &soc_gpio2 2 0>;
1422+
gpio-map-mask = <0xf 0x0>;
1423+
gpio-map-pass-thru = <0x0 0x1>;
1424+
};
1425+
1426+
expansion_device {
1427+
reset-gpios = <&connector 2 GPIO_ACTIVE_LOW>;
1428+
};
1429+
1430+
1431+
Each row in the gpio-map table consists of three parts: a child unit
1432+
specifier, which is mapped to a *gpio-controller*
1433+
node with a parent specifier.
1434+
1435+
* For example, the first row of the specifier-map table specifies the
1436+
mapping for GPIO 0 of the connector. The components of that row are shown
1437+
here
1438+
1439+
| child specifier: ``0 0``
1440+
| specifier parent: ``&soc_gpio1``
1441+
| parent specifier: ``1 0``
1442+
1443+
* The child specifier is ``<0 0>``, which specifies GPIO 0 in the connector
1444+
with a *flags* field of ``0``. This takes two 32-bit cells as specified
1445+
by the *#gpio-cells* property of the connector node, which is the
1446+
child specifier domian.
1447+
1448+
* The specifier parent is specified by a phandle which points to the
1449+
specifier parent of the connector, the first GPIO controller in the SoC.
1450+
1451+
* The parent specifier is ``<1 0>``. The number of cells to
1452+
represent the gpio specifier (two cells) is determined by the
1453+
*#gpio-cells* property on the specifier parent, the soc_gpio1
1454+
node.
1455+
1456+
* The value ``<1 0>`` is a value specified by the device binding for
1457+
the GPIO controller. The value ``<1>`` specifies the
1458+
GPIO pin number on the GPIO controller to which GPIO 0 on the connector
1459+
is wired. The value ``<0>`` specifies the flags (active low,
1460+
active high, etc.).
1461+
1462+
In this example, the *gpio-map-mask* property has a value of ``<0xf 0>``.
1463+
This mask is applied to a child unit specifier before performing a lookup in
1464+
the *gpio-map* table. Similarly, the *gpio-map-pass-thru* property has a value
1465+
of ``<0x0 0x1>``. This mask is applied to a child unit specifier when mapping
1466+
it to the parent unit specifier. Any bits set in this mask are cleared out of
1467+
the parent unit specifier and copied over from the child unit specifier
1468+
to the parent unit specifier.
1469+
1470+
To perform a lookup of the connector's specifier source number for GPIO 2
1471+
from the expansion device's reset-gpios property, the following steps would be
1472+
performed:
1473+
1474+
* The child specifier forms the value ``<2 GPIO_ACTIVE_LOW>``.
1475+
1476+
* The specifier is encoding GPIO 2 with active low flags per the GPIO
1477+
binding.
1478+
1479+
* The *gpio-map-mask* value ``<0xf 0x0>`` is ANDed with the child specifier,
1480+
giving a result of ``<0x2 0>``.
1481+
1482+
* The result is looked up in the *gpio-map* table, which maps to
1483+
the parent specifier ``<3 0>`` and &soc_gpio1 *phandle*.
1484+
1485+
* The *gpio-map-pass-thru* value ``<0x0 0x1>`` is inverted and ANDed with the
1486+
parent specifier found in the *gpio-map* table, resulting in ``<3 0>``.
1487+
The child specifier is ANDed with the *gpio-map-pass-thru* mask, forming
1488+
``<0 GPIO_ACTIVE_LOW>`` which is then ORed with the cleared parent specifier
1489+
``<3 0>`` resulting in ``<3 GPIO_ACTIVE_LOW>``.
1490+
1491+
* The specifier ``<3 GPIO_ACTIVE_LOW>`` is appended to the mapped *phandle*
1492+
&soc_gpio1 resulting in ``<&soc_gpio1 3 GPIO_ACTIVE_LOW>``.

0 commit comments

Comments
 (0)