Thread (124 messages) 124 messages, 6 authors, 2026-06-11
COLD42d

[PATCH 10/39] drm/imx: dc: ed: Pass struct dc_ed_subdev_match_data via OF match data

From: Marek Vasut <hidden>
Date: 2025-10-11 17:03:22
Also in: dri-devel, imx, linux-clk, linux-devicetree
Subsystem: drm drivers, drm drivers and misc gpu patches, drm drivers for freescale imx8 display controller, the rest · Maintainers: David Airlie, Simona Vetter, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Liu Ying, Linus Torvalds

Introduce struct dc_ed_subdev_match_data which describes the differences
between i.MX8QXP and i.MX95, which in this case is src_sels mapping and
address space offsets, and pass it as OF match data into the driver, so
the driver can use the match data to apply correct src_sels value to the
IP registers on each SoC. This is a preparatory patch for i.MX95 addition.
No functional change.

Signed-off-by: Marek Vasut <redacted>
---
Cc: Abel Vesa <abelvesa@kernel.org>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Liu Ying <victor.liu@nxp.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Rob Herring <robh@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: devicetree@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: imx@lists.linux.dev
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-clk@vger.kernel.org
---
 drivers/gpu/drm/imx/dc/dc-ed.c | 24 +++++++++++++++++++-----
 drivers/gpu/drm/imx/dc/dc-pe.h |  1 +
 2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/imx/dc/dc-ed.c b/drivers/gpu/drm/imx/dc/dc-ed.c
index 2fdd22a903dec..63dcad30ecced 100644
--- a/drivers/gpu/drm/imx/dc/dc-ed.c
+++ b/drivers/gpu/drm/imx/dc/dc-ed.c
@@ -9,6 +9,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 
 #include "dc-drv.h"
@@ -35,7 +36,12 @@
 #define CONTROL			0xc
 #define  GAMMAAPPLYENABLE	BIT(0)
 
-static const struct dc_subdev_info dc_ed_info[] = {
+struct dc_ed_subdev_match_data {
+	const enum dc_link_id		*src_sels;
+	const struct dc_subdev_info	*info;
+};
+
+static const struct dc_subdev_info dc_ed_info_imx8qxp[] = {
 	{ .reg_start = 0x56180980, .id = 0, },
 	{ .reg_start = 0x56180a00, .id = 1, },
 	{ .reg_start = 0x561809c0, .id = 4, },
@@ -106,7 +112,7 @@ static const struct regmap_config dc_ed_cfg_regmap_config = {
 	.max_register = CONTROL,
 };
 
-static const enum dc_link_id src_sels[] = {
+static const enum dc_link_id src_sels_imx8qxp[] = {
 	LINK_ID_NONE,
 	LINK_ID_CONSTFRAME0,
 	LINK_ID_CONSTFRAME1,
@@ -119,6 +125,11 @@ static const enum dc_link_id src_sels[] = {
 	LINK_ID_LAST	/* sentinel */
 };
 
+static const struct dc_ed_subdev_match_data dc_ed_match_data_imx8qxp = {
+	.src_sels = src_sels_imx8qxp,
+	.info = dc_ed_info_imx8qxp,
+};
+
 static inline void dc_ed_pec_enable_shden(struct dc_ed *ed)
 {
 	regmap_write_bits(ed->reg_pec, PIXENGCFG_STATIC, SHDEN, SHDEN);
@@ -144,8 +155,8 @@ void dc_ed_pec_src_sel(struct dc_ed *ed, enum dc_link_id src)
 {
 	int i = 0;
 
-	while (src_sels[i] != LINK_ID_LAST) {
-		if (src_sels[i++] == src) {
+	while (ed->src_sels[i] != LINK_ID_LAST) {
+		if (ed->src_sels[i++] == src) {
 			regmap_write(ed->reg_pec, PIXENGCFG_DYNAMIC, src);
 			return;
 		}
@@ -192,6 +203,8 @@ void dc_ed_init(struct dc_ed *ed)
 
 static int dc_ed_bind(struct device *dev, struct device *master, void *data)
 {
+	const struct dc_ed_subdev_match_data *dc_ed_match_data = device_get_match_data(dev);
+	const struct dc_subdev_info *dc_ed_info = dc_ed_match_data->info;
 	struct platform_device *pdev = to_platform_device(dev);
 	struct dc_drm_device *dc_drm = data;
 	struct resource *res_pec;
@@ -227,6 +240,7 @@ static int dc_ed_bind(struct device *dev, struct device *master, void *data)
 		return ed->irq_shdload;
 
 	ed->dev = dev;
+	ed->src_sels = dc_ed_match_data->src_sels;
 
 	id = dc_subdev_get_id(dc_ed_info, res_pec);
 	if (id < 0) {
@@ -274,7 +288,7 @@ static void dc_ed_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id dc_ed_dt_ids[] = {
-	{ .compatible = "fsl,imx8qxp-dc-extdst" },
+	{ .compatible = "fsl,imx8qxp-dc-extdst", .data = &dc_ed_match_data_imx8qxp },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, dc_ed_dt_ids);
diff --git a/drivers/gpu/drm/imx/dc/dc-pe.h b/drivers/gpu/drm/imx/dc/dc-pe.h
index 1e1e04cc39d4b..7928f947b0cef 100644
--- a/drivers/gpu/drm/imx/dc/dc-pe.h
+++ b/drivers/gpu/drm/imx/dc/dc-pe.h
@@ -56,6 +56,7 @@ struct dc_ed {
 	struct regmap *reg_pec;
 	struct regmap *reg_cfg;
 	int irq_shdload;
+	const enum dc_link_id *src_sels;
 };
 
 struct dc_lb {
-- 
2.51.0

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help