diff --git a/Documentation/devicetree/bindings/display/apple,dcp-typec-routes.yaml b/Documentation/devicetree/bindings/display/apple,dcp-typec-routes.yaml index 9bd123527b2c8..858a09501e4f6 100644 --- a/Documentation/devicetree/bindings/display/apple,dcp-typec-routes.yaml +++ b/Documentation/devicetree/bindings/display/apple,dcp-typec-routes.yaml @@ -131,6 +131,19 @@ properties: whose connector already has as many mode-switch providers as the Type-C class allows can still offer another tunnel pipeline. + apple,connector-group: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 3 + default: 0 + description: | + The order group of the route's display connector. + Connectors are created group by group, and in a group the + tunnel-only routes' after the others on SoCs that give every + port/pipeline pair a connector of its own (T6050). A port + added to a board gets the next group, so the connectors that + already exist keep their names. All routes to one port + should have the same group. port: $ref: /schemas/graph.yaml#/properties/port required: diff --git a/Documentation/devicetree/bindings/display/apple,dcp.yaml b/Documentation/devicetree/bindings/display/apple,dcp.yaml index 680fc93ef2e5d..62414cd1229d0 100644 --- a/Documentation/devicetree/bindings/display/apple,dcp.yaml +++ b/Documentation/devicetree/bindings/display/apple,dcp.yaml @@ -493,6 +493,18 @@ properties: description: The route carries USB4 DP tunnels only, never a DP Alt Mode display. It is not a Type-C mode-switch. + apple,connector-group: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 3 + default: 0 + description: + The order group of the route's display connector. + Connectors are created group by group, and in a group the + tunnel-only routes' after the others on SoCs that give every + port/pipeline pair a connector of its own (T6050), so a port + added to a board in a new group keeps the existing + connectors' names. port: $ref: /schemas/graph.yaml#/properties/port required: diff --git a/Documentation/devicetree/bindings/firmware/apple,atc-handoff.yaml b/Documentation/devicetree/bindings/firmware/apple,atc-handoff.yaml new file mode 100644 index 0000000000000..00b06d90ca689 --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/apple,atc-handoff.yaml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/firmware/apple,atc-handoff.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Type-C (ATC) port boot ownership handoff interface + +maintainers: + - Dj + +description: | + A Type-C port whose ATC the boot producer may be using, for example as its + USB debug port. The port's devices start disabled. This firmware interface + identifies the port's PHY and the group the producer may enable after + relinquishing USB/debug ownership, proving no DMA was retained, and + supplying the current machine's PHY tunables. Shared providers are + excluded. Older producers leave the group disabled; Linux does not + activate it. + +properties: + compatible: + const: apple,atc-handoff + + apple,phy: + $ref: /schemas/types.yaml#/definitions/phandle + description: | + The port's ATC PHY. It is also a member of apple,devices. + + apple,devices: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 1 + maxItems: 32 + items: + maxItems: 1 + description: | + The port's own devices: its power domains, PHY and mailbox, USB DARTs + and DRD, port controller, USB4 router and its mailbox/NHI/DART, PCIe + tunnel parent/DART/root controller, and display crossbar. Every member + must be disabled until handoff. Do not include providers shared with + other ports, such as the AOP GPIO, AUSS or CIO reset providers. + +required: + - compatible + - apple,phy + - apple,devices + +additionalProperties: false diff --git a/arch/arm64/boot/dts/apple/t6050-j714s-display.dtsi b/arch/arm64/boot/dts/apple/t6050-j714s-display.dtsi index f4bd8b98ea502..a7fb666907ef7 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714s-display.dtsi +++ b/arch/arm64/boot/dts/apple/t6050-j714s-display.dtsi @@ -1,9 +1,15 @@ // SPDX-License-Identifier: GPL-2.0+ OR MIT /* - * J714s external displays: DisplayPort alt mode and USB4 DisplayPort tunnels on the left-front - * and right ports. dcpext0 and dcpext2 drive the DP alt mode and tunnel routes, dcpext1 a third - * tunnel on either port; dcpext3 is the pair for modes that need two pipelines. The left-back - * port (ATC0) is the debug port and is not described. + * J714s external displays: DisplayPort alt mode and USB4 DisplayPort tunnels on all three + * ports. dcpext0 and dcpext2 drive the DP alt mode and tunnel routes, dcpext1 a third tunnel on + * any port; dcpext3 is the pair for modes that need two pipelines. Each DCP's routes are the + * right port (typec0, route@0), the left-front port (typec1, route@1) and the left-back port + * (typec2, route@2). The left-back routes were added last: connector group 1 gives their + * connectors the names after the other ports' (DP-7..DP-9), so DP-1..DP-6 keep theirs. + * Every DCP lists all three ports' PHYs and crossbars. A route whose PHY or crossbar node is + * disabled is left out. A PHY that is enabled but fails to probe holds every dcpext until + * deferred probing gives up (about 10 s); they then join the display subsystem as unusable + * pipes with no route: the panel works, and no external display does, on any port. * Addresses and interrupts are from the J714sAP ADT. The boot loader hands each engine over: it * enables the engine, its mailbox and DARTs, publishes its bandwidth scratch and adds its * display DART to the display subsystem. @@ -14,30 +20,32 @@ apple,connector-type = "USB-C"; apple,dptx-die = <0>; /* - * A third pipeline for USB4 DP tunnels on the right and left-front - * ports, so a dock on either can drive three displays as on macOS. + * A third pipeline for USB4 DP tunnels on every port, so a dock on any + * of them can drive three displays as on macOS. * Routing dcpext1 stops it being a merged-mode peer; dcpext0, dcpext1 * and dcpext2 then pair with dcpext3, so only one display wider than * one pipeline runs at a time. - * Crossbar source 2 (dispext1 port 0) on both crossbars follows the + * Crossbar source 2 (dispext1 port 0) on all three crossbars follows the * 2 * dispext pattern of dcpext0 (0) and dcpext2 (4), and the T6040 * dcpext1 (2). - * No mode-switch: hpm1 and hpm2 already have TYPEC_MUX_MAX_DEVS (3) - * mode-switch providers each (the ATC PHY, dcpext0 and dcpext2); + * No mode-switch: hpm0, hpm1 and hpm2 already have TYPEC_MUX_MAX_DEVS + * (3) mode-switch providers each (the ATC PHY, dcpext0 and dcpext2); * tunnels find the port through the endpoint, not the mux. * apple,tunnel-only keeps DP alt mode displays off it: only tunnels * have been driven through it. */ - apple,typec-dptx-phys = <2 1>; - apple,typec-mux-indices = <2 2>; - phys = <&atc2_phy 6>, <&atc1_phy 6>; - phy-names = "typec0", "typec1"; + apple,typec-dptx-phys = <2 1 0>; + apple,typec-mux-indices = <2 2 2>; + phys = <&atc2_phy 6>, <&atc1_phy 6>, <&atc0_phy 6>; + phy-names = "typec0", "typec1", "typec2"; mux-controls = <&atc2_xbar 0>, <&atc2_xbar 1>, <&atc2_xbar 2>, <&atc2_xbar 3>, <&atc2_xbar 4>, <&atc1_dpxbar 0>, <&atc1_dpxbar 1>, <&atc1_dpxbar 2>, - <&atc1_dpxbar 3>, <&atc1_dpxbar 4>; + <&atc1_dpxbar 3>, <&atc1_dpxbar 4>, <&atc0_dpxbar 0>, <&atc0_dpxbar 1>, + <&atc0_dpxbar 2>, <&atc0_dpxbar 3>, <&atc0_dpxbar 4>; mux-control-names = "typec0", "typec0-dpin0", "typec0-dpin1", "typec0-dpin2", "typec0-dpin3", "typec1", "typec1-dpin0", "typec1-dpin1", - "typec1-dpin2", "typec1-dpin3"; + "typec1-dpin2", "typec1-dpin3", "typec2", "typec2-dpin0", + "typec2-dpin1", "typec2-dpin2", "typec2-dpin3"; typec-routes { #address-cells = <1>; @@ -64,6 +72,18 @@ }; }; }; + + route@2 { + reg = <2>; + apple,tunnel-only; + apple,connector-group = <1>; + + port { + dcpext1_left_back: endpoint { + remote-endpoint = <&typec2_dp2>; + }; + }; + }; }; }; @@ -71,16 +91,18 @@ apple,dcp-index = <3>; apple,connector-type = "USB-C"; apple,dptx-die = <0>; - apple,typec-dptx-phys = <2 1>; - apple,typec-mux-indices = <4 4>; - phys = <&atc2_phy 6>, <&atc1_phy 6>; - phy-names = "typec0", "typec1"; + apple,typec-dptx-phys = <2 1 0>; + apple,typec-mux-indices = <4 4 4>; + phys = <&atc2_phy 6>, <&atc1_phy 6>, <&atc0_phy 6>; + phy-names = "typec0", "typec1", "typec2"; mux-controls = <&atc2_xbar 0>, <&atc2_xbar 1>, <&atc2_xbar 2>, <&atc2_xbar 3>, <&atc2_xbar 4>, <&atc1_dpxbar 0>, <&atc1_dpxbar 1>, <&atc1_dpxbar 2>, - <&atc1_dpxbar 3>, <&atc1_dpxbar 4>; + <&atc1_dpxbar 3>, <&atc1_dpxbar 4>, <&atc0_dpxbar 0>, <&atc0_dpxbar 1>, + <&atc0_dpxbar 2>, <&atc0_dpxbar 3>, <&atc0_dpxbar 4>; mux-control-names = "typec0", "typec0-dpin0", "typec0-dpin1", "typec0-dpin2", "typec0-dpin3", "typec1", "typec1-dpin0", "typec1-dpin1", - "typec1-dpin2", "typec1-dpin3"; + "typec1-dpin2", "typec1-dpin3", "typec2", "typec2-dpin0", + "typec2-dpin1", "typec2-dpin2", "typec2-dpin3"; typec-routes { #address-cells = <1>; @@ -107,6 +129,18 @@ }; }; }; + + route@2 { + reg = <2>; + mode-switch; + apple,connector-group = <1>; + + port { + dcpext2_left_back: endpoint { + remote-endpoint = <&typec2_dp1>; + }; + }; + }; }; }; @@ -117,16 +151,18 @@ }; &dcpext0 { - apple,typec-dptx-phys = <2 1>; - apple,typec-mux-indices = <0 0>; - phys = <&atc2_phy 6>, <&atc1_phy 6>; - phy-names = "typec0", "typec1"; + apple,typec-dptx-phys = <2 1 0>; + apple,typec-mux-indices = <0 0 0>; + phys = <&atc2_phy 6>, <&atc1_phy 6>, <&atc0_phy 6>; + phy-names = "typec0", "typec1", "typec2"; mux-controls = <&atc2_xbar 0>, <&atc2_xbar 1>, <&atc2_xbar 2>, <&atc2_xbar 3>, <&atc2_xbar 4>, <&atc1_dpxbar 0>, <&atc1_dpxbar 1>, <&atc1_dpxbar 2>, - <&atc1_dpxbar 3>, <&atc1_dpxbar 4>; + <&atc1_dpxbar 3>, <&atc1_dpxbar 4>, <&atc0_dpxbar 0>, <&atc0_dpxbar 1>, + <&atc0_dpxbar 2>, <&atc0_dpxbar 3>, <&atc0_dpxbar 4>; mux-control-names = "typec0", "typec0-dpin0", "typec0-dpin1", "typec0-dpin2", "typec0-dpin3", "typec1", "typec1-dpin0", "typec1-dpin1", - "typec1-dpin2", "typec1-dpin3"; + "typec1-dpin2", "typec1-dpin3", "typec2", "typec2-dpin0", + "typec2-dpin1", "typec2-dpin2", "typec2-dpin3"; typec-routes { route@0 { @@ -143,6 +179,18 @@ }; }; }; + + route@2 { + reg = <2>; + mode-switch; + apple,connector-group = <1>; + + port { + dcpext0_left_back: endpoint { + remote-endpoint = <&typec2_dp0>; + }; + }; + }; }; }; @@ -199,6 +247,31 @@ }; }; +&typec2 { + ports { + port@2 { + reg = <2>; + #address-cells = <1>; + #size-cells = <0>; + + typec2_dp0: endpoint@0 { + reg = <0>; + remote-endpoint = <&dcpext0_left_back>; + }; + + typec2_dp1: endpoint@1 { + reg = <1>; + remote-endpoint = <&dcpext2_left_back>; + }; + + typec2_dp2: endpoint@2 { + reg = <2>; + remote-endpoint = <&dcpext1_left_back>; + }; + }; + }; +}; + /* Scanout and PIODMA share the first register window, as on dispext0 */ &dispext1_dart { reg = <0x3 0x92300000 0x0 0xc000>; @@ -254,6 +327,29 @@ status = "okay"; }; +/* The left-back crossbar (the inventory's, as atc1_dpxbar) and the PHY's tunnel clock gates */ +&atc0_dpxbar { + power-domains = <&ps_atc0_usb_aon>, <&ps_atc0_common>; + power-domain-names = "usb-aon", "common"; + status = "disabled"; +}; + +&ps_atc0_common_dp_0 { + status = "disabled"; +}; + +&ps_atc0_common_dp_1 { + status = "disabled"; +}; + +&ps_atc0_common_dp_2 { + status = "disabled"; +}; + +&ps_atc0_common_dp_3 { + status = "disabled"; +}; + &atc2_phy { reg = <0x3 0x83000000 0x0 0x2c000>, <0x3 0x82a90000 0x0 0x4000>, @@ -298,6 +394,14 @@ power-domain-names = "usb-aon", "common", "wrapper", "usb", "dp0", "dp1", "dp2", "dp3"; }; +/* The left-back PHY's tunnel clock gates, as the other ports' */ +&atc0_phy { + power-domains = <&ps_atc0_usb_aon>, <&ps_atc0_common>, <&ps_atc0_phymxwrap>, + <&ps_atc0_usb>, <&ps_atc0_common_dp_0>, <&ps_atc0_common_dp_1>, + <&ps_atc0_common_dp_2>, <&ps_atc0_common_dp_3>; + power-domain-names = "usb-aon", "common", "wrapper", "usb", "dp0", "dp1", "dp2", "dp3"; +}; + /* The right router's DP IN interrupts (ADT atc2-dpin0..3) */ &acio2 { interrupts = , , diff --git a/arch/arm64/boot/dts/apple/t6050-j714s-left-back.dtsi b/arch/arm64/boot/dts/apple/t6050-j714s-left-back.dtsi new file mode 100644 index 0000000000000..e9de93f3d042d --- /dev/null +++ b/arch/arm64/boot/dts/apple/t6050-j714s-left-back.dtsi @@ -0,0 +1,727 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * J714s left-back USB-C port (ATC0), next to MagSafe: USB 2/3, the PD controller, and the + * USB4/Thunderbolt router and its PCIe tunnel. + * + * ADT /arm-io/nub-spmi-a0/hpm0 (SN201202x at 0xc), atc-phy0, acio-phy-cpu0, usb-drd0 and + * dart-usb0; acio0, acio-cpu0, dart-acio0, apciec0 and dart-apciec0. They are the left-front + * port's (ATC1, t6050-j714s-left-usb4.dtsi) at its addresses and interrupts, as J716c + * describes its ATC0 (t6050-j716c-left-usb4.dtsi) and as in the T6050 inventory + * (t6050-peripherals.dtsi): every ATC0 register block is ATC1's less 0x8000000, every + * interrupt ATC1's less 32 (the PHY's and the router CPU's mailboxes' less 10). + * + * This is Apple's debug (DFU) port, as the ADT marks it (hpm0's uart-hpm-rids, usb-drd0's NCM + * debug gadget settings), and the boot loader's debug link: the console (serial0, the + * dockchannel UART) and, on request, its USB proxy, whose USB2 route it sets with one DVEn + * action in a short DBMa session. Describing the port hands it to Linux: tipd, the PHY and the + * DRD's role switch then decide what the USB2 pair carries, and genpd may power the port's + * domains off while unused. Every ATC0 device starts disabled. Aura may enable the + * handoff group only after excluding debug/proxy ownership, proving USB DMA stopped, + * and exporting this machine's ADT tunables. Older producers leave the port reserved. + */ + +/* + * The inventory gives ATC0_COMMON the FAB3 SoC domain as a parent, which is not described here. + * ATC1's and ATC2's common domains have none: do the same. J716c enables ps_fab3_soc instead, + * which would hand that fabric domain, and its other undescribed users, to genpd's unused + * power-off; left out, it stays as the boot loader leaves it, on. + */ +&ps_atc0_common { + /delete-property/ power-domains; + status = "disabled"; +}; + +&ps_atc0_usb_aon { + status = "disabled"; +}; + +&ps_atc0_usb { + status = "disabled"; +}; + +&ps_atc0_phymxwrap { + status = "disabled"; +}; + +&{/soc@200000000} { + /* acio-phy-cpu0 reg[0]: the PHY firmware's mailbox (it runs, pre-loaded by iBoot) */ + atc0_phy_mbox: mailbox@2a3148000 { + status = "disabled"; + compatible = "apple,t6050-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x2 0xa3148000 0x0 0x4000>; + interrupts = , + , + , + ; + interrupt-names = "send-empty", "send-not-empty", "recv-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; + + /* + * atc-phy0 regs [2] [0] usb-drd0[4] [39] [40] [41] [42] [43] [38] [37] usb-drd0[3], and + * the DP clock source register: ATC1's (0x58) less 0x10, as J716c's atc0_phy (the ADT + * does not give the per-port address). + */ + atc0_phy: phy@2a3000000 { + status = "disabled"; + compatible = "apple,t6050-combo-phy"; + reg = <0x2 0xa3000000 0x0 0x2c000>, + <0x2 0xa2a90000 0x0 0x4000>, + <0x2 0xa2800000 0x0 0x4000>, + <0x2 0xa3200000 0x0 0x4000>, + <0x2 0xa3244000 0x0 0x4000>, + <0x2 0xa0000000 0x0 0x8000>, + <0x2 0xa0020000 0x0 0x4000>, + <0x2 0xa3250000 0x0 0x4000>, + <0x2 0xa3140000 0x0 0x4000>, + <0x2 0xa30c0000 0x0 0x10000>, + <0x2 0xa2a84000 0x0 0x4000>, + <0x2 0x80000048 0x0 0x10>; + reg-names = "core", "usb2phy", "usb2-digital", "reset", "fabric", "axi2af", "lioa", + "common-cfg", "usb-control", "firmware-data", "pipehandler", + "dp-clock-source"; + #phy-cells = <1>; + #reset-cells = <1>; + apple,port-index = <0>; + mode-switch; + orientation-switch; + mboxes = <&atc0_phy_mbox>; + power-domains = <&ps_atc0_usb_aon>, <&ps_atc0_common>, <&ps_atc0_phymxwrap>, + <&ps_atc0_usb>; + power-domain-names = "usb-aon", "common", "wrapper", "usb"; + + port { + atc0_phy_typec: endpoint { + remote-endpoint = <&typec2_ss>; + }; + }; + }; +}; + +/* /arm-io/dart-usb0 reg[0] and reg[1], interrupt 1423; vm-base 0x10000004000 +0xffff0000 */ +&usb0_dart { + apple,dma-range = <0x100 0x4000 0x0 0xffff0000>; + status = "disabled"; +}; + +&usb0_dart1 { + apple,dma-range = <0x100 0x4000 0x0 0xffff0000>; + status = "disabled"; +}; + +/* + * /arm-io/usb-drd0: the inventory's registers and interrupt (1419), with usb-drd1's setup and + * tunables (the DRD tables are the same on every port, as on J716c). + */ +&usb_drd0 { + dr_mode = "otg"; + usb-role-switch; + role-switch-default-mode = "host"; + resets = <&atc0_phy 0>; + phys = <&atc0_phy PHY_TYPE_USB2>, <&atc0_phy PHY_TYPE_USB3>; + phy-names = "usb2-phy", "usb3-phy"; + apple,tunable-gbl-default = <0x64 0x2 0x0>, <0x10 0xfff80000 0x00680000>; + apple,tunable-gbl-host = <0x4 0x0001ef00 0x00002f00>, <0x1c 0x00000100 0x0>, + <0x2c 0x000a07ff 0x000800c8>, <0x100 0x02000100 0x02000100>, + <0x504 0x00001000 0x0>, <0x528 0xff0000ff 0x06000006>, + <0x52c 0xff0000ff 0x08000008>, <0x580 0xffffffff 0x6f000006>, + <0x584 0xffffffff 0x00060000>; + apple,tunable-dbg = <0x0 0x8 0x8>; + apple,tunable-cfg-host = <0x20 0xff 0x1b>; + apple,tunable-link = <0x10 0xff000000 0xff000000>, <0x20 0x7ff00000 0x4e900000>, + <0x24 0x001f8000 0x000b8000>, <0x60 0x0003ffff 0x00000600>; + apple,tunable-cio = <0x20 0x00ff0000 0x001e0000>; + status = "disabled"; + + port { + usb_drd0_hs: endpoint { + remote-endpoint = <&typec2_hs>; + }; + }; +}; + +/* + * typec2: the third connector, after the right (typec0) and left-front (typec1) ports, so + * those keep their names. + */ +&nub_spmi_a0 { + hpm0: usb-pd@c { + status = "disabled"; + compatible = "apple,sn201202x"; + reg = <0xc SPMI_USID>; + + typec2: connector { + compatible = "usb-c-connector"; + label = "USB-C Left-back"; + power-role = "dual"; + data-role = "dual"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + typec2_hs: endpoint { + remote-endpoint = <&usb_drd0_hs>; + }; + }; + + port@1 { + reg = <1>; + typec2_ss: endpoint { + remote-endpoint = <&atc0_phy_typec>; + }; + }; + }; + }; + }; +}; + +/* All per-machine PHY tables are supplied by aura only at a successful handoff. */ + +/* ==== The USB4/Thunderbolt router and its PCIe tunnel ==== */ + +&ps_atc0_cio { + power-domains = <&ps_atc0_common>; + status = "disabled"; +}; + +&ps_atc0_cio_pcie { + power-domains = <&ps_atc0_cio>; + status = "disabled"; +}; + +&ps_atc0_cio_usb { + power-domains = <&ps_atc0_cio>; + status = "disabled"; +}; + +&ps_atc0_cio_auss { + power-domains = <&ps_atc0_cio>, <&ps_auss>; + status = "disabled"; +}; + +/* With the ATC0 USB always-on clock gate, as ATC1_PCIE and ATC2_PCIE */ +&ps_atc0_pcie { + power-domains = <&ps_atc0_common>, <&ps_atc0_usb_aon>; + status = "disabled"; +}; + +/* LSTX: AOP GPIO pin 77 (0x4d), function 1 for the router, as J716c's acio0 */ +&pinctrl_aop { + acio0_lstx_pins: acio0-lstx-pins { + pinmux = <0x1004d>; /* APPLE_PINMUX(77, 1) */ + }; +}; + +&{/soc@200000000} { + /* /arm-io/acio-cpu0 reg[0]: the router CPU's mailbox, inside its wrapper */ + acio0_mbox: mailbox@2a1108000 { + status = "disabled"; + compatible = "apple,t6050-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x2 0xa1108000 0x0 0x4000>; + interrupts = , + , + , + ; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; + + acio0: acio@2a1ac0000 { + status = "disabled"; + compatible = "apple,t6050-usb4-acio"; + reg = <0x2 0xa1ac0000 0x0 0xc000>, + <0x2 0xa1080000 0x0 0x26000>, + <0x2 0xa1e44000 0x0 0x4000>, + <0x2 0xa1100000 0x0 0x4000>, + <0x2 0xa1c80000 0x0 0x4000>; + reg-names = "rc", "sram", "pcie-adapter", "cpu", "router-ap-fw"; + mboxes = <&acio0_mbox>; + resets = <&cio_reconfig0 0>; + /* ATC0_PCIE last: the PCIe tunnel root port, set up before it is populated */ + power-domains = <&ps_atc0_cio>, <&ps_atc0_cio_pcie>, + <&ps_atc0_cio_usb>, <&ps_atc0_cio_auss>, <&ps_atc0_pcie>; + thunderbolt-switch; + apple,pcie-tunnel = <&acio0_pcie_tunnel>; + pinctrl-0 = <&acio0_lstx_pins>; + pinctrl-names = "lstx"; + lstx-gpios = <&pinctrl_aop 77 GPIO_ACTIVE_HIGH>; + + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x2 0xa1000000 0x1000000>; + nonposted-mmio; + + acio0_dart: iommu@a80000 { + status = "disabled"; + compatible = "apple,t6050-dart", "apple,t8110-dart"; + reg = <0xa80000 0xc000>; + interrupts = ; + power-domains = <&ps_atc0_cio>; + #iommu-cells = <1>; + apple,dma-range = <0x100 0x4000 0x0 0xffff0000>; + apple,bypass-sids = <15>; + apple,full-error-reporting; + apple,ctc-flush; + }; + + /* Interrupts 0x62b.. (1579) are the TX rings and 0x637.. (1591) the RX rings */ + acio0_nhi: nhi@f00000 { + status = "disabled"; + compatible = "apple,t6050-usb4-nhi"; + reg = <0xf00000 0x100000>; + reg-names = "nhi"; + interrupts = , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names = "txring0", "txring1", "txring2", "txring3", + "txring4", "txring5", "txring6", "txring7", + "txring8", "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", "rxring3", + "rxring4", "rxring5", "rxring6", "rxring7", + "rxring8", "rxring9", "rxring10", "rxring11", + "parity"; + iommus = <&acio0_dart 0>, + <&acio0_dart 1>, + <&acio0_dart 2>, + <&acio0_dart 3>, + <&acio0_dart 4>, + <&acio0_dart 5>, + <&acio0_dart 6>, + <&acio0_dart 7>, + <&acio0_dart 8>, + <&acio0_dart 9>, + <&acio0_dart 10>, + <&acio0_dart 11>, + <&acio0_dart 16>, + <&acio0_dart 17>, + <&acio0_dart 18>, + <&acio0_dart 19>, + <&acio0_dart 20>, + <&acio0_dart 21>, + <&acio0_dart 22>, + <&acio0_dart 23>, + <&acio0_dart 24>, + <&acio0_dart 25>, + <&acio0_dart 26>, + <&acio0_dart 27>; + }; + }; +}; + +/* + * ATC0's PCIe tunnel: /arm-io/apciec0 and dart-apciec0, the PCIe-C root port behind the router's + * PCIe down adapter, set up as ATC1's. Its config space and windows are J716c's apciec0's, below + * ATC1's; MSIs use the bridge's 32-vector slice (128-159) and PCI domain 1, both unused so far. + */ +/ { + acio0_pcie_tunnel: pcie-tunnel-0 { + status = "disabled"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + nonposted-mmio; + + apciec0_dart: iommu@2a4000000 { + status = "disabled"; + compatible = "apple,t6050-dart", "apple,t8110-dart"; + reg = <0x2 0xa4000000 0x0 0x20000>; + interrupts = ; + power-domains = <&ps_atc0_pcie>; + #iommu-cells = <1>; + apple,bypass-sids = <253 255>; + apple,full-error-reporting; + apple,ctc-flush; + }; + + apciec0: pcie@1c50000000 { + status = "disabled"; + compatible = "apple,t6050-pciec"; + device_type = "pci"; + reg = <0x1c 0x50000000 0x0 0x10000000>, + <0x2 0xa4034000 0x0 0x4000>, + <0x2 0xa4020000 0x0 0x8000>, + <0x2 0xa4038000 0x0 0x4000>, + <0x2 0xa4060000 0x0 0x4000>, + <0x2 0xa402c000 0x0 0x4000>, + <0x2 0xa4028000 0x0 0x4000>; + reg-names = "config", "rc", "port0", "fabric", "debug", "ltssm", "intr2axi"; + /* The port's: link events and INTx */ + interrupts = ; + power-domains = <&ps_atc0_pcie>; + /* No boot loader hands the port over: the kernel cold-initializes it. */ + apple,pciec-kernel-init; + + msi-controller; + msi-parent = <&apciec0>; + msi-ranges = <&aic AIC_IRQ 0 1952 IRQ_TYPE_EDGE_RISING 32>; + apple,msi-vector-base = <128>; + + iommu-map = <0x0 &apciec0_dart 0x0 0x40>; + iommu-map-mask = <0x3f>; + linux,pci-domain = <1>; + bus-range = <0x0 0x7f>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x43000000 0x8 0x0 0x8 0x0 0x2 0x0>, + <0x02000000 0x0 0x00100000 0xa 0x00100000 0x0 0x3ff00000>, + <0x42000000 0x0 0x40000000 0xa 0x40000000 0x0 0x40000000>; + + apciec0_port: pci@0,0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + external-facing; + + #address-cells = <3>; + #size-cells = <2>; + ranges; + + interrupt-controller; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &apciec0_port 0 0 0 0>, + <0 0 0 2 &apciec0_port 0 0 0 1>, + <0 0 0 3 &apciec0_port 0 0 0 2>, + <0 0 0 4 &apciec0_port 0 0 0 3>; + }; + }; + }; +}; + +/* + * The PHY's CIO80 RX_TOP tunables (ADT atc-phy0 tunable_LN0/LN1_RX_TOP_CIO_DFLT): 0x200, as on + * the left-front port (the right port's is 0x0). + */ +&atc0_phy { + apple,tunable-lane0-rx-top-cio = <0x35c 0xe00 0x200>; + apple,tunable-lane1-rx-top-cio = <0x35c 0xe00 0x200>; +}; + +&typec2 { + ports { + port@3 { + reg = <3>; + typec2_usb4: endpoint { + remote-endpoint = <&acio0_tbt>; + }; + }; + }; +}; + +/* + * The router's tunables and its DP IN interrupts (atc0-dpin0..3 in the T6050 inventory, as J716c's + * acio0). The router, NHI, DART and tunnel tunables are the same on ATC1 and ATC2 here and on + * J716c's ATC0 and ATC1. + */ +&acio0 { + interrupts = , , + , ; + interrupt-names = "dpin0", "dpin1", "dpin2", "dpin3"; + apple,tunable-rc = <0x0 0xfff0 0x4020>, + <0x2c 0x4 0x0>, + <0x4004 0x1ff01ff 0x1000100>, + <0x4008 0x801f 0x4>, + <0x4010 0x7f 0x40>, + <0x4014 0x801f 0x4>, + <0x401c 0x7f 0x40>, + <0x4024 0x801f 0x4>, + <0x402c 0x7f 0x40>, + <0x4030 0x801f 0x4>, + <0x4038 0xffffffff 0x1010101>, + <0x403c 0xffff 0x101>, + <0x4040 0x1 0x1>, + <0x4044 0xffffffff 0x1010101>, + <0x4048 0x1 0x1>, + <0x404c 0x801f 0x4>, + <0x8004 0x70007 0x40004>, + <0x8008 0x801f 0x4>, + <0x8010 0x70007 0x40004>, + <0x8018 0x801f 0x4>, + <0x8020 0x70007 0x40004>, + <0x8028 0x801f 0x4>, + <0x8030 0x801f 0x4>, + <0x8038 0x801f 0x4>, + <0x8040 0x801f 0x4>, + <0x8048 0x801f 0x4>, + <0x8050 0x801f 0x4>, + <0x8058 0x801f 0x4>, + <0x8060 0x801f 0x4>; + apple,tunable-pcie-adapter = <0x1008 0x6 0x6>; + apple,tunable-router-ap-fw = <0x8 0xff2 0x482>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + acio0_tbt: endpoint { + remote-endpoint = <&typec2_usb4>; + }; + }; + }; +}; + +&acio0_dart { + apple,tunable = <0x20c 0x80000121 0x80000121>, + <0x220 0xf0f 0xf0f>, + <0x224 0xffff 0x909>, + <0x300 0x1f31 0x1>, + <0x308 0x3ffffffc 0x10000000>, + <0x310 0x3ffffffc 0x3ffffffc>, + <0x800 0xf003f 0x10000>, + <0x804 0xf003f 0x10002>, + <0x808 0xf003f 0x10004>, + <0x80c 0xf003f 0x20006>, + <0x810 0xf003f 0x2000a>, + <0x814 0xf003f 0x2000e>, + <0x818 0xf003f 0x20012>, + <0x81c 0xf003f 0x20016>, + <0x820 0xf003f 0x2001a>, + <0x824 0xf003f 0x2001e>, + <0x828 0xf003f 0x20022>, + <0x82c 0xf003f 0x20026>, + <0x830 0xf003f 0x2002a>, + <0x834 0xf003f 0x2002e>, + <0x838 0xf003f 0x20032>, + <0x83c 0xf003f 0x10036>; +}; + +/* + * The host DROM: the J714sAP ADT's /arm-io/acio0 thunderbolt-drom (acio1's with the router's + * port entries for port 0 and UID 0). The boot loader does not replace it on this board (no + * usb4_N_nhi alias). + */ +&acio0_nhi { + apple,tunable-nhi = <0xf8004 0xff 0x80>, + <0xf8008 0x801f 0x4>, + <0xf8010 0x3f 0x20>, + <0xf8014 0x801f 0x4>, + <0xf801c 0x1f 0x10>, + <0xf8020 0x801f 0x4>, + <0xf8028 0xff 0x80>, + <0xf802c 0x801f 0x4>, + <0xf8034 0xff 0x80>, + <0xf8038 0x801f 0x4>, + <0xf8040 0x3f 0x20>, + <0xf8044 0x801f 0x4>, + <0xf804c 0x8007 0x1>, + <0xfc004 0x3 0x2>, + <0xfc008 0x801f 0x4>, + <0xfc010 0x7 0x4>, + <0xfc014 0x801f 0x4>, + <0xfc01c 0x7 0x4>, + <0xfc020 0x801f 0x4>, + <0xfc028 0x7 0x4>, + <0xfc02c 0x801f 0x4>, + <0xfc034 0x7 0x4>, + <0xfc038 0x801f 0x4>, + <0xfc040 0x3 0x2>, + <0xfc044 0x801f 0x4>, + <0xfc04c 0x8007 0x1>, + <0x4000 0x1000000f 0x10000002>, + <0x4004 0x1000000f 0x10000002>, + <0x4008 0x1000000f 0x10000002>, + <0x400c 0x1000000f 0x10000002>, + <0x4010 0x1000000f 0x10000002>, + <0x4014 0x1000000f 0x10000002>, + <0x4018 0x1000000f 0x10000002>, + <0x401c 0x1000000f 0x10000002>, + <0x4020 0x1000000f 0x10000002>, + <0x4024 0x1000000f 0x10000002>, + <0x4028 0x1000000f 0x10000002>, + <0x402c 0x1000000f 0x10000002>, + <0x4040 0x1000000f 0x10000002>, + <0x4044 0x1000000f 0x10000002>, + <0x4048 0x1000000f 0x10000002>, + <0x404c 0x1000000f 0x10000002>, + <0x4050 0x1000000f 0x10000002>, + <0x4054 0x1000000f 0x10000002>, + <0x4058 0x1000000f 0x10000002>, + <0x405c 0x1000000f 0x10000002>, + <0x4060 0x1000000f 0x10000002>, + <0x4064 0x1000000f 0x10000002>, + <0x4068 0x1000000f 0x10000002>, + <0x406c 0x1000000f 0x10000002>, + <0x4080 0x1000000f 0x10000002>, + <0x4084 0x1000000f 0x10000002>, + <0x4088 0x1000000f 0x10000002>, + <0x408c 0x1000000f 0x10000002>, + <0x4090 0x1000000f 0x10000002>, + <0x4094 0x1000000f 0x10000002>, + <0x4098 0x1000000f 0x10000002>, + <0x409c 0x1000000f 0x10000002>, + <0x40a0 0x1000000f 0x10000002>, + <0x40a4 0x1000000f 0x10000002>, + <0x40a8 0x1000000f 0x10000002>, + <0x40ac 0x1000000f 0x10000002>, + <0x40c0 0x1000000f 0x10000002>, + <0x40c4 0x1000000f 0x10000002>, + <0x40c8 0x1000000f 0x10000002>, + <0x40cc 0x1000000f 0x10000002>, + <0x40d0 0x1000000f 0x10000002>, + <0x40d4 0x1000000f 0x10000002>, + <0x40d8 0x1000000f 0x10000002>, + <0x40dc 0x1000000f 0x10000002>, + <0x40e0 0x1000000f 0x10000002>, + <0x40e4 0x1000000f 0x10000002>, + <0x40e8 0x1000000f 0x10000002>, + <0x40ec 0x1000000f 0x10000002>, + <0x4100 0x1000000f 0x10000002>, + <0x4104 0x1000000f 0x10000002>, + <0x4108 0x1000000f 0x10000002>, + <0x410c 0x1000000f 0x10000002>, + <0x4110 0x1000000f 0x10000002>, + <0x4114 0x1000000f 0x10000002>, + <0x4118 0x1000000f 0x10000002>, + <0x411c 0x1000000f 0x10000002>, + <0x4120 0x1000000f 0x10000002>, + <0x4124 0x1000000f 0x10000002>, + <0x4128 0x1000000f 0x10000002>, + <0x412c 0x1000000f 0x10000002>, + <0x4140 0x1000000f 0x10000002>, + <0x4144 0x1000000f 0x10000002>, + <0x4148 0x1000000f 0x10000002>, + <0x414c 0x1000000f 0x10000002>, + <0x4150 0x1000000f 0x10000002>, + <0x4154 0x1000000f 0x10000002>, + <0x4158 0x1000000f 0x10000002>, + <0x415c 0x1000000f 0x10000002>, + <0x4160 0x1000000f 0x10000002>, + <0x4164 0x1000000f 0x10000002>, + <0x4168 0x1000000f 0x10000002>, + <0x416c 0x1000000f 0x10000002>, + <0x43e4 0x7 0x7>; + apple,thunderbolt-drom = [db 00 00 00 00 00 00 00 00 c0 49 a7 a6 00 5c 00 + 00 00 00 00 00 00 08 81 80 02 80 00 00 00 08 82 + 90 01 80 00 00 00 03 83 20 08 84 00 00 00 00 00 + 00 08 85 00 00 00 00 00 00 05 86 09 01 00 08 87 + 00 00 00 00 00 00 05 88 09 01 00 05 89 09 01 00 + 05 8a 09 01 00 0e 01 41 70 70 6c 65 2c 20 49 6e + 63 2e 00 06 02 69 4f 53 00 00 00 00]; +}; + +/* The tunnel's tunables: ATC1's and ATC2's, and J716c's ATC0's */ +&apciec0_dart { + apple,tunable = <0x20c 0x80000121 0x80000121>, + <0x220 0xf0f 0xf0f>, + <0x224 0xffff 0x909>, + <0x300 0x1f31 0x1>, + <0x308 0x3ffffffc 0x10000000>, + <0x310 0x3ffffffc 0x3ffffffc>; +}; + +&apciec0 { + apple,tunable-debug = <0x1000 0x1 0x0>; + apple,tunable-rc = <0x78 0x7000 0x0>, + <0x718 0x7c000 0x0>, + <0x814 0xffffffff 0x2020f060>, + <0x8bc 0x1 0x0>; + apple,tunable-fabric = <0x4 0x3f003f 0x240024>, + <0x8 0x1 0x1>, + <0xc 0x1 0x1>, + <0x10 0x801f 0x4>, + <0x18 0x1ff 0x1e0>, + <0x1c 0x1 0x1>, + <0x20 0x801f 0x4>, + <0x28 0x1f 0x10>, + <0x2c 0x801f 0x4>, + <0x34 0x3f 0x20>, + <0x38 0x801f 0x4>, + <0x40 0x3f 0x20>, + <0x44 0x801f 0x4>, + <0x4c 0x10001 0x10001>, + <0x50 0x1 0x1>, + <0x54 0x1 0x1>, + <0x58 0x801f 0x4>, + <0x60 0x7f007f 0x450045>, + <0x64 0x801f 0x4>, + <0x6c 0x1f001f 0x100010>, + <0x70 0xf1 0x1>, + <0x74 0x801f 0x4>, + <0x7c 0x801f 0x4>, + <0x84 0x1 0x1>, + <0x88 0x1 0x1>, + <0x8c 0x801f 0x4>, + <0x94 0x1 0x1>, + <0x98 0x801f 0x4>, + <0xa0 0x1 0x1>, + <0xa4 0x801f 0x4>, + <0xac 0x1 0x1>, + <0xb0 0x1 0x1>, + <0xb4 0x801f 0x4>, + <0xbc 0x801f 0x4>, + <0xc4 0x801f 0x4>; +}; + +&apciec0_port { + apple,tunable = <0x140 0x1 0x1>, + <0x2a0 0x7e 0xa>; +}; + +/* + * The producer's all-or-nothing ATC0 activation group. Shared AUSS, AOP GPIO + * and CIO reset providers stay enabled for the existing ports. GPIO 77 stays + * reserved until the same handoff transaction releases only that pin. + */ + +/ { + firmware { + atc0-handoff { + compatible = "apple,atc-handoff"; + apple,phy = <&atc0_phy>; + apple,devices = <&ps_atc0_common>, + <&ps_atc0_usb_aon>, + <&ps_atc0_usb>, + <&ps_atc0_phymxwrap>, + <&ps_atc0_cio>, + <&ps_atc0_cio_pcie>, + <&ps_atc0_cio_usb>, + <&ps_atc0_cio_auss>, + <&ps_atc0_pcie>, + <&ps_atc0_common_dp_0>, + <&ps_atc0_common_dp_1>, + <&ps_atc0_common_dp_2>, + <&ps_atc0_common_dp_3>, + <&atc0_phy_mbox>, + <&atc0_phy>, + <&usb0_dart>, + <&usb0_dart1>, + <&usb_drd0>, + <&hpm0>, + <&acio0_mbox>, + <&acio0>, + <&acio0_dart>, + <&acio0_nhi>, + <&acio0_pcie_tunnel>, + <&apciec0_dart>, + <&apciec0>, + <&atc0_dpxbar>; + }; + }; +}; diff --git a/arch/arm64/boot/dts/apple/t6050-j714s-left-usb4.dtsi b/arch/arm64/boot/dts/apple/t6050-j714s-left-usb4.dtsi index 016432b78a47d..081f17d51e47e 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714s-left-usb4.dtsi +++ b/arch/arm64/boot/dts/apple/t6050-j714s-left-usb4.dtsi @@ -41,11 +41,6 @@ }; }; -/* The two routers' LSTX pins (79 and 81) are the only AOP GPIOs exposed. */ -&pinctrl_aop { - gpio-reserved-ranges = <0 79>, <80 1>, <82 3>; -}; - &{/soc@200000000} { /* /arm-io/acio-cpu1 reg[0]: the router CPU's mailbox, inside its wrapper */ acio1_mbox: mailbox@2a9108000 { diff --git a/arch/arm64/boot/dts/apple/t6050-j714s-sleep.dtsi b/arch/arm64/boot/dts/apple/t6050-j714s-sleep.dtsi index c6391bcb1b81a..9f5098d072b89 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714s-sleep.dtsi +++ b/arch/arm64/boot/dts/apple/t6050-j714s-sleep.dtsi @@ -141,6 +141,10 @@ }; /* The port controllers put in system power state S3 before the commit, then SLEEP */ +&hpm0 { + apple,sleep-ssps; +}; + &hpm1 { apple,sleep-ssps; }; diff --git a/arch/arm64/boot/dts/apple/t6050-j714s.dts b/arch/arm64/boot/dts/apple/t6050-j714s.dts index 383ec08bedbe2..6e22844b2df7a 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714s.dts +++ b/arch/arm64/boot/dts/apple/t6050-j714s.dts @@ -296,12 +296,13 @@ /* * Type-C, from the ADT: - * ATC0 usb-drd0 left-back hpm0 nub-spmi-a0 0x0c (the debug port, not described) + * ATC0 usb-drd0 left-back hpm0 nub-spmi-a0 0x0c (the debug port) * ATC1 usb-drd1 left-front hpm1 nub-spmi-a0 0x0a * ATC2 usb-drd2 right hpm2 nub-spmi-a1 0x0c * hpm5 nub-spmi-a0 0x08 (MagSafe 3, power in only: no connector node) * There is no usb-drd3 and no nub-spmi-a2, so ATC3's USB chain and that bus stay - * off. Both described ports are wired as on J716s. + * off. The left-front and right ports are wired as on J716s; the left-back port is in + * t6050-j714s-left-back.dtsi. */ &atc3_phy_mbox { status = "disabled"; @@ -424,6 +425,14 @@ /* Left-front port (ATC1): the USB4/Thunderbolt router and its PCIe tunnel */ #include "t6050-j714s-left-usb4.dtsi" +/* Left-back port (ATC0) */ +#include "t6050-j714s-left-back.dtsi" + +/* Reserve ATC0 LSTX until aura hands it over; ATC1/2 retain their pins. */ +&pinctrl_aop { + gpio-reserved-ranges = <0 79>, <80 1>, <82 3>; +}; + /* * The PMP (ADT pmp0, /chosen, /arm-io/pmgr). iBoot loads its firmware and the driver starts it * with these boot arguments and the firmware properties below. Its report tells it which devices diff --git a/arch/arm64/boot/dts/apple/t6050-peripherals.dtsi b/arch/arm64/boot/dts/apple/t6050-peripherals.dtsi index 488f3c3ee6d6e..9d944c3d182fb 100644 --- a/arch/arm64/boot/dts/apple/t6050-peripherals.dtsi +++ b/arch/arm64/boot/dts/apple/t6050-peripherals.dtsi @@ -1545,7 +1545,7 @@ -#ifndef T6050_J716C +#if !defined(T6050_J714S) && !defined(T6050_J716C) apciec0_dart: iommu@2a4000000 { compatible = "apple,t6050-dart", "apple,t8110-dart"; reg = <0x2 0xa4000000 0x0 0x20000>; diff --git a/drivers/gpu/drm/apple/Makefile b/drivers/gpu/drm/apple/Makefile index 8b2d7288b5639..59592a94690e7 100644 --- a/drivers/gpu/drm/apple/Makefile +++ b/drivers/gpu/drm/apple/Makefile @@ -23,6 +23,7 @@ appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += iomfb_external_hdr_hints_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += apple_resume_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += apple_boot_display_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp-syslog-test.o +appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp-route-supplier-test.dtbo.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += parser_mode_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_external_resume_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_external_ready_test.o diff --git a/drivers/gpu/drm/apple/apple_drv.c b/drivers/gpu/drm/apple/apple_drv.c index bd57a279537cb..f7cf1f0f74ccb 100644 --- a/drivers/gpu/drm/apple/apple_drv.c +++ b/drivers/gpu/drm/apple/apple_drv.c @@ -1245,8 +1245,11 @@ static int apple_probe_typec_ports(struct drm_device *drm, unsigned int n, nr_ports = dcp_typec_nr_ports(); bool fixed = dcp_typec_fixed_crtcs(); unsigned int slots = fixed ? num_dcp : (dcp_typec_dual_stream() ? 2 : 1); - /* T6050 creates its tunnel-only port/pipeline pairs in a second pass. */ - unsigned int passes = fixed ? 2 : 1; + /* + * Connectors are created in passes, by connector group; on T6050, in a + * group, the tunnel-only port/pipeline pairs after the others. + */ + unsigned int passes = dcp_typec_nr_passes(); int i, ret; /* Keep the existing physical-port connector numbers stable. On the @@ -1274,13 +1277,14 @@ static int apple_probe_typec_ports(struct drm_device *drm, if (fixed) { if (!dcp_typec_port_has_candidate(port_idx, pipeline)) continue; - /* T6050: tunnel-only pairs in the second pass */ - if (dcp_typec_port_tunnel_only(port_idx, pipeline) != pass) + if (dcp_typec_port_pass(port_idx, pipeline) != pass) continue; mask = crtc_mask[idx / nr_ports]; if (!mask) continue; } else { + if (dcp_typec_port_pass(port_idx, NULL) != pass) + continue; for (i = 0; i < num_dcp; i++) { if (!dcp_typec_port_has_candidate(port_idx, dcp[i])) continue; diff --git a/drivers/gpu/drm/apple/dcp-fabric-topology-test.c b/drivers/gpu/drm/apple/dcp-fabric-topology-test.c index a9e4c3d95e3a7..2240be4d8b2a3 100644 --- a/drivers/gpu/drm/apple/dcp-fabric-topology-test.c +++ b/drivers/gpu/drm/apple/dcp-fabric-topology-test.c @@ -1,8 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only OR MIT /* Included by dcp-fabric.c to exercise its connector publication paths. */ +#include +#include #include #include +OF_OVERLAY_DECLARE(dcp_route_supplier_test); + struct dcp_topology_test { struct apple_dcp_typec_port port[3]; struct apple_dcp_typec_route route[3][2]; @@ -164,10 +168,255 @@ static void topology_unbind_test(struct kunit *test) } } +/* The J714s's display fabric: three ports, three pipelines, the second tunnel-only */ +enum { TOPO_RIGHT, TOPO_LEFT_FRONT, TOPO_LEFT_BACK, TOPO_PORTS }; +enum { TOPO_DCPEXT0, TOPO_DCPEXT1, TOPO_DCPEXT2, TOPO_PIPES }; +#define TOPO_PAIR(port, pipe) ((port) * TOPO_PIPES + (pipe)) + +struct topology_j714s { + struct apple_dcp_typec_port port[TOPO_PORTS]; + struct apple_dcp_typec_route route[TOPO_PORTS][TOPO_PIPES]; + struct apple_dcp dcp[TOPO_PIPES]; + struct platform_device *pdev[TOPO_PIPES]; + unsigned int first; + /* The passes the ports already registered (a real J714s's) take */ + unsigned int passes; +}; + +static void topology_j714s_unlist(void *data) +{ + struct topology_j714s *t = data; + unsigned int p; + + guard(mutex)(&dcp_typec_fabric_lock); + for (p = 0; p < TOPO_PORTS; p++) + list_del(&t->port[p].link); +} + +static struct topology_j714s *topology_j714s_init(struct kunit *test) +{ + struct topology_j714s *t; + unsigned int p, i; + + t = kunit_kzalloc(test, sizeof(*t), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, t); + kunit_activate_static_stub(test, dcp_typec_fixed_crtcs, topology_fixed_crtcs); + for (i = 0; i < TOPO_PIPES; i++) { + t->pdev[i] = kunit_platform_device_alloc(test, "dcp-j714s", PLATFORM_DEVID_AUTO); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, t->pdev[i]); + t->dcp[i].dev = &t->pdev[i]->dev; + } + t->first = dcp_typec_nr_ports(); + t->passes = dcp_typec_nr_passes(); + scoped_guard(mutex, &dcp_typec_fabric_lock) { + for (p = 0; p < TOPO_PORTS; p++) { + INIT_LIST_HEAD(&t->port[p].routes); + for (i = 0; i < TOPO_PIPES; i++) { + struct apple_dcp_typec_route *route = &t->route[p][i]; + + route->dcp = &t->dcp[i]; + route->port = &t->port[p]; + route->core.tunnel_only = i == TOPO_DCPEXT1; + list_add_tail(&route->port_link, &t->port[p].routes); + } + list_add_tail(&t->port[p].link, &dcp_typec_ports); + } + } + KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, topology_j714s_unlist, t), 0); + return t; +} + +/* + * Lists the connectors of the first @nr_ports ports in + * apple_probe_typec_ports()'s order, as TOPO_PAIR(port, pipeline), and + * returns how many. It mirrors that loop: passes outermost, then pipelines + * (dcp[idx / nr_ports]), then ports (idx % nr_ports). + */ +static unsigned int topology_connector_order(struct topology_j714s *t, unsigned int nr_ports, + unsigned int *order) +{ + unsigned int pass, i, p, n = 0; + + for (pass = 0; pass < dcp_typec_nr_passes(); pass++) + for (i = 0; i < TOPO_PIPES; i++) + for (p = 0; p < nr_ports; p++) + if (dcp_typec_port_has_candidate(t->first + p, t->pdev[i]) && + dcp_typec_port_pass(t->first + p, t->pdev[i]) == pass) + order[n++] = TOPO_PAIR(p, i); + return n; +} + +/* The passes with @passes needed by the fixture's own routes */ +static unsigned int topology_passes(struct topology_j714s *t, unsigned int passes) +{ + return max(t->passes, passes); +} + +/* + * The J714s's connector names: DP-1..DP-6 for the right and left-front ports + * as before the left-back port was added, whose routes are in connector group + * 1 and get DP-7..DP-9. In group 0 they would take DP-3 and push the rest on. + */ +static void topology_connector_group_test(struct kunit *test) +{ + static const unsigned int two_ports[] = { + TOPO_PAIR(TOPO_RIGHT, TOPO_DCPEXT0), /* DP-1 */ + TOPO_PAIR(TOPO_LEFT_FRONT, TOPO_DCPEXT0), /* DP-2 */ + TOPO_PAIR(TOPO_RIGHT, TOPO_DCPEXT2), /* DP-3 */ + TOPO_PAIR(TOPO_LEFT_FRONT, TOPO_DCPEXT2), /* DP-4 */ + TOPO_PAIR(TOPO_RIGHT, TOPO_DCPEXT1), /* DP-5 */ + TOPO_PAIR(TOPO_LEFT_FRONT, TOPO_DCPEXT1), /* DP-6 */ + }; + static const unsigned int three_ports[] = { + TOPO_PAIR(TOPO_RIGHT, TOPO_DCPEXT0), + TOPO_PAIR(TOPO_LEFT_FRONT, TOPO_DCPEXT0), + TOPO_PAIR(TOPO_RIGHT, TOPO_DCPEXT2), + TOPO_PAIR(TOPO_LEFT_FRONT, TOPO_DCPEXT2), + TOPO_PAIR(TOPO_RIGHT, TOPO_DCPEXT1), + TOPO_PAIR(TOPO_LEFT_FRONT, TOPO_DCPEXT1), + TOPO_PAIR(TOPO_LEFT_BACK, TOPO_DCPEXT0), /* DP-7 */ + TOPO_PAIR(TOPO_LEFT_BACK, TOPO_DCPEXT2), /* DP-8 */ + TOPO_PAIR(TOPO_LEFT_BACK, TOPO_DCPEXT1), /* DP-9 */ + }; + struct topology_j714s *t = topology_j714s_init(test); + unsigned int order[TOPO_PORTS * TOPO_PIPES], i, n; + + /* Everything in group 0: two passes */ + KUNIT_EXPECT_EQ(test, dcp_typec_nr_passes(), topology_passes(t, 2)); + n = topology_connector_order(t, 2, order); + KUNIT_ASSERT_EQ(test, n, ARRAY_SIZE(two_ports)); + KUNIT_EXPECT_MEMEQ(test, order, two_ports, sizeof(two_ports)); + + /* The left-back port in group 0 too: its first pair would be DP-3 */ + n = topology_connector_order(t, 3, order); + KUNIT_ASSERT_EQ(test, n, ARRAY_SIZE(three_ports)); + KUNIT_EXPECT_EQ(test, order[2], TOPO_PAIR(TOPO_LEFT_BACK, TOPO_DCPEXT0)); + + /* In group 1, as the J714s DT has it */ + for (i = 0; i < TOPO_PIPES; i++) + t->route[TOPO_LEFT_BACK][i].connector_group = 1; + KUNIT_EXPECT_EQ(test, dcp_typec_nr_passes(), topology_passes(t, 4)); + KUNIT_EXPECT_EQ(test, dcp_typec_port_pass(t->first + TOPO_LEFT_BACK, + t->pdev[TOPO_DCPEXT0]), 2); + KUNIT_EXPECT_EQ(test, dcp_typec_port_pass(t->first + TOPO_LEFT_BACK, + t->pdev[TOPO_DCPEXT1]), 3); + /* A port's shared connector (no fixed CRTCs) takes its group's first pass */ + KUNIT_EXPECT_EQ(test, dcp_typec_port_pass(t->first + TOPO_LEFT_BACK, NULL), 2); + KUNIT_EXPECT_EQ(test, dcp_typec_port_pass(t->first + TOPO_RIGHT, NULL), 0); + n = topology_connector_order(t, 3, order); + KUNIT_ASSERT_EQ(test, n, ARRAY_SIZE(three_ports)); + KUNIT_EXPECT_MEMEQ(test, order, three_ports, sizeof(three_ports)); + + /* A later group adds passes; the order is the same */ + for (i = 0; i < TOPO_PIPES; i++) + t->route[TOPO_LEFT_BACK][i].connector_group = 3; + KUNIT_EXPECT_EQ(test, dcp_typec_nr_passes(), topology_passes(t, 8)); + n = topology_connector_order(t, 3, order); + KUNIT_ASSERT_EQ(test, n, ARRAY_SIZE(three_ports)); + KUNIT_EXPECT_MEMEQ(test, order, three_ports, sizeof(three_ports)); +} + +static void topology_route_supplier_put(void *data) +{ + struct device *dev = data; + + of_node_put(dev->of_node); + dev->of_node = NULL; +} + +/* + * Only a route whose PHY or crossbar node is disabled is skipped. A missing + * or malformed entry counts as available, so that its lookup fails the probe. + */ +static void topology_route_supplier_test(struct kunit *test) +{ + struct device *dev; + + KUNIT_ASSERT_EQ(test, 0, of_overlay_apply_kunit(test, dcp_route_supplier_test)); + dev = kunit_device_register(test, "dcp-route-supplier"); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); + dev->of_node = of_find_node_by_path("/dcp-route-supplier-test/dcp"); + KUNIT_ASSERT_NOT_NULL(test, dev->of_node); + KUNIT_ASSERT_EQ(test, + kunit_add_action_or_reset(test, topology_route_supplier_put, dev), 0); + + KUNIT_EXPECT_TRUE(test, dcp_typec_route_supplier_available(dev, "phys", "#phy-cells", + "phy-names", "typec0")); + KUNIT_EXPECT_FALSE(test, dcp_typec_route_supplier_available(dev, "phys", "#phy-cells", + "phy-names", "typec1")); + /* No such name, and no crossbar entry for typec2: the lookups report those */ + KUNIT_EXPECT_TRUE(test, dcp_typec_route_supplier_available(dev, "phys", "#phy-cells", + "phy-names", "typec4")); + KUNIT_EXPECT_TRUE(test, dcp_typec_route_supplier_available(dev, "mux-controls", + "#mux-control-cells", + "mux-control-names", "typec2")); + KUNIT_EXPECT_TRUE(test, dcp_typec_route_supplier_available(dev, "mux-controls", + "#mux-control-cells", + "mux-control-names", "typec1")); + + /* + * The per-route decision a failsafe dcpext's supplier preflight + * (dcp_ext_route_suppliers()) and route registration share + */ + KUNIT_EXPECT_NULL(test, dcp_typec_route_supplier_disabled(dev, "typec0")); + KUNIT_EXPECT_STREQ(test, dcp_typec_route_supplier_disabled(dev, "typec1") ?: "", + "DP PHY"); + KUNIT_EXPECT_NULL(test, dcp_typec_route_supplier_disabled(dev, "typec2")); + KUNIT_EXPECT_STREQ(test, dcp_typec_route_supplier_disabled(dev, "typec3") ?: "", + "display crossbar"); + + /* Available suppliers: the route is not skipped, and nothing is changed */ + KUNIT_EXPECT_NULL(test, dcp_typec_route_skip(dev, dev->of_node, "typec0")); + KUNIT_EXPECT_NULL(test, dcp_typec_route_skip(dev, dev->of_node, "typec2")); + KUNIT_EXPECT_TRUE(test, of_device_is_available(dev->of_node)); +} + +static void topology_route_node_put(void *data) +{ + of_node_put(data); +} + +/* + * A route whose PHY is disabled is skipped and disabled itself, so its port + * stops waiting for it. The changeset is reverted, for the overlay's removal. + */ +static void topology_route_skip_test(struct kunit *test) +{ + struct device_node *route_np; + struct of_changeset *cs; + struct device *dev; + + KUNIT_ASSERT_EQ(test, 0, of_overlay_apply_kunit(test, dcp_route_supplier_test)); + dev = kunit_device_register(test, "dcp-route-skip"); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); + dev->of_node = of_find_node_by_path("/dcp-route-supplier-test/dcp"); + KUNIT_ASSERT_NOT_NULL(test, dev->of_node); + KUNIT_ASSERT_EQ(test, + kunit_add_action_or_reset(test, topology_route_supplier_put, dev), 0); + route_np = of_find_node_by_path("/dcp-route-supplier-test/dcp/typec-routes/route@1"); + KUNIT_ASSERT_NOT_NULL(test, route_np); + KUNIT_ASSERT_EQ(test, + kunit_add_action_or_reset(test, topology_route_node_put, route_np), 0); + KUNIT_ASSERT_TRUE(test, of_device_is_available(route_np)); + + cs = dcp_typec_route_skip(dev, route_np, "typec1"); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, cs); + KUNIT_EXPECT_FALSE(test, of_device_is_available(route_np)); + + /* A changeset still applied must not be destroyed */ + KUNIT_ASSERT_EQ(test, of_changeset_revert(cs), 0); + of_changeset_destroy(cs); + kfree(cs); + KUNIT_EXPECT_TRUE(test, of_device_is_available(route_np)); +} + static struct kunit_case dcp_topology_cases[] = { KUNIT_CASE(topology_pipeline_identity_test), KUNIT_CASE(topology_adopt_release_test), KUNIT_CASE(topology_unbind_test), + KUNIT_CASE(topology_connector_group_test), + KUNIT_CASE(topology_route_supplier_test), + KUNIT_CASE(topology_route_skip_test), {} }; diff --git a/drivers/gpu/drm/apple/dcp-fabric.c b/drivers/gpu/drm/apple/dcp-fabric.c index 824df5f341022..8c9a9039cb9a5 100644 --- a/drivers/gpu/drm/apple/dcp-fabric.c +++ b/drivers/gpu/drm/apple/dcp-fabric.c @@ -4387,23 +4387,59 @@ bool dcp_typec_port_has_candidate(unsigned int idx, struct platform_device *pdev return false; } -/* Is @pdev's route to port @idx for DP tunnels only (apple,tunnel-only)? */ -bool dcp_typec_port_tunnel_only(unsigned int idx, struct platform_device *pdev) +static unsigned int dcp_typec_route_pass(const struct apple_dcp_typec_route *route) +{ + return 2 * route->connector_group + (route->core.tunnel_only ? 1 : 0); +} + +/* + * The number of passes in which the connectors are created: two (the other + * routes', then the tunnel-only ones') per apple,connector-group, up to the + * largest group any route has. + */ +unsigned int dcp_typec_nr_passes(void) { struct apple_dcp_typec_port *port; struct apple_dcp_typec_route *route; + u32 groups = 1; + + guard(mutex)(&dcp_typec_fabric_lock); + + list_for_each_entry(port, &dcp_typec_ports, link) + list_for_each_entry(route, &port->routes, port_link) + groups = max(groups, route->connector_group + 1); + + return 2 * groups; +} + +/* + * The pass in which the connector of @pdev's route to port @idx is created: + * connectors come group by group (apple,connector-group), and in a group a + * tunnel-only route's (apple,tunnel-only) after the others'. A port added to + * a board in the next group gets the next connector names, and the existing + * connectors keep theirs. With @pdev NULL (a port whose routes share its + * connectors), the port's: its largest group's first pass. + */ +unsigned int dcp_typec_port_pass(unsigned int idx, struct platform_device *pdev) +{ + struct apple_dcp_typec_port *port; + struct apple_dcp_typec_route *route; + u32 group = 0; guard(mutex)(&dcp_typec_fabric_lock); port = dcp_typec_port_by_index(idx); if (!port) - return false; + return 0; - list_for_each_entry(route, &port->routes, port_link) - if (route->dcp->dev == &pdev->dev) - return route->core.tunnel_only; + list_for_each_entry(route, &port->routes, port_link) { + if (!pdev) + group = max(group, route->connector_group); + else if (route->dcp->dev == &pdev->dev) + return dcp_typec_route_pass(route); + } - return false; + return 2 * group; } /* @@ -4612,6 +4648,104 @@ struct dcp_route_probe_context { struct device_node *routes; }; +/* + * Is the provider that @dev's @names entry @name points to in @list available? + * A disabled one never registers, so looking it up would defer for ever. A + * missing or malformed entry counts as available: the lookup reports it. + */ +static bool dcp_typec_route_supplier_available(struct device *dev, const char *list, + const char *cells, const char *names, + const char *name) +{ + struct of_phandle_args args; + bool available; + int index; + + index = of_property_match_string(dev->of_node, names, name); + if (index < 0 || of_parse_phandle_with_args(dev->of_node, list, cells, index, &args)) + return true; + available = of_device_is_available(args.np); + of_node_put(args.np); + return available; +} + +/* + * Disables @route, or every available route under @routes if @route is NULL, + * in the device tree, in one changeset, for good. A connector passes over + * unavailable routes when it looks for its display routes, so the port no + * longer waits for them. Returns the applied changeset, which stays (the live + * tree refers to it), or an ERR_PTR. + */ +static struct of_changeset *dcp_typec_routes_disable_nodes(struct device *dev, + struct device_node *routes, + struct device_node *route) +{ + struct of_changeset *cs; + struct device_node *np; + int ret = 0; + + cs = kzalloc_obj(*cs); + if (!cs) + return ERR_PTR(-ENOMEM); + of_changeset_init(cs); + if (route) { + ret = of_changeset_update_prop_string(cs, route, "status", "disabled"); + } else { + for_each_available_child_of_node(routes, np) { + ret = of_changeset_update_prop_string(cs, np, "status", "disabled"); + if (ret) { + of_node_put(np); + break; + } + } + } + if (!ret) + ret = of_changeset_apply(cs); + if (ret) { + if (route) + dev_err(dev, "%pOF: could not disable the route: %d\n", route, ret); + else + dev_err(dev, "could not disable the Type-C display routes: %d\n", ret); + of_changeset_destroy(cs); + kfree(cs); + return ERR_PTR(ret); + } + return cs; +} + +/* + * Which of @dev's suppliers for its Type-C route @name ("typecN") has a + * disabled node: "DP PHY", "display crossbar", or NULL if neither. Such a + * route is left out, here and in a failsafe dcpext's supplier preflight. + */ +const char *dcp_typec_route_supplier_disabled(struct device *dev, const char *name) +{ + if (!dcp_typec_route_supplier_available(dev, "phys", "#phy-cells", "phy-names", name)) + return "DP PHY"; + if (!dcp_typec_route_supplier_available(dev, "mux-controls", "#mux-control-cells", + "mux-control-names", name)) + return "display crossbar"; + return NULL; +} + +/* + * A route whose PHY or crossbar node is disabled is skipped and disabled in + * turn, so that one port's disabled PHY costs only that port's displays, not + * every route of the processor. Returns NULL if the route is not skipped, + * else the changeset that disabled it, or an ERR_PTR if that failed. + */ +static struct of_changeset *dcp_typec_route_skip(struct device *dev, + struct device_node *route_np, + const char *name) +{ + const char *what = dcp_typec_route_supplier_disabled(dev, name); + + if (!what) + return NULL; + dev_warn(dev, "%pOF: its %s is disabled, route skipped\n", route_np, what); + return dcp_typec_routes_disable_nodes(dev, NULL, route_np); +} + static int dcp_register_typec_routes_present(void *data) { struct dcp_route_probe_context *ctx = data; @@ -4652,6 +4786,10 @@ static int dcp_register_typec_routes_present(void *data) if (!mux_name) return -ENOMEM; + /* Skipped even if disabling it failed (logged): it cannot register */ + if (dcp_typec_route_skip(dev, route_np, name)) + continue; + route = &dcp->typec_routes[dcp->nr_typec_routes]; route->dcp = dcp; INIT_LIST_HEAD(&route->port_link); @@ -4660,6 +4798,7 @@ static int dcp_register_typec_routes_present(void *data) return dev_err_probe(dev, PTR_ERR(route->phy), "%pOF: failed to get DP PHY\n", route_np); + /* A failure fails the probe, and devres puts the PHY */ route->xbar = devm_mux_control_get(dev, name); if (IS_ERR(route->xbar)) return dev_err_probe(dev, PTR_ERR(route->xbar), @@ -4674,6 +4813,15 @@ static int dcp_register_typec_routes_present(void *data) /* A route for USB4 DP tunnels only is never given a DP-alt stream. */ route->core.tunnel_only = of_property_read_bool(route_np, "apple,tunnel-only"); + ret = of_property_read_u32(route_np, "apple,connector-group", + &route->connector_group); + if (ret == -EINVAL) + route->connector_group = 0; + else if (ret) + return dev_err_probe(dev, ret, "%pOF: invalid connector group\n", route_np); + if (route->connector_group >= DCP_TYPEC_CONNECTOR_GROUPS) + return dev_err_probe(dev, -EINVAL, "%pOF: invalid connector group %u\n", + route_np, route->connector_group); ret = of_property_read_u32_index(dev->of_node, "apple,typec-dptx-phys", route_index, &route->dptx_phy); @@ -4763,31 +4911,9 @@ void dcp_typec_routes_disable_dev(struct device *dev) { struct device_node *routes __free(device_node) = of_get_child_by_name(dev->of_node, "typec-routes"); - struct device_node *route; - struct of_changeset *cs; - int ret = 0; - if (!routes) - return; - cs = kzalloc(sizeof(*cs), GFP_KERNEL); - if (!cs) - return; - of_changeset_init(cs); - for_each_available_child_of_node(routes, route) { - ret = of_changeset_update_prop_string(cs, route, "status", "disabled"); - if (ret) { - of_node_put(route); - break; - } - } - if (!ret) - ret = of_changeset_apply(cs); - if (ret) { - dev_err(dev, "could not disable the Type-C display routes: %d\n", ret); - of_changeset_destroy(cs); - kfree(cs); - } - /* Applied, it stays: the live tree refers to it. */ + if (routes) + dcp_typec_routes_disable_nodes(dev, routes, NULL); } int dcp_register_typec_routes(struct apple_dcp *dcp) diff --git a/drivers/gpu/drm/apple/dcp-fabric.h b/drivers/gpu/drm/apple/dcp-fabric.h index c1ee7b6c6e1d6..65cc8845a496d 100644 --- a/drivers/gpu/drm/apple/dcp-fabric.h +++ b/drivers/gpu/drm/apple/dcp-fabric.h @@ -37,6 +37,8 @@ struct apple_dcp_typec_route { struct mux_control *xbar; struct mux_control *dpin[DCP_FABRIC_DPIN_MAX]; bool dual_stream; + /* apple,connector-group: its connector's order group */ + u32 connector_group; struct typec_mux_dev *typec_mux; u32 dptx_phy; u32 mux_index; @@ -76,7 +78,10 @@ bool dcp_has_typec_routes(struct platform_device *pdev); unsigned int dcp_typec_nr_ports(void); struct device_node *dcp_typec_port_of_node(unsigned int idx); bool dcp_typec_port_has_candidate(unsigned int idx, struct platform_device *pdev); -bool dcp_typec_port_tunnel_only(unsigned int idx, struct platform_device *pdev); +/* Connectors by apple,connector-group; T6050's tunnel-only pairs after the others in each */ +#define DCP_TYPEC_CONNECTOR_GROUPS 4 +unsigned int dcp_typec_nr_passes(void); +unsigned int dcp_typec_port_pass(unsigned int idx, struct platform_device *pdev); bool dcp_typec_port_unusable(unsigned int idx); void dcp_typec_port_set_connector(unsigned int idx, bool secondary, struct apple_connector *connector, @@ -127,6 +132,7 @@ int dcp_fabric_sleep_withdraw(struct apple_dcp *dcp, s64 ms[2]); void dcp_fabric_sleep_done(struct apple_dcp *dcp); void dcp_typec_routes_disable(struct apple_dcp *dcp); void dcp_typec_routes_disable_dev(struct device *dev); +const char *dcp_typec_route_supplier_disabled(struct device *dev, const char *name); void dcp_typec_retrain_work(struct work_struct *work); void dcp_fabric_init(struct apple_dcp *dcp); void dcp_fabric_hdmi_resume(struct apple_dcp *dcp); diff --git a/drivers/gpu/drm/apple/dcp-route-supplier-test.dtso b/drivers/gpu/drm/apple/dcp-route-supplier-test.dtso new file mode 100644 index 0000000000000..341c32634afee --- /dev/null +++ b/drivers/gpu/drm/apple/dcp-route-supplier-test.dtso @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/dts-v1/; +/plugin/; + +/* + * A DCP's Type-C route suppliers: an available and a disabled DP PHY, and an + * available and a disabled crossbar. Nothing binds to these nodes; the tests + * read them, and disable one route. + */ +&{/} { + dcp-route-supplier-test { + phy_ok: phy-ok { + #phy-cells = <1>; + }; + + phy_off: phy-off { + #phy-cells = <1>; + status = "disabled"; + }; + + xbar_ok: xbar-ok { + #mux-control-cells = <1>; + }; + + xbar_off: xbar-off { + #mux-control-cells = <1>; + status = "disabled"; + }; + + dcp { + phys = <&phy_ok 6>, <&phy_off 6>, <&phy_ok 6>, <&phy_ok 6>; + phy-names = "typec0", "typec1", "typec2", "typec3"; + mux-controls = <&xbar_ok 0>, <&xbar_ok 1>, <&xbar_off 0>; + mux-control-names = "typec0", "typec1", "typec3"; + + typec-routes { + #address-cells = <1>; + #size-cells = <0>; + + route@1 { + reg = <1>; + }; + }; + }; + }; +}; diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index d9c1759989781..370c39a722aa7 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -7108,7 +7108,8 @@ static void dcp_ext_give_up(struct apple_dcp *dcp, int err, const char *when) } /* - * Whether the DP PHY and display crossbar of every Type-C route are there. + * Whether the DP PHY and display crossbar of every Type-C route are there, + * but for a route whose PHY or crossbar node is disabled, which is left out. * Routes register one at a time, and one registered cannot be taken back, * since a port controller may hold it: a later route waiting for its * supplier would leave the dcpext unusable for the boot. Returns @@ -7131,6 +7132,12 @@ static int dcp_ext_route_suppliers(struct device *dev) if (of_property_read_u32(route_np, "reg", &index)) continue; snprintf(name, sizeof(name), "typec%u", index); + /* + * A disabled PHY or crossbar never registers: probe skips its + * route (dcp_register_typec_routes()), so do not wait for it. + */ + if (dcp_typec_route_supplier_disabled(dev, name)) + continue; phy = of_phy_get(dev->of_node, name); if (PTR_ERR_OR_ZERO(phy) == -EPROBE_DEFER) return -EPROBE_DEFER; diff --git a/drivers/gpu/drm/apple/tests/topology.kunitconfig b/drivers/gpu/drm/apple/tests/topology.kunitconfig new file mode 100644 index 0000000000000..8e8ffd66a5d9f --- /dev/null +++ b/drivers/gpu/drm/apple/tests/topology.kunitconfig @@ -0,0 +1,10 @@ +CONFIG_KUNIT=y +CONFIG_ARCH_APPLE=y +CONFIG_MAILBOX=y +CONFIG_APPLE_MAILBOX=y +CONFIG_APPLE_RTKIT=y +CONFIG_DRM=y +CONFIG_BACKLIGHT_CLASS_DEVICE=y +CONFIG_DRM_APPLE=y +CONFIG_DRM_APPLE_KUNIT_TEST=y +CONFIG_OF_OVERLAY=y