From: Manikandan Muralidharan <manikandan.m@microchip.com>
To: <sam@ravnborg.org>, <bbrezillon@kernel.org>,
<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>,
Dharma Balasubiramani <dharma.b@microchip.com>
Subject: [PATCH 3/3] drm: atmel-hlcdc: set LVDS PLL clock rate for LVDS Displays
Date: Thu, 21 Nov 2024 14:53:08 +0530 [thread overview]
Message-ID: <20241121092308.130328-3-manikandan.m@microchip.com> (raw)
In-Reply-To: <20241121092308.130328-1-manikandan.m@microchip.com>
From: Dharma Balasubiramani <dharma.b@microchip.com>
The LVDS PLL clock is 7x the Panel Pixel clock.
When using LVDS displays, the LVDS PLL clock rate is set using the
panel pixel clock, this skips the usage of 'assigned-clock-rates'
DT property for lvds_pll_clk clock for LCD node.
Signed-off-by: Dharma Balasubiramani <dharma.b@microchip.com>
Signed-off-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
.../gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 48 ++++++++++++++++---
1 file changed, 42 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 0e709047369a..d11040d5cc5f 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -99,9 +99,15 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
drm_connector_list_iter_end(&iter);
}
- ret = clk_prepare_enable(crtc->dc->hlcdc->sys_clk);
- if (ret)
- return;
+ if (crtc->dc->hlcdc->lvds_pll_clk) {
+ ret = clk_prepare_enable(crtc->dc->hlcdc->lvds_pll_clk);
+ if (ret)
+ return;
+ } else {
+ ret = clk_prepare_enable(crtc->dc->hlcdc->sys_clk);
+ if (ret)
+ return;
+ }
vm.vfront_porch = adj->crtc_vsync_start - adj->crtc_vdisplay;
vm.vback_porch = adj->crtc_vtotal - adj->crtc_vsync_end;
@@ -186,7 +192,10 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
ATMEL_XLCDC_DPI : ATMEL_HLCDC_MODE_MASK),
cfg);
- clk_disable_unprepare(crtc->dc->hlcdc->sys_clk);
+ if (crtc->dc->hlcdc->lvds_pll_clk)
+ clk_disable_unprepare(crtc->dc->hlcdc->lvds_pll_clk);
+ else
+ clk_disable_unprepare(crtc->dc->hlcdc->sys_clk);
}
static enum drm_mode_status
@@ -242,7 +251,11 @@ static void atmel_hlcdc_crtc_atomic_disable(struct drm_crtc *c,
10, 1000))
dev_warn(dev->dev, "Atmel LCDC status register CLKSTS timeout\n");
- clk_disable_unprepare(crtc->dc->hlcdc->sys_clk);
+ if (crtc->dc->hlcdc->lvds_pll_clk)
+ clk_disable_unprepare(crtc->dc->hlcdc->lvds_pll_clk);
+ else
+ clk_disable_unprepare(crtc->dc->hlcdc->sys_clk);
+
pinctrl_pm_select_sleep_state(dev->dev);
pm_runtime_allow(dev->dev);
@@ -255,15 +268,38 @@ static void atmel_hlcdc_crtc_atomic_enable(struct drm_crtc *c,
{
struct drm_device *dev = c->dev;
struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
+ struct drm_display_mode *adj = &c->state->adjusted_mode;
struct regmap *regmap = crtc->dc->hlcdc->regmap;
unsigned int status;
+ int ret;
pm_runtime_get_sync(dev->dev);
pm_runtime_forbid(dev->dev);
pinctrl_pm_select_default_state(dev->dev);
- clk_prepare_enable(crtc->dc->hlcdc->sys_clk);
+
+ if (crtc->dc->hlcdc->lvds_pll_clk) {
+ /*
+ * When using LVDS displays, fetch the pixel clock from the panel
+ * and set the LVDS PLL clock rate.
+ * As per the datasheet, LVDS PLL clock is 7x the pixel clock.
+ */
+ ret = clk_set_rate(crtc->dc->hlcdc->lvds_pll_clk,
+ (adj->clock * 7 * 1000));
+ if (ret) {
+ dev_err(dev->dev, "Failed to set LVDS PLL clk rate: %d\n", ret);
+ return;
+ }
+
+ ret = clk_prepare_enable(crtc->dc->hlcdc->lvds_pll_clk);
+ if (ret)
+ return;
+ } else {
+ ret = clk_prepare_enable(crtc->dc->hlcdc->sys_clk);
+ if (ret)
+ return;
+ }
regmap_write(regmap, ATMEL_HLCDC_EN, ATMEL_HLCDC_PIXEL_CLK);
if (regmap_read_poll_timeout(regmap, ATMEL_HLCDC_SR, status,
--
2.25.1
next prev parent reply other threads:[~2024-11-21 9:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 9:23 [PATCH 1/3] drm: atmel-hlcdc: add support for LVDS encoder type Manikandan Muralidharan
2024-11-21 9:23 ` [PATCH 2/3] mfd: atmel-hlcdc: fetch LVDS PLL clock for LVDS display Manikandan Muralidharan
2025-02-10 17:25 ` Lee Jones
2025-02-10 17:25 ` Lee Jones
2024-11-21 9:23 ` Manikandan Muralidharan [this message]
2025-01-28 5:03 ` [PATCH 1/3] drm: atmel-hlcdc: add support for LVDS encoder type Manikandan.M
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=20241121092308.130328-3-manikandan.m@microchip.com \
--to=manikandan.m@microchip.com \
--cc=airlied@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=bbrezillon@kernel.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=dharma.b@microchip.com \
--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=sam@ravnborg.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.