public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 12/19] video: sunxi: de2: switch to DT probing
Date: Tue, 6 Apr 2021 02:09:08 +0100	[thread overview]
Message-ID: <20210406020908.4df233f6@slackpad.fritz.box> (raw)
In-Reply-To: <20210306195437.9740-13-jernej.skrabec@siol.net>

On Sat,  6 Mar 2021 20:54:30 +0100
Jernej Skrabec <jernej.skrabec@siol.net> wrote:

Hi Jernej,

(CC:ing Simon for some DM issues below)

> 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.

So on a first glance this looks alright (also the fixed version on your
github). However it doesn't work on the Pine64-LTS (or A64 in general),
and I identified at least two problems below:

> 
> 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;

nit: can you rename this to something less general, like mux or
pipeline_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))) {

So this call tries to enumerate all devices registered as
UCLASS_DISPLAY. For the A64 the sunxi_lcd driver provides one device,
however it only probes correctly when there is bridge configured (for
the Pinebook, for instance). There is code to read timings from DT,
but I don't find any of the required properties (simple-panel) in any
Allwinner DTs (using DE2, at least).
As a consequence the probe in sunxi_lcd.c fails (except for the
Pinebook), and it returns -ENODEV. This is unfortunately the same error
code that uclass_get_device_by_driver() returns when there are no
(more) devices providing UCLASS_DISPLAY, so the while loop stops here,
before having considered the HDMI devices (which are enumerated *after*
the LCD device). This is the same problem with your change to use
uclass_id_foreach_dev(), btw.

Not sure how to best solve this, it sounds like a general DM related
problem (failing probe() ending iterating all devices in one class).

I hacked this a bit (using a different error code in sunxi_lcd_probe()
and catching/translating this here), but this revealed another problem:
I only ever see the mixer0 device being probed (actually multiple
times). I could debug that both mixers are detected in the DT, created
as two devices and bound (using the right .id value and the right DT
offset), but only the first one is ever probed through this function
here. Unfortunately this is the wrong one (HDMI is on mixer1), so
de2_probe() fails :-(
Disabling mixer0 in the DT makes it work (on top of the hack above).

No real clue about this second problem, but I will debug further.

Cheers,
Andre


> +		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.
>   */

  reply	other threads:[~2021-04-06  1:09 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-06 19:54 [PATCH v2 00/19] video: sunxi: rework DE2 driver Jernej Skrabec
2021-03-06 19:54 ` [PATCH v2 01/19] sunxi: video: select dw-hdmi in Kconfig, not Makefile Jernej Skrabec
2021-03-06 19:54 ` [PATCH v2 02/19] video: sunxi: Add mode_valid callback to sunxi_dw_hdmi Jernej Skrabec
2021-03-06 19:54 ` [PATCH v2 03/19] common: edid: check for digital display earlier Jernej Skrabec
2021-03-06 19:54 ` [PATCH v2 04/19] common: edid: extract code for detailed timing search Jernej Skrabec
2021-03-07  1:29   ` Andre Przywara
2021-03-06 19:54 ` [PATCH v2 05/19] common: edid: Search for valid timing in extension block Jernej Skrabec
2021-03-06 19:54 ` [PATCH v2 06/19] video: sunxi: Use DW-HDMI hpd function Jernej Skrabec
2021-03-07  1:30   ` Andre Przywara
2021-03-06 19:54 ` [PATCH v2 07/19] video: sunxi: Remove check for ddc-i2c-bus property Jernej Skrabec
2021-03-06 19:54 ` [PATCH v2 08/19] video: sunxi: Remove TV probe from DE2 Jernej Skrabec
2021-03-07  1:31   ` Andre Przywara
2021-03-06 19:54 ` [PATCH v2 09/19] video: sunxi: de2: switch to public uclass functions Jernej Skrabec
2021-03-07  1:32   ` Andre Przywara
2021-03-07  7:35     ` Jernej Škrabec
2021-03-09  0:40       ` Andre Przywara
2021-03-09  5:35         ` Jernej Škrabec
2021-03-06 19:54 ` [PATCH v2 10/19] video: sunxi: dw-hdmi: probe driver by compatible Jernej Skrabec
2021-03-07  1:33   ` Andre Przywara
2021-03-06 19:54 ` [PATCH v2 11/19] video: sunxi: dw-hdmi: read address from DT node Jernej Skrabec
2021-04-06  1:09   ` Andre Przywara
2021-03-06 19:54 ` [PATCH v2 12/19] video: sunxi: de2: switch to DT probing Jernej Skrabec
2021-04-06  1:09   ` Andre Przywara [this message]
2021-04-06  7:14     ` Simon Glass
2021-03-06 19:54 ` [PATCH v2 13/19] video: sunxi: de2: read address from DT node Jernej Skrabec
2021-04-06  1:10   ` Andre Przywara
2021-03-06 19:54 ` [PATCH v2 14/19] clk: sunxi: Add DE2 and HDMI clocks to H3 and A64 Jernej Skrabec
2021-03-08  8:00   ` Jagan Teki
2021-03-06 19:54 ` [PATCH v2 15/19] clk: sunxi: add DE2 clock driver Jernej Skrabec
2021-03-08  7:59   ` Jagan Teki
2021-03-06 19:54 ` [PATCH v2 16/19] video: sunxi: de2: switch clock setup to DM model Jernej Skrabec
2021-03-08  8:02   ` Jagan Teki
2021-03-06 19:54 ` [PATCH v2 17/19] video: dw-hdmi: modify phy init callback to include full timings Jernej Skrabec
2021-03-06 19:54 ` [PATCH v2 18/19] video: sunxi: Add DW HDMI PHY driver Jernej Skrabec
2021-03-08  7:57   ` Jagan Teki
2021-03-09  5:38     ` Jernej Škrabec
2021-03-06 19:54 ` [PATCH v2 19/19] video: sunxi: dw-hdmi: Use new " 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=20210406020908.4df233f6@slackpad.fritz.box \
    --to=andre.przywara@arm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox