xtensa: extract common CPU reset code into separate function
authorMax Filippov <jcmvbkbc@gmail.com>
Wed, 7 Sep 2016 20:33:47 +0000 (13:33 -0700)
committerMax Filippov <jcmvbkbc@gmail.com>
Mon, 12 Sep 2016 06:53:22 +0000 (23:53 -0700)
platform_restart implementatations do the same thing to reset CPU.
Don't duplicate that code, move it to a function and call it from
platform_restart.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
arch/xtensa/include/asm/platform.h
arch/xtensa/kernel/setup.c
arch/xtensa/platforms/iss/setup.c
arch/xtensa/platforms/xt2000/setup.c
arch/xtensa/platforms/xtfpga/setup.c

index 32e98f27ce9797cc6b82427ce9e98a3083158794..f8fbef67bc5f20590df28e635950faeecce521e2 100644 (file)
@@ -69,4 +69,10 @@ extern int platform_pcibios_fixup (void);
  */
 extern void platform_calibrate_ccount (void);
 
+/*
+ * Flush and reset the mmu, simulate a processor reset, and
+ * jump to the reset vector.
+ */
+void cpu_reset(void) __attribute__((noreturn));
+
 #endif /* _XTENSA_PLATFORM_H */
index 393206b6aabc8b9b48116c4d81fdb9a84fa6b76c..868b54fce2ed9143cdc196552ec2ef7cf9788c02 100644 (file)
@@ -549,6 +549,29 @@ static int __init topology_init(void)
 }
 subsys_initcall(topology_init);
 
+void cpu_reset(void)
+{
+       __asm__ __volatile__ ("movi     a2, 15\n\t"
+                             "wsr      a2, icountlevel\n\t"
+                             "movi     a2, 0\n\t"
+                             "wsr      a2, icount\n\t"
+#if XCHAL_NUM_IBREAK > 0
+                             "wsr      a2, ibreakenable\n\t"
+#endif
+#if XCHAL_HAVE_LOOPS
+                             "wsr      a2, lcount\n\t"
+#endif
+                             "movi     a2, 0x1f\n\t"
+                             "wsr      a2, ps\n\t"
+                             "isync\n\t"
+                             "jx       %0\n\t"
+                             :
+                             : "a" (XCHAL_RESET_VECTOR_VADDR)
+                             : "a2");
+       for (;;)
+               ;
+}
+
 void machine_restart(char * cmd)
 {
        platform_restart();
index 391820539f0ae12bea63f1327cf859357647c859..e29e1b41ef9698cdf7b823a2ea1949af6283cb76 100644 (file)
@@ -53,25 +53,7 @@ void platform_restart(void)
 {
        /* Flush and reset the mmu, simulate a processor reset, and
         * jump to the reset vector. */
-
-       __asm__ __volatile__("movi      a2, 15\n\t"
-                            "wsr       a2, icountlevel\n\t"
-                            "movi      a2, 0\n\t"
-                            "wsr       a2, icount\n\t"
-#if XCHAL_NUM_IBREAK > 0
-                            "wsr       a2, ibreakenable\n\t"
-#endif
-#if XCHAL_HAVE_LOOPS
-                            "wsr       a2, lcount\n\t"
-#endif
-                            "movi      a2, 0x1f\n\t"
-                            "wsr       a2, ps\n\t"
-                            "isync\n\t"
-                            "jx        %0\n\t"
-                            :
-                            : "a" (XCHAL_RESET_VECTOR_VADDR)
-                            : "a2");
-
+       cpu_reset();
        /* control never gets here */
 }
 
index 5f4bd71971d6a317562289f2e9156f60fd07ed02..11b91d6a3b82d32de27a22f642380c171a74de12 100644 (file)
@@ -64,26 +64,7 @@ void platform_restart(void)
 {
        /* Flush and reset the mmu, simulate a processor reset, and
         * jump to the reset vector. */
-
-       __asm__ __volatile__ ("movi     a2, 15\n\t"
-                             "wsr      a2, icountlevel\n\t"
-                             "movi     a2, 0\n\t"
-                             "wsr      a2, icount\n\t"
-#if XCHAL_NUM_IBREAK > 0
-                             "wsr      a2, ibreakenable\n\t"
-#endif
-#if XCHAL_HAVE_LOOPS
-                             "wsr      a2, lcount\n\t"
-#endif
-                             "movi     a2, 0x1f\n\t"
-                             "wsr      a2, ps\n\t"
-                             "isync\n\t"
-                             "jx       %0\n\t"
-                             :
-                             : "a" (XCHAL_RESET_VECTOR_VADDR)
-                             : "a2"
-                             );
-
+       cpu_reset();
        /* control never gets here */
 }
 
index b509d1f55ed5c2445f1bb4930b48a84c9d34edce..f0b753f335d8c5ab12aa660edbd930a255e1073d 100644 (file)
@@ -54,27 +54,7 @@ void platform_restart(void)
 {
        /* Flush and reset the mmu, simulate a processor reset, and
         * jump to the reset vector. */
-
-
-       __asm__ __volatile__ ("movi     a2, 15\n\t"
-                             "wsr      a2, icountlevel\n\t"
-                             "movi     a2, 0\n\t"
-                             "wsr      a2, icount\n\t"
-#if XCHAL_NUM_IBREAK > 0
-                             "wsr      a2, ibreakenable\n\t"
-#endif
-#if XCHAL_HAVE_LOOPS
-                             "wsr      a2, lcount\n\t"
-#endif
-                             "movi     a2, 0x1f\n\t"
-                             "wsr      a2, ps\n\t"
-                             "isync\n\t"
-                             "jx       %0\n\t"
-                             :
-                             : "a" (XCHAL_RESET_VECTOR_VADDR)
-                             : "a2"
-                             );
-
+       cpu_reset();
        /* control never gets here */
 }