diff --git a/drivers/gpu/drm/bridge/imx/Kconfig b/drivers/gpu/drm/bridge/imx/Kconfig index 8877b9789868..005a745e5c47 100644 --- a/drivers/gpu/drm/bridge/imx/Kconfig +++ b/drivers/gpu/drm/bridge/imx/Kconfig @@ -8,6 +8,8 @@ config DRM_IMX8MP_DW_HDMI_BRIDGE depends on OF depends on COMMON_CLK select DRM_DW_HDMI + select OF_OVERLAY + select DRM_DISPLAY_CONNECTOR imply DRM_IMX8MP_HDMI_PAI imply DRM_IMX8MP_HDMI_PVI imply PHY_FSL_SAMSUNG_HDMI_PHY @@ -15,6 +17,22 @@ config DRM_IMX8MP_DW_HDMI_BRIDGE Choose this to enable support for the internal HDMI encoder found on the i.MX8MP SoC. +config DRM_IMX8MP_DW_HDMI_BRIDGE_CONNECTOR_FIXUP + bool + default y + depends on DRM_IMX_LCDIF + depends on DRM_IMX8MP_DW_HDMI_BRIDGE + depends on OF + help + Modifies at early boot the live device tree of boards using the + i.MX8MP fsl,imx8mp-hdmi-tx adding a hdmi-connector node linked to + the hdmi-tx. This is needed to support bridge-connector usage in + the i.MX8MP LCDIF driver. + + You need this if you use the i.MX8MP HDMI output and your board + device tree file does not have an hdmi-connector node connected + to it. + config DRM_IMX8MP_HDMI_PAI tristate "Freescale i.MX8MP HDMI PAI bridge support" depends on OF diff --git a/drivers/gpu/drm/bridge/imx/Makefile b/drivers/gpu/drm/bridge/imx/Makefile index 69d9f9abbe36..94ac8c40ebe9 100644 --- a/drivers/gpu/drm/bridge/imx/Makefile +++ b/drivers/gpu/drm/bridge/imx/Makefile @@ -1,5 +1,7 @@ obj-$(CONFIG_DRM_IMX_LDB_HELPER) += imx-ldb-helper.o obj-$(CONFIG_DRM_IMX8MP_DW_HDMI_BRIDGE) += imx8mp-hdmi-tx.o +obj-$(CONFIG_DRM_IMX8MP_DW_HDMI_BRIDGE_CONNECTOR_FIXUP) += imx8mp-hdmi-tx-connector-fixup.o \ + imx8mp-hdmi-tx-connector-fixup.dtbo.o obj-$(CONFIG_DRM_IMX8MP_HDMI_PAI) += imx8mp-hdmi-pai.o obj-$(CONFIG_DRM_IMX8MP_HDMI_PVI) += imx8mp-hdmi-pvi.o obj-$(CONFIG_DRM_IMX8QM_LDB) += imx8qm-ldb.o diff --git a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx-connector-fixup.c b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx-connector-fixup.c new file mode 100644 index 000000000000..dc1736bfc3ac --- /dev/null +++ b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx-connector-fixup.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Add an hdmi-connector node to boards using the imx8mp hdmi_tx which + * don't have one. This is needed for the i.MX LCDIF to work with + * DRM_BRIDGE_ATTACH_NO_CONNECTOR. + * + * Copyright (C) 2026 GE HealthCare + * Author: Luca Ceresoli + */ + +#include +#include +#include +#include + +/* Embedded dtbo symbols created by cmd_wrap_S_dtb in scripts/Makefile.dtbs */ +extern char __dtbo_imx8mp_hdmi_tx_connector_fixup_begin[]; +extern char __dtbo_imx8mp_hdmi_tx_connector_fixup_end[]; + +static int __init imx8mp_hdmi_tx_connector_fixup_init(void) +{ + struct device_node *soc __free(device_node) = NULL; + struct device_node *hdmi_tx __free(device_node) = NULL; + struct device_node *endpoint __free(device_node) = NULL; + void *dtbo_start; + u32 dtbo_size; + int ovcs_id; + int err; + + soc = of_find_node_by_path("/soc@0"); + if (!soc) + return 0; + + /* This applies to i.MX8MP only, do nothing on other systems */ + if (!of_device_is_compatible(soc, "fsl,imx8mp-soc")) + return 0; + + hdmi_tx = of_find_node_by_path("/soc@0/bus@32c00000/hdmi@32fd8000"); + if (!of_device_is_available(hdmi_tx)) + return 0; + + /* If endpoint exists, assume an hdmi-connector exists already */ + endpoint = of_graph_get_endpoint_by_regs(hdmi_tx, 1, -1); + if (endpoint) + return 0; + + dtbo_start = __dtbo_imx8mp_hdmi_tx_connector_fixup_begin; + dtbo_size = __dtbo_imx8mp_hdmi_tx_connector_fixup_end - + __dtbo_imx8mp_hdmi_tx_connector_fixup_begin; + + err = of_overlay_fdt_apply(dtbo_start, dtbo_size, &ovcs_id, NULL); + if (err) + err = of_overlay_remove(&ovcs_id); + + return err; +} + +subsys_initcall(imx8mp_hdmi_tx_connector_fixup_init); diff --git a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx-connector-fixup.dtso b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx-connector-fixup.dtso new file mode 100644 index 000000000000..6ba1c1854aee --- /dev/null +++ b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx-connector-fixup.dtso @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * DTS overlay adding an hdmi-connector node to boards using the imx8mp hdmi_tx + * + * Copyright (C) 2026 GE HealthCare + * Author: Luca Ceresoli + */ + +/dts-v1/; +/plugin/; + +&{/} { + fixup-hdmi-connector { + compatible = "hdmi-connector"; + label = "HDMI"; + type = "a"; + + port { + fixup_hdmi_connector_in: endpoint { + remote-endpoint = <&hdmi_tx_out>; + }; + }; + }; +}; + +&{/soc@0/bus@32c00000/hdmi@32fd8000/ports/port@1} { + hdmi_tx_out: endpoint { + remote-endpoint = <&fixup_hdmi_connector_in>; + }; +};