Skip to content

Commit 83206e7

Browse files
committed
power: reset: at91-poweroff: use only one poweroff function
Use only one poweroff function for sama5d2 and adapt it to work for both scenarios (having LPDDR or not). Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
1 parent 2efd53c commit 83206e7

1 file changed

Lines changed: 8 additions & 21 deletions

File tree

drivers/power/reset/at91-sama5d2_shdwc.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,6 @@ static void __init at91_wakeup_status(struct platform_device *pdev)
109109
}
110110

111111
static void at91_poweroff(void)
112-
{
113-
/* Switch the master clock source to slow clock. */
114-
writel(readl(at91_shdwc->pmc_base + AT91_PMC_MCKR) & ~AT91_PMC_CSS,
115-
at91_shdwc->pmc_base + AT91_PMC_MCKR);
116-
while (!(readl(at91_shdwc->pmc_base + AT91_PMC_SR) & AT91_PMC_MCKRDY))
117-
;
118-
119-
writel(AT91_SHDW_KEY | AT91_SHDW_SHDW,
120-
at91_shdwc->at91_shdwc_base + AT91_SHDW_CR);
121-
}
122-
123-
static void at91_lpddr_poweroff(void)
124112
{
125113
asm volatile(
126114
/* Align to cache lines */
@@ -130,16 +118,18 @@ static void at91_lpddr_poweroff(void)
130118
" ldr r6, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t"
131119

132120
/* Power down SDRAM0 */
121+
" tst %0, #0\n\t"
122+
" beq 1f\n\t"
133123
" str %1, [%0, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t"
134124

135125
/* Switch the master clock source to slow clock. */
136-
" ldr r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t"
126+
"1: ldr r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t"
137127
" bic r6, r6, #" __stringify(AT91_PMC_CSS) "\n\t"
138128
" str r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t"
139129
/* Wait for clock switch. */
140-
"1: ldr r6, [%4, #" __stringify(AT91_PMC_SR) "]\n\t"
130+
"2: ldr r6, [%4, #" __stringify(AT91_PMC_SR) "]\n\t"
141131
" tst r6, #" __stringify(AT91_PMC_MCKRDY) "\n\t"
142-
" beq 1b\n\t"
132+
" beq 2b\n\t"
143133

144134
/* Shutdown CPU */
145135
" str %3, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t"
@@ -326,10 +316,8 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
326316
pm_power_off = at91_poweroff;
327317

328318
ddr_type = readl(mpddrc_base + AT91_DDRSDRC_MDR) & AT91_DDRSDRC_MD;
329-
if ((ddr_type == AT91_DDRSDRC_MD_LPDDR2) ||
330-
(ddr_type == AT91_DDRSDRC_MD_LPDDR3)) {
331-
pm_power_off = at91_lpddr_poweroff;
332-
} else {
319+
if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
320+
ddr_type != AT91_DDRSDRC_MD_LPDDR3) {
333321
iounmap(mpddrc_base);
334322
mpddrc_base = NULL;
335323
}
@@ -348,8 +336,7 @@ static int __exit at91_shdwc_remove(struct platform_device *pdev)
348336
{
349337
struct shdwc *shdw = platform_get_drvdata(pdev);
350338

351-
if (pm_power_off == at91_poweroff ||
352-
pm_power_off == at91_lpddr_poweroff)
339+
if (pm_power_off == at91_poweroff)
353340
pm_power_off = NULL;
354341

355342
/* Reset values to disable wake-up features */

0 commit comments

Comments
 (0)