/* SPDX-License-Identifier: GPL-2.01*2* MS7724SE sdram self/auto-refresh setup code3*4* Copyright (C) 2009 Magnus Damm5*/67#include <linux/sys.h>8#include <linux/errno.h>9#include <linux/linkage.h>10#include <asm/asm-offsets.h>11#include <asm/suspend.h>12#include <asm/romimage-macros.h>1314/* code to enter and leave self-refresh. must be self-contained.15* this code will be copied to on-chip memory and executed from there.16*/17.balign 418ENTRY(ms7724se_sdram_enter_start)1920/* DBSC: put memory in self-refresh mode */2122ED 0xFD000010, 0x00000000 /* DBEN */23ED 0xFD000040, 0x00000000 /* DBRFPDN0 */24ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */25ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */26ED 0xFD000040, 0x00000001 /* DBRFPDN0 */2728rts29nop3031ENTRY(ms7724se_sdram_enter_end)3233.balign 434ENTRY(ms7724se_sdram_leave_start)3536/* DBSC: put memory in auto-refresh mode */3738mov.l @(SH_SLEEP_MODE, r5), r039tst #SUSP_SH_RSTANDBY, r040bf resume_rstandby4142ED 0xFD000040, 0x00000000 /* DBRFPDN0 */43WAIT 144ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */45ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */46ED 0xFD000010, 0x00000001 /* DBEN */47ED 0xFD000040, 0x00010000 /* DBRFPDN0 */4849rts50nop5152resume_rstandby:5354/* CPG: setup clocks before restarting external memory */5556ED 0xA4150024, 0x00004000 /* PLLCR */5758mov.l FRQCRA,r059mov.l @r0,r360mov.l KICK,r161or r1, r362mov.l r3, @r06364mov.l LSTATS,r065mov #1,r166WAIT_LSTATS:67mov.l @r0,r368tst r1,r369bf WAIT_LSTATS7071/* DBSC: re-initialize and put in auto-refresh */7273ED 0xFD000108, 0x00000181 /* DBPDCNT0 */74ED 0xFD000020, 0x015B0002 /* DBCONF */75ED 0xFD000030, 0x03071502 /* DBTR0 */76ED 0xFD000034, 0x02020102 /* DBTR1 */77ED 0xFD000038, 0x01090405 /* DBTR2 */78ED 0xFD00003C, 0x00000002 /* DBTR3 */79ED 0xFD000008, 0x00000005 /* DBKIND */80ED 0xFD000040, 0x00000001 /* DBRFPDN0 */81ED 0xFD000040, 0x00000000 /* DBRFPDN0 */82ED 0xFD000018, 0x00000001 /* DBCKECNT */8384mov #100,r085WAIT_400NS:86dt r087bf WAIT_400NS8889ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */90ED 0xFD000060, 0x00020000 /* DBMRCNT (EMR2) */91ED 0xFD000060, 0x00030000 /* DBMRCNT (EMR3) */92ED 0xFD000060, 0x00010004 /* DBMRCNT (EMR) */93ED 0xFD000060, 0x00000532 /* DBMRCNT (MRS) */94ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */95ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */96ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */97ED 0xFD000060, 0x00000432 /* DBMRCNT (MRS) */98ED 0xFD000060, 0x000103c0 /* DBMRCNT (EMR) */99ED 0xFD000060, 0x00010040 /* DBMRCNT (EMR) */100101mov #100,r0102WAIT_400NS_2:103dt r0104bf WAIT_400NS_2105106ED 0xFD000010, 0x00000001 /* DBEN */107ED 0xFD000044, 0x0000050f /* DBRFPDN1 */108ED 0xFD000048, 0x236800e6 /* DBRFPDN2 */109110mov.l DUMMY,r0111mov.l @r0, r1 /* force single dummy read */112113ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */114ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */115ED 0xFD000108, 0x00000080 /* DBPDCNT0 */116ED 0xFD000040, 0x00010000 /* DBRFPDN0 */117118rts119nop120121.balign 4122DUMMY: .long 0xac400000123FRQCRA: .long 0xa4150000124KICK: .long 0x80000000125LSTATS: .long 0xa4150060126127ENTRY(ms7724se_sdram_leave_end)128129130