diff --git a/Documentation/devicetree/bindings/display/apple,dcp.yaml b/Documentation/devicetree/bindings/display/apple,dcp.yaml index 57616c37cda25..6a70e0b74b76a 100644 --- a/Documentation/devicetree/bindings/display/apple,dcp.yaml +++ b/Documentation/devicetree/bindings/display/apple,dcp.yaml @@ -17,6 +17,7 @@ description: properties: compatible: oneOf: + - const: apple,t6034-dcp - items: - enum: - apple,t8103-dcp diff --git a/Documentation/devicetree/bindings/display/apple,display-subsystem.yaml b/Documentation/devicetree/bindings/display/apple,display-subsystem.yaml index 2bff1703d7c94..358a9b7d65f77 100644 --- a/Documentation/devicetree/bindings/display/apple,display-subsystem.yaml +++ b/Documentation/devicetree/bindings/display/apple,display-subsystem.yaml @@ -19,6 +19,7 @@ properties: - enum: - apple,display-subsystem - apple,t6031-display-subsystem + - apple,t6034-display-subsystem - apple,t8122-display-subsystem - apple,t8132-display-subsystem - const: apple,t8132-display-diagnostics diff --git a/Documentation/devicetree/bindings/power/apple,t8140-pmp-report.yaml b/Documentation/devicetree/bindings/power/apple,t8140-pmp-report.yaml index c5cffcf0a28a8..f16a762b83c19 100644 --- a/Documentation/devicetree/bindings/power/apple,t8140-pmp-report.yaml +++ b/Documentation/devicetree/bindings/power/apple,t8140-pmp-report.yaml @@ -56,7 +56,9 @@ properties: - apple,t8140-pmp-v2-report - apple,t8142-pmp-v2-report - items: - - const: apple,t6031-pmp-v2-report + - enum: + - apple,t6031-pmp-v2-report + - apple,t6034-pmp-v2-report - const: apple,t6020-pmp-v2-report reg: diff --git a/Documentation/devicetree/bindings/soc/apple/apple,pmp.yaml b/Documentation/devicetree/bindings/soc/apple/apple,pmp.yaml index 33c9d95e38243..d9cfa5ae5f9ee 100644 --- a/Documentation/devicetree/bindings/soc/apple/apple,pmp.yaml +++ b/Documentation/devicetree/bindings/soc/apple/apple,pmp.yaml @@ -26,6 +26,7 @@ properties: - enum: - apple,t6030-pmp-v2 - apple,t6031-pmp-v2 + - apple,t6034-pmp-v2 - apple,t6041-pmp-v2 - apple,t6050-pmp-v2 - apple,t8122-pmp-v2 diff --git a/arch/arm64/boot/dts/apple/t6034-dcp.dtsi b/arch/arm64/boot/dts/apple/t6034-dcp.dtsi new file mode 100644 index 0000000000000..824549363791b --- /dev/null +++ b/arch/arm64/boot/dts/apple/t6034-dcp.dtsi @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * J514M/T6034 internal display. Fresh ADT metadata identifies the same + * DCP/DART/PMP register layout and 14.7 firmware images as T6031, with a + * 400 MHz disp0 clock. Keep a separate handoff and component compatible; + * every consumer remains disabled until the T6034 gate validates it. + */ +#include "t6031-dcp.dtsi" + +&clk_disp0 { + clock-frequency = <400000000>; +}; + +&display { + compatible = "apple,t6034-display-subsystem"; +}; + +&dcp { + compatible = "apple,t6034-dcp"; +}; + +&pmp { + compatible = "apple,t6034-pmp-v2", "apple,t6000-pmp-v2"; +}; + +&pmp_report { + compatible = "apple,t6034-pmp-v2-report", "apple,t6020-pmp-v2-report"; +}; diff --git a/arch/arm64/boot/dts/apple/t6034-j514m.dts b/arch/arm64/boot/dts/apple/t6034-j514m.dts index f316f52dfa6cf..37ef5c0876755 100644 --- a/arch/arm64/boot/dts/apple/t6034-j514m.dts +++ b/arch/arm64/boot/dts/apple/t6034-j514m.dts @@ -10,7 +10,7 @@ /dts-v1/; #include "t6034.dtsi" -#include "t6031-dcp.dtsi" +#include "t6034-dcp.dtsi" #include "t603x-j514-j516.dtsi" / { diff --git a/arch/arm64/boot/dts/apple/t6034-j516m.dts b/arch/arm64/boot/dts/apple/t6034-j516m.dts index ee28181492a0a..4b617269f7ad4 100644 --- a/arch/arm64/boot/dts/apple/t6034-j516m.dts +++ b/arch/arm64/boot/dts/apple/t6034-j516m.dts @@ -71,3 +71,17 @@ status = "disabled"; }; }; + +/* + * J516M ADT confirms the J516C display register and interrupt layout. + * External displays (dcpext, HDMI) are not described here yet. + */ +&clk_disp0 { + /* + * Preserve the captured boot-clock metadata, as the J514M path does. + * Firmware warns that this is below its video clock; + * that warning is not proof of the programmed clock or a startup veto. + * The metadata does not qualify sustained power or thermal behavior. + */ + clock-frequency = <400000000>; +}; diff --git a/drivers/gpu/drm/apple/Makefile b/drivers/gpu/drm/apple/Makefile index 6098e8efb7c59..e8a862faf8b16 100644 --- a/drivers/gpu/drm/apple/Makefile +++ b/drivers/gpu/drm/apple/Makefile @@ -8,7 +8,7 @@ appledrm-y += dcp-hdmi.o appledrm-$(CONFIG_DRM_APPLE_CEC) += cec.o appledrm-$(CONFIG_DRM_APPLE_AUDIO) += audio.o appledrm-$(CONFIG_DRM_APPLE_AUDIO) += av.o -appledrm-y += connector.o dcp-panel-adt.o dcp-display-metadata.o dcp-180hz.o +appledrm-y += connector.o dcp-panel-adt.o dcp-display-metadata.o dcp-180hz.o dcp-panel-edid.o appledrm-y += ibootep.o appledrm-y += dcpext_scanout.o appledrm-y += dcpext_drm.o @@ -35,6 +35,7 @@ appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_external_ready_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_external_announce_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_external_relink_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_dropped_swap_test.o +appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp-panel-edid-test.o appledrm-y += iomfb_v26_6.o iomfb_v26_6_link.o j613_dcp_activate.o appledrm-y += iomfb_v27.o appledrm-y += epic/dpavservep.o diff --git a/drivers/gpu/drm/apple/apple_drv.c b/drivers/gpu/drm/apple/apple_drv.c index f39238a60bb22..b0e8a365af09d 100644 --- a/drivers/gpu/drm/apple/apple_drv.c +++ b/drivers/gpu/drm/apple/apple_drv.c @@ -125,6 +125,7 @@ static DEFINE_MUTEX(apple_g15_display_lock); static struct device *apple_t6030_display; static struct device *apple_t6031_display; static struct device *apple_t8132_display; +static struct device *apple_t6034_display; #define APPLE_DRM_PUBLISHED_MAX 8 static struct device *apple_drm_published[APPLE_DRM_PUBLISHED_MAX]; @@ -137,6 +138,8 @@ static struct device **apple_g15_display_slot(struct device *dev) return &apple_t6031_display; if (of_device_is_compatible(dev->of_node, "apple,t8132-display-subsystem")) return &apple_t8132_display; + if (of_device_is_compatible(dev->of_node, "apple,t6034-display-subsystem")) + return &apple_t6034_display; return NULL; } @@ -270,6 +273,17 @@ int apple_drm_link_device(struct device *consumer, return -EPROBE_DEFER; } EXPORT_SYMBOL_GPL(apple_drm_link_device); +int apple_drm_t6034_link_device(struct device *consumer) +{ + if (of_machine_is_compatible("apple,j516m")) + return apple_g15_link_device(consumer, "apple,t6034", "apple,agx-t6034", + &apple_t6031_display); + if (!of_machine_is_compatible("apple,j514m")) + return -ENODEV; + return apple_g15_link_device(consumer, "apple,t6034", "apple,agx-t6034", + &apple_t6034_display); +} +EXPORT_SYMBOL_GPL(apple_drm_t6034_link_device); DEFINE_DRM_GEM_DMA_FOPS(apple_fops); @@ -1819,6 +1833,7 @@ static const struct of_device_id apple_dcp_id_tbl[] = { { .compatible = "apple,t6030-dcp" }, { .compatible = "apple,t8122-dcp" }, { .compatible = "apple,t6031-dcp" }, + { .compatible = "apple,t6034-dcp" }, #if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132) { .compatible = "apple,t8132-dcp" }, #endif @@ -2372,6 +2387,7 @@ static const struct of_device_id of_match[] = { { .compatible = "apple,t6030-display-subsystem" }, { .compatible = "apple,t8122-display-subsystem" }, { .compatible = "apple,t6031-display-subsystem" }, + { .compatible = "apple,t6034-display-subsystem" }, #if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132) { .compatible = "apple,t8132-display-subsystem" }, /* Accept the qualified handoff emitted by the existing boot loader. */ diff --git a/drivers/gpu/drm/apple/dcp-internal.h b/drivers/gpu/drm/apple/dcp-internal.h index fd561bc7358cc..079272949a66e 100644 --- a/drivers/gpu/drm/apple/dcp-internal.h +++ b/drivers/gpu/drm/apple/dcp-internal.h @@ -32,6 +32,7 @@ #include "dcp-color.h" #include "dcp-display-metadata.h" #include "dcp-metadata-epoch.h" +#include "dcp-panel-edid.h" #include "dcp-180hz.h" #include "iomfb.h" #include "iomfb_h17p.h" @@ -234,6 +235,8 @@ struct dcp_panel { u32 edr_ceiling; /// calibrated colour target from the raw ADT; NULL if not given const struct dcp_color_space *color_target; + /// make and product for the base EDID, from the panel's compatible + struct dcp_panel_id id; }; /* diff --git a/drivers/gpu/drm/apple/dcp-panel-edid-test.c b/drivers/gpu/drm/apple/dcp-panel-edid-test.c new file mode 100644 index 0000000000000..399f6e5bfd647 --- /dev/null +++ b/drivers/gpu/drm/apple/dcp-panel-edid-test.c @@ -0,0 +1,276 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +/* + * The built-in panel's EDID, read back with the DRM EDID helpers: the make, + * product, model year and native timing come from the panel's compatible and + * the model table; the base block holds the panel's geometry at 60 Hz with P3 + * colour and gamma 2.2, the DisplayID extension the 120 Hz timing; an update + * publishes both blocks on the connector and adds no mode. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "dcp-panel-edid.h" + +#define J516_W_MM 346 +#define J516_H_MM 216 + +static void panel_id_j516(struct kunit *test, struct dcp_panel_id *id) +{ + KUNIT_ASSERT_EQ(test, dcp_panel_id_from_compatible(id, "apple,panel-j516"), 0); +} + +static void panel_id_from_compatible(struct kunit *test) +{ + struct dcp_panel_id id; + + panel_id_j516(test, &id); + KUNIT_EXPECT_STREQ(test, id.vendor, "APP"); + KUNIT_EXPECT_STREQ(test, id.name, "J516"); + KUNIT_EXPECT_EQ(test, id.model_year, 2023); + KUNIT_EXPECT_EQ(test, id.timing.clock_khz, 1042130); + KUNIT_EXPECT_EQ(test, id.timing.vtotal, 2456); + /* A model without a known year and timing gets none, and no EDID. */ + KUNIT_ASSERT_EQ(test, dcp_panel_id_from_compatible(&id, "apple,panel-j999"), 0); + KUNIT_EXPECT_EQ(test, id.model_year, 0); + KUNIT_EXPECT_EQ(test, id.timing.clock_khz, 0); +} + +static void panel_id_needs_a_model_and_a_known_vendor(struct kunit *test) +{ + struct dcp_panel_id id; + + KUNIT_EXPECT_EQ(test, dcp_panel_id_from_compatible(&id, "apple,panel"), -EINVAL); + KUNIT_EXPECT_EQ(test, dcp_panel_id_from_compatible(&id, "apple,panel-"), -EINVAL); + KUNIT_EXPECT_EQ(test, dcp_panel_id_from_compatible(&id, "panel-j516"), -EINVAL); + KUNIT_EXPECT_EQ(test, dcp_panel_id_from_compatible(&id, "acme,panel-j516"), -ENOENT); + KUNIT_EXPECT_EQ(test, dcp_panel_id_from_compatible(&id, "apple,panel-j516 x"), -EINVAL); + KUNIT_EXPECT_EQ(test, dcp_panel_id_from_compatible(&id, + "apple,panel-j5160000000000"), + -EINVAL); +} + +static const struct drm_edid *panel_edid_j516(struct kunit *test, + u8 e[DCP_PANEL_EDID_BLOCKS * EDID_LENGTH]) +{ + struct dcp_panel_id id; + const struct drm_edid *edid; + + panel_id_j516(test, &id); + KUNIT_ASSERT_EQ(test, dcp_panel_edid_build(&id, J516_W_MM, J516_H_MM, e), 0); + edid = drm_edid_alloc(e, DCP_PANEL_EDID_BLOCKS * EDID_LENGTH); + KUNIT_ASSERT_NOT_NULL(test, edid); + return edid; +} + +static u8 sum(const u8 *p, size_t len) +{ + u8 s = 0; + + while (len--) + s += *p++; + return s; +} + +static void panel_edid_parses_with_make_product_and_size(struct kunit *test) +{ + struct drm_edid_product_id product; + u8 e[DCP_PANEL_EDID_BLOCKS * EDID_LENGTH]; + const struct drm_edid *edid = panel_edid_j516(test, e); + const struct edid *raw; + char vendor[4], name[14]; + + KUNIT_EXPECT_TRUE(test, drm_edid_valid(edid)); + drm_edid_get_product_id(edid, &product); + drm_edid_decode_mfg_id(be16_to_cpu(product.manufacturer_name), vendor); + KUNIT_EXPECT_STREQ(test, vendor, "APP"); + KUNIT_EXPECT_EQ(test, le16_to_cpu(product.product_code), 0); + KUNIT_EXPECT_EQ(test, le32_to_cpu(product.serial_number), 0); + + raw = drm_edid_raw(edid); + KUNIT_ASSERT_NOT_NULL(test, raw); + drm_edid_get_monitor_name(raw, name, sizeof(name)); + KUNIT_EXPECT_STREQ(test, name, "J516"); + /* The connector's size (the firmware's), in whole centimetres. */ + KUNIT_EXPECT_EQ(test, raw->width_cm, 35); + KUNIT_EXPECT_EQ(test, raw->height_cm, 22); + /* Gamma 2.2, not 1.00 (0) and not "in an extension" (0xff). */ + KUNIT_EXPECT_EQ(test, raw->gamma, 0x78); + /* Model year 2023: week 0xff, year 2023 - 1990. */ + KUNIT_EXPECT_EQ(test, raw->mfg_week, 0xff); + KUNIT_EXPECT_EQ(test, raw->mfg_year, 33); + /* P3 red (0.680, 0.320) and the D65 white point (0.3127, 0.3290), 10-bit. */ + KUNIT_EXPECT_EQ(test, raw->red_x << 2 | raw->red_green_lo >> 6, 696); + KUNIT_EXPECT_EQ(test, raw->red_y << 2 | (raw->red_green_lo >> 4 & 3), 328); + KUNIT_EXPECT_EQ(test, raw->white_x << 2 | (raw->blue_white_lo >> 2 & 3), 320); + KUNIT_EXPECT_EQ(test, raw->white_y << 2 | (raw->blue_white_lo & 3), 337); + /* One extension; both blocks sum to 0. */ + KUNIT_EXPECT_EQ(test, raw->extensions, 1); + KUNIT_EXPECT_EQ(test, sum(e, EDID_LENGTH), 0); + KUNIT_EXPECT_EQ(test, sum(e + EDID_LENGTH, EDID_LENGTH), 0); + drm_edid_free(edid); +} + +/* + * The base block's first descriptor is the panel's geometry at 60 Hz (its 120 Hz + * clock does not fit the 16-bit field); the DisplayID extension holds the real + * 120 Hz timing as its preferred Type VII timing. + */ +static void panel_edid_timings_are_the_panels(struct kunit *test) +{ + u8 e[DCP_PANEL_EDID_BLOCKS * EDID_LENGTH]; + const struct drm_edid *edid = panel_edid_j516(test, e); + const struct edid *raw = drm_edid_raw(edid); + const struct detailed_timing *d = &raw->detailed_timings[0]; + const struct detailed_pixel_timing *pt = &d->data.pixel_data; + const u8 *ext = e + EDID_LENGTH, *section = ext + 1, *t; + unsigned int i, names = 0; + + /* 3536 x 2456 x 60 Hz = 521.06 MHz, in 10 kHz. */ + KUNIT_EXPECT_EQ(test, le16_to_cpu(d->pixel_clock), 52106); + KUNIT_EXPECT_EQ(test, pt->hactive_lo | (pt->hactive_hblank_hi >> 4) << 8, 3456); + KUNIT_EXPECT_EQ(test, pt->hblank_lo | (pt->hactive_hblank_hi & 0xf) << 8, 80); + KUNIT_EXPECT_EQ(test, pt->vactive_lo | (pt->vactive_vblank_hi >> 4) << 8, 2234); + KUNIT_EXPECT_EQ(test, pt->vblank_lo | (pt->vactive_vblank_hi & 0xf) << 8, 222); + KUNIT_EXPECT_EQ(test, pt->hsync_offset_lo, 8); + KUNIT_EXPECT_EQ(test, pt->hsync_pulse_width_lo, 32); + /* The front porch at the field's 63, the sync width the panel's 8. */ + KUNIT_EXPECT_EQ(test, (pt->vsync_offset_pulse_width_lo >> 4) | + (pt->hsync_vsync_offset_pulse_width_hi >> 2 & 3) << 4, 63); + KUNIT_EXPECT_EQ(test, pt->vsync_offset_pulse_width_lo & 0xf, 8); + KUNIT_EXPECT_EQ(test, pt->width_mm_lo | (pt->width_height_mm_hi >> 4) << 8, J516_W_MM); + KUNIT_EXPECT_EQ(test, pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8, J516_H_MM); + /* It is not the preferred mode with its refresh rate. */ + KUNIT_EXPECT_EQ(test, raw->features & DRM_EDID_FEATURE_PREFERRED_TIMING, 0); + for (i = 1; i < ARRAY_SIZE(raw->detailed_timings); i++) { + const struct detailed_timing *o = &raw->detailed_timings[i]; + + KUNIT_EXPECT_EQ(test, le16_to_cpu(o->pixel_clock), 0); + KUNIT_EXPECT_NE(test, o->data.other_data.type, EDID_DETAIL_MONITOR_SERIAL); + KUNIT_EXPECT_NE(test, o->data.other_data.type, EDID_DETAIL_MONITOR_RANGE); + names += o->data.other_data.type == EDID_DETAIL_MONITOR_NAME; + } + KUNIT_EXPECT_EQ(test, names, 1); + for (i = 0; i < sizeof(raw->established_timings); i++) + KUNIT_EXPECT_EQ(test, ((const u8 *)&raw->established_timings)[i], 0); + + /* DisplayID 2.0, generic display, Display Parameters then one Type VII timing. */ + KUNIT_EXPECT_EQ(test, ext[0], 0x70); + KUNIT_EXPECT_EQ(test, section[0], 0x20); + KUNIT_EXPECT_EQ(test, section[2], 0x02); + KUNIT_ASSERT_EQ(test, section[1], 3 + 29 + 3 + 20); + KUNIT_EXPECT_EQ(test, sum(section, 4 + section[1] + 1), 0); + KUNIT_EXPECT_EQ(test, section[4], 0x21); + KUNIT_EXPECT_EQ(test, section[6], 29); + /* Image size in 0.1 mm, the native pixels, gamma 2.2. */ + KUNIT_EXPECT_EQ(test, section[7] | section[8] << 8, J516_W_MM * 10); + KUNIT_EXPECT_EQ(test, section[9] | section[10] << 8, J516_H_MM * 10); + KUNIT_EXPECT_EQ(test, section[11] | section[12] << 8, 3456); + KUNIT_EXPECT_EQ(test, section[13] | section[14] << 8, 2234); + KUNIT_EXPECT_EQ(test, section[7 + 28], 0x78); + t = section + 4 + 3 + 29; + KUNIT_EXPECT_EQ(test, t[0], 0x22); + KUNIT_EXPECT_EQ(test, t[2], 20); + t += 3; + /* 1042130 kHz, preferred, and the DCP mode line's porches (each minus one). */ + KUNIT_EXPECT_EQ(test, t[0] | t[1] << 8 | t[2] << 16, 1042130 - 1); + KUNIT_EXPECT_EQ(test, t[3] & 0x80, 0x80); + KUNIT_EXPECT_EQ(test, t[4] | t[5] << 8, 3456 - 1); + KUNIT_EXPECT_EQ(test, t[6] | t[7] << 8, 3536 - 3456 - 1); + KUNIT_EXPECT_EQ(test, (t[8] | t[9] << 8) & 0x7fff, 3464 - 3456 - 1); + KUNIT_EXPECT_EQ(test, t[10] | t[11] << 8, 3496 - 3464 - 1); + KUNIT_EXPECT_EQ(test, t[12] | t[13] << 8, 2234 - 1); + KUNIT_EXPECT_EQ(test, t[14] | t[15] << 8, 2456 - 2234 - 1); + KUNIT_EXPECT_EQ(test, (t[16] | t[17] << 8) & 0x7fff, 2352 - 2234 - 1); + KUNIT_EXPECT_EQ(test, t[18] | t[19] << 8, 2360 - 2352 - 1); + drm_edid_free(edid); +} + +static void panel_edid_refuses_a_size_it_cannot_hold(struct kunit *test) +{ + u8 e[DCP_PANEL_EDID_BLOCKS * EDID_LENGTH]; + struct dcp_panel_id id; + + panel_id_j516(test, &id); + KUNIT_EXPECT_EQ(test, dcp_panel_edid_build(&id, 0, J516_H_MM, e), -EINVAL); + KUNIT_EXPECT_EQ(test, dcp_panel_edid_build(&id, J516_W_MM, 2560, e), -EINVAL); + id.model_year = 2005; + KUNIT_EXPECT_EQ(test, dcp_panel_edid_build(&id, J516_W_MM, J516_H_MM, e), -EINVAL); + id.model_year = 2023; + id.timing.clock_khz = 0; + KUNIT_EXPECT_EQ(test, dcp_panel_edid_build(&id, J516_W_MM, J516_H_MM, e), -EINVAL); + panel_id_j516(test, &id); + id.vendor[0] = '\0'; + KUNIT_EXPECT_EQ(test, dcp_panel_edid_build(&id, J516_W_MM, J516_H_MM, e), -EINVAL); +} + +struct panel_edid_test { + struct drm_device drm; + struct drm_connector connector; +}; + +/* The DRM KUnit device is atomic: a connector needs its state helpers. */ +static const struct drm_connector_funcs panel_edid_connector_funcs = { + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, +}; + +static void panel_edid_update_publishes_the_block(struct kunit *test) +{ + struct panel_edid_test *t; + struct drm_connector *connector; + struct dcp_panel_id id; + struct device *dev; + int ret; + + dev = drm_kunit_helper_alloc_device(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); + t = drm_kunit_helper_alloc_drm_device(test, dev, struct panel_edid_test, drm, + DRIVER_MODESET); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, t); + connector = &t->connector; + ret = drmm_connector_init(&t->drm, connector, &panel_edid_connector_funcs, + DRM_MODE_CONNECTOR_eDP, NULL); + KUNIT_ASSERT_EQ(test, ret, 0); + + panel_id_j516(test, &id); + mutex_lock(&t->drm.mode_config.mutex); + ret = dcp_panel_edid_update(connector, &id, J516_W_MM, J516_H_MM); + mutex_unlock(&t->drm.mode_config.mutex); + KUNIT_ASSERT_EQ(test, ret, 0); + + /* The update sets 350x220 from the block; dcp_get_modes() restores the mm. */ + KUNIT_EXPECT_EQ(test, connector->display_info.width_mm, 350); + KUNIT_EXPECT_EQ(test, connector->display_info.height_mm, 220); + KUNIT_ASSERT_NOT_NULL(test, connector->edid_blob_ptr); + KUNIT_EXPECT_EQ(test, connector->edid_blob_ptr->length, 2 * EDID_LENGTH); + /* The update adds no mode: the modes stay the firmware's. */ + KUNIT_EXPECT_TRUE(test, list_empty(&connector->probed_modes)); +} + +static struct kunit_case panel_edid_cases[] = { + KUNIT_CASE(panel_id_from_compatible), + KUNIT_CASE(panel_id_needs_a_model_and_a_known_vendor), + KUNIT_CASE(panel_edid_parses_with_make_product_and_size), + KUNIT_CASE(panel_edid_timings_are_the_panels), + KUNIT_CASE(panel_edid_refuses_a_size_it_cannot_hold), + KUNIT_CASE(panel_edid_update_publishes_the_block), + {} +}; + +static struct kunit_suite panel_edid_suite = { + .name = "apple-dcp-panel-edid", + .test_cases = panel_edid_cases, +}; + +kunit_test_suite(panel_edid_suite); diff --git a/drivers/gpu/drm/apple/dcp-panel-edid.c b/drivers/gpu/drm/apple/dcp-panel-edid.c new file mode 100644 index 0000000000000..97eee16101697 --- /dev/null +++ b/drivers/gpu/drm/apple/dcp-panel-edid.c @@ -0,0 +1,354 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* + * An EDID for a built-in panel. + * + * The DCP gives no EDID for a built-in panel, so a compositor sees no make, + * model or physical size for it. This builds one from what the panel's + * device-tree node and a table of the known panel models say: the vendor and + * model of its most specific compatible ("apple,panel-j516": make APP, name + * J516), the size the connector has, the model year, the panel's native timing + * as the DCP's mode line gives it with all rows shown, and the colour of a P3 + * wide-colour panel (P3 primaries, D65 white point and a nominal gamma of + * 2.2, which the sRGB transfer function of Display P3 approximates). + * + * The native timing is 3456x2234 at 120 Hz with a pixel clock of 1042 MHz. + * The base block's detailed timing cannot hold it: its pixel clock field is + * 16 bits in 10 kHz units (at most 655.35 MHz) and its vertical front porch 6 + * bits. The base block therefore carries the panel's geometry at 60 Hz (the + * same totals and horizontal porches, the vertical front porch at most 63 + * lines), and a DisplayID 2.0 extension carries the real 120 Hz timing as its + * preferred timing, with the display parameters. Neither is a mode source: + * the driver publishes the firmware's modes and never adds modes from this + * EDID. It makes no other claim: no product code or serial number, no + * manufacture week, no luminance and no refresh range. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "dcp-panel-edid.h" + +/* Device-tree vendor prefixes and their PNP IDs. */ +static const struct { + const char *prefix; + const char *pnp; +} dcp_panel_vendors[] = { + { "apple", "APP" }, +}; + +/* + * Panel models: the year their machines came out (the EDID model year) and the + * native timing of the DCP's mode line, with the rows the notch hides shown. + */ +static const struct { + const char *name; + u16 year; + struct dcp_panel_timing timing; +} dcp_panel_models[] = { + /* MacBook Pro (16-inch, M3 Pro or M3 Max): 3456x2234 at 120 Hz */ + { "J516", 2023, { 1042130, 3456, 3464, 3496, 3536, 2234, 2352, 2360, 2456 } }, +}; + +/* EDID 1.4: a nominal gamma of 2.2 is (2.2 - 1) * 100 = 120. */ +#define DCP_PANEL_EDID_GAMMA 120 +/* EDID 1.4: week 0xff marks the year byte as the model year, from 1990. */ +#define DCP_PANEL_EDID_MODEL_YEAR 0xff +/* The base block's detailed timing: the panel's geometry at this rate. */ +#define DCP_PANEL_EDID_DTD_HZ 60 +/* EDID 1.4 detailed timing: the vertical front porch field is 6 bits. */ +#define DCP_PANEL_EDID_DTD_VFP_MAX 63 + +/* P3 primaries and the D65 white point, CIE 1931 x and y in 1/10000. */ +static const u16 dcp_panel_p3[8] = { 6800, 3200, 2650, 6900, 1500, 600, 3127, 3290 }; + +/* DisplayID 2.0 (VESA DisplayID Standard v2.0). */ +#define DISPLAYID_EXT 0x70 /* EDID extension tag */ +#define DISPLAYID_V20 0x20 /* structure version 2, revision 0 */ +#define DISPLAYID_GENERIC 0x02 /* primary use case: generic display */ +#define DISPLAYID_PARAMS 0x21 /* Display Parameters data block */ +#define DISPLAYID_PARAMS_LEN 29 +#define DISPLAYID_TYPE7 0x22 /* Type VII detailed timing data block */ +#define DISPLAYID_TYPE7_LEN 20 +#define DISPLAYID_PREFERRED 0x80 /* timing options: preferred */ +#define DISPLAYID_ASPECT_NONE 0x08 /* aspect ratio not given (from the pixels) */ +#define DISPLAYID_SYNC_POS 0x8000 /* front porch word: positive sync */ +#define DISPLAYID_NO_SPEAKERS 0x80 /* features: audio not integrated */ +#define DISPLAYID_TECH_LCD 0x10 /* device technology: active-matrix LCD */ + +int dcp_panel_id_from_compatible(struct dcp_panel_id *id, const char *compatible) +{ + const char *comma = strchr(compatible, ','), *model; + size_t vendor_len, len, i; + + memset(id, 0, sizeof(*id)); + if (!comma) + return -EINVAL; + vendor_len = comma - compatible; + model = comma + 1; + if (str_has_prefix(model, "panel-")) + model += strlen("panel-"); + else + return -EINVAL; + len = strlen(model); + if (!len || len > DCP_PANEL_NAME_LEN) + return -EINVAL; + for (i = 0; i < len; i++) { + if (!isalnum(model[i]) && model[i] != '-') + return -EINVAL; + id->name[i] = toupper(model[i]); + } + + for (i = 0; i < ARRAY_SIZE(dcp_panel_models); i++) { + if (!strcmp(id->name, dcp_panel_models[i].name)) { + id->model_year = dcp_panel_models[i].year; + id->timing = dcp_panel_models[i].timing; + } + } + for (i = 0; i < ARRAY_SIZE(dcp_panel_vendors); i++) { + if (strlen(dcp_panel_vendors[i].prefix) == vendor_len && + !strncmp(compatible, dcp_panel_vendors[i].prefix, vendor_len)) { + strscpy(id->vendor, dcp_panel_vendors[i].pnp); + return 0; + } + } + memset(id, 0, sizeof(*id)); + return -ENOENT; +} + +static void put_le16(u8 *p, u16 v) +{ + p[0] = v; + p[1] = v >> 8; +} + +static void checksum(u8 *start, size_t len) +{ + u8 sum = 0; + size_t i; + + for (i = 0; i < len - 1; i++) + sum += start[i]; + start[len - 1] = -sum; +} + +static bool timing_valid(const struct dcp_panel_timing *t) +{ + return t->clock_khz && t->hdisplay < t->hsync_start && t->hsync_start < t->hsync_end && + t->hsync_end < t->htotal && t->htotal - t->hdisplay < 4096 && + t->vdisplay < t->vsync_start && t->vsync_start < t->vsync_end && + t->vsync_end < t->vtotal && t->vtotal - t->vdisplay < 4096 && + t->hsync_start - t->hdisplay < 1024 && t->hsync_end - t->hsync_start < 1024 && + t->vsync_end - t->vsync_start < 64; +} + +/* The base block's detailed timing: the panel's geometry at DCP_PANEL_EDID_DTD_HZ. */ +static void base_dtd(u8 *d, const struct dcp_panel_timing *t, int width_mm, int height_mm) +{ + u32 clock = DIV_ROUND_CLOSEST((u32)t->htotal * t->vtotal * DCP_PANEL_EDID_DTD_HZ, 10000); + u16 hblank = t->htotal - t->hdisplay, vblank = t->vtotal - t->vdisplay; + u16 hfp = t->hsync_start - t->hdisplay, hsw = t->hsync_end - t->hsync_start; + u16 vfp = min_t(u16, t->vsync_start - t->vdisplay, DCP_PANEL_EDID_DTD_VFP_MAX); + u16 vsw = t->vsync_end - t->vsync_start; + + put_le16(d, clock); + d[2] = t->hdisplay; + d[3] = hblank; + d[4] = (t->hdisplay >> 8) << 4 | hblank >> 8; + d[5] = t->vdisplay; + d[6] = vblank; + d[7] = (t->vdisplay >> 8) << 4 | vblank >> 8; + d[8] = hfp; + d[9] = hsw; + d[10] = (vfp & 0xf) << 4 | (vsw & 0xf); + d[11] = (hfp >> 8) << 6 | (hsw >> 8) << 4 | (vfp >> 4) << 2 | (vsw >> 4); + d[12] = width_mm; + d[13] = height_mm; + d[14] = (width_mm >> 8) << 4 | height_mm >> 8; + /* Digital separate sync, positive vertical and horizontal sync. */ + d[17] = 0x1e; +} + +/* The P3/D65 chromaticity of the base block, in 10-bit fractions. */ +static void base_chromaticity(struct edid *block) +{ + u16 v[8]; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(v); i++) + v[i] = DIV_ROUND_CLOSEST(dcp_panel_p3[i] * 1024, 10000); + block->red_green_lo = (v[0] & 3) << 6 | (v[1] & 3) << 4 | (v[2] & 3) << 2 | (v[3] & 3); + block->blue_white_lo = (v[4] & 3) << 6 | (v[5] & 3) << 4 | (v[6] & 3) << 2 | (v[7] & 3); + block->red_x = v[0] >> 2; + block->red_y = v[1] >> 2; + block->green_x = v[2] >> 2; + block->green_y = v[3] >> 2; + block->blue_x = v[4] >> 2; + block->blue_y = v[5] >> 2; + block->white_x = v[6] >> 2; + block->white_y = v[7] >> 2; +} + +static int base_block(const struct dcp_panel_id *id, int width_mm, int height_mm, + struct edid *block) +{ + struct detailed_non_pixel *name; + u16 manufacturer = 0; + size_t len = strnlen(id->name, sizeof(id->name)); + unsigned int i; + + for (i = 0; i < 3; i++) { + if (id->vendor[i] < 'A' || id->vendor[i] > 'Z') + return -EINVAL; + manufacturer = manufacturer << 5 | (id->vendor[i] - '@'); + } + + memset(block, 0, sizeof(*block)); + memcpy(block->header, "\x00\xff\xff\xff\xff\xff\xff\x00", sizeof(block->header)); + block->product_id.manufacturer_name = cpu_to_be16(manufacturer); + block->mfg_week = DCP_PANEL_EDID_MODEL_YEAR; + block->mfg_year = id->model_year - 1990; + block->version = 1; + block->revision = 4; + block->input = DRM_EDID_INPUT_DIGITAL; + block->width_cm = DIV_ROUND_CLOSEST(width_mm, 10); + block->height_cm = DIV_ROUND_CLOSEST(height_mm, 10); + block->gamma = DCP_PANEL_EDID_GAMMA; + base_chromaticity(block); + /* Standard timings 0x0101 are unused slots. */ + memset(block->standard_timings, 0x01, sizeof(block->standard_timings)); + + /* EDID 1.4: the first descriptor is a detailed timing; the second names the panel. */ + base_dtd((u8 *)&block->detailed_timings[0], &id->timing, width_mm, height_mm); + name = &block->detailed_timings[1].data.other_data; + name->type = EDID_DETAIL_MONITOR_NAME; + memset(name->data.str.str, ' ', sizeof(name->data.str.str)); + memcpy(name->data.str.str, id->name, len); + if (len < sizeof(name->data.str.str)) + name->data.str.str[len] = '\n'; + for (i = 2; i < ARRAY_SIZE(block->detailed_timings); i++) + block->detailed_timings[i].data.other_data.type = 0x10; + block->extensions = DCP_PANEL_EDID_BLOCKS - 1; + checksum((u8 *)block, EDID_LENGTH); + return 0; +} + +/* DisplayID 2.0 CIE 1931 x/y pair in 12-bit fractions, packed in 3 bytes. */ +static void displayid_xy(u8 *p, u16 x, u16 y) +{ + u16 X = DIV_ROUND_CLOSEST(x * 4095, 10000), Y = DIV_ROUND_CLOSEST(y * 4095, 10000); + + p[0] = X; + p[1] = (X >> 8) | (Y & 0xf) << 4; + p[2] = Y >> 4; +} + +/* The DisplayID 2.0 extension: display parameters and the 120 Hz Type VII timing. */ +static void displayid_block(const struct dcp_panel_id *id, int width_mm, int height_mm, + u8 *ext) +{ + const struct dcp_panel_timing *t = &id->timing; + u8 *section = ext + 1, *p, *b; + unsigned int i; + + memset(ext, 0, EDID_LENGTH); + ext[0] = DISPLAYID_EXT; + section[0] = DISPLAYID_V20; + section[1] = 3 + DISPLAYID_PARAMS_LEN + 3 + DISPLAYID_TYPE7_LEN; + section[2] = DISPLAYID_GENERIC; + section[3] = 0; /* no further DisplayID extensions */ + + b = section + 4; + b[0] = DISPLAYID_PARAMS; + b[2] = DISPLAYID_PARAMS_LEN; + p = b + 3; + put_le16(p + 0, width_mm * 10); /* 0.1 mm */ + put_le16(p + 2, height_mm * 10); + put_le16(p + 4, t->hdisplay); + put_le16(p + 6, t->vdisplay); + /* Left to right, top to bottom; CIE 1931; the speakers are not the panel's. */ + p[8] = DISPLAYID_NO_SPEAKERS; + for (i = 0; i < 4; i++) + displayid_xy(p + 9 + 3 * i, dcp_panel_p3[2 * i], dcp_panel_p3[2 * i + 1]); + /* Bytes 21-26, the luminances, are not known: left 0. Colour depth not given. */ + p[27] = DISPLAYID_TECH_LCD; + p[28] = DCP_PANEL_EDID_GAMMA; + + b = p + DISPLAYID_PARAMS_LEN; + b[0] = DISPLAYID_TYPE7; + b[2] = DISPLAYID_TYPE7_LEN; + p = b + 3; + /* Pixel clock in kHz minus one, 24 bits. */ + p[0] = (t->clock_khz - 1); + p[1] = (t->clock_khz - 1) >> 8; + p[2] = (t->clock_khz - 1) >> 16; + p[3] = DISPLAYID_PREFERRED | DISPLAYID_ASPECT_NONE; + /* Each field minus one; the front porch words carry the sync polarity. */ + put_le16(p + 4, t->hdisplay - 1); + put_le16(p + 6, t->htotal - t->hdisplay - 1); + put_le16(p + 8, (t->hsync_start - t->hdisplay - 1) | DISPLAYID_SYNC_POS); + put_le16(p + 10, t->hsync_end - t->hsync_start - 1); + put_le16(p + 12, t->vdisplay - 1); + put_le16(p + 14, t->vtotal - t->vdisplay - 1); + put_le16(p + 16, (t->vsync_start - t->vdisplay - 1) | DISPLAYID_SYNC_POS); + put_le16(p + 18, t->vsync_end - t->vsync_start - 1); + + /* The section's checksum after its payload, then the block's. */ + checksum(section, 4 + section[1] + 1); + checksum(ext, EDID_LENGTH); +} + +int dcp_panel_edid_build(const struct dcp_panel_id *id, int width_mm, int height_mm, + u8 edid[DCP_PANEL_EDID_BLOCKS * EDID_LENGTH]) +{ + size_t len = strnlen(id->name, sizeof(id->name)); + int ret; + + if (width_mm <= 0 || height_mm <= 0 || width_mm > 4095 || height_mm > 4095 || + DIV_ROUND_CLOSEST(width_mm, 10) > 255 || DIV_ROUND_CLOSEST(height_mm, 10) > 255) + return -EINVAL; + if (strnlen(id->vendor, sizeof(id->vendor)) != 3 || !len || len > DCP_PANEL_NAME_LEN) + return -EINVAL; + /* EDID 1.4 reserves the years before 2006. */ + if (id->model_year < 2006 || id->model_year > 1990 + 255) + return -EINVAL; + if (!timing_valid(&id->timing)) + return -EINVAL; + ret = base_block(id, width_mm, height_mm, (struct edid *)edid); + if (ret) + return ret; + displayid_block(id, width_mm, height_mm, edid + EDID_LENGTH); + return 0; +} + +int dcp_panel_edid_update(struct drm_connector *connector, const struct dcp_panel_id *id, + int width_mm, int height_mm) +{ + const struct drm_edid *edid; + u8 *blocks; + int ret; + + blocks = kmalloc(DCP_PANEL_EDID_BLOCKS * EDID_LENGTH, GFP_KERNEL); + if (!blocks) + return -ENOMEM; + ret = dcp_panel_edid_build(id, width_mm, height_mm, blocks); + if (ret) + goto out; + edid = drm_edid_alloc(blocks, DCP_PANEL_EDID_BLOCKS * EDID_LENGTH); + if (!edid) { + ret = -ENOMEM; + goto out; + } + /* This sets the connector's size from the block, in whole centimetres. */ + ret = drm_edid_connector_update(connector, edid); + drm_edid_free(edid); +out: + kfree(blocks); + return ret; +} diff --git a/drivers/gpu/drm/apple/dcp-panel-edid.h b/drivers/gpu/drm/apple/dcp-panel-edid.h new file mode 100644 index 0000000000000..1e9a6242831b1 --- /dev/null +++ b/drivers/gpu/drm/apple/dcp-panel-edid.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* A base EDID for a built-in panel, from its device-tree node. */ +#ifndef __APPLE_DCP_PANEL_EDID_H__ +#define __APPLE_DCP_PANEL_EDID_H__ + +#include + +/* The monitor-name text of an EDID descriptor holds 13 characters. */ +#define DCP_PANEL_NAME_LEN 13 + +/* An EDID of a base block and one DisplayID extension. */ +#define DCP_PANEL_EDID_BLOCKS 2 + +/* A panel's native timing, as the DCP's mode line gives it (all rows shown). */ +struct dcp_panel_timing { + u32 clock_khz; + u16 hdisplay, hsync_start, hsync_end, htotal; + u16 vdisplay, vsync_start, vsync_end, vtotal; +}; + +/* The make, product, model year and native timing of a panel. */ +struct dcp_panel_id { + char vendor[4]; /* PNP ID, empty if unknown */ + char name[DCP_PANEL_NAME_LEN + 1]; /* monitor name */ + u16 model_year; /* the model's year, 0 if unknown */ + struct dcp_panel_timing timing; /* zero if unknown */ +}; + +struct drm_connector; + +int dcp_panel_id_from_compatible(struct dcp_panel_id *id, const char *compatible); +int dcp_panel_edid_build(const struct dcp_panel_id *id, int width_mm, int height_mm, + u8 edid[DCP_PANEL_EDID_BLOCKS * 128]); +int dcp_panel_edid_update(struct drm_connector *connector, const struct dcp_panel_id *id, + int width_mm, int height_mm); + +#endif diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 5e72a0dc79d9e..3ed96ece7fb2a 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -7189,6 +7189,8 @@ static int dcp_comp_bind_pipe(struct device *dev, struct device *main, void *dat panel_np = of_get_compatible_child(dev->of_node, "apple,panel"); if (panel_np) { + const char *compatible; + if (dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP) { /* * Desktop 26.x swaps carry nits, and the panel node @@ -7207,6 +7209,12 @@ static int dcp_comp_bind_pipe(struct device *dev, struct device *main, void *dat } dcp_panel_read_dimensions(dcp, panel_np); + /* The most specific compatible names the panel for its EDID. */ + if (iomfb_v14_7_base_edid(dcp) && + !of_property_read_string_index(panel_np, "compatible", 0, &compatible) && + dcp_panel_id_from_compatible(&dcp->panel.id, compatible)) + dev_dbg(dev, "no EDID make and product in '%s'\n", compatible); + of_node_put(panel_np); /* Read target metadata for H17P and desktop firmware alike. */ dcp_panel_read_adt(dcp); @@ -11471,6 +11479,7 @@ static const struct of_device_id of_match[] = { { .compatible = "apple,t6030-dcpext", .data = &apple_dcp_hw_t6030_dcpext, }, { .compatible = "apple,t8122-dcp", .data = &apple_dcp_hw_t8122, }, { .compatible = "apple,t6031-dcp", .data = &apple_dcp_hw_t6031, }, + { .compatible = "apple,t6034-dcp", .data = &apple_dcp_hw_t6031, }, { .compatible = "apple,t8122-dcpext", .data = &apple_dcp_hw_t8122_dcpext, }, { .compatible = "apple,dcp", .data = &apple_dcp_hw_dcp, }, { .compatible = "apple,dcpext", .data = &apple_dcp_hw_dcpext, }, diff --git a/drivers/gpu/drm/apple/iomfb.c b/drivers/gpu/drm/apple/iomfb.c index cbc093e132fc8..14f5861343663 100644 --- a/drivers/gpu/drm/apple/iomfb.c +++ b/drivers/gpu/drm/apple/iomfb.c @@ -2932,6 +2932,22 @@ int dcp_get_modes(struct drm_connector *connector) if (dcp->hw.link_report) dcp_note_edid(apple_connector, apple_connector->drm_edid); } + } else if (nr_modes && dcp_is_v14_7_panel(dcp) && dcp->panel.id.vendor[0]) { + /* + * No EDID comes for this panel: publish the base block of its + * node, sized as the connector is (the firmware's size, else the + * node's), then give the connector back its size in millimetres. + */ + int update; + + dcp_update_connector_dimensions(dcp, connector); + update = dcp_panel_edid_update(connector, &dcp->panel.id, + connector->display_info.width_mm, + connector->display_info.height_mm); + dcp_update_connector_dimensions(dcp, connector); + apple_connector->drm_edid_firmware_derived = false; + if (update) + dev_warn_once(dcp->dev, "panel EDID publication failed: %d\n", update); } else { u64 generation = 0; u32 defaults = 0; diff --git a/drivers/gpu/drm/apple/iomfb_v14_7.c b/drivers/gpu/drm/apple/iomfb_v14_7.c index 5b0983a643b74..2dafb23a90b8b 100644 --- a/drivers/gpu/drm/apple/iomfb_v14_7.c +++ b/drivers/gpu/drm/apple/iomfb_v14_7.c @@ -198,6 +198,27 @@ static const struct dcp_v14_board dcp_v14_board_j516c = { * at most), as the e272b67 path on this J516C presented it. */ .panel_nits = true, + .base_edid = true, +}; + +/* J516M uses the J516C image; its first boot offered only a 120 Hz panel timing. */ +static const struct dcp_v14_board dcp_v14_board_j516m = { + .name = "J516M", + .debugfs = "dcp-j516m", + .dcp_compatible = "apple,t6031-dcp", + .machine = "apple,j516m", + .soc = "apple,t6034", + .firmware_uuid = DCP_V14_J516C_FIRMWARE_UUID, + .handoff = "apple,t6031-handoff", + .panel_width = 3456, + .panel_height = 2234, + .promotion = true, + .log_bringup = true, + .base_edid = true, + /* Same pinned DCP image as J516C: zero stamps cap this panel at 60 fps. */ + .swap_timestamps = true, + /* J516C's 14.7 image uses the bounded nits block for the J516 panel. */ + .panel_nits = true, }; /* @@ -218,6 +239,19 @@ static const struct dcp_v14_board dcp_v14_board_j514c = { .log_bringup = true, }; +/* J514M's 14.7 DCP image and panel geometry; the root SoC is required too. */ +static const struct dcp_v14_board dcp_v14_board_j514m = { + .name = "J514M", + .debugfs = "dcp-j514m", + .dcp_compatible = "apple,t6034-dcp", + .machine = "apple,j514m", + .soc = "apple,t6034", + .firmware_uuid = DCP_V14_J516C_FIRMWARE_UUID, + .handoff = "apple,t6034-handoff", + .promotion = true, + .log_bringup = true, +}; + static const struct dcp_v14_board *const dcp_v14_boards[] = { &dcp_v14_board_t6030, &dcp_v14_board_j613, @@ -225,6 +259,8 @@ static const struct dcp_v14_board *const dcp_v14_boards[] = { &dcp_v14_board_j504, &dcp_v14_board_j516c, &dcp_v14_board_j514c, + &dcp_v14_board_j514m, + &dcp_v14_board_j516m, }; struct dcp_v14_property { @@ -354,7 +390,7 @@ static int dcp_v14_callback(void *cookie, u32 tag, const void *input, u32 in_siz static void dcp_v14_backlight_work(struct work_struct *work); -/* The internal panel of a board whose swap level block was validated (T6030). */ +/* The internal panel of a board admitted to the bounded swap level path. */ static bool dcp_v14_board_nits(const struct apple_dcp_v14 *v14) { return !v14->external && v14->panel_nits && v14->board && v14->board->panel_nits; @@ -1682,7 +1718,8 @@ const struct dcp_v14_board *dcp_v14_board_select(dcp_v14_compat_fn dcp_is, if (!dcp_is(ctx, board->dcp_compatible)) continue; *dcp_known = true; - if (board->machine && !machine_is(ctx, board->machine)) + if ((board->machine && !machine_is(ctx, board->machine)) || + (board->soc && !machine_is(ctx, board->soc))) continue; if (board->panel && !panel_is(ctx, board->panel)) continue; @@ -1742,7 +1779,8 @@ static bool dcp_v14_panel_nits_admit(const struct dcp_v14_board *board, return board && board->panel_nits && (board->panel || machine_is(ctx, "apple,j514s") || machine_is(ctx, "apple,j516s") || - machine_is(ctx, "apple,j516c") || machine_is(ctx, "apple,j613")); + machine_is(ctx, "apple,j516c") || machine_is(ctx, "apple,j613") || + machine_is(ctx, "apple,j516m")); } const char *iomfb_v14_7_board_name(const struct dcp_v14_board *board) @@ -1755,6 +1793,11 @@ bool dcp_v14_board_stamps_swaps(const struct dcp_v14_board *board, bool external return board && !external && board->swap_timestamps; } +bool iomfb_v14_7_base_edid(const struct apple_dcp *dcp) +{ + return dcp->v14 && dcp->v14->board && dcp->v14->board->base_edid; +} + int iomfb_v14_7_probe(struct apple_dcp *dcp) { struct device *dev = dcp->dev; diff --git a/drivers/gpu/drm/apple/iomfb_v14_7.h b/drivers/gpu/drm/apple/iomfb_v14_7.h index 8aa4eeda4be7a..7eb6ada2b1c26 100644 --- a/drivers/gpu/drm/apple/iomfb_v14_7.h +++ b/drivers/gpu/drm/apple/iomfb_v14_7.h @@ -28,6 +28,8 @@ const __be32 *of_translate_dma_region_checked(struct device_node *dev, */ const struct dcp_v14_board *iomfb_v14_7_board(struct device *dev); const char *iomfb_v14_7_board_name(const struct dcp_v14_board *board); +/* Whether the internal panel's board record gives it a base EDID. */ +bool iomfb_v14_7_base_edid(const struct apple_dcp *dcp); /* Platform probe: firmware identity, boot loader handoff, PMP acknowledgment. */ int iomfb_v14_7_probe(struct apple_dcp *dcp); diff --git a/drivers/gpu/drm/apple/iomfb_v14_7_board.h b/drivers/gpu/drm/apple/iomfb_v14_7_board.h index 8394a99f3d2f5..ee3d805e79db5 100644 --- a/drivers/gpu/drm/apple/iomfb_v14_7_board.h +++ b/drivers/gpu/drm/apple/iomfb_v14_7_board.h @@ -21,6 +21,8 @@ struct dcp_v14_board { const char *machine; /* The compatible of the DCP's "panel" child; NULL for any panel. */ const char *panel; + /* Optional additional root SoC restriction. */ + const char *soc; /* The firmware image whose layouts were tested on this board. */ const char *firmware_uuid; /* Set to <1> by the boot loader on the DCP, display and PIODMA nodes. */ @@ -50,6 +52,11 @@ struct dcp_v14_board { bool swap_timestamps; /* This board has a qualified panel level block; machine admission is separate. */ bool panel_nits; + /* + * The panel gets a base EDID (make, model and size) built from its + * device-tree node, as the firmware gives none. + */ + bool base_edid; }; /* diff --git a/drivers/gpu/drm/apple/v14-board-test.c b/drivers/gpu/drm/apple/v14-board-test.c index 3148bc81c0458..2a44ac045e133 100644 --- a/drivers/gpu/drm/apple/v14-board-test.c +++ b/drivers/gpu/drm/apple/v14-board-test.c @@ -66,7 +66,11 @@ static const struct dcp_v14_board *board_for(const char *dcp, const char *const static const char *const j516c[] = { "apple,j516c", "apple,t6031", "apple,arm-platform", NULL }; static const char *const j514c[] = { "apple,j514c", "apple,t6031", "apple,arm-platform", NULL }; +static const char *const j514m[] = { "apple,j514m", "apple,t6034", "apple,arm-platform", NULL }; +static const char *const j514m_wrong_soc[] = { "apple,j514m", "apple,t6031", NULL }; static const char *const j516m[] = { "apple,j516m", "apple,t6034", "apple,arm-platform", NULL }; +static const char *const j516m_wrong_soc[] = { "apple,j516m", "apple,t6031", NULL }; +static const char *const t6034_other[] = { "apple,j999", "apple,t6034", "apple,arm-platform", NULL }; static const char *const j516s[] = { "apple,j516s", "apple,t6030", "apple,arm-platform", NULL }; static const char *const j613[] = { "apple,j613", "apple,t8122", "apple,arm-platform", NULL }; static const char *const j504[] = { "apple,j504", "apple,t8122", "apple,arm-platform", NULL }; @@ -92,6 +96,7 @@ static void v14_board_j516c(struct kunit *test) /* No colour matrix method is known for this board. */ KUNIT_EXPECT_EQ(test, b->ctm_set, 0); KUNIT_EXPECT_EQ(test, b->ctm_get, 0); + KUNIT_EXPECT_TRUE(test, b->base_edid); } /* @@ -116,18 +121,74 @@ static void v14_board_j514c(struct kunit *test) KUNIT_EXPECT_TRUE(test, b->promotion); KUNIT_EXPECT_TRUE(test, b->log_bringup); KUNIT_EXPECT_EQ(test, b->ctm_set, 0); + /* Its panel is not the J516C's: no base EDID. */ + KUNIT_EXPECT_FALSE(test, b->base_edid); KUNIT_EXPECT_TRUE(test, dcp_v14_board_admits(b, J516C_DCP_IMAGE)); KUNIT_EXPECT_FALSE(test, dcp_v14_board_admits(b, T6030_DCP_IMAGE)); /* Not the J516C record. */ KUNIT_EXPECT_PTR_NE(test, b, board_for("apple,t6031-dcp", j516c, &known)); } -/* A T6031 DCP on a T6034 has no record: refused. */ +static void v14_board_j514m(struct kunit *test) +{ + const struct dcp_v14_board *b; + bool known; + + b = board_for("apple,t6034-dcp", j514m, &known); + KUNIT_ASSERT_NOT_NULL(test, b); + KUNIT_EXPECT_TRUE(test, known); + KUNIT_EXPECT_STREQ(test, b->machine, "apple,j514m"); + KUNIT_EXPECT_STREQ(test, b->soc, "apple,t6034"); + KUNIT_EXPECT_STREQ(test, b->handoff, "apple,t6034-handoff"); + KUNIT_EXPECT_TRUE(test, dcp_v14_board_admits(b, J516C_DCP_IMAGE)); + KUNIT_EXPECT_FALSE(test, dcp_v14_board_admits(b, T6030_DCP_IMAGE)); + KUNIT_EXPECT_FALSE(test, b->panel_nits); + KUNIT_EXPECT_NULL(test, board_for("apple,t6034-dcp", j514m_wrong_soc, &known)); + KUNIT_EXPECT_NULL(test, board_for("apple,t6034-dcp", j516m, &known)); + KUNIT_EXPECT_NULL(test, board_for("apple,t6031-dcp", j514m, &known)); +} + +/* + * The J516M: a T6034 with the T6031 DCP layout, running the J516C image on the + * J516 panel. Admitted only on its own record, with its own SoC. + */ +static void v14_board_j516m(struct kunit *test) +{ + const struct dcp_v14_board *b; + bool known; + + b = board_for("apple,t6031-dcp", j516m, &known); + KUNIT_ASSERT_NOT_NULL(test, b); + KUNIT_EXPECT_TRUE(test, known); + KUNIT_EXPECT_STREQ(test, b->name, "J516M"); + KUNIT_EXPECT_STREQ(test, b->debugfs, "dcp-j516m"); + KUNIT_EXPECT_STREQ(test, b->machine, "apple,j516m"); + KUNIT_EXPECT_STREQ(test, b->soc, "apple,t6034"); + KUNIT_EXPECT_STREQ(test, b->handoff, "apple,t6031-handoff"); + KUNIT_EXPECT_STREQ(test, b->firmware_uuid, J516C_DCP_IMAGE); + KUNIT_EXPECT_EQ(test, b->panel_width, 3456); + KUNIT_EXPECT_EQ(test, b->panel_height, 2234); + KUNIT_EXPECT_TRUE(test, b->promotion); + KUNIT_EXPECT_TRUE(test, b->base_edid); + KUNIT_EXPECT_TRUE(test, b->panel_nits); + KUNIT_EXPECT_TRUE(test, dcp_v14_board_stamps_swaps(b, false)); + KUNIT_EXPECT_TRUE(test, dcp_v14_board_admits(b, J516C_DCP_IMAGE)); + KUNIT_EXPECT_FALSE(test, dcp_v14_board_admits(b, T6030_DCP_IMAGE)); + /* Neither the J516C record nor the J514M one. */ + KUNIT_EXPECT_PTR_NE(test, b, board_for("apple,t6031-dcp", j516c, &known)); + KUNIT_EXPECT_PTR_NE(test, b, board_for("apple,t6034-dcp", j514m, &known)); + /* Its name on a T6031 root is not a J516M. */ + KUNIT_EXPECT_NULL(test, board_for("apple,t6031-dcp", j516m_wrong_soc, &known)); +} + +/* A T6031 DCP on any other T6034, or on a J514M, has no record: refused. */ static void v14_board_t6031_other_boards(struct kunit *test) { bool known; - KUNIT_EXPECT_NULL(test, board_for("apple,t6031-dcp", j516m, &known)); + KUNIT_EXPECT_NULL(test, board_for("apple,t6031-dcp", t6034_other, &known)); + KUNIT_EXPECT_TRUE(test, known); + KUNIT_EXPECT_NULL(test, board_for("apple,t6031-dcp", j514m, &known)); KUNIT_EXPECT_TRUE(test, known); /* Not a 14.x internal DCP at all. */ KUNIT_EXPECT_NULL(test, board_for("apple,t8112-dcp", j516c, &known)); @@ -174,6 +235,7 @@ static void v14_board_unchanged(struct kunit *test) KUNIT_EXPECT_TRUE(test, b->promotion); KUNIT_EXPECT_FALSE(test, b->log_bringup); KUNIT_EXPECT_EQ(test, b->ctm_set, 0); + KUNIT_EXPECT_FALSE(test, b->base_edid); KUNIT_EXPECT_TRUE(test, dcp_v14_board_admits(b, T6030_DCP_IMAGE)); KUNIT_EXPECT_FALSE(test, dcp_v14_board_admits(b, J613_DCP_IMAGE)); /* The T6030 record serves a T6030 DCP on any machine, as before. */ @@ -188,6 +250,7 @@ static void v14_board_unchanged(struct kunit *test) KUNIT_EXPECT_EQ(test, b->panel_height, 1664); KUNIT_EXPECT_FALSE(test, b->promotion); KUNIT_EXPECT_FALSE(test, b->log_bringup); + KUNIT_EXPECT_FALSE(test, b->base_edid); KUNIT_EXPECT_FALSE(test, dcp_v14_board_admits(b, T6030_DCP_IMAGE)); /* A T8122 DCP on a T6031 machine has no record. */ @@ -315,6 +378,8 @@ static struct kunit_case v14_board_cases[] = { KUNIT_CASE(v14_board_j504), KUNIT_CASE(v14_board_j516c), KUNIT_CASE(v14_board_j514c), + KUNIT_CASE(v14_board_j514m), + KUNIT_CASE(v14_board_j516m), KUNIT_CASE(v14_board_t6031_other_boards), KUNIT_CASE(v14_board_j516c_image), KUNIT_CASE(v14_board_unchanged), diff --git a/drivers/gpu/drm/asahi/g15/board.rs b/drivers/gpu/drm/asahi/g15/board.rs index f9682b2ead10c..5bb672fce6c49 100644 --- a/drivers/gpu/drm/asahi/g15/board.rs +++ b/drivers/gpu/drm/asahi/g15/board.rs @@ -158,6 +158,7 @@ pub(crate) fn hardware_record( }; } let inputs = record::Inputs { + chip_id: cfg.chip_id, props, zones: &zones, main: &main, diff --git a/drivers/gpu/drm/asahi/g15/board/record.rs b/drivers/gpu/drm/asahi/g15/board/record.rs index 119a692064391..e20116f513a16 100644 --- a/drivers/gpu/drm/asahi/g15/board/record.rs +++ b/drivers/gpu/drm/asahi/g15/board/record.rs @@ -183,6 +183,8 @@ pub(crate) struct IoSlot { /// Everything the record is built from. pub(crate) struct Inputs<'a> { + /// SoC identity of this G15C record. + pub(crate) chip_id: u32, pub(crate) props: [u32; PROPS.len()], /// `apple,power-zones` cells (triples). pub(crate) zones: &'a [u32], @@ -458,7 +460,7 @@ fn hwdata_b(out: &mut [u8], i: &Inputs<'_>, t: &Tables) -> R<()> { put32(out, IOMAPS + 32 * slot as usize + 0x18, 1)?; } // Identity and flags. - put32(out, 0xa28, 0x6031)?; + put32(out, 0xa28, i.chip_id)?; put32(out, 0xa2c, 1)?; put32(out, 0xa30, 2)?; for at in [0xa38, 0xa3c, 0xa40, 0xa50, 0xa58, 0xa60] { @@ -848,6 +850,9 @@ pub(crate) fn cross_check(built: &[u8], file: &[u8]) -> Option<(usize, u32, u32) /// Builds the record into `out` (zeroed first) from the inputs. pub(crate) fn build(out: &mut [u8], i: &Inputs<'_>) -> R<()> { + if !matches!(i.chip_id, 0x6031 | 0x6034) { + return Err("unsupported G15C record SoC"); + } if out.len() != SIZE { return Err("record of another size"); } @@ -950,6 +955,7 @@ mod tests { fn inputs<'a>(main: &'a [Opp], cs: &'a [Opp], slots: &'a [IoSlot]) -> Inputs<'a> { Inputs { + chip_id: 0x6031, props: props(), zones: &[], main, @@ -966,6 +972,31 @@ mod tests { } } + #[test] + fn t6034_identity_and_six_memory_channels() { + let main = main_opps(); + let cs = [opp(24, [635; CLUSTERS])]; + let slots = [IoSlot { + slot: 11, + pa: 0x220000000, + va: 0xfffffc2068000000, + total: 6 * 0xd8000, + element: 0xd8000, + writable: true, + }]; + let mut input = inputs(&main, &cs, &slots); + input.chip_id = 0x6034; + let mut out = vec![0u8; SIZE]; + build(&mut out, &input).unwrap(); + assert_eq!(get(&out, 0xa28), 0x6034); + assert_eq!(get(&out, IOMAPS + 32 * 11 + 0x10), 6 * 0xd8000); + assert_eq!(get(&out, IOMAPS + 32 * 11 + 0x14), 0xd8000); + // The fused 30-core part still has four ten-slot physical clusters. + assert_eq!(get(&out, 0xb54), 40); + input.chip_id = 0x6030; + assert_eq!(build(&mut out, &input), Err("unsupported G15C record SoC")); + } + #[test] fn factors() { assert_eq!(F_1, 1.0f32.to_bits()); @@ -1500,6 +1531,7 @@ mod tests { }) .collect(); let i = Inputs { + chip_id: 0x6031, props, zones: &zones, main: &main, diff --git a/drivers/gpu/drm/asahi/g15/boot.rs b/drivers/gpu/drm/asahi/g15/boot.rs index 0bc0f490596bd..9fd137a692f97 100644 --- a/drivers/gpu/drm/asahi/g15/boot.rs +++ b/drivers/gpu/drm/asahi/g15/boot.rs @@ -462,6 +462,23 @@ pub(crate) fn admit( ) -> Result { let dev = pdev.as_ref(); let pmp = cfg.platform == hw::Platform::AdtWithPmp; + // J514C uses the same-die T6031 path on a normal boot. This does not qualify + // the inherited J516C reference words. Keep exact board AND SoC checks; + // T6034 boards use their own profile and never inherit T6031 admission. + // The remaining display, DT/ADT, full firmware identity, hardware identity + // and record-builder admission below is unchanged. + let j514c_board = cfg.chip_id == 0x6031 + && cfg.platform == hw::Platform::DeviceTree + && glue::machine(kernel::c_str!("apple,j514c")) + && glue::machine(kernel::c_str!("apple,t6031")); + let j514m_board = cfg.chip_id == 0x6034 + && cfg.platform == hw::Platform::DeviceTree + && glue::machine(kernel::c_str!("apple,j514m")) + && glue::machine(kernel::c_str!("apple,t6034")); + let j516m_board = cfg.chip_id == 0x6034 + && cfg.platform == hw::Platform::DeviceTree + && glue::machine(kernel::c_str!("apple,j516m")) + && glue::machine(kernel::c_str!("apple,t6034")); if pmp { if !glue::board() { return Err(ENODEV); @@ -476,7 +493,9 @@ pub(crate) fn admit( } return Err(err); } - } else if !glue::machine(cfg.machine) { + } else if (cfg.chip_id == 0x6034 && !j514m_board && !j516m_board) + || (!glue::machine(cfg.machine) && !j514c_board) + { dev_err!(dev, "G15: not a {} machine\n", cfg.name); return Err(ENODEV); } else { @@ -491,9 +510,24 @@ pub(crate) fn admit( return Err(err); } } + if j514c_board || j514m_board || j516m_board { + if let hw::Board::DeviceTree(reference) = cfg.board { + dev_warn!( + dev, + "{} bring-up: unqualified J516C reference: max_power_mw={} relative_power={:?} fast_die_mask={:#018x} alarm_mask={:#018x}; OPP powers are boot-loader stand-ins\n", + cfg.name, + reference.max_power_mw, + reference.relative_power, + reference.fast_die_mask, + reference.alarm_mask + ); + } + } let adt = adt::read(dev, cfg) .inspect_err(|e| dev_err!(dev, "GPU regions not admitted: {:?}\n", e))?; - identity::firmware(dev, &adt, cfg.firmware) + // T6034 requires complete identities; the older profiles keep their + // existing explicitly requested bring-up prefix policy. + identity::firmware(dev, &adt, cfg.firmware, cfg.chip_id != 0x6034) .inspect_err(|e| dev_err!(dev, "loaded GFX TEXT identity mismatch: {:?}\n", e))?; dev_info!(dev, "M3: firmware identity accepted\n"); if cfg.board == hw::Board::None { @@ -646,6 +680,19 @@ pub(crate) fn start( ); return Err(eproto()); } + if cfg.chip_id == 0x6034 + && glue::machine(kernel::c_str!("apple,j516m")) + && !hw::j516m::identity_matches(id.version, id.counts, id.cores) + { + dev_err!( + d, + "J516M powered identity is not the 30-core G15C: version {:#x} counts {:#x} core-mask {:#x}\n", + id.version, + id.counts, + id.cores + ); + return Err(eproto()); + } // Binning: any non-empty enabled set in each cluster, nothing above the core slots. let clusters = cfg.num_clusters as usize; let slots = cfg.core_slots(); diff --git a/drivers/gpu/drm/asahi/g15/glue.c b/drivers/gpu/drm/asahi/g15/glue.c index a12a5e6fa2fe7..66730228704ac 100644 --- a/drivers/gpu/drm/asahi/g15/glue.c +++ b/drivers/gpu/drm/asahi/g15/glue.c @@ -52,6 +52,7 @@ void asahi_g15_report_loader_gpu(void) const char *compatible; } socs[] = { { "asahi,t6031-gpu", "apple,agx-t6031" }, + { "asahi,t6034-gpu", "apple,agx-t6034" }, { "asahi,t6030-gpu", "apple,agx-t6030" }, }; struct device_node *chosen, *np; @@ -142,7 +143,7 @@ int asahi_g15_pmp_prepare(struct device *dev) } /* - * T6031 has no PMP vote, but its first firmware start follows the native + * T6031/T6034 have no PMP vote, but its first firmware start follows the native * display as T6030's does: defer until that display is up. The display can * be off for this boot (no handoff, or not requested), so say once why. An * enabled display that is not published yet is said once too: if it never @@ -152,18 +153,36 @@ int asahi_g15_pmp_prepare(struct device *dev) int asahi_g15_display_prepare(struct device *dev) { struct device_node *np; + const char *compatible, *name; int ret; - if (!dev->of_node || !of_device_is_compatible(dev->of_node, "apple,agx-t6031")) + if (!dev->of_node) return -ENODEV; - ret = apple_drm_t6031_link_device(dev); + if (of_device_is_compatible(dev->of_node, "apple,agx-t6031")) { + compatible = "apple,t6031-display-subsystem"; + name = "T6031"; + ret = apple_drm_t6031_link_device(dev); + } else if (of_device_is_compatible(dev->of_node, "apple,agx-t6034")) { + compatible = of_machine_is_compatible("apple,j516m") ? + "apple,t6031-display-subsystem" : "apple,t6034-display-subsystem"; + name = "T6034"; + ret = apple_drm_t6034_link_device(dev); + } else { + return -ENODEV; + } if (ret != -EPROBE_DEFER) return ret; - np = of_find_compatible_node(NULL, NULL, "apple,t6031-display-subsystem"); + + np = of_find_compatible_node(NULL, NULL, compatible); if (!np || !of_device_is_available(np)) - dev_info_once(dev, "G15: waiting for the T6031 native display, which this boot did not enable (it needs the boot loader's display handoff, and apple_t6031_display.enable=1 except on the J516C)\n"); + dev_info_once(dev, + "G15: waiting for the %s native display, which this boot did not enable (it needs the boot loader's display handoff, and an admitted native-display board)\n", + name); else - dev_info_once(dev, "G15: waiting for the T6031 native display to come up: the GPU firmware starts only after the display is published\n"); + dev_info_once(dev, + "G15: waiting for the %s native display to come up: the GPU firmware starts only after the display is published\n", + name); + of_node_put(np); return ret; } diff --git a/drivers/gpu/drm/asahi/g15/hw.rs b/drivers/gpu/drm/asahi/g15/hw.rs index cac11c55d3ca0..0e295f98376e0 100644 --- a/drivers/gpu/drm/asahi/g15/hw.rs +++ b/drivers/gpu/drm/asahi/g15/hw.rs @@ -9,6 +9,10 @@ use core::ops::Range; #[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) mod t6031; +#[cfg(CONFIG_DRM_ASAHI_G15)] +pub(crate) mod t6034; +#[cfg(CONFIG_DRM_ASAHI_G15)] +pub(crate) mod j516m; /// Identification register values of a qualified G15S. pub(crate) struct HwId { diff --git a/drivers/gpu/drm/asahi/g15/hw/j516m.rs b/drivers/gpu/drm/asahi/g15/hw/j516m.rs new file mode 100644 index 0000000000000..1ae58fe1a365d --- /dev/null +++ b/drivers/gpu/drm/asahi/g15/hw/j516m.rs @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +//! Measured J516M/T6034 30-core profile. Share the six-channel G15C layout +//! with J514M, but retain independent machine, firmware and fused-core admission. +//! Native rendering is verified; inherited J516C power/reference values remain +//! unqualified for sustained power and thermal behavior on this board. + +use super::super::Config; +use super::FirmwareBuild; + +pub(crate) const CONFIG: Config = Config { + machine: kernel::c_str!("apple,j516m"), + firmware: &[FirmwareBuild { + name: "J516M RTKit 2419.140.12 (power qualification pending)", + machine: Some(kernel::c_str!("apple,j516m")), + text_size: 0x64000, + data_size: 0x140000, + marker: 0x5cf28, + text_sha256: [ + 0x4c, 0xa2, 0x4b, 0x65, 0x8f, 0x8e, 0xbe, 0x7c, 0x27, 0x37, 0x5f, 0xdf, 0x38, 0xe4, + 0x1e, 0x5d, 0xaf, 0x86, 0x32, 0x51, 0x50, 0x77, 0xb5, 0x37, 0xca, 0x19, 0xe6, 0xd0, + 0xdc, 0x77, 0x04, 0xb7, + ], + }], + ..super::t6034::CONFIG +}; + +/// The 14-core-CPU, 30-core-GPU J516M: its G15C revision and counts, and exactly 30 enabled +/// cores. Which cores are fused off differs between Macs of the same bin, so the mask itself is +/// not pinned (the per-cluster plausibility check in `start()` still applies). +pub(crate) const ENABLED_CORES: u32 = 30; + +pub(crate) fn identity_matches(version: u32, counts: u32, cores: u64) -> bool { + version == 0x07041100 && counts == 0x0021040a && cores.count_ones() == ENABLED_CORES +} diff --git a/drivers/gpu/drm/asahi/g15/hw/t6031.rs b/drivers/gpu/drm/asahi/g15/hw/t6031.rs index 8bac33989db64..68a9b6704fe7a 100644 --- a/drivers/gpu/drm/asahi/g15/hw/t6031.rs +++ b/drivers/gpu/drm/asahi/g15/hw/t6031.rs @@ -1,6 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-only OR MIT -//! T6031 (M3 Max, G15C) configuration, admitted on J516C only. +//! T6031 (M3 Max, G15C) configuration, qualified on J516C only. +//! +//! J514C uses these reference words on normal boots after its board, firmware, +//! and hardware checks pass. This is not J514C power/thermal qualification. //! //! One die, four clusters of ten core slots. The firmware is the same RTKit 2419 generation as //! the T6030's and the initdata graph keeps the T6030 canonical VAs; what differs is the SoC @@ -129,14 +132,16 @@ pub(crate) const CONFIG: Config = Config { version: 0x07041100, counts: 0x0021040a, }], - // The stubs the boot chains of this J516C leave loaded (RTKit-2419.140.12): the macOS 14.7 - // chain's and the macOS 14.8 boot volume's. Same segment sizes and marker; the layout, board - // images and initdata below do not depend on which one is loaded. A further build can be - // admitted for one boot with `g15_accept_text_prefix`, which logs its digest. + // The stubs the boot chains of J516Cs leave loaded (RTKit-2419.140.12): the macOS 14.7 + // chain's, the macOS 14.8 boot volume's and a third TEXT seen on two further J516Cs (omacom + // /linux-aurora#289). Same segment sizes and marker; the layout, board images and initdata + // below do not depend on which one is loaded. The names say where a digest was measured, + // not that it identifies one build. A further digest can be admitted for one boot with + // `g15_accept_text_prefix`, which logs it. firmware: &[ FirmwareBuild { name: "macOS 14.7 stub firmware (iBoot-10151.140.19.700.2), J516C", - machine: None, + machine: Some(kernel::c_str!("apple,j516c")), text_size: 0x64000, data_size: 0x140000, marker: 0x5cf28, @@ -148,7 +153,7 @@ pub(crate) const CONFIG: Config = Config { }, FirmwareBuild { name: "macOS 14.8 stub firmware, J516C", - machine: None, + machine: Some(kernel::c_str!("apple,j516c")), text_size: 0x64000, data_size: 0x140000, marker: 0x5cf28, @@ -158,9 +163,56 @@ pub(crate) const CONFIG: Config = Config { 0x9d, 0x6b, 0xcd, 0xa0, 0x26, 0xcf, ], }, + // Two J516Cs (iBoot2 iBoot-10151.140.19.700.2, OS firmware 14.7; iBoot1 mBoot-20457.1.29 + // and mBoot-20457.41.3) load this TEXT. On the second, 10 boots, glxinfo on the M3 Max + // renderer and a GLES compute job with no mismatches, no GPU faults (#289). + FirmwareBuild { + name: "J516C stub firmware, TEXT 125f0497 (seen with iBoot-10151.140.19.700.2)", + machine: Some(kernel::c_str!("apple,j516c")), + text_size: 0x64000, + data_size: 0x140000, + marker: 0x5cf28, + text_sha256: [ + 0x12, 0x5f, 0x04, 0x97, 0xc7, 0x90, 0x4f, 0xde, 0x87, 0xb0, 0x5a, 0x92, 0x64, + 0xa8, 0x8c, 0xf0, 0x3b, 0xdb, 0x35, 0x72, 0xa1, 0x71, 0x5c, 0xec, 0x91, 0xbd, + 0x0f, 0x9b, 0x78, 0x24, 0x55, 0x44, + ], + }, + // Measured by the normal driver on J514C's 14.7 boot chain (system + // firmware 26.5.2). Short native GL/Vulkan and normal-login checks passed; + // power/thermal qualification remains open. Exact board identity is required. + FirmwareBuild { + name: "J514C macOS 14.7 boot-chain firmware", + machine: Some(kernel::c_str!("apple,j514c")), + text_size: 0x64000, + data_size: 0x140000, + marker: 0x5cf28, + text_sha256: [ + 0x66, 0x99, 0x13, 0xfb, 0xa2, 0x73, 0x6e, 0x4b, 0x8f, 0x8a, 0x0f, 0x81, + 0xea, 0xdc, 0x5a, 0xc0, 0x0c, 0x9d, 0xc5, 0x1f, 0xdd, 0x4c, 0x9d, 0x37, + 0x70, 0xc6, 0x6d, 0x2b, 0x0a, 0x1e, 0x87, 0x86, + ], + }, + // The same TEXT as the J516C row above, on one J514C (OS firmware 14.7, system firmware + // 26.6.2). With `g15_accept_text_prefix`, 3 boots with the GPU up; OpenGL 4.6 accelerated + // and no asahi-g15 errors on the one checked; idle only. Exact board identity is + // required; Vulkan, load and power/thermal qualification remain open. + FirmwareBuild { + name: "J514C stub firmware, TEXT 125f0497", + machine: Some(kernel::c_str!("apple,j514c")), + text_size: 0x64000, + data_size: 0x140000, + marker: 0x5cf28, + text_sha256: [ + 0x12, 0x5f, 0x04, 0x97, 0xc7, 0x90, 0x4f, 0xde, 0x87, 0xb0, 0x5a, 0x92, 0x64, + 0xa8, 0x8c, 0xf0, 0x3b, 0xdb, 0x35, 0x72, 0xa1, 0x71, 0x5c, 0xec, 0x91, 0xbd, + 0x0f, 0x9b, 0x78, 0x24, 0x55, 0x44, + ], + }, ], - // The reference words and measured layout belong to the J516C, not - // every T6031 board (in particular, not the 14-inch J514C). + // This is the reference board. The exact J514C/T6031 pair also uses this + // configuration through normal admission, with the unmeasured reference + // power words reported explicitly for that chassis. machine: kernel::c_str!("apple,j516c"), platform: super::Platform::DeviceTree, layout: &LAYOUT, diff --git a/drivers/gpu/drm/asahi/g15/hw/t6034.rs b/drivers/gpu/drm/asahi/g15/hw/t6034.rs new file mode 100644 index 0000000000000..1c0ec130cc177 --- /dev/null +++ b/drivers/gpu/drm/asahi/g15/hw/t6034.rs @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +//! J514M/T6034 (M3 Max, G15C) measured boot-chain profile. +//! +//! The powered identity read on this J514M found four ten-slot clusters with +//! enabled masks [0x1fd, 0x1fd, 0x1fc, 0x1ed], or 30 enabled cores. Its ADT has +//! four voltage tables and six memory channels. The four-cluster G15C object +//! and command layouts below are inherited from T6031; they are not a native +//! macOS capture of this machine. The J516C power/reference words remain +//! unqualified for this board and are identified at admission. +//! +//! The loaded firmware identity below was measured after native display +//! publication on J514M. Runtime and power/thermal qualification remain +//! pending; this profile never permits the generic digest-prefix override. + +use super::super::Config; +use super::{FirmwareBuild, HwId, IoMap, Layout}; + +/// Six memory-cache elements, rather than the T6031 reference's eight. +const MCC_BYTES: u64 = 6 * 0xd_8000; +const IOMAP_GAP: u64 = 0x4000; + +/// Keep the shared G15C physical apertures and pack firmware VAs after the +/// smaller memory-cache aperture. No seventh or eighth element is mapped. +const fn iomaps() -> [IoMap; 17] { + let mut out = super::t6031::IOMAPS; + let mut va = out[0].va; + let mut k = 0; + while k < out.len() { + if out[k].slot == 11 { + out[k].map_bytes = MCC_BYTES; + } + out[k].va = va; + va += out[k].map_bytes + IOMAP_GAP; + k += 1; + } + out +} + +pub(crate) const IOMAPS: [IoMap; 17] = iomaps(); + +const fn record_slots() -> [(u32, u32, bool); 17] { + let mut out = [(0, 0, false); 17]; + let mut k = 0; + while k < out.len() { + out[k] = super::t6031::LAYOUT.record_slots[k]; + if IOMAPS[k].slot == 11 { + out[k].0 = MCC_BYTES as u32; + } + k += 1; + } + out +} + +const RECORD_SLOTS: [(u32, u32, bool); 17] = record_slots(); + +pub(crate) const LAYOUT: Layout = Layout { + iomaps: &IOMAPS, + record_slots: &RECORD_SLOTS, + ..super::t6031::LAYOUT +}; + +pub(crate) const CONFIG: Config = Config { + name: "T6034 G15C", + chip_id: 0x6034, + gpu_variant: crate::hw::GpuVariant::C, + // ID_VERSION's silicon revision byte: (0x07041100 >> 8) & 0xff. + gpu_revision: 0x11, + uat_ias: 42, + uat_oas: 42, + num_clusters: 4, + num_cores_per_cluster: 10, + hw_ids: &[HwId { + version: 0x07041100, + counts: 0x0021040a, + }], + firmware: &[FirmwareBuild { + name: "J514M RTKit 2419.140.12 (runtime qualification pending)", + machine: Some(kernel::c_str!("apple,j514m")), + text_size: 0x64000, + data_size: 0x140000, + marker: 0x5cf28, + text_sha256: [ + 0x4c, 0xa2, 0x4b, 0x65, 0x8f, 0x8e, 0xbe, 0x7c, 0x27, 0x37, 0x5f, 0xdf, 0x38, + 0xe4, 0x1e, 0x5d, 0xaf, 0x86, 0x32, 0x51, 0x50, 0x77, 0xb5, 0x37, 0xca, 0x19, + 0xe6, 0xd0, 0xdc, 0x77, 0x04, 0xb7, + ], + }], + machine: kernel::c_str!("apple,j514m"), + platform: super::Platform::DeviceTree, + layout: &LAYOUT, + board: super::Board::DeviceTree(&super::super::board::record::J516C), + // Binning changes enabled masks, not the four physical clusters or the + // ten slots per cluster used by these G15C command words. + compute: super::t6031::CONFIG.compute, +}; diff --git a/drivers/gpu/drm/asahi/g15/identity.rs b/drivers/gpu/drm/asahi/g15/identity.rs index 2bf95c8ad98db..4193a3cba9078 100644 --- a/drivers/gpu/drm/asahi/g15/identity.rs +++ b/drivers/gpu/drm/asahi/g15/identity.rs @@ -70,10 +70,12 @@ impl From<&FirmwareBuild> for Measured { /// Identifies the loaded firmware build: the pinned build, or `None` for a build admitted by /// its digest prefix (`g15_accept_text_prefix`). +/// With `allow_prefix` false, only a complete pinned identity may be admitted. pub(crate) fn firmware( dev: &device::Device, adt: &super::adt::GpuAdt, builds: &'static [FirmwareBuild], + allow_prefix: bool, ) -> Result> { let size = usize::try_from(adt.text.end - adt.text.start)?; let data_size = adt.data.end - adt.data.start; @@ -97,7 +99,14 @@ pub(crate) fn firmware( let qualified = builds .iter() .map(|b| (Measured::from(b), b.machine.map_or(true, glue::machine))); - match lookup::verdict(&m, qualified, super::params::accept_text_prefix()) { + // A profile may require exact identities even after its first build is + // pinned. Empty profiles remain measurement-only in either policy. + let accept_prefix = if !allow_prefix || builds.is_empty() { + 0 + } else { + super::params::accept_text_prefix() + }; + match lookup::verdict(&m, qualified, accept_prefix) { Verdict::Pinned(i) => { let build = builds.get(i).ok_or(EINVAL)?; dev_info!(dev, "GPU firmware build: {}\n", build.name); diff --git a/drivers/gpu/drm/asahi/g15/mod.rs b/drivers/gpu/drm/asahi/g15/mod.rs index 6d5ca934a0ff2..53adbf8610ae6 100644 --- a/drivers/gpu/drm/asahi/g15/mod.rs +++ b/drivers/gpu/drm/asahi/g15/mod.rs @@ -139,7 +139,7 @@ impl Config { } /// OF match table of the G15 platform driver. -const OF_TABLE: kernel::device_id::IdArray = +const OF_TABLE: kernel::device_id::IdArray = kernel::device_id::IdArray::new([ ( of::DeviceId::new(c_str!("apple,agx-t6030")), @@ -149,6 +149,10 @@ const OF_TABLE: kernel::device_id::IdArray = of::DeviceId::new(c_str!("apple,agx-t6031")), &&hw::t6031::CONFIG, ), + ( + of::DeviceId::new(c_str!("apple,agx-t6034")), + &&hw::t6034::CONFIG, + ), ]); // Probe admission requires the native display before firmware starts (T6030 @@ -159,6 +163,7 @@ kernel::of_device_table!( [ of::DeviceId::new(c_str!("apple,agx-t6030")), of::DeviceId::new(c_str!("apple,agx-t6031")), + of::DeviceId::new(c_str!("apple,agx-t6034")), ] ); @@ -217,6 +222,11 @@ impl platform::Driver for Driver<'_> { }) { return Err(ENODEV); } + let cfg = if cfg.chip_id == 0x6034 && boot::glue::machine(c_str!("apple,j516m")) { + &hw::j516m::CONFIG + } else { + cfg + }; dev_info!(pdev.as_ref(), "G15: probing ({})\n", cfg.name); match crate::driver::AsahiPlatformDriver::probe_g15(pdev, cfg) { Ok(driver) => Some(driver), diff --git a/drivers/media/platform/apple/isp/isp-drv.c b/drivers/media/platform/apple/isp/isp-drv.c index 758200422d68d..5f6cd26aaf496 100644 --- a/drivers/media/platform/apple/isp/isp-drv.c +++ b/drivers/media/platform/apple/isp/isp-drv.c @@ -879,6 +879,18 @@ static int apple_isp_probe(struct platform_device *pdev) /* the sensor connection layout, for firmware that takes it at boot */ of_property_read_u32(dev->of_node, "apple,cam-connections-scheme", &isp->cam_connections_scheme); + /* + * M3 MacBook Air firmware 14.7 stalls capture with temporal filter 1. + * The J615 has the J613's sensor and ISP configuration; only the J613 + * has been tested. + */ + if ((of_machine_is_compatible("apple,j613") || + of_machine_is_compatible("apple,j615")) && + isp->fw_compat == ISP_FIRMWARE_V_14_7 && + isp->temporal_filter == 1) { + dev_info(dev, "using temporal filter 0 on M3 Air firmware 14.7\n"); + isp->temporal_filter = 0; + } err = apple_isp_init_presets(isp); if (err) { diff --git a/drivers/pmdomain/apple/pmp-report.c b/drivers/pmdomain/apple/pmp-report.c index 76e72185bfbab..869193911388f 100644 --- a/drivers/pmdomain/apple/pmp-report.c +++ b/drivers/pmdomain/apple/pmp-report.c @@ -1281,10 +1281,18 @@ static void apple_pmp_start_finish(struct apple_pmp_start *st, int result) st->result = result; complete_all(&st->started); } - if (result && READ_ONCE(st->enabled)) + if (result && READ_ONCE(st->enabled)) { + const char *fallback = st->rep->offsets->fallback; + + /* J516M shares the T6031 report layout, but has its own display gate. */ + if (of_machine_is_compatible("apple,t6034") && + of_machine_is_compatible("apple,j516m")) + fallback = "apple_t6034_display.enable=0"; + dev_err(st->rep->dev, "%s PMP start failed (%d) after the PMP was enabled: it may keep running until the next reboot. Reboot to stop it; to boot without starting it: %s, or nomodeset\n", - st->rep->offsets->name, result, st->rep->offsets->fallback); + st->rep->offsets->name, result, fallback); + } } /* Teardown has begun: a start still in progress gives up early. */ @@ -2641,7 +2649,26 @@ static const struct apple_pmp_report_offsets apple_pmp_offsets_t6031 = { .status = 0x10, .starts_pmp = true, .name = "T6031", - .fallback = "leave out apple_t6031_display.enable=1", + .fallback = "apple_t6031_display.enable=0", + .pwrstate = "apple,t6031-pmgr-pwrstate", + .devices_ordered = true, +}; + +/* + * J514M/T6034's selected ADT ptd-range has the same request (index 0x200), + * acknowledge (0x208) and status (0x1) apertures. Its 35 soc-device records + * are in ID order; DISP is ID 17 with ACK and ANS is ID 34 without ACK. + * The exact T6034 display gate supplies the halted PMP and validated values. + * The generic T6020 fallback only observes an already-running PMP. + */ +static const struct apple_pmp_report_offsets apple_pmp_offsets_t6034 = { + .tgt_read = 0x2000, + .tgt_write = 0x11000, + .actual = 0x2080, + .status = 0x10, + .starts_pmp = true, + .name = "T6034", + .fallback = "apple_t6034_display.enable=0", .pwrstate = "apple,t6031-pmgr-pwrstate", .devices_ordered = true, }; @@ -2715,6 +2742,7 @@ static const struct of_device_id apple_pmp_report_of_match[] = { { .compatible = "apple,t6041-pmp-v2-report", .data = &apple_pmp_offsets_t6041 }, /* T6050: the ADT's ptd-range lists T6041's entries at the same places. */ { .compatible = "apple,t6050-pmp-v2-report", .data = &apple_pmp_offsets_t6041 }, + { .compatible = "apple,t6034-pmp-v2-report", .data = &apple_pmp_offsets_t6034 }, { .compatible = "apple,t8112-pmp-v2-report", .data = &apple_pmp_offsets_t8112 }, { .compatible = "apple,t8122-pmp-v2-report", .data = &apple_pmp_offsets_t8122 }, { .compatible = "apple,t8132-pmp-v2-report", .data = &apple_pmp_offsets_t8132 }, diff --git a/drivers/soc/apple/Kconfig b/drivers/soc/apple/Kconfig index 2d1e29d1c7c73..6b06d95e5fe4a 100644 --- a/drivers/soc/apple/Kconfig +++ b/drivers/soc/apple/Kconfig @@ -487,7 +487,7 @@ config APPLE_DISPLAY_GATE It also serves T6031 (M3 Max) device trees with apple,t6031-handoff, in the same way and only with the PMP values the boot loader passes. - There the native display is on by default on the J516C, unless + There the native display is on by default on J514C and J516C, unless apple_t6031_display.enable=0; the other T6031 boards need apple_t6031_display.enable=1 on the kernel command line. The T6031 GPU driver starts its firmware only after this native display is @@ -507,6 +507,11 @@ config APPLE_DISPLAY_GATE displays up. The Type-C ports work as USB ports after 20 seconds meanwhile, and take the display routes once the chain is up. + J514M/T6034 uses an independent apple,t6034-handoff profile and the + same checked PMP firmware layout. It starts on normal boots of that + exact board and SoC pair; apple_t6034_display.enable=0 retains the + boot framebuffer and keeps its GPU off. Other T6034 boards stay off. + Say 'y' if you want the native display on M3 Pro, M3 Max, M3 and M4 Pro Macs. @@ -535,7 +540,7 @@ config APPLE_DISPLAY_GATE_KUNIT_TEST help Runs the display gate on test device trees with the T6030, T6031 and T8122 display nodes, without Apple hardware. On T6031: on by - default only on the default board (the J516C), otherwise only with + default only on J514C and J516C, otherwise only with apple_t6031_display.enable=1, off with apple_t6031_display.enable=0, only with the boot loader's handoff marker and this Mac's PMP values, and with nothing changed when a check fails. On T6030: on by default, as diff --git a/drivers/soc/apple/display-gate-test.c b/drivers/soc/apple/display-gate-test.c index cff3298d1ee57..24fb52db610fd 100644 --- a/drivers/soc/apple/display-gate-test.c +++ b/drivers/soc/apple/display-gate-test.c @@ -8,8 +8,8 @@ * the T6031 switch does not change it. Run first: the T6031 and T8122 * trees describe a PMP, and the T6030 gate refuses to add a second one. * - T6031 (t6031-gate-test.dtso): on by default only on the default board - * (the J516C; the cases point it at the test tree's own root to run that - * path), otherwise only with apple_t6031_display.enable=1, never with + * (J514C or J516C; the cases supply a synthetic root identity), + * otherwise only with apple_t6031_display.enable=1, never with * apple_t6031_display.enable=0; always with the full handoff, and nothing * changed when a check fails. * - T8122 (t8122-gate-test.dtso): on by default, with the full handoff, @@ -159,8 +159,8 @@ struct gate_test { struct of_changeset cs; /* this case's own edits to the test tree */ bool requested, t6031_requested; int t6031_switch; - const char *t6031_board; const char *pmp_uuid; /* the PMP image the values name: the fixture's unless set */ + const char *default_board; }; static struct device_node *__init gt_node(struct kunit *test, const char *path) @@ -406,6 +406,16 @@ static int __init gt_suite_init_t8122(struct kunit_suite *suite) return gt_apply_fixture(>_t8122, >_fixture_t8122); } +/* Static-stub resources are task-scoped and removed by KUnit case cleanup. */ +static bool __init gt_root_is_compatible(const char *compat) +{ + struct kunit *test = kunit_get_current_test(); + struct gate_test *t = test->priv; + + return t->default_board && + (!strcmp(compat, "apple,t6031") || !strcmp(compat, t->default_board)); +} + static int __init gt_init(struct kunit *test, const struct gt_soc *s) { struct gate_test *t = kunit_kzalloc(test, sizeof(*t), GFP_KERNEL); @@ -419,7 +429,6 @@ static int __init gt_init(struct kunit *test, const struct gt_soc *s) t->requested = gate_requested; t->t6031_requested = gate_t6031_requested; t->t6031_switch = gate_t6031_switch; - t->t6031_board = gate_t6031_board; of_changeset_init(&t->cs); gate_soc = s->soc; gate_pmp_values = NULL; @@ -431,6 +440,7 @@ static int __init gt_init(struct kunit *test, const struct gt_soc *s) gate_t8122_dcpext_cs = NULL; if (gt_live_soc) kunit_skip(test, "the booted device tree has its own /soc"); + kunit_activate_static_stub(test, gate_t6031_is_compatible, gt_root_is_compatible); return 0; } @@ -481,7 +491,6 @@ static void __init gt_exit(struct kunit *test) gate_requested = t->requested; gate_t6031_requested = t->t6031_requested; gate_t6031_switch = t->t6031_switch; - gate_t6031_board = t->t6031_board; gate_soc = NULL; } @@ -494,7 +503,7 @@ static void __init gate_t6031_param(struct kunit *test) KUNIT_EXPECT_FALSE(test, t->t6031_requested); KUNIT_EXPECT_EQ(test, t->t6031_switch, -1); - KUNIT_EXPECT_STREQ(test, t->t6031_board, "apple,j516c"); + KUNIT_EXPECT_NULL(test, gate_t6031_default_board()); KUNIT_EXPECT_TRUE(test, t->requested); KUNIT_EXPECT_EQ(test, gate_setup_t6031("1"), 0); @@ -532,14 +541,19 @@ static void __init gate_t6031_resolution(struct kunit *test) KUNIT_EXPECT_TRUE(test, gate_t6031_wanted(1, false)); } -/* Points the default board at the test tree's root, so gate_run() takes that path. */ +static const char * const gt_default_boards[] = { + "apple,j514c", + "apple,j516c", +}; +KUNIT_ARRAY_PARAM(gt_default_board, gt_default_boards, NULL); + +/* Exercise the real selector and gate_run(), with a test-scoped identity. */ static void __init gt_default_board(struct kunit *test) { - const char *root = NULL; + struct gate_test *t = test->priv; - if (of_property_read_string(of_root, "compatible", &root) || !root) - kunit_skip(test, "the test tree's root has no compatible"); - gate_t6031_board = root; + t->default_board = *(const char * const *)test->param_value; + KUNIT_ASSERT_STREQ(test, gate_t6031_default_board(), t->default_board); } /* On the default board, the full handoff and no switch: enabled. */ @@ -547,6 +561,7 @@ static void __init gate_t6031_default_board_on(struct kunit *test) { gt_default_board(test); gt_run(test); + KUNIT_EXPECT_TRUE(test, gate_t6031_requested); gt_expect_enabled(test); } @@ -556,6 +571,7 @@ static void __init gate_t6031_default_board_switched_off(struct kunit *test) gt_default_board(test); KUNIT_ASSERT_EQ(test, gate_setup_t6031("0"), 0); gt_run(test); + KUNIT_EXPECT_FALSE(test, gate_t6031_requested); gt_expect_untouched(test); } @@ -565,6 +581,7 @@ static void __init gate_t6031_default_board_no_marker(struct kunit *test) gt_default_board(test); gt_remove(test, gt_t6031.dcp, "apple,t6031-handoff"); gt_run(test); + KUNIT_EXPECT_TRUE(test, gate_t6031_requested); gt_expect_untouched(test); } @@ -1225,9 +1242,9 @@ static struct kunit_case gate_t6031_cases[] __refdata = { KUNIT_CASE(gate_t6031_param), KUNIT_CASE(gate_t6031_resolution), KUNIT_CASE(gate_t6031_off_by_default), - KUNIT_CASE(gate_t6031_default_board_on), - KUNIT_CASE(gate_t6031_default_board_switched_off), - KUNIT_CASE(gate_t6031_default_board_no_marker), + KUNIT_CASE_PARAM(gate_t6031_default_board_on, gt_default_board_gen_params), + KUNIT_CASE_PARAM(gate_t6031_default_board_switched_off, gt_default_board_gen_params), + KUNIT_CASE_PARAM(gate_t6031_default_board_no_marker, gt_default_board_gen_params), KUNIT_CASE(gate_t6031_switched_off), KUNIT_CASE(gate_t6031_enabled), KUNIT_CASE(gate_t6031_no_dcp_marker), diff --git a/drivers/soc/apple/display-gate.c b/drivers/soc/apple/display-gate.c index b371853cdb74e..9178a08df58d0 100644 --- a/drivers/soc/apple/display-gate.c +++ b/drivers/soc/apple/display-gate.c @@ -53,8 +53,8 @@ * option. * * On T6031 (M3 Max) the gate serves the same handoff, marked - * apple,t6031-handoff. Its default is scoped to the J516C: there the native - * display is on unless apple_t6031_display.enable=0; the other T6031 boards + * apple,t6031-handoff. Its default is scoped to J514C and J516C: there the native + * display is on unless apple_t6031_display.enable=0; other T6031 boards * need apple_t6031_display.enable=1. The T6031 GPU starts its firmware only * after this native display is up, so enable=0 (or a display that never * comes up) keeps the GPU off for that boot too: it is not a display-only @@ -116,6 +116,10 @@ #include #include