Skip to content

Commit 6354e3d

Browse files
committed
drm: apple: Use typec mux to switch atc-phy into DP
The upstream atc phy driver has no longer special handling for the phy only use case on 14/16-inch Macbook Pros. So simply let dcp handle this and switch the type-c mux to full 4 lane DisplayPort mode. This requires devicetree changes in the form of a graph based connection between dcpext0 and atc-phy. Signed-off-by: Janne Grunau <[email protected]>
1 parent 1a697da commit 6354e3d

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

drivers/gpu/drm/apple/apple_drv.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,17 @@ static int add_dcp_components(struct device *dev,
735735
continue;
736736
}
737737
#endif
738+
739+
/*
740+
* The ATC phy driver is not part of the component
741+
* collection for the Apple display-subsystem so
742+
* ignore it here.
743+
*/
744+
if (of_device_is_compatible(port, "apple,t8103-atcphy")) {
745+
of_node_put(port);
746+
continue;
747+
}
748+
738749
if (of_device_is_available(port))
739750
drm_of_component_match_add(dev, matchptr,
740751
component_compare_of,

drivers/gpu/drm/apple/dcp-internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/phy/phy.h>
1313
#include <linux/platform_device.h>
1414
#include <linux/scatterlist.h>
15+
#include <linux/usb/typec_mux.h>
1516

1617
#include "dptxep.h"
1718
#include "iomfb.h"
@@ -252,6 +253,7 @@ struct apple_dcp {
252253
/* these fields are output port specific */
253254
struct phy *phy;
254255
struct mux_control *xbar;
256+
struct typec_mux *typec_mux;
255257

256258
struct gpio_desc *hdmi_hpd;
257259
struct gpio_desc *hdmi_pwren;

drivers/gpu/drm/apple/dcp.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include <linux/slab.h>
2222
#include <linux/soc/apple/rtkit.h>
2323
#include <linux/string.h>
24+
#include <linux/usb/typec_altmode.h>
25+
#include <linux/usb/typec_dp.h>
26+
#include <linux/usb/typec_mux.h>
2427
#include <linux/workqueue.h>
2528

2629
#include <drm/drm_fb_dma_helper.h>
@@ -1094,6 +1097,8 @@ static void dcp_comp_unbind(struct device *dev, struct device *main, void *data)
10941097
if (dcp->hdmi_hpd_irq)
10951098
disable_irq(dcp->hdmi_hpd_irq);
10961099

1100+
typec_mux_put(dcp->typec_mux);
1101+
10971102
if (dcp->avep) {
10981103
av_service_disconnect(dcp);
10991104
afk_shutdown(dcp->avep);
@@ -1231,6 +1236,27 @@ static int dcp_platform_probe(struct platform_device *pdev)
12311236
ret = mux_control_select(dcp->xbar, mux_index);
12321237
if (ret)
12331238
dev_warn(dev, "mux_control_select failed: %d\n", ret);
1239+
1240+
/*
1241+
* Switch atcphy to DP-only. should move to a Macbook Pro
1242+
* 14-/16-inch specific DP-to-HDMI drm_bridge.
1243+
*/
1244+
dcp->typec_mux = fwnode_typec_mux_get(dev_fwnode(dcp->dev));
1245+
if (!IS_ERR_OR_NULL(dcp->typec_mux)) {
1246+
struct typec_altmode alt = {
1247+
.svid = USB_TYPEC_DP_SID,
1248+
};
1249+
struct typec_mux_state state = {
1250+
.alt = &alt,
1251+
.mode = TYPEC_DP_STATE_C,
1252+
};
1253+
int ret = typec_mux_set(dcp->typec_mux, &state);
1254+
dev_info(dev, "typec_mux_set() returned: %d\n", ret);
1255+
} else {
1256+
dev_info(dev, "fwnode_typec_mux_get() returned: %ld\n",
1257+
IS_ERR(dcp->typec_mux) ? PTR_ERR(dcp->typec_mux) : 0);
1258+
dcp->typec_mux = NULL;
1259+
}
12341260
}
12351261
}
12361262

drivers/gpu/drm/apple/dptxep.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,9 @@ dptxport_call_activate(struct apple_epic_service *service,
479479
const struct apple_dcp *dcp = service->ep->dcp;
480480

481481
// TODO: hack, use phy_set_mode to select the correct DCP(EXT) input
482-
phy_set_mode_ext(dptx->atcphy, PHY_MODE_DP, dcp->index);
482+
// for standalone phy (i.e. not atc phy).
483+
if (!dcp->typec_mux)
484+
phy_set_mode_ext(dptx->atcphy, PHY_MODE_DP, dcp->index);
483485

484486
memcpy(reply, data, min(reply_size, data_size));
485487
if (reply_size >= 4)

0 commit comments

Comments
 (0)