@@ -10,6 +10,7 @@
#include <linux/clk.h>
#include <linux/dma-mapping.h>
+#include <linux/of.h>
#include <linux/io.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
@@ -222,6 +223,8 @@ static int mxsfb_load(struct drm_device *drm,
if (!mxsfb)
return -ENOMEM;
+ mxsfb->enabled =
+ of_property_read_bool(drm->dev->of_node, "fsl,boot-on");
mxsfb->drm = drm;
drm->dev_private = mxsfb;
mxsfb->devdata = devdata;
@@ -47,6 +47,7 @@ struct mxsfb_drm_private {
struct drm_bridge *bridge;
bool crc_active;
+ bool enabled;
};
static inline struct mxsfb_drm_private *
@@ -202,9 +202,11 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)
writel(reg, mxsfb->base + LCDC_CTRL1);
writel(CTRL_RUN, mxsfb->base + LCDC_CTRL + REG_SET);
+
+ mxsfb->enabled = true;
}
-static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb)
+static void _mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb)
{
u32 reg;
@@ -221,6 +223,13 @@ static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb)
reg &= ~VDCTRL4_SYNC_SIGNALS_ON;
writel(reg, mxsfb->base + LCDC_VDCTRL4);
+ mxsfb->enabled = false;
+}
+
+static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb)
+{
+ _mxsfb_disable_controller(mxsfb);
+
clk_disable_unprepare(mxsfb->clk);
if (mxsfb->clk_disp_axi)
clk_disable_unprepare(mxsfb->clk_disp_axi);
@@ -296,10 +305,14 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
bus_flags);
DRM_DEV_DEBUG_DRIVER(drm->dev, "Mode flags: 0x%08X\n", m->flags);
- /* Mandatory eLCDIF reset as per the Reference Manual */
- err = mxsfb_reset_block(mxsfb);
- if (err)
- return;
+ if (mxsfb->enabled) {
+ _mxsfb_disable_controller(mxsfb);
+ } else {
+ /* Mandatory eLCDIF reset as per the Reference Manual */
+ err = mxsfb_reset_block(mxsfb);
+ if (err)
+ return;
+ }
mxsfb_set_formats(mxsfb, bus_format);
@@ -418,6 +431,7 @@ static void mxsfb_crtc_atomic_disable(struct drm_crtc *crtc,
mxsfb_disable_axi_clk(mxsfb);
pm_runtime_put_sync(drm->dev);
+ mxsfb->enabled = false;
}
static int mxsfb_crtc_enable_vblank(struct drm_crtc *crtc)
You can't re-program the controller if it is still running. This may lead to shifted pictures (FIFO issue?), so stop the controller and drain its FIFOs in case it's already properly setup. This patch is crucial when supporting the simple framebuffer, as the controller has already been initialized by the bootloader. Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 3 +++ drivers/gpu/drm/mxsfb/mxsfb_drv.h | 1 + drivers/gpu/drm/mxsfb/mxsfb_kms.c | 24 +++++++++++++++++++----- 3 files changed, 23 insertions(+), 5 deletions(-)