commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=53955e83336e274c5e3abcf0065f5ba5e6825d28
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/2012R1

Signed-off-by: Steven Miao <[email protected]>
---
 arch/blackfin/mach-bf609/hibernate.S       |   75 +++++++++++++++++++++++++-
 arch/blackfin/mach-bf609/include/mach/pm.h |    6 +-
 arch/blackfin/mach-bf609/pm.c              |   80 +++++++++++++++------------
 3 files changed, 121 insertions(+), 40 deletions(-)

diff --git a/arch/blackfin/mach-bf609/hibernate.S b/arch/blackfin/mach-bf609/hibernate.S
index d37a532..271402b 100644
--- a/arch/blackfin/mach-bf609/hibernate.S
+++ b/arch/blackfin/mach-bf609/hibernate.S
@@ -30,7 +30,80 @@ ENTRY(_enter_hibernate)
 	[P0] = R3;
 
 	SSYNC;
-ENDPROC(_enter_hibernate_mode)
+ENDPROC(_enter_hibernate)
+
+
+ENTRY(_dummy_deepsleep)
+	cli r0;
+	[--sp] = (R7:0,P5:0);
+	P0.l = LO(SEC_SCI_BASE + SEC_CSID);
+	P0.h = HI(SEC_SCI_BASE + SEC_CSID);
+	R0 = [P0];
+
+	P1.l = LO(SEC_END);
+	P1.h = HI(SEC_END);
+
+	[P1] = R0;
+
+	p0.h = hi(EVT11);
+	p0.l = lo(EVT11);
+	p1.h = _evt_evt11;
+	p1.l = _evt_evt11;
+
+	[p0] = p1;
+
+	(R7:0,P5:0) = [SP++];
+	RTI;
+ENDPROC(_dummy_deepsleep)
+
+ENTRY(_enter_deepsleep)
+	[--sp] = (R7:0,P5:0);
+	p0.h = hi(EVT11);
+	p0.l = lo(EVT11);
+	p1.h = _dummy_deepsleep;
+	p1.l = _dummy_deepsleep;
+
+	[p0] = p1;
+
+	P0.H = HI(PM_STACK);
+	P0.L = LO(PM_STACK);
+
+	i2 = SP;
+	SP = P0;
+
+	SSYNC;
+
+	call _bf609_ddr_sr;
+
+	P0.H = HI(DPM0_CTL);
+	P0.L = LO(DPM0_CTL);
+	R3.H = HI(0x00000008);
+	R3.L = LO(0x00000008);
+	[P0] = R3;
+
+	CSYNC;
+
+	r0.l = 0xffff;
+	r0.h = 0;
+	sti r0;
+	SSYNC;
+
+	idle;
+	SSYNC;
+
+	R3 = 0;
+1:
+	cc = R3;
+	if !cc jump 1b;
+
+	call _bf609_resume_ccbuf;
+
+	call _bf609_ddr_sr_exit;
+	SP = i2;
+
+	(R7:0,P5:0) = [SP++];
+	RTS;
+ENDPROC(_enter_deepsleep)
 
 .section .text
 ENTRY(_bf609_hibernate)
diff --git a/arch/blackfin/mach-bf609/include/mach/pm.h b/arch/blackfin/mach-bf609/include/mach/pm.h
index 036d9bd..68435f9 100644
--- a/arch/blackfin/mach-bf609/include/mach/pm.h
+++ b/arch/blackfin/mach-bf609/include/mach/pm.h
@@ -11,9 +11,9 @@
 
 #include <linux/suspend.h>
 
-int bfin609_pm_enter(suspend_state_t state);
-int bf609_pm_prepare(void);
-void bf609_pm_finish(void);
+extern int bfin609_pm_enter(suspend_state_t state);
+extern int bf609_pm_prepare(void);
+extern void bf609_pm_finish(void);
 
 void bf609_hibernate(void);
 void bfin_sec_raise_irq(unsigned int sid);
diff --git a/arch/blackfin/mach-bf609/pm.c b/arch/blackfin/mach-bf609/pm.c
index e6c83ae..5f14540 100644
--- a/arch/blackfin/mach-bf609/pm.c
+++ b/arch/blackfin/mach-bf609/pm.c
@@ -133,35 +133,6 @@ void bfin_cpu_suspend(void)
 }
 
 __attribute__((l1_text))
-void bfin_deepsleep(unsigned long mask)
-{
-	uint32_t dpm0_ctl;
-
-	bfin_write32(DPM0_WAKE_EN, 0x10);
-	bfin_write32(DPM0_WAKE_POL, 0x10);
-	dpm0_ctl = 0x00000008;
-	bfin_write32(DPM0_CTL, dpm0_ctl);
-	SSYNC();
-	__asm__ __volatile__( \
-			".align 8;" \
-			"idle;" \
-			: : \
-			);
-#ifdef CONFIG_BFIN_PM_WAKEUP_TIME_BENCH
-	__asm__ __volatile__(
-		"R0 = 0;"
-		"CYCLES = R0;"
-		"CYCLES2 = R0;"
-		"R0 = SYSCFG;"
-		"BITSET(R0, 1);"
-		"SYSCFG = R0;"
-		: : : "R0"
-	);
-#endif
-
-}
-
-__attribute__((l1_text))
 void bf609_ddr_sr(void)
 {
 	uint32_t reg;
@@ -177,16 +148,41 @@ void bf609_ddr_sr(void)
 __attribute__((l1_text))
 void bf609_ddr_sr_exit(void)
 {
-	uint32_t reg;
-	while (!(bfin_read_DMC0_STAT() & 0x1))
+	int dlldatacycle;
+	int dll_ctl;
+
+	/* 250  Mhz */
+	bfin_write_DDR0_CFG(0x00000422);
+	bfin_write_DDR0_TR0(0x20E0A424);
+	bfin_write_DDR0_TR1(0x3020079E);
+	bfin_write_DDR0_TR2(0x0032020D);
+	bfin_write_DDR0_MR(0x00000842);
+	bfin_write_DDR0_EMR1(0x4);
+	bfin_write_DDR0_CTL(0x00000904);
+	while (!(bfin_read_DDR0_STAT() & 0x4))
 		continue;
+	dlldatacycle = (bfin_read_DDR0_STAT() & 0x00f00000) >> 20;
+	dll_ctl = bfin_read_DDR0_DLLCTL();
+	dll_ctl &= 0x0ff;
+	bfin_write_DDR0_DLLCTL(dll_ctl | (dlldatacycle << 8));
 
-	reg = bfin_read_DMC0_CTL();
-	reg &= ~0x8;
-	bfin_write_DMC0_CTL(reg);
+	while (!(bfin_read_DDR0_STAT() & 0x2000))
+		continue;
 
 	while ((bfin_read_DMC0_STAT() & 0x8))
 		continue;
+	while (!(bfin_read_DDR0_STAT() & 0x1))
+		continue;
+
+}
+
+__attribute__((l1_text))
+void bf609_resume_ccbuf(void)
+{
+	bfin_write32(DPM0_CCBF_EN, 3);
+	bfin_write32(DPM0_CTL, 2);
+
+	while ((bfin_read32(DPM0_STAT) & 0xf) != 1);
 }
 
 __attribute__((l1_text))
@@ -205,6 +201,16 @@ void bfin_hibernate_syscontrol(void)
 }
 
 # define IRQ_SID(irq)	((irq) - IVG15)
+asmlinkage void enter_deepsleep(void);
+
+__attribute__((l1_text))
+void bfin_deepsleep(unsigned long mask)
+{
+	bfin_write32(DPM0_WAKE_EN, 0x10);
+	bfin_write32(DPM0_WAKE_POL, 0x10);
+	SSYNC();
+	enter_deepsleep();
+}
 
 void bfin_hibernate(unsigned long mask)
 {
@@ -329,12 +335,13 @@ static irqreturn_t dpm0_isr(int irq, void *dev_id)
 	uint32_t wake_stat;
 
 	wake_stat = bfin_read32(DPM0_WAKE_STAT);
-	printk(KERN_DEBUG "enter %s wake stat %08x\n", __func__, wake_stat);
+//	printk(KERN_DEBUG "enter %s wake stat %08x\n", __func__, wake_stat);
 
 	bfin_write32(DPM0_WAKE_STAT, wake_stat);
 	return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_BFIN_COREB
 void core1_evt_handle(void)
 {
 	unsigned int sid = bfin_read_SEC_SCI(1, SEC_CSID);
@@ -374,13 +381,14 @@ void coreb_start(void)
 		}
 	}
 }
+#endif
 
 static int __init bf609_init_pm(void)
 {
 	int irq;
 	int error;
 
-#if CONFIG_PM_BFIN_WAKE_PE12
+#ifdef CONFIG_PM_BFIN_WAKE_PE12
 	irq = gpio_to_irq(GPIO_PE12);
 	if (irq < 0) {
 		error = irq;
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to