1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2# Copyright (c) 2020 MediaTek
3%YAML 1.2
4---
5$id: http://devicetree.org/schemas/usb/mediatek,mtu3.yaml#
6$schema: http://devicetree.org/meta-schemas/core.yaml#
7
8title: MediaTek USB3 DRD Controller Device Tree Bindings
9
10maintainers:
11  - Chunfeng Yun <chunfeng.yun@mediatek.com>
12
13allOf:
14  - $ref: "usb-drd.yaml"
15
16description: |
17  The DRD controller has a glue layer IPPC (IP Port Control), and its host is
18  based on xHCI.
19
20properties:
21  compatible:
22    items:
23      - enum:
24          - mediatek,mt2712-mtu3
25          - mediatek,mt8173-mtu3
26          - mediatek,mt8183-mtu3
27          - mediatek,mt8188-mtu3
28          - mediatek,mt8192-mtu3
29          - mediatek,mt8195-mtu3
30      - const: mediatek,mtu3
31
32  reg:
33    items:
34      - description: the registers of device MAC
35      - description: the registers of IP Port Control
36
37  reg-names:
38    items:
39      - const: mac
40      - const: ippc
41
42  interrupts:
43    description:
44      use "interrupts-extended" when the interrupts are connected to the
45      separate interrupt controllers
46    minItems: 1
47    items:
48      - description: SSUSB device controller interrupt
49      - description: optional, wakeup interrupt used to support runtime PM
50
51  interrupt-names:
52    items:
53      - const: device
54      - const: wakeup
55
56  power-domains:
57    description: A phandle to USB power domain node to control USB's MTCMOS
58    maxItems: 1
59
60  clocks:
61    minItems: 1
62    items:
63      - description: Controller clock used by normal mode
64      - description: Reference clock used by low power mode etc
65      - description: Mcu bus clock for register access
66      - description: DMA bus clock for data transfer
67
68  clock-names:
69    minItems: 1
70    items:
71      - const: sys_ck  # required, others are optional
72      - const: ref_ck
73      - const: mcu_ck
74      - const: dma_ck
75
76  phys:
77    description:
78      List of all the USB PHYs used, it's better to keep the sequence
79      as the hardware layout.
80    minItems: 1
81    items:
82      - description: USB2/HS PHY    # required, others are optional
83      - description: USB3/SS(P) PHY
84      - description: USB2/HS PHY    # the following for backward compatible
85      - description: USB3/SS(P) PHY
86      - description: USB2/HS PHY
87      - description: USB3/SS(P) PHY
88      - description: USB2/HS PHY
89      - description: USB3/SS(P) PHY
90      - description: USB2/HS PHY
91
92  vusb33-supply:
93    description: Regulator of USB AVDD3.3v
94
95  vbus-supply:
96    deprecated: true
97    description: |
98      Regulator of USB VBUS5v, needed when supports dual-role mode.
99      Particularly, if use an output GPIO to control a VBUS regulator, should
100      model it as a regulator. See bindings/regulator/fixed-regulator.yaml
101      It's considered valid for compatibility reasons, not allowed for
102      new bindings, and put into a usb-connector node.
103
104  dr_mode:
105    enum: [host, peripheral, otg]
106    default: otg
107
108  maximum-speed:
109    enum: [super-speed-plus, super-speed, high-speed, full-speed]
110
111  resets:
112    maxItems: 1
113
114  "#address-cells":
115    enum: [1, 2]
116
117  "#size-cells":
118    enum: [1, 2]
119
120  ranges: true
121
122  extcon:
123    deprecated: true
124    description: |
125      Phandle to the extcon device detecting the IDDIG state, needed
126      when supports dual-role mode.
127      It's considered valid for compatibility reasons, not allowed for
128      new bindings, and use "usb-role-switch" property instead.
129
130  usb-role-switch:
131    $ref: /schemas/types.yaml#/definitions/flag
132    description: Support role switch.
133    type: boolean
134
135  role-switch-default-mode:
136    enum: [host, peripheral]
137    default: host
138
139  connector:
140    $ref: /schemas/connector/usb-connector.yaml#
141    description:
142      Connector for dual role switch, especially for "gpio-usb-b-connector"
143    type: object
144
145  port:
146    description:
147      Any connector to the data bus of this controller should be modelled
148      using the OF graph bindings specified, if the "usb-role-switch"
149      property is used. See graph.txt
150    $ref: /schemas/graph.yaml#/properties/port
151
152  enable-manual-drd:
153    $ref: /schemas/types.yaml#/definitions/flag
154    description:
155      supports manual dual-role switch via debugfs; usually used when
156      receptacle is TYPE-A and also wants to support dual-role mode.
157    type: boolean
158
159  wakeup-source:
160    description: enable USB remote wakeup, see power/wakeup-source.txt
161    type: boolean
162
163  mediatek,syscon-wakeup:
164    $ref: /schemas/types.yaml#/definitions/phandle-array
165    maxItems: 1
166    description:
167      A phandle to syscon used to access the register of the USB wakeup glue
168      layer between xHCI and SPM, the field should always be 3 cells long.
169    items:
170      items:
171        - description:
172            The first cell represents a phandle to syscon
173        - description:
174            The second cell represents the register base address of the glue
175            layer in syscon
176        - description: |
177            The third cell represents the hardware version of the glue layer,
178            1 - used by mt8173 etc, revision 1 without following IPM rule;
179            2 - used by mt2712 etc, revision 2 with following IPM rule;
180            101 - used by mt8183, specific 1.01;
181            102 - used by mt8192, specific 1.02;
182          enum: [1, 2, 101, 102]
183
184  mediatek,u3p-dis-msk:
185    $ref: /schemas/types.yaml#/definitions/uint32
186    description: The mask to disable u3ports, bit0 for u3port0,
187      bit1 for u3port1, ... etc
188
189  mediatek,u2p-dis-msk:
190    $ref: /schemas/types.yaml#/definitions/uint32
191    description: The mask to disable u2ports, bit0 for u2port0,
192      bit1 for u2port1, ... etc; but can't disable u2port0 if dual role mode
193      is enabled, so will be skipped in this case.
194
195# Required child node when support dual-role
196patternProperties:
197  "^usb@[0-9a-f]+$":
198    type: object
199    $ref: /schemas/usb/mediatek,mtk-xhci.yaml#
200    description:
201      The xhci should be added as subnode to mtu3 as shown in the following
202      example if the host mode is enabled.
203
204dependencies:
205  connector: [ 'usb-role-switch' ]
206  port: [ 'usb-role-switch' ]
207  role-switch-default-mode: [ 'usb-role-switch' ]
208  wakeup-source: [ 'mediatek,syscon-wakeup' ]
209
210required:
211  - compatible
212  - reg
213  - reg-names
214  - interrupts
215  - clocks
216  - clock-names
217
218additionalProperties: false
219
220examples:
221  # Dual role switch by extcon
222  - |
223    #include <dt-bindings/clock/mt8173-clk.h>
224    #include <dt-bindings/interrupt-controller/arm-gic.h>
225    #include <dt-bindings/interrupt-controller/irq.h>
226    #include <dt-bindings/phy/phy.h>
227    #include <dt-bindings/power/mt8173-power.h>
228
229    usb@11271000 {
230        compatible = "mediatek,mt8173-mtu3", "mediatek,mtu3";
231        reg = <0x11271000 0x3000>, <0x11280700 0x0100>;
232        reg-names = "mac", "ippc";
233        interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_LOW>;
234        phys = <&phy_port0 PHY_TYPE_USB3>, <&phy_port1 PHY_TYPE_USB2>;
235        power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
236        clocks = <&topckgen CLK_TOP_USB30_SEL>;
237        clock-names = "sys_ck";
238        vusb33-supply = <&mt6397_vusb_reg>;
239        vbus-supply = <&usb_p0_vbus>;
240        extcon = <&extcon_usb>;
241        dr_mode = "otg";
242        wakeup-source;
243        mediatek,syscon-wakeup = <&pericfg 0x400 1>;
244        #address-cells = <1>;
245        #size-cells = <1>;
246        ranges;
247
248        xhci: usb@11270000 {
249            compatible = "mediatek,mt8173-xhci", "mediatek,mtk-xhci";
250            reg = <0x11270000 0x1000>;
251            reg-names = "mac";
252            interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
253            power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
254            clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
255            clock-names = "sys_ck", "ref_ck";
256            vusb33-supply = <&mt6397_vusb_reg>;
257        };
258    };
259
260  # Dual role switch by gpio-usb-b-connector
261  - |
262    #include <dt-bindings/gpio/gpio.h>
263    #include <dt-bindings/power/mt2712-power.h>
264
265    usb@112c1000 {
266        compatible = "mediatek,mt2712-mtu3", "mediatek,mtu3";
267        reg = <0x112c1000 0x3000>, <0x112d0700 0x0100>;
268        reg-names = "mac", "ippc";
269        interrupts = <GIC_SPI 248 IRQ_TYPE_LEVEL_LOW>;
270        phys = <&u2port2 PHY_TYPE_USB2>;
271        power-domains = <&scpsys MT2712_POWER_DOMAIN_USB2>;
272        clocks = <&topckgen CLK_TOP_USB30_SEL>;
273        clock-names = "sys_ck";
274        dr_mode = "otg";
275        usb-role-switch;
276        #address-cells = <1>;
277        #size-cells = <1>;
278        ranges;
279
280        host0: usb@11270000 {
281            compatible = "mediatek,mt2712-xhci", "mediatek,mtk-xhci";
282            reg = <0x11270000 0x1000>;
283            reg-names = "mac";
284            interrupts = <GIC_SPI 123 IRQ_TYPE_LEVEL_LOW>;
285            power-domains = <&scpsys MT2712_POWER_DOMAIN_USB>;
286            clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
287            clock-names = "sys_ck", "ref_ck";
288        };
289
290        connector {
291            compatible = "gpio-usb-b-connector", "usb-b-connector";
292            type = "micro";
293            id-gpios = <&pio 12 GPIO_ACTIVE_HIGH>;
294            vbus-supply = <&usb_p0_vbus>;
295        };
296    };
297
298  # Dual role switch with type-c
299  - |
300    usb@11201000 {
301        compatible ="mediatek,mt8183-mtu3", "mediatek,mtu3";
302        reg = <0x11201000 0x2e00>, <0x11203e00 0x0100>;
303        reg-names = "mac", "ippc";
304        interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_LOW>;
305        phys = <&u2port0 PHY_TYPE_USB2>;
306        clocks = <&clk26m>;
307        clock-names = "sys_ck";
308        mediatek,syscon-wakeup = <&pericfg 0x400 1>;
309        wakeup-source;
310        dr_mode = "otg";
311        usb-role-switch;
312        role-switch-default-mode = "host";
313        #address-cells = <1>;
314        #size-cells = <1>;
315        ranges;
316
317        host: usb@11200000 {
318            compatible = "mediatek,mt8183-xhci", "mediatek,mtk-xhci";
319            reg = <0x11200000 0x1000>;
320            reg-names = "mac";
321            interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_LOW>;
322            clocks = <&clk26m>;
323            clock-names = "sys_ck";
324        };
325
326        port {
327            usb_role_sw: endpoint {
328                remote-endpoint = <&hs_ep>;
329            };
330        };
331    };
332
333...
334