Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
211 changes: 211 additions & 0 deletions arch/arm64/boot/dts/apple/t6022-j475d.dts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,217 @@
power-domains = <&ps_dispext0_cpu0_die1>, <&ps_dptx_phy_ps_die1>;
};

/*
* HDMI scans out through dispext0 on die 1, and the rear USB-C ports through
* dcpext1/dispext1 on die 0 (see t602x-j474-j475.dtsi).
*/
&display {
iommus = <&dispext0_dart_die1 0 0x100 0x0 0x10 0x0>,
<&dispext0_dart 0 0x100 0x0 0x10 0x0>,
<&dispext1_dart 0 0x100 0x0 0x10 0x0>;
};

/*
* Thunderbolt DP tunnels on M2 need two pipelines per port with named DPIN
* crossbar controls, as on the 14/16-inch boards. HDMI uses die 1 here, so
* die-0 dcpext0 is free to be the second rear-port pipeline (crossbar state
* 0, dcpext1 state 2).
*/
/ {
aliases {
/* m1n1 fills apple,firmware-compat through the ADT-indexed alias */
dcpext0 = &dcpext0;
};
};

&dispext0_dart {
status = "okay";
};

&dcpext0_dart {
status = "okay";
};

&dcpext0_mbox {
status = "okay";
};

&dpaudio1 {
status = "okay";
};

&dcpext0 {
status = "okay";
apple,connector-type = "USB-C";
phys = <&atcphy0 PHY_TYPE_DP>, <&atcphy1 PHY_TYPE_DP>,
<&atcphy2 PHY_TYPE_DP>, <&atcphy3 PHY_TYPE_DP>;
phy-names = "typec0", "typec1", "typec2", "typec3";
mux-controls = <&atcphy0_xbar 0>,
<&atcphy1_xbar 0>,
<&atcphy2_xbar 0>,
<&atcphy3_xbar 0>,
<&atcphy0_xbar 1>,
<&atcphy1_xbar 1>,
<&atcphy2_xbar 1>,
<&atcphy3_xbar 1>,
<&atcphy0_xbar 2>,
<&atcphy1_xbar 2>,
<&atcphy2_xbar 2>,
<&atcphy3_xbar 2>;
mux-control-names = "typec0", "typec1", "typec2", "typec3",
"typec0-dpin0", "typec1-dpin0", "typec2-dpin0", "typec3-dpin0",
"typec0-dpin1", "typec1-dpin1", "typec2-dpin1", "typec3-dpin1";
apple,typec-mux-indices = <0 0 0 0>;
apple,typec-dptx-phys = <0 1 2 3>;

typec-routes {
#address-cells = <1>;
#size-cells = <0>;

route@0 {
reg = <0>;
mode-switch;

port {
dcpext0_typec0: endpoint {
remote-endpoint = <&typec0_dcpext0>;
};
};
};

route@1 {
reg = <1>;
mode-switch;

port {
dcpext0_typec1: endpoint {
remote-endpoint = <&typec1_dcpext0>;
};
};
};

route@2 {
reg = <2>;
mode-switch;

port {
dcpext0_typec2: endpoint {
remote-endpoint = <&typec2_dcpext0>;
};
};
};

route@3 {
reg = <3>;
mode-switch;

port {
dcpext0_typec3: endpoint {
remote-endpoint = <&typec3_dcpext0>;
};
};
};
};
};

&dcpext1 {
mux-controls = <&atcphy0_xbar 0>,
<&atcphy1_xbar 0>,
<&atcphy2_xbar 0>,
<&atcphy3_xbar 0>,
<&atcphy0_xbar 1>,
<&atcphy1_xbar 1>,
<&atcphy2_xbar 1>,
<&atcphy3_xbar 1>,
<&atcphy0_xbar 2>,
<&atcphy1_xbar 2>,
<&atcphy2_xbar 2>,
<&atcphy3_xbar 2>;
mux-control-names = "typec0", "typec1", "typec2", "typec3",
"typec0-dpin0", "typec1-dpin0", "typec2-dpin0", "typec3-dpin0",
"typec0-dpin1", "typec1-dpin1", "typec2-dpin1", "typec3-dpin1";
};

&typec0 {
ports {
port@3 {
#address-cells = <1>;
#size-cells = <0>;
/delete-node/ endpoint;

typec0_dcp: endpoint@0 {
reg = <0>;
remote-endpoint = <&dcpext1_typec0>;
};

typec0_dcpext0: endpoint@1 {
reg = <1>;
remote-endpoint = <&dcpext0_typec0>;
};
};
};
};

&typec1 {
ports {
port@3 {
#address-cells = <1>;
#size-cells = <0>;
/delete-node/ endpoint;

typec1_dcp: endpoint@0 {
reg = <0>;
remote-endpoint = <&dcpext1_typec1>;
};

typec1_dcpext0: endpoint@1 {
reg = <1>;
remote-endpoint = <&dcpext0_typec1>;
};
};
};
};

&typec2 {
ports {
port@3 {
#address-cells = <1>;
#size-cells = <0>;
/delete-node/ endpoint;

typec2_dcp: endpoint@0 {
reg = <0>;
remote-endpoint = <&dcpext1_typec2>;
};

typec2_dcpext0: endpoint@1 {
reg = <1>;
remote-endpoint = <&dcpext0_typec2>;
};
};
};
};

&typec3 {
ports {
port@3 {
#address-cells = <1>;
#size-cells = <0>;
/delete-node/ endpoint;

typec3_dcp: endpoint@0 {
reg = <0>;
remote-endpoint = <&dcpext1_typec3>;
};

typec3_dcpext0: endpoint@1 {
reg = <1>;
remote-endpoint = <&dcpext0_typec3>;
};
};
};
};

&dcpext0_die1 {
// J180 misses "function-dp2hdmi_pwr_en"
dp2hdmi-pwren-gpios = <&smc_gpio 25 GPIO_ACTIVE_HIGH>;
Expand Down
15 changes: 14 additions & 1 deletion arch/arm64/boot/dts/apple/t602x-j474-j475.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#ifdef APPLE_T602X_NON_ULTRA
/ {
aliases {
dcpext1 = &dcpext1;
/* Same Thunderbolt aliases as the 14/16-inch boards. This mini
* brings up a fourth controller.
*/
Expand Down Expand Up @@ -67,6 +66,19 @@
iommus = <&dispext0_dart 0 0x100 0x0 0x10 0x0>,
<&dispext1_dart 0 0x100 0x0 0x10 0x0>;
};
#endif

/*
* dcpext1 on die 0 drives the rear USB-C ports through the display crossbar
* on all of these boards, M2 Ultra included: macOS routes a DP alt mode
* display on the J475d's rear ports to DCPEXT1 as well. Only the USB4 and
* PCIe-C wiring below stays non-Ultra.
*/
/ {
aliases {
dcpext1 = &dcpext1;
};
};

&dispext1_dart {
status = "okay";
Expand Down Expand Up @@ -229,6 +241,7 @@
apple,always-on;
};

#ifdef APPLE_T602X_NON_ULTRA
&usb4_0_acio {
apple,pcie-tunnel = <&usb4_0_pcie_tunnel>;
};
Expand Down
36 changes: 25 additions & 11 deletions drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,21 +816,35 @@ static int apple_probe_typec_ports(struct drm_device *drm,
connector->connected = false;
connector->dcp = NULL;

for (i = 0; i < num_dcp; i++) {
if (!dcp_typec_port_has_candidate(port_idx, dcp[i]))
continue;
if (secondary && dcp_typec_ordered_dual_stream()) {
u32 candidates[MAX_COPROCESSORS];
bool typec_only[MAX_COPROCESSORS];
unsigned int count = 0;

/*
* A dock's second stream (DPIN1) always runs on the
* lowest-indexed Type-C-only pipeline (dcpext1). Fix the
* A dock's second stream (DPIN1) always runs on one
* Type-C-only pipeline, not the one the first stream
* takes (see dcp_fabric_secondary_crtc()). Fix the
* connector to it: compositors read possible_crtcs once
* and would otherwise pair it with a pipeline the stream
* can never be routed to. T6030 instead narrows both
* connectors to the native processor holding their route.
* can never be routed to.
*/
for (i = 0; i < num_dcp; i++) {
if (!dcp_typec_port_has_candidate(port_idx, dcp[i]))
continue;
candidates[count] = crtc_mask[i];
typec_only[count++] = dcp_is_typec_only(dcp[i]);
}
mask = dcp_fabric_secondary_crtc(candidates, typec_only,
count);
} else {
/*
* Every pipeline that can drive the port; a routed port
* may be narrowed later (see dcp_typec_narrows()).
*/
mask = dcp_fabric_port_crtc_mask(secondary,
dcp_typec_ordered_dual_stream(),
dcp_is_typec_only(dcp[i]),
mask, crtc_mask[i]);
for (i = 0; i < num_dcp; i++)
if (dcp_typec_port_has_candidate(port_idx, dcp[i]))
mask |= crtc_mask[i];
}

if (!mask) {
Expand Down
30 changes: 30 additions & 0 deletions drivers/gpu/drm/apple/dcp-fabric-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,36 @@ u32 dcp_fabric_port_crtc_mask(bool secondary, bool ordered_dual, bool typec_only
}
EXPORT_SYMBOL_GPL(dcp_fabric_port_crtc_mask);

/*
* The CRTC an ordered dual-stream port's second stream (DPIN1) is fixed to.
* dcp_fabric_plan() walks pipelines in CRTC order, so the first stream takes
* the port's lowest-indexed pipeline: skip it. On the M2 Pro/Max laptops
* that is the HDMI hybrid, never a candidate here, which leaves dcpext1. On
* the M2 Ultra Mac Studio every rear-port pipeline is Type-C-only, and the
* second stream would otherwise be fixed to the first stream's dcpext0. A
* port with a single Type-C-only pipeline keeps it.
*/
u32 dcp_fabric_secondary_crtc(const u32 *candidates, const bool *typec_only,
unsigned int count)
{
u32 first = 0, mask = 0, fallback = 0;
unsigned int i;

for (i = 0; i < count; i++)
if (!first || candidates[i] < first)
first = candidates[i];
for (i = 0; i < count; i++) {
if (!typec_only[i])
continue;
if (!fallback || candidates[i] < fallback)
fallback = candidates[i];
if (candidates[i] != first && (!mask || candidates[i] < mask))
mask = candidates[i];
}
return mask ?: fallback;
}
EXPORT_SYMBOL_GPL(dcp_fabric_secondary_crtc);

enum dcp_fabric_attach_action dcp_fabric_attach_action(bool external)
{
return external ? DCP_FABRIC_ATTACH_WORK : DCP_FABRIC_ATTACH_OOB;
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/apple/dcp-fabric-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ u32 dcp_fabric_connector_mask(bool dual_stream, bool bound, bool routed,
unsigned int index, u32 candidates);
u32 dcp_fabric_port_crtc_mask(bool secondary, bool ordered_dual, bool typec_only,
u32 mask, u32 candidate);
u32 dcp_fabric_secondary_crtc(const u32 *candidates, const bool *typec_only,
unsigned int count);
enum dcp_fabric_attach_action dcp_fabric_attach_action(bool external);
bool dcp_fabric_t6030_link(bool tunnel, bool has_xbar, bool t6030_dpin);

Expand Down
Loading