1# Copyright (c) 2021 Teslabs Engineering S.L.
2# Copyright (c) 2021 Yonatan Schachter
3# SPDX-License-Identifier: Apache-2.0
4
5description: |
6    The RPi Pico pin controller is a node responsible for controlling
7    pin function selection and pin properties, such as routing a UART0 Rx
8    to pin 1 and enabling the pullup resistor on that pin.
9
10    The node has the 'pinctrl' node label set in your SoC's devicetree,
11    so you can modify it like this:
12
13      &pinctrl {
14              /* your modifications go here */
15      };
16
17    All device pin configurations should be placed in child nodes of the
18    'pinctrl' node, as shown in this example:
19
20      /* You can put this in places like a board-pinctrl.dtsi file in
21       * your board directory, or a devicetree overlay in your application.
22       */
23
24      /* include pre-defined combinations for the SoC variant used by the board */
25      #include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
26
27      &pinctrl {
28        /* configuration for the usart0 "default" state */
29        uart0_default: uart0_default {
30          /* group 1 */
31          group1 {
32            /* configure P0 as UART0 TX */
33            pinmux = <UART0_TX_P0>;
34          };
35          /* group 2 */
36          group2 {
37            /* configure P1 as UART0 RX */
38            pinmux = <UART0_RX_P1>;
39            /* enable input on pin 1 */
40            input-enable;
41          };
42        };
43      };
44
45    The 'uart0_default' child node encodes the pin configurations for a
46    particular state of a device; in this case, the default (that is, active)
47    state.
48
49    As shown, pin configurations are organized in groups within each child node.
50    Each group can specify a list of pin function selections in the 'pinmux'
51    property.
52
53    A group can also specify shared pin properties common to all the specified
54    pins, such as the 'input-enable' property in group 2. Here is a list of
55    supported standard pin properties:
56
57    - bias-disable: Disable pull-up/down (default, not required).
58    - bias-pull-up: Enable pull-up resistor.
59    - bias-pull-down: Enable pull-down resistor.
60    - input-enable: Enable input from the pin.
61    - input-schmitt-enable: Enable input hysteresys.
62    - drive-strength: Set the drive strength of the pin, in milliamps. Possible
63      values are: 2, 4, 8, 12 (default: 4mA)
64    - slew-rate: If set to 0, slew rate is set to slow. If set to 1, it is set
65      to fast.
66
67    To link pin configurations with a device, use a pinctrl-N property for some
68    number N, like this example you could place in your board's DTS file:
69
70       #include "board-pinctrl.dtsi"
71
72       &uart0 {
73             pinctrl-0 = <&uart0_default>;
74             pinctrl-1 = <&uart0_sleep>;
75             pinctrl-names = "default", "sleep";
76       };
77
78compatible: "raspberrypi,pico-pinctrl"
79
80include: base.yaml
81
82child-binding:
83  description: |
84    Definitions for a pinctrl state.
85  child-binding:
86
87    include:
88      - name: pincfg-node.yaml
89        property-allowlist:
90          - bias-disable
91          - bias-pull-down
92          - bias-pull-up
93          - input-enable
94          - input-schmitt-enable
95          - drive-strength
96          - slew-rate
97
98    properties:
99      pinmux:
100        required: true
101        type: array
102        description: |
103          An array of pins sharing the same group properties. Each
104          element of the array is an integer constructed from the
105          pin number and the alternative function of the pin.
106      drive-strength:
107        enum:
108          - 2
109          - 4
110          - 8
111          - 12
112        default: 4
113        description: |
114          The drive strength of a pin, in mA. The default value is 4mA, as this
115          is the power on reset value.
116      slew-rate:
117        enum:
118          - 0
119          - 1
120        default: 0
121        description: |
122          The slew rate of a pin. 0 corresponds to slow, and 1 corresponds to fast.
123          The default value is 0 (slow), as this is the power on reset value.
124