Path: blob/master/arch/mips/alchemy/common/sleeper.S
10819 views
/*1* Copyright 2002 Embedded Edge, LLC2* Author: [email protected]3*4* Sleep helper for Au1xxx sleep mode.5*6* This program is free software; you can redistribute it and/or modify it7* under the terms of the GNU General Public License as published by the8* Free Software Foundation; either version 2 of the License, or (at your9* option) any later version.10*/1112#include <asm/asm.h>13#include <asm/mipsregs.h>14#include <asm/regdef.h>15#include <asm/stackframe.h>1617.extern __flush_cache_all1819.text20.set noreorder21.set noat22.align 5232425/* preparatory stuff */26.macro SETUP_SLEEP27subu sp, PT_SIZE28sw $1, PT_R1(sp)29sw $2, PT_R2(sp)30sw $3, PT_R3(sp)31sw $4, PT_R4(sp)32sw $5, PT_R5(sp)33sw $6, PT_R6(sp)34sw $7, PT_R7(sp)35sw $16, PT_R16(sp)36sw $17, PT_R17(sp)37sw $18, PT_R18(sp)38sw $19, PT_R19(sp)39sw $20, PT_R20(sp)40sw $21, PT_R21(sp)41sw $22, PT_R22(sp)42sw $23, PT_R23(sp)43sw $26, PT_R26(sp)44sw $27, PT_R27(sp)45sw $28, PT_R28(sp)46sw $30, PT_R30(sp)47sw $31, PT_R31(sp)48mfc0 k0, CP0_STATUS49sw k0, 0x20(sp)50mfc0 k0, CP0_CONTEXT51sw k0, 0x1c(sp)52mfc0 k0, CP0_PAGEMASK53sw k0, 0x18(sp)54mfc0 k0, CP0_CONFIG55sw k0, 0x14(sp)5657/* flush caches to make sure context is in memory */58la t1, __flush_cache_all59lw t0, 0(t1)60jalr t061nop6263/* Now set up the scratch registers so the boot rom will64* return to this point upon wakeup.65* sys_scratch0 : SP66* sys_scratch1 : RA67*/68lui t3, 0xb190 /* sys_xxx */69sw sp, 0x0018(t3)70la k0, alchemy_sleep_wakeup /* resume path */71sw k0, 0x001c(t3)72.endm7374.macro DO_SLEEP75/* put power supply and processor to sleep */76sw zero, 0x0078(t3) /* sys_slppwr */77sync78sw zero, 0x007c(t3) /* sys_sleep */79sync80nop81nop82nop83nop84nop85nop86nop87nop88.endm8990/* sleep code for Au1000/Au1100/Au1500 memory controller type */91LEAF(alchemy_sleep_au1000)9293SETUP_SLEEP9495/* cache following instructions, as memory gets put to sleep */96la t0, 1f97.set mips398cache 0x14, 0(t0)99cache 0x14, 32(t0)100cache 0x14, 64(t0)101cache 0x14, 96(t0)102.set mips01031041: lui a0, 0xb400 /* mem_xxx */105sw zero, 0x001c(a0) /* Precharge */106sync107sw zero, 0x0020(a0) /* Auto Refresh */108sync109sw zero, 0x0030(a0) /* Sleep */110sync111112DO_SLEEP113114END(alchemy_sleep_au1000)115116/* sleep code for Au1550/Au1200 memory controller type */117LEAF(alchemy_sleep_au1550)118119SETUP_SLEEP120121/* cache following instructions, as memory gets put to sleep */122la t0, 1f123.set mips3124cache 0x14, 0(t0)125cache 0x14, 32(t0)126cache 0x14, 64(t0)127cache 0x14, 96(t0)128.set mips01291301: lui a0, 0xb400 /* mem_xxx */131sw zero, 0x08c0(a0) /* Precharge */132sync133sw zero, 0x08d0(a0) /* Self Refresh */134sync135136/* wait for sdram to enter self-refresh mode */137lui t0, 0x01001382: lw t1, 0x0850(a0) /* mem_sdstat */139and t2, t1, t0140beq t2, zero, 2b141nop142143/* disable SDRAM clocks */144lui t0, 0xcfff145ori t0, t0, 0xffff146lw t1, 0x0840(a0) /* mem_sdconfiga */147and t1, t0, t1 /* clear CE[1:0] */148sw t1, 0x0840(a0) /* mem_sdconfiga */149sync150151DO_SLEEP152153END(alchemy_sleep_au1550)154155156/* This is where we return upon wakeup.157* Reload all of the registers and return.158*/159LEAF(alchemy_sleep_wakeup)160lw k0, 0x20(sp)161mtc0 k0, CP0_STATUS162lw k0, 0x1c(sp)163mtc0 k0, CP0_CONTEXT164lw k0, 0x18(sp)165mtc0 k0, CP0_PAGEMASK166lw k0, 0x14(sp)167mtc0 k0, CP0_CONFIG168169/* We need to catch the early Alchemy SOCs with170* the write-only Config[OD] bit and set it back to one...171*/172jal au1x00_fixup_config_od173nop174lw $1, PT_R1(sp)175lw $2, PT_R2(sp)176lw $3, PT_R3(sp)177lw $4, PT_R4(sp)178lw $5, PT_R5(sp)179lw $6, PT_R6(sp)180lw $7, PT_R7(sp)181lw $16, PT_R16(sp)182lw $17, PT_R17(sp)183lw $18, PT_R18(sp)184lw $19, PT_R19(sp)185lw $20, PT_R20(sp)186lw $21, PT_R21(sp)187lw $22, PT_R22(sp)188lw $23, PT_R23(sp)189lw $26, PT_R26(sp)190lw $27, PT_R27(sp)191lw $28, PT_R28(sp)192lw $30, PT_R30(sp)193lw $31, PT_R31(sp)194jr ra195addiu sp, PT_SIZE196END(alchemy_sleep_wakeup)197198199