From 09d1fc5a6ddf77f8cc62f21e1461d52da1a14fa7 Mon Sep 17 00:00:00 2001
From: robert jakub <rj@project2.pl>
Date: Sun, 24 Nov 2024 15:20:49 +0100
Subject: [PATCH] linux 6.6.51 stable_20241008

---
 uconsole/kernel/default.nix                   |   7 +-
 .../patches/006-vc4_dsi-update-20241008.patch | 122 ------------------
 2 files changed, 3 insertions(+), 126 deletions(-)
 delete mode 100644 uconsole/kernel/patches/006-vc4_dsi-update-20241008.patch

diff --git a/uconsole/kernel/default.nix b/uconsole/kernel/default.nix
index c44e698..973f7df 100644
--- a/uconsole/kernel/default.nix
+++ b/uconsole/kernel/default.nix
@@ -5,8 +5,8 @@
     fetchFromGitHub,
   }: let
     # Version picked from the current (as of 8th Oct 2024) nixpkgs-unstable branch
-    modDirVersion = "6.6.31";
-    tag = "stable_20240529";
+    modDirVersion = "6.6.51";
+    tag = "stable_20241008";
   in
     linuxPackagesFor (linux_rpi4.override {
       argsOverride = {
@@ -17,7 +17,7 @@
           owner = "raspberrypi";
           repo = "linux";
           rev = tag;
-          hash = "sha256-UWUTeCpEN7dlFSQjog6S3HyEWCCnaqiUqV5KxCjYink=";
+          hash = "sha256-phCxkuO+jUGZkfzSrBq6yErQeO2Td+inIGHxctXbD5U=";
         };
       };
     });
@@ -27,7 +27,6 @@
     ./patches/003-axp20x-power.patch
     ./patches/004-vc4_dsi-update.patch
     ./patches/005-bcm2835-audio-staging.patch
-    ./patches/006-vc4_dsi-update-20241008.patch
     ./patches/007-drm-panel-cwu50-expose-dsi-error-status-to-userspace.patch
     ./patches/008-driver-staging-add-uconsole-simple-amplifier-switch.patch
   ];
