Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ properties:
minItems: 1
maxItems: 8

dma-noncoherent: true

memory-region:
minItems: 1
maxItems: 64
Expand Down
66 changes: 65 additions & 1 deletion arch/arm64/boot/dts/apple/t8132-j773g.dts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
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;
/* Select the main DCP front end for the 26.6.2 boot framebuffer. */
disp0-fe = &ps_disp_fe;
};

/*
* The speaker amp's shutdown line (SDZ, AP GPIO 15, the ADT
* function-reset; low = shutdown).
Expand All @@ -35,6 +42,62 @@
};
};

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

&dcp_dart {
power-domains = <&ps_disp_cpu>;
};

&disp0_dart {
power-domains = <&ps_disp_cpu>;
};

&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 = <&lpdptx_phy>;
phy-names = "dp-phy";
/* ADT dp2hdmi-gpio0: hdmi_hpd on AOP GPIO 41. */
hdmi-hpd-gpios = <&pinctrl_aop 41 GPIO_ACTIVE_HIGH>;
hdmi-pwren-gpios = <&smc_gpio 15 GPIO_ACTIVE_HIGH>;
dp2hdmi-pwren-gpios = <&smc_gpio 26 GPIO_ACTIVE_HIGH>;
};

/*
* The scanout frontend has no registers. The shared tree keeps it, disabled,
* under /soc, where the loader enables it for the boards with a panel. This
* board describes it at the root because a simple-bus child needs reg. The
* disp0 alias follows the label.
*/
/delete-node/ &display;

/ {
display: display-subsystem {
compatible = "apple,t8132-display-subsystem", "apple,t8132-display-diagnostics";
iommus = <&disp0_dart 0>;
dma-noncoherent;
status = "disabled";
};
};

/*
* Both retained display DARTs sit in DISP_CPU. iBoot leaves this
* state under firmware control and Linux must not touch its register.
* Give the DARTs a logical, always-on domain without a consumer switch.
*/
&ps_disp_cpu {
apple,firmware-owned;
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
Expand All @@ -56,7 +119,8 @@
* idle, and enables the display subsystem on iBoot's framebuffer; the display
* gate (drivers/soc/apple/display-gate.c) then enables the admitted external
* chains and points the display subsystem at their scanout DARTs. On the M4
* 26.6.2 firmware path none of it is enabled from here.
* 26.6.2 firmware path the gate can instead enable the shared physical PHY
* for the main DCP.
*/
/ {
reserved-memory {
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 @@ -2197,6 +2197,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 @@ -2216,7 +2218,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 @@ -2279,6 +2283,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 @@ -2287,7 +2301,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 @@ -2372,6 +2386,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 @@ -2442,8 +2465,17 @@ static int apple_drm_init_dcp(struct device *dev)
}
}

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 @@ -2596,9 +2628,11 @@ static int apple_drm_init(struct device *dev)
*/
apple->drm.mode_config.prefer_shadow = true;

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 @@ -2726,7 +2760,8 @@ static int apple_drm_init(struct device *dev)
disable_work_sync(&apple->notch_console);
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 Down Expand Up @@ -2758,7 +2793,8 @@ static void apple_drm_uninit(struct device *dev)
disable_work_sync(&apple->notch_hotplug);
disable_work_sync(&apple->notch_console);

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 @@ -2834,10 +2870,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 @@ -2853,7 +2893,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