Skip to content

Commit e70bfc2

Browse files
claudiubezneaalexandrebelloni
authored andcommitted
ARM: at91: pm: add support for ULP0 fast wakeup
ULP0 fast improves suspend/resume time with few milliseconds the drawback being the power consumption. The mean values measured for suspend/resume time are as follows (measured on SAMA5D2 Xplained board), ULP0 compared with fast ULP0: - ulp0 fast: suspend time: 169 ms, resume time: 216 ms - ulp0 : suspend time: 197 ms, resume time: 258 ms Current consumption while suspended (measured on SAMA5D2 Xplained board): - ulp0 fast: 730uA - ulp0 : 270uA Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/1596616610-15460-2-git-send-email-claudiu.beznea@microchip.com
1 parent 9123e3a commit e70bfc2

3 files changed

Lines changed: 45 additions & 10 deletions

File tree

arch/arm/mach-at91/pm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ static struct at91_soc_pm soc_pm = {
5151
};
5252

5353
static const match_table_t pm_modes __initconst = {
54-
{ AT91_PM_STANDBY, "standby" },
55-
{ AT91_PM_ULP0, "ulp0" },
56-
{ AT91_PM_ULP1, "ulp1" },
57-
{ AT91_PM_BACKUP, "backup" },
54+
{ AT91_PM_STANDBY, "standby" },
55+
{ AT91_PM_ULP0, "ulp0" },
56+
{ AT91_PM_ULP0_FAST, "ulp0-fast" },
57+
{ AT91_PM_ULP1, "ulp1" },
58+
{ AT91_PM_BACKUP, "backup" },
5859
{ -1, NULL },
5960
};
6061

arch/arm/mach-at91/pm.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919

2020
#define AT91_PM_STANDBY 0x00
2121
#define AT91_PM_ULP0 0x01
22-
#define AT91_PM_ULP1 0x02
23-
#define AT91_PM_BACKUP 0x03
22+
#define AT91_PM_ULP0_FAST 0x02
23+
#define AT91_PM_ULP1 0x03
24+
#define AT91_PM_BACKUP 0x04
2425

2526
#ifndef __ASSEMBLY__
2627
struct at91_pm_data {

arch/arm/mach-at91/pm_suspend.S

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,22 @@ ENDPROC(at91_backup_mode)
164164

165165
.macro at91_pm_ulp0_mode
166166
ldr pmc, .pmc_base
167+
ldr tmp2, .pm_mode
168+
ldr tmp3, .mckr_offset
169+
170+
/* Check if ULP0 fast variant has been requested. */
171+
cmp tmp2, #AT91_PM_ULP0_FAST
172+
bne 0f
173+
174+
/* Set highest prescaler for power saving */
175+
ldr tmp1, [pmc, tmp3]
176+
bic tmp1, tmp1, #AT91_PMC_PRES
177+
orr tmp1, tmp1, #AT91_PMC_PRES_64
178+
str tmp1, [pmc, tmp3]
179+
wait_mckrdy
180+
b 1f
167181

182+
0:
168183
/* Turn off the crystal oscillator */
169184
ldr tmp1, [pmc, #AT91_CKGR_MOR]
170185
bic tmp1, tmp1, #AT91_PMC_MOSCEN
@@ -192,7 +207,18 @@ ENDPROC(at91_backup_mode)
192207
/* Wait for interrupt */
193208
1: at91_cpu_idle
194209

195-
/* Restore RC oscillator state */
210+
/* Check if ULP0 fast variant has been requested. */
211+
cmp tmp2, #AT91_PM_ULP0_FAST
212+
bne 5f
213+
214+
/* Set lowest prescaler for fast resume. */
215+
ldr tmp1, [pmc, tmp3]
216+
bic tmp1, tmp1, #AT91_PMC_PRES
217+
str tmp1, [pmc, tmp3]
218+
wait_mckrdy
219+
b 6f
220+
221+
5: /* Restore RC oscillator state */
196222
ldr tmp1, .saved_osc_status
197223
tst tmp1, #AT91_PMC_MOSCRCS
198224
beq 4f
@@ -216,6 +242,7 @@ ENDPROC(at91_backup_mode)
216242
str tmp1, [pmc, #AT91_CKGR_MOR]
217243

218244
wait_moscrdy
245+
6:
219246
.endm
220247

221248
/**
@@ -473,23 +500,29 @@ ENDPROC(at91_backup_mode)
473500
ENTRY(at91_ulp_mode)
474501
ldr pmc, .pmc_base
475502
ldr tmp2, .mckr_offset
503+
ldr tmp3, .pm_mode
476504

477505
/* Save Master clock setting */
478506
ldr tmp1, [pmc, tmp2]
479507
str tmp1, .saved_mckr
480508

481509
/*
482-
* Set the Master clock source to slow clock
510+
* Set master clock source to:
511+
* - MAINCK if using ULP0 fast variant
512+
* - slow clock, otherwise
483513
*/
484514
bic tmp1, tmp1, #AT91_PMC_CSS
515+
cmp tmp3, #AT91_PM_ULP0_FAST
516+
bne save_mck
517+
orr tmp1, tmp1, #AT91_PMC_CSS_MAIN
518+
save_mck:
485519
str tmp1, [pmc, tmp2]
486520

487521
wait_mckrdy
488522

489523
at91_plla_disable
490524

491-
ldr r0, .pm_mode
492-
cmp r0, #AT91_PM_ULP1
525+
cmp tmp3, #AT91_PM_ULP1
493526
beq ulp1_mode
494527

495528
at91_pm_ulp0_mode

0 commit comments

Comments
 (0)