diff --git a/uconsole/kernel/patches/006-vc4_dsi-update-20241008.patch b/uconsole/kernel/patches/006-vc4_dsi-update-20241008.patch
deleted file mode 100644
index 5cb1b74..0000000
--- a/uconsole/kernel/patches/006-vc4_dsi-update-20241008.patch
+++ /dev/null
@@ -1,122 +0,0 @@
---- a/drivers/gpu/drm/vc4/vc4_dsi.c
-+++ b/drivers/gpu/drm/vc4/vc4_dsi.c
-@@ -286,6 +286,8 @@
- 					 DSI1_INT_PR_TO)
- 
- #define DSI0_STAT		0x2c
-+# define DSI0_STAT_ERR_CONT_LP1		BIT(6)
-+# define DSI0_STAT_ERR_CONT_LP0		BIT(5)
- #define DSI0_HSTX_TO_CNT	0x30
- #define DSI0_LPRX_TO_CNT	0x34
- #define DSI0_TA_TO_CNT		0x38
-@@ -818,7 +820,14 @@
- 	disp0_ctrl = DSI_PORT_READ(DISP0_CTRL);
- 	disp0_ctrl &= ~DSI_DISP0_ENABLE;
- 	DSI_PORT_WRITE(DISP0_CTRL, disp0_ctrl);
-+}
- 
-+static void vc4_dsi_bridge_post_disable(struct drm_bridge *bridge,
-+					struct drm_bridge_state *state)
-+{
-+	struct vc4_dsi *dsi = bridge_to_vc4_dsi(bridge);
-+	struct device *dev = &dsi->pdev->dev;
-+
- 	/* Reset the DSI and all its fifos. */
- 	DSI_PORT_WRITE(CTRL, DSI_CTRL_SOFT_RESET_CFG |
- 		       DSI_PORT_BIT(CTRL_RESET_FIFOS));
-@@ -828,14 +837,6 @@
- 		       DSI_PORT_BIT(PHY_AFEC0_PD) |
- 		       DSI_PORT_BIT(AFEC0_PD_ALL_LANES));
- 
--}
--
--static void vc4_dsi_bridge_post_disable(struct drm_bridge *bridge,
--					struct drm_bridge_state *state)
--{
--	struct vc4_dsi *dsi = bridge_to_vc4_dsi(bridge);
--	struct device *dev = &dsi->pdev->dev;
--
- 	clk_disable_unprepare(dsi->pll_phy_clock);
- 	clk_disable_unprepare(dsi->escape_clock);
- 	clk_disable_unprepare(dsi->pixel_clock);
-@@ -1204,10 +1205,9 @@
- 				 &dsi->bridge, flags);
- }
- 
--static ssize_t vc4_dsi_host_transfer(struct mipi_dsi_host *host,
--				     const struct mipi_dsi_msg *msg)
-+static ssize_t vc4_dsi_transfer(struct vc4_dsi *dsi,
-+				const struct mipi_dsi_msg *msg, bool log_error)
- {
--	struct vc4_dsi *dsi = host_to_dsi(host);
- 	struct mipi_dsi_packet packet;
- 	u32 pkth = 0, pktc = 0;
- 	int i, ret;
-@@ -1316,10 +1316,12 @@
- 	DSI_PORT_WRITE(TXPKT1C, pktc);
- 
- 	if (!wait_for_completion_timeout(&dsi->xfer_completion,
--					 msecs_to_jiffies(1000))) {
--		dev_err(&dsi->pdev->dev, "transfer interrupt wait timeout");
--		dev_err(&dsi->pdev->dev, "instat: 0x%08x\n",
--			DSI_PORT_READ(INT_STAT));
-+					 msecs_to_jiffies(500))) {
-+		if (log_error) {
-+			dev_err(&dsi->pdev->dev, "transfer interrupt wait timeout");
-+			dev_err(&dsi->pdev->dev, "instat: 0x%08x, stat: 0x%08x\n",
-+				DSI_PORT_READ(INT_STAT), DSI_PORT_READ(INT_STAT));
-+		}
- 		ret = -ETIMEDOUT;
- 	} else {
- 		ret = dsi->xfer_result;
-@@ -1362,7 +1364,8 @@
- 	return ret;
- 
- reset_fifo_and_return:
--	DRM_ERROR("DSI transfer failed, resetting: %d\n", ret);
-+	if (log_error)
-+		DRM_ERROR("DSI transfer failed, resetting: %d\n", ret);
- 
- 	DSI_PORT_WRITE(TXPKT1C, DSI_PORT_READ(TXPKT1C) & ~DSI_TXPKT1C_CMD_EN);
- 	udelay(1);
-@@ -1375,6 +1378,40 @@
- 	return ret;
- }
- 
-+static ssize_t vc4_dsi_host_transfer(struct mipi_dsi_host *host,
-+				     const struct mipi_dsi_msg *msg)
-+{
-+	struct vc4_dsi *dsi = host_to_dsi(host);
-+	u32 stat, disp0_ctrl;
-+	int ret;
-+
-+	ret = vc4_dsi_transfer(dsi, msg, false);
-+
-+	if (ret == -ETIMEDOUT) {
-+		stat = DSI_PORT_READ(STAT);
-+		disp0_ctrl = DSI_PORT_READ(DISP0_CTRL);
-+
-+		DSI_PORT_WRITE(STAT, DSI_PORT_BIT(STAT_ERR_CONT_LP1));
-+		if (!(disp0_ctrl & DSI_DISP0_ENABLE)) {
-+			/* If video mode not enabled, then try recovering by
-+			 * enabling it briefly to clear FIFOs and the state.
-+			 */
-+			disp0_ctrl |= DSI_DISP0_ENABLE;
-+			DSI_PORT_WRITE(DISP0_CTRL, disp0_ctrl);
-+			msleep(30);
-+			disp0_ctrl &= ~DSI_DISP0_ENABLE;
-+			DSI_PORT_WRITE(DISP0_CTRL, disp0_ctrl);
-+			msleep(30);
-+
-+			ret = vc4_dsi_transfer(dsi, msg, true);
-+		} else {
-+			DRM_ERROR("DSI transfer failed whilst in HS mode stat: 0x%08x\n",
-+				  stat);
-+		}
-+	}
-+	return ret;
-+}
-+
- static const struct component_ops vc4_dsi_ops;
- static int vc4_dsi_host_attach(struct mipi_dsi_host *host,
- 			       struct mipi_dsi_device *device)