Skip to content

Commit 8bd10f0

Browse files
ryan-wannerclaudiubeznea
authored andcommitted
ARM: at91: pm: Enable ULP0/ULP1 for SAMA7D65
New clocks are saved to enable ULP0/ULP1 for SAMA7D65 because this SoC has a total of 9 main clocks that need to be saved for ULP0/ULP1 mode. Add mcks member to at91_pm_data, this will be used to determine how many main clocks need to be saved. In the pm_mcks variable will also make sure that no unnecessary clock settings are written during mck_ps_restore. Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Link: https://lore.kernel.org/r/2ac0832f6ede17a5c111ede09b44b8a126e33e36.1740671156.git.Ryan.Wanner@microchip.com [claudiu.beznea: adjusted the entry in pmc_infos[] array] Signed-off-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
1 parent 23b43c1 commit 8bd10f0

4 files changed

Lines changed: 99 additions & 9 deletions

File tree

arch/arm/mach-at91/pm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,7 @@ struct pmc_info {
13391339
unsigned long uhp_udp_mask;
13401340
unsigned long mckr;
13411341
unsigned long version;
1342+
unsigned long mcks;
13421343
};
13431344

13441345
static const struct pmc_info pmc_infos[] __initconst = {
@@ -1370,11 +1371,13 @@ static const struct pmc_info pmc_infos[] __initconst = {
13701371
{
13711372
.mckr = 0x28,
13721373
.version = AT91_PMC_V2,
1374+
.mcks = 4,
13731375
},
13741376
{
13751377
.uhp_udp_mask = AT91SAM926x_PMC_UHP,
13761378
.mckr = 0x28,
13771379
.version = AT91_PMC_V2,
1380+
.mcks = 9,
13781381
},
13791382
};
13801383

@@ -1463,6 +1466,7 @@ static void __init at91_pm_init(void (*pm_idle)(void))
14631466
soc_pm.data.uhp_udp_mask = pmc->uhp_udp_mask;
14641467
soc_pm.data.pmc_mckr_offset = pmc->mckr;
14651468
soc_pm.data.pmc_version = pmc->version;
1469+
soc_pm.data.pmc_mcks = pmc->mcks;
14661470

14671471
if (pm_idle)
14681472
arm_pm_idle = pm_idle;

arch/arm/mach-at91/pm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct at91_pm_data {
3939
unsigned int suspend_mode;
4040
unsigned int pmc_mckr_offset;
4141
unsigned int pmc_version;
42+
unsigned int pmc_mcks;
4243
};
4344
#endif
4445

arch/arm/mach-at91/pm_data-offsets.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ int main(void)
1818
pmc_mckr_offset));
1919
DEFINE(PM_DATA_PMC_VERSION, offsetof(struct at91_pm_data,
2020
pmc_version));
21+
DEFINE(PM_DATA_PMC_MCKS, offsetof(struct at91_pm_data,
22+
pmc_mcks));
2123

2224
return 0;
2325
}

arch/arm/mach-at91/pm_suspend.S

Lines changed: 92 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -814,18 +814,20 @@ sr_dis_exit:
814814
.endm
815815

816816
/**
817-
* at91_mckx_ps_enable: save MCK1..4 settings and switch it to main clock
817+
* at91_mckx_ps_enable: save MCK settings and switch it to main clock
818818
*
819-
* Side effects: overwrites tmp1, tmp2
819+
* Side effects: overwrites tmp1, tmp2, tmp3
820820
*/
821821
.macro at91_mckx_ps_enable
822822
#ifdef CONFIG_SOC_SAMA7
823823
ldr pmc, .pmc_base
824+
ldr tmp3, .mcks
824825

825-
/* There are 4 MCKs we need to handle: MCK1..4 */
826+
/* Start at MCK1 and go until MCKs */
826827
mov tmp1, #1
827-
e_loop: cmp tmp1, #5
828-
beq e_done
828+
e_loop:
829+
cmp tmp1, tmp3
830+
bgt e_done
829831

830832
/* Write MCK ID to retrieve the settings. */
831833
str tmp1, [pmc, #AT91_PMC_MCR_V2]
@@ -850,7 +852,37 @@ e_save_mck3:
850852
b e_ps
851853

852854
e_save_mck4:
855+
cmp tmp1, #4
856+
bne e_save_mck5
853857
str tmp2, .saved_mck4
858+
b e_ps
859+
860+
e_save_mck5:
861+
cmp tmp1, #5
862+
bne e_save_mck6
863+
str tmp2, .saved_mck5
864+
b e_ps
865+
866+
e_save_mck6:
867+
cmp tmp1, #6
868+
bne e_save_mck7
869+
str tmp2, .saved_mck6
870+
b e_ps
871+
872+
e_save_mck7:
873+
cmp tmp1, #7
874+
bne e_save_mck8
875+
str tmp2, .saved_mck7
876+
b e_ps
877+
878+
e_save_mck8:
879+
cmp tmp1, #8
880+
bne e_save_mck9
881+
str tmp2, .saved_mck8
882+
b e_ps
883+
884+
e_save_mck9:
885+
str tmp2, .saved_mck9
854886

855887
e_ps:
856888
/* Use CSS=MAINCK and DIV=1. */
@@ -870,18 +902,20 @@ e_done:
870902
.endm
871903

872904
/**
873-
* at91_mckx_ps_restore: restore MCK1..4 settings
905+
* at91_mckx_ps_restore: restore MCKx settings
874906
*
875907
* Side effects: overwrites tmp1, tmp2
876908
*/
877909
.macro at91_mckx_ps_restore
878910
#ifdef CONFIG_SOC_SAMA7
879911
ldr pmc, .pmc_base
912+
ldr tmp2, .mcks
880913

881-
/* There are 4 MCKs we need to handle: MCK1..4 */
914+
/* Start from MCK1 and go up to MCKs */
882915
mov tmp1, #1
883-
r_loop: cmp tmp1, #5
884-
beq r_done
916+
r_loop:
917+
cmp tmp1, tmp2
918+
bgt r_done
885919

886920
r_save_mck1:
887921
cmp tmp1, #1
@@ -902,7 +936,37 @@ r_save_mck3:
902936
b r_ps
903937

904938
r_save_mck4:
939+
cmp tmp1, #4
940+
bne r_save_mck5
905941
ldr tmp2, .saved_mck4
942+
b r_ps
943+
944+
r_save_mck5:
945+
cmp tmp1, #5
946+
bne r_save_mck6
947+
ldr tmp2, .saved_mck5
948+
b r_ps
949+
950+
r_save_mck6:
951+
cmp tmp1, #6
952+
bne r_save_mck7
953+
ldr tmp2, .saved_mck6
954+
b r_ps
955+
956+
r_save_mck7:
957+
cmp tmp1, #7
958+
bne r_save_mck8
959+
ldr tmp2, .saved_mck7
960+
b r_ps
961+
962+
r_save_mck8:
963+
cmp tmp1, #8
964+
bne r_save_mck9
965+
ldr tmp2, .saved_mck8
966+
b r_ps
967+
968+
r_save_mck9:
969+
ldr tmp2, .saved_mck9
906970

907971
r_ps:
908972
/* Write MCK ID to retrieve the settings. */
@@ -921,6 +985,7 @@ r_ps:
921985
wait_mckrdy tmp1
922986

923987
add tmp1, tmp1, #1
988+
ldr tmp2, .mcks
924989
b r_loop
925990
r_done:
926991
#endif
@@ -1045,6 +1110,10 @@ ENTRY(at91_pm_suspend_in_sram)
10451110
str tmp1, .memtype
10461111
ldr tmp1, [r0, #PM_DATA_MODE]
10471112
str tmp1, .pm_mode
1113+
#ifdef CONFIG_SOC_SAMA7
1114+
ldr tmp1, [r0, #PM_DATA_PMC_MCKS]
1115+
str tmp1, .mcks
1116+
#endif
10481117

10491118
/*
10501119
* ldrne below are here to preload their address in the TLB as access
@@ -1132,6 +1201,10 @@ ENDPROC(at91_pm_suspend_in_sram)
11321201
.word 0
11331202
.pmc_version:
11341203
.word 0
1204+
#ifdef CONFIG_SOC_SAMA7
1205+
.mcks:
1206+
.word 0
1207+
#endif
11351208
.saved_mckr:
11361209
.word 0
11371210
.saved_pllar:
@@ -1155,6 +1228,16 @@ ENDPROC(at91_pm_suspend_in_sram)
11551228
.word 0
11561229
.saved_mck4:
11571230
.word 0
1231+
.saved_mck5:
1232+
.word 0
1233+
.saved_mck6:
1234+
.word 0
1235+
.saved_mck7:
1236+
.word 0
1237+
.saved_mck8:
1238+
.word 0
1239+
.saved_mck9:
1240+
.word 0
11581241
#endif
11591242

11601243
ENTRY(at91_pm_suspend_in_sram_sz)

0 commit comments

Comments
 (0)