1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/pinctrl/mediatek,mt7986-pinctrl.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Mediatek MT7986 Pin Controller
8
9maintainers:
10  - Sean Wang <sean.wang@kernel.org>
11
12description: |+
13  The MediaTek's MT7986 Pin controller is used to control SoC pins.
14
15properties:
16  compatible:
17    enum:
18      - mediatek,mt7986a-pinctrl
19      - mediatek,mt7986b-pinctrl
20
21  reg:
22    minItems: 8
23    maxItems: 8
24
25  reg-names:
26    items:
27      - const: gpio
28      - const: iocfg_rt
29      - const: iocfg_rb
30      - const: iocfg_lt
31      - const: iocfg_lb
32      - const: iocfg_tr
33      - const: iocfg_tl
34      - const: eint
35
36  gpio-controller: true
37
38  "#gpio-cells":
39    const: 2
40    description: |
41      Number of cells in GPIO specifier. Since the generic GPIO
42      binding is used, the amount of cells must be specified as 2. See the below
43      mentioned gpio binding representation for description of particular cells.
44
45  gpio-ranges:
46    minItems: 1
47    maxItems: 5
48    description: |
49      GPIO valid number range.
50
51  interrupt-controller: true
52
53  interrupts:
54    maxItems: 1
55
56  "#interrupt-cells":
57    const: 2
58
59allOf:
60  - $ref: "pinctrl.yaml#"
61
62required:
63  - compatible
64  - reg
65  - reg-names
66  - gpio-controller
67  - "#gpio-cells"
68
69patternProperties:
70  '-pins$':
71    type: object
72    additionalProperties: false
73
74    patternProperties:
75      '.*mux.*':
76        type: object
77        additionalProperties: false
78        description: |
79          pinmux configuration nodes.
80
81          The following table shows the effective values of "group", "function"
82          properties and chip pinout pins
83
84          groups	    function    pins (in pin#)
85          ---------------------------------------------------------------------
86          "watchdog"        "watchdog"  0
87          "wifi_led"        "led"       1, 2
88          "i2c"             "i2c"       3, 4
89          "uart1_0"         "uart"      7, 8, 9, 10
90          "pcie_clk"        "pcie"      9
91          "pcie_wake"       "pcie"      10
92          "spi1_0"          "spi"       11, 12, 13, 14
93          "pwm1_1"          "pwm"       20,
94          "pwm0"            "pwm"       21,
95          "pwm1_0"          "pwm"       22,
96          "snfi"            "flash"     23, 24, 25, 26, 27, 28
97          "spi1_2"          "spi"       29, 30, 31, 32
98          "emmc_45"         "emmc"      22, 23, 24, 25, 26, 27, 28, 29, 30,
99                                        31, 32
100          "spi1_1"          "spi"       23, 24, 25, 26
101          "uart1_2"         "uart"      29, 30, 31, 32
102          "uart1_1"         "uart"      23, 24, 25, 26
103          "uart2_0"         "uart"      29, 30, 31, 32
104          "spi0"            "spi"       33, 34, 35, 36
105          "spi0_wp_hold"    "spi"       37, 38
106          "uart1_3_rx_tx"   "uart"      35, 36
107          "uart1_3_cts_rts" "uart"      37, 38
108          "uart2_1"         "uart"      33, 34, 35, 36
109          "spi1_3"          "spi"       33, 34, 35, 36
110          "uart0"           "uart"      39, 40
111          "pcie_pereset"    "pcie"      41
112          "uart1"           "uart"      42, 43, 44, 45
113          "uart2"           "uart"      46, 47, 48, 49
114          "emmc_51"         "emmc"      50, 51, 52, 53, 54, 55, 56, 57, 57,
115                                        59, 60, 61
116          "pcm"             "audio"     62, 63, 64, 65
117          "i2s"             "audio"     62, 63, 64, 65
118          "switch_int"      "eth"       66
119          "mdc_mdio"        "eth"       67
120          "wf_2g"           "wifi"      74, 75, 76, 77, 78, 79, 80, 81, 82, 83
121          "wf_5g"           "wifi"      91, 92, 93, 94, 95, 96, 97, 98, 99, 100
122          "wf_dbdc"         "wifi"      74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
123                                        84, 85
124
125        $ref: "/schemas/pinctrl/pinmux-node.yaml"
126        properties:
127          function:
128            description: |
129              A string containing the name of the function to mux to the group.
130              There is no "audio", "pcie" functions on mt7986b, you can only use
131              those functions on mt7986a.
132            enum: [audio, emmc, eth, i2c, led, flash, pcie, pwm, spi, uart,
133                   watchdog, wifi]
134          groups:
135            description: |
136              An array of strings. Each string contains the name of a group.
137              There is no "pcie_pereset", "uart1", "uart2" "emmc_51", "pcm",
138              and "i2s" groups on mt7986b, you can only use those groups on
139              mt7986a.
140        required:
141          - function
142          - groups
143
144        allOf:
145          - if:
146              properties:
147                function:
148                  const: audio
149            then:
150              properties:
151                groups:
152                  enum: [pcm, i2s]
153          - if:
154              properties:
155                function:
156                  const: emmc
157            then:
158              properties:
159                groups:
160                  enum: [emmc, emmc_rst]
161          - if:
162              properties:
163                function:
164                  const: eth
165            then:
166              properties:
167                groups:
168                  enum: [switch_int, mdc_mdio]
169          - if:
170              properties:
171                function:
172                  const: i2c
173            then:
174              properties:
175                groups:
176                  enum: [i2c]
177          - if:
178              properties:
179                function:
180                  const: led
181            then:
182              properties:
183                groups:
184                  enum: [wifi_led]
185          - if:
186              properties:
187                function:
188                  const: flash
189            then:
190              properties:
191                groups:
192                  enum: [snfi]
193          - if:
194              properties:
195                function:
196                  const: pcie
197            then:
198              properties:
199                groups:
200                  enum: [pcie_clk, pcie_wake, pcie_pereset]
201          - if:
202              properties:
203                function:
204                  const: pwm
205            then:
206              properties:
207                groups:
208                  enum: [pwm0, pwm1_0, pwm1_1]
209          - if:
210              properties:
211                function:
212                  const: spi
213            then:
214              properties:
215                groups:
216                  enum: [spi0, spi0_wp_hold, spi1_0, spi1_1, spi1_2, spi1_3]
217          - if:
218              properties:
219                function:
220                  const: uart
221            then:
222              properties:
223                groups:
224                  enum: [uart1_0, uart1_1, uart1_2, uart1_3_rx_tx,
225                         uart1_3_cts_rts, uart2_0, uart2_1, uart0, uart1, uart2]
226          - if:
227              properties:
228                function:
229                  const: watchdog
230            then:
231              properties:
232                groups:
233                  enum: [watchdog]
234          - if:
235              properties:
236                function:
237                  const: wifi
238            then:
239              properties:
240                groups:
241                  items:
242                    enum: [wf_2g, wf_5g, wf_dbdc]
243                  maxItems: 3
244      '.*conf.*':
245        type: object
246        additionalProperties: false
247        description: |
248          pinconf configuration nodes.
249        $ref: "/schemas/pinctrl/pincfg-node.yaml"
250
251        properties:
252          pins:
253            description: |
254              An array of strings. Each string contains the name of a pin.
255              There is no PIN 41 to PIN 65 above on mt7686b, you can only use
256              those pins on mt7986a.
257            items:
258              enum: [SYS_WATCHDOG, WF2G_LED, WF5G_LED, I2C_SCL, I2C_SDA, GPIO_0,
259                     GPIO_1, GPIO_2, GPIO_3, GPIO_4, GPIO_5, GPIO_6, GPIO_7,
260                     GPIO_8, GPIO_9, GPIO_10, GPIO_11, GPIO_12, GPIO_13, GPIO_14,
261                     GPIO_15, PWM0, PWM1, SPI0_CLK, SPI0_MOSI, SPI0_MISO, SPI0_CS,
262                     SPI0_HOLD, SPI0_WP, SPI1_CLK, SPI1_MOSI, SPI1_MISO, SPI1_CS,
263                     SPI2_CLK, SPI2_MOSI, SPI2_MISO, SPI2_CS, SPI2_HOLD, SPI2_WP,
264                     UART0_RXD, UART0_TXD, PCIE_PERESET_N, UART1_RXD, UART1_TXD,
265                     UART1_CTS, UART1_RTS, UART2_RXD, UART2_TXD, UART2_CTS,
266                     UART2_RTS, EMMC_DATA_0, EMMC_DATA_1, EMMC_DATA_2,
267                     EMMC_DATA_3, EMMC_DATA_4, EMMC_DATA_5, EMMC_DATA_6,
268                     EMMC_DATA_7, EMMC_CMD, EMMC_CK, EMMC_DSL, EMMC_RSTB, PCM_DTX,
269                     PCM_DRX, PCM_CLK, PCM_FS, MT7531_INT, SMI_MDC, SMI_MDIO,
270                     WF0_DIG_RESETB, WF0_CBA_RESETB, WF0_XO_REQ, WF0_TOP_CLK,
271                     WF0_TOP_DATA, WF0_HB1, WF0_HB2, WF0_HB3, WF0_HB4, WF0_HB0,
272                     WF0_HB0_B, WF0_HB5, WF0_HB6, WF0_HB7, WF0_HB8, WF0_HB9,
273                     WF0_HB10, WF1_DIG_RESETB, WF1_CBA_RESETB, WF1_XO_REQ,
274                     WF1_TOP_CLK, WF1_TOP_DATA, WF1_HB1, WF1_HB2, WF1_HB3,
275                     WF1_HB4, WF1_HB0, WF1_HB0_B, WF1_HB5, WF1_HB6, WF1_HB7,
276                     WF1_HB8]
277            maxItems: 101
278
279          bias-disable: true
280
281          bias-pull-up: true
282
283          bias-pull-down: true
284
285          input-enable: true
286
287          input-disable: true
288
289          output-enable: true
290
291          output-low: true
292
293          output-high: true
294
295          input-schmitt-enable: true
296
297          input-schmitt-disable: true
298
299          drive-strength:
300            enum: [2, 4, 6, 8, 10, 12, 14, 16]
301
302          mediatek,pull-up-adv:
303            description: |
304              Valid arguments for 'mediatek,pull-up-adv' are '0', '1', '2', '3'
305              Pull up setings for 2 pull resistors, R0 and R1. Valid arguments
306              are described as below:
307              0: (R1, R0) = (0, 0) which means R1 disabled and R0 disabled.
308              1: (R1, R0) = (0, 1) which means R1 disabled and R0 enabled.
309              2: (R1, R0) = (1, 0) which means R1 enabled and R0 disabled.
310              3: (R1, R0) = (1, 1) which means R1 enabled and R0 enabled.
311            $ref: /schemas/types.yaml#/definitions/uint32
312            enum: [0, 1, 2, 3]
313
314          mediatek,pull-down-adv:
315            description: |
316              Valid arguments for 'mediatek,pull-up-adv' are '0', '1', '2', '3'
317              Pull down setings for 2 pull resistors, R0 and R1. Valid arguments
318              are described as below:
319              0: (R1, R0) = (0, 0) which means R1 disabled and R0 disabled.
320              1: (R1, R0) = (0, 1) which means R1 disabled and R0 enabled.
321              2: (R1, R0) = (1, 0) which means R1 enabled and R0 disabled.
322              3: (R1, R0) = (1, 1) which means R1 enabled and R0 enabled.
323            $ref: /schemas/types.yaml#/definitions/uint32
324            enum: [0, 1, 2, 3]
325
326        required:
327          - pins
328
329additionalProperties: false
330
331examples:
332  - |
333    #include <dt-bindings/interrupt-controller/irq.h>
334    #include <dt-bindings/interrupt-controller/arm-gic.h>
335
336    soc {
337      #address-cells = <2>;
338      #size-cells = <2>;
339      pio: pinctrl@1001f000 {
340        compatible = "mediatek,mt7986a-pinctrl";
341        reg = <0 0x1001f000 0 0x1000>,
342              <0 0x11c30000 0 0x1000>,
343              <0 0x11c40000 0 0x1000>,
344              <0 0x11e20000 0 0x1000>,
345              <0 0x11e30000 0 0x1000>,
346              <0 0x11f00000 0 0x1000>,
347              <0 0x11f10000 0 0x1000>,
348              <0 0x1000b000 0 0x1000>;
349        reg-names = "gpio", "iocfg_rt", "iocfg_rb", "iocfg_lt",
350                    "iocfg_lb", "iocfg_tr", "iocfg_tl", "eint";
351        gpio-controller;
352        #gpio-cells = <2>;
353        gpio-ranges = <&pio 0 0 100>;
354        interrupt-controller;
355        interrupts = <GIC_SPI 225 IRQ_TYPE_LEVEL_HIGH>;
356        interrupt-parent = <&gic>;
357        #interrupt-cells = <2>;
358
359        uart1_pins: uart1-pins {
360          mux {
361            function = "uart";
362            groups = "uart1";
363          };
364        };
365
366        uart2_pins: uart2-pins {
367          mux {
368            function = "uart";
369            groups = "uart2";
370          };
371        };
372
373      };
374    };
375