[Bugfix][API-890]fix medmcu sleep fail

Change-Id: Ief0d693e7f95dc1086449bd366b2baf7b9685d2c
(cherry picked from commit 53e9ffcc7714b8993900d6784ab17f812ec11903)
(cherry picked from commit 30612a5d06b9bfaa554b5efa3a9544268bf888e6)
diff --git a/prebuilt/firmware/medmcu/mt2735/medmcu.img b/prebuilt/firmware/medmcu/mt2735/medmcu.img
index 899260b..4a92117 100644
--- a/prebuilt/firmware/medmcu/mt2735/medmcu.img
+++ b/prebuilt/firmware/medmcu/mt2735/medmcu.img
Binary files differ
diff --git a/src/kernel/linux/v4.19/drivers/misc/mediatek/eccci/fsm/ccci_fsm.c b/src/kernel/linux/v4.19/drivers/misc/mediatek/eccci/fsm/ccci_fsm.c
index 22cc580..26b9810 100644
--- a/src/kernel/linux/v4.19/drivers/misc/mediatek/eccci/fsm/ccci_fsm.c
+++ b/src/kernel/linux/v4.19/drivers/misc/mediatek/eccci/fsm/ccci_fsm.c
@@ -40,7 +40,13 @@
 
 static int needforcestop;
 static bool sForceWakeup;
