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
8 changes: 0 additions & 8 deletions arch/arm64/boot/dts/apple/t6040-j773s.dts
Original file line number Diff line number Diff line change
Expand Up @@ -934,11 +934,3 @@
*/
#include "t604x-usb4-typec.dtsi"
#include "t6040-usb4-routers.dtsi"

/*
* The routers' LSTX pins (AOP GPIO 49, 51, 53) are in the AOP pin controller. No display gate
* chain uses it on this board, so it is enabled here.
*/
&pinctrl_aop {
status = "okay";
};
11 changes: 9 additions & 2 deletions arch/arm64/boot/dts/apple/t6040-usb4-routers.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
* PCIe tunnels (t6040-usb4.dtsi): the CIO power domains, the router mailboxes, routers, DARTs
* and NHIs. For boards whose ADT has acio0-2, dart-acio0-2 and acio-cpu0-2: J614s, J616s, J773s.
* The loader hands each router its router, adapter and NHI tuning and its DROM over from this
* machine's ADT (usb4-N aliases). The routers' LSTX pins are in the AOP pin controller, which the
* board enables (J773s) or the HDMI display gate enables with its chain (J614s, J616s).
* machine's ADT (usb4-N aliases).
*/
&pmgr_cio {
status = "okay";
};

/*
* The routers' LSTX pins (pinctrl-0, AOP GPIO 49, 51, 53) are in the AOP pin controller. Its
* probe writes no pin register; the display gate only takes it as the HDMI hotplug supplier.
*/
&pinctrl_aop {
status = "okay";
};

&ps_atc0_cio {
status = "okay";
};
Expand Down
7 changes: 6 additions & 1 deletion arch/arm64/boot/dts/apple/t604x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,12 @@
<AIC_IRQ 704 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 705 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 706 IRQ_TYPE_LEVEL_HIGH>;
/* Coprocessor pins and interrupt groups need an ownership handoff. */
/*
* Enabled by a board for the devices that use its pins (the
* T6040 USB4 routers' LSTX pins), and by the display gate for
* the HDMI converter's hotplug input. Its probe writes no pin
* register: each consumer configures only its own pins.
*/
status = "disabled";
};

Expand Down
28 changes: 26 additions & 2 deletions drivers/soc/apple/display-gate-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
* - T6041 on the J616c (t6041-gate-test.dtso): no PMP; each external chain
* is enabled once its processor has firmware memory, one without it or
* already enabled stays as it is, and the chains never write the display
* subsystem's status. The tree has no dcp alias, so the internal display
* handoff finds nothing to adopt.
* subsystem's status. The HDMI converter's hotplug pin controller is
* enabled with the HDMI chain, and one already enabled does not refuse
* it. The tree has no dcp alias, so the internal display handoff finds
* nothing to adopt.
* Included at the end of display-gate.c.
*
* The test trees are applied once and stay: the gate gives some properties
Expand Down Expand Up @@ -1392,6 +1394,8 @@ static void __init gate_t6041_max_enabled(struct kunit *test)
gt_max_expect_chain(test, 0, true);
gt_max_expect_chain(test, 1, true);
gt_max_expect_display(test, BIT(0) | BIT(1));
/* The pin controller of the HDMI converter's hotplug input, with the chain. */
KUNIT_EXPECT_TRUE(test, gt_okay(test, "/pinctrl@510824000"));
}

/* A boot loader that fills nothing leaves everything as it is. */
Expand All @@ -1403,6 +1407,24 @@ static void __init gate_t6041_max_no_memory(struct kunit *test)
gt_max_expect_chain(test, 2, false);
gt_max_expect_chain(test, 3, false);
gt_max_expect_display(test, 0);
KUNIT_EXPECT_FALSE(test, gt_okay(test, "/pinctrl@510824000"));
}

