Skip to content
Merged
8 changes: 8 additions & 0 deletions arch/arm64/boot/dts/apple/t6030-dcp.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
<0x2 0x8e850000 0x0 0x4000>;
power-domains = <&ps_disp_cpu>;
clocks = <&clk_disp0>;
/* Display bandwidth request slot in the disp-5 window. */
apple,bw-scratch = <&pmgr_dcp 0 5 0x988>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
Expand All @@ -97,6 +99,12 @@
};
};

pmgr_dcp: power-management@3503d0000 {
reg = <0x3 0x503d0000 0x0 0x4000>;
reg-names = "dcp-fw-pmgr";
#apple,bw-scratch-cells = <3>;
};

dcpext_dart: iommu@2d130c000 {
compatible = "apple,t6030-dart", "apple,t8110-dart";
reg = <0x2 0xd130c000 0x0 0x4000>;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/apple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ appledrm-$(CONFIG_DRM_APPLE_DCP_T8152) += t8152_hdmi.o t8152_typec.o
appledrm-$(CONFIG_DRM_APPLE_DCP_T8152) += iomfb_iboot.o iboot_drm.o
appledrm-y += iomfb_h17p.o
appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += iomfb_h17p_test.o parser_test.o
appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += iomfb_v27_test.o
appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += iomfb_external_hdr_hints_test.o
appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += apple_resume_test.o
appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += apple_boot_display_test.o
Expand Down
216 changes: 216 additions & 0 deletions drivers/gpu/drm/apple/dcp-firmware-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,226 @@ static void dcp_firmware_27_empty_clock_table(struct kunit *test)
KUNIT_EXPECT_EQ(test, dcp_firmware_clocks_v27(dcp), -EINVAL);
}

/*
* Explicit match-data and image-UUID pins stay ahead of generic firmware-27
* admission: T8122 wrong/missing 27.2 UUIDs and internal T8142 unknown 27.x
* builds are terminally refused rather than using generic v27 or H17P,
* while generic refmac DCPs (T6030, T8112) take firmware 27 on complete 27.x
* method tables and refuse incomplete ones.
*/
static void dcp_firmware_27_pin_precedence(struct kunit *test)
{
static const char t6030[] = "apple,t6030-dcp";
static const char t6041[] = "apple,t6041-dcp\0apple,dcp";
static const char t6041_ext[] = "apple,t6041-dcpext\0apple,dcpext";
static const char t8122[] = "apple,t8122-dcp\0apple,dcp";
static const char t8122_ext[] = "apple,t8122-dcpext\0apple,dcpext";
static const char t8142[] = "apple,t8142-dcp";
#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132)
static const char t8132[] = "apple,t8132-dcp";
#endif
static const char bad_uuid[] = "00000000-0000-0000-0000-000000000000";
__be32 compat_26_6[] = { cpu_to_be32(26), cpu_to_be32(6), cpu_to_be32(2) };
__be32 compat_27_0[] = { cpu_to_be32(27), 0, 0 };
__be32 compat_27_1[] = { cpu_to_be32(27), cpu_to_be32(1), 0 };
__be32 compat_27_2[] = { cpu_to_be32(27), cpu_to_be32(2), 0 };
__be32 compat_27_3[] = { cpu_to_be32(27), cpu_to_be32(3), 0 };
struct dcp_pin_precedence_fixture {
struct property props[4];
struct property ext_props[3];
struct device_node node;
struct device_node ext_node;
struct device dev;
} *fx;

fx = kunit_kzalloc(test, sizeof(*fx), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, fx);

fx->props[0] = (struct property) {
.name = "apple,firmware-compat",
.length = sizeof(compat_27_2),
.value = compat_27_2,
.next = &fx->props[1],
};
fx->props[1] = (struct property) {
.name = "apple,firmware-version",
.length = sizeof(compat_27_2),
.value = compat_27_2,
.next = &fx->props[2],
};
fx->props[2] = (struct property) {
.name = "apple,firmware-uuid",
.length = sizeof(bad_uuid),
.value = (void *)bad_uuid,
.next = &fx->props[3],
};
fx->props[3] = (struct property) {
.name = "compatible",
.length = sizeof(t6030),
.value = (void *)t6030,
};
fx->ext_props[0] = (struct property) {
.name = "apple,firmware-compat",
.length = sizeof(compat_27_2),
.value = compat_27_2,
.next = &fx->ext_props[1],
};
fx->ext_props[1] = (struct property) {
.name = "apple,firmware-version",
.length = sizeof(compat_27_2),
.value = compat_27_2,
.next = &fx->ext_props[2],
};
fx->ext_props[2] = (struct property) {
.name = "compatible",
.length = sizeof(t8122_ext),
.value = (void *)t8122_ext,
};
fx->node.properties = fx->props;
fx->ext_node.properties = fx->ext_props;
fx->dev.init_name = "dcp-firmware-test";
fx->dev.of_node = &fx->node;
fx->dev.driver = &apple_platform_driver.driver;

KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_V_27_0);

fx->props[0].value = compat_27_3;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_UNKNOWN);
fx->props[0].value = compat_27_2;

