Merge remote-tracking branch 'lsk/v3.10/topic/gator' into linux-linaro-lsk
[firefly-linux-kernel-4.4.55.git] / arch / arm64 / mm / proc.S
index 9ef7633a8eb964d5315702703eae98febe1ec5f5..e0ef63cd05dccca405010f747e5df71a2d15caa3 100644 (file)
@@ -80,6 +80,75 @@ ENTRY(cpu_do_idle)
        ret
 ENDPROC(cpu_do_idle)
 
+#ifdef CONFIG_ARM64_CPU_SUSPEND
+/**
+ * cpu_do_suspend - save CPU registers context
+ *
+ * x0: virtual address of context pointer
+ */
+ENTRY(cpu_do_suspend)
+       mrs     x2, tpidr_el0
+       mrs     x3, tpidrro_el0
+       mrs     x4, contextidr_el1
+       mrs     x5, mair_el1
+       mrs     x6, cpacr_el1
+       mrs     x7, ttbr1_el1
+       mrs     x8, tcr_el1
+       mrs     x9, vbar_el1
+       mrs     x10, mdscr_el1
+       mrs     x11, oslsr_el1
+       mrs     x12, sctlr_el1
+       stp     x2, x3, [x0]
+       stp     x4, x5, [x0, #16]
+       stp     x6, x7, [x0, #32]
+       stp     x8, x9, [x0, #48]
+       stp     x10, x11, [x0, #64]
+       str     x12, [x0, #80]
+       ret
+ENDPROC(cpu_do_suspend)
+
+/**
+ * cpu_do_resume - restore CPU register context
+ *
+ * x0: Physical address of context pointer
+ * x1: ttbr0_el1 to be restored
+ *
+ * Returns:
+ *     sctlr_el1 value in x0
+ */
+ENTRY(cpu_do_resume)
+       /*
+        * Invalidate local tlb entries before turning on MMU
+        */
+       tlbi    vmalle1
+       ldp     x2, x3, [x0]
+       ldp     x4, x5, [x0, #16]
+       ldp     x6, x7, [x0, #32]
+       ldp     x8, x9, [x0, #48]
+       ldp     x10, x11, [x0, #64]
+       ldr     x12, [x0, #80]
+       msr     tpidr_el0, x2
+       msr     tpidrro_el0, x3
+       msr     contextidr_el1, x4
+       msr     mair_el1, x5
+       msr     cpacr_el1, x6
+       msr     ttbr0_el1, x1
+       msr     ttbr1_el1, x7
+       msr     tcr_el1, x8
+       msr     vbar_el1, x9
+       msr     mdscr_el1, x10
+       /*
+        * Restore oslsr_el1 by writing oslar_el1
+        */
+       ubfx    x11, x11, #1, #1
+       msr     oslar_el1, x11
+       mov     x0, x12
+       dsb     nsh             // Make sure local tlb invalidation completed
+       isb
+       ret
+ENDPROC(cpu_do_resume)
+#endif
+
 /*
  *     cpu_do_switch_mm(pgd_phys, tsk)
  *
@@ -104,12 +173,6 @@ ENDPROC(cpu_do_switch_mm)
  *     value of the SCTLR_EL1 register.
  */
 ENTRY(__cpu_setup)
-       /*
-        * Preserve the link register across the function call.
-        */
-       mov     x28, lr
-       bl      __flush_dcache_all
-       mov     lr, x28
        ic      iallu                           // I+BTB cache invalidate
        tlbi    vmalle1is                       // invalidate I + D TLBs
        dsb     sy
@@ -162,9 +225,9 @@ ENDPROC(__cpu_setup)
         *       CE0      XWHW CZ     ME TEEA S
         * .... .IEE .... NEAI TE.I ..AD DEN0 ACAM
         * 0011 0... 1101 ..0. ..0. 10.. .... .... < hardware reserved
-        * .... .100 .... 01.1 11.1 ..01 0001 1101 < software settings
+        * .... .1.. .... 01.1 11.1 ..01 0001 1101 < software settings
         */
        .type   crval, #object
 crval:
-       .word   0x030802e2                      // clear
+       .word   0x000802e2                      // clear
        .word   0x0405d11d                      // set