]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/arm/mach-imx/imx6sl_lpm_wfi.S
MLK-9961-4 arm:imx6x: Change PLL1 clock management.
[karo-tx-linux.git] / arch / arm / mach-imx / imx6sl_lpm_wfi.S
1 /*
2  * Copyright (C) 2015 Freescale Semiconductor, Inc. All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the license, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in teh hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  */
14
15 #include <linux/linkage.h>
16
17 #define PM_INFO_PM_INFO_SIZE_OFFSET     0x0
18 #define PM_INFO_TTBR_OFFSET             0x4
19 #define PM_INFO_MMDC_V_OFFSET           0x8
20 #define PM_INFO_IOMUXC_V_OFFSET         0xc
21 #define PM_INFO_CCM_V_OFFSET            0x10
22 #define PM_INFO_L2_V_OFFSET             0x14
23 #define PM_INFO_ANATOP_V_OFFSET         0x18
24 #define PM_INFO_IO_NUM_OFFSET           0x1c
25 #define PM_INFO_IO_VAL_OFFSET           0x20
26
27 #define MX6Q_MMDC_MAPSR                 0x404
28 #define MX6Q_MMDC_MPDGCTRL0             0x83c
29
30 .global mx6sl_lpm_wfi_start
31 .global mx6sl_lpm_wfi_end
32
33         .macro  pll_do_wait_lock
34 1:
35         ldr     r7, [r10, r8]
36         ands    r7, #0x80000000
37         beq     1b
38
39         .endm
40
41         .macro  ccm_do_wait
42 2:
43         ldr     r7, [r10, #0x48]
44         cmp     r7, #0x0
45         bne     2b
46
47         .endm
48
49         .macro  ccm_enter_idle
50
51         ldr     r10, [r0, #PM_INFO_CCM_V_OFFSET]
52         /*
53          * if in audio_bus_freq_mode, skip to
54          * audio_mode low power setting.
55          */
56         cmp     r1, #0x1
57         beq     audio_mode
58         /*
59          * Now set DDR rate to 1MHz.
60          * DDR is from bypassed PLL2 on periph2_clk2 path.
61          * Set the periph2_clk2_podf to divide by 8.
62          */
63         ldr     r6, [r10, #0x14]
64         orr     r6, r6, #0x07
65         str     r6, [r10, #0x14]
66
67         /* Now set MMDC PODF to divide by 3. */
68         ldr     r6, [r10, #0x14]
69         bic     r6, r6, #0x38
70         orr     r6, r6, #0x10
71         str     r6, [r10, #0x14]
72
73         ccm_do_wait
74
75         /* Set the AHB to 3MHz. AXI to 3MHz. */
76         ldr     r6, [r10, #0x14]
77         /*r12 stores the origin AHB podf value */
78         mov     r12, r6
79         orr     r6, r6, #0x1c00
80         orr     r6, r6, #0x70000
81         str     r6, [r10, #0x14]
82
83         ccm_do_wait
84
85         /* Now set ARM to 24MHz.
86          * Move ARM to be sourced from step_clk
87          * after setting step_clk to 24MHz.
88          */
89         ldr     r6, [r10, #0x0c]
90         bic     r6, r6, #0x100
91         str     r6, [r10, #0xc]
92         /*Now pll1_sw_clk to step_clk */
93         ldr     r6, [r10, #0x0c]
94         orr     r6, r6, #0x4
95         str     r6, [r10, #0x0c]
96
97         /* Bypass PLL1 and power it down */
98         ldr     r10, [r0, #PM_INFO_ANATOP_V_OFFSET]
99         ldr     r6, =(1 << 16)
100         orr     r6, r6, #0x1000
101         str     r6, [r10, #0x04]
102
103         /*
104          * Set the ARM PODF to divide by 8.
105          * IPG is at 1.5MHz here, we need ARM to
106          * run at the 12:5 ratio (WAIT mode issue).
107          */
108         ldr     r10, [r0, #PM_INFO_CCM_V_OFFSET]
109         ldr     r11, [r10, #0x10]
110         ldr     r6, =0x07
111         str     r6, [r10, #0x10]
112
113         ccm_do_wait
114
115         b       ccm_idle_done
116
117 audio_mode:
118         /*
119          * MMDC is sourced from pll2_200M.
120          * Set the mmdc_podf to div by 8
121          */
122         ldr     r10, [r0, #PM_INFO_CCM_V_OFFSET]
123         ldr     r6, [r10, #0x14]
124         orr     r6, r6, #0x38
125         str     r6, [r10, #0x14]
126
127         ccm_do_wait
128
129         /*
130          * ARM is sourced from pll2_pfd2_400M here.
131          * switch ARM to bypassed PLL1
132          */
133         ldr     r10, [r0, #PM_INFO_CCM_V_OFFSET]
134         ldr     r6, [r10, #0x0c]
135         bic     r6, r6, #0x4
136         str     r6, [r10, #0xc]
137
138         /*
139          * set the arm_podf to divide by 3
140          * as IPG is at 4MHz, we cannot run
141          * arm clk above 9.6MHz when system
142          * enter WAIT mode
143          */
144         ldr     r11, [r10, #0x10]
145         ldr     r6, =0x2
146         str     r6, [r10, #0x10]
147
148         ccm_do_wait
149
150 ccm_idle_done:
151
152         .endm
153
154         .macro  ccm_exit_idle
155
156         /*
157          * If in audio_bus_freq_mode, skip to
158          * audio_mode ccm restore.
159          */
160         cmp     r1, #0x1
161         beq     audio_ccm_restore
162
163         ldr     r10, [r0, #PM_INFO_ANATOP_V_OFFSET]
164         /* Power up PLL1 and un-bypass it. */
165         ldr     r6, =(1 << 12)
166         str     r6, [r10, #0x08]
167
168         /* Wait for PLL1 to relock */
169         ldr     r8, =0x0
170         pll_do_wait_lock
171
172         ldr     r6, =(1 << 16)
173         str     r6, [r10, #0x08]
174
175         ldr     r10, [r0, #PM_INFO_CCM_V_OFFSET]
176         /* Set PLL1_sw_clk back to PLL1 */
177         ldr     r6, [r10, #0x0c]
178         bic     r6, r6, #0x4
179         str     r6, [r10, #0x0c]
180
181         /* Restore AHB/AXI back */
182         str     r12, [r10, #0x14]
183
184         ccm_do_wait
185
186         /* restore mmdc back to 24MHz*/
187         ldr     r6, [r10, #0x14]
188         bic     r6, r6, #0x3f
189         str     r6, [r10, #0x14]
190
191         ccm_do_wait
192         b       ccm_exit_done
193
194 audio_ccm_restore:
195         /* move arm clk back to pll2_pfd2_400M */
196         ldr     r6, [r10, #0xc]
197         orr     r6, r6, #0x4
198         str     r6, [r10, #0xc]
199
200         /* restore mmdc podf */
201         ldr     r10, [r0, #PM_INFO_CCM_V_OFFSET]
202         ldr     r6, [r10, #0x14]
203         bic     r6, r6, #0x38
204         orr     r6, #0x8
205         str     r6, [r10, #0x14]
206
207         ccm_do_wait
208
209 ccm_exit_done:
210
211         .endm
212
213         .macro check_pll_state
214
215         ldr     r10, [r0, #PM_INFO_ANATOP_V_OFFSET]
216         /*
217          * Check whether any PLL is enabled, as only when
218          * there is no PLLs enabled, 2p5 can be off and
219          * only enable the weak one. PLL1 will be powered
220          * down late, so no need to check PLL1 state.
221          */
222
223         /* sys PLL2 */
224         ldr     r6, [r10, #0x30]
225         ands r6, r6, #(1 << 31)
226         bne     1f
227
228         /* usb PLL3 */
229         ldr     r6, [r10, #0x10]
230         ands    r6, r6, #(1 << 31)
231         bne     1f
232
233         /* audio PLL4 */
234         ldr     r6, [r10, #0x70]
235         ands    r6, r6, #(1 << 31)
236         bne     1f
237
238         /* video PLL5 */
239         ldr     r6, [r10, #0xa0]
240         ands    r6, r6, #(1 << 31)
241         bne     1f
242
243         /* enet PLL6 */
244         ldr     r6, [r10, #0xe0]
245         ands    r6, r6, #(1 << 31)
246         bne     1f
247
248         /* usb host PLL7 */
249         ldr     r6, [r10, #0x20]
250         ands    r6, r6, #(1 << 31)
251         bne     1f
252
253         ldr     r4, =0x1
254         b       check_done
255 1:
256         ldr     r4, =0x0
257
258 check_done:
259         .endm
260
261         .macro  anatop_enter_idle
262
263         ldr     r10, [r0, #PM_INFO_ANATOP_V_OFFSET]
264         cmp     r4, #0x0
265         beq     anatop_enter_done
266
267         /* Disable 1p1 brown out. */
268         ldr     r10, [r0, #PM_INFO_ANATOP_V_OFFSET]
269         ldr     r6, [r10, #0x110]
270         bic     r6, r6, #0x2
271         str     r6, [r10, #0x110]
272         /*
273          * Set the OSC bias current to -37.5%
274          * to drop the power on VDDHIGH.
275          */
276         ldr     r6, [r10, #0x150]
277         orr     r6, r6, #0xc000
278         str     r6, [r10, #0x150]
279
280         /*
281          * if the usb VBUS wakeup is enabled, skip
282          * disable main 2p5.
283          */
284         cmp     r2, #0x1
285         beq     anatop_enter_done
286
287         /* Enable the week 2p5 */
288         ldr     r6, [r10, #0x130]
289         orr     r6, r6, #0x40000
290         str     r6, [r10, #0x130]
291
292         /* Disable main 2p5. */
293         ldr     r6, [r10, #0x130]
294         bic     r6, r6, #0x1
295         str     r6, [r10, #0x130]
296
297         /*
298          * Cannot diable regular bandgap
299          * in LDO-enable mode. The bandgap
300          * is required for ARM-LDO to regulate
301          * the voltage.
302          */
303         ldr     r6, [r10, #0x140]
304         and     r6, r6, #0x1f
305         cmp     r6, #0x1f
306         bne     anatop_enter_done
307
308         /* Enable low power bandgap */
309         ldr     r6, [r10, #0x260]
310         orr     r6, r6, #0x20
311         str     r6, [r10, #0x260]
312
313         /*
314          * Turn off the bias current
315          * from the regular bandgap.
316          */
317         ldr     r6, [r10, #0x260]
318         orr     r6, r6, #0x80
319         str     r6, [r10, #0x260]
320
321         /*
322          * Clear the REFTTOP+SELFBIASOFF,
323          * self_bais circuit of the band gap.
324          * Per RM, should be cleared when
325          * band gap is powered down.
326          */
327         ldr     r6, [r10, #0x150]
328         bic     r6, r6, #0x8
329         str     r6, [r10, #0x150]
330
331         /* Power down the regular bandgap */
332         ldr     r6, [r10, #0x150]
333         orr     r6, r6, #0x1
334         str     r6, [r10, #0x150]
335 anatop_enter_done:
336
337         .endm
338
339         .macro  anatop_exit_idle
340
341         ldr     r10, [r0, #PM_INFO_ANATOP_V_OFFSET]
342         cmp     r4, #0x0
343         beq     skip_anatop_restore
344
345         cmp     r2, #0x1
346         beq     ldo2p5_not_disabled
347         /*
348          * Regular bandgap will not be disabled
349          * in LDO-enabled mode as it is required
350          * for ARM-LDO to reguulate the voltage.
351          */
352         ldr     r6, [r10, #0x140]
353         and     r6, r6, #0x1f
354         cmp     r6, #0x1f
355         bne     skip_bandgap_restore
356
357         /* Power up the regular bandgap */
358         ldr     r6, [r10, #0x150]
359         bic     r6, r6, #0x1
360         str     r6, [r10, #0x150]
361
362         /* wait for bandgap stable */
363 3:
364         ldr     r6, [r10, #0x150]
365         and     r6, r6, #0x80
366         cmp     r6, #0x80
367         bne     3b
368
369         /* now disable bandgap self-bias circuit */
370         ldr     r6, [r10, #0x150]
371         orr     r6, r6, #0x8
372         str     r6, [r10, #0x150]
373
374         /* Turn on the bias current
375          * from the regular bandgap.
376          */
377         ldr     r6, [r10, #0x260]
378         bic     r6, r6, #0x80
379         str     r6, [r10, #0x260]
380
381         /* Disable the low power bandgap */
382         ldr     r6, [r10, #0x260]
383         bic     r6, r6, #0x20
384         str     r6, [r10, #0x260]
385
386 skip_bandgap_restore:
387         /* Enable main 2p5. */
388         ldr     r6, [r10, #0x130]
389         orr     r6, r6, #0x1
390         str     r6, [r10, #0x130]
391
392         /* Ensure the 2p5 is up */
393 5:
394         ldr     r6, [r10, #0x130]
395         and     r6, r6, #0x20000
396         cmp     r6, #0x20000
397         bne     5b
398
399         /* Disable the weak 2p5 */
400         ldr     r6, [r10, #0x130]
401         bic     r6, r6, #0x40000
402         str     r6, [r10, #0x130]
403
404 ldo2p5_not_disabled:
405         /*
406          * Set the OSC bias current to max
407          * value for normal operation.
408          */
409         ldr     r6, [r10, #0x150]
410         bic     r6, r6, #0xc000
411         str     r6, [r10, #0x150]
412
413         /* Enable 1p1 brown out, */
414         ldr     r6, [r10, #0x110]
415         orr     r6, r6, #0x2
416         str     r6, [r10, #0x110]
417
418 skip_anatop_restore:
419
420         .endm
421
422         .macro  disable_l1_dcache
423
424         /* disable d-cache */
425         mrc     p15, 0, r7, c1, c0, 0
426         bic     r7, r7, #(1 << 2)
427         mcr     p15, 0, r7, c1, c0, 0
428
429         dsb
430         isb
431
432         .endm
433
434         .macro  mmdc_enter_dvfs_mode
435
436         /* disable automatic power saving. */
437         ldr     r7, [r10, #MX6Q_MMDC_MAPSR]
438         orr     r7, r7, #0x1
439         str     r7, [r10, #MX6Q_MMDC_MAPSR]
440
441         /* disable power down timer */
442         ldr     r7, [r10, #0x04]
443         bic     r7, r7, #0xff00
444         str     r7, [r10, #0x04]
445
446         /* Make the DDR explicitly enter self-refresh. */
447         ldr     r7, [r10, #MX6Q_MMDC_MAPSR]
448         orr     r7, r7, #(1 << 21)
449         str     r7, [r10, #MX6Q_MMDC_MAPSR]
450
451 poll_dvfs_set:
452         ldr     r7, [r10, #MX6Q_MMDC_MAPSR]
453         ands    r7, r7, #(1 << 25)
454         beq     poll_dvfs_set
455
456         /* set SBS step-by step mode */
457         ldr     r7, [r10, #0x410]
458         orr     r7, r7, #0x100
459         str     r7, [r10, #0x410]
460
461         .endm
462
463         .macro  resume_mmdc
464         /* restore MMDC IO */
465         ldr     r10, [r0, #PM_INFO_IOMUXC_V_OFFSET]
466
467         ldr     r6, [r0, #PM_INFO_IO_NUM_OFFSET]
468         ldr     r7, =PM_INFO_IO_VAL_OFFSET
469         add     r7, r7, r0
470 6:
471         ldr     r8, [r7], #0x4
472         ldr     r9, [r7], #0x4
473         str     r9, [r10, r8]
474         subs    r6, r6, #0x1
475         bne     6b
476
477         /*
478          * Need to reset the FIFO to avoid MMDC lockup
479          * caused because of floating/changing the
480          * configuration of many DDR IO pads.
481          */
482         ldr     r10, [r0, #PM_INFO_MMDC_V_OFFSET]
483         /* reset read FIFO, RST_RD_FIFO */
484         ldr     r7, =MX6Q_MMDC_MPDGCTRL0
485         ldr     r6, [r10, r7]
486         orr     r6, r6, #(1 << 31)
487         str     r6, [r10, r7]
488 7:
489         ldr     r6, [r10, r7]
490         ands    r6, r6, #(1 << 31)
491         bne     7b
492
493         /* reset FIFO a second time */
494         ldr     r7, =MX6Q_MMDC_MPDGCTRL0
495         ldr     r6, [r10, r7]
496         orr     r6, r6, #(1 << 31)
497         str     r6, [r10, r7]
498 8:
499         ldr     r6, [r10, r7]
500         ands    r6, r6, #(1 <<31)
501         bne     8b
502
503         ldr     r10, [r0, #PM_INFO_MMDC_V_OFFSET]
504         /* Let DDR out of self-refresh */
505         ldr     r7, [r10, #MX6Q_MMDC_MAPSR]
506         bic     r7, r7, #(1 << 21)
507         str     r7, [r10, #MX6Q_MMDC_MAPSR]
508 9:
509         ldr     r7, [r10, #MX6Q_MMDC_MAPSR]
510         ands    r7, r7, #(1 << 25)
511         bne     9b
512
513         /* enable power down timer */
514         ldr     r7, [r10, #0x04]
515         orr     r7, r7, #0x5500
516         str     r7, [r10, #0x04]
517
518         /* enable DDR auto power saving */
519         ldr     r7, [r10, #MX6Q_MMDC_MAPSR]
520         bic     r7, r7, #0x1
521         str     r7, [r10, #MX6Q_MMDC_MAPSR]
522
523         /* Clear SBS - unblock DDR accesses */
524         ldr     r7, [r10, #0x410]
525         bic     r7, r7, #0x100
526         str     r7, [r10, #0x410]
527
528         .endm
529
530         .macro  tlb_set_to_ocram
531
532         /* save ttbr */
533         mrc     p15, 0, r7, c2, c0, 1
534         str     r7, [r0, #PM_INFO_TTBR_OFFSET]
535
536         /*
537          * To ensure no page table walks occur in DDR, we
538          * have a another page table stored in IRAM that only
539          * contains entries pointing to IRAM, AIPS1 and AIPS2.
540          * we need to set the TTBR1 to the new IRAM TLB.
541          * Do the following steps:
542          * 1. Flush the Branch Target Address Cache (BTAC)
543          * 2. Set TTBR1 to point to the IRAM page table.
544          * 3. Disable page table walks in TTBR0 (PD0 = 1)
545          * 4. Set TTBR0.N=1, implying 0-2G is transslated by TTBR0
546          *    and 2-4G is translated by TTBR1.
547          */
548
549         ldr     r6, =iram_tlb_phys_addr
550         ldr     r7, [r6]
551
552         /* Disable Branch Prediction, Z bit in SCTLR */
553         mrc     p15, 0, r6, c1, c0, 0
554         bic     r6, r6, #0x800
555         mcr     p15, 0, r6, c1, c0, 0
556
557         /* Flush the BTAC. */
558         ldr     r6, =0x0
559         mcr     p15, 0, r6, c7, c1, 6
560
561         dsb
562         isb
563
564         /* store the IRAM table in TTBR1 */
565         mcr     p15, 0, r7, c2, c0, 1
566         /* Read TTBCR and set PD0=1, N=1 */
567         mrc     p15, 0, r6, c2, c0, 2
568         orr     r6, r6, #0x11
569         mcr     p15, 0, r6, c2, c0, 2
570
571         dsb
572         isb
573
574         /* Flush the TLB */
575         ldr     r6, =0x0
576         mcr     p15, 0, r6, c8, c3, 0
577
578         .endm
579
580         .macro  tlb_back_to_ddr
581
582         /* Restore the TTBCR */
583         dsb
584         isb
585
586         /* Read TTBCR and set PD0=0, N=0 */
587         mrc     p15, 0, r6, c2, c0, 2
588         bic     r6, r6, #0x11
589         mcr     p15, 0, r6, c2, c0, 2
590         /* Flush the TLB */
591         ldr     r6, =0x0
592         mcr     p15, 0, r6, c8, c3, 0
593
594         dsb
595         isb
596
597         /* Enable Branch Prediction, Z bit in SCTLR. */
598         mrc     p15, 0, r6, c1, c0, 0
599         orr     r6, r6, #0x800
600         mcr     p15, 0 ,r6, c1, c0, 0
601         /* Flush the Branch Target Address Cache (BTAC) */
602         ldr     r6, =0x0
603         mcr     p15, 0, r6, c7, c1, 6
604         /* Restore ttbr */
605         ldr     r7, [r0, #PM_INFO_TTBR_OFFSET]
606         mcr     p15, 0, r7, c2, c0, 1
607
608         .endm
609
610 .extern iram_tlb_phys_addr
611
612 /*
613  * imx6sl_low_power_wfi code
614  * r0: wfi code base address
615  * r1: audio_bus_freq mode stat
616  * r2: vbus_ldo status
617  * r4: used for store the PLLs state
618  * r11: used for saving the ARM_PODF origin value
619  * r12: used for saving AHB_PODF origin value
620  */
621         .align 3
622 ENTRY(imx6sl_low_power_wfi)
623
624 mx6sl_lpm_wfi_start:
625
626         push {r4-r12}
627
628         tlb_set_to_ocram
629         disable_l1_dcache
630
631 #ifdef CONFIG_CACHE_L2X0
632         /* sync L2 */
633         ldr     r10, [r0, #PM_INFO_L2_V_OFFSET]
634         /* Wait for background operations to complete. */
635 wait_for_l2_idle:
636         ldr     r6, [r10, #0x730]
637         cmp     r6, #0x0
638         bne     wait_for_l2_idle
639
640         mov     r6, #0x0
641         str     r6, [r10, #0x730]
642         /* disable L2 */
643         str     r6, [r10, #0x100]
644
645         dsb
646         isb
647 #endif
648
649         /* make sure MMDC in self-refresh */
650         ldr     r10, [r0, #PM_INFO_MMDC_V_OFFSET]
651         mmdc_enter_dvfs_mode
652         /* save DDR IO settings and set to LPM mode*/
653         ldr     r10, [r0, #PM_INFO_IOMUXC_V_OFFSET]
654         ldr     r6, =0x0
655         ldr     r7, [r0, #PM_INFO_IO_NUM_OFFSET]
656         ldr     r8, =PM_INFO_IO_VAL_OFFSET
657         add     r8, r8, r0
658
659         /* imx6sl's last 3 IOs need special setting */
660         sub     r7, r7, #0x3
661 save_and_set_mmdc_io_lpm:
662         ldr     r9, [r8], #0x4
663         ldr     r5, [r10, r9]
664         str     r6, [r10, r9]
665         str     r5, [r8], #0x4
666         subs    r7, r7, #0x1
667         bne     save_and_set_mmdc_io_lpm
668         ldr     r6, =0x1000
669         ldr     r9, [r8], #0x4
670         ldr     r5, [r10, r9]
671         str     r5, [r8], #0x4
672         str     r6, [r10, r9]
673         ldr     r9, [r8], #0x4
674         ldr     r5, [r10, r9]
675         str     r6, [r10, r9]
676         str     r5, [r8], #0x4
677         ldr     r6, =0x80000
678         ldr     r9, [r8], #0x4
679         ldr     r5, [r10, r9]
680         str     r6, [r10, r9]
681         str     r5, [r8], #0x4
682
683
684         /* check the PLLs lock state */
685         check_pll_state
686
687         ccm_enter_idle
688         /* if in audio low power mode, no
689          * need to do anatop setting.
690          */
691         cmp     r1, #0x1
692         beq     do_wfi
693         anatop_enter_idle
694 do_wfi:
695         wfi
696         /*
697          * Add these nops so that the
698          * prefetcher will not try to get
699          * any instrutions from DDR.
700          * The prefetch depth is about 23
701          * on A9, so adding 25 nops.
702          */
703         nop
704         nop
705         nop
706         nop
707         nop
708
709         nop
710         nop
711         nop
712         nop
713         nop
714
715         nop
716         nop
717         nop
718         nop
719         nop
720
721         nop
722         nop
723         nop
724         nop
725         nop
726
727         nop
728         nop
729         nop
730         nop
731         nop
732
733         /*
734          * restore the ARM PODF first to speed
735          * up the restore procedure
736          */
737         ldr     r10, [r0, #PM_INFO_CCM_V_OFFSET]
738         /* Restore arm_clk_podf */
739         str     r11, [r10, #0x10]
740         ccm_do_wait
741
742         /*
743          * if in audio low power mode, skip
744          * restore the anatop setting.
745          */
746         cmp     r1, #0x1
747         beq     skip_analog_restore
748         anatop_exit_idle
749
750 skip_analog_restore:
751         ccm_exit_idle
752         resume_mmdc
753
754         /* enable d-cache */
755         mrc     p15, 0, r7, c1, c0, 0
756         orr     r7, r7, #(1 << 2)
757         mcr     p15, 0, r7, c1, c0, 0
758
759 #ifdef CONFIG_CACHE_L2X0
760         ldr     r10, [r0, #PM_INFO_L2_V_OFFSET]
761         mov     r7, #0x1
762         /* enable L2 */
763         str     r7, [r10, #0x100]
764 #endif
765         tlb_back_to_ddr
766
767         /* Restore register */
768         pop     {r4 - r12}
769         mov     pc, lr
770
771         /*
772          * Add ltorg here to ensure that all
773          * literals are stored here and are
774          * within the text space.
775          */
776         .ltorg
777 mx6sl_lpm_wfi_end: