Skip to content
Merged
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
7 changes: 5 additions & 2 deletions Documentation/devicetree/bindings/phy/apple,dptx-phy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ select:
- apple,t6041-dptx-phy
- apple,t6050-dptx-phy
- apple,t8122-dptx-phy
- apple,t8132-dptx-phy
required:
- compatible

Expand All @@ -36,7 +37,9 @@ properties:
- const: apple,dptx-phy
- const: apple,t6050-dptx-phy
- items:
- const: apple,t6041-dptx-phy
- enum:
- apple,t6041-dptx-phy
- apple,t8132-dptx-phy
- const: apple,t6050-dptx-phy

reg:
Expand All @@ -63,7 +66,7 @@ properties:
The display crossbar's upstream-facing endpoint that feeds this PHY.

patternProperties:
'^apple,(pll-(dcocfg|dtcvreg|dtccal|dcdadj|dlfcfg)|pclkdrv-select)$':
'^apple,(pll-(dcocfg|dtcvreg|dtccal|dcdadj|dlfcfg|rodcoroleakcomp)|pclkdrv-select)$':
$ref: /schemas/types.yaml#/definitions/uint32
description:
PLL and pixel clock driver settings the PHY is programmed with, as the
Expand Down
114 changes: 113 additions & 1 deletion arch/arm64/boot/dts/apple/t8132-j773g.dts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*
* target-type: J773g
*
* Wired from the J773g ADT (macOS 26.6.2).
* Wired from the J773g ADT (macOS 26.6.2; the HDMI port on dcpext0 from the
* macOS 27.2 one).
*
* Copyright The Asahi Linux Contributors
*/
Expand Down Expand Up @@ -43,6 +44,117 @@
power-domains = <&ps_dispext0_fe>, <&ps_dptx_phy>;
};

/*
* The HDMI port as macOS 27.2 drives it: from dispext0 alone (4K60, and
* 4K120 with DSC; the main DCP started and then parked), through the LPDPTX
* PHY and the PS190 DP-to-HDMI converter. It is the M4 Max Mac Studio's HDMI
* port (t6041-j575c-hdmi.dtsi): the same PHY block, converter and rails, and
* it is handed over the same way, on the firmware-27 backend.
*
* Every node is disabled. On macOS 27.2 the boot loader (aura) fills
* dcpext0's firmware memory and firmware clocks, leaves the main DCP running
* idle, and enables the display subsystem on iBoot's framebuffer; the display
* gate (drivers/soc/apple/display-gate.c) then enables this chain and points
* the display subsystem at dispext0's DART. On the M4 26.6.2 firmware path
* none of it is enabled from here.
*/
/ {
reserved-memory {
/* Filled by the boot loader on macOS 27.2, as the J575c's. */
dcpext0_text: dcpext0-text {
compatible = "apple,asc-mem";
reg = <0x0 0x0 0x0 0x4000>;
no-map;
status = "disabled";
};

dcpext0_data: dcpext0-data {
compatible = "apple,asc-mem";
reg = <0x0 0x0 0x0 0x4000>;
no-map;
status = "disabled";
};

dcpext0_heap: dcpext0-heap {
compatible = "apple,asc-mem";
reg = <0x0 0x0 0x0 0x4000>;
no-map;
status = "disabled";
};
};
};

&soc {
/*
* ADT /arm-io/dptx-phy (dptx-phy,t8132, as the J575c's lpdptx-phy0):
* the T6050 layout, a core bank and a dptx bank, and the ADT's PLL
* calibration (FD0FD1SWAP unset). The display crossbar's dfp-endpoint 4
* (lpdptx); dispext0 is its ufp-endpoint 0, which the PHY's source
* select takes as 1, dcpext0's apple,dcp-index.
*/
lpdptx_phy: phy@39a700000 {
compatible = "apple,t8132-dptx-phy", "apple,t6050-dptx-phy";
reg = <0x3 0x9a700000 0x0 0x4000>,
<0x3 0x9a740000 0x0 0x10000>;
reg-names = "core", "dptx";
power-domains = <&ps_dptx_phy>;
#phy-cells = <0>;
#reset-cells = <0>;
apple,ufp-endpoint = <0>;
apple,pll-dcocfg = <0x4>;
apple,pll-dtcvreg = <0xf>;
apple,pll-dtccal = <0x2>;
apple,pll-dcdadj = <0x10>;
apple,pll-dlfcfg = <0x3>;
apple,pll-rodcoroleakcomp = <0x0>;
status = "disabled";
};
};

/*
* No PMP runs off the M4 firmware path, and iBoot leaves DISPEXT0 powered
* with its CPU domain under hardware control: as on the J575c, the pipe has
* no power domain here, and Linux never switches it. Its front end (and
* through it DISPEXT0_SYS) is held by the boot framebuffer only: keep it on
* once the display driver has taken over, or the domain would be powered off
* under the running processor.
*/
&ps_dispext0_fe {
apple,always-on;
};

&dcpext0_mbox {
/delete-property/ power-domains;
};

&dcpext0_dart {
/delete-property/ power-domains;
};

&dispext0_dart {
/delete-property/ power-domains;
};

/*
* ADT /arm-io/dp2hdmi-gpio0: hdmi_hpd on AOP GPIO 41, hdmi_pwr_en on SMC
* gP0f and dp2hdmi_pwr_en on SMC gP1a (the J575c's rails). No Type-C route:
* dcpext0 drives only this port.
*/
&dcpext0 {
/delete-property/ power-domains;
apple,iomfb-surfaces = <1 1 0 0>;
apple,connector-type = "HDMI-A";
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>;
phys = <&lpdptx_phy>;
phy-names = "dp-phy";
/* the crossbar's output 4 (ADT dptx-phy dp-switch-dfp-endpoint) */
apple,dptx-phy = <4>;
memory-region = <&dcpext0_text>, <&dcpext0_data>, <&dcpext0_heap>;
memory-region-names = "text", "data", "heap";
};

/*
* Without this, the PMP firmware faults in the PMC block (0x382800000)
* shortly after it starts on this board. J713 keeps ps_pmc out of Linux
Expand Down
17 changes: 16 additions & 1 deletion drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/workqueue.h>
#include <linux/soc/apple/dp-tunnel.h>
#include <linux/soc/apple/display.h>
#include <linux/soc/apple/t8132.h>

#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
Expand Down Expand Up @@ -1785,6 +1786,8 @@ static const struct of_device_id apple_dcp_id_tbl[] = {
#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132)
{ .compatible = "apple,t8132-dcp" },
#endif
/* apple_dcp_usable(): only one on firmware 27.2 (apple_t8132_dcpext_v27_2()). */
{ .compatible = "apple,t8132-dcpext" },
{},
};

Expand All @@ -1803,7 +1806,19 @@ static bool apple_dcp_usable(struct device_node *np)
dcp_h17p_external_supported(np)) &&
/* t6041_dcpext=0 keeps the T6041 external processors out. */
(!of_device_is_compatible(np, "apple,t6041-dcpext") ||
dcp_t6041_ext_enabled());
dcp_t6041_ext_enabled()) &&
/*
* The T8132 main DCP is the M4 backend's, on its 26.6.2
* firmware path only (see dcp_check_firmware_version()).
*/
(!of_device_is_compatible(np, "apple,t8132-dcp") ||
apple_t8132_firmware_path()) &&
/*
* A T8132 dcpext the M4 backend adopts is no component: its
* outputs are t8132_ext_drm.c's. One on the 27.2 image is a pipe.
*/
(!of_device_is_compatible(np, "apple,t8132-dcpext") ||
apple_t8132_dcpext_v27_2(np));
}

static void apple_drm_quiesce_connectors(struct drm_device *drm)
Expand Down
21 changes: 15 additions & 6 deletions drivers/gpu/drm/apple/dcp-fabric.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#include <linux/phy/phy.h>
#include <linux/slab.h>
#include <linux/suspend.h>
#include <linux/soc/apple/display.h>
#include <linux/soc/apple/dp-tunnel.h>
#include <linux/soc/apple/t8132.h>
#include <linux/usb/typec_altmode.h>
#include <linux/usb/typec_dp.h>
#include <linux/workqueue.h>
Expand Down Expand Up @@ -226,6 +228,17 @@ bool dcp_hdmi_port_attached(struct apple_dcp *dcp)
gpiod_get_value_cansleep(dcp->hdmi_hpd) > 0;
}

