Skip to content

Commit bc0779b

Browse files
claudiubeznealdesroches
authored andcommitted
ARM: at91: pm: disable RC oscillator in ULP0
Disable RC oscillator in ULP0 as datasheet specifies. Signed-off-by: Claudiu Beznea <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Signed-off-by: Ludovic Desroches <[email protected]>
1 parent eaedc0d commit bc0779b

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

arch/arm/mach-at91/pm_suspend.S

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,46 @@ ENDPROC(at91_backup_mode)
178178
orr tmp1, tmp1, #AT91_PMC_KEY
179179
str tmp1, [pmc, #AT91_CKGR_MOR]
180180

181+
/* Save RC oscillator state */
182+
ldr tmp1, [pmc, #AT91_PMC_SR]
183+
str tmp1, .saved_osc_status
184+
tst tmp1, #AT91_PMC_MOSCRCS
185+
bne 1f
186+
187+
/* Turn off RC oscillator */
188+
ldr tmp1, [pmc, #AT91_CKGR_MOR]
189+
bic tmp1, tmp1, #AT91_PMC_MOSCRCEN
190+
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
191+
orr tmp1, tmp1, #AT91_PMC_KEY
192+
str tmp1, [pmc, #AT91_CKGR_MOR]
193+
194+
/* Wait main RC disabled done */
195+
2: ldr tmp1, [pmc, #AT91_PMC_SR]
196+
tst tmp1, #AT91_PMC_MOSCRCS
197+
bne 2b
198+
181199
/* Wait for interrupt */
182-
at91_cpu_idle
200+
1: at91_cpu_idle
183201

184-
/* Turn on the crystal oscillator */
202+
/* Restore RC oscillator state */
203+
ldr tmp1, .saved_osc_status
204+
tst tmp1, #AT91_PMC_MOSCRCS
205+
beq 4f
206+
207+
/* Turn on RC oscillator */
185208
ldr tmp1, [pmc, #AT91_CKGR_MOR]
209+
orr tmp1, tmp1, #AT91_PMC_MOSCRCEN
210+
bic tmp1, tmp1, #AT91_PMC_KEY_MASK
211+
orr tmp1, tmp1, #AT91_PMC_KEY
212+
str tmp1, [pmc, #AT91_CKGR_MOR]
213+
214+
/* Wait main RC stabilization */
215+
3: ldr tmp1, [pmc, #AT91_PMC_SR]
216+
tst tmp1, #AT91_PMC_MOSCRCS
217+
beq 3b
218+
219+
/* Turn on the crystal oscillator */
220+
4: ldr tmp1, [pmc, #AT91_CKGR_MOR]
186221
orr tmp1, tmp1, #AT91_PMC_MOSCEN
187222
orr tmp1, tmp1, #AT91_PMC_KEY
188223
str tmp1, [pmc, #AT91_CKGR_MOR]

0 commit comments

Comments
 (0)