xref: /optee_os/core/drivers/pm/sam/pm_suspend.S (revision b22418eb66e3ccb261c00e5284f194e82d20e893)
1/* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */
2/*
3 * This file was imported from Linux arch/arm/mach-at91/pm_suspend.S and
4 * relicensed with dual GPL-2.0/BSD-2-Clause with Microchip agreement.
5 *
6 * Copyright (c) 2021, Microchip
7 */
8
9#include <arm.h>
10#include <arm32_macros.S>
11#include <asm.S>
12#include <at91_pmc.h>
13#include <drivers/sam/at91_ddr.h>
14#include <generated/pm-defines.h>
15
16#include "at91_pm.h"
17
18#define	SRAMC_SELF_FRESH_ACTIVE		0x01
19#define	SRAMC_SELF_FRESH_EXIT		0x00
20
21pmc	.req	r0
22tmp1	.req	r4
23tmp2	.req	r5
24tmp3	.req	r6
25
26/*
27 * Wait until master clock is ready (after switching master clock source)
28 * @r_mckid:	register holding master clock identifier
29 *
30 * Side effects: overwrites tmp1
31 */
32.macro wait_mckrdy r_mckid
33#ifdef CFG_SAMA7G5
34	cmp	\r_mckid, #0
35	beq	1f
362:	ldr	tmp1, [pmc, #AT91_PMC_SR]
37	tst	tmp1, #AT91_PMC_MCKXRDY
38	beq	2b
39	b	3f
40#endif
411:	ldr	tmp1, [pmc, #AT91_PMC_SR]
42	tst	tmp1, #AT91_PMC_MCKRDY
43	beq	1b
443:
45.endm
46
47/*
48 * Wait until master oscillator has stabilized.
49 */
50.macro wait_moscrdy
511:	ldr	tmp1, [pmc, #AT91_PMC_SR]
52	tst	tmp1, #AT91_PMC_MOSCS
53	beq	1b
54.endm
55
56/*
57 * Wait for main oscillator selection is done
58 */
59.macro wait_moscsels
601:	ldr	tmp1, [pmc, #AT91_PMC_SR]
61	tst	tmp1, #AT91_PMC_MOSCSELS
62	beq	1b
63.endm
64
65/*
66 * Put the processor to enter the idle state
67 */
68.macro at91_cpu_idle
69
70	mov	tmp1, #AT91_PMC_PCK
71	str	tmp1, [pmc, #AT91_PMC_SCDR]
72
73	dsb
74
75	wfi		@ Wait For Interrupt
76
77.endm
78
79.section .text.psci.suspend
80
81.arm
82
83
84#define SUSPEND_FUNC(__name) \
85__name:
86
87#define SUSPEND_END_FUNC(__name) \
88	.size __name, .-__name
89
90.macro check_fit_in_sram since
91	.if (. - \since) > 0x10000
92		.error "Suspend assembly code exceeds dedicated SRAM size"
93	.endif
94.endm
95
96/*
97 * void at91_suspend_sram_fn(struct at91_pm_data*)
98 * @input param:
99 * 	@r0: base address of struct at91_pm_data
100 */
101.align 3
102.global at91_pm_suspend_in_sram
103SUSPEND_FUNC(at91_pm_suspend_in_sram)
104	/* Save registers on stack */
105	stmfd	sp!, {r4 - r12, lr}
106
107	/* Drain write buffer */
108	mov	tmp1, #0
109	mcr	p15, 0, tmp1, c7, c10, 4
110
111	ldr	tmp1, [r0, #PM_DATA_PMC]
112	str	tmp1, .pmc_base
113	ldr	tmp1, [r0, #PM_DATA_RAMC0]
114	str	tmp1, .sramc_base
115	ldr	tmp1, [r0, #PM_DATA_MODE]
116	str	tmp1, .pm_mode
117	/* Both ldrne below are here to preload their address in the TLB */
118	ldr	tmp1, [r0, #PM_DATA_SHDWC]
119	str	tmp1, .shdwc
120	cmp	tmp1, #0
121	ldrne	tmp2, [tmp1, #0]
122	ldr	tmp1, [r0, #PM_DATA_SFRBU]
123	str	tmp1, .sfrbu
124	cmp	tmp1, #0
125	ldrne	tmp2, [tmp1, #0x10]
126
127	/* Active the self-refresh mode */
128	mov	r0, #SRAMC_SELF_FRESH_ACTIVE
129	bl	at91_sramc_self_refresh
130
131	ldr	r0, .pm_mode
132	cmp	r0, #AT91_PM_STANDBY
133	beq	standby
134	cmp	r0, #AT91_PM_BACKUP
135	beq	backup_mode
136
137	bl	at91_ulp_mode
138	b	exit_suspend
139
140standby:
141	/* Wait for interrupt */
142	ldr	pmc, .pmc_base
143	at91_cpu_idle
144	b	exit_suspend
145
146backup_mode:
147	bl	at91_backup_mode
148	b	exit_suspend
149
150exit_suspend:
151	/* Exit the self-refresh mode */
152	mov	r0, #SRAMC_SELF_FRESH_EXIT
153	bl	at91_sramc_self_refresh
154
155	/* Restore registers, and return */
156	ldmfd	sp!, {r4 - r12, pc}
157SUSPEND_END_FUNC(at91_pm_suspend_in_sram)
158
159SUSPEND_FUNC(at91_backup_mode)
160	/* Switch the master clock source to slow clock. */
161	ldr	pmc, .pmc_base
162	ldr	tmp1, [pmc, #AT91_PMC_MCKR]
163	bic	tmp1, tmp1, #AT91_PMC_CSS
164	str	tmp1, [pmc, #AT91_PMC_MCKR]
165
166	mov	tmp3, #0
167	wait_mckrdy tmp3
168
169	/*BUMEN*/
170	ldr	r0, .sfrbu
171	mov	tmp1, #0x1
172	str	tmp1, [r0, #0x10]
173
174	/* Shutdown */
175	ldr	r0, .shdwc
176	mov	tmp1, #0xA5000000
177	add	tmp1, tmp1, #0x1
178	str	tmp1, [r0, #0]
179SUSPEND_END_FUNC(at91_backup_mode)
180
181.macro at91_pm_ulp0_mode
182	ldr	pmc, .pmc_base
183	ldr	tmp2, .pm_mode
184
185	/* Check if ULP0 fast variant has been requested. */
186	cmp	tmp2, #AT91_PM_ULP0_FAST
187	bne	0f
188
189	/* Set highest prescaler for power saving */
190	ldr	tmp1, [pmc, #AT91_PMC_MCKR]
191	bic	tmp1, tmp1, #AT91_PMC_PRES
192	orr	tmp1, tmp1, #AT91_PMC_PRES_64
193	str	tmp1, [pmc, #AT91_PMC_MCKR]
194
195	mov	tmp3, #0
196	wait_mckrdy tmp3
197	b	1f
198
1990:
200	/* Turn off the crystal oscillator */
201	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
202	bic	tmp1, tmp1, #AT91_PMC_MOSCEN
203	orr	tmp1, tmp1, #AT91_PMC_KEY
204	str	tmp1, [pmc, #AT91_CKGR_MOR]
205
206	/* Save RC oscillator state */
207	ldr	tmp1, [pmc, #AT91_PMC_SR]
208	str	tmp1, .saved_osc_status
209	tst	tmp1, #AT91_PMC_MOSCRCS
210	bne	1f
211
212	/* Turn off RC oscillator */
213	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
214	bic	tmp1, tmp1, #AT91_PMC_MOSCRCEN
215	bic	tmp1, tmp1, #AT91_PMC_KEY_MASK
216	orr	tmp1, tmp1, #AT91_PMC_KEY
217	str	tmp1, [pmc, #AT91_CKGR_MOR]
218
219	/* Wait main RC disabled done */
2202:	ldr	tmp1, [pmc, #AT91_PMC_SR]
221	tst	tmp1, #AT91_PMC_MOSCRCS
222	bne	2b
223
224	/* Wait for interrupt */
2251:	at91_cpu_idle
226
227	/* Check if ULP0 fast variant has been requested. */
228	cmp	tmp2, #AT91_PM_ULP0_FAST
229	bne	5f
230
231	/* Set lowest prescaler for fast resume. */
232	ldr	tmp1, [pmc, #AT91_PMC_MCKR]
233	bic	tmp1, tmp1, #AT91_PMC_PRES
234	str	tmp1, [pmc, #AT91_PMC_MCKR]
235
236	mov	tmp3, #0
237	wait_mckrdy tmp3
238	b	6f
239
2405:	/* Restore RC oscillator state */
241	ldr	tmp1, .saved_osc_status
242	tst	tmp1, #AT91_PMC_MOSCRCS
243	beq	4f
244
245	/* Turn on RC oscillator */
246	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
247	orr	tmp1, tmp1, #AT91_PMC_MOSCRCEN
248	bic	tmp1, tmp1, #AT91_PMC_KEY_MASK
249	orr	tmp1, tmp1, #AT91_PMC_KEY
250	str	tmp1, [pmc, #AT91_CKGR_MOR]
251
252	/* Wait main RC stabilization */
2533:	ldr	tmp1, [pmc, #AT91_PMC_SR]
254	tst	tmp1, #AT91_PMC_MOSCRCS
255	beq	3b
256
257	/* Turn on the crystal oscillator */
2584:	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
259	orr	tmp1, tmp1, #AT91_PMC_MOSCEN
260	orr	tmp1, tmp1, #AT91_PMC_KEY
261	str	tmp1, [pmc, #AT91_CKGR_MOR]
262
263	wait_moscrdy
2646:
265.endm
266
267/**
268 * Note: This procedure only applies on the platform which uses
269 * the external crystal oscillator as a main clock source.
270 */
271.macro at91_pm_ulp1_mode
272	ldr	pmc, .pmc_base
273
274	/* Save RC oscillator state and check if it is enabled. */
275	ldr	tmp1, [pmc, #AT91_PMC_SR]
276	str	tmp1, .saved_osc_status
277	tst	tmp1, #AT91_PMC_MOSCRCS
278	bne	2f
279
280	/* Enable RC oscillator */
281	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
282	orr	tmp1, tmp1, #AT91_PMC_MOSCRCEN
283	bic	tmp1, tmp1, #AT91_PMC_KEY_MASK
284	orr	tmp1, tmp1, #AT91_PMC_KEY
285	str	tmp1, [pmc, #AT91_CKGR_MOR]
286
287	/* Wait main RC stabilization */
2881:	ldr	tmp1, [pmc, #AT91_PMC_SR]
289	tst	tmp1, #AT91_PMC_MOSCRCS
290	beq	1b
291
292	/* Switch the main clock source to 12-MHz RC oscillator */
2932:	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
294	bic	tmp1, tmp1, #AT91_PMC_MOSCSEL
295	bic	tmp1, tmp1, #AT91_PMC_KEY_MASK
296	orr	tmp1, tmp1, #AT91_PMC_KEY
297	str	tmp1, [pmc, #AT91_CKGR_MOR]
298
299	wait_moscsels
300
301	/* Disable the crystal oscillator */
302	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
303	bic	tmp1, tmp1, #AT91_PMC_MOSCEN
304	bic	tmp1, tmp1, #AT91_PMC_KEY_MASK
305	orr	tmp1, tmp1, #AT91_PMC_KEY
306	str	tmp1, [pmc, #AT91_CKGR_MOR]
307
308	/* Switch the master clock source to main clock */
309	ldr	tmp1, [pmc, #AT91_PMC_MCKR]
310	bic	tmp1, tmp1, #AT91_PMC_CSS
311	orr	tmp1, tmp1, #AT91_PMC_CSS_MAIN
312	str	tmp1, [pmc, #AT91_PMC_MCKR]
313
314	mov	tmp3, #0
315	wait_mckrdy tmp3
316
317	/* Enter the ULP1 mode by set WAITMODE bit in CKGR_MOR */
318	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
319	orr	tmp1, tmp1, #AT91_PMC_WAITMODE
320	bic	tmp1, tmp1, #AT91_PMC_KEY_MASK
321	orr	tmp1, tmp1, #AT91_PMC_KEY
322	str	tmp1, [pmc, #AT91_CKGR_MOR]
323
324	/* Quirk for SAM9X60's PMC */
325	nop
326	nop
327
328	wait_mckrdy tmp3
329
330	/* Enable the crystal oscillator */
331	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
332	orr	tmp1, tmp1, #AT91_PMC_MOSCEN
333	bic	tmp1, tmp1, #AT91_PMC_KEY_MASK
334	orr	tmp1, tmp1, #AT91_PMC_KEY
335	str	tmp1, [pmc, #AT91_CKGR_MOR]
336
337	wait_moscrdy
338
339	/* Switch the master clock source to slow clock */
340	ldr	tmp1, [pmc, #AT91_PMC_MCKR]
341	bic	tmp1, tmp1, #AT91_PMC_CSS
342	str	tmp1, [pmc, #AT91_PMC_MCKR]
343
344	wait_mckrdy tmp3
345
346	/* Switch main clock source to crystal oscillator */
347	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
348	orr	tmp1, tmp1, #AT91_PMC_MOSCSEL
349	bic	tmp1, tmp1, #AT91_PMC_KEY_MASK
350	orr	tmp1, tmp1, #AT91_PMC_KEY
351	str	tmp1, [pmc, #AT91_CKGR_MOR]
352
353	wait_moscsels
354
355	/* Switch the master clock source to main clock */
356	ldr	tmp1, [pmc, #AT91_PMC_MCKR]
357	bic	tmp1, tmp1, #AT91_PMC_CSS
358	orr	tmp1, tmp1, #AT91_PMC_CSS_MAIN
359	str	tmp1, [pmc, #AT91_PMC_MCKR]
360
361	wait_mckrdy tmp3
362
363	/* Restore RC oscillator state */
364	ldr	tmp1, .saved_osc_status
365	tst	tmp1, #AT91_PMC_MOSCRCS
366	bne	3f
367
368	/* Disable RC oscillator */
369	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
370	bic	tmp1, tmp1, #AT91_PMC_MOSCRCEN
371	bic	tmp1, tmp1, #AT91_PMC_KEY_MASK
372	orr	tmp1, tmp1, #AT91_PMC_KEY
373	str	tmp1, [pmc, #AT91_CKGR_MOR]
374
375	/* Wait RC oscillator disable done */
3764:	ldr	tmp1, [pmc, #AT91_PMC_SR]
377	tst	tmp1, #AT91_PMC_MOSCRCS
378	bne	4b
379
3803:
381.endm
382
383/*
384 * Save PLLA setting and disable it
385 *
386 * Side effects: overwrites tmp1, tmp2
387 */
388.macro at91_plla_disable
389#ifdef CFG_SAMA7G5
390	/* Save PLLA settings */
391	ldr	tmp2, [pmc, #AT91_PMC_PLL_UPDT]
392	bic	tmp2, tmp2, #AT91_PMC_PLL_UPDT_ID
393	str	tmp2, [pmc, #AT91_PMC_PLL_UPDT]
394
395	/* save div */
396	mov	tmp1, #0
397	ldr	tmp2, [pmc, #AT91_PMC_PLL_CTRL0]
398	bic	tmp2, tmp2, #0xffffff00
399	orr	tmp1, tmp1, tmp2
400
401	/* save mul */
402	ldr	tmp2, [pmc, #AT91_PMC_PLL_CTRL1]
403	bic	tmp2, tmp2, #0xffffff
404	orr	tmp1, tmp1, tmp2
405	str	tmp1, .saved_pllar
406
407	/* step 2 */
408	ldr	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
409	bic	tmp1, tmp1, #AT91_PMC_PLL_UPDT_UPDATE
410	bic	tmp1, tmp1, #AT91_PMC_PLL_UPDT_ID
411	str	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
412
413	/* step 3 */
414	ldr	tmp1, [pmc, #AT91_PMC_PLL_CTRL0]
415	bic	tmp1, tmp1, #AT91_PMC_PLL_CTRL0_ENPLLCK
416	orr	tmp1, tmp1, #AT91_PMC_PLL_CTRL0_ENPLL
417	str	tmp1, [pmc, #AT91_PMC_PLL_CTRL0]
418
419	/* step 4 */
420	ldr	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
421	orr	tmp1, tmp1, #AT91_PMC_PLL_UPDT_UPDATE
422	bic	tmp1, tmp1, #AT91_PMC_PLL_UPDT_ID
423	str	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
424
425	/* step 5 */
426	ldr	tmp1, [pmc, #AT91_PMC_PLL_CTRL0]
427	bic	tmp1, tmp1, #AT91_PMC_PLL_CTRL0_ENPLL
428	str	tmp1, [pmc, #AT91_PMC_PLL_CTRL0]
429
430	/* step 6 */
431	ldr	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
432	orr	tmp1, tmp1, #AT91_PMC_PLL_UPDT_UPDATE
433	bic	tmp1, tmp1, #AT91_PMC_PLL_UPDT_ID
434	str	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
435#else
436	/* Save PLLA setting and disable it */
437	ldr	tmp1, [pmc, #AT91_CKGR_PLLAR]
438	str	tmp1, .saved_pllar
439
440	/* Disable PLLA. */
441	mov	tmp1, #AT91_PMC_PLLCOUNT
442	orr	tmp1, tmp1, #(1 << 29)		/* bit 29 always set */
443	str	tmp1, [pmc, #AT91_CKGR_PLLAR]
444#endif
4452:
446.endm
447
448/*
449 * Enable PLLA with the saved setting
450 *
451 * Side effects: overwrites tmp1, tmp2
452 */
453.macro at91_plla_enable
454#ifdef CFG_SAMA7G5
455	/* step 1 */
456	ldr	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
457	bic	tmp1, tmp1, #AT91_PMC_PLL_UPDT_ID
458	bic	tmp1, tmp1, #AT91_PMC_PLL_UPDT_UPDATE
459	str	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
460
461	/* step 2 */
462	ldr	tmp1, =AT91_PMC_PLL_ACR_DEFAULT_PLLA
463	str	tmp1, [pmc, #AT91_PMC_PLL_ACR]
464
465	/* step 3 */
466	ldr	tmp1, [pmc, #AT91_PMC_PLL_CTRL1]
467	ldr	tmp2, .saved_pllar
468	bic	tmp2, tmp2, #0xffffff
469	orr	tmp1, tmp1, tmp2
470	str	tmp1, [pmc, #AT91_PMC_PLL_CTRL1]
471
472	/* step 4 */
473	ldr	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
474	bic	tmp1, tmp1, #AT91_PMC_PLL_UPDT_ID
475	orr	tmp1, tmp1, #AT91_PMC_PLL_UPDT_UPDATE
476	str	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
477
478	/* step 5 */
479	ldr	tmp1, [pmc, #AT91_PMC_PLL_CTRL0]
480	orr	tmp1, tmp1, #AT91_PMC_PLL_CTRL0_ENLOCK
481	orr	tmp1, tmp1, #AT91_PMC_PLL_CTRL0_ENPLL
482	orr	tmp1, tmp1, #AT91_PMC_PLL_CTRL0_ENPLLCK
483	bic	tmp1, tmp1, #0xff
484	ldr	tmp2, .saved_pllar
485	bic	tmp2, tmp2, #0xffffff00
486	orr	tmp1, tmp1, tmp2
487	str	tmp1, [pmc, #AT91_PMC_PLL_CTRL0]
488
489	/* step 6 */
490	ldr	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
491	orr	tmp1, tmp1, #AT91_PMC_PLL_UPDT_UPDATE
492	bic	tmp1, tmp1, #AT91_PMC_PLL_UPDT_ID
493	str	tmp1, [pmc, #AT91_PMC_PLL_UPDT]
494
495	/* step 7 */
4963:	ldr	tmp1, [pmc, #AT91_PMC_PLL_ISR0]
497	tst	tmp1, #0x1
498	beq	3b
499#else
500	ldr	tmp2, .saved_pllar
501
502	/* Restore PLLA setting */
503	str	tmp2, [pmc, #AT91_CKGR_PLLAR]
504
505	/* Enable PLLA. */
506	tst	tmp2, #(AT91_PMC_MUL &  0xff0000)
507	bne	1f
508	tst	tmp2, #(AT91_PMC_MUL & ~0xff0000)
509	beq	2f
510
5111:	ldr	tmp1, [pmc, #AT91_PMC_SR]
512	tst	tmp1, #AT91_PMC_LOCKA
513	beq	1b
5142:
515#endif
516.endm
517
518SUSPEND_FUNC(at91_ulp_mode)
519	ldr	pmc, .pmc_base
520	ldr	tmp3, .pm_mode
521
522	/* Save Master clock setting */
523	ldr	tmp1, [pmc, #AT91_PMC_MCKR]
524	str	tmp1, .saved_mckr
525
526	/*
527	 * Set master clock source to:
528	 * - MAINCK if using ULP0 fast variant
529	 * - slow clock, otherwise
530	 */
531	bic	tmp1, tmp1, #AT91_PMC_CSS
532	cmp	tmp3, #AT91_PM_ULP0_FAST
533	bne	save_mck
534	orr	tmp1, tmp1, #AT91_PMC_CSS_MAIN
535save_mck:
536	str	tmp1, [pmc, #AT91_PMC_MCKR]
537
538	mov	tmp3, #0
539	wait_mckrdy tmp3
540
541	at91_plla_disable
542
543	ldr	tmp3, .pm_mode
544	cmp	tmp3, #AT91_PM_ULP1
545	beq	ulp1_mode
546
547	at91_pm_ulp0_mode
548	b	ulp_exit
549
550ulp1_mode:
551	at91_pm_ulp1_mode
552	b	ulp_exit
553
554ulp_exit:
555	ldr	pmc, .pmc_base
556
557	at91_plla_enable
558
559	/*
560	 * Restore master clock setting
561	 */
562	ldr	tmp2, .saved_mckr
563	str	tmp2, [pmc, #AT91_PMC_MCKR]
564
565	mov	tmp3, #0
566	wait_mckrdy tmp3
567
568	mov	pc, lr
569SUSPEND_END_FUNC(at91_ulp_mode)
570
571/*
572 * void at91_sramc_self_refresh(unsigned int is_active)
573 *
574 * @input param:
575 *	@r0: 1 - active self-refresh mode
576 *	     0 - exit self-refresh mode
577 * register usage:
578 *	@r2: base address of the sram controller
579 */
580
581SUSPEND_FUNC(at91_sramc_self_refresh)
582	ldr	r2, .sramc_base
583
584	/*
585	 * DDR Memory controller
586	 */
587	tst	r0, #SRAMC_SELF_FRESH_ACTIVE
588	beq	ddrc_exit_sf
589
590	/* LPDDR1 --> force DDR2 mode during self-refresh */
591	ldr	r3, [r2, #AT91_DDRSDRC_MDR]
592	str	r3, .saved_sam9_mdr
593	bic	r3, r3, #~AT91_DDRSDRC_MD
594	cmp	r3, #AT91_DDRSDRC_MD_LOW_POWER_DDR
595	ldreq	r3, [r2, #AT91_DDRSDRC_MDR]
596	biceq	r3, r3, #AT91_DDRSDRC_MD
597	orreq	r3, r3, #AT91_DDRSDRC_MD_DDR2
598	streq	r3, [r2, #AT91_DDRSDRC_MDR]
599
600	/* Active DDRC self-refresh mode */
601	ldr	r3, [r2, #AT91_DDRSDRC_LPR]
602	str	r3, .saved_sam9_lpr
603	bic	r3, r3, #AT91_DDRSDRC_LPCB
604	orr	r3, r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH
605	str	r3, [r2, #AT91_DDRSDRC_LPR]
606
607	b	exit_sramc_sf
608
609ddrc_exit_sf:
610	/* Restore MDR in case of LPDDR1 */
611	ldr	r3, .saved_sam9_mdr
612	str	r3, [r2, #AT91_DDRSDRC_MDR]
613	/* Restore LPR on AT91 with DDRAM */
614	ldr	r3, .saved_sam9_lpr
615	str	r3, [r2, #AT91_DDRSDRC_LPR]
616
617exit_sramc_sf:
618	mov	pc, lr
619SUSPEND_END_FUNC(at91_sramc_self_refresh)
620
621.pmc_base:
622	.word 0
623.sramc_base:
624	.word 0
625.shdwc:
626	.word 0
627.sfrbu:
628	.word 0
629.pm_mode:
630	.word 0
631.saved_mckr:
632	.word 0
633.saved_pllar:
634	.word 0
635.saved_sam9_lpr:
636	.word 0
637.saved_sam9_mdr:
638	.word 0
639.saved_osc_status:
640	.word 0
641
642.global at91_pm_suspend_in_sram_sz
643at91_pm_suspend_in_sram_sz:
644	.word .-at91_pm_suspend_in_sram
645
646check_fit_in_sram at91_pm_suspend_in_sram
647