devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
	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>,
	 Simona Vetter <simona@ffwll.ch>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	 Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	 Biju Das <biju.das.jz@bp.renesas.com>,
	Magnus Damm <magnus.damm@gmail.com>,
	 dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	 linux-clk@vger.kernel.org,
	 Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: Re: [PATCH v5 4/4] drm: renesas: rz-du: mipi_dsi: Add support for RZ/V2H(P) SoC
Date: Wed, 28 May 2025 10:48:20 +0100	[thread overview]
Message-ID: <CA+V-a8sde6Zaz3Z2uDt3OGZ52UBJfR3vQMs4-ZUusDu=oNwFhg@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdX5_P4R43HOPuZc3JSAOQ5O2xOBDVhVVg1SxU1ucPdbPA@mail.gmail.com>

Hi Geert,

Thank you for the review.

On Fri, May 23, 2025 at 4:19 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Prabhakar, Fabrizio,
>
> On Mon, 12 May 2025 at 20:43, Prabhakar <prabhakar.csengg@gmail.com> wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > Add DSI support for Renesas RZ/V2H(P) SoC.
> >
> > Co-developed-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
> > Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Thanks for your patch!
>
> > --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c
> > +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c
> > @@ -5,6 +5,7 @@
> >   * Copyright (C) 2022 Renesas Electronics Corporation
> >   */
> >  #include <linux/clk.h>
> > +#include <linux/clk/renesas-rzv2h-dsi.h>
> >  #include <linux/delay.h>
> >  #include <linux/io.h>
> >  #include <linux/iopoll.h>
> > @@ -30,6 +31,9 @@
> >
> >  #define RZ_MIPI_DSI_FEATURE_16BPP      BIT(0)
> >
> > +#define RZV2H_MIPI_DPHY_FOUT_MIN_IN_MEGA       (80 * MEGA)
> > +#define RZV2H_MIPI_DPHY_FOUT_MAX_IN_MEGA       (1500 * MEGA)
>
> RZV2H_MIPI_DPHY_FOUT_M{IN,AX}_IN_MHZ?
>
Ok, I'll rename them as above.

