Path: blob/master/arch/powerpc/platforms/52xx/mpc52xx_sleep.S
10818 views
#include <asm/reg.h>1#include <asm/ppc_asm.h>2#include <asm/processor.h>345.text67_GLOBAL(mpc52xx_deep_sleep)8mpc52xx_deep_sleep: /* args r3-r6: SRAM, SDRAM regs, CDM regs, INTR regs */910/* enable interrupts */11mfmsr r712ori r7, r7, 0x8000 /* EE */13mtmsr r714sync; isync;1516li r10, 0 /* flag that irq handler sets */1718/* enable tmr7 (or any other) interrupt */19lwz r8, 0x14(r6) /* intr->main_mask */20ori r8, r8, 0x121xori r8, r8, 0x122stw r8, 0x14(r6)23sync2425/* emulate tmr7 interrupt */26li r8, 0x127stw r8, 0x40(r6) /* intr->main_emulate */28sync2930/* wait for it to happen */311:32cmpi cr0, r10, 133bne cr0, 1b3435/* lock icache */36mfspr r10, SPRN_HID037ori r10, r10, 0x200038sync; isync;39mtspr SPRN_HID0, r1040sync; isync;414243mflr r9 /* save LR */4445/* jump to sram */46mtlr r347blrl4849mtlr r9 /* restore LR */5051/* unlock icache */52mfspr r10, SPRN_HID053ori r10, r10, 0x200054xori r10, r10, 0x200055sync; isync;56mtspr SPRN_HID0, r1057sync; isync;585960/* return to C code */61blr626364_GLOBAL(mpc52xx_ds_sram)65mpc52xx_ds_sram:66/* put SDRAM into self-refresh */67lwz r8, 0x4(r4) /* sdram->ctrl */6869oris r8, r8, 0x8000 /* mode_en */70stw r8, 0x4(r4)71sync7273ori r8, r8, 0x0002 /* soft_pre */74stw r8, 0x4(r4)75sync76xori r8, r8, 0x00027778xoris r8, r8, 0x8000 /* !mode_en */79stw r8, 0x4(r4)80sync8182oris r8, r8, 0x500083xoris r8, r8, 0x4000 /* ref_en !cke */84stw r8, 0x4(r4)85sync8687/* disable SDRAM clock */88lwz r8, 0x14(r5) /* cdm->clkenable */89ori r8, r8, 0x000890xori r8, r8, 0x000891stw r8, 0x14(r5)92sync939495/* put mpc5200 to sleep */96mfmsr r1097oris r10, r10, 0x0004 /* POW = 1 */98sync; isync;99mtmsr r10100sync; isync;101102103/* enable clock */104lwz r8, 0x14(r5)105ori r8, r8, 0x0008106stw r8, 0x14(r5)107sync108109/* get ram out of self-refresh */110lwz r8, 0x4(r4)111oris r8, r8, 0x5000 /* cke ref_en */112stw r8, 0x4(r4)113sync114115blr116_GLOBAL(mpc52xx_ds_sram_size)117mpc52xx_ds_sram_size:118.long $-mpc52xx_ds_sram119120121/* ### interrupt handler for wakeup from deep-sleep ### */122_GLOBAL(mpc52xx_ds_cached)123mpc52xx_ds_cached:124mtspr SPRN_SPRG0, r7125mtspr SPRN_SPRG1, r8126127/* disable emulated interrupt */128mfspr r7, 311 /* MBAR */129addi r7, r7, 0x540 /* intr->main_emul */130li r8, 0131stw r8, 0(r7)132sync133dcbf 0, r7134135/* acknowledge wakeup, so CCS releases power pown */136mfspr r7, 311 /* MBAR */137addi r7, r7, 0x524 /* intr->enc_status */138lwz r8, 0(r7)139ori r8, r8, 0x0400140stw r8, 0(r7)141sync142dcbf 0, r7143144/* flag - we handled the interrupt */145li r10, 1146147mfspr r8, SPRN_SPRG1148mfspr r7, SPRN_SPRG0149150rfi151_GLOBAL(mpc52xx_ds_cached_size)152mpc52xx_ds_cached_size:153.long $-mpc52xx_ds_cached154155156