Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xtensa: extract common CPU reset code into separate function

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>

+32 -60
+6
arch/xtensa/include/asm/platform.h
··· 69 69 */ 70 70 extern void platform_calibrate_ccount (void); 71 71 72 + /* 73 + * Flush and reset the mmu, simulate a processor reset, and 74 + * jump to the reset vector. 75 + */ 76 + void cpu_reset(void) __attribute__((noreturn)); 77 + 72 78 #endif /* _XTENSA_PLATFORM_H */
+23
arch/xtensa/kernel/setup.c
··· 549 549 } 550 550 subsys_initcall(topology_init); 551 551 552 + void cpu_reset(void) 553 + { 554 + __asm__ __volatile__ ("movi a2, 15\n\t" 555 + "wsr a2, icountlevel\n\t" 556 + "movi a2, 0\n\t" 557 + "wsr a2, icount\n\t" 558 + #if XCHAL_NUM_IBREAK > 0 559 + "wsr a2, ibreakenable\n\t" 560 + #endif 561 + #if XCHAL_HAVE_LOOPS 562 + "wsr a2, lcount\n\t" 563 + #endif 564 + "movi a2, 0x1f\n\t" 565 + "wsr a2, ps\n\t" 566 + "isync\n\t" 567 + "jx %0\n\t" 568 + : 569 + : "a" (XCHAL_RESET_VECTOR_VADDR) 570 + : "a2"); 571 + for (;;) 572 + ; 573 + } 574 + 552 575 void machine_restart(char * cmd) 553 576 { 554 577 platform_restart();
+1 -19
arch/xtensa/platforms/iss/setup.c
··· 53 53 { 54 54 /* Flush and reset the mmu, simulate a processor reset, and 55 55 * jump to the reset vector. */ 56 - 57 - __asm__ __volatile__("movi a2, 15\n\t" 58 - "wsr a2, icountlevel\n\t" 59 - "movi a2, 0\n\t" 60 - "wsr a2, icount\n\t" 61 - #if XCHAL_NUM_IBREAK > 0 62 - "wsr a2, ibreakenable\n\t" 63 - #endif 64 - #if XCHAL_HAVE_LOOPS 65 - "wsr a2, lcount\n\t" 66 - #endif 67 - "movi a2, 0x1f\n\t" 68 - "wsr a2, ps\n\t" 69 - "isync\n\t" 70 - "jx %0\n\t" 71 - : 72 - : "a" (XCHAL_RESET_VECTOR_VADDR) 73 - : "a2"); 74 - 56 + cpu_reset(); 75 57 /* control never gets here */ 76 58 } 77 59
+1 -20
arch/xtensa/platforms/xt2000/setup.c
··· 64 64 { 65 65 /* Flush and reset the mmu, simulate a processor reset, and 66 66 * jump to the reset vector. */ 67 - 68 - __asm__ __volatile__ ("movi a2, 15\n\t" 69 - "wsr a2, icountlevel\n\t" 70 - "movi a2, 0\n\t" 71 - "wsr a2, icount\n\t" 72 - #if XCHAL_NUM_IBREAK > 0 73 - "wsr a2, ibreakenable\n\t" 74 - #endif 75 - #if XCHAL_HAVE_LOOPS 76 - "wsr a2, lcount\n\t" 77 - #endif 78 - "movi a2, 0x1f\n\t" 79 - "wsr a2, ps\n\t" 80 - "isync\n\t" 81 - "jx %0\n\t" 82 - : 83 - : "a" (XCHAL_RESET_VECTOR_VADDR) 84 - : "a2" 85 - ); 86 - 67 + cpu_reset(); 87 68 /* control never gets here */ 88 69 } 89 70
+1 -21
arch/xtensa/platforms/xtfpga/setup.c
··· 54 54 { 55 55 /* Flush and reset the mmu, simulate a processor reset, and 56 56 * jump to the reset vector. */ 57 - 58 - 59 - __asm__ __volatile__ ("movi a2, 15\n\t" 60 - "wsr a2, icountlevel\n\t" 61 - "movi a2, 0\n\t" 62 - "wsr a2, icount\n\t" 63 - #if XCHAL_NUM_IBREAK > 0 64 - "wsr a2, ibreakenable\n\t" 65 - #endif 66 - #if XCHAL_HAVE_LOOPS 67 - "wsr a2, lcount\n\t" 68 - #endif 69 - "movi a2, 0x1f\n\t" 70 - "wsr a2, ps\n\t" 71 - "isync\n\t" 72 - "jx %0\n\t" 73 - : 74 - : "a" (XCHAL_RESET_VECTOR_VADDR) 75 - : "a2" 76 - ); 77 - 57 + cpu_reset(); 78 58 /* control never gets here */ 79 59 } 80 60