All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrzej Hajda <a.hajda@samsung.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	dri-devel@lists.freedesktop.org,
	Lucas Stach <l.stach@pengutronix.de>,
	Andrey Gusakov <andrey.gusakov@cogentembedded.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Andrey Smirnov <andrew.smirnov@gmail.com>,
	Jyri Sarha <jsarha@ti.com>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	Benoit Parrot <bparrot@ti.com>
Subject: Re: [PATCHv2 15/22] drm/bridge: tc358767: clean-up link training
Date: Mon, 15 Apr 2019 11:54:58 +0200	[thread overview]
Message-ID: <19a5958b-c73e-ee62-7675-7c7551bd8e68@samsung.com> (raw)
In-Reply-To: <20190326103146.24795-16-tomi.valkeinen@ti.com>

On 26.03.2019 11:31, Tomi Valkeinen wrote:
> The current link training code does unnecessary retry-loops, and does
> extra writes to the registers. It is easier to follow the flow and
> ensure it's similar to Toshiba's documentation if we deal with LT inside
> tc_main_link_enable() function.
>
> This patch adds tc_wait_link_training() which handles waiting for the LT
> phase to finish, and does the necessary LT register setups in
> tc_main_link_enable, without extra loops.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>


Btw, there is other patchset which touches the same things, have you
decided which one should go first? yours or Andrey's?


 --
Regards
Andrzej


