From e0b41a8f51f2c68e714f0b9321128281ad2a7e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Wed, 11 Aug 2021 16:06:40 -0700 Subject: [PATCH] doc: document devicetree/pinctrl.h macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new section in the API reference for the newly added devicetree/pinctrl.h macros. Amend macros.bnf in the guide to reflect the new generated macros for getting at pinctrl information by name. Signed-off-by: Martí Bolívar --- doc/guides/dts/macros.bnf | 46 ++++++++++++++++++++++++++++++++ doc/reference/devicetree/api.rst | 28 +++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/doc/guides/dts/macros.bnf b/doc/guides/dts/macros.bnf index b66c71f3f54..1514e0b883e 100644 --- a/doc/guides/dts/macros.bnf +++ b/doc/guides/dts/macros.bnf @@ -19,6 +19,8 @@ dt-macro = node-macro / other-macro ; A macro about a property value node-macro = property-macro +; A macro about the pinctrl properties in a node. +node-macro =/ pinctrl-macro ; EXISTS macro: node exists in the devicetree node-macro =/ %s"DT_N" path-id %s"_EXISTS" ; Bus macros: the plain BUS is a way to access a node's bus controller. @@ -71,6 +73,50 @@ node-macro =/ %s"DT_N" path-id %s"_REQUIRES_ORDS" ; The dependency ordinals of a node supports (reverse direct dependencies). node-macro =/ %s"DT_N" path-id %s"_SUPPORTS_ORDS" +; -------------------------------------------------------------------- +; pinctrl-macro: a macro related to the pinctrl properties in a node +; +; These are a bit of a special case because they kind of form an array, +; but the array indexes correspond to pinctrl-DIGIT properties in a node. +; +; So they're related to a node, but not just one property within the node. +; +; The following examples assume something like this: +; +; foo { +; pinctrl-0 = <&bar>; +; pinctrl-1 = <&baz>; +; pinctrl-names = "default", "sleep"; +; }; + +; Total number of pinctrl-DIGIT properties in the node. May be zero. +; +; #define DT_N__PINCTRL_NUM 2 +pinctrl-macro = %s"DT_N" path-id %s"_PINCTRL_NUM" +; A given pinctrl-DIGIT property exists. +; +; #define DT_N__PINCTRL_IDX_0_EXISTS 1 +; #define DT_N__PINCTRL_IDX_1_EXISTS 1 +pinctrl-macro =/ %s"DT_N" path-id %s"_PINCTRL_IDX_" DIGIT %s"_EXISTS" +; A given pinctrl property name exists. +; +; #define DT_N__PINCTRL_NAME_default_EXISTS 1 +; #define DT_N__PINCTRL_NAME_sleep_EXISTS 1 +pinctrl-macro =/ %s"DT_N" path-id %s"_PINCTRL_NAME_" dt-name %s"_EXISTS" +; The corresponding index number of a named pinctrl property. +; +; #define DT_N__PINCTRL_NAME_default_IDX 0 +; #define DT_N__PINCTRL_NAME_sleep_IDX 1 +pinctrl-macro =/ %s"DT_N" path-id %s"_PINCTRL_NAME_" dt-name %s"_IDX" +; The node identifier for the phandle in a named pinctrl property. +; +; #define DT_N__PINCTRL_NAME_default_IDX_0_PH +; +; There's no need for a separate macro for access by index: that's +; covered by property-macro. We only need this because the map from +; names to properties is implicit in the structure of the DT. +pinctrl-macro =/ %s"DT_N" path-id %s"_PINCTRL_NAME_" dt-name %s"_IDX_" DIGIT %s"_PH" + ; -------------------------------------------------------------------- ; property-macro: a macro related to a node property ; diff --git a/doc/reference/devicetree/api.rst b/doc/reference/devicetree/api.rst index b48a3441da2..7f0cf233ebc 100644 --- a/doc/reference/devicetree/api.rst +++ b/doc/reference/devicetree/api.rst @@ -254,6 +254,34 @@ channels (e.g. ADC or DAC channels) for conversion. .. doxygengroup:: devicetree-io-channels +Pinctrl (pin control) +===================== + +These are used to access pin control properties by name or index. + +Devicetree nodes may have properties which specify pin control (sometimes known +as pin mux) settings. These are expressed using ``pinctrl-`` properties +within the node, where the ```` values are contiguous integers starting +from 0. These may also be named using the ``pinctrl-names`` property. + +Here is an example: + +.. code-block:: DTS + + node { + ... + pinctrl-0 = <&foo &bar ...>; + pinctrl-1 = <&baz ...>; + pinctrl-names = "default", "sleep"; + }; + +Above, ``pinctrl-0`` has name ``"default"``, and ``pinctrl-1`` has name +``"sleep"``. The ``pinctrl-`` property values contain phandles. The +``&foo``, ``&bar``, etc. phandles within the properties point to nodes whose +contents vary by platform, and which describe a pin configuration for the node. + +.. doxygengroup:: devicetree-pinctrl + PWM ===