162306a36Sopenharmony_ci# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
262306a36Sopenharmony_ci%YAML 1.2
362306a36Sopenharmony_ci---
462306a36Sopenharmony_ci$id: http://devicetree.org/schemas/pinctrl/renesas,rza1-ports.yaml#
562306a36Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/core.yaml#
662306a36Sopenharmony_ci
762306a36Sopenharmony_cititle: Renesas RZ/A1 combined Pin and GPIO controller
862306a36Sopenharmony_ci
962306a36Sopenharmony_cimaintainers:
1062306a36Sopenharmony_ci  - Jacopo Mondi <jacopo+renesas@jmondi.org>
1162306a36Sopenharmony_ci  - Geert Uytterhoeven <geert+renesas@glider.be>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cidescription:
1462306a36Sopenharmony_ci  The Renesas SoCs of the RZ/A1 family feature a combined Pin and GPIO
1562306a36Sopenharmony_ci  controller, named "Ports" in the hardware reference manual.
1662306a36Sopenharmony_ci  Pin multiplexing and GPIO configuration is performed on a per-pin basis
1762306a36Sopenharmony_ci  writing configuration values to per-port register sets.
1862306a36Sopenharmony_ci  Each "port" features up to 16 pins, each of them configurable for GPIO
1962306a36Sopenharmony_ci  function (port mode) or in alternate function mode.
2062306a36Sopenharmony_ci  Up to 8 different alternate function modes exist for each single pin.
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciproperties:
2362306a36Sopenharmony_ci  compatible:
2462306a36Sopenharmony_ci    oneOf:
2562306a36Sopenharmony_ci      - const: renesas,r7s72100-ports     # RZ/A1H
2662306a36Sopenharmony_ci      - items:
2762306a36Sopenharmony_ci          - const: renesas,r7s72101-ports # RZ/A1M
2862306a36Sopenharmony_ci          - const: renesas,r7s72100-ports # fallback
2962306a36Sopenharmony_ci      - const: renesas,r7s72102-ports     # RZ/A1L
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci  reg:
3262306a36Sopenharmony_ci    maxItems: 1
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciallOf:
3562306a36Sopenharmony_ci  - $ref: pinctrl.yaml#
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_cirequired:
3862306a36Sopenharmony_ci  - compatible
3962306a36Sopenharmony_ci  - reg
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_cipatternProperties:
4262306a36Sopenharmony_ci  "^gpio-[0-9]*$":
4362306a36Sopenharmony_ci    type: object
4462306a36Sopenharmony_ci    additionalProperties: false
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci    description:
4762306a36Sopenharmony_ci      Each port of the r7s72100 pin controller hardware is itself a GPIO
4862306a36Sopenharmony_ci      controller.
4962306a36Sopenharmony_ci      Different SoCs have different numbers of available pins per port, but
5062306a36Sopenharmony_ci      generally speaking, each of them can be configured in GPIO ("port") mode
5162306a36Sopenharmony_ci      on this hardware.
5262306a36Sopenharmony_ci      Describe GPIO controllers using sub-nodes with the following properties.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci    properties:
5562306a36Sopenharmony_ci      gpio-controller: true
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci      '#gpio-cells':
5862306a36Sopenharmony_ci        const: 2
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci      gpio-ranges:
6162306a36Sopenharmony_ci        maxItems: 1
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci    required:
6462306a36Sopenharmony_ci      - gpio-controller
6562306a36Sopenharmony_ci      - '#gpio-cells'
6662306a36Sopenharmony_ci      - gpio-ranges
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ciadditionalProperties:
7062306a36Sopenharmony_ci  anyOf:
7162306a36Sopenharmony_ci    - type: object
7262306a36Sopenharmony_ci      allOf:
7362306a36Sopenharmony_ci        - $ref: pincfg-node.yaml#
7462306a36Sopenharmony_ci        - $ref: pinmux-node.yaml#
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci      description:
7762306a36Sopenharmony_ci        A pin multiplexing sub-node describes how to configure a set of (or a
7862306a36Sopenharmony_ci        single) pin in some desired alternate function mode.
7962306a36Sopenharmony_ci        A single sub-node may define several pin configurations.
8062306a36Sopenharmony_ci        A few alternate function require special pin configuration flags to be
8162306a36Sopenharmony_ci        supplied along with the alternate function configuration number.
8262306a36Sopenharmony_ci        The hardware reference manual specifies when a pin function requires
8362306a36Sopenharmony_ci        "software IO driven" mode to be specified. To do so use the generic
8462306a36Sopenharmony_ci        properties from the <include/linux/pinctrl/pinconf_generic.h> header
8562306a36Sopenharmony_ci        file to instruct the pin controller to perform the desired pin
8662306a36Sopenharmony_ci        configuration operation.
8762306a36Sopenharmony_ci        The hardware reference manual specifies when a pin has to be configured
8862306a36Sopenharmony_ci        to work in bi-directional mode and when the IO direction has to be
8962306a36Sopenharmony_ci        specified by software. Bi-directional pins must be managed by the pin
9062306a36Sopenharmony_ci        controller driver internally, while software driven IO direction has to
9162306a36Sopenharmony_ci        be explicitly selected when multiple options are available.
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci      properties:
9462306a36Sopenharmony_ci        pinmux:
9562306a36Sopenharmony_ci          description: |
9662306a36Sopenharmony_ci            Integer array representing pin number and pin multiplexing
9762306a36Sopenharmony_ci            configuration.
9862306a36Sopenharmony_ci            When a pin has to be configured in alternate function mode, use
9962306a36Sopenharmony_ci            this property to identify the pin by its global index, and provide
10062306a36Sopenharmony_ci            its alternate function configuration number along with it.
10162306a36Sopenharmony_ci            When multiple pins are required to be configured as part of the
10262306a36Sopenharmony_ci            same alternate function they shall be specified as members of the
10362306a36Sopenharmony_ci            same argument list of a single "pinmux" property.
10462306a36Sopenharmony_ci            Helper macros to ease assembling the pin index from its position
10562306a36Sopenharmony_ci            (port where it sits on and pin number) and alternate function
10662306a36Sopenharmony_ci            identifier are provided by the pin controller header file at:
10762306a36Sopenharmony_ci            <include/dt-bindings/pinctrl/r7s72100-pinctrl.h>
10862306a36Sopenharmony_ci            Integers values in "pinmux" argument list are assembled as:
10962306a36Sopenharmony_ci            ((PORT * 16 + PIN) | MUX_FUNC << 16)
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci        input-enable: true
11262306a36Sopenharmony_ci        output-enable: true
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci      required:
11562306a36Sopenharmony_ci        - pinmux
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci      additionalProperties: false
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci    - type: object
12062306a36Sopenharmony_ci      additionalProperties:
12162306a36Sopenharmony_ci        $ref: "#/additionalProperties/anyOf/0"
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ciexamples:
12462306a36Sopenharmony_ci  - |
12562306a36Sopenharmony_ci    #include <dt-bindings/pinctrl/r7s72100-pinctrl.h>
12662306a36Sopenharmony_ci    pinctrl: pinctrl@fcfe3000 {
12762306a36Sopenharmony_ci            compatible = "renesas,r7s72100-ports";
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci            reg = <0xfcfe3000 0x4230>;
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci            /*
13262306a36Sopenharmony_ci             * A GPIO controller node, controlling 16 pins indexed from 0.
13362306a36Sopenharmony_ci             * The GPIO controller base in the global pin indexing space is pin
13462306a36Sopenharmony_ci             * 48, thus pins [0 - 15] on this controller map to pins [48 - 63]
13562306a36Sopenharmony_ci             * in the global pin indexing space.
13662306a36Sopenharmony_ci             */
13762306a36Sopenharmony_ci            port3: gpio-3 {
13862306a36Sopenharmony_ci                    gpio-controller;
13962306a36Sopenharmony_ci                    #gpio-cells = <2>;
14062306a36Sopenharmony_ci                    gpio-ranges = <&pinctrl 0 48 16>;
14162306a36Sopenharmony_ci            };
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci            /*
14462306a36Sopenharmony_ci             * A serial communication interface with a TX output pin and an RX
14562306a36Sopenharmony_ci             * input pin.
14662306a36Sopenharmony_ci             * Pin #0 on port #3 is configured as alternate function #6.
14762306a36Sopenharmony_ci             * Pin #2 on port #3 is configured as alternate function #4.
14862306a36Sopenharmony_ci             */
14962306a36Sopenharmony_ci            scif2_pins: serial2 {
15062306a36Sopenharmony_ci                    pinmux = <RZA1_PINMUX(3, 0, 6)>, <RZA1_PINMUX(3, 2, 4)>;
15162306a36Sopenharmony_ci            };
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci            /*
15562306a36Sopenharmony_ci             * I2c master: both SDA and SCL pins need bi-directional operations
15662306a36Sopenharmony_ci             * Pin #4 on port #1 is configured as alternate function #1.
15762306a36Sopenharmony_ci             * Pin #5 on port #1 is configured as alternate function #1.
15862306a36Sopenharmony_ci             * Both need to work in bi-directional mode, the driver must manage
15962306a36Sopenharmony_ci             * this internally.
16062306a36Sopenharmony_ci             */
16162306a36Sopenharmony_ci            i2c2_pins: i2c2 {
16262306a36Sopenharmony_ci                    pinmux = <RZA1_PINMUX(1, 4, 1)>, <RZA1_PINMUX(1, 5, 1)>;
16362306a36Sopenharmony_ci            };
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci            /*
16762306a36Sopenharmony_ci             * Multi-function timer input and output compare pins.
16862306a36Sopenharmony_ci             */
16962306a36Sopenharmony_ci            tioc0_pins: tioc0 {
17062306a36Sopenharmony_ci                    /*
17162306a36Sopenharmony_ci                     * Configure TIOC0A as software driven input
17262306a36Sopenharmony_ci                     * Pin #0 on port #4 is configured as alternate function #2
17362306a36Sopenharmony_ci                     * with IO direction specified by software as input.
17462306a36Sopenharmony_ci                     */
17562306a36Sopenharmony_ci                    tioc0_input_pins {
17662306a36Sopenharmony_ci                            pinmux = <RZA1_PINMUX(4, 0, 2)>;
17762306a36Sopenharmony_ci                            input-enable;
17862306a36Sopenharmony_ci                    };
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_ci                    /*
18162306a36Sopenharmony_ci                     * Configure TIOC0B as software driven output
18262306a36Sopenharmony_ci                     * Pin #1 on port #4 is configured as alternate function #1
18362306a36Sopenharmony_ci                     * with IO direction specified by software as output.
18462306a36Sopenharmony_ci                     */
18562306a36Sopenharmony_ci                    tioc0_output_pins {
18662306a36Sopenharmony_ci                            pinmux = <RZA1_PINMUX(4, 1, 1)>;
18762306a36Sopenharmony_ci                            output-enable;
18862306a36Sopenharmony_ci                    };
18962306a36Sopenharmony_ci            };
19062306a36Sopenharmony_ci    };
191