/*
* The hotplug pin controller is a shared supplier, not part of the chain:
* already enabled (a board whose USB4 routers use its pins), it does not
* refuse the HDMI chain, and it stays enabled.
*/
static void __init gate_t6041_max_shared_pins(struct kunit *test)
{
gt_max_fill(test, 0);
gt_max_fill(test, 1);
gt_set_string(test, "/pinctrl@510824000", "status", "okay");
gt_max_run(test);
gt_max_expect_chain(test, 0, true);
gt_max_expect_chain(test, 1, true);
gt_max_expect_display(test, BIT(0) | BIT(1));
KUNIT_EXPECT_TRUE(test, gt_okay(test, "/pinctrl@510824000"));
}

/* With dcpext2 filled too, the second USB-C chain comes up after dcpext1's, its DART last. */
Expand Down Expand Up @@ -1501,6 +1523,7 @@ static void __init gate_t6041_max_one_processor(struct kunit *test)
gt_max_expect_chain(test, 0, false);
gt_max_expect_chain(test, 1, true);
gt_max_expect_display(test, BIT(1));
KUNIT_EXPECT_FALSE(test, gt_okay(test, "/pinctrl@510824000"));
}

/* A region that is still a placeholder keeps the whole chain off. */
Expand Down Expand Up @@ -1612,6 +1635,7 @@ static void __init gate_t6041_max_v27_2(struct kunit *test)
static struct kunit_case gate_t6041_max_cases[] __refdata = {
KUNIT_CASE(gate_t6041_max_enabled),
KUNIT_CASE(gate_t6041_max_no_memory),
KUNIT_CASE(gate_t6041_max_shared_pins),
KUNIT_CASE(gate_t6041_max_second_usbc),
KUNIT_CASE(gate_t6041_max_all_externals),
KUNIT_CASE(gate_t6041_max_dt_routes),
Expand Down
43 changes: 35 additions & 8 deletions drivers/soc/apple/display-gate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2471,7 +2471,7 @@ static struct device_node *staged_routes(const struct gate_staged *st)
}

