xref: /linux/arch/sh/boards/mach-ecovec24/sdram.S (revision 2839bd61f671d3debf9ef0893a0470fd97b2e2ce)
1eb0cd9e8SMagnus Damm/*
2eb0cd9e8SMagnus Damm * Ecovec24 sdram self/auto-refresh setup code
3eb0cd9e8SMagnus Damm *
4eb0cd9e8SMagnus Damm *  Copyright (C) 2009 Magnus Damm
5eb0cd9e8SMagnus Damm *
6eb0cd9e8SMagnus Damm * This file is subject to the terms and conditions of the GNU General Public
7eb0cd9e8SMagnus Damm * License.  See the file "COPYING" in the main directory of this archive
8eb0cd9e8SMagnus Damm * for more details.
9eb0cd9e8SMagnus Damm */
10eb0cd9e8SMagnus Damm
11eb0cd9e8SMagnus Damm#include <linux/sys.h>
12eb0cd9e8SMagnus Damm#include <linux/errno.h>
13eb0cd9e8SMagnus Damm#include <linux/linkage.h>
14eb0cd9e8SMagnus Damm#include <asm/asm-offsets.h>
15eb0cd9e8SMagnus Damm#include <asm/suspend.h>
16eb0cd9e8SMagnus Damm#include <asm/romimage-macros.h>
17eb0cd9e8SMagnus Damm
18eb0cd9e8SMagnus Damm/* code to enter and leave self-refresh. must be self-contained.
19eb0cd9e8SMagnus Damm * this code will be copied to on-chip memory and executed from there.
20eb0cd9e8SMagnus Damm */
21eb0cd9e8SMagnus Damm	.balign 4
22eb0cd9e8SMagnus DammENTRY(ecovec24_sdram_enter_start)
23eb0cd9e8SMagnus Damm
24eb0cd9e8SMagnus Damm	/* DBSC: put memory in self-refresh mode */
25eb0cd9e8SMagnus Damm
26eb0cd9e8SMagnus Damm	ED 0xFD000010, 0x00000000 /* DBEN */
27eb0cd9e8SMagnus Damm	ED 0xFD000040, 0x00000000 /* DBRFPDN0 */
28eb0cd9e8SMagnus Damm	ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */
29eb0cd9e8SMagnus Damm	ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */
30eb0cd9e8SMagnus Damm	ED 0xFD000040, 0x00000001 /* DBRFPDN0 */
31eb0cd9e8SMagnus Damm
32eb0cd9e8SMagnus Damm	rts
33eb0cd9e8SMagnus Damm	 nop
34eb0cd9e8SMagnus Damm
35eb0cd9e8SMagnus DammENTRY(ecovec24_sdram_enter_end)
36eb0cd9e8SMagnus Damm
37eb0cd9e8SMagnus Damm	.balign 4
38eb0cd9e8SMagnus DammENTRY(ecovec24_sdram_leave_start)
39eb0cd9e8SMagnus Damm
40*2839bd61SMagnus Damm	mov.l	@(SH_SLEEP_MODE, r5), r0
41*2839bd61SMagnus Damm	tst	#SUSP_SH_RSTANDBY, r0
42*2839bd61SMagnus Damm	bf	resume_rstandby
43*2839bd61SMagnus Damm
44eb0cd9e8SMagnus Damm	/* DBSC: put memory in auto-refresh mode */
45eb0cd9e8SMagnus Damm
46eb0cd9e8SMagnus Damm	ED 0xFD000040, 0x00000000 /* DBRFPDN0 */
47eb0cd9e8SMagnus Damm	WAIT 1
48eb0cd9e8SMagnus Damm	ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */
49eb0cd9e8SMagnus Damm	ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */
50eb0cd9e8SMagnus Damm	ED 0xFD000010, 0x00000001 /* DBEN */
51eb0cd9e8SMagnus Damm	ED 0xFD000040, 0x00010000 /* DBRFPDN0 */
52eb0cd9e8SMagnus Damm
53eb0cd9e8SMagnus Damm	rts
54eb0cd9e8SMagnus Damm	 nop
55eb0cd9e8SMagnus Damm
56*2839bd61SMagnus Dammresume_rstandby:
57*2839bd61SMagnus Damm
58*2839bd61SMagnus Damm	/* DBSC: re-initialize and put in auto-refresh */
59*2839bd61SMagnus Damm
60*2839bd61SMagnus Damm	ED 0xFD000108, 0x00000181 /* DBPDCNT0 */
61*2839bd61SMagnus Damm	ED 0xFD000020, 0x015B0002 /* DBCONF */
62*2839bd61SMagnus Damm	ED 0xFD000030, 0x03071502 /* DBTR0 */
63*2839bd61SMagnus Damm	ED 0xFD000034, 0x02020102 /* DBTR1 */
64*2839bd61SMagnus Damm	ED 0xFD000038, 0x01090405 /* DBTR2 */
65*2839bd61SMagnus Damm	ED 0xFD00003C, 0x00000002 /* DBTR3 */
66*2839bd61SMagnus Damm	ED 0xFD000008, 0x00000005 /* DBKIND */
67*2839bd61SMagnus Damm	ED 0xFD000040, 0x00000001 /* DBRFPDN0 */
68*2839bd61SMagnus Damm	ED 0xFD000040, 0x00000000 /* DBRFPDN0 */
69*2839bd61SMagnus Damm	ED 0xFD000018, 0x00000001 /* DBCKECNT */
70*2839bd61SMagnus Damm
71*2839bd61SMagnus Damm	mov	#100,r0
72*2839bd61SMagnus DammWAIT_400NS:
73*2839bd61SMagnus Damm	dt	r0
74*2839bd61SMagnus Damm	bf	WAIT_400NS
75*2839bd61SMagnus Damm
76*2839bd61SMagnus Damm	ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */
77*2839bd61SMagnus Damm	ED 0xFD000060, 0x00020000 /* DBMRCNT (EMR2) */
78*2839bd61SMagnus Damm	ED 0xFD000060, 0x00030000 /* DBMRCNT (EMR3) */
79*2839bd61SMagnus Damm	ED 0xFD000060, 0x00010004 /* DBMRCNT (EMR) */
80*2839bd61SMagnus Damm	ED 0xFD000060, 0x00000532 /* DBMRCNT (MRS) */
81*2839bd61SMagnus Damm	ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */
82*2839bd61SMagnus Damm	ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */
83*2839bd61SMagnus Damm	ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */
84*2839bd61SMagnus Damm	ED 0xFD000060, 0x00000432 /* DBMRCNT (MRS) */
85*2839bd61SMagnus Damm	ED 0xFD000060, 0x000103c0 /* DBMRCNT (EMR) */
86*2839bd61SMagnus Damm	ED 0xFD000060, 0x00010040 /* DBMRCNT (EMR) */
87*2839bd61SMagnus Damm
88*2839bd61SMagnus Damm	mov	#100,r0
89*2839bd61SMagnus DammWAIT_400NS_2:
90*2839bd61SMagnus Damm	dt	r0
91*2839bd61SMagnus Damm	bf	WAIT_400NS_2
92*2839bd61SMagnus Damm
93*2839bd61SMagnus Damm	ED 0xFD000010, 0x00000001 /* DBEN */
94*2839bd61SMagnus Damm	ED 0xFD000044, 0x0000050f /* DBRFPDN1 */
95*2839bd61SMagnus Damm	ED 0xFD000048, 0x236800e6 /* DBRFPDN2 */
96*2839bd61SMagnus Damm
97*2839bd61SMagnus Damm	mov.l	DUMMY,r0
98*2839bd61SMagnus Damm	mov.l	@r0, r1 /* force single dummy read */
99*2839bd61SMagnus Damm
100*2839bd61SMagnus Damm	ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */
101*2839bd61SMagnus Damm	ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */
102*2839bd61SMagnus Damm	ED 0xFD000108, 0x00000080 /* DBPDCNT0 */
103*2839bd61SMagnus Damm	ED 0xFD000040, 0x00010000 /* DBRFPDN0 */
104*2839bd61SMagnus Damm
105*2839bd61SMagnus Damm	rts
106*2839bd61SMagnus Damm	 nop
107*2839bd61SMagnus Damm
108*2839bd61SMagnus Damm	.balign 4
109*2839bd61SMagnus DammDUMMY:	.long	0xac400000
110*2839bd61SMagnus Damm
111eb0cd9e8SMagnus DammENTRY(ecovec24_sdram_leave_end)
112