1*b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */ 22e1ee1f7SDomen Puncer#include <asm/reg.h> 32e1ee1f7SDomen Puncer#include <asm/ppc_asm.h> 42e1ee1f7SDomen Puncer#include <asm/processor.h> 52e1ee1f7SDomen Puncer 62e1ee1f7SDomen Puncer 72e1ee1f7SDomen Puncer.text 82e1ee1f7SDomen Puncer 92e1ee1f7SDomen Puncer_GLOBAL(mpc52xx_deep_sleep) 102e1ee1f7SDomen Puncermpc52xx_deep_sleep: /* args r3-r6: SRAM, SDRAM regs, CDM regs, INTR regs */ 112e1ee1f7SDomen Puncer 122e1ee1f7SDomen Puncer /* enable interrupts */ 132e1ee1f7SDomen Puncer mfmsr r7 142e1ee1f7SDomen Puncer ori r7, r7, 0x8000 /* EE */ 152e1ee1f7SDomen Puncer mtmsr r7 162e1ee1f7SDomen Puncer sync; isync; 172e1ee1f7SDomen Puncer 182e1ee1f7SDomen Puncer li r10, 0 /* flag that irq handler sets */ 192e1ee1f7SDomen Puncer 202e1ee1f7SDomen Puncer /* enable tmr7 (or any other) interrupt */ 212e1ee1f7SDomen Puncer lwz r8, 0x14(r6) /* intr->main_mask */ 222e1ee1f7SDomen Puncer ori r8, r8, 0x1 232e1ee1f7SDomen Puncer xori r8, r8, 0x1 242e1ee1f7SDomen Puncer stw r8, 0x14(r6) 252e1ee1f7SDomen Puncer sync 262e1ee1f7SDomen Puncer 272e1ee1f7SDomen Puncer /* emulate tmr7 interrupt */ 282e1ee1f7SDomen Puncer li r8, 0x1 292e1ee1f7SDomen Puncer stw r8, 0x40(r6) /* intr->main_emulate */ 302e1ee1f7SDomen Puncer sync 312e1ee1f7SDomen Puncer 322e1ee1f7SDomen Puncer /* wait for it to happen */ 332e1ee1f7SDomen Puncer1: 342e1ee1f7SDomen Puncer cmpi cr0, r10, 1 352e1ee1f7SDomen Puncer bne cr0, 1b 362e1ee1f7SDomen Puncer 372e1ee1f7SDomen Puncer /* lock icache */ 382e1ee1f7SDomen Puncer mfspr r10, SPRN_HID0 392e1ee1f7SDomen Puncer ori r10, r10, 0x2000 402e1ee1f7SDomen Puncer sync; isync; 412e1ee1f7SDomen Puncer mtspr SPRN_HID0, r10 422e1ee1f7SDomen Puncer sync; isync; 432e1ee1f7SDomen Puncer 442e1ee1f7SDomen Puncer 452e1ee1f7SDomen Puncer mflr r9 /* save LR */ 462e1ee1f7SDomen Puncer 472e1ee1f7SDomen Puncer /* jump to sram */ 482e1ee1f7SDomen Puncer mtlr r3 492e1ee1f7SDomen Puncer blrl 502e1ee1f7SDomen Puncer 512e1ee1f7SDomen Puncer mtlr r9 /* restore LR */ 522e1ee1f7SDomen Puncer 532e1ee1f7SDomen Puncer /* unlock icache */ 542e1ee1f7SDomen Puncer mfspr r10, SPRN_HID0 552e1ee1f7SDomen Puncer ori r10, r10, 0x2000 562e1ee1f7SDomen Puncer xori r10, r10, 0x2000 572e1ee1f7SDomen Puncer sync; isync; 582e1ee1f7SDomen Puncer mtspr SPRN_HID0, r10 592e1ee1f7SDomen Puncer sync; isync; 602e1ee1f7SDomen Puncer 612e1ee1f7SDomen Puncer 622e1ee1f7SDomen Puncer /* return to C code */ 632e1ee1f7SDomen Puncer blr 642e1ee1f7SDomen Puncer 652e1ee1f7SDomen Puncer 662e1ee1f7SDomen Puncer_GLOBAL(mpc52xx_ds_sram) 672e1ee1f7SDomen Puncermpc52xx_ds_sram: 682e1ee1f7SDomen Puncer /* put SDRAM into self-refresh */ 692e1ee1f7SDomen Puncer lwz r8, 0x4(r4) /* sdram->ctrl */ 702e1ee1f7SDomen Puncer 712e1ee1f7SDomen Puncer oris r8, r8, 0x8000 /* mode_en */ 722e1ee1f7SDomen Puncer stw r8, 0x4(r4) 732e1ee1f7SDomen Puncer sync 742e1ee1f7SDomen Puncer 752e1ee1f7SDomen Puncer ori r8, r8, 0x0002 /* soft_pre */ 762e1ee1f7SDomen Puncer stw r8, 0x4(r4) 772e1ee1f7SDomen Puncer sync 782e1ee1f7SDomen Puncer xori r8, r8, 0x0002 792e1ee1f7SDomen Puncer 802e1ee1f7SDomen Puncer xoris r8, r8, 0x8000 /* !mode_en */ 812e1ee1f7SDomen Puncer stw r8, 0x4(r4) 822e1ee1f7SDomen Puncer sync 832e1ee1f7SDomen Puncer 842e1ee1f7SDomen Puncer oris r8, r8, 0x5000 852e1ee1f7SDomen Puncer xoris r8, r8, 0x4000 /* ref_en !cke */ 862e1ee1f7SDomen Puncer stw r8, 0x4(r4) 872e1ee1f7SDomen Puncer sync 882e1ee1f7SDomen Puncer 892e1ee1f7SDomen Puncer /* disable SDRAM clock */ 902e1ee1f7SDomen Puncer lwz r8, 0x14(r5) /* cdm->clkenable */ 912e1ee1f7SDomen Puncer ori r8, r8, 0x0008 922e1ee1f7SDomen Puncer xori r8, r8, 0x0008 932e1ee1f7SDomen Puncer stw r8, 0x14(r5) 942e1ee1f7SDomen Puncer sync 952e1ee1f7SDomen Puncer 962e1ee1f7SDomen Puncer 972e1ee1f7SDomen Puncer /* put mpc5200 to sleep */ 982e1ee1f7SDomen Puncer mfmsr r10 992e1ee1f7SDomen Puncer oris r10, r10, 0x0004 /* POW = 1 */ 1002e1ee1f7SDomen Puncer sync; isync; 1012e1ee1f7SDomen Puncer mtmsr r10 1022e1ee1f7SDomen Puncer sync; isync; 1032e1ee1f7SDomen Puncer 1042e1ee1f7SDomen Puncer 1052e1ee1f7SDomen Puncer /* enable clock */ 1062e1ee1f7SDomen Puncer lwz r8, 0x14(r5) 1072e1ee1f7SDomen Puncer ori r8, r8, 0x0008 1082e1ee1f7SDomen Puncer stw r8, 0x14(r5) 1092e1ee1f7SDomen Puncer sync 1102e1ee1f7SDomen Puncer 1112e1ee1f7SDomen Puncer /* get ram out of self-refresh */ 1122e1ee1f7SDomen Puncer lwz r8, 0x4(r4) 1132e1ee1f7SDomen Puncer oris r8, r8, 0x5000 /* cke ref_en */ 1142e1ee1f7SDomen Puncer stw r8, 0x4(r4) 1152e1ee1f7SDomen Puncer sync 1162e1ee1f7SDomen Puncer 1172e1ee1f7SDomen Puncer blr 1182e1ee1f7SDomen Puncer_GLOBAL(mpc52xx_ds_sram_size) 1192e1ee1f7SDomen Puncermpc52xx_ds_sram_size: 1202e1ee1f7SDomen Puncer .long $-mpc52xx_ds_sram 1212e1ee1f7SDomen Puncer 1222e1ee1f7SDomen Puncer 1232e1ee1f7SDomen Puncer/* ### interrupt handler for wakeup from deep-sleep ### */ 1242e1ee1f7SDomen Puncer_GLOBAL(mpc52xx_ds_cached) 1252e1ee1f7SDomen Puncermpc52xx_ds_cached: 1262e1ee1f7SDomen Puncer mtspr SPRN_SPRG0, r7 1272e1ee1f7SDomen Puncer mtspr SPRN_SPRG1, r8 1282e1ee1f7SDomen Puncer 1292e1ee1f7SDomen Puncer /* disable emulated interrupt */ 1302e1ee1f7SDomen Puncer mfspr r7, 311 /* MBAR */ 1312e1ee1f7SDomen Puncer addi r7, r7, 0x540 /* intr->main_emul */ 1322e1ee1f7SDomen Puncer li r8, 0 1332e1ee1f7SDomen Puncer stw r8, 0(r7) 1342e1ee1f7SDomen Puncer sync 1352e1ee1f7SDomen Puncer dcbf 0, r7 1362e1ee1f7SDomen Puncer 1372e1ee1f7SDomen Puncer /* acknowledge wakeup, so CCS releases power pown */ 1382e1ee1f7SDomen Puncer mfspr r7, 311 /* MBAR */ 1392e1ee1f7SDomen Puncer addi r7, r7, 0x524 /* intr->enc_status */ 1402e1ee1f7SDomen Puncer lwz r8, 0(r7) 1412e1ee1f7SDomen Puncer ori r8, r8, 0x0400 1422e1ee1f7SDomen Puncer stw r8, 0(r7) 1432e1ee1f7SDomen Puncer sync 1442e1ee1f7SDomen Puncer dcbf 0, r7 1452e1ee1f7SDomen Puncer 1462e1ee1f7SDomen Puncer /* flag - we handled the interrupt */ 1472e1ee1f7SDomen Puncer li r10, 1 1482e1ee1f7SDomen Puncer 1492e1ee1f7SDomen Puncer mfspr r8, SPRN_SPRG1 1502e1ee1f7SDomen Puncer mfspr r7, SPRN_SPRG0 1512e1ee1f7SDomen Puncer 1522e1ee1f7SDomen Puncer rfi 1532e1ee1f7SDomen Puncer_GLOBAL(mpc52xx_ds_cached_size) 1542e1ee1f7SDomen Puncermpc52xx_ds_cached_size: 1552e1ee1f7SDomen Puncer .long $-mpc52xx_ds_cached 156