/* T6041 internal and external UUID pins remain enforced on 27.2. */
fx->props[3].length = sizeof(t6041);
fx->props[3].value = (void *)t6041;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_UNKNOWN);

fx->props[2].length = sizeof(APPLE_T6041_DCP_26B123_UUID);
fx->props[2].value = (void *)APPLE_T6041_DCP_26B123_UUID;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_V_27_0);

fx->props[3].length = sizeof(t6041_ext);
fx->props[3].value = (void *)t6041_ext;
fx->props[2].length = sizeof(bad_uuid);
fx->props[2].value = (void *)bad_uuid;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_UNKNOWN);

fx->props[2].name = "apple,unrelated";
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_UNKNOWN);

fx->props[2].name = "apple,firmware-uuid";
fx->props[2].length = sizeof(APPLE_T6041_DCP_26B123_UUID);
fx->props[2].value = (void *)APPLE_T6041_DCP_26B123_UUID;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_V_27_0);

/* T8122 wrong or missing 27.2 UUID is terminally refused (never takes generic v27). */
fx->props[3].length = sizeof(t8122);
fx->props[3].value = (void *)t8122;
fx->props[2].name = "apple,firmware-uuid";
fx->props[2].length = sizeof(bad_uuid);
fx->props[2].value = (void *)bad_uuid;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_UNKNOWN);
KUNIT_EXPECT_FALSE(test,
apple_t8122_dcpext_v27_2_for_internal(&fx->ext_node, &fx->node));

fx->props[2].name = "apple,unrelated";
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_UNKNOWN);
KUNIT_EXPECT_FALSE(test,
apple_t8122_dcpext_v27_2_for_internal(&fx->ext_node, &fx->node));

fx->props[2].name = "apple,firmware-uuid";
fx->props[2].length = sizeof(APPLE_T8122_DCP_26B123_UUID);
fx->props[2].value = (void *)APPLE_T8122_DCP_26B123_UUID;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_V_27_0);
KUNIT_EXPECT_TRUE(test,
apple_t8122_dcpext_v27_2_for_internal(&fx->ext_node, &fx->node));

/* T8122 external with mismatched version is terminally refused regardless of live tree. */
fx->ext_props[1].value = compat_27_0;
KUNIT_EXPECT_FALSE(test,
apple_t8122_dcpext_v27_2_for_internal(&fx->ext_node, &fx->node));
fx->dev.of_node = &fx->ext_node;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_UNKNOWN);
fx->ext_props[1].value = compat_27_2;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
apple_t8122_dcpext_v27_2(&fx->ext_node) ?
DCP_FIRMWARE_V_27_0 : DCP_FIRMWARE_UNKNOWN);
fx->dev.of_node = &fx->node;

/* Internal T8142: known 27.x takes v27, unknown 27.x is refused (never takes H17P). */
fx->props[3].length = sizeof(t8142);
fx->props[3].value = (void *)t8142;
fx->props[0].value = compat_27_0;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_V_27_0);
fx->props[0].value = compat_27_2;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_V_27_0);
fx->props[0].value = compat_27_1;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_UNKNOWN);
fx->props[0].value = compat_27_3;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_UNKNOWN);
fx->props[0].value = compat_26_6;
KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev),
DCP_FIRMWARE_H17P);
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. */
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);
#endif
}

static void dcp_typec_routes_available_children(struct kunit *test)
{
static const char disabled[] = "disabled";
static const char okay[] = "okay";
struct property child_status = {
.name = "status", .length = sizeof(disabled), .value = (void *)disabled,
};
struct device_node child = {
.name = "route", .full_name = "route@0", .properties = &child_status,
};
struct device_node routes = {
.name = "typec-routes", .full_name = "typec-routes",
};
struct device_node parent = {
.name = "dcp", .full_name = "dcp", .child = &routes,
};

/* Empty typec-routes container has no available route children. */
KUNIT_EXPECT_FALSE(test, dcp_has_available_typec_routes(&parent));

/* Container with only disabled child routes has no available routes. */
routes.child = &child;
KUNIT_EXPECT_FALSE(test, dcp_has_available_typec_routes(&parent));

/* Available child route activates Type-C route detection. */
child_status.length = sizeof(okay);
child_status.value = (void *)okay;
KUNIT_EXPECT_TRUE(test, dcp_has_available_typec_routes(&parent));
}

static struct kunit_case dcp_firmware_cases[] = {
KUNIT_CASE(dcp_firmware_13_5_compat),
KUNIT_CASE(dcp_firmware_27_method_admission),
KUNIT_CASE(dcp_firmware_27_empty_clock_table),
KUNIT_CASE(dcp_firmware_27_pin_precedence),
KUNIT_CASE(dcp_typec_routes_available_children),
{}
};

Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/apple/dcp-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ struct apple_dcp_hw_data {
* standard RTKit wake instead of starting or restarting the ASC.
*/
bool adopt_live_session;
/* Bootloader property marking this DCP as running under iBoot. */
const char *iboot_handoff;
enum dcp_firmware_version firmware_compat;
/* Firmware-visible clock aperture, independent of the AP PMGR window. */
const struct resource *firmware_clock;
Expand Down
Loading
Loading