2019-06-04 15:11:33 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2008-09-22 03:35:18 +07:00
|
|
|
/*
|
|
|
|
* arch/arm/mach-at91/pm_slow_clock.S
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Savin Zlobec
|
|
|
|
*
|
|
|
|
* AT91SAM9 support:
|
2017-03-28 17:26:18 +07:00
|
|
|
* Copyright (C) 2007 Anti Sullin <anti.sullin@artecdesign.ee>
|
2008-09-22 03:35:18 +07:00
|
|
|
*/
|
|
|
|
#include <linux/linkage.h>
|
2013-10-11 14:37:45 +07:00
|
|
|
#include <linux/clk/at91_pmc.h>
|
2015-03-09 10:49:46 +07:00
|
|
|
#include "pm.h"
|
ARM: at91: move platform-specific asm-offset.h to arch/arm/mach-at91
<generated/at91_pm_data-offsets.h> is only generated and included by
arch/arm/mach-at91/, so it does not need to reside in the globally
visible include/generated/.
I renamed it to arch/arm/mach-at91/pm_data-offsets.h since the prefix
'at91_' is just redundant in mach-at91/.
My main motivation of this change is to avoid the race condition for
the parallel build (-j) when CONFIG_IKHEADERS is enabled.
When it is enabled, all the headers under include/ are archived into
kernel/kheaders_data.tar.xz and exposed in the sysfs.
In the parallel build, we have no idea in which order files are built.
- If at91_pm_data-offsets.h is built before kheaders_data.tar.xz,
the header will be included in the archive. Probably nobody will
use it, but it is harmless except that it will increase the archive
size needlessly.
- If kheaders_data.tar.xz is built before at91_pm_data-offsets.h,
the header will not be included in the archive. However, in the next
build, the archive will be re-generated to include the newly-found
at91_pm_data-offsets.h. This is not nice from the build system point
of view.
- If at91_pm_data-offsets.h and kheaders_data.tar.xz are built at the
same time, the corrupted header might be included in the archive,
which does not look nice either.
This commit fixes the race.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Link: https://lore.kernel.org/r/20190823024346.591-1-yamada.masahiro@socionext.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-08-23 09:43:45 +07:00
|
|
|
#include "pm_data-offsets.h"
|
2008-09-22 03:35:18 +07:00
|
|
|
|
2015-03-09 10:48:26 +07:00
|
|
|
#define SRAMC_SELF_FRESH_ACTIVE 0x01
|
|
|
|
#define SRAMC_SELF_FRESH_EXIT 0x00
|
|
|
|
|
2012-02-22 23:50:54 +07:00
|
|
|
pmc .req r0
|
2012-02-22 23:50:55 +07:00
|
|
|
tmp1 .req r4
|
|
|
|
tmp2 .req r5
|
2008-09-22 03:35:18 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait until master clock is ready (after switching master clock source)
|
|
|
|
*/
|
|
|
|
.macro wait_mckrdy
|
2015-02-05 13:00:37 +07:00
|
|
|
1: ldr tmp1, [pmc, #AT91_PMC_SR]
|
2012-02-22 23:50:53 +07:00
|
|
|
tst tmp1, #AT91_PMC_MCKRDY
|
2008-09-22 03:35:18 +07:00
|
|
|
beq 1b
|
|
|
|
.endm
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait until master oscillator has stabilized.
|
|
|
|
*/
|
|
|
|
.macro wait_moscrdy
|
2015-02-05 13:00:37 +07:00
|
|
|
1: ldr tmp1, [pmc, #AT91_PMC_SR]
|
2012-02-22 23:50:53 +07:00
|
|
|
tst tmp1, #AT91_PMC_MOSCS
|
2008-09-22 03:35:18 +07:00
|
|
|
beq 1b
|
|
|
|
.endm
|
|
|
|
|
2018-07-17 15:26:55 +07:00
|
|
|
/*
|
|
|
|
* Wait for main oscillator selection is done
|
|
|
|
*/
|
|
|
|
.macro wait_moscsels
|
|
|
|
1: ldr tmp1, [pmc, #AT91_PMC_SR]
|
|
|
|
tst tmp1, #AT91_PMC_MOSCSELS
|
|
|
|
beq 1b
|
|
|
|
.endm
|
|
|
|
|
2015-03-09 10:53:46 +07:00
|
|
|
/*
|
|
|
|
* Put the processor to enter the idle state
|
|
|
|
*/
|
|
|
|
.macro at91_cpu_idle
|
|
|
|
|
|
|
|
#if defined(CONFIG_CPU_V7)
|
|
|
|
mov tmp1, #AT91_PMC_PCK
|
|
|
|
str tmp1, [pmc, #AT91_PMC_SCDR]
|
|
|
|
|
|
|
|
dsb
|
|
|
|
|
|
|
|
wfi @ Wait For Interrupt
|
|
|
|
#else
|
|
|
|
mcr p15, 0, tmp1, c7, c0, 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
.endm
|
|
|
|
|
2008-09-22 03:35:18 +07:00
|
|
|
.text
|
|
|
|
|
2015-03-11 09:08:12 +07:00
|
|
|
.arm
|
|
|
|
|
2015-03-09 10:51:09 +07:00
|
|
|
/*
|
2017-02-01 00:12:57 +07:00
|
|
|
* void at91_suspend_sram_fn(struct at91_pm_data*)
|
2015-03-09 10:51:09 +07:00
|
|
|
* @input param:
|
2017-02-01 00:12:57 +07:00
|
|
|
* @r0: base address of struct at91_pm_data
|
2012-02-22 23:50:55 +07:00
|
|
|
*/
|
2015-10-16 17:39:05 +07:00
|
|
|
/* at91_pm_suspend_in_sram must be 8-byte aligned per the requirements of fncpy() */
|
|
|
|
.align 3
|
2015-03-09 10:51:09 +07:00
|
|
|
ENTRY(at91_pm_suspend_in_sram)
|
2008-09-22 03:35:18 +07:00
|
|
|
/* Save registers on stack */
|
2012-02-22 23:50:55 +07:00
|
|
|
stmfd sp!, {r4 - r12, lr}
|
2008-09-22 03:35:18 +07:00
|
|
|
|
|
|
|
/* Drain write buffer */
|
2012-02-22 23:50:53 +07:00
|
|
|
mov tmp1, #0
|
|
|
|
mcr p15, 0, tmp1, c7, c10, 4
|
2008-09-22 03:35:18 +07:00
|
|
|
|
2017-02-01 00:12:57 +07:00
|
|
|
ldr tmp1, [r0, #PM_DATA_PMC]
|
|
|
|
str tmp1, .pmc_base
|
|
|
|
ldr tmp1, [r0, #PM_DATA_RAMC0]
|
|
|
|
str tmp1, .sramc_base
|
|
|
|
ldr tmp1, [r0, #PM_DATA_RAMC1]
|
|
|
|
str tmp1, .sramc1_base
|
|
|
|
ldr tmp1, [r0, #PM_DATA_MEMCTRL]
|
|
|
|
str tmp1, .memtype
|
|
|
|
ldr tmp1, [r0, #PM_DATA_MODE]
|
|
|
|
str tmp1, .pm_mode
|
2016-09-27 17:29:50 +07:00
|
|
|
/* Both ldrne below are here to preload their address in the TLB */
|
|
|
|
ldr tmp1, [r0, #PM_DATA_SHDWC]
|
|
|
|
str tmp1, .shdwc
|
|
|
|
cmp tmp1, #0
|
|
|
|
ldrne tmp2, [tmp1, #0]
|
|
|
|
ldr tmp1, [r0, #PM_DATA_SFRBU]
|
|
|
|
str tmp1, .sfr
|
|
|
|
cmp tmp1, #0
|
|
|
|
ldrne tmp2, [tmp1, #0x10]
|
2012-02-22 23:50:55 +07:00
|
|
|
|
2015-03-09 10:48:26 +07:00
|
|
|
/* Active the self-refresh mode */
|
|
|
|
mov r0, #SRAMC_SELF_FRESH_ACTIVE
|
|
|
|
bl at91_sramc_self_refresh
|
2012-02-22 23:50:55 +07:00
|
|
|
|
2015-03-09 10:49:46 +07:00
|
|
|
ldr r0, .pm_mode
|
2018-07-17 15:26:55 +07:00
|
|
|
cmp r0, #AT91_PM_STANDBY
|
|
|
|
beq standby
|
2016-09-27 17:29:50 +07:00
|
|
|
cmp r0, #AT91_PM_BACKUP
|
|
|
|
beq backup_mode
|
2015-03-09 10:49:46 +07:00
|
|
|
|
2018-07-17 15:26:55 +07:00
|
|
|
bl at91_ulp_mode
|
|
|
|
b exit_suspend
|
|
|
|
|
|
|
|
standby:
|
2016-09-27 17:29:50 +07:00
|
|
|
/* Wait for interrupt */
|
|
|
|
ldr pmc, .pmc_base
|
|
|
|
at91_cpu_idle
|
|
|
|
b exit_suspend
|
|
|
|
|
|
|
|
backup_mode:
|
|
|
|
bl at91_backup_mode
|
|
|
|
b exit_suspend
|
|
|
|
|
|
|
|
exit_suspend:
|
|
|
|
/* Exit the self-refresh mode */
|
|
|
|
mov r0, #SRAMC_SELF_FRESH_EXIT
|
|
|
|
bl at91_sramc_self_refresh
|
|
|
|
|
|
|
|
/* Restore registers, and return */
|
|
|
|
ldmfd sp!, {r4 - r12, pc}
|
|
|
|
ENDPROC(at91_pm_suspend_in_sram)
|
|
|
|
|
|
|
|
ENTRY(at91_backup_mode)
|
2018-08-30 18:50:06 +07:00
|
|
|
/* Switch the master clock source to slow clock. */
|
|
|
|
ldr pmc, .pmc_base
|
|
|
|
ldr tmp1, [pmc, #AT91_PMC_MCKR]
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_CSS
|
|
|
|
str tmp1, [pmc, #AT91_PMC_MCKR]
|
|
|
|
|
|
|
|
wait_mckrdy
|
|
|
|
|
2016-09-27 17:29:50 +07:00
|
|
|
/*BUMEN*/
|
|
|
|
ldr r0, .sfr
|
|
|
|
mov tmp1, #0x1
|
|
|
|
str tmp1, [r0, #0x10]
|
|
|
|
|
|
|
|
/* Shutdown */
|
|
|
|
ldr r0, .shdwc
|
|
|
|
mov tmp1, #0xA5000000
|
|
|
|
add tmp1, tmp1, #0x1
|
|
|
|
str tmp1, [r0, #0]
|
|
|
|
ENDPROC(at91_backup_mode)
|
|
|
|
|
2018-07-17 15:26:55 +07:00
|
|
|
.macro at91_pm_ulp0_mode
|
|
|
|
ldr pmc, .pmc_base
|
|
|
|
|
|
|
|
/* Turn off the crystal oscillator */
|
|
|
|
ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_MOSCEN
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
2019-02-14 22:55:01 +07:00
|
|
|
/* Save RC oscillator state */
|
|
|
|
ldr tmp1, [pmc, #AT91_PMC_SR]
|
|
|
|
str tmp1, .saved_osc_status
|
|
|
|
tst tmp1, #AT91_PMC_MOSCRCS
|
|
|
|
bne 1f
|
|
|
|
|
|
|
|
/* Turn off RC oscillator */
|
|
|
|
ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_MOSCRCEN
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
|
|
|
/* Wait main RC disabled done */
|
|
|
|
2: ldr tmp1, [pmc, #AT91_PMC_SR]
|
|
|
|
tst tmp1, #AT91_PMC_MOSCRCS
|
|
|
|
bne 2b
|
|
|
|
|
2018-07-17 15:26:55 +07:00
|
|
|
/* Wait for interrupt */
|
2019-02-14 22:55:01 +07:00
|
|
|
1: at91_cpu_idle
|
2018-07-17 15:26:55 +07:00
|
|
|
|
2019-02-14 22:55:01 +07:00
|
|
|
/* Restore RC oscillator state */
|
|
|
|
ldr tmp1, .saved_osc_status
|
|
|
|
tst tmp1, #AT91_PMC_MOSCRCS
|
|
|
|
beq 4f
|
|
|
|
|
|
|
|
/* Turn on RC oscillator */
|
2018-07-17 15:26:55 +07:00
|
|
|
ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
2019-02-14 22:55:01 +07:00
|
|
|
orr tmp1, tmp1, #AT91_PMC_MOSCRCEN
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
|
|
|
/* Wait main RC stabilization */
|
|
|
|
3: ldr tmp1, [pmc, #AT91_PMC_SR]
|
|
|
|
tst tmp1, #AT91_PMC_MOSCRCS
|
|
|
|
beq 3b
|
|
|
|
|
|
|
|
/* Turn on the crystal oscillator */
|
|
|
|
4: ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
2018-07-17 15:26:55 +07:00
|
|
|
orr tmp1, tmp1, #AT91_PMC_MOSCEN
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
|
|
|
wait_moscrdy
|
|
|
|
.endm
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Note: This procedure only applies on the platform which uses
|
|
|
|
* the external crystal oscillator as a main clock source.
|
|
|
|
*/
|
|
|
|
.macro at91_pm_ulp1_mode
|
|
|
|
ldr pmc, .pmc_base
|
|
|
|
|
2019-02-14 22:54:57 +07:00
|
|
|
/* Save RC oscillator state and check if it is enabled. */
|
|
|
|
ldr tmp1, [pmc, #AT91_PMC_SR]
|
|
|
|
str tmp1, .saved_osc_status
|
|
|
|
tst tmp1, #AT91_PMC_MOSCRCS
|
|
|
|
bne 2f
|
|
|
|
|
|
|
|
/* Enable RC oscillator */
|
2018-07-17 15:26:55 +07:00
|
|
|
ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
2019-02-14 22:54:57 +07:00
|
|
|
orr tmp1, tmp1, #AT91_PMC_MOSCRCEN
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
|
|
|
/* Wait main RC stabilization */
|
|
|
|
1: ldr tmp1, [pmc, #AT91_PMC_SR]
|
|
|
|
tst tmp1, #AT91_PMC_MOSCRCS
|
|
|
|
beq 1b
|
|
|
|
|
|
|
|
/* Switch the main clock source to 12-MHz RC oscillator */
|
|
|
|
2: ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
2018-07-17 15:26:55 +07:00
|
|
|
bic tmp1, tmp1, #AT91_PMC_MOSCSEL
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
|
|
|
wait_moscsels
|
|
|
|
|
|
|
|
/* Disable the crystal oscillator */
|
|
|
|
ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_MOSCEN
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
|
|
|
/* Switch the master clock source to main clock */
|
|
|
|
ldr tmp1, [pmc, #AT91_PMC_MCKR]
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_CSS
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_CSS_MAIN
|
|
|
|
str tmp1, [pmc, #AT91_PMC_MCKR]
|
|
|
|
|
|
|
|
wait_mckrdy
|
|
|
|
|
|
|
|
/* Enter the ULP1 mode by set WAITMODE bit in CKGR_MOR */
|
|
|
|
ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_WAITMODE
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
|
|
|
wait_mckrdy
|
|
|
|
|
|
|
|
/* Enable the crystal oscillator */
|
|
|
|
ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_MOSCEN
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
|
|
|
wait_moscrdy
|
|
|
|
|
|
|
|
/* Switch the master clock source to slow clock */
|
|
|
|
ldr tmp1, [pmc, #AT91_PMC_MCKR]
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_CSS
|
|
|
|
str tmp1, [pmc, #AT91_PMC_MCKR]
|
|
|
|
|
|
|
|
wait_mckrdy
|
|
|
|
|
|
|
|
/* Switch main clock source to crystal oscillator */
|
|
|
|
ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_MOSCSEL
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
|
|
|
wait_moscsels
|
|
|
|
|
|
|
|
/* Switch the master clock source to main clock */
|
|
|
|
ldr tmp1, [pmc, #AT91_PMC_MCKR]
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_CSS
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_CSS_MAIN
|
|
|
|
str tmp1, [pmc, #AT91_PMC_MCKR]
|
|
|
|
|
|
|
|
wait_mckrdy
|
2019-02-14 22:54:57 +07:00
|
|
|
|
|
|
|
/* Restore RC oscillator state */
|
|
|
|
ldr tmp1, .saved_osc_status
|
|
|
|
tst tmp1, #AT91_PMC_MOSCRCS
|
|
|
|
bne 3f
|
|
|
|
|
|
|
|
/* Disable RC oscillator */
|
|
|
|
ldr tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_MOSCRCEN
|
|
|
|
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
|
|
|
|
orr tmp1, tmp1, #AT91_PMC_KEY
|
|
|
|
str tmp1, [pmc, #AT91_CKGR_MOR]
|
|
|
|
|
|
|
|
/* Wait RC oscillator disable done */
|
|
|
|
4: ldr tmp1, [pmc, #AT91_PMC_SR]
|
|
|
|
tst tmp1, #AT91_PMC_MOSCRCS
|
|
|
|
bne 4b
|
|
|
|
|
|
|
|
3:
|
2018-07-17 15:26:55 +07:00
|
|
|
.endm
|
|
|
|
|
|
|
|
ENTRY(at91_ulp_mode)
|
2015-03-09 10:48:26 +07:00
|
|
|
ldr pmc, .pmc_base
|
2008-09-22 03:35:18 +07:00
|
|
|
|
|
|
|
/* Save Master clock setting */
|
2011-11-25 08:59:46 +07:00
|
|
|
ldr tmp1, [pmc, #AT91_PMC_MCKR]
|
2012-02-22 23:50:53 +07:00
|
|
|
str tmp1, .saved_mckr
|
2008-09-22 03:35:18 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the Master clock source to slow clock
|
|
|
|
*/
|
2012-02-22 23:50:53 +07:00
|
|
|
bic tmp1, tmp1, #AT91_PMC_CSS
|
2011-11-25 08:59:46 +07:00
|
|
|
str tmp1, [pmc, #AT91_PMC_MCKR]
|
2008-09-22 03:35:18 +07:00
|
|
|
|
|
|
|
wait_mckrdy
|
|
|
|
|
2018-07-17 15:26:55 +07:00
|
|
|
ldr r0, .pm_mode
|
|
|
|
cmp r0, #AT91_PM_ULP1
|
|
|
|
beq ulp1_mode
|
2008-09-22 03:35:18 +07:00
|
|
|
|
2018-07-17 15:26:55 +07:00
|
|
|
at91_pm_ulp0_mode
|
|
|
|
b ulp_exit
|
2008-09-22 03:35:18 +07:00
|
|
|
|
2018-07-17 15:26:55 +07:00
|
|
|
ulp1_mode:
|
|
|
|
at91_pm_ulp1_mode
|
|
|
|
b ulp_exit
|
2008-09-22 03:35:18 +07:00
|
|
|
|
2018-07-17 15:26:55 +07:00
|
|
|
ulp_exit:
|
|
|
|
ldr pmc, .pmc_base
|
2008-09-22 03:35:18 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore master clock setting
|
|
|
|
*/
|
2015-03-09 10:48:26 +07:00
|
|
|
ldr tmp1, .saved_mckr
|
2011-11-25 08:59:46 +07:00
|
|
|
str tmp1, [pmc, #AT91_PMC_MCKR]
|
2008-09-22 03:35:18 +07:00
|
|
|
|
|
|
|
wait_mckrdy
|
|
|
|
|
2016-09-27 17:29:50 +07:00
|
|
|
mov pc, lr
|
2018-07-17 15:26:55 +07:00
|
|
|
ENDPROC(at91_ulp_mode)
|
2015-03-09 10:48:26 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* void at91_sramc_self_refresh(unsigned int is_active)
|
|
|
|
*
|
|
|
|
* @input param:
|
|
|
|
* @r0: 1 - active self-refresh mode
|
|
|
|
* 0 - exit self-refresh mode
|
|
|
|
* register usage:
|
|
|
|
* @r1: memory type
|
|
|
|
* @r2: base address of the sram controller
|
|
|
|
*/
|
|
|
|
|
|
|
|
ENTRY(at91_sramc_self_refresh)
|
|
|
|
ldr r1, .memtype
|
|
|
|
ldr r2, .sramc_base
|
|
|
|
|
|
|
|
cmp r1, #AT91_MEMCTRL_MC
|
|
|
|
bne ddrc_sf
|
|
|
|
|
2012-02-22 23:50:55 +07:00
|
|
|
/*
|
|
|
|
* at91rm9200 Memory controller
|
|
|
|
*/
|
2015-03-09 10:48:26 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For exiting the self-refresh mode, do nothing,
|
|
|
|
* automatically exit the self-refresh mode.
|
|
|
|
*/
|
|
|
|
tst r0, #SRAMC_SELF_FRESH_ACTIVE
|
|
|
|
beq exit_sramc_sf
|
|
|
|
|
|
|
|
/* Active SDRAM self-refresh mode */
|
|
|
|
mov r3, #1
|
2015-03-16 21:14:50 +07:00
|
|
|
str r3, [r2, #AT91_MC_SDRAMC_SRR]
|
2015-03-09 10:48:26 +07:00
|
|
|
b exit_sramc_sf
|
|
|
|
|
|
|
|
ddrc_sf:
|
|
|
|
cmp r1, #AT91_MEMCTRL_DDRSDR
|
|
|
|
bne sdramc_sf
|
2012-02-22 23:50:55 +07:00
|
|
|
|
|
|
|
/*
|
2015-03-09 10:48:26 +07:00
|
|
|
* DDR Memory controller
|
2012-02-22 23:50:55 +07:00
|
|
|
*/
|
2015-03-09 10:48:26 +07:00
|
|
|
tst r0, #SRAMC_SELF_FRESH_ACTIVE
|
|
|
|
beq ddrc_exit_sf
|
|
|
|
|
|
|
|
/* LPDDR1 --> force DDR2 mode during self-refresh */
|
|
|
|
ldr r3, [r2, #AT91_DDRSDRC_MDR]
|
|
|
|
str r3, .saved_sam9_mdr
|
|
|
|
bic r3, r3, #~AT91_DDRSDRC_MD
|
|
|
|
cmp r3, #AT91_DDRSDRC_MD_LOW_POWER_DDR
|
|
|
|
ldreq r3, [r2, #AT91_DDRSDRC_MDR]
|
|
|
|
biceq r3, r3, #AT91_DDRSDRC_MD
|
|
|
|
orreq r3, r3, #AT91_DDRSDRC_MD_DDR2
|
|
|
|
streq r3, [r2, #AT91_DDRSDRC_MDR]
|
|
|
|
|
|
|
|
/* Active DDRC self-refresh mode */
|
|
|
|
ldr r3, [r2, #AT91_DDRSDRC_LPR]
|
|
|
|
str r3, .saved_sam9_lpr
|
|
|
|
bic r3, r3, #AT91_DDRSDRC_LPCB
|
|
|
|
orr r3, r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH
|
|
|
|
str r3, [r2, #AT91_DDRSDRC_LPR]
|
|
|
|
|
|
|
|
/* If using the 2nd ddr controller */
|
|
|
|
ldr r2, .sramc1_base
|
|
|
|
cmp r2, #0
|
|
|
|
beq no_2nd_ddrc
|
|
|
|
|
|
|
|
ldr r3, [r2, #AT91_DDRSDRC_MDR]
|
|
|
|
str r3, .saved_sam9_mdr1
|
|
|
|
bic r3, r3, #~AT91_DDRSDRC_MD
|
|
|
|
cmp r3, #AT91_DDRSDRC_MD_LOW_POWER_DDR
|
|
|
|
ldreq r3, [r2, #AT91_DDRSDRC_MDR]
|
|
|
|
biceq r3, r3, #AT91_DDRSDRC_MD
|
|
|
|
orreq r3, r3, #AT91_DDRSDRC_MD_DDR2
|
|
|
|
streq r3, [r2, #AT91_DDRSDRC_MDR]
|
|
|
|
|
|
|
|
/* Active DDRC self-refresh mode */
|
|
|
|
ldr r3, [r2, #AT91_DDRSDRC_LPR]
|
|
|
|
str r3, .saved_sam9_lpr1
|
|
|
|
bic r3, r3, #AT91_DDRSDRC_LPCB
|
|
|
|
orr r3, r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH
|
|
|
|
str r3, [r2, #AT91_DDRSDRC_LPR]
|
|
|
|
|
|
|
|
no_2nd_ddrc:
|
|
|
|
b exit_sramc_sf
|
|
|
|
|
|
|
|
ddrc_exit_sf:
|
2015-02-05 13:02:09 +07:00
|
|
|
/* Restore MDR in case of LPDDR1 */
|
2015-03-09 10:48:26 +07:00
|
|
|
ldr r3, .saved_sam9_mdr
|
|
|
|
str r3, [r2, #AT91_DDRSDRC_MDR]
|
2010-06-21 20:59:27 +07:00
|
|
|
/* Restore LPR on AT91 with DDRAM */
|
2015-03-09 10:48:26 +07:00
|
|
|
ldr r3, .saved_sam9_lpr
|
|
|
|
str r3, [r2, #AT91_DDRSDRC_LPR]
|
2010-06-21 20:59:27 +07:00
|
|
|
|
2015-03-09 10:48:26 +07:00
|
|
|
/* If using the 2nd ddr controller */
|
|
|
|
ldr r2, .sramc1_base
|
|
|
|
cmp r2, #0
|
|
|
|
ldrne r3, .saved_sam9_mdr1
|
|
|
|
strne r3, [r2, #AT91_DDRSDRC_MDR]
|
|
|
|
ldrne r3, .saved_sam9_lpr1
|
|
|
|
strne r3, [r2, #AT91_DDRSDRC_LPR]
|
2010-06-21 20:59:27 +07:00
|
|
|
|
2015-03-09 10:48:26 +07:00
|
|
|
b exit_sramc_sf
|
2012-02-22 23:50:55 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* SDRAMC Memory controller
|
|
|
|
*/
|
2015-03-09 10:48:26 +07:00
|
|
|
sdramc_sf:
|
|
|
|
tst r0, #SRAMC_SELF_FRESH_ACTIVE
|
|
|
|
beq sdramc_exit_sf
|
|
|
|
|
|
|
|
/* Active SDRAMC self-refresh mode */
|
|
|
|
ldr r3, [r2, #AT91_SDRAMC_LPR]
|
|
|
|
str r3, .saved_sam9_lpr
|
|
|
|
bic r3, r3, #AT91_SDRAMC_LPCB
|
|
|
|
orr r3, r3, #AT91_SDRAMC_LPCB_SELF_REFRESH
|
|
|
|
str r3, [r2, #AT91_SDRAMC_LPR]
|
|
|
|
|
|
|
|
sdramc_exit_sf:
|
|
|
|
ldr r3, .saved_sam9_lpr
|
|
|
|
str r3, [r2, #AT91_SDRAMC_LPR]
|
|
|
|
|
|
|
|
exit_sramc_sf:
|
|
|
|
mov pc, lr
|
|
|
|
ENDPROC(at91_sramc_self_refresh)
|
|
|
|
|
|
|
|
.pmc_base:
|
|
|
|
.word 0
|
|
|
|
.sramc_base:
|
|
|
|
.word 0
|
|
|
|
.sramc1_base:
|
|
|
|
.word 0
|
2016-09-27 17:29:50 +07:00
|
|
|
.shdwc:
|
|
|
|
.word 0
|
|
|
|
.sfr:
|
|
|
|
.word 0
|
2015-03-09 10:48:26 +07:00
|
|
|
.memtype:
|
|
|
|
.word 0
|
2015-03-09 10:49:46 +07:00
|
|
|
.pm_mode:
|
|
|
|
.word 0
|
2008-09-22 03:35:18 +07:00
|
|
|
.saved_mckr:
|
|
|
|
.word 0
|
|
|
|
.saved_sam9_lpr:
|
|
|
|
.word 0
|
2010-06-21 20:59:27 +07:00
|
|
|
.saved_sam9_lpr1:
|
|
|
|
.word 0
|
2015-02-05 13:02:09 +07:00
|
|
|
.saved_sam9_mdr:
|
|
|
|
.word 0
|
|
|
|
.saved_sam9_mdr1:
|
|
|
|
.word 0
|
2019-02-14 22:54:57 +07:00
|
|
|
.saved_osc_status:
|
|
|
|
.word 0
|
2015-02-05 13:02:09 +07:00
|
|
|
|
2015-03-09 10:51:09 +07:00
|
|
|
ENTRY(at91_pm_suspend_in_sram_sz)
|
|
|
|
.word .-at91_pm_suspend_in_sram
|