All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gianfranco Mariotti" <gianfranco.mariotti94@gmail.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] drm/bridge: Add Rockchip RK628 HDMI to LVDS bridge driver
Date: Thu, 03 Dec 2026 01:47:28 +0000	[thread overview]
Message-ID: <sashiko-outbox-246905@kernel.org> (raw)
In-Reply-To: <20261203013324.30650-3-gianfranco.mariotti94@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/bridge: missing CPLL normal-mode switch in
  rk628_cru_set_cpll_rate()
- [High] drm/bridge: unhalved dual-link LVDS rate_khz in
  rk628_lvds_enable()
--

commit 34e8a3883e021abde91da05b1e8d453218e0f56a
Author: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>

drm/bridge: Add Rockchip RK628 HDMI to LVDS bridge driver

This commit adds an atomic DRM bridge driver for the Rockchip RK628D and
RK628F video interface bridges supporting the HDMI RX to single- or
dual-link LVDS TX pipeline.

> diff --git a/drivers/gpu/drm/bridge/rockchip-rk628.c b/drivers/gpu/drm/bridge/rockchip-rk628.c
> new file mode 100644
> index 0000000000000..b4b84788a133f
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/rockchip-rk628.c
[ ... ]
> +static void rk628_cru_init(struct rk628 *rk628)
> +{
> +	unsigned int val = 0;
> +	bool mcu_mode;
> +
> +	regmap_read(rk628->regmap, GRF_SYSTEM_STATUS0, &val);
> +	mcu_mode = !(val & I2C_ONLY_FLAG);
> +	if (mcu_mode || rk628->version >= RK628F_VERSION) {
> +		regmap_write(rk628->regmap, CRU_MODE_CON00,
> +			     RK628_HIWORD_UPDATE(1, 4, 4));
> +		return;
> +	}
[ ... ]
> +static unsigned long rk628_cru_get_pll_rate(struct rk628 *rk628, bool is_gpll)
> +{
[ ... ]
> +	regmap_read(rk628->regmap, CRU_MODE_CON00, &mode);
> +	if (!(mode & mode_mask))
> +		return parent_rate;
[ ... ]
> +static void rk628_cru_set_cpll_rate(struct rk628 *rk628, unsigned long rate)
> +{
[ ... ]
> +	regmap_write(rk628->regmap, CRU_CPLL_CON0,
> +		     PLL_BYPASS(0) | PLL_POSTDIV1(postdiv1) | PLL_FBDIV(fbdiv));
> +	regmap_write(rk628->regmap, CRU_CPLL_CON1,
> +		     PLL_DSMPD(dsmpd) | PLL_POSTDIV2(postdiv2) |
> +		     PLL_REFDIV(refdiv));
> +	regmap_write(rk628->regmap, CRU_CPLL_CON2, frac);
> +	regmap_write(rk628->regmap, CRU_CPLL_CON1, PLL_PD(0));
> +
> +	regmap_read_poll_timeout(rk628->regmap, CRU_CPLL_CON1, val,
> +				 val & PLL_LOCK, 200, 10000);
> +}

[Severity: High]
Does rk628_cru_set_cpll_rate() need to set CLK_CPLL_MODE_MASK (bit 0) in
CRU_MODE_CON00 to switch CPLL from slow mode to normal mode?

On RK628F, rk628_cru_init() returns early after setting bit 4 in
CRU_MODE_CON00 without setting CLK_CPLL_MODE_MASK.  When
rk628_hdmirx_enable() calls rk628_cru_set_cpll_rate(), CPLL locks but its
mode bit in CRU_MODE_CON00 remains 0, so CPLL stays in 24 MHz reference
clock bypass and rk628_cru_get_pll_rate() returns 24 MHz instead of the
configured CPLL rate when rk628_cru_set_frac_clk() programs the
CRU_CLKSEL_CON13 and CRU_CLKSEL_CON14 fractional dividers.

[ ... ]

> +static void rk628_lvds_enable(struct rk628 *rk628,
> +			      const struct drm_bridge_state *bridge_state)
> +{
> +	bool data_mirror = !!(bridge_state->output_bus_cfg.flags &
> +			      DRM_BUS_FLAG_DATA_LSB_TO_MSB);
> +	u32 rate_khz = rk628->dst_mode.clock * 7U;
> +	enum rk628_lvds_format lvds_fmt;
> +	u32 rate_div, mask, val, phy_mod;
> +	unsigned int status = 0;
> +	int ret;
[ ... ]
> +	if (rate_khz < 500000U)
> +		rate_div = 4;
> +	else if (rate_khz < 1000000U)
> +		rate_div = 2;
> +	else
> +		rate_div = 1;
> +
> +	regmap_write(rk628->regmap, COMBTXPHY_CON5,
> +		     SW_REF_DIV(0) | SW_PLL_FB_DIV(14) |
> +		     SW_PLL_FRAC_DIV(0) | SW_RATE(rate_div / 2));

[Severity: High]
Should rate_khz be halved in dual-link LVDS mode?

In dual-link LVDS mode, odd and even pixels are split across module A and
module B so each link runs at dst_mode.clock / 2.  Computing rate_khz from
the full dst_mode.clock doubles the per-link serial bit rate for modes at
or above 71429 kHz (such as 1920x1080p60 at 148.5 MHz), selecting half the
required rate_div in COMBTXPHY_CON5.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203013324.30650-1-gianfranco.mariotti94@gmail.com?part=2

  reply	other threads:[~2026-12-03  1:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  1:33 [PATCH 0/2] drm/bridge: Add Rockchip RK628 video interface bridge support Gianfranco Mariotti
2026-12-03  1:33 ` Gianfranco Mariotti
2026-12-03  1:33 ` [PATCH 1/2] dt-bindings: display: bridge: Add Rockchip RK628 video interface bridge Gianfranco Mariotti
2026-12-03  1:33   ` Gianfranco Mariotti
2026-12-03  1:33 ` [PATCH 2/2] drm/bridge: Add Rockchip RK628 HDMI to LVDS bridge driver Gianfranco Mariotti
2026-12-03  1:33   ` Gianfranco Mariotti
2026-12-03  1:47   ` sashiko-bot [this message]
2026-12-03  2:07     ` Gianfranco Mariotti

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=sashiko-outbox-246905@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gianfranco.mariotti94@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.