1*0fdebc5eSThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */ 226705ca4STodd Poynor/* 326705ca4STodd Poynor * PXA27x standby mode 426705ca4STodd Poynor * 526705ca4STodd Poynor * Author: David Burrage 626705ca4STodd Poynor * 7*0fdebc5eSThomas Gleixner * 2005 (c) MontaVista Software, Inc. 826705ca4STodd Poynor */ 926705ca4STodd Poynor 1026705ca4STodd Poynor#include <linux/linkage.h> 1126705ca4STodd Poynor#include <asm/assembler.h> 1226705ca4STodd Poynor 13e6acc406SArnd Bergmann#include "pxa2xx-regs.h" 1426705ca4STodd Poynor 1526705ca4STodd Poynor .text 1626705ca4STodd Poynor 17533462fbSRussell King#ifdef CONFIG_PXA27x 1826705ca4STodd PoynorENTRY(pxa_cpu_standby) 1926705ca4STodd Poynor ldr r0, =PSSR 2026705ca4STodd Poynor mov r1, #(PSSR_PH | PSSR_STS) 2180a18573STodd Poynor mov r2, #PWRMODE_STANDBY 2226705ca4STodd Poynor mov r3, #UNCACHED_PHYS_0 @ Read mem context in. 2326705ca4STodd Poynor ldr ip, [r3] 2426705ca4STodd Poynor b 1f 2526705ca4STodd Poynor 2626705ca4STodd Poynor .align 5 2726705ca4STodd Poynor1: mcr p14, 0, r2, c7, c0, 0 @ put the system into Standby 2826705ca4STodd Poynor str r1, [r0] @ make sure PSSR_PH/STS are clear 296ebbf2ceSRussell King ret lr 30533462fbSRussell King 31533462fbSRussell King#endif 327b5dea12SRussell King 337b5dea12SRussell King#ifdef CONFIG_PXA3xx 347b5dea12SRussell King 35ffdf7862SRussell King#define PXA3_MDCNFG 0x0000 36ffdf7862SRussell King#define PXA3_MDCNFG_DMCEN (1 << 30) 37ffdf7862SRussell King#define PXA3_DDR_HCAL 0x0060 38ffdf7862SRussell King#define PXA3_DDR_HCAL_HCRNG 0x1f 39ffdf7862SRussell King#define PXA3_DDR_HCAL_HCPROG (1 << 28) 40ffdf7862SRussell King#define PXA3_DDR_HCAL_HCEN (1 << 31) 41ffdf7862SRussell King#define PXA3_DMCIER 0x0070 42ffdf7862SRussell King#define PXA3_DMCIER_EDLP (1 << 29) 43ffdf7862SRussell King#define PXA3_DMCISR 0x0078 44ffdf7862SRussell King#define PXA3_RCOMP 0x0100 45ffdf7862SRussell King#define PXA3_RCOMP_SWEVAL (1 << 31) 467b5dea12SRussell King 477b5dea12SRussell KingENTRY(pm_enter_standby_start) 48ffdf7862SRussell King mov r1, #0xf6000000 @ DMEMC_REG_BASE (PXA3_MDCNFG) 497b5dea12SRussell King add r1, r1, #0x00100000 507b5dea12SRussell King 517b5dea12SRussell King /* 527b5dea12SRussell King * Preload the TLB entry for accessing the dynamic memory 537b5dea12SRussell King * controller registers. Note that page table lookups will 547b5dea12SRussell King * fail until the dynamic memory controller has been 557b5dea12SRussell King * reinitialised - and that includes MMU page table walks. 567b5dea12SRussell King * This also means that only the dynamic memory controller 577b5dea12SRussell King * can be reliably accessed in the code following standby. 587b5dea12SRussell King */ 59ffdf7862SRussell King ldr r2, [r1] @ Dummy read PXA3_MDCNFG 607b5dea12SRussell King 617b5dea12SRussell King mcr p14, 0, r0, c7, c0, 0 627b5dea12SRussell King .rept 8 637b5dea12SRussell King nop 647b5dea12SRussell King .endr 657b5dea12SRussell King 66ffdf7862SRussell King ldr r0, [r1, #PXA3_DDR_HCAL] @ Clear (and wait for) HCEN 67ffdf7862SRussell King bic r0, r0, #PXA3_DDR_HCAL_HCEN 68ffdf7862SRussell King str r0, [r1, #PXA3_DDR_HCAL] 69ffdf7862SRussell King1: ldr r0, [r1, #PXA3_DDR_HCAL] 70ffdf7862SRussell King tst r0, #PXA3_DDR_HCAL_HCEN 717b5dea12SRussell King bne 1b 727b5dea12SRussell King 73ffdf7862SRussell King ldr r0, [r1, #PXA3_RCOMP] @ Initiate RCOMP 74ffdf7862SRussell King orr r0, r0, #PXA3_RCOMP_SWEVAL 75ffdf7862SRussell King str r0, [r1, #PXA3_RCOMP] 767b5dea12SRussell King 777b5dea12SRussell King mov r0, #~0 @ Clear interrupts 78ffdf7862SRussell King str r0, [r1, #PXA3_DMCISR] 797b5dea12SRussell King 80ffdf7862SRussell King ldr r0, [r1, #PXA3_DMCIER] @ set DMIER[EDLP] 81ffdf7862SRussell King orr r0, r0, #PXA3_DMCIER_EDLP 82ffdf7862SRussell King str r0, [r1, #PXA3_DMCIER] 837b5dea12SRussell King 84ffdf7862SRussell King ldr r0, [r1, #PXA3_DDR_HCAL] @ clear HCRNG, set HCPROG, HCEN 85ffdf7862SRussell King bic r0, r0, #PXA3_DDR_HCAL_HCRNG 86ffdf7862SRussell King orr r0, r0, #PXA3_DDR_HCAL_HCEN | PXA3_DDR_HCAL_HCPROG 87ffdf7862SRussell King str r0, [r1, #PXA3_DDR_HCAL] 887b5dea12SRussell King 89ffdf7862SRussell King1: ldr r0, [r1, #PXA3_DMCISR] 90ffdf7862SRussell King tst r0, #PXA3_DMCIER_EDLP 917b5dea12SRussell King beq 1b 927b5dea12SRussell King 93ffdf7862SRussell King ldr r0, [r1, #PXA3_MDCNFG] @ set PXA3_MDCNFG[DMCEN] 94ffdf7862SRussell King orr r0, r0, #PXA3_MDCNFG_DMCEN 95ffdf7862SRussell King str r0, [r1, #PXA3_MDCNFG] 96ffdf7862SRussell King1: ldr r0, [r1, #PXA3_MDCNFG] 97ffdf7862SRussell King tst r0, #PXA3_MDCNFG_DMCEN 987b5dea12SRussell King beq 1b 997b5dea12SRussell King 100ffdf7862SRussell King ldr r0, [r1, #PXA3_DDR_HCAL] @ set PXA3_DDR_HCAL[HCRNG] 1017b5dea12SRussell King orr r0, r0, #2 @ HCRNG 102ffdf7862SRussell King str r0, [r1, #PXA3_DDR_HCAL] 1037b5dea12SRussell King 104ffdf7862SRussell King ldr r0, [r1, #PXA3_DMCIER] @ Clear the interrupt 1057b5dea12SRussell King bic r0, r0, #0x20000000 106ffdf7862SRussell King str r0, [r1, #PXA3_DMCIER] 1077b5dea12SRussell King 1086ebbf2ceSRussell King ret lr 1097b5dea12SRussell KingENTRY(pm_enter_standby_end) 1107b5dea12SRussell King 1117b5dea12SRussell King#endif 112