1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Add an hdmi-connector node to boards using the imx8mp hdmi_tx which 4 * don't have one. This is needed for the i.MX LCDIF to work with 5 * DRM_BRIDGE_ATTACH_NO_CONNECTOR. 6 * 7 * Copyright (C) 2026 GE HealthCare 8 * Author: Luca Ceresoli <luca.ceresoli@bootlin.com> 9 */ 10 11 #include <linux/cleanup.h> 12 #include <linux/init.h> 13 #include <linux/of.h> 14 #include <linux/of_graph.h> 15 16 /* Embedded dtbo symbols created by cmd_wrap_S_dtb in scripts/Makefile.dtbs */ 17 extern char __dtbo_imx8mp_hdmi_tx_connector_fixup_begin[]; 18 extern char __dtbo_imx8mp_hdmi_tx_connector_fixup_end[]; 19 20 static int __init imx8mp_hdmi_tx_connector_fixup_init(void) 21 { 22 struct device_node *soc __free(device_node) = NULL; 23 struct device_node *hdmi_tx __free(device_node) = NULL; 24 struct device_node *endpoint __free(device_node) = NULL; 25 void *dtbo_start; 26 u32 dtbo_size; 27 int ovcs_id; 28 int err; 29 30 soc = of_find_node_by_path("/soc@0"); 31 if (!soc) 32 return 0; 33 34 /* This applies to i.MX8MP only, do nothing on other systems */ 35 if (!of_device_is_compatible(soc, "fsl,imx8mp-soc")) 36 return 0; 37 38 hdmi_tx = of_find_node_by_path("/soc@0/bus@32c00000/hdmi@32fd8000"); 39 if (!of_device_is_available(hdmi_tx)) 40 return 0; 41 42 /* If endpoint exists, assume an hdmi-connector exists already */ 43 endpoint = of_graph_get_endpoint_by_regs(hdmi_tx, 1, -1); 44 if (endpoint) 45 return 0; 46 47 /* 48 * Boards with an HDMI connector should describe it in a device 49 * tree node with compatible = "hdmi-connector". 50 * 51 * If you see this warning, it means such a node was not found and 52 * a fallback one is added using a device tree overlay. Please add 53 * one in your device tree, also describing the exact connector 54 * type (the added overlay assumes Type A as a fallback, but it 55 * might be wrong). 56 * 57 * This node is necessary for modern DRM, where bridge drivers do 58 * not create a connector (see the DRM_BRIDGE_ATTACH_NO_CONNECTOR 59 * flag). See https://docs.kernel.org/gpu/drm-kms-helpers.html for 60 * more info. 61 */ 62 pr_warn("Please add a hdmi-connector DT node for imx8mp-hdmi-tx.\n"); 63 64 dtbo_start = __dtbo_imx8mp_hdmi_tx_connector_fixup_begin; 65 dtbo_size = __dtbo_imx8mp_hdmi_tx_connector_fixup_end - 66 __dtbo_imx8mp_hdmi_tx_connector_fixup_begin; 67 68 err = of_overlay_fdt_apply(dtbo_start, dtbo_size, &ovcs_id, NULL); 69 if (err) 70 err = of_overlay_remove(&ovcs_id); 71 72 return err; 73 } 74 75 subsys_initcall(imx8mp_hdmi_tx_connector_fixup_init); 76