All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jayesh Choudhary <j-choudhary@ti.com>
To: Michael Walle <mwalle@kernel.org>, Doug Anderson <dianders@chromium.org>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/bridge: ti-sn65dsi86: fix REFCLK setting
Date: Thu, 12 Jun 2025 13:04:43 +0530	[thread overview]
Message-ID: <affbef6e-f253-4dbb-bf64-3cc7d244acbb@ti.com> (raw)
In-Reply-To: <c0027ff0e63bcc0fd21aab37af991baf@kernel.org>

Hello Michael,

On 10/06/25 12:45, Michael Walle wrote:
> Hi Jayesh,
> 
>>>> +       /*
>>>> +        * After EN is deasserted and an external clock is detected, 
>>>> the bridge
>>>> +        * will sample GPIO3:1 to determine its frequency. The 
>>>> driver will
>>>> +        * overwrite this setting. But this is racy. Thus we have to 
>>>> wait a
>>>> +        * couple of us. According to the datasheet the GPIO lines 
>>>> has to be
>>>> +        * stable at least 5 us (td5) but it seems that is not 
>>>> enough and the
>>>> +        * refclk frequency value is lost/overwritten by the bridge 
>>>> itself.
>>>> +        * Waiting for 20us seems to work.
>>>> +        */
>>>> +       usleep_range(20, 30);
>>>
>>> It might be worth pointing at _where_ the driver overwrites this
>>> setting, or maybe at least pointing to something that makes it easy to
>>> find which exact bits you're talking about.
> 
> Yeah, Jayesh just pointed that out below. I'll add add it to the comment.
> 
>>> This looks reasonable to me, though.
>>
>> I think we are talking about SN_DPPLL_SRC_REG[3:1] bits?
> 
> Yes.
> 
>> What exact mismatch are you observing in register value?
> 
> The one set by the chip itself vs the one from the driver, see below.
> 
>> I am assuming that you have a clock at REFCLK pin. For that:
> 
> Yes, I'm using an external clock.
> 
>> If refclk is described in devicetree node, then I see that
>> the driver modifies it in every resume call based solely on the
>> clock value in dts.
> 
> Exactly. But that is racy with what the chip itself is doing. I.e.
> if you don't have that usleep() above, the chip will win the race
> and the refclk frequency setting will be set according to the
> external GPIOs (which is poorly described in the datasheet, btw),
> regardless what the linux driver is setting (because that I2C write
> happens too early).

I am a little confused here.
Won't it be opposite?
If we have this delay here, GPIO will stabilize and set the register
accordingly?

In the driver, I came across the case when we do not have refclk.
(My platform does have a refclk, I am just removing the property from
the dts node to check the affect of GPIO[3:1] in question because clock
is not a required property for the bridge as per the bindings)

In the ti_sn65dsi86_probe(), before we read SN_DEVICE_ID_REGS,
when we go to resume(), we do not do enable_comms() that calls
ti_sn_bridge_set_refclk_freq() to set SN_DPPLL_SRC_REG.
I see that register read for SN_DEVICE_ID_REGS fails in that case.

Adding this delay fixes that issue. This made me think that we need
the delay for GPIO to stabilize and set the refclk.

Is my understanding incorrect?

I am totally on board with your change especially after observing the
above but is my understanding incorrect somewhere?

Warm Regards,
Jayesh

> 
>> If refclk is not described in dts, then this register is modified by the
>> driver only when pre_enable() calls enable_comms(). Here also, the
>> value depends on crtc_mode and the refclk_rate often would not be equal
>> to the values in "ti_sn_bridge_dsiclk_lut" (supported frequencies), and
>> you would fallback to "001" register value.
> 
>> Rest of time, I guess it depends on reading the status from GPIO and
>> changing the register.
> 
> Not "rest of the time", the reading of the strapping option from the
> GPIO always happens if an external refclk is detected. It's part of
> the chip after all. It will just sometimes be overwritten by the
> linux driver.
> 
>> Is the latter one your usecase?
> 
> My use case is that the GPIO setting is wrong on my board (it's really
> non-existent) and I'm relying on the linux driver to set the correct
> frequency.
> 
> HTH,
> -michael

  reply	other threads:[~2025-06-12  7:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-28 13:21 [PATCH] drm/bridge: ti-sn65dsi86: fix REFCLK setting Michael Walle
2025-06-09 22:29 ` Doug Anderson
2025-06-10  7:03   ` Jayesh Choudhary
2025-06-10  7:15     ` Michael Walle
2025-06-12  7:34       ` Jayesh Choudhary [this message]
2025-06-12 11:59         ` Michael Walle
2025-06-12 17:52         ` Doug Anderson
2025-06-12 22:31           ` Doug Anderson
2025-06-13  6:41             ` Lucas Stach

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=affbef6e-f253-4dbb-bf64-3cc7d244acbb@ti.com \
    --to=j-choudhary@ti.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=mwalle@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.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.