@@ -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>
@@ -221,6 +222,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);
@@ -354,6 +363,9 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc,
u32 bus_format = 0;
dma_addr_t dma_addr;
+ if (mxsfb->enabled)
+ _mxsfb_disable_controller(mxsfb);
+
pm_runtime_get_sync(drm->dev);
mxsfb_enable_axi_clk(mxsfb);
You can't re-program the controller if it is still running. This may lead to shifted pictures, 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 | 14 +++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-)