static const char *const t6041_hdmi_nodes[] = {
/* ATC3 power, PMP DISPEXT0 request, DISPEXT0, AOP pins, PHY, crossbar, DARTs, mailbox, dcpext0 */
/* ATC3 power, PMP DISPEXT0 request, DISPEXT0, PHY, crossbar, DARTs, mailbox, dcpext0 */
"/power-management@502800000/power-controller@408",
"/power-management@508300000/power-controller@e0",
"/power-management@508300000/power-controller@168",
Expand All @@ -2480,7 +2480,6 @@ static const char *const t6041_hdmi_nodes[] = {
"/pmp-report@5003c0000/report@11",
"/power-management@502800000/power-controller@340",
"/power-management@502800000/power-controller@348",
"/pinctrl@510824000",
"/mailbox@39b148000",
"/phy@39aa90000",
"/mux@39b24c000",
Expand Down Expand Up @@ -2525,7 +2524,10 @@ static bool staged_is_route_path(const char *path)
* dcpext1 and dcpext2.
*/
static const char *const t6041_j614s_hdmi_nodes[] = {
/* ATC3 power, PMP DISPEXT2 request, FAB7_SOC, DISPEXT2, AOP pins, PHY, crossbar, DARTs, mailbox, routes, dcpext2 */
/*
* ATC3 power, PMP DISPEXT2 request, FAB7_SOC, DISPEXT2, PHY, crossbar,
* DARTs, mailbox, routes, dcpext2
*/
"/power-management@502800000/power-controller@408",
"/power-management@508300000/power-controller@e0",
"/power-management@508300000/power-controller@168",
Expand All @@ -2535,7 +2537,6 @@ static const char *const t6041_j614s_hdmi_nodes[] = {
"/power-management@502800000/power-controller@488",
"/power-management@502800000/power-controller@4e0",
"/power-management@502800000/power-controller@4e8",
"/pinctrl@510824000",
"/mailbox@39b148000",
"/phy@39aa90000",
"/mux@39b24c000",
Expand Down Expand Up @@ -2693,6 +2694,30 @@ static bool staged_ready(const struct gate_staged *st)
return true;
}

/*
* The pin controller of the HDMI converter's hotplug input (the processor's
* hdmi-hpd-gpios; the processor is the stage's last node) is a supplier the
* chain shares, not part of the handover: on the T6040 the AOP pin controller
* also has the USB4 routers' LSTX pins, and a board that enables the routers
* enables it in its device tree. Its probe writes no pin register; each
* consumer configures only its own pins. So it is not in the chain's
* must-be-disabled check: already enabled it stays as it is, disabled it is
* enabled in the chain's changeset.
*/
static int staged_enable_hpd_supplier(struct of_changeset *cs, const struct gate_staged *st)
{
struct device_node *dcp, *np;
int ret = 0;

dcp = of_find_node_by_path(st->nodes[st->nr - 1]);
np = dcp ? of_parse_phandle(dcp, "hdmi-hpd-gpios", 0) : NULL;
of_node_put(dcp);
if (np && !of_device_is_available(np))
ret = of_changeset_update_prop_string(cs, np, "status", "okay");
of_node_put(np);
return ret;
}

/* Enable @st's nodes and put its display DART into the display subsystem's iommus. */
static int staged_apply(const struct gate_staged *st, struct device_node *display)
{
Expand All @@ -2709,6 +2734,8 @@ static int staged_apply(const struct gate_staged *st, struct device_node *displa
np = of_find_node_by_path(st->dart);
ret = np ? gate_iommus_append(cs, display, np) : -ENODEV;
of_node_put(np);
if (!ret)
ret = staged_enable_hpd_supplier(cs, st);
for (i = 0; !ret && i < st->nr; i++) {
if (staged_is_dcp(st->nodes[i]) || staged_is_route(st->nodes[i]))
continue;
Expand Down Expand Up @@ -3335,13 +3362,12 @@ static void __init gate_t6041_run(void)
* nothing is requested or waited for: the domains are on as iBoot left them.
*/
static const char *const t6041_max_hdmi_nodes[] = {
/* ATC3 power, AOP pins, PHY, crossbar, DARTs, mailbox, dcpext0 */
/* ATC3 power, PHY, crossbar, DARTs, mailbox, dcpext0 */
"/power-management@502800000/power-controller@408",
"/power-management@508300000/power-controller@e0",
"/power-management@508300000/power-controller@168",
"/power-management@508300000/power-controller@b8",
"/power-management@508300000/power-controller@148",
"/pinctrl@510824000",
"/mailbox@39b148000",
"/phy@39aa90000",
"/mux@39b24c000",
Expand Down Expand Up @@ -3450,11 +3476,10 @@ static const struct gate_staged t6041_j575c_usbc2 = {
/*
* The J575c's HDMI chain. Its ATC3 is a USB-C port, and its HDMI port runs
* through the LPDPTX PHY instead (t6041-j575c-hdmi.dtsi): that PHY's power,
* the AOP pins (the converter's hotplug), the PHY, then dcpext0's chain.
* the PHY, then dcpext0's chain.
*/
static const char *const t6041_j575c_hdmi_nodes[] = {
"/power-management@502280000/power-controller@360",
"/pinctrl@510824000",
"/phy@51c200000",
"/iommu@3a2340000",
"/iommu@3a2300000",
Expand Down Expand Up @@ -3551,6 +3576,8 @@ static int __init t6041_max_apply(unsigned int i, struct device_node *display)
np = of_find_node_by_path(st->dart);
ret = np ? gate_iommus_append(cs, display, np) : -ENODEV;
of_node_put(np);
if (!ret)
ret = staged_enable_hpd_supplier(cs, st);
for (n = 0; !ret && n < st->nr; n++) {
/* The routes go in just before their processor, the last node. */
if (n == st->nr - 1)
Expand Down
5 changes: 4 additions & 1 deletion drivers/soc/apple/t6041-gate-test.dtso
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@
};
};

pinctrl@510824000 {
pinctrl_aop: pinctrl@510824000 {
gpio-controller;
#gpio-cells = <2>;
status = "disabled";
};

Expand Down Expand Up @@ -138,6 +140,7 @@
compatible = "apple,t6041-dcpext";
iommus = <&dcpext0_dart 23>;
memory-region = <&dcpext0_data>, <&dcpext0_heap>, <&dcpext0_text>;
hdmi-hpd-gpios = <&pinctrl_aop 36 0>;
status = "disabled";

piodma {
Expand Down
Loading