> ---
>  drivers/gpu/drm/bridge/tc358767.c | 129 +++++++++++++-----------------
>  1 file changed, 57 insertions(+), 72 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
> index 220408db82f7..1c61f6205e43 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -740,83 +740,25 @@ static int tc_set_video_mode(struct tc_data *tc,
>  	return ret;
>  }
>  
> -static int tc_link_training(struct tc_data *tc, int pattern)
> +static int tc_wait_link_training(struct tc_data *tc, u32 *error)
>  {
> -	const char * const *errors;
> -	u32 srcctrl = tc_srcctrl(tc) | DP0_SRCCTRL_SCRMBLDIS |
> -		      DP0_SRCCTRL_AUTOCORRECT;
> -	int timeout;
> -	int retry;
> +	u32 timeout = 1000;
>  	u32 value;
>  	int ret;
>  
> -	if (pattern == DP_TRAINING_PATTERN_1) {
> -		srcctrl |= DP0_SRCCTRL_TP1;
> -		errors = training_pattern1_errors;
> -	} else {
> -		srcctrl |= DP0_SRCCTRL_TP2;
> -		errors = training_pattern2_errors;
> -	}
> -
> -	/* Set DPCD 0x102 for Training Part 1 or 2 */
> -	tc_write(DP0_SNKLTCTRL, DP_LINK_SCRAMBLING_DISABLE | pattern);
> -
> -	tc_write(DP0_LTLOOPCTRL,
> -		 (0x0f << 28) |	/* Defer Iteration Count */
> -		 (0x0f << 24) |	/* Loop Iteration Count */
> -		 (0x0d << 0));	/* Loop Timer Delay */
> -
> -	retry = 5;
>  	do {
> -		/* Set DP0 Training Pattern */
> -		tc_write(DP0_SRCCTRL, srcctrl);
> -
> -		/* Enable DP0 to start Link Training */
> -		tc_write(DP0CTL, DP_EN);
> -
> -		/* wait */
> -		timeout = 1000;
> -		do {
> -			tc_read(DP0_LTSTAT, &value);
> -			udelay(1);
> -		} while ((!(value & LT_LOOPDONE)) && (--timeout));
> -		if (timeout == 0) {
> -			dev_err(tc->dev, "Link training timeout!\n");
> -		} else {
> -			int pattern = (value >> 11) & 0x3;
> -			int error = (value >> 8) & 0x7;
> -
> -			dev_dbg(tc->dev,
> -				"Link training phase %d done after %d uS: %s\n",
> -				pattern, 1000 - timeout, errors[error]);
> -			if (pattern == DP_TRAINING_PATTERN_1 && error == 0)
> -				break;
> -			if (pattern == DP_TRAINING_PATTERN_2) {
> -				value &= LT_CHANNEL1_EQ_BITS |
> -					 LT_INTERLANE_ALIGN_DONE |
> -					 LT_CHANNEL0_EQ_BITS;
> -				/* in case of two lanes */
> -				if ((tc->link.base.num_lanes == 2) &&
> -				    (value == (LT_CHANNEL1_EQ_BITS |
> -					       LT_INTERLANE_ALIGN_DONE |
> -					       LT_CHANNEL0_EQ_BITS)))
> -					break;
> -				/* in case of one line */
> -				if ((tc->link.base.num_lanes == 1) &&
> -				    (value == (LT_INTERLANE_ALIGN_DONE |
> -					       LT_CHANNEL0_EQ_BITS)))
> -					break;
> -			}
> -		}
> -		/* restart */
> -		tc_write(DP0CTL, 0);
> -		usleep_range(10, 20);
> -	} while (--retry);
> -	if (retry == 0) {
> -		dev_err(tc->dev, "Failed to finish training phase %d\n",
> -			pattern);
> +		udelay(1);
> +		tc_read(DP0_LTSTAT, &value);
> +	} while ((!(value & LT_LOOPDONE)) && (--timeout));
> +
> +	if (timeout == 0) {
> +		dev_err(tc->dev, "Link training timeout waiting for LT_LOOPDONE!\n");
> +		ret = -ETIMEDOUT;
> +		goto err;
>  	}
>  
> +	*error = (value >> 8) & 0x7;
> +
>  	return 0;
>  err:
>  	return ret;
> @@ -832,6 +774,7 @@ static int tc_main_link_enable(struct tc_data *tc)
>  	u32 value;
>  	int ret;
>  	u8 tmp[8];
> +	u32 error;
>  
>  	/* display mode should be set at this point */
>  	if (!tc->mode)
> @@ -950,14 +893,56 @@ static int tc_main_link_enable(struct tc_data *tc)
>  	if (ret < 0)
>  		goto err_dpcd_write;
>  
> -	ret = tc_link_training(tc, DP_TRAINING_PATTERN_1);
> +	/* LINK TRAINING PATTERN 1 */
> +
> +	/* Set DPCD 0x102 for Training Pattern 1 */
> +	tc_write(DP0_SNKLTCTRL, DP_LINK_SCRAMBLING_DISABLE | DP_TRAINING_PATTERN_1);
> +
> +	tc_write(DP0_LTLOOPCTRL,
> +		 (15 << 28) |	/* Defer Iteration Count */
> +		 (15 << 24) |	/* Loop Iteration Count */
> +		 (0xd << 0));	/* Loop Timer Delay */
> +
> +	tc_write(DP0_SRCCTRL, tc_srcctrl(tc) | DP0_SRCCTRL_SCRMBLDIS | DP0_SRCCTRL_AUTOCORRECT |
> +		 DP0_SRCCTRL_TP1);
> +
> +	/* Enable DP0 to start Link Training */
> +	tc_write(DP0CTL,
> +		 ((tc->link.base.capabilities & DP_LINK_CAP_ENHANCED_FRAMING) ? EF_EN : 0) |
> +		 DP_EN);
> +
> +	/* wait */
> +	ret = tc_wait_link_training(tc, &error);
>  	if (ret)
>  		goto err;
>  
> -	ret = tc_link_training(tc, DP_TRAINING_PATTERN_2);
> +	if (error) {
> +		dev_err(tc->dev, "Link training phase 1 failed: %s\n",
> +			training_pattern1_errors[error]);
> +		ret = -ENODEV;
> +		goto err;
> +	}
> +
> +	/* LINK TRAINING PATTERN 2 */
> +
> +	/* Set DPCD 0x102 for Training Pattern 2 */
> +	tc_write(DP0_SNKLTCTRL, DP_LINK_SCRAMBLING_DISABLE | DP_TRAINING_PATTERN_2);
> +
> +	tc_write(DP0_SRCCTRL, tc_srcctrl(tc) | DP0_SRCCTRL_SCRMBLDIS | DP0_SRCCTRL_AUTOCORRECT |
> +		 DP0_SRCCTRL_TP2);
> +
> +	/* wait */
> +	ret = tc_wait_link_training(tc, &error);
>  	if (ret)
>  		goto err;
>  
> +	if (error) {
> +		dev_err(tc->dev, "Link training phase 2 failed: %s\n",
> +			training_pattern2_errors[error]);
> +		ret = -ENODEV;
> +		goto err;
> +	}
> +
>  	/* Clear Training Pattern, set AutoCorrect Mode = 1 */
>  	tc_write(DP0_SRCCTRL, tc_srcctrl(tc) | DP0_SRCCTRL_AUTOCORRECT);
>  


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-04-15  9:54 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26 10:31 [PATCHv2 00/22] drm/bridge: tc358767: DP support Tomi Valkeinen
2019-03-26 10:31 ` [PATCHv2 01/22] drm/bridge: tc358767: fix tc_aux_get_status error handling Tomi Valkeinen
2019-04-15  7:20   ` Andrzej Hajda
2019-04-20 20:14   ` Laurent Pinchart
2019-04-26 14:08     ` Tomi Valkeinen
2019-03-26 10:31 ` [PATCHv2 02/22] drm/bridge: tc358767: reset voltage-swing & pre-emphasis Tomi Valkeinen
2019-04-15  7:20   ` Andrzej Hajda
2019-04-20 20:30   ` Laurent Pinchart
2019-04-26 14:14     ` Tomi Valkeinen
2019-04-26 23:46       ` Laurent Pinchart
2019-04-26 23:54       ` Andrey Smirnov
2019-03-26 10:31 ` [PATCHv2 03/22] drm/bridge: tc358767: fix ansi 8b10b use Tomi Valkeinen
2019-04-15  7:29   ` Andrzej Hajda
2019-04-20 21:13   ` Laurent Pinchart
2019-04-23  8:19     ` Andrey Gusakov
2019-04-23 14:56       ` Laurent Pinchart
2019-04-24 13:52         ` Andrey Gusakov
2019-05-03 11:43         ` Tomi Valkeinen
2019-05-03 12:48           ` Laurent Pinchart
2019-05-03 13:17             ` Tomi Valkeinen
2019-05-03 17:11               ` Laurent Pinchart
2019-05-06  9:58                 ` Tomi Valkeinen
2019-05-21  7:21                   ` Andrey Smirnov
2019-03-26 10:31 ` [PATCHv2 04/22] drm/bridge: tc358767: cleanup spread & scrambler_dis Tomi Valkeinen
2019-04-15  7:31   ` Andrzej Hajda
2019-04-20 21:16   ` Laurent Pinchart
2019-03-26 10:31 ` [PATCHv2 05/22] drm/bridge: tc358767: remove unused swing & preemp Tomi Valkeinen
2019-04-15  7:31   ` Andrzej Hajda
2019-04-20 21:16   ` Laurent Pinchart
2019-03-26 10:31 ` [PATCHv2 06/22] drm/bridge: tc358767: cleanup aux_link_setup Tomi Valkeinen
2019-04-15  7:38   ` Andrzej Hajda
2019-04-15  7:52     ` Tomi Valkeinen
2019-04-20 21:20       ` Laurent Pinchart
2019-03-26 10:31 ` [PATCHv2 07/22] drm/bridge: tc358767: move video stream setup to tc_main_link_stream Tomi Valkeinen
2019-04-15  7:48   ` Andrzej Hajda
2019-04-20 21:25   ` Laurent Pinchart
2019-05-03  9:12     ` Tomi Valkeinen
2019-03-26 10:31 ` [PATCHv2 08/22] drm/bridge: tc358767: split stream enable/disable Tomi Valkeinen
2019-04-15  8:26   ` Andrzej Hajda
2019-04-20 21:29   ` Laurent Pinchart
2019-05-03  9:20     ` Tomi Valkeinen
2019-05-03 12:55       ` Laurent Pinchart
2019-05-03 13:08         ` Tomi Valkeinen
2019-03-26 10:31 ` [PATCHv2 09/22] drm/bridge: tc358767: move PXL PLL enable/disable to " Tomi Valkeinen
2019-04-15  8:28   ` Andrzej Hajda
2019-04-20 21:33   ` Laurent Pinchart
2019-03-26 10:31 ` [PATCHv2 10/22] drm/bridge: tc358767: add link disable function Tomi Valkeinen
2019-04-15  8:36   ` Andrzej Hajda
2019-04-15 11:39     ` Tomi Valkeinen
2019-04-20 21:39       ` Laurent Pinchart
2019-05-03  9:36         ` Tomi Valkeinen
2019-03-26 10:31 ` [PATCHv2 11/22] drm/bridge: tc358767: ensure DP is disabled before LT Tomi Valkeinen
2019-04-15  8:49   ` Andrzej Hajda
2019-04-15 11:26     ` Tomi Valkeinen
2019-04-20 21:41       ` Laurent Pinchart
2019-03-26 10:31 ` [PATCHv2 12/22] drm/bridge: tc358767: remove unnecessary msleep Tomi Valkeinen
2019-04-15  8:50   ` Andrzej Hajda
2019-04-20 21:43   ` Laurent Pinchart
2019-04-23  7:52     ` Andrey Gusakov
2019-03-26 10:31 ` [PATCHv2 13/22] drm/bridge: tc358767: use more reliable seq when finishing LT Tomi Valkeinen
2019-04-15  8:51   ` Andrzej Hajda
2019-04-20 21:44   ` Laurent Pinchart
2019-05-03 11:04     ` Tomi Valkeinen
2019-03-26 10:31 ` [PATCHv2 14/22] drm/bridge: tc358767: cleanup LT result check Tomi Valkeinen
2019-04-15  8:53   ` Andrzej Hajda
2019-04-20 22:06   ` Laurent Pinchart
2019-05-03 11:00     ` Tomi Valkeinen
2019-03-26 10:31 ` [PATCHv2 15/22] drm/bridge: tc358767: clean-up link training Tomi Valkeinen
2019-04-15  9:54   ` Andrzej Hajda [this message]
2019-04-15 11:03     ` Tomi Valkeinen
2019-04-20 22:13   ` Laurent Pinchart
2019-05-03  8:37     ` Tomi Valkeinen
2019-03-26 10:31 ` [PATCHv2 16/22] drm/bridge: tc358767: remove check for video mode in link enable Tomi Valkeinen
2019-04-15  9:55   ` Andrzej Hajda
2019-04-20 22:14   ` Laurent Pinchart
2019-05-03  8:10     ` Tomi Valkeinen
2019-05-03 13:00       ` Laurent Pinchart
2019-03-26 10:31 ` [PATCHv2 17/22] drm/bridge: tc358767: use bridge mode_valid Tomi Valkeinen
2019-04-15  9:56   ` Andrzej Hajda
2019-04-20 22:15   ` Laurent Pinchart
2019-03-26 10:31 ` [PATCHv2 18/22] drm/bridge: tc358767: remove tc_connector_best_encoder Tomi Valkeinen
2019-04-15  9:57   ` Andrzej Hajda
2019-04-20 22:18   ` Laurent Pinchart
2019-03-26 10:31 ` [PATCHv2 19/22] drm/bridge: tc358767: copy the mode data, instead of storing the pointer Tomi Valkeinen
2019-04-15 10:09   ` Andrzej Hajda
2019-04-15 11:19     ` Tomi Valkeinen
2019-04-15 12:12       ` Andrzej Hajda
2019-04-20 22:20         ` Laurent Pinchart
2019-03-26 10:31 ` [PATCHv2 20/22] drm/bridge: tc358767: add GPIO & interrupt registers Tomi Valkeinen
2019-04-15 10:09   ` Andrzej Hajda
2019-03-26 10:31 ` [PATCHv2 21/22] drm/bridge: tc358767: add IRQ and HPD support Tomi Valkeinen
2019-04-02  2:16   ` Andrey Smirnov
2019-04-03 11:34     ` Tomi Valkeinen
2019-04-12  8:02       ` Tomi Valkeinen
2019-04-12 18:17         ` Andrey Smirnov
2019-04-15 10:42   ` Andrzej Hajda
2019-04-15 10:59     ` Tomi Valkeinen
2019-04-17  7:32       ` Andrzej Hajda
2019-04-29  9:27         ` Tomi Valkeinen
2019-03-26 10:31 ` [PATCHv2 22/22] dt-bindings: tc358767: add IRQ & " Tomi Valkeinen
2019-03-31  6:42   ` Rob Herring
2019-04-01 10:13   ` [PATCHv2.1 22/22] dt-bindings: tc358767: add " Tomi Valkeinen
2019-04-06  6:06     ` Rob Herring

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=19a5958b-c73e-ee62-7675-7c7551bd8e68@samsung.com \
    --to=a.hajda@samsung.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=andrew.smirnov@gmail.com \
    --cc=andrey.gusakov@cogentembedded.com \
    --cc=bparrot@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=l.stach@pengutronix.de \
    --cc=p.zabel@pengutronix.de \
    --cc=peter.ujfalusi@ti.com \
    --cc=tomi.valkeinen@ti.com \
    /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.