From e20721c41893e20c51d9520d2a1ab6bc7846a4a2 Mon Sep 17 00:00:00 2001
From: cinap_lenrek <cinap_lenrek@felloff.net>
Date: Wed, 11 Jan 2023 18:18:20 -0500
Subject: [PATCH] work around shifted screen image in linux

Linux kernel mode setting seems to fail to
properly reset the mipi core, causing the
screen to be shifted to the right.

As a work around, we reset the lcdif and
mipi core in a board_quiesce_devices()
function.
---
 board/boundary/nitrogen8m_som/lcdif.c          | 12 ++++++++++++
 board/boundary/nitrogen8m_som/nitrogen8m_som.c | 17 +++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/board/boundary/nitrogen8m_som/lcdif.c b/board/boundary/nitrogen8m_som/lcdif.c
index 71c1657f95f..77f13ca3cfe 100644
--- a/board/boundary/nitrogen8m_som/lcdif.c
+++ b/board/boundary/nitrogen8m_som/lcdif.c
@@ -984,3 +984,15 @@ out:
 	printf("lcdif: video_hw_init(): %s\n", err);
 	return NULL;
 }
+
+void
+video_hw_exit(void)
+{
+	lcdifreset();
+
+	mr(resetc, SRC_MIPIPHY_RCR, 0, RCR_MIPI_DSI_RESET_N);
+	mr(resetc, SRC_MIPIPHY_RCR, 0, RCR_MIPI_DSI_PCLK_RESET_N);
+	mr(resetc, SRC_MIPIPHY_RCR, 0, RCR_MIPI_DSI_ESC_RESET_N);
+	mr(resetc, SRC_MIPIPHY_RCR, 0, RCR_MIPI_DSI_RESET_BYTE_N);
+	mr(resetc, SRC_MIPIPHY_RCR, 0, RCR_MIPI_DSI_DPI_RESET_N);
+}
diff --git a/board/boundary/nitrogen8m_som/nitrogen8m_som.c b/board/boundary/nitrogen8m_som/nitrogen8m_som.c
index ae0fbe906f3..c2373707f40 100644
--- a/board/boundary/nitrogen8m_som/nitrogen8m_som.c
+++ b/board/boundary/nitrogen8m_som/nitrogen8m_som.c
@@ -391,3 +391,20 @@ int board_late_init(void)
 
 	return 0;
 }
+
+void
+board_quiesce_devices(void)
+{
+	extern void video_hw_exit(void);	/* lcdif.c */
+
+	/*
+	 * Linux kermel mode setting seems to fail to
+	 * properly reset the mipi core, causing the
+	 * screen to be shifted to the right.
+	 *
+	 * As a work around, we reset the lcdif and
+	 * mipi core for it.
+	 */
+	if (images.os.os == IH_OS_LINUX)
+		video_hw_exit();
+}
-- 
GitLab