@@ -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,