18c2ecf20Sopenharmony_ciNVIDIA Tegra186 GPIO controllers
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciTegra186 contains two GPIO controllers; a main controller and an "AON"
48c2ecf20Sopenharmony_cicontroller. This binding document applies to both controllers. The register
58c2ecf20Sopenharmony_cilayouts for the controllers share many similarities, but also some significant
68c2ecf20Sopenharmony_cidifferences. Hence, this document describes closely related but different
78c2ecf20Sopenharmony_cibindings and compatible values.
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciThe Tegra186 GPIO controller allows software to set the IO direction of, and
108c2ecf20Sopenharmony_ciread/write the value of, numerous GPIO signals. Routing of GPIO signals to
118c2ecf20Sopenharmony_cipackage balls is under the control of a separate pin controller HW block. Two
128c2ecf20Sopenharmony_cimajor sets of registers exist:
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cia) Security registers, which allow configuration of allowed access to the GPIO
158c2ecf20Sopenharmony_ciregister set. These registers exist in a single contiguous block of physical
168c2ecf20Sopenharmony_ciaddress space. The size of this block, and the security features available,
178c2ecf20Sopenharmony_civaries between the different GPIO controllers.
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciAccess to this set of registers is not necessary in all circumstances. Code
208c2ecf20Sopenharmony_cithat wishes to configure access to the GPIO registers needs access to these
218c2ecf20Sopenharmony_ciregisters to do so. Code which simply wishes to read or write GPIO data does not
228c2ecf20Sopenharmony_cineed access to these registers.
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cib) GPIO registers, which allow manipulation of the GPIO signals. In some GPIO
258c2ecf20Sopenharmony_cicontrollers, these registers are exposed via multiple "physical aliases" in
268c2ecf20Sopenharmony_ciaddress space, each of which access the same underlying state. See the hardware
278c2ecf20Sopenharmony_cidocumentation for rationale. Any particular GPIO client is expected to access
288c2ecf20Sopenharmony_cijust one of these physical aliases.
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciTegra HW documentation describes a unified naming convention for all GPIOs
318c2ecf20Sopenharmony_ciimplemented by the SoC. Each GPIO is assigned to a port, and a port may control
328c2ecf20Sopenharmony_cia number of GPIOs. Thus, each GPIO is named according to an alphabetical port
338c2ecf20Sopenharmony_ciname and an integer GPIO name within the port. For example, GPIO_PA0, GPIO_PN6,
348c2ecf20Sopenharmony_cior GPIO_PCC3.
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciThe number of ports implemented by each GPIO controller varies. The number of
378c2ecf20Sopenharmony_ciimplemented GPIOs within each port varies. GPIO registers within a controller
388c2ecf20Sopenharmony_ciare grouped and laid out according to the port they affect.
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciThe mapping from port name to the GPIO controller that implements that port, and
418c2ecf20Sopenharmony_cithe mapping from port name to register offset within a controller, are both
428c2ecf20Sopenharmony_ciextremely non-linear. The header file <dt-bindings/gpio/tegra186-gpio.h>
438c2ecf20Sopenharmony_cidescribes the port-level mapping. In that file, the naming convention for ports
448c2ecf20Sopenharmony_cimatches the HW documentation. The values chosen for the names are alphabetically
458c2ecf20Sopenharmony_cisorted within a particular controller. Drivers need to map between the DT GPIO
468c2ecf20Sopenharmony_ciIDs and HW register offsets using a lookup table.
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciEach GPIO controller can generate a number of interrupt signals. Each signal
498c2ecf20Sopenharmony_cirepresents the aggregate status for all GPIOs within a set of ports. Thus, the
508c2ecf20Sopenharmony_cinumber of interrupt signals generated by a controller varies as a rough function
518c2ecf20Sopenharmony_ciof the number of ports it implements. Note that the HW documentation refers to
528c2ecf20Sopenharmony_ciboth the overall controller HW module and the sets-of-ports as "controllers".
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciEach GPIO controller in fact generates multiple interrupts signals for each set
558c2ecf20Sopenharmony_ciof ports. Each GPIO may be configured to feed into a specific one of the
568c2ecf20Sopenharmony_ciinterrupt signals generated by a set-of-ports. The intent is for each generated
578c2ecf20Sopenharmony_cisignal to be routed to a different CPU, thus allowing different CPUs to each
588c2ecf20Sopenharmony_cihandle subsets of the interrupts within a port. The status of each of these
598c2ecf20Sopenharmony_ciper-port-set signals is reported via a separate register. Thus, a driver needs
608c2ecf20Sopenharmony_cito know which status register to observe. This binding currently defines no
618c2ecf20Sopenharmony_ciconfiguration mechanism for this. By default, drivers should use register
628c2ecf20Sopenharmony_ciGPIO_${port}_INTERRUPT_STATUS_G1_0. Future revisions to the binding could
638c2ecf20Sopenharmony_cidefine a property to configure this.
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ciRequired properties:
668c2ecf20Sopenharmony_ci- compatible
678c2ecf20Sopenharmony_ci    Array of strings.
688c2ecf20Sopenharmony_ci    One of:
698c2ecf20Sopenharmony_ci    - "nvidia,tegra186-gpio".
708c2ecf20Sopenharmony_ci    - "nvidia,tegra186-gpio-aon".
718c2ecf20Sopenharmony_ci    - "nvidia,tegra194-gpio".
728c2ecf20Sopenharmony_ci    - "nvidia,tegra194-gpio-aon".
738c2ecf20Sopenharmony_ci- reg-names
748c2ecf20Sopenharmony_ci    Array of strings.
758c2ecf20Sopenharmony_ci    Contains a list of names for the register spaces described by the reg
768c2ecf20Sopenharmony_ci    property. May contain the following entries, in any order:
778c2ecf20Sopenharmony_ci    - "gpio": Mandatory. GPIO control registers. This may cover either:
788c2ecf20Sopenharmony_ci        a) The single physical alias that this OS should use.
798c2ecf20Sopenharmony_ci        b) All physical aliases that exist in the controller. This is
808c2ecf20Sopenharmony_ci           appropriate when the OS is responsible for managing assignment of
818c2ecf20Sopenharmony_ci           the physical aliases.
828c2ecf20Sopenharmony_ci    - "security": Optional. Security configuration registers.
838c2ecf20Sopenharmony_ci    Users of this binding MUST look up entries in the reg property by name,
848c2ecf20Sopenharmony_ci    using this reg-names property to do so.
858c2ecf20Sopenharmony_ci- reg
868c2ecf20Sopenharmony_ci    Array of (physical base address, length) tuples.
878c2ecf20Sopenharmony_ci    Must contain one entry per entry in the reg-names property, in a matching
888c2ecf20Sopenharmony_ci    order.
898c2ecf20Sopenharmony_ci- interrupts
908c2ecf20Sopenharmony_ci    Array of interrupt specifiers.
918c2ecf20Sopenharmony_ci    The interrupt outputs from the HW block, one per set of ports, in the
928c2ecf20Sopenharmony_ci    order the HW manual describes them. The number of entries required varies
938c2ecf20Sopenharmony_ci    depending on compatible value:
948c2ecf20Sopenharmony_ci    - "nvidia,tegra186-gpio": 6 entries.
958c2ecf20Sopenharmony_ci    - "nvidia,tegra186-gpio-aon": 1 entry.
968c2ecf20Sopenharmony_ci    - "nvidia,tegra194-gpio": 6 entries.
978c2ecf20Sopenharmony_ci    - "nvidia,tegra194-gpio-aon": 1 entry.
988c2ecf20Sopenharmony_ci- gpio-controller
998c2ecf20Sopenharmony_ci    Boolean.
1008c2ecf20Sopenharmony_ci    Marks the device node as a GPIO controller/provider.
1018c2ecf20Sopenharmony_ci- #gpio-cells
1028c2ecf20Sopenharmony_ci    Single-cell integer.
1038c2ecf20Sopenharmony_ci    Must be <2>.
1048c2ecf20Sopenharmony_ci    Indicates how many cells are used in a consumer's GPIO specifier.
1058c2ecf20Sopenharmony_ci    In the specifier:
1068c2ecf20Sopenharmony_ci    - The first cell is the pin number.
1078c2ecf20Sopenharmony_ci        See <dt-bindings/gpio/tegra186-gpio.h>.
1088c2ecf20Sopenharmony_ci    - The second cell contains flags:
1098c2ecf20Sopenharmony_ci        - Bit 0 specifies polarity
1108c2ecf20Sopenharmony_ci            - 0: Active-high (normal).
1118c2ecf20Sopenharmony_ci            - 1: Active-low (inverted).
1128c2ecf20Sopenharmony_ci- interrupt-controller
1138c2ecf20Sopenharmony_ci    Boolean.
1148c2ecf20Sopenharmony_ci    Marks the device node as an interrupt controller/provider.
1158c2ecf20Sopenharmony_ci- #interrupt-cells
1168c2ecf20Sopenharmony_ci    Single-cell integer.
1178c2ecf20Sopenharmony_ci    Must be <2>.
1188c2ecf20Sopenharmony_ci    Indicates how many cells are used in a consumer's interrupt specifier.
1198c2ecf20Sopenharmony_ci    In the specifier:
1208c2ecf20Sopenharmony_ci    - The first cell is the GPIO number.
1218c2ecf20Sopenharmony_ci        See <dt-bindings/gpio/tegra186-gpio.h>.
1228c2ecf20Sopenharmony_ci    - The second cell is contains flags:
1238c2ecf20Sopenharmony_ci        - Bits [3:0] indicate trigger type and level:
1248c2ecf20Sopenharmony_ci            - 1: Low-to-high edge triggered.
1258c2ecf20Sopenharmony_ci            - 2: High-to-low edge triggered.
1268c2ecf20Sopenharmony_ci            - 4: Active high level-sensitive.
1278c2ecf20Sopenharmony_ci            - 8: Active low level-sensitive.
1288c2ecf20Sopenharmony_ci            Valid combinations are 1, 2, 3, 4, 8.
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ciExample:
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#include <dt-bindings/interrupt-controller/irq.h>
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_cigpio@2200000 {
1358c2ecf20Sopenharmony_ci	compatible = "nvidia,tegra186-gpio";
1368c2ecf20Sopenharmony_ci	reg-names = "security", "gpio";
1378c2ecf20Sopenharmony_ci	reg =
1388c2ecf20Sopenharmony_ci		<0x0 0x2200000 0x0 0x10000>,
1398c2ecf20Sopenharmony_ci		<0x0 0x2210000 0x0 0x10000>;
1408c2ecf20Sopenharmony_ci	interrupts =
1418c2ecf20Sopenharmony_ci		<0 47 IRQ_TYPE_LEVEL_HIGH>,
1428c2ecf20Sopenharmony_ci		<0 50 IRQ_TYPE_LEVEL_HIGH>,
1438c2ecf20Sopenharmony_ci		<0 53 IRQ_TYPE_LEVEL_HIGH>,
1448c2ecf20Sopenharmony_ci		<0 56 IRQ_TYPE_LEVEL_HIGH>,
1458c2ecf20Sopenharmony_ci		<0 59 IRQ_TYPE_LEVEL_HIGH>,
1468c2ecf20Sopenharmony_ci		<0 180 IRQ_TYPE_LEVEL_HIGH>;
1478c2ecf20Sopenharmony_ci	gpio-controller;
1488c2ecf20Sopenharmony_ci	#gpio-cells = <2>;
1498c2ecf20Sopenharmony_ci	interrupt-controller;
1508c2ecf20Sopenharmony_ci	#interrupt-cells = <2>;
1518c2ecf20Sopenharmony_ci};
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cigpio@c2f0000 {
1548c2ecf20Sopenharmony_ci	compatible = "nvidia,tegra186-gpio-aon";
1558c2ecf20Sopenharmony_ci	reg-names = "security", "gpio";
1568c2ecf20Sopenharmony_ci	reg =
1578c2ecf20Sopenharmony_ci		<0x0 0xc2f0000 0x0 0x1000>,
1588c2ecf20Sopenharmony_ci		<0x0 0xc2f1000 0x0 0x1000>;
1598c2ecf20Sopenharmony_ci	interrupts =
1608c2ecf20Sopenharmony_ci		<0 60 IRQ_TYPE_LEVEL_HIGH>;
1618c2ecf20Sopenharmony_ci	gpio-controller;
1628c2ecf20Sopenharmony_ci	#gpio-cells = <2>;
1638c2ecf20Sopenharmony_ci	interrupt-controller;
1648c2ecf20Sopenharmony_ci	#interrupt-cells = <2>;
1658c2ecf20Sopenharmony_ci};
166