1*aaf9128aSKuninori Morimoto/* SPDX-License-Identifier: GPL-2.0 2*aaf9128aSKuninori Morimoto * 3eb0cd9e8SMagnus Damm * Ecovec24 sdram self/auto-refresh setup code 4eb0cd9e8SMagnus Damm * 5eb0cd9e8SMagnus Damm * Copyright (C) 2009 Magnus Damm 6eb0cd9e8SMagnus Damm */ 7eb0cd9e8SMagnus Damm 8eb0cd9e8SMagnus Damm#include <linux/sys.h> 9eb0cd9e8SMagnus Damm#include <linux/errno.h> 10eb0cd9e8SMagnus Damm#include <linux/linkage.h> 11eb0cd9e8SMagnus Damm#include <asm/asm-offsets.h> 12eb0cd9e8SMagnus Damm#include <asm/suspend.h> 13eb0cd9e8SMagnus Damm#include <asm/romimage-macros.h> 14eb0cd9e8SMagnus Damm 15eb0cd9e8SMagnus Damm/* code to enter and leave self-refresh. must be self-contained. 16eb0cd9e8SMagnus Damm * this code will be copied to on-chip memory and executed from there. 17eb0cd9e8SMagnus Damm */ 18eb0cd9e8SMagnus Damm .balign 4 19eb0cd9e8SMagnus DammENTRY(ecovec24_sdram_enter_start) 20eb0cd9e8SMagnus Damm 21eb0cd9e8SMagnus Damm /* DBSC: put memory in self-refresh mode */ 22eb0cd9e8SMagnus Damm 23eb0cd9e8SMagnus Damm ED 0xFD000010, 0x00000000 /* DBEN */ 24eb0cd9e8SMagnus Damm ED 0xFD000040, 0x00000000 /* DBRFPDN0 */ 25eb0cd9e8SMagnus Damm ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */ 26eb0cd9e8SMagnus Damm ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */ 27eb0cd9e8SMagnus Damm ED 0xFD000040, 0x00000001 /* DBRFPDN0 */ 28eb0cd9e8SMagnus Damm 29eb0cd9e8SMagnus Damm rts 30eb0cd9e8SMagnus Damm nop 31eb0cd9e8SMagnus Damm 32eb0cd9e8SMagnus DammENTRY(ecovec24_sdram_enter_end) 33eb0cd9e8SMagnus Damm 34eb0cd9e8SMagnus Damm .balign 4 35eb0cd9e8SMagnus DammENTRY(ecovec24_sdram_leave_start) 36eb0cd9e8SMagnus Damm 372839bd61SMagnus Damm mov.l @(SH_SLEEP_MODE, r5), r0 382839bd61SMagnus Damm tst #SUSP_SH_RSTANDBY, r0 392839bd61SMagnus Damm bf resume_rstandby 402839bd61SMagnus Damm 41eb0cd9e8SMagnus Damm /* DBSC: put memory in auto-refresh mode */ 42eb0cd9e8SMagnus Damm 43eb0cd9e8SMagnus Damm ED 0xFD000040, 0x00000000 /* DBRFPDN0 */ 44eb0cd9e8SMagnus Damm WAIT 1 45eb0cd9e8SMagnus Damm ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */ 46eb0cd9e8SMagnus Damm ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */ 47eb0cd9e8SMagnus Damm ED 0xFD000010, 0x00000001 /* DBEN */ 48eb0cd9e8SMagnus Damm ED 0xFD000040, 0x00010000 /* DBRFPDN0 */ 49eb0cd9e8SMagnus Damm 50eb0cd9e8SMagnus Damm rts 51eb0cd9e8SMagnus Damm nop 52eb0cd9e8SMagnus Damm 532839bd61SMagnus Dammresume_rstandby: 542839bd61SMagnus Damm 552839bd61SMagnus Damm /* DBSC: re-initialize and put in auto-refresh */ 562839bd61SMagnus Damm 572839bd61SMagnus Damm ED 0xFD000108, 0x00000181 /* DBPDCNT0 */ 582839bd61SMagnus Damm ED 0xFD000020, 0x015B0002 /* DBCONF */ 592839bd61SMagnus Damm ED 0xFD000030, 0x03071502 /* DBTR0 */ 602839bd61SMagnus Damm ED 0xFD000034, 0x02020102 /* DBTR1 */ 612839bd61SMagnus Damm ED 0xFD000038, 0x01090405 /* DBTR2 */ 622839bd61SMagnus Damm ED 0xFD00003C, 0x00000002 /* DBTR3 */ 632839bd61SMagnus Damm ED 0xFD000008, 0x00000005 /* DBKIND */ 642839bd61SMagnus Damm ED 0xFD000040, 0x00000001 /* DBRFPDN0 */ 652839bd61SMagnus Damm ED 0xFD000040, 0x00000000 /* DBRFPDN0 */ 662839bd61SMagnus Damm ED 0xFD000018, 0x00000001 /* DBCKECNT */ 672839bd61SMagnus Damm 682839bd61SMagnus Damm mov #100,r0 692839bd61SMagnus DammWAIT_400NS: 702839bd61SMagnus Damm dt r0 712839bd61SMagnus Damm bf WAIT_400NS 722839bd61SMagnus Damm 732839bd61SMagnus Damm ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */ 742839bd61SMagnus Damm ED 0xFD000060, 0x00020000 /* DBMRCNT (EMR2) */ 752839bd61SMagnus Damm ED 0xFD000060, 0x00030000 /* DBMRCNT (EMR3) */ 762839bd61SMagnus Damm ED 0xFD000060, 0x00010004 /* DBMRCNT (EMR) */ 772839bd61SMagnus Damm ED 0xFD000060, 0x00000532 /* DBMRCNT (MRS) */ 782839bd61SMagnus Damm ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */ 792839bd61SMagnus Damm ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */ 802839bd61SMagnus Damm ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */ 812839bd61SMagnus Damm ED 0xFD000060, 0x00000432 /* DBMRCNT (MRS) */ 822839bd61SMagnus Damm ED 0xFD000060, 0x000103c0 /* DBMRCNT (EMR) */ 832839bd61SMagnus Damm ED 0xFD000060, 0x00010040 /* DBMRCNT (EMR) */ 842839bd61SMagnus Damm 852839bd61SMagnus Damm mov #100,r0 862839bd61SMagnus DammWAIT_400NS_2: 872839bd61SMagnus Damm dt r0 882839bd61SMagnus Damm bf WAIT_400NS_2 892839bd61SMagnus Damm 902839bd61SMagnus Damm ED 0xFD000010, 0x00000001 /* DBEN */ 912839bd61SMagnus Damm ED 0xFD000044, 0x0000050f /* DBRFPDN1 */ 922839bd61SMagnus Damm ED 0xFD000048, 0x236800e6 /* DBRFPDN2 */ 932839bd61SMagnus Damm 942839bd61SMagnus Damm mov.l DUMMY,r0 952839bd61SMagnus Damm mov.l @r0, r1 /* force single dummy read */ 962839bd61SMagnus Damm 972839bd61SMagnus Damm ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */ 982839bd61SMagnus Damm ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */ 992839bd61SMagnus Damm ED 0xFD000108, 0x00000080 /* DBPDCNT0 */ 1002839bd61SMagnus Damm ED 0xFD000040, 0x00010000 /* DBRFPDN0 */ 1012839bd61SMagnus Damm 1022839bd61SMagnus Damm rts 1032839bd61SMagnus Damm nop 1042839bd61SMagnus Damm 1052839bd61SMagnus Damm .balign 4 1062839bd61SMagnus DammDUMMY: .long 0xac400000 1072839bd61SMagnus Damm 108eb0cd9e8SMagnus DammENTRY(ecovec24_sdram_leave_end) 109