bool dcp_t8132_ext_m4_node(const struct device_node *np)
{
return of_device_is_compatible(np, "apple,t8132-dcpext") &&
!apple_t8132_dcpext_v27_2(np);
}

bool dcp_is_t8132_ext(const struct apple_dcp *dcp)
{
return dcp_t8132_ext_m4_node(dcp->dev->of_node);
}

/*
* A route of an adopted T8132 dcpext whose PHY has no DP alt mode: the
* crossbar's DP PHY output has nothing behind it. The board marks the PHYs
Expand All @@ -234,17 +247,12 @@ bool dcp_hdmi_port_attached(struct apple_dcp *dcp)
*/
static bool dcp_typec_route_no_dp_alt(const struct apple_dcp_typec_route *route)
{
if (!of_device_is_compatible(route->dcp->dev->of_node, "apple,t8132-dcpext"))
if (!dcp_is_t8132_ext(route->dcp))
return false;
return IS_ERR_OR_NULL(route->phy) ||
!of_property_read_bool(route->phy->dev.of_node, "apple,dp-alt-mode");
}

bool dcp_is_t8132_ext(const struct apple_dcp *dcp)
{
return of_device_is_compatible(dcp->dev->of_node, "apple,t8132-dcpext");
}

/*
* DP IN outputs (bits 0/1) whose tunnel pixel clock source @route cannot be:
* T6030 even sources only, T8132 its dcpexts (2 and 4), others any.
Expand Down Expand Up @@ -579,6 +587,7 @@ static int dcp_dpxbar_tunnel_select_source(struct mux_control *mux, int state)
return ret;
}

/* A desktop external processor on firmware 27: T6041's, or the J773g's T8132 one. */
static bool dcp_t6041_ext_v27(const struct apple_dcp *dcp)
{
return dcp->fw_compat == DCP_FIRMWARE_V_27_0 && dcp->desktop_external;
Expand Down
7 changes: 6 additions & 1 deletion drivers/gpu/drm/apple/dcp-fabric.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ int dcp_tunnel_set_rate(struct apple_dcp *dcp, struct phy *phy, u32 unit,
u32 link_rate);
int dcp_tunnel_dpin_activate(struct apple_dcp *dcp, u32 unit, bool active);

/* An adopted T8132 dcpext. */
/*
* A T8132 dcpext adopted through the M4 26.6.2 backend (iomfb_m4.c,
* t8132_ext_drm.c). A J773g dcpext on firmware 27.2 is an ordinary
* firmware-27 pipe instead and is neither of these.
*/
bool dcp_t8132_ext_m4_node(const struct device_node *np);
bool dcp_is_t8132_ext(const struct apple_dcp *dcp);

/* DCP probe, resume and endpoint teardown hooks. */
Expand Down
8 changes: 6 additions & 2 deletions drivers/gpu/drm/apple/dcp-firmware-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,15 @@ static void dcp_firmware_27_pin_precedence(struct kunit *test)
fx->props[0].value = compat_27_2;

#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132)
/* T8132 keeps its M4 match-data pin on 27.2. */
/*
* T8132 keeps its M4 match-data pin on 27.2, never generic firmware
* 27: the M4 backend's on its 26.6.2 firmware path, nobody's off it.
*/
fx->props[3].length = sizeof(t8132);
fx->props[3].value = (void *)t8132;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_M4);
apple_t8132_firmware_path() ? DCP_FIRMWARE_M4 :
DCP_FIRMWARE_UNKNOWN);
#endif
}

Expand Down
6 changes: 5 additions & 1 deletion drivers/gpu/drm/apple/dcp-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,11 @@ struct apple_dcp {
bool external;
/* Any external processor (apple,dcpext), whatever its SoC; set at probe. */
bool dcpext;
/* A desktop 26.x external processor (apple,t6041-dcpext) */
/*
* A desktop external processor: apple,t6041-dcpext (26.x or 27.2), or
* the J773g's apple,t8132-dcpext on 27.2 (apple_t8132_dcpext_v27_2()),
* which drives the HDMI port the same way.
*/
bool desktop_external;
/*
* A failsafe dcpext (dcp_ext_is_failsafe(): T8122's, T6041's, T6050's):
Expand Down
Loading
Loading