From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Adam Ford <aford173@gmail.com>, dri-devel@lists.freedesktop.org
Cc: aford@beaconembedded.com, Lucas Stach <l.stach@pengutronix.de>,
Chen-Yu Tsai <wenst@chromium.org>,
Frieder Schrempf <frieder.schrempf@kontron.de>,
Michael Walle <michael@walle.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>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
Inki Dae <inki.dae@samsung.com>,
Jagan Teki <jagan@amarulasolutions.com>,
Marek Vasut <marex@denx.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V6 5/6] drm: bridge: samsung-dsim: Dynamically configure DPHY timing
Date: Wed, 17 May 2023 23:34:25 +0200 [thread overview]
Message-ID: <45e4370f-fdee-9178-5c15-43205dc02bb9@samsung.com> (raw)
In-Reply-To: <CAHCN7xL8qkCgXEE3nZvmwbWGO5GtF+37eOVYq63djGOHDaSdmA@mail.gmail.com>
Hi Adam,
On 17.05.2023 04:55, Adam Ford wrote:
> On Mon, May 15, 2023 at 6:57 PM Adam Ford <aford173@gmail.com> wrote:
>> The DPHY timings are currently hard coded. Since the input
>> clock can be variable, the phy timings need to be variable
>> too. To facilitate this, we need to cache the hs_clock
>> based on what is generated from the PLL.
>>
>> The phy_mipi_dphy_get_default_config_for_hsclk function
>> configures the DPHY timings in pico-seconds, and a small macro
>> converts those timings into clock cycles based on the hs_clk.
>>
>> Signed-off-by: Adam Ford <aford173@gmail.com>
>> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
>> Tested-by: Chen-Yu Tsai <wenst@chromium.org>
>> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
>> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
>> Tested-by: Michael Walle <michael@walle.cc>
>> ---
>> drivers/gpu/drm/bridge/samsung-dsim.c | 57 +++++++++++++++++++++++----
>> include/drm/bridge/samsung-dsim.h | 1 +
>> 2 files changed, 51 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
>> index 08266303c261..3944b7cfbbdf 100644
>> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
>> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
>> @@ -218,6 +218,8 @@
>>
>> #define OLD_SCLK_MIPI_CLK_NAME "pll_clk"
>>
>> +#define PS_TO_CYCLE(ps, hz) DIV64_U64_ROUND_CLOSEST(((ps) * (hz)), 1000000000000ULL)
>> +
>> static const char *const clk_names[5] = {
>> "bus_clk",
>> "sclk_mipi",
>> @@ -651,6 +653,8 @@ static unsigned long samsung_dsim_set_pll(struct samsung_dsim *dsi,
>> reg = samsung_dsim_read(dsi, DSIM_STATUS_REG);
>> } while ((reg & DSIM_PLL_STABLE) == 0);
>>
>> + dsi->hs_clock = fout;
>> +
>> return fout;
>> }
>>
>> @@ -698,13 +702,46 @@ static void samsung_dsim_set_phy_ctrl(struct samsung_dsim *dsi)
>> const struct samsung_dsim_driver_data *driver_data = dsi->driver_data;
>> const unsigned int *reg_values = driver_data->reg_values;
>> u32 reg;
>> + struct phy_configure_opts_mipi_dphy cfg;
>> + int clk_prepare, lpx, clk_zero, clk_post, clk_trail;
>> + int hs_exit, hs_prepare, hs_zero, hs_trail;
>> + unsigned long long byte_clock = dsi->hs_clock / 8;
>>
>> if (driver_data->has_freqband)
>> return;
>>
>> + phy_mipi_dphy_get_default_config_for_hsclk(dsi->hs_clock,
>> + dsi->lanes, &cfg);
>> +
>> + /*
>> + * TODO:
>> + * The tech reference manual for i.MX8M Mini/Nano/Plus
>> + * doesn't state what the definition of the PHYTIMING
>> + * bits are beyond their address and bit position.
>> + * After reviewing NXP's downstream code, it appears
>> + * that the various PHYTIMING registers take the number
>> + * of cycles and use various dividers on them. This
>> + * calculation does not result in an exact match to the
>> + * downstream code, but it is very close, and it appears
>> + * to sync at a variety of resolutions. If someone
>> + * can get a more accurate mathematical equation needed
>> + * for these registers, this should be updated.
>> + */
> Marek Szyprowski -
>
> I was curious to know if you have any opinion on this TODO note and/or
> if you have any stuff you can share about how the values of the
> following variables are configured?
>> +
>> + lpx = PS_TO_CYCLE(cfg.lpx, byte_clock);
>> + hs_exit = PS_TO_CYCLE(cfg.hs_exit, byte_clock);
>> + clk_prepare = PS_TO_CYCLE(cfg.clk_prepare, byte_clock);
>> + clk_zero = PS_TO_CYCLE(cfg.clk_zero, byte_clock);
>> + clk_post = PS_TO_CYCLE(cfg.clk_post, byte_clock);
>> + clk_trail = PS_TO_CYCLE(cfg.clk_trail, byte_clock);
>> + hs_prepare = PS_TO_CYCLE(cfg.hs_prepare, byte_clock);
>> + hs_zero = PS_TO_CYCLE(cfg.hs_zero, byte_clock);
>> + hs_trail = PS_TO_CYCLE(cfg.hs_trail, byte_clock);
>> +
> These 'work' but they don't exactly match the NXP reference code, but
> they're not significantly different. The NXP reference manual doesn't
> describe how these registers are set, they only publish the register
> and bits used. Since you work for Samsung, I was hoping you might
> have inside information to know if this is a reasonable approach.
Unfortunately I won't be able to provide any info on that. You may check
the reference Samsung code for various Exynos based products, but I
suspect it will be similar to what was already in the Exynos DSI driver.
> ...
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
next prev parent reply other threads:[~2023-05-17 21:34 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230515235729eucas1p2c5a85ead90e0fc033e41dc81b67d6922@eucas1p2.samsung.com>
2023-05-15 23:57 ` [PATCH V6 0/6] drm: bridge: samsung-dsim: Support variable clocking Adam Ford
2023-05-15 23:57 ` [PATCH V6 1/6] drm: bridge: samsung-dsim: fix blanking packet size calculation Adam Ford
2023-05-18 11:51 ` Jagan Teki
2023-05-15 23:57 ` [PATCH V6 2/6] drm: bridge: samsung-dsim: Fix PMS Calculator on imx8m[mnp] Adam Ford
2023-05-18 11:52 ` Jagan Teki
2023-05-15 23:57 ` [PATCH V6 3/6] drm: bridge: samsung-dsim: Fetch pll-clock-frequency automatically Adam Ford
2023-05-17 12:56 ` Lucas Stach
2023-05-17 13:09 ` Adam Ford
2023-05-18 12:01 ` Jagan Teki
2023-05-15 23:57 ` [PATCH V6 4/6] drm: bridge: samsung-dsim: Select GENERIC_PHY_MIPI_DPHY Adam Ford
2023-05-17 11:04 ` Jagan Teki
2023-05-17 11:14 ` Adam Ford
2023-05-17 11:17 ` Jagan Teki
2023-05-17 12:58 ` Lucas Stach
2023-05-17 13:02 ` Adam Ford
2023-05-17 13:20 ` Lucas Stach
2023-05-15 23:57 ` [PATCH V6 5/6] drm: bridge: samsung-dsim: Dynamically configure DPHY timing Adam Ford
2023-05-17 2:55 ` Adam Ford
2023-05-17 21:34 ` Marek Szyprowski [this message]
2023-05-17 11:27 ` Jagan Teki
2023-05-17 12:01 ` Adam Ford
2023-05-17 13:06 ` Lucas Stach
2023-05-18 12:05 ` Jagan Teki
2023-05-15 23:57 ` [PATCH V6 6/6] drm: bridge: samsung-dsim: Support non-burst mode Adam Ford
2023-05-16 3:26 ` Chen-Yu Tsai
2023-05-16 13:02 ` Adam Ford
2023-05-17 13:01 ` Lucas Stach
2023-05-18 12:07 ` Jagan Teki
2023-05-16 22:57 ` [PATCH V6 0/6] drm: bridge: samsung-dsim: Support variable clocking Marek Szyprowski
2023-05-17 2:57 ` Adam Ford
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=45e4370f-fdee-9178-5c15-43205dc02bb9@samsung.com \
--to=m.szyprowski@samsung.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=aford173@gmail.com \
--cc=aford@beaconembedded.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=frieder.schrempf@kontron.de \
--cc=inki.dae@samsung.com \
--cc=jagan@amarulasolutions.com \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=l.stach@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=marex@denx.de \
--cc=michael@walle.cc \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=wenst@chromium.org \
/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
all inboxes | Powered by JetHome®