-
+/*jb.qi change for medmcu sleep fail on 20230418 start*/
+int ccci_fsm_get_md_force_stop_state(void)
+{
+       return needforcestop;
+}
+EXPORT_SYMBOL_GPL(ccci_fsm_get_md_force_stop_state);
+/*jb.qi change for medmcu sleep fail on 20230418 end*/
 int force_md_stop(struct ccci_fsm_monitor *monitor_ctl)
 {
 	int ret = -1;
@@ -452,6 +458,7 @@
 	ctl->curr_state = CCCI_FSM_GATED;
 	fsm_broadcast_state(ctl, GATED);
 	fsm_finish_command(ctl, cmd, 1);
+	needforcestop = 0;//jb.qi change for medmcu sleep fail on 20230418
 }
 
 static void fsm_routine_wdt(struct ccci_fsm_ctl *ctl,
diff --git a/src/kernel/linux/v4.19/drivers/misc/mediatek/eccci/inc/ccci_fsm.h b/src/kernel/linux/v4.19/drivers/misc/mediatek/eccci/inc/ccci_fsm.h
index 600a2f3..59656ed 100644
--- a/src/kernel/linux/v4.19/drivers/misc/mediatek/eccci/inc/ccci_fsm.h
+++ b/src/kernel/linux/v4.19/drivers/misc/mediatek/eccci/inc/ccci_fsm.h
@@ -21,5 +21,6 @@
 
 extern void mdee_set_ex_time_str(unsigned char md_id, unsigned int type,
 	char *str);
+int ccci_fsm_get_md_force_stop_state(void); //jb.qi change for medmcu sleep fail on 20230418
 #endif /* __CCCI_FSM_H__ */
 
diff --git a/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/Makefile b/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/Makefile
index 34b58b4..e20c3c2 100644
--- a/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/Makefile
+++ b/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/Makefile
@@ -28,6 +28,9 @@
 # include mtk_spm_resource_req
 ccflags-y += -I$(srctree)/drivers/misc/mediatek/base/power/include/
 
+# include ccci_fsm.h jb.qi change for medmcu sleep fail on 202304018
+ccflags-y += -I$(srctree)/drivers/misc/mediatek/eccci/inc
+
 #ifeq ($(CONFIG_MTK_ENG_BUILD),y)
 CFLAGS_scp_excep.o       += -DDEBUG
 CFLAGS_scp_helper.o      += -DDEBUG
diff --git a/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/medmcu_helper.h b/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/medmcu_helper.h
index 16b0083..2fda41b 100644
--- a/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/medmcu_helper.h
+++ b/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/medmcu_helper.h
@@ -88,7 +88,8 @@
 	RESET_TYPE_CMD = 2,
 	RESET_TYPE_TIMEOUT = 3,
 	RESET_TYPE_MD_EXCEP = 4,
-	RESET_TYPE_RESUME = 5,
+	RESET_TYPE_MD_FORCE_STOP = 5, //jb.qi change for medmcu sleep fail on 20230418
+	RESET_TYPE_RESUME = 6, //jb.qi change for medmcu sleep fail on 20230418
 };
 
 struct scp_regs {
diff --git a/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/v02/medmcu_helper.c b/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/v02/medmcu_helper.c
index a9986e0..b7d4349 100644
--- a/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/v02/medmcu_helper.c
+++ b/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/v02/medmcu_helper.c
@@ -30,6 +30,7 @@
 #include <mt-plat/sync_write.h>
 //#include <mt-plat/aee.h>
 #include <linux/delay.h>
+#include <linux/pm_wakeup.h> //jb.qi change for medmcu sleep fail on 20230418
 #include <linux/syscore_ops.h>
 #include "medmcu_helper.h"
 #include "medmcu_ipi_pin.h"
@@ -38,14 +39,15 @@
 #include "medmcu_excep.h"
 #include "medmcu_scpctl.h"
 #include "medmcu_dvfs.h"
-
+#include "ccci_fsm.h" //jb.qi change for medmcu sleep fail on 20230418
 void __iomem *medhw_base;
 EXPORT_SYMBOL_GPL(medhw_base);
 
 #define MEDHW_BASE           medhw_base
 #define MEDHW_INT_MNG_BASE          (MEDHW_BASE + 0x3000)
+#define MEDHW_INT_EXCEP_W1C         (MEDHW_INT_MNG_BASE + 0x00) //jb.qi change for medmcu sleep fail on 20230418
 #define MEDHW_INT_EXCEP_SET         (MEDHW_INT_MNG_BASE + 0x08)
-
+#define MEDHW_INT_NOTIF_W1C         (MEDHW_INT_MNG_BASE + 0x20) //jb.qi change for medmcu sleep fail on 20230418
 void __iomem *fe_base;
 #define FE_BASE           fe_base
 
@@ -228,7 +230,7 @@
 static unsigned int scp_timeout_times;
 #endif
 static struct scp_work_struct scp_A_notify_work;
-
+static unsigned int g_ignore_stop_ipi_flag = 0; //jb.qi change for medmcu sleep fail on 20230418
 //represent the suspend response from medmcu, 0: no response, 1: idle, -1: can't suspend
 atomic_t medmcu_suspend_response;
 //represent the medmcu is ready for suspend query or not
@@ -245,8 +247,11 @@
 
 char *core_ids[SCP_CORE_TOTAL] = {"SCP A"};
 DEFINE_SPINLOCK(scp_awake_spinlock);
+DEFINE_SPINLOCK(medmcu_resume_spinlock);//jb.qi change for medmcu sleep fail on 20230418
 /* set flag after driver initial done */
 static bool driver_init_done;
+static struct wakeup_source *medmcu_dl_wakelock;//jb.qi change for medmcu sleep fail on 20230418
+
 struct scp_ipi_irq {
 	const char *name;
 	int order;
@@ -276,6 +281,17 @@
 	}
 	return 0;
 }
+/*jb.qi change for medmcu sleep fail on 20230418 start*/
+static void medmcu_set_ignore_stop_ipi_flag(unsigned int flag)
+{
+	g_ignore_stop_ipi_flag = flag;
+}
+
+static bool medmcu_ignore_stop_ipi(void)
+{
+	return (g_ignore_stop_ipi_flag == 1);
+}
+/*jb.qi change for medmcu sleep fail on 20230418 end*/
 
 void fdma_init(struct net_device *dev)
 {
@@ -422,7 +438,7 @@
 	//Enable DMA check WDONE bit by 0x15104204[28]=1
 	//Disable 2-byte offset by 0x15104204[31]=0
 	//Disable TX_DMA writing back DDONE into TXD: 0x15104204[6]=0
-	reg_write(MDMA_GLO_CFG, 0x10404825);
+	reg_write(MDMA_GLO_CFG, 0x10804825); //jb.qi change for medmcu sleep fail on 20230418
 }
 
 int mdma_init(struct net_device *dev, struct MDMA_END_DEVICE *ei_local)
