Skip to content

Commit f4f07ee

Browse files
svenpeter42marcan
authored andcommitted
drm: apple: Add DPTX support
This is required for DP Altmode, DP Thunderbolt tunneling and HDMI output on 14/16-inch Macbook Pros and M2* desktop devices. M2* desktops and 14 and 16 inch Macbook Pros expose a DisplayPort to HDMI converter which is driven by the DP output of one of the DCP/DCPext display coprocessor/controller blocks. Two gpio pins are used for power control. Another gpio pin acts as HDMI hpd. Do not use the hpd as direct drm_connector interrupt since that is already wired to DCPs hotplug notification. Instead use it to trigger link setup via the dptx endpoint. Signed-off-by: Sven Peter <sven@svenpeter.dev> Co-developed-by: Janne Grunau <j@jannau.net> Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 27d37bc commit f4f07ee

14 files changed

Lines changed: 1025 additions & 13 deletions

File tree

drivers/gpu/drm/apple/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ config DRM_APPLE
77
select DRM_KMS_DMA_HELPER
88
select DRM_GEM_DMA_HELPER
99
select VIDEOMODE_HELPERS
10+
select MULTIPLEXER
1011
help
1112
Say Y if you have an Apple Silicon chipset.

drivers/gpu/drm/apple/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ CFLAGS_trace.o = -I$(src)
44

55
appledrm-y := apple_drv.o
66

7-
apple_dcp-y := afk.o dcp.o dcp_backlight.o iomfb.o parser.o
7+
apple_dcp-y := afk.o dcp.o dcp_backlight.o dptxep.o iomfb.o parser.o systemep.o
8+
apple_dcp-y += ibootep.o
89
apple_dcp-y += iomfb_v12_3.o
910
apple_dcp-y += iomfb_v13_3.o
1011
apple_dcp-$(CONFIG_TRACING) += trace.o

drivers/gpu/drm/apple/apple_drv.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static const struct drm_crtc_helper_funcs apple_crtc_helper_funcs = {
313313
static int apple_probe_per_dcp(struct device *dev,
314314
struct drm_device *drm,
315315
struct platform_device *dcp,
316-
int num)
316+
int num, bool dcp_ext)
317317
{
318318
struct apple_crtc *crtc;
319319
struct apple_connector *connector;
@@ -345,6 +345,10 @@ static int apple_probe_per_dcp(struct device *dev,
345345
drm_connector_helper_add(&connector->base,
346346
&apple_connector_helper_funcs);
347347

348+
// HACK:
349+
if (dcp_ext)
350+
connector->base.fwnode = fwnode_handle_get(dev->fwnode);
351+
348352
ret = drm_connector_init(drm, &connector->base, &apple_connector_funcs,
349353
dcp_get_connector_type(dcp));
350354
if (ret)
@@ -396,6 +400,7 @@ static int apple_get_fb_resource(struct device *dev, const char *name,
396400

397401
static const struct of_device_id apple_dcp_id_tbl[] = {
398402
{ .compatible = "apple,dcp" },
403+
{ .compatible = "apple,dcpext" },
399404
{},
400405
};
401406

@@ -408,18 +413,20 @@ static int apple_drm_init_dcp(struct device *dev)
408413
int i, ret, num_dcp = 0;
409414

410415
for_each_matching_node(np, apple_dcp_id_tbl) {
416+
bool dcp_ext;
411417
if (!of_device_is_available(np)) {
412418
of_node_put(np);
413419
continue;
414420
}
421+
dcp_ext = of_device_is_compatible(np, "apple,dcpext");
415422

416423
dcp[num_dcp] = of_find_device_by_node(np);
417424
of_node_put(np);
418425
if (!dcp[num_dcp])
419426
continue;
420427

421428
ret = apple_probe_per_dcp(dev, &apple->drm, dcp[num_dcp],
422-
num_dcp);
429+
num_dcp, dcp_ext);
423430
if (ret)
424431
continue;
425432

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
#include <linux/backlight.h>
88
#include <linux/device.h>
99
#include <linux/mutex.h>
10+
#include <linux/mux/consumer.h>
11+
#include <linux/phy/phy.h>
1012
#include <linux/platform_device.h>
1113
#include <linux/scatterlist.h>
1214

15+
#include "dptxep.h"
1316
#include "iomfb.h"
1417
#include "iomfb_v12_3.h"
1518
#include "iomfb_v13_3.h"
@@ -94,6 +97,10 @@ struct dcp_panel {
9497
bool has_mini_led;
9598
};
9699

100+
struct apple_dcp_hw_data {
101+
u32 num_dptx_ports;
102+
};
103+
97104
/* TODO: move IOMFB members to its own struct */
98105
struct apple_dcp {
99106
struct device *dev;
@@ -103,6 +110,8 @@ struct apple_dcp {
103110
struct apple_crtc *crtc;
104111
struct apple_connector *connector;
105112

113+
struct apple_dcp_hw_data hw;
114+
106115
/* firmware version and compatible firmware version */
107116
enum dcp_firmware_version fw_compat;
108117

@@ -127,6 +136,8 @@ struct apple_dcp {
127136
struct resource *disp_registers[MAX_DISP_REGISTERS];
128137
unsigned int nr_disp_registers;
129138

139+
u32 index;
140+
130141
/* Bitmap of memory descriptors used for mappings made by the DCP */
131142
DECLARE_BITMAP(memdesc_map, DCP_MAX_MAPPINGS);
132143

@@ -191,6 +202,29 @@ struct apple_dcp {
191202

192203
/* integrated panel if present */
193204
struct dcp_panel panel;
205+
206+
struct apple_dcp_afkep *systemep;
207+
struct completion systemep_done;
208+
209+
struct apple_dcp_afkep *ibootep;
210+
211+
struct apple_dcp_afkep *dptxep;
212+
213+
struct dptx_port dptxport[2];
214+
215+
/* these fields are output port specific */
216+
struct phy *phy;
217+
struct mux_control *xbar;
218+
219+
struct gpio_desc *hdmi_hpd;
220+
struct gpio_desc *hdmi_pwren;
221+
struct gpio_desc *dp2hdmi_pwren;
222+
223+
struct mutex hpd_mutex;
224+
225+
u32 dptx_phy;
226+
u32 dptx_die;
227+
int hdmi_hpd_irq;
194228
};
195229

196230
int dcp_backlight_register(struct apple_dcp *dcp);

0 commit comments

Comments
 (0)