Path: blob/master/arch/powerpc/platforms/52xx/mpc52xx_sleep.S
26481 views
/* SPDX-License-Identifier: GPL-2.0 */1#include <asm/reg.h>2#include <asm/ppc_asm.h>3#include <asm/processor.h>456.text78_GLOBAL(mpc52xx_deep_sleep)9mpc52xx_deep_sleep: /* args r3-r6: SRAM, SDRAM regs, CDM regs, INTR regs */1011/* enable interrupts */12mfmsr r713ori r7, r7, 0x8000 /* EE */14mtmsr r715sync; isync;1617li r10, 0 /* flag that irq handler sets */1819/* enable tmr7 (or any other) interrupt */20lwz r8, 0x14(r6) /* intr->main_mask */21ori r8, r8, 0x122xori r8, r8, 0x123stw r8, 0x14(r6)24sync2526/* emulate tmr7 interrupt */27li r8, 0x128stw r8, 0x40(r6) /* intr->main_emulate */29sync3031/* wait for it to happen */321:33cmpi cr0, r10, 134bne cr0, 1b3536/* lock icache */37mfspr r10, SPRN_HID038ori r10, r10, 0x200039sync; isync;40mtspr SPRN_HID0, r1041sync; isync;424344mflr r9 /* save LR */4546/* jump to sram */47mtlr r348blrl4950mtlr r9 /* restore LR */5152/* unlock icache */53mfspr r10, SPRN_HID054ori r10, r10, 0x200055xori r10, r10, 0x200056sync; isync;57mtspr SPRN_HID0, r1058sync; isync;596061/* return to C code */62blr636465_GLOBAL(mpc52xx_ds_sram)66mpc52xx_ds_sram:67/* put SDRAM into self-refresh */68lwz r8, 0x4(r4) /* sdram->ctrl */6970oris r8, r8, 0x8000 /* mode_en */71stw r8, 0x4(r4)72sync7374ori r8, r8, 0x0002 /* soft_pre */75stw r8, 0x4(r4)76sync77xori r8, r8, 0x00027879xoris r8, r8, 0x8000 /* !mode_en */80stw r8, 0x4(r4)81sync8283oris r8, r8, 0x500084xoris r8, r8, 0x4000 /* ref_en !cke */85stw r8, 0x4(r4)86sync8788/* disable SDRAM clock */89lwz r8, 0x14(r5) /* cdm->clkenable */90ori r8, r8, 0x000891xori r8, r8, 0x000892stw r8, 0x14(r5)93sync949596/* put mpc5200 to sleep */97mfmsr r1098oris r10, r10, 0x0004 /* POW = 1 */99sync; isync;100mtmsr r10101sync; isync;102103104/* enable clock */105lwz r8, 0x14(r5)106ori r8, r8, 0x0008107stw r8, 0x14(r5)108sync109110/* get ram out of self-refresh */111lwz r8, 0x4(r4)112oris r8, r8, 0x5000 /* cke ref_en */113stw r8, 0x4(r4)114sync115116blr117_GLOBAL(mpc52xx_ds_sram_size)118mpc52xx_ds_sram_size:119.long $-mpc52xx_ds_sram120121122/* ### interrupt handler for wakeup from deep-sleep ### */123_GLOBAL(mpc52xx_ds_cached)124mpc52xx_ds_cached:125mtspr SPRN_SPRG0, r7126mtspr SPRN_SPRG1, r8127128/* disable emulated interrupt */129mfspr r7, 311 /* MBAR */130addi r7, r7, 0x540 /* intr->main_emul */131li r8, 0132stw r8, 0(r7)133sync134dcbf 0, r7135136/* acknowledge wakeup, so CCS releases power pown */137mfspr r7, 311 /* MBAR */138addi r7, r7, 0x524 /* intr->enc_status */139lwz r8, 0(r7)140ori r8, r8, 0x0400141stw r8, 0(r7)142sync143dcbf 0, r7144145/* flag - we handled the interrupt */146li r10, 1147148mfspr r8, SPRN_SPRG1149mfspr r7, SPRN_SPRG0150151rfi152_GLOBAL(mpc52xx_ds_cached_size)153mpc52xx_ds_cached_size:154.long $-mpc52xx_ds_cached155156157