> > +
> >  struct rzg2l_mipi_dsi;
> >
> >  struct rzg2l_mipi_dsi_hw_info {
> > @@ -40,6 +44,7 @@ struct rzg2l_mipi_dsi_hw_info {
> >                               u64 *hsfreq_millihz);
> >         unsigned int (*dphy_mode_clk_check)(struct rzg2l_mipi_dsi *dsi,
> >                                             unsigned long mode_freq);
> > +       const struct rzv2h_pll_div_limits *cpg_dsi_limits;
> >         u32 phy_reg_offset;
> >         u32 link_reg_offset;
> >         unsigned long max_dclk;
> > @@ -47,6 +52,11 @@ struct rzg2l_mipi_dsi_hw_info {
> >         u8 features;
> >  };
> >
> > +struct rzv2h_dsi_mode_calc {
> > +       unsigned long mode_freq;
> > +       u64 mode_freq_hz;
>
> Interesting... I guess mode_freq is not in Hz?
>
Actually it is int Hz, I will make it unsigned long.

> > +};
> > +
> >  struct rzg2l_mipi_dsi {
> >         struct device *dev;
> >         void __iomem *mmio;
>
> > +static u16 rzv2h_dphy_find_ulpsexit(unsigned long freq)
> > +{
> > +       static const unsigned long hsfreq[] = {
> > +               1953125UL,
> > +               3906250UL,
> > +               7812500UL,
> > +               15625000UL,
> > +       };
> > +       static const u16 ulpsexit[] = {49, 98, 195, 391};
> > +       unsigned int i;
> > +
> > +       for (i = 0; i < ARRAY_SIZE(hsfreq); i++) {
> > +               if (freq <= hsfreq[i])
> > +                       break;
> > +       }
> > +
> > +       if (i == ARRAY_SIZE(hsfreq))
> > +               i -= 1;
>
> i--
>
OK.

> > +
> > +       return ulpsexit[i];
> > +}
> > +
> > +static u16 rzv2h_dphy_find_timings_val(unsigned long freq, u8 index)
> > +{
> > +       const struct rzv2h_mipi_dsi_timings *timings;
> > +       u16 i;
> > +
> > +       timings = &rzv2h_dsi_timings_tables[index];
> > +       for (i = 0; i < timings->len; i++) {
> > +               unsigned long hsfreq = timings->hsfreq[i] * 10000000UL;
>
> (I wanted to say "MEGA", but then I noticed the 7th zero ;-)
>
> 10 * MEGA?
>
Agreed, I will update it as above.

> > +
> > +               if (freq <= hsfreq)
> > +                       break;
> > +       }
> > +
> > +       if (i == timings->len)
> > +               i -= 1;
>
> i--
>
> > +
> > +       return timings->start_index + i;
> > +};
> > +
> >  static void rzg2l_mipi_dsi_phy_write(struct rzg2l_mipi_dsi *dsi, u32 reg, u32 data)
> >  {
> >         iowrite32(data, dsi->mmio + dsi->info->phy_reg_offset + reg);
> > @@ -308,6 +479,158 @@ static int rzg2l_dphy_conf_clks(struct rzg2l_mipi_dsi *dsi, unsigned long mode_f
> >         return 0;
> >  }
> >
> > +static unsigned int rzv2h_dphy_mode_clk_check(struct rzg2l_mipi_dsi *dsi,
> > +                                             unsigned long mode_freq)
> > +{
> > +       struct rzv2h_plldsi_parameters *dsi_parameters = &dsi->dsi_parameters;
> > +       u64 hsfreq_millihz, mode_freq_hz, mode_freq_millihz;
> > +       struct rzv2h_plldsi_parameters cpg_dsi_parameters;
> > +       unsigned int bpp, i;
> > +
> > +       bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
> > +
> > +       for (i = 0; i < 10; i += 1) {
> > +               unsigned long hsfreq;
> > +               bool parameters_found;
> > +
> > +               mode_freq_hz = mode_freq * MILLI + i;
>
> KILO?
>
OK, as mode_freq_hz is in Hz I'll make it unsigned long.

> And I guess you want to use mul_u32_u32(), as mode_freq_hz is u64?
>
and use mul_u32_u32() below...
> > +               mode_freq_millihz = mode_freq_hz * MILLI * 1ULL;
>
> Why * 1ULL?
>
Agreed, not needed, I will use mul_u32_u32() here.

> > +               parameters_found = rzv2h_dsi_get_pll_parameters_values(dsi->info->cpg_dsi_limits,
> > +                                                                      &cpg_dsi_parameters,
> > +                                                                      mode_freq_millihz);
> > +               if (!parameters_found)
> > +                       continue;
> > +
> > +               hsfreq_millihz = DIV_ROUND_CLOSEST_ULL(cpg_dsi_parameters.freq_millihz * bpp,
> > +                                                      dsi->lanes);
> > +               parameters_found = rzv2h_dsi_get_pll_parameters_values(&rzv2h_plldsi_div_limits,
> > +                                                                      dsi_parameters,
> > +                                                                      hsfreq_millihz);
> > +               if (!parameters_found)
> > +                       continue;
> > +
> > +               if (abs(dsi_parameters->error_millihz) >= 500)
> > +                       continue;
> > +
> > +               hsfreq = DIV_ROUND_CLOSEST_ULL(hsfreq_millihz, MILLI);
> > +               if (hsfreq >= RZV2H_MIPI_DPHY_FOUT_MIN_IN_MEGA &&
> > +                   hsfreq <= RZV2H_MIPI_DPHY_FOUT_MAX_IN_MEGA) {
> > +                       dsi->mode_calc.mode_freq_hz = mode_freq_hz;
> > +                       dsi->mode_calc.mode_freq = mode_freq;
> > +                       return MODE_OK;
> > +               }
> > +       }
> > +
> > +       return MODE_CLOCK_RANGE;
> > +}
>
> > --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi_regs.h
> > +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi_regs.h
> > @@ -40,6 +40,39 @@
> >  #define DSIDPHYTIM3_THS_TRAIL(x)       ((x) << 8)
> >  #define DSIDPHYTIM3_THS_ZERO(x)                ((x) << 0)
> >
> > +/* RZ/V2H DPHY Registers */
> > +#define PLLENR                         0x000
> > +#define PLLENR_PLLEN                   BIT(0)
> > +
> > +#define PHYRSTR                                0x004
> > +#define PHYRSTR_PHYMRSTN               BIT(0)
> > +
> > +#define PLLCLKSET0R                    0x010
> > +#define PLLCLKSET0R_PLL_S(x)           ((x) << 0)
>
>  #define PLLCLKSET0R_PLL_S GENMASK(2, 0)
>
> and after that you can use FIELD_PREP(PLLCLKSET0R_PLL_S, x) in the code.
> More opportunities for masks below...
>
Thanks, I will make use of GENMASK/FIELD_PREP macros.

Cheers,
Prabhakar

  reply	other threads:[~2025-05-28  9:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-12 18:42 [PATCH v5 0/4] Add support for DU/DSI clocks and DSI driver support for the Renesas RZ/V2H(P) SoC Prabhakar
2025-05-12 18:42 ` [PATCH v5 1/4] clk: renesas: rzv2h-cpg: Add support for DSI clocks Prabhakar
2025-05-20  6:19   ` Biju Das
2025-05-23 14:45   ` Geert Uytterhoeven
2025-05-27 21:50     ` Lad, Prabhakar
2025-05-28  7:09       ` Geert Uytterhoeven
2025-05-28 14:13         ` Lad, Prabhakar
2025-05-12 18:43 ` [PATCH v5 2/4] clk: renesas: r9a09g057: Add clock and reset entries for DSI and LCDC Prabhakar
2025-05-23 14:46   ` Geert Uytterhoeven
2025-05-27 22:01     ` Lad, Prabhakar
2025-05-12 18:43 ` [PATCH v5 3/4] dt-bindings: display: bridge: renesas,dsi: Add support for RZ/V2H(P) SoC Prabhakar
2025-05-23 14:58   ` Geert Uytterhoeven
2025-05-27 22:04     ` Lad, Prabhakar
2025-05-12 18:43 ` [PATCH v5 4/4] drm: renesas: rz-du: mipi_dsi: " Prabhakar
2025-05-23 15:18   ` Geert Uytterhoeven
2025-05-28  9:48     ` Lad, Prabhakar [this message]
2025-05-28 12:31       ` Geert Uytterhoeven
2025-05-28 17:43         ` Lad, Prabhakar

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='CA+V-a8sde6Zaz3Z2uDt3OGZ52UBJfR3vQMs4-ZUusDu=oNwFhg@mail.gmail.com' \
    --to=prabhakar.csengg@gmail.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fabrizio.castro.jz@renesas.com \
    --cc=geert@linux-m68k.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=krzk+dt@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=magnus.damm@gmail.com \
    --cc=mripard@kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=neil.armstrong@linaro.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=rfoss@kernel.org \
    --cc=robh@kernel.org \
    --cc=sboyd@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).