@@ -756,9 +772,14 @@
 			if (!is_scp_ready(SCP_A_ID)) {
 				pr_notice("[MEDMCU] %s(): scp_extern_notify SCP_EVENT_STOP_ACK\n", __func__);
 				scp_extern_notify(SCP_EVENT_STOP_ACK);
-			} else {
+			/*jb.qi change for medmcu sleep fail on 20230417 start*/
+			} else if (medmcu_ignore_stop_ipi()) {
+				medmcu_set_ignore_stop_ipi_flag(0);
+				pr_notice("[MEDMCU] %s(): scp_extern_notify SCP_EVENT_STOP_ACK\n", __func__);
+				scp_extern_notify(SCP_EVENT_STOP_ACK);
+			} else
 				handle_dpmaif_stop();
-			}
+			/*jb.qi change for medmcu sleep fail on 20230417 start*/
 			break;
 		case CCCI_DPMAIF_EVENT_READY:
 			if (!is_scp_ready(SCP_A_ID)) {
@@ -852,9 +873,10 @@
  */
 static void scp_A_notify_ws(struct work_struct *ws)
 {
+	unsigned long spin_flags;
 	struct scp_work_struct *sws =
 		container_of(ws, struct scp_work_struct, work);
-	unsigned int scp_notify_flag = sws->flags;
+	unsigned int scp_notify_flag = sws->flags; //jb.qi change for medmcu sleep fail on20230417
 
 
 	if (scp_notify_flag) {
@@ -875,11 +897,13 @@
 			, SCP_EVENT_READY, NULL);
 		mutex_unlock(&scp_A_notify_mutex);
 		//for resume medmcu, need dpamif ready event.
+		spin_lock_irqsave(&medmcu_resume_spinlock, spin_flags); //jb.qi change for medmcu sleep fail on20230417
 		if (atomic_read(&medmcu_resume_need_dpmaif_ready) == 1) {
 			//ask ccci to send dpmaif ready, since dpmaif hw/sw is still alive after resume
 			ccci_dpmaif_resend_ready();
 			atomic_set(&medmcu_resume_need_dpmaif_ready, 0);
 		}
+		spin_unlock_irqrestore(&medmcu_resume_spinlock, spin_flags); //jb.qi change for medmcu sleep fail on20230417
 	}
 
 	/* register scp dvfs*/
@@ -1078,10 +1102,20 @@
 static int med_stop_ack_ipi_handler(unsigned int id, void *prdata, void *data,
 				    unsigned int len)
 {
+	int md_force_stop;//jb.qi change for medmcu sleep fail on 20230418
 	scp_reset_counts = 9999;
-	scp_reset_by_md_excep = 1;
-	scp_send_reset_wq(RESET_TYPE_MD_EXCEP);
+	/*jb.qi change for medmcu sleep fail on 20230418 start*/
+	md_force_stop = ccci_fsm_get_md_force_stop_state();
 
+	if (md_force_stop == 1) {
+		   pr_notice("[MEDMCU] %s(): scp_extern_notify SCP_EVENT_STOP_ACK, md force stop state = %d\n",
+									 __func__, md_force_stop);
+		   scp_send_reset_wq(RESET_TYPE_MD_FORCE_STOP);
+	} else {
+		   scp_reset_by_md_excep = 1;
+		   scp_send_reset_wq(RESET_TYPE_MD_EXCEP);
+	}
+	/*jb.qi change for medmcu sleep fail on 20230418 end*/
 	return 0;
 }
 
@@ -2177,6 +2211,17 @@
 
 /******************************************************************************
  *****************************************************************************/
+/*jb.qi change for medmcu sleep fail on 20230418 start */
+void print_med_registers(void)
+{
+	uint32_t medhw_int_exp_w1c, medhw_int_notif_w1c;
+
+	medhw_int_exp_w1c = reg_read(MEDHW_INT_EXCEP_W1C);
+	medhw_int_notif_w1c = reg_read(MEDHW_INT_NOTIF_W1C);
+	pr_notice("MEDHW_INT_EXCEP_W1C = 0x%08x\n", medhw_int_exp_w1c);
+	pr_notice("MEDHW_INT_NOTIFY_W1C = 0x%08x\n", medhw_int_notif_w1c);
+}
+/*jb.qi change for medmcu sleep fail on 20230418 end */
 void print_clk_registers(void)
 {
 	void __iomem *cfg = scpreg.cfg;
@@ -2214,14 +2259,12 @@
 void scp_reset_wait_timeout(void)
 {
 	uint32_t core0_halt = 0;
-	uint32_t core1_halt = 0;
 	/* make sure scp is in idle state */
 	int timeout = 50; /* max wait 1s */
 
 	while (timeout--) {
 		core0_halt = readl(R_CORE0_STATUS) & B_CORE_HALT;
-		core1_halt = readl(R_CORE1_STATUS) & B_CORE_HALT;
-		if (core0_halt && core1_halt) {
+		if (core0_halt) { //jb.qi change for medmcu sleep fail on 20230418
 			/* SCP stops any activities
 			 * and parks at wfi
 			 */
@@ -2264,8 +2307,14 @@
 #endif
 		}
 	} else {
-		/* reset type scp WDT or CMD or MD_EXCEP*/
-		/* make sure scp is in idle state */
+		/*
+		 * reset type scp WDT, CMD or MD_EXCEP
+		 * make sure scp is in idle state
+		 */
+		/*jb.qi change for medmcu sleep fail on 20230418 start*/
+		if (scp_reset_type == RESET_TYPE_WDT)
+			medmcu_set_ignore_stop_ipi_flag(1);
+		/*jb.qi change for medmcu sleep fail on 20230418 end*/
 		scp_reset_wait_timeout();
 		writel(1, R_CORE0_SW_RSTN_SET);
 		writel(1, R_CORE1_SW_RSTN_SET);
@@ -2285,8 +2334,13 @@
 
 	/* start scp */
 	pr_notice("[MEDMCU] start scp\n");
+	/*jb.qi change for medmcu sleep fail on 20230418 start*/
+	if (scp_reset_type == RESET_TYPE_RESUME) {
+		pr_notice("[MEDMCU] get spinlock for atomic medmcu resume rstn sequence\n");
+		spin_lock_irqsave(&medmcu_resume_spinlock, spin_flags);
+	}
+	/*jb.qi change for medmcu sleep fail on 20230418 end*/
 	writel(1, R_CORE0_SW_RSTN_CLR);
-	pr_notice("[MEDMCU] rstn core0 %x\n", readl(R_CORE0_SW_RSTN_CLR));
 	dsb(SY); /* may take lot of time */
 
 	atomic_set(&medmcu_resume_need_dpmaif_ready, 0);
@@ -2301,10 +2355,14 @@
 		scp_extern_notify(SCP_EVENT_STOP_BY_WDT);
 	} else if (scp_reset_type == RESET_TYPE_RESUME) {
 		//wait scp ready and ask for dpmaif_ready_event
-		pr_notice("[MEDMCU] %s(): scp_extern_notify RESET_TYPE_RESUME222\n", __func__);
 		atomic_set(&medmcu_resume_need_dpmaif_ready, 1);
-	}
+		/*jb.qi change for medmcu sleep fail on 20230418 start*/
+		spin_unlock_irqrestore(&medmcu_resume_spinlock, spin_flags);
+		pr_notice("[MEDMCU] %s(): need dpmaif ready flag set in RESET_TYPE_RESUME\n", __func__);
+		/*jb.qi change for medmcu sleep fail on 20230418 end*/
 
+	}
+	pr_notice("[MEDMCU] rstn core0 %x\n", readl(R_CORE0_SW_RSTN_CLR)); //jb.qi change for medmcu sleep fail on 20230418
 #if SCP_BOOT_TIME_OUT_MONITOR
 	mod_timer(&scp_ready_timer[SCP_A_ID], jiffies + SCP_READY_TIMEOUT);
 #endif
@@ -2341,6 +2399,12 @@
 	unsigned int scp_reset_type = sws->flags;
 
 	pr_notice("[MEDMCU] %s(): remain %d times\n", __func__, scp_reset_counts);
+	/*jb.qi change for medmcu sleep fail on 20230418 start */
+	if (scp_reset_type == RESET_TYPE_MD_FORCE_STOP) {
+		scp_extern_notify(SCP_EVENT_STOP_ACK);
+		return;
+	}
+	/*jb.qi change for medmcu sleep fail on 20230418 end*/
 	/*notify scp functions stop*/
 	pr_debug("[MEDMCU] %s(): scp_extern_notify SCP_EVENT_STOP\n", __func__);
 	scp_extern_notify(SCP_EVENT_STOP);
@@ -2497,7 +2561,13 @@
 	struct net_device *netdev;
 
 	struct MDMA_END_DEVICE *ei_local = &mdma_device;
-
+	/*jb.qi change for medmcu sleep fail on20230418 start*/
+	medmcu_dl_wakelock = wakeup_source_register(NULL, "medmcu_dl_wakelock");
+	if (!medmcu_dl_wakelock) {
+		pr_err("%s %d: init dl wakeup source fail!", __func__, __LINE__);
+		return -1;
+	}
+	/*jb.qi change for medmcu sleep fail on20230418 end*/
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	scpreg.sram = devm_ioremap_resource(dev, res);
 	if (IS_ERR((void const *) scpreg.sram)) {
@@ -2678,6 +2748,7 @@
 int medmcu_pm_suspend(struct device *device)
 {
 	if (sync_medmcu_can_suspend() == -1) {
+		__pm_wakeup_event(medmcu_dl_wakelock, jiffies_to_msecs(HZ)); //jb.qi change for medmcu sleep fail on 20230418
 		return -1;
 	}
 	writel(V_DISABLE_WDT, R_CORE0_WDT_CFG);
diff --git a/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/v02/medmcu_logger.c b/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/v02/medmcu_logger.c
index 1e45b9c..f3efc22 100644
--- a/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/v02/medmcu_logger.c
+++ b/src/kernel/linux/v4.19/drivers/misc/mediatek/medmcu/rv33/v02/medmcu_logger.c
@@ -800,7 +800,7 @@
 	u32 i;
 	u32 *p;
 	char buf[100];
-
+	pr_notice("Dump TX_DESC...\n"); //jb.qi change for medmcu sleep fail on 20230418
 	p = (u32 *)medmcu_tx_desc_base_virt;
 	if (seq != NULL) {
 		seq_puts(seq, "        <<TX_DESC DUMP>>\n");
@@ -824,7 +824,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump RX_DESC...\n");//jb.qi change for medmcu sleep fail on 20230418
 	p = (u32 *)medmcu_rx_desc_base_virt;
 	if (seq != NULL) {
 		seq_puts(seq, "        <<RX_DESC DUMP>>\n");
@@ -848,7 +848,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump HNAT_INFO...\n");//jb.qi change for medmcu sleep fail on 20230418
 	p = (u32 *)medmcu_hnat_info_base_virt;
 	if (seq != NULL) {
 		seq_puts(seq, "        <<HNAT_INFO DUMP>>\n");
@@ -872,7 +872,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump HNAT_INFO_HOST...\n");//jb.qi change for medmcu sleep fail on 20230418
 	p = (u32 *)medmcu_hnat_info_host_base_virt;
 	if (seq != NULL) {
 		seq_puts(seq, "        <<HNAT_INFO_HOST DUMP>>\n");
@@ -896,7 +896,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump PIT_NAT...\n");//jb.qi change for medmcu sleep fail on 20230418
 	p = (u32 *)medmcu_pit_nat_base_virt;
 	if (seq != NULL) {
 		seq_puts(seq, "        <<PIT_NAT DUMP>>\n");
@@ -920,7 +920,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump PIT...\n");//jb.qi change for medmcu sleep fail on 20230418
 	p = (u32 *)medmcu_pit_base_virt;
 	if (seq != NULL) {
 		seq_puts(seq, "        <<PIT DUMP>>\n");
@@ -944,7 +944,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump DRB0...\n");//jb.qi change for medmcu sleep fail on 20230418
 	p = (u32 *)medmcu_drb0_base_virt;
 	if (seq != NULL) {
 		seq_puts(seq, "        <<DRB0 DUMP>>\n");
@@ -968,7 +968,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump DRB1...\n");//jb.qi change for medmcu sleep fail on 20230418
 	p = (u32 *)medmcu_drb1_base_virt;
 	if (seq != NULL) {
 		seq_puts(seq, "        <<DRB1 DUMP>>\n");
@@ -992,6 +992,9 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
+	medhw_dram_logged = 1;//jb.qi change for medmcu sleep fail on 20230418
+	pr_notice("[MEDHW] read dram end\n");//jb.qi change for medmcu sleep fail on 20230418
+
 	return 0;
 }
 
@@ -1027,7 +1030,8 @@
 
 	unsigned char *medhw_bat_sw_map_buf = (unsigned char *)(SCP_TCM + bat_addr);
 	unsigned char *medhw_fbat_sw_map_buf = (unsigned char *)(SCP_TCM + fbat_addr);
-
+	
+	pr_notice("Dump MEDHW_INT_MNG...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, "       <<MEDHW_INT_MNG CR DUMP>>\n");
 	} else {
@@ -1050,7 +1054,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump MEDHW_BMP...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<MEDHW_BMP CR DUMP>>\n");
 	} else {
@@ -1073,7 +1077,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump MEDHW_SSR0...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<MEDHW_SSR0 CR DUMP>>\n");
 	} else {
@@ -1096,7 +1100,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump MEDHW_SSR1...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<MEDHW_SSR1 CR DUMP>>\n");
 	} else {
@@ -1119,7 +1123,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump MEDHW_SSR2...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<MEDHW_SSR2 CR DUMP>>\n");
 	} else {
@@ -1142,7 +1146,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump DPMAIF_INT...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<DPMAIF_INT CR DUMP>>\n");
 	} else {
@@ -1165,7 +1169,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump DPMAIF_DL...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<DPMAIF_DL CR DUMP>>\n");
 	} else {
@@ -1188,7 +1192,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump DPMAIF_UL...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<DPMAIF_UL CR DUMP>>\n");
 	} else {
@@ -1212,7 +1216,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump MDMA_TX_DESC...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<MDMA_TX_DESC CR DUMP>>\n");
 	} else {
@@ -1235,7 +1239,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump MDMA_RX_DESC...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<MDMA_RX_DESC CR DUMP>>\n");
 	} else {
@@ -1258,7 +1262,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump MDMA_TXRX_DESC_INFO...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<MDMA_TXRX_DESC_INFO CR DUMP>>\n");
 	} else {
@@ -1281,7 +1285,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump FDMA_HNAT_INFO...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<FDMA_HNAT_INFO CR DUMP>>\n");
 	} else {
@@ -1304,7 +1308,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump FDMA_HNAT_INFO_INFO...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<FDMA_HNAT_INFO_INFO CR DUMP>>\n");
 	} else {
@@ -1327,7 +1331,7 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-
+	pr_notice("Dump BAT_SW_MAP...\n");//jb.qi change for medmcu sleep fail on 20230418
 	if (!sw_map_flush(false)) {
 		seq_puts(seq, "BAT_SW_MAP flush error\n");
 		return 0;
@@ -1353,7 +1357,7 @@
 			pr_notice("[MEDHW] %s", buf);
 		}
 	}
-
+	pr_notice("Dump FBAT_SW_MAP...\n");//jb.qi change for medmcu sleep fail on 20230418
 	p = (u32 *)medhw_fbat_sw_map_buf;
 	if (seq != NULL) {
 		seq_puts(seq, " 	  <<FBAT_SW_MAP DUMP>>\n");
@@ -1378,50 +1382,22 @@
 		pr_notice("+-----------------------------------------------+\n");
 	}
 
-	return 0;
-}
+	medhw_cr_dump_logged = 1;//jb.qi change for medmcu sleep fail on 20230418
+	pr_notice("[MEDHW] read cr_dump end\n");//jb.qi change for medmcu sleep fail on 20230418
 
-static void *dram_seq_start(struct seq_file *seq, loff_t *pos)
-{
-	if (*pos) {
-		medhw_dram_logged = 1;
-		mutex_unlock(&medhw_dram_mutex);
-		pr_notice("[MEDHW] read dram end\n");
-		return NULL;
-	}
-	return SEQ_START_TOKEN;
-}
-
-static void *dram_seq_next(struct seq_file *seq, void *v, loff_t *pos)
-{
-	++*pos;
-	return NULL;
-}
-
-static void dram_seq_stop(struct seq_file *seq, void *v)
-{
+	return 0;//jb.qi change for medmcu sleep fail on 20230418
 }
 
 static int dram_seq_show(struct seq_file *seq, void *v)
 {
-	if (v == SEQ_START_TOKEN) {
-		return print_medhw_dram(seq);
-	}
-	return 0;
+	return print_medhw_dram(seq);//jb.qi change for medmcu sleep fail on 20230418
 }
 
-static const struct seq_operations dram_seq_ops = {
-	.start  = dram_seq_start,
-	.next   = dram_seq_next,
-	.stop   = dram_seq_stop,
-	.show   = dram_seq_show,
-};
 
 static int dram_seq_open(struct inode *inode, struct file *file)
 {
-	mutex_lock(&medhw_dram_mutex);
 	pr_notice("[MEDHW] read dram start\n");
-	return seq_open(file, &dram_seq_ops);
+	return single_open_size(file, dram_seq_show, NULL, (PAGE_SIZE << 11));//jb.qi change for medmcu sleep fail on 20230418
 }
 
 static const struct file_operations dram_fops = {
@@ -1431,47 +1407,17 @@
 	.release = seq_release,
 };
 
-static void *cr_dump_seq_start(struct seq_file *seq, loff_t *pos)
-{
-	if (*pos) {
-		medhw_cr_dump_logged = 1;
-		mutex_unlock(&medhw_cr_dump_mutex);
-		pr_notice("[MEDHW] read cr_dump end\n");
-		return NULL;
-	}
-	return SEQ_START_TOKEN;
-}
-
-static void *cr_dump_seq_next(struct seq_file *seq, void *v, loff_t *pos)
-{
-	++*pos;
-	return NULL;
-}
-
-static void cr_dump_seq_stop(struct seq_file *seq, void *v)
-{
-}
-
 static int cr_dump_seq_show(struct seq_file *seq, void *v)
 {
-	if (v == SEQ_START_TOKEN) {
-		return print_medhw_cr_dump(seq);
-	}
-	return 0;
-}
 
-static const struct seq_operations cr_dump_seq_ops = {
-	.start  = cr_dump_seq_start,
-	.next   = cr_dump_seq_next,
-	.stop   = cr_dump_seq_stop,
-	.show   = cr_dump_seq_show,
-};
+	return print_medhw_cr_dump(seq);//jb.qi change for medmcu sleep fail on 20230418
+}
 
 static int cr_dump_seq_open(struct inode *inode, struct file *file)
 {
-	mutex_lock(&medhw_cr_dump_mutex);
+	
 	pr_notice("[MEDHW] read cr_dump start\n");
-	return seq_open(file, &cr_dump_seq_ops);
+	return single_open_size(file, cr_dump_seq_show, NULL, (PAGE_SIZE << 4));//jb.qi change for medmcu sleep fail on 20230418
 }
 
 static const struct file_operations cr_dump_fops = {