Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-at91/pm_slow_clock.S |
| 3 | * |
| 4 | * Copyright (C) 2006 Savin Zlobec |
| 5 | * |
| 6 | * AT91SAM9 support: |
| 7 | * Copyright (C) 2007 Anti Sullin <anti.sullin@artecdesign.ee |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | */ |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 14 | #include <linux/linkage.h> |
Boris BREZILLON | 2edb90a | 2013-10-11 09:37:45 +0200 | [diff] [blame] | 15 | #include <linux/clk/at91_pmc.h> |
Wenyou Yang | 23be4be | 2015-03-09 11:49:46 +0800 | [diff] [blame] | 16 | #include "pm.h" |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 17 | |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 18 | #define SRAMC_SELF_FRESH_ACTIVE 0x01 |
| 19 | #define SRAMC_SELF_FRESH_EXIT 0x00 |
| 20 | |
Jean-Christophe PLAGNIOL-VILLARD | 8ff12ad3 | 2012-02-22 17:50:54 +0100 | [diff] [blame] | 21 | pmc .req r0 |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 22 | tmp1 .req r4 |
| 23 | tmp2 .req r5 |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Wait until master clock is ready (after switching master clock source) |
| 27 | */ |
| 28 | .macro wait_mckrdy |
Sylvain Rochet | ad4a38d | 2015-02-05 14:00:37 +0800 | [diff] [blame] | 29 | 1: ldr tmp1, [pmc, #AT91_PMC_SR] |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 30 | tst tmp1, #AT91_PMC_MCKRDY |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 31 | beq 1b |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 32 | .endm |
| 33 | |
| 34 | /* |
| 35 | * Wait until master oscillator has stabilized. |
| 36 | */ |
| 37 | .macro wait_moscrdy |
Sylvain Rochet | ad4a38d | 2015-02-05 14:00:37 +0800 | [diff] [blame] | 38 | 1: ldr tmp1, [pmc, #AT91_PMC_SR] |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 39 | tst tmp1, #AT91_PMC_MOSCS |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 40 | beq 1b |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 41 | .endm |
| 42 | |
| 43 | /* |
| 44 | * Wait until PLLA has locked. |
| 45 | */ |
| 46 | .macro wait_pllalock |
Sylvain Rochet | ad4a38d | 2015-02-05 14:00:37 +0800 | [diff] [blame] | 47 | 1: ldr tmp1, [pmc, #AT91_PMC_SR] |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 48 | tst tmp1, #AT91_PMC_LOCKA |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 49 | beq 1b |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 50 | .endm |
| 51 | |
Wenyou Yang | 2056765 | 2015-03-09 11:53:46 +0800 | [diff] [blame] | 52 | /* |
| 53 | * Put the processor to enter the idle state |
| 54 | */ |
| 55 | .macro at91_cpu_idle |
| 56 | |
| 57 | #if defined(CONFIG_CPU_V7) |
| 58 | mov tmp1, #AT91_PMC_PCK |
| 59 | str tmp1, [pmc, #AT91_PMC_SCDR] |
| 60 | |
| 61 | dsb |
| 62 | |
| 63 | wfi @ Wait For Interrupt |
| 64 | #else |
| 65 | mcr p15, 0, tmp1, c7, c0, 4 |
| 66 | #endif |
| 67 | |
| 68 | .endm |
| 69 | |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 70 | .text |
| 71 | |
Wenyou Yang | e7b848d | 2015-03-11 10:08:12 +0800 | [diff] [blame] | 72 | .arm |
| 73 | |
Wenyou Yang | 5726a8b | 2015-03-09 11:51:09 +0800 | [diff] [blame] | 74 | /* |
| 75 | * void at91_pm_suspend_in_sram(void __iomem *pmc, void __iomem *sdramc, |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 76 | * void __iomem *ramc1, int memctrl) |
Wenyou Yang | 5726a8b | 2015-03-09 11:51:09 +0800 | [diff] [blame] | 77 | * @input param: |
| 78 | * @r0: base address of AT91_PMC |
| 79 | * @r1: base address of SDRAM Controller (SDRAM, DDRSDR, or AT91_SYS) |
| 80 | * @r2: base address of second SDRAM Controller or 0 if not present |
| 81 | * @r3: pm information |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 82 | */ |
Patrick Doyle | 5fcf8d1 | 2015-10-16 12:39:05 +0200 | [diff] [blame] | 83 | /* at91_pm_suspend_in_sram must be 8-byte aligned per the requirements of fncpy() */ |
| 84 | .align 3 |
Wenyou Yang | 5726a8b | 2015-03-09 11:51:09 +0800 | [diff] [blame] | 85 | ENTRY(at91_pm_suspend_in_sram) |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 86 | /* Save registers on stack */ |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 87 | stmfd sp!, {r4 - r12, lr} |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 88 | |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 89 | /* Drain write buffer */ |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 90 | mov tmp1, #0 |
| 91 | mcr p15, 0, tmp1, c7, c10, 4 |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 92 | |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 93 | str r0, .pmc_base |
| 94 | str r1, .sramc_base |
| 95 | str r2, .sramc1_base |
Wenyou Yang | 23be4be | 2015-03-09 11:49:46 +0800 | [diff] [blame] | 96 | |
| 97 | and r0, r3, #AT91_PM_MEMTYPE_MASK |
| 98 | str r0, .memtype |
| 99 | |
| 100 | lsr r0, r3, #AT91_PM_MODE_OFFSET |
| 101 | and r0, r0, #AT91_PM_MODE_MASK |
| 102 | str r0, .pm_mode |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 103 | |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 104 | /* Active the self-refresh mode */ |
| 105 | mov r0, #SRAMC_SELF_FRESH_ACTIVE |
| 106 | bl at91_sramc_self_refresh |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 107 | |
Wenyou Yang | 23be4be | 2015-03-09 11:49:46 +0800 | [diff] [blame] | 108 | ldr r0, .pm_mode |
| 109 | tst r0, #AT91_PM_SLOW_CLOCK |
| 110 | beq skip_disable_main_clock |
| 111 | |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 112 | ldr pmc, .pmc_base |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 113 | |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 114 | /* Save Master clock setting */ |
Jean-Christophe PLAGNIOL-VILLARD | b551495 | 2011-11-25 09:59:46 +0800 | [diff] [blame] | 115 | ldr tmp1, [pmc, #AT91_PMC_MCKR] |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 116 | str tmp1, .saved_mckr |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 117 | |
| 118 | /* |
| 119 | * Set the Master clock source to slow clock |
| 120 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 121 | bic tmp1, tmp1, #AT91_PMC_CSS |
Jean-Christophe PLAGNIOL-VILLARD | b551495 | 2011-11-25 09:59:46 +0800 | [diff] [blame] | 122 | str tmp1, [pmc, #AT91_PMC_MCKR] |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 123 | |
| 124 | wait_mckrdy |
| 125 | |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 126 | /* Save PLLA setting and disable it */ |
Jean-Christophe PLAGNIOL-VILLARD | b551495 | 2011-11-25 09:59:46 +0800 | [diff] [blame] | 127 | ldr tmp1, [pmc, #AT91_CKGR_PLLAR] |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 128 | str tmp1, .saved_pllar |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 129 | |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 130 | mov tmp1, #AT91_PMC_PLLCOUNT |
| 131 | orr tmp1, tmp1, #(1 << 29) /* bit 29 always set */ |
Jean-Christophe PLAGNIOL-VILLARD | b551495 | 2011-11-25 09:59:46 +0800 | [diff] [blame] | 132 | str tmp1, [pmc, #AT91_CKGR_PLLAR] |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 133 | |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 134 | /* Turn off the main oscillator */ |
Jean-Christophe PLAGNIOL-VILLARD | b551495 | 2011-11-25 09:59:46 +0800 | [diff] [blame] | 135 | ldr tmp1, [pmc, #AT91_CKGR_MOR] |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 136 | bic tmp1, tmp1, #AT91_PMC_MOSCEN |
Patrice Vilchez | 5957457 | 2015-02-12 10:52:13 +0800 | [diff] [blame] | 137 | orr tmp1, tmp1, #AT91_PMC_KEY |
Jean-Christophe PLAGNIOL-VILLARD | b551495 | 2011-11-25 09:59:46 +0800 | [diff] [blame] | 138 | str tmp1, [pmc, #AT91_CKGR_MOR] |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 139 | |
Wenyou Yang | 23be4be | 2015-03-09 11:49:46 +0800 | [diff] [blame] | 140 | skip_disable_main_clock: |
| 141 | ldr pmc, .pmc_base |
| 142 | |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 143 | /* Wait for interrupt */ |
Wenyou Yang | 2056765 | 2015-03-09 11:53:46 +0800 | [diff] [blame] | 144 | at91_cpu_idle |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 145 | |
Wenyou Yang | 23be4be | 2015-03-09 11:49:46 +0800 | [diff] [blame] | 146 | ldr r0, .pm_mode |
| 147 | tst r0, #AT91_PM_SLOW_CLOCK |
| 148 | beq skip_enable_main_clock |
| 149 | |
| 150 | ldr pmc, .pmc_base |
| 151 | |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 152 | /* Turn on the main oscillator */ |
Jean-Christophe PLAGNIOL-VILLARD | b551495 | 2011-11-25 09:59:46 +0800 | [diff] [blame] | 153 | ldr tmp1, [pmc, #AT91_CKGR_MOR] |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 154 | orr tmp1, tmp1, #AT91_PMC_MOSCEN |
Patrice Vilchez | 5957457 | 2015-02-12 10:52:13 +0800 | [diff] [blame] | 155 | orr tmp1, tmp1, #AT91_PMC_KEY |
Jean-Christophe PLAGNIOL-VILLARD | b551495 | 2011-11-25 09:59:46 +0800 | [diff] [blame] | 156 | str tmp1, [pmc, #AT91_CKGR_MOR] |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 157 | |
| 158 | wait_moscrdy |
| 159 | |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 160 | /* Restore PLLA setting */ |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 161 | ldr tmp1, .saved_pllar |
Jean-Christophe PLAGNIOL-VILLARD | b551495 | 2011-11-25 09:59:46 +0800 | [diff] [blame] | 162 | str tmp1, [pmc, #AT91_CKGR_PLLAR] |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 163 | |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 164 | tst tmp1, #(AT91_PMC_MUL & 0xff0000) |
Anders Larsen | 9823f1a | 2010-04-08 11:48:16 +0100 | [diff] [blame] | 165 | bne 3f |
Jean-Christophe PLAGNIOL-VILLARD | 0dcfed1 | 2012-02-22 17:50:53 +0100 | [diff] [blame] | 166 | tst tmp1, #(AT91_PMC_MUL & ~0xff0000) |
Anders Larsen | 9823f1a | 2010-04-08 11:48:16 +0100 | [diff] [blame] | 167 | beq 4f |
| 168 | 3: |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 169 | wait_pllalock |
Anders Larsen | 9823f1a | 2010-04-08 11:48:16 +0100 | [diff] [blame] | 170 | 4: |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 171 | |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 172 | /* |
| 173 | * Restore master clock setting |
| 174 | */ |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 175 | ldr tmp1, .saved_mckr |
Jean-Christophe PLAGNIOL-VILLARD | b551495 | 2011-11-25 09:59:46 +0800 | [diff] [blame] | 176 | str tmp1, [pmc, #AT91_PMC_MCKR] |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 177 | |
| 178 | wait_mckrdy |
| 179 | |
Wenyou Yang | 23be4be | 2015-03-09 11:49:46 +0800 | [diff] [blame] | 180 | skip_enable_main_clock: |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 181 | /* Exit the self-refresh mode */ |
| 182 | mov r0, #SRAMC_SELF_FRESH_EXIT |
| 183 | bl at91_sramc_self_refresh |
| 184 | |
| 185 | /* Restore registers, and return */ |
| 186 | ldmfd sp!, {r4 - r12, pc} |
Wenyou Yang | 5726a8b | 2015-03-09 11:51:09 +0800 | [diff] [blame] | 187 | ENDPROC(at91_pm_suspend_in_sram) |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 188 | |
| 189 | /* |
| 190 | * void at91_sramc_self_refresh(unsigned int is_active) |
| 191 | * |
| 192 | * @input param: |
| 193 | * @r0: 1 - active self-refresh mode |
| 194 | * 0 - exit self-refresh mode |
| 195 | * register usage: |
| 196 | * @r1: memory type |
| 197 | * @r2: base address of the sram controller |
| 198 | */ |
| 199 | |
| 200 | ENTRY(at91_sramc_self_refresh) |
| 201 | ldr r1, .memtype |
| 202 | ldr r2, .sramc_base |
| 203 | |
| 204 | cmp r1, #AT91_MEMCTRL_MC |
| 205 | bne ddrc_sf |
| 206 | |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 207 | /* |
| 208 | * at91rm9200 Memory controller |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 209 | */ |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 210 | |
| 211 | /* |
| 212 | * For exiting the self-refresh mode, do nothing, |
| 213 | * automatically exit the self-refresh mode. |
| 214 | */ |
| 215 | tst r0, #SRAMC_SELF_FRESH_ACTIVE |
| 216 | beq exit_sramc_sf |
| 217 | |
| 218 | /* Active SDRAM self-refresh mode */ |
| 219 | mov r3, #1 |
Alexandre Belloni | d7d45f2 | 2015-03-16 15:14:50 +0100 | [diff] [blame] | 220 | str r3, [r2, #AT91_MC_SDRAMC_SRR] |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 221 | b exit_sramc_sf |
| 222 | |
| 223 | ddrc_sf: |
| 224 | cmp r1, #AT91_MEMCTRL_DDRSDR |
| 225 | bne sdramc_sf |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 226 | |
| 227 | /* |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 228 | * DDR Memory controller |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 229 | */ |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 230 | tst r0, #SRAMC_SELF_FRESH_ACTIVE |
| 231 | beq ddrc_exit_sf |
| 232 | |
| 233 | /* LPDDR1 --> force DDR2 mode during self-refresh */ |
| 234 | ldr r3, [r2, #AT91_DDRSDRC_MDR] |
| 235 | str r3, .saved_sam9_mdr |
| 236 | bic r3, r3, #~AT91_DDRSDRC_MD |
| 237 | cmp r3, #AT91_DDRSDRC_MD_LOW_POWER_DDR |
| 238 | ldreq r3, [r2, #AT91_DDRSDRC_MDR] |
| 239 | biceq r3, r3, #AT91_DDRSDRC_MD |
| 240 | orreq r3, r3, #AT91_DDRSDRC_MD_DDR2 |
| 241 | streq r3, [r2, #AT91_DDRSDRC_MDR] |
| 242 | |
| 243 | /* Active DDRC self-refresh mode */ |
| 244 | ldr r3, [r2, #AT91_DDRSDRC_LPR] |
| 245 | str r3, .saved_sam9_lpr |
| 246 | bic r3, r3, #AT91_DDRSDRC_LPCB |
| 247 | orr r3, r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH |
| 248 | str r3, [r2, #AT91_DDRSDRC_LPR] |
| 249 | |
| 250 | /* If using the 2nd ddr controller */ |
| 251 | ldr r2, .sramc1_base |
| 252 | cmp r2, #0 |
| 253 | beq no_2nd_ddrc |
| 254 | |
| 255 | ldr r3, [r2, #AT91_DDRSDRC_MDR] |
| 256 | str r3, .saved_sam9_mdr1 |
| 257 | bic r3, r3, #~AT91_DDRSDRC_MD |
| 258 | cmp r3, #AT91_DDRSDRC_MD_LOW_POWER_DDR |
| 259 | ldreq r3, [r2, #AT91_DDRSDRC_MDR] |
| 260 | biceq r3, r3, #AT91_DDRSDRC_MD |
| 261 | orreq r3, r3, #AT91_DDRSDRC_MD_DDR2 |
| 262 | streq r3, [r2, #AT91_DDRSDRC_MDR] |
| 263 | |
| 264 | /* Active DDRC self-refresh mode */ |
| 265 | ldr r3, [r2, #AT91_DDRSDRC_LPR] |
| 266 | str r3, .saved_sam9_lpr1 |
| 267 | bic r3, r3, #AT91_DDRSDRC_LPCB |
| 268 | orr r3, r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH |
| 269 | str r3, [r2, #AT91_DDRSDRC_LPR] |
| 270 | |
| 271 | no_2nd_ddrc: |
| 272 | b exit_sramc_sf |
| 273 | |
| 274 | ddrc_exit_sf: |
Peter Rosin | 02f513a | 2015-02-05 14:02:09 +0800 | [diff] [blame] | 275 | /* Restore MDR in case of LPDDR1 */ |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 276 | ldr r3, .saved_sam9_mdr |
| 277 | str r3, [r2, #AT91_DDRSDRC_MDR] |
Nicolas Ferre | 7dca334 | 2010-06-21 14:59:27 +0100 | [diff] [blame] | 278 | /* Restore LPR on AT91 with DDRAM */ |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 279 | ldr r3, .saved_sam9_lpr |
| 280 | str r3, [r2, #AT91_DDRSDRC_LPR] |
Nicolas Ferre | 7dca334 | 2010-06-21 14:59:27 +0100 | [diff] [blame] | 281 | |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 282 | /* If using the 2nd ddr controller */ |
| 283 | ldr r2, .sramc1_base |
| 284 | cmp r2, #0 |
| 285 | ldrne r3, .saved_sam9_mdr1 |
| 286 | strne r3, [r2, #AT91_DDRSDRC_MDR] |
| 287 | ldrne r3, .saved_sam9_lpr1 |
| 288 | strne r3, [r2, #AT91_DDRSDRC_LPR] |
Nicolas Ferre | 7dca334 | 2010-06-21 14:59:27 +0100 | [diff] [blame] | 289 | |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 290 | b exit_sramc_sf |
Jean-Christophe PLAGNIOL-VILLARD | fb7e197 | 2012-02-22 17:50:55 +0100 | [diff] [blame] | 291 | |
| 292 | /* |
| 293 | * SDRAMC Memory controller |
| 294 | */ |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 295 | sdramc_sf: |
| 296 | tst r0, #SRAMC_SELF_FRESH_ACTIVE |
| 297 | beq sdramc_exit_sf |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 298 | |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 299 | /* Active SDRAMC self-refresh mode */ |
| 300 | ldr r3, [r2, #AT91_SDRAMC_LPR] |
| 301 | str r3, .saved_sam9_lpr |
| 302 | bic r3, r3, #AT91_SDRAMC_LPCB |
| 303 | orr r3, r3, #AT91_SDRAMC_LPCB_SELF_REFRESH |
| 304 | str r3, [r2, #AT91_SDRAMC_LPR] |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 305 | |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 306 | sdramc_exit_sf: |
| 307 | ldr r3, .saved_sam9_lpr |
| 308 | str r3, [r2, #AT91_SDRAMC_LPR] |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 309 | |
Wenyou Yang | 0ab285c | 2015-03-09 11:48:26 +0800 | [diff] [blame] | 310 | exit_sramc_sf: |
| 311 | mov pc, lr |
| 312 | ENDPROC(at91_sramc_self_refresh) |
| 313 | |
| 314 | .pmc_base: |
| 315 | .word 0 |
| 316 | .sramc_base: |
| 317 | .word 0 |
| 318 | .sramc1_base: |
| 319 | .word 0 |
| 320 | .memtype: |
| 321 | .word 0 |
Wenyou Yang | 23be4be | 2015-03-09 11:49:46 +0800 | [diff] [blame] | 322 | .pm_mode: |
| 323 | .word 0 |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 324 | .saved_mckr: |
| 325 | .word 0 |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 326 | .saved_pllar: |
| 327 | .word 0 |
Andrew Victor | eaad2db | 2008-09-21 21:35:18 +0100 | [diff] [blame] | 328 | .saved_sam9_lpr: |
| 329 | .word 0 |
Nicolas Ferre | 7dca334 | 2010-06-21 14:59:27 +0100 | [diff] [blame] | 330 | .saved_sam9_lpr1: |
| 331 | .word 0 |
Peter Rosin | 02f513a | 2015-02-05 14:02:09 +0800 | [diff] [blame] | 332 | .saved_sam9_mdr: |
| 333 | .word 0 |
Peter Rosin | 02f513a | 2015-02-05 14:02:09 +0800 | [diff] [blame] | 334 | .saved_sam9_mdr1: |
| 335 | .word 0 |
| 336 | |
Wenyou Yang | 5726a8b | 2015-03-09 11:51:09 +0800 | [diff] [blame] | 337 | ENTRY(at91_pm_suspend_in_sram_sz) |
| 338 | .word .-at91_pm_suspend_in_sram |