All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Tony Lindgren <tony@atomide.com>,
	"H . Nikolaus Schaller" <hns@goldelico.com>,
	Jyri Sarha <jsarha@ti.com>,
	dri-devel@lists.freedesktop.org,
	Aaro Koskinen <aaro.koskinen@iki.fi>
Subject: Re: [PATCH 3/3] drm/omap: fix i886 work-around
Date: Mon, 07 Aug 2017 14:47:48 +0300	[thread overview]
Message-ID: <5477872.jgrBENxQhv@avalon> (raw)
In-Reply-To: <1497344530-19940-4-git-send-email-tomi.valkeinen@ti.com>

Hi Tomi,

Thank you for the patch.

On Tuesday 13 Jun 2017 12:02:10 Tomi Valkeinen wrote:
> 7d267f068a8b4944d52e8b0ae4c8fcc1c1c5c5ba ("drm/omap: work-around for
> errata i886") changed how the PLL dividers and multipliers are
> calculated. While the new way should work fine for all the PLLs, it
> breaks omap5 PLLs. The issues seen are rather odd: seemed that the
> output clock rate is half of what we asked. It is unclear what's causing
> there issues.

Does this patch result in PLL parameters for half of the expected rate, or 
does it compute the expected parameters, with the PLL producing half of the 
expected rate for an unknown reason ?

> As a work-around this patch adds a "errata_i886" flag, which is set only
> for DRA7's PLLs, and the PLL setup is done according to that flag.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dss.h       |  3 +++
>  drivers/gpu/drm/omapdrm/dss/pll.c       | 29 ++++++++++++++++++++---------
>  drivers/gpu/drm/omapdrm/dss/video-pll.c |  2 ++
>  3 files changed, 25 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h
> b/drivers/gpu/drm/omapdrm/dss/dss.h index 5dd29c98143a..8ea3daa9aed9 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -174,6 +174,9 @@ struct dss_pll_hw {
>  	bool has_freqsel;
>  	bool has_selfreqdco;
>  	bool has_refsel;
> +
> +	/* DRA7 errata i886: use high N & M to avoid jitter */
> +	bool errata_i886;
>  };
> 
>  struct dss_pll {
> diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c
> b/drivers/gpu/drm/omapdrm/dss/pll.c index 5e221302768b..9d9d9d42009b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/pll.c
> @@ -215,8 +215,8 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned
> long clkin, dss_pll_calc_func func, void *data)
>  {
>  	const struct dss_pll_hw *hw = pll->hw;
> -	int n, n_min, n_max;
> -	int m, m_min, m_max;
> +	int n, n_start, n_stop, n_inc;
> +	int m, m_start, m_stop, m_inc;
>  	unsigned long fint, clkdco;
>  	unsigned long pll_hw_max;
>  	unsigned long fint_hw_min, fint_hw_max;
> @@ -226,22 +226,33 @@ bool dss_pll_calc_a(const struct dss_pll *pll,
> unsigned long clkin, fint_hw_min = hw->fint_min;
>  	fint_hw_max = hw->fint_max;
> 
> -	n_min = max(DIV_ROUND_UP(clkin, fint_hw_max), 1ul);
> -	n_max = min((unsigned)(clkin / fint_hw_min), hw->n_max);
> +	n_start = max(DIV_ROUND_UP(clkin, fint_hw_max), 1ul);
> +	n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max);
> +	n_inc = 1;
> +
> +	if (hw->errata_i886) {
> +		swap(n_start, n_stop);
> +		n_inc = -1;
> +	}
> 
>  	pll_max = pll_max ? pll_max : ULONG_MAX;
> 
> -	/* Try to find high N & M to avoid jitter (DRA7 errata i886) */
> -	for (n = n_max; n >= n_min; --n) {
> +	for (n = n_start; n != n_stop; n += n_inc) {
>  		fint = clkin / n;
> 
> -		m_min = max(DIV_ROUND_UP(DIV_ROUND_UP(pll_min, fint), 2),
> +		m_start = max(DIV_ROUND_UP(DIV_ROUND_UP(pll_min, fint), 2),
>  				1ul);
> -		m_max = min3((unsigned)(pll_max / fint / 2),
> +		m_stop = min3((unsigned)(pll_max / fint / 2),
>  				(unsigned)(pll_hw_max / fint / 2),
>  				hw->m_max);
> +		m_inc = 1;
> +
> +		if (hw->errata_i886) {
> +			swap(m_start, m_stop);
> +			m_inc = -1;
> +		}
> 
> -		for (m = m_max; m >= m_min; --m) {
> +		for (m = m_start; m != m_stop; m += m_inc) {
>  			clkdco = 2 * m * fint;
> 
>  			if (func(n, m, fint, clkdco, data))
> diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c
> b/drivers/gpu/drm/omapdrm/dss/video-pll.c index 7429de928d4e..8201ecf826d9
> 100644
> --- a/drivers/gpu/drm/omapdrm/dss/video-pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c
> @@ -131,6 +131,8 @@ static const struct dss_pll_hw dss_dra7_video_pll_hw = {
> .mX_lsb[3] = 5,
> 
>  	.has_refsel = true,
> +
> +	.errata_i886 = true,
>  };
> 
>  struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,

-- 
Regards,

Laurent Pinchart

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

  reply	other threads:[~2017-08-07 11:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13  9:02 [PATCH 0/3] drm/omap: misc fixes Tomi Valkeinen
2017-06-13  9:02 ` [PATCH 1/3] drm/omap: work-around for omap3 display enable Tomi Valkeinen
2017-06-14 20:07   ` Aaro Koskinen
2017-08-23  9:33   ` Tomi Valkeinen
2017-10-12 22:47     ` Aaro Koskinen
2017-06-13  9:02 ` [PATCH 2/3] drm/omap: fix analog tv-out modecheck Tomi Valkeinen
2017-06-13  9:02 ` [PATCH 3/3] drm/omap: fix i886 work-around Tomi Valkeinen
2017-08-07 11:47   ` Laurent Pinchart [this message]
2017-08-07 11:52     ` Tomi Valkeinen
2017-06-14 11:17 ` [PATCH 0/3] drm/omap: misc fixes Tony Lindgren
2017-06-14 15:54 ` H. Nikolaus Schaller

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=5477872.jgrBENxQhv@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hns@goldelico.com \
    --cc=jsarha@ti.com \
    --cc=tomi.valkeinen@ti.com \
    --cc=tony@atomide.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.