From: Manikandan Muralidharan <manikandan.m@microchip.com>
To: <maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>,
<tzimmermann@suse.de>, <airlied@gmail.com>, <simona@ffwll.ch>,
<nicolas.ferre@microchip.com>, <alexandre.belloni@bootlin.com>,
<claudiu.beznea@tuxon.dev>, <lee@kernel.org>,
<dri-devel@lists.freedesktop.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Cc: <manikandan.m@microchip.com>
Subject: [PATCH v3 3/4] drm: atmel-hlcdc: bypass clock divider for LVDS displays
Date: Mon, 23 Feb 2026 15:49:19 +0530 [thread overview]
Message-ID: <20260223101920.284697-4-manikandan.m@microchip.com> (raw)
In-Reply-To: <20260223101920.284697-1-manikandan.m@microchip.com>
For LVDS displays with pre-configured PLL clock, bypass the clock
divider calculation by setting ATMEL_XLCDC_CLKBYP flag.
For non-LVDS displays, retain existing clock divider calculation logic
to determine appropriate clock scaling based on display requirements.
Signed-off-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
changes in v3:
- Introduce ATMEL_XLCDC_CLKBYP to this series
---
.../gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 65 ++++++++++---------
include/linux/mfd/atmel-hlcdc.h | 1 +
2 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 26c9fbdfd871..73ac5ebbe121 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -127,39 +127,44 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
(adj->crtc_hdisplay - 1) |
((adj->crtc_vdisplay - 1) << 16));
- prate = clk_get_rate(crtc->dc->hlcdc->sys_clk);
- mode_rate = adj->crtc_clock * 1000;
- if (!crtc->dc->desc->fixed_clksrc) {
- prate *= 2;
- cfg |= ATMEL_HLCDC_CLKSEL;
- mask |= ATMEL_HLCDC_CLKSEL;
- }
+ if (crtc->dc->hlcdc->lvds_pll_clk) {
+ cfg |= ATMEL_XLCDC_CLKBYP;
+ mask |= ATMEL_XLCDC_CLKBYP;
+ } else {
+ prate = clk_get_rate(crtc->dc->hlcdc->sys_clk);
+ mode_rate = adj->crtc_clock * 1000;
+ if (!crtc->dc->desc->fixed_clksrc) {
+ prate *= 2;
+ cfg |= ATMEL_HLCDC_CLKSEL;
+ mask |= ATMEL_HLCDC_CLKSEL;
+ }
- div = DIV_ROUND_UP(prate, mode_rate);
- if (div < 2) {
- div = 2;
- } else if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK) {
- /* The divider ended up too big, try a lower base rate. */
- cfg &= ~ATMEL_HLCDC_CLKSEL;
- prate /= 2;
div = DIV_ROUND_UP(prate, mode_rate);
- if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK)
- div = ATMEL_HLCDC_CLKDIV_MASK;
- } else {
- int div_low = prate / mode_rate;
-
- if (div_low >= 2 &&
- (10 * (prate / div_low - mode_rate) <
- (mode_rate - prate / div)))
- /*
- * At least 10 times better when using a higher
- * frequency than requested, instead of a lower.
- * So, go with that.
- */
- div = div_low;
- }
+ if (div < 2) {
+ div = 2;
+ } else if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK) {
+ /* The divider ended up too big, try a lower base rate. */
+ cfg &= ~ATMEL_HLCDC_CLKSEL;
+ prate /= 2;
+ div = DIV_ROUND_UP(prate, mode_rate);
+ if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK)
+ div = ATMEL_HLCDC_CLKDIV_MASK;
+ } else {
+ int div_low = prate / mode_rate;
+
+ if (div_low >= 2 &&
+ (10 * (prate / div_low - mode_rate) <
+ (mode_rate - prate / div)))
+ /*
+ * At least 10 times better when using a higher
+ * frequency than requested, instead of a lower.
+ * So, go with that.
+ */
+ div = div_low;
+ }
- cfg |= ATMEL_HLCDC_CLKDIV(div);
+ cfg |= ATMEL_HLCDC_CLKDIV(div);
+ }
if (connector &&
connector->display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE)
diff --git a/include/linux/mfd/atmel-hlcdc.h b/include/linux/mfd/atmel-hlcdc.h
index 07c2081867fd..19504d3ea12c 100644
--- a/include/linux/mfd/atmel-hlcdc.h
+++ b/include/linux/mfd/atmel-hlcdc.h
@@ -44,6 +44,7 @@
#define ATMEL_XLCDC_HEO_UPDATE BIT(3)
#define ATMEL_HLCDC_CLKPOL BIT(0)
+#define ATMEL_XLCDC_CLKBYP BIT(1)
#define ATMEL_HLCDC_CLKSEL BIT(2)
#define ATMEL_HLCDC_CLKPWMSEL BIT(3)
#define ATMEL_HLCDC_CGDIS(i) BIT(8 + (i))
--
2.25.1
next prev parent reply other threads:[~2026-02-23 10:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 10:19 [PATCH v3 0/4] Add LVDS display support and PLL handling Manikandan Muralidharan
2026-02-23 10:19 ` [PATCH v3 1/4] mfd: atmel-hlcdc: fetch LVDS PLL clock for LVDS display Manikandan Muralidharan
2026-03-06 12:20 ` (subset) " Lee Jones
2026-02-23 10:19 ` [PATCH v3 2/4] drm: atmel-hlcdc: configure LVDS PLL clock rate for LVDS Displays Manikandan Muralidharan
2026-02-23 10:19 ` Manikandan Muralidharan [this message]
2026-02-23 10:19 ` [PATCH v3 4/4] drm: atmel-hlcdc: add support for LVDS output formats Manikandan Muralidharan
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=20260223101920.284697-4-manikandan.m@microchip.com \
--to=manikandan.m@microchip.com \
--cc=airlied@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=dri-devel@lists.freedesktop.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nicolas.ferre@microchip.com \
--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