All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jernej Skrabec <jernej.skrabec@siol.net>
To: u-boot@lists.denx.de
Subject: [PATCH 15/19] video: sunxi: de2: switch to DT probing
Date: Tue, 23 Feb 2021 21:46:27 +0100	[thread overview]
Message-ID: <20210223204631.1609597-16-jernej.skrabec@siol.net> (raw)
In-Reply-To: <20210223204631.1609597-1-jernej.skrabec@siol.net>

Currently DE2 driver is probed via driver info. Switch probing to device
tree compatible string method.

Display is now searched via driver name which has same limitation as
previous method. This can be improved only when all drivers in chain are
probed via device tree compatible strings.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/video/sunxi/sunxi_de2.c | 88 +++++++++++++++++++--------------
 1 file changed, 52 insertions(+), 36 deletions(-)

diff --git a/drivers/video/sunxi/sunxi_de2.c b/drivers/video/sunxi/sunxi_de2.c
index e02d359cd259..81576e45e9ef 100644
--- a/drivers/video/sunxi/sunxi_de2.c
+++ b/drivers/video/sunxi/sunxi_de2.c
@@ -31,6 +31,11 @@ enum {
 	LCD_MAX_LOG2_BPP	= VIDEO_BPP32,
 };
 
+struct sunxi_de2_data {
+	int id;
+	const char *disp_drv_name;
+};
+
 static void sunxi_de2_composer_init(void)
 {
 	struct sunxi_ccm_reg * const ccm =
@@ -228,51 +233,34 @@ static int sunxi_de2_init(struct udevice *dev, ulong fbbase,
 
 static int sunxi_de2_probe(struct udevice *dev)
 {
+	const struct sunxi_de2_data *data =
+		(const struct sunxi_de2_data *)dev_get_driver_data(dev);
 	struct video_uc_plat *plat = dev_get_uclass_plat(dev);
 	struct udevice *disp;
-	int ret;
+	int ret, index = 0;
 
 	/* Before relocation we don't need to do anything */
 	if (!(gd->flags & GD_FLG_RELOC))
 		return 0;
 
-	ret = uclass_get_device_by_driver(UCLASS_DISPLAY,
-					  DM_DRIVER_GET(sunxi_lcd), &disp);
-	if (!ret) {
-		int mux;
+	while (!(ret = uclass_get_device(UCLASS_DISPLAY, index++, &disp))) {
+		if (strcmp(disp->driver->name, data->disp_drv_name))
+			continue;
 
-		mux = 0;
+		ret = sunxi_de2_init(dev, plat->base, VIDEO_BPP32, disp,
+				     data->id, false);
+		if (ret)
+			return ret;
 
-		ret = sunxi_de2_init(dev, plat->base, VIDEO_BPP32, disp, mux,
-				     false);
-		if (!ret) {
-			video_set_flush_dcache(dev, 1);
-			return 0;
-		}
-	}
-
-	debug("%s: lcd display not found (ret=%d)\n", __func__, ret);
-
-	ret = uclass_get_device_by_driver(UCLASS_DISPLAY,
-					  DM_DRIVER_GET(sunxi_dw_hdmi), &disp);
-	if (!ret) {
-		int mux;
-		if (IS_ENABLED(CONFIG_MACH_SUNXI_H3_H5))
-			mux = 0;
-		else
-			mux = 1;
+		video_set_flush_dcache(dev, 1);
 
-		ret = sunxi_de2_init(dev, plat->base, VIDEO_BPP32, disp, mux,
-				     false);
-		if (!ret) {
-			video_set_flush_dcache(dev, 1);
-			return 0;
-		}
+		return 0;
 	}
 
-	debug("%s: hdmi display not found (ret=%d)\n", __func__, ret);
+	debug("%s: %s not found (ret=%d)\n", __func__,
+	      data->disp_drv_name, ret);
 
-	return -ENODEV;
+	return ret;
 }
 
 static int sunxi_de2_bind(struct udevice *dev)
@@ -285,22 +273,50 @@ static int sunxi_de2_bind(struct udevice *dev)
 	return 0;
 }
 
+const struct sunxi_de2_data h3_mixer_0 = {
+	.id = 0,
+	.disp_drv_name = "sunxi_dw_hdmi",
+};
+
+const struct sunxi_de2_data a64_mixer_0 = {
+	.id = 0,
+	.disp_drv_name = "sunxi_lcd",
+};
+
+const struct sunxi_de2_data a64_mixer_1 = {
+	.id = 1,
+	.disp_drv_name = "sunxi_dw_hdmi",
+};
+
+static const struct udevice_id sunxi_de2_ids[] = {
+	{
+		.compatible = "allwinner,sun8i-h3-de2-mixer-0",
+		.data = (ulong)&h3_mixer_0,
+	},
+	{
+		.compatible = "allwinner,sun50i-a64-de2-mixer-0",
+		.data = (ulong)&a64_mixer_0,
+	},
+	{
+		.compatible = "allwinner,sun50i-a64-de2-mixer-1",
+		.data = (ulong)&a64_mixer_1,
+	},
+	{ }
+};
+
 static const struct video_ops sunxi_de2_ops = {
 };
 
 U_BOOT_DRIVER(sunxi_de2) = {
 	.name	= "sunxi_de2",
 	.id	= UCLASS_VIDEO,
+	.of_match = sunxi_de2_ids,
 	.ops	= &sunxi_de2_ops,
 	.bind	= sunxi_de2_bind,
 	.probe	= sunxi_de2_probe,
 	.flags	= DM_FLAG_PRE_RELOC,
 };
 
-U_BOOT_DRVINFO(sunxi_de2) = {
-	.name = "sunxi_de2"
-};
-
 /*
  * Simplefb support.
  */
-- 
2.30.1

  parent reply	other threads:[~2021-02-23 20:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23 20:46 [PATCH 00/19] video: sunxi: Rework DE2 driver Jernej Skrabec
2021-02-23 20:46 ` [PATCH 01/19] sunxi: video: select dw-hdmi in Kconfig, not Makefile Jernej Skrabec
2021-03-04  1:40   ` Andre Przywara
2021-02-23 20:46 ` [PATCH 02/19] video: sunxi: Add mode_valid callback to sunxi_dw_hdmi Jernej Skrabec
2021-03-04  1:41   ` Andre Przywara
2021-02-23 20:46 ` [PATCH 03/19] common: edid: check for digital display earlier Jernej Skrabec
2021-03-04  1:41   ` Andre Przywara
2021-02-23 20:46 ` [PATCH 04/19] common: edid: extract code for detailed timing search Jernej Skrabec
2021-03-04  1:41   ` Andre Przywara
2021-03-06 19:16     ` Jernej Škrabec
2021-02-23 20:46 ` [PATCH 05/19] common: edid: Search for valid timing in extension block Jernej Skrabec
2021-02-23 20:46 ` [PATCH 06/19] video: sunxi: Use DW-HDMI hpd function Jernej Skrabec
2021-03-04  1:42   ` Andre Przywara
2021-03-04 17:27     ` Jernej Škrabec
2021-02-23 20:46 ` [PATCH 07/19] video: sunxi: Remove check for ddc-i2c-bus property Jernej Skrabec
2021-03-04  1:42   ` Andre Przywara
2021-03-04 19:41     ` Jernej Škrabec
2021-02-23 20:46 ` [PATCH 08/19] video: sunxi: Remove TV probe from DE2 Jernej Skrabec
2021-02-23 20:46 ` [PATCH 09/19] video: sunxi: de2: switch to public uclass functions Jernej Skrabec
2021-02-23 20:46 ` [PATCH 10/19] video: sunxi: dw-hdmi: probe driver by compatible Jernej Skrabec
2021-02-23 20:46 ` [PATCH 11/19] video: sunxi: dw-hdmi: read address from DT node Jernej Skrabec
2021-02-23 20:46 ` [PATCH 12/19] video: dw-hdmi: modify phy init callback to include full timings Jernej Skrabec
2021-02-23 20:46 ` [PATCH 13/19] video: sunxi: dw-hdmi: move PHY config to appropriate place Jernej Skrabec
2021-02-23 20:46 ` [PATCH 14/19] video: sunxi: dw-hdmi: rework PHY initialization Jernej Skrabec
2021-02-24 18:21   ` [linux-sunxi] " Jernej Škrabec
2021-02-23 20:46 ` Jernej Skrabec [this message]
2021-02-23 20:46 ` [PATCH 16/19] video: sunxi: de2: read address from DT node Jernej Skrabec
2021-02-23 20:46 ` [PATCH 17/19] clk: sunxi: Add DE2 clocks to H3 and A64 Jernej Skrabec
2021-02-23 20:46 ` [PATCH 18/19] clk: sunxi: add DE2 clock driver Jernej Skrabec
2021-02-23 20:46 ` [PATCH 19/19] video: sunxi: de2: switch clock setup to DM model Jernej Skrabec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210223204631.1609597-16-jernej.skrabec@siol.net \
    --to=jernej.skrabec@siol.net \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.