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
8 changes: 4 additions & 4 deletions Documentation/devicetree/bindings/phy/apple,dptx-phy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ maintainers:

description: |
Hardware resources of the Apple Silicon DisplayPort transmitter PHY.
The interface is described for discovery and must remain disabled until
its ownership, initialization and shutdown are supported. Register windows
are listed in hardware resource order; firmware configuration and tuning
data are supplied by the boot firmware rather than this binding.
Register windows are listed in hardware resource order; firmware
configuration and tuning data are supplied by the boot firmware rather
than this binding.

select:
properties:
Expand Down Expand Up @@ -72,6 +71,7 @@ patternProperties:
required:
- compatible
- reg
- reg-names
- power-domains
- '#phy-cells'

Expand Down
5 changes: 3 additions & 2 deletions arch/arm64/boot/dts/apple/t8122-peripherals.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,9 @@

dptx_phy: phy@2c7540000 {
compatible = "apple,t8122-dptx-phy", "apple,dptx-phy";
reg = <0x2 0xc7540000 0x0 0x10000>,
<0x2 0xc7500000 0x0 0x4000>;
reg = <0x2 0xc7500000 0x0 0x4000>,
<0x2 0xc7540000 0x0 0x10000>;
reg-names = "core", "dptx";
power-domains = <&ps_dptx_ext_phy>;
#phy-cells = <0>;
status = "disabled";
Expand Down
63 changes: 58 additions & 5 deletions arch/arm64/boot/dts/apple/t8132-j773g.dts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
model = "Apple Mac mini (M4, 2024)";
chassis-type = "desktop";

aliases {
/* The loader and the display DART find the PIODMA stream by it. */
disp0_piodma = &disp0_piodma;
};

/*
* The speaker amp's shutdown line (SDZ, AP GPIO 15, the ADT
* function-reset; low = shutdown).
Expand All @@ -34,13 +39,61 @@
};
};

&soc {
dptx_phy: phy@39a700000 {
compatible = "apple,t8122-dptx-phy", "apple,dptx-phy";
reg = <0x3 0x9a700000 0x0 0x4000>,
<0x3 0x9a740000 0x0 0x10000>;
reg-names = "core", "dptx";
power-domains = <&ps_dptx_phy>;
#phy-cells = <0>;
status = "okay";
};
};

&dcp_mbox {
/* iBoot leaves DISP_CPU in auto mode; Linux must not switch it. */
/delete-property/ power-domains;
status = "okay";
};

&dcp_dart {
status = "okay";
};

&disp0_dart {
status = "okay";
};

&dcp {
/* iBoot leaves DISP_CPU in auto mode; Linux must not switch it. */
/delete-property/ power-domains;
/* Its PIODMA child owns iommu-addresses entries in /reserved-memory. */
#address-cells = <2>;
#size-cells = <2>;
apple,connector-type = "HDMI-A";
apple,dptx-phy = <4>;
phys = <&dptx_phy>;
phy-names = "dp-phy";
hdmi-pwren-gpios = <&smc_gpio 15 GPIO_ACTIVE_HIGH>;
dp2hdmi-pwren-gpios = <&smc_gpio 26 GPIO_ACTIVE_HIGH>;
status = "okay";
};

&disp0_piodma {
status = "okay";
};

&display {
status = "okay";
};

/*
* iBoot scans out through dispext0 to the HDMI port (dptx-phy and a
* DP-to-HDMI converter at i2c0 0x08, hot-plug on AOP GPIO 41): keep the
* power domains used for it on.
* The DPTX PHY's domain: the J713 PMGR policy keeps it from Linux, and the
* PHY (and the DCP that waits on it) would never probe.
*/
&framebuffer0 {
power-domains = <&ps_dispext0_fe>, <&ps_dptx_phy>;
&ps_dptx_phy {
status = "okay";
};

/*
Expand Down
71 changes: 57 additions & 14 deletions drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,8 @@ static int apple_probe_typec_ports(struct drm_device *drm,
return 0;
}

static bool apple_t8132_main_external_present(void);

static int apple_get_fb_resource(struct device *dev, const char *name,
struct resource *fb_r)
{
Expand All @@ -1364,7 +1366,9 @@ static int apple_get_fb_resource(struct device *dev, const char *name,
goto err;
}

if (!of_device_is_compatible(node, "framebuffer")) {
if (!of_device_is_compatible(node, "framebuffer") &&
!(apple_t8132_main_external_present() &&
of_device_is_compatible(node, "apple,asc-mem"))) {
dev_err(dev, "reserved-memory node '%s' is incompatible\n",
node->full_name);
goto err;
Expand Down Expand Up @@ -1425,6 +1429,16 @@ static const struct of_device_id apple_dcp_id_tbl[] = {
{},
};

static bool apple_t8132_main_external_present(void)
{
struct device_node *np = of_find_compatible_node(NULL, NULL,
"apple,t8132-dcp");
bool present = dcp_t8132_main_external(np) && of_device_is_available(np);

of_node_put(np);
return present;
}

/*
* A supported firmware-described external provider participates in component
* matching. A T6030 external display processor is a pipe of this DRM device
Expand All @@ -1433,7 +1447,7 @@ static const struct of_device_id apple_dcp_id_tbl[] = {
*/
static bool apple_dcp_usable(struct device_node *np)
{
return of_device_is_available(np) &&
return of_device_is_available(np) && !dcp_t8132_main_external(np) &&
(!of_device_is_compatible(np, "apple,t6030-dcpext") ||
dcp_t6030_ext_native(np)) &&
(!of_device_is_compatible(np, "apple,t8140-dcpext") ||
Expand Down Expand Up @@ -1488,6 +1502,15 @@ static void apple_dcp_start_fn(struct work_struct *work)
w->ret = dcp_start(w->dcp);
}

static bool apple_drm_has_output(struct drm_device *drm)
{
struct drm_crtc *crtc;

drm_for_each_crtc(crtc, drm)
return true;
return false;
}

static int apple_drm_init_dcp(struct device *dev)
{
struct apple_drm_private *apple = dev_get_drvdata(dev);
Expand Down Expand Up @@ -1545,8 +1568,17 @@ static int apple_drm_init_dcp(struct device *dev)
num_dcp++;
}

if (num_dcp < 1)
return -ENODEV;
if (num_dcp < 1) {
if (!apple_t8132_main_external_present())
return -ENODEV;
ret = t8132_ext_drm_init(&apple->drm);
if (ret)
dev_warn(dev, "T8132 main external output was not registered: %d\n",
ret);
else if (!apple_drm_has_output(&apple->drm))
ret = -ENODEV;
return ret;
}

/*
* Build the Type-C port connectors before starting any pipeline: a
Expand Down Expand Up @@ -1682,9 +1714,11 @@ static int apple_drm_init(struct device *dev)
apple->drm.mode_config.funcs = &apple_mode_config_funcs;
apple->drm.mode_config.helper_private = &apple_mode_config_helpers;

ret = component_bind_all(dev, apple);
if (ret)
return ret;
if (!apple_t8132_main_external_present()) {
ret = component_bind_all(dev, apple);
if (ret)
return ret;
}

ret = apple_drm_init_dcp(dev);
if (ret)
Expand Down Expand Up @@ -1802,7 +1836,8 @@ static int apple_drm_init(struct device *dev)
err_unbind:
t8132_ext_drm_fini(&apple->drm);
apple_drm_quiesce_connectors(&apple->drm);
component_unbind_all(dev, NULL);
if (!apple_t8132_main_external_present())
component_unbind_all(dev, NULL);
dcp_unlink(&apple->drm);
return ret;
}
Expand All @@ -1825,7 +1860,8 @@ static void apple_drm_uninit(struct device *dev)
drm_dev_unplug(&apple->drm);
drm_atomic_helper_shutdown(&apple->drm);

component_unbind_all(dev, NULL);
if (!apple_t8132_main_external_present())
component_unbind_all(dev, NULL);

dcp_unlink(&apple->drm);
dev_set_drvdata(dev, NULL);
Expand Down Expand Up @@ -1900,10 +1936,14 @@ static int apple_platform_probe(struct platform_device *pdev)

/* add DCP components, handle less than 1 as probe error */
num_dcp = add_dcp_components(mdev, &match);
if (num_dcp < 1)
return -ENODEV;

ret = component_master_add_with_match(mdev, &apple_drm_ops, match);
if (num_dcp < 1) {
if (!apple_t8132_main_external_present())
return -ENODEV;
ret = apple_drm_init(mdev);
} else {
ret = component_master_add_with_match(mdev, &apple_drm_ops,
match);
}
if (ret)
return ret;

Expand All @@ -1919,7 +1959,10 @@ static int apple_platform_probe(struct platform_device *pdev)
static void apple_platform_remove(struct platform_device *pdev)
{
pm_vt_switch_unregister(&pdev->dev);
component_master_del(&pdev->dev, &apple_drm_ops);
if (apple_t8132_main_external_present())
apple_drm_uninit(&pdev->dev);
else
component_master_del(&pdev->dev, &apple_drm_ops);
}

static const struct of_device_id of_match[] = {
Expand Down
15 changes: 15 additions & 0 deletions drivers/gpu/drm/apple/dcp-m4-profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ static const struct dcp_m4_profile dcp_m4_profile_j713 = {
.timing = dcp_m4_timing_j713, .timing_elements = 1,
};

/* The J773g uses the shared firmware ABI for an external output, not a panel. */
static const struct dcp_m4_profile dcp_m4_profile_j773g = {
.name = "J773g", .machine = "apple,j773g",
.panel_width = 2560, .panel_height = 1664, .notch_rows = 64,
.boot_stride = 10240,
.swap_size = 0x1bd8, .swap_surface = 0x588, .swap_dva = 0xe38,
.swap_nullable = 0x1bcb, .swap_tail = 0x1bd6, .swap_nits = 0x35e,
.swap_intent = 0x17c,
.disabled_color = 0xff000000,
.done_method = 590, .done_size = 0x730, .open_method = 457,
.brightness_max = 500, .brightness_default = 120,
.width_mm = 0, .height_mm = 0,
};

/* The J715's panel timing, as macOS reports it (TimingElements, ID 2). */
static const u32 dcp_m4_timing_j715[2][8] = {
{ 2880, 2960, 8, 32, 40, 7710975, 1, 0 },
Expand Down Expand Up @@ -106,6 +120,7 @@ static const struct dcp_m4_profile dcp_m4_profile_j604 = {

static const struct dcp_m4_profile *const dcp_m4_profiles[] = {
&dcp_m4_profile_j713,
&dcp_m4_profile_j773g,
&dcp_m4_profile_j715,
&dcp_m4_profile_j604,
};
Expand Down
Loading
Loading