diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2016-09-07 16:33:47 -0400 |
---|---|---|
committer | Max Filippov <jcmvbkbc@gmail.com> | 2016-09-12 02:53:22 -0400 |
commit | 4f2056873ff0748d413c0dc3577186f78fafa7c9 (patch) | |
tree | 2c33b1f2f9a2beb5e8b1cdd0c62a7319da3bfee4 | |
parent | 23c2b9321b30f947b4f908e40379eed50f48508c (diff) |
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>
-rw-r--r-- | arch/xtensa/include/asm/platform.h | 6 | ||||
-rw-r--r-- | arch/xtensa/kernel/setup.c | 23 | ||||
-rw-r--r-- | arch/xtensa/platforms/iss/setup.c | 20 | ||||
-rw-r--r-- | arch/xtensa/platforms/xt2000/setup.c | 21 | ||||
-rw-r--r-- | arch/xtensa/platforms/xtfpga/setup.c | 22 |
5 files changed, 32 insertions, 60 deletions
diff --git a/arch/xtensa/include/asm/platform.h b/arch/xtensa/include/asm/platform.h index 32e98f27ce97..f8fbef67bc5f 100644 --- a/arch/xtensa/include/asm/platform.h +++ b/arch/xtensa/include/asm/platform.h | |||
@@ -69,4 +69,10 @@ extern int platform_pcibios_fixup (void); | |||
69 | */ | 69 | */ |
70 | extern void platform_calibrate_ccount (void); | 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 | #endif /* _XTENSA_PLATFORM_H */ | 78 | #endif /* _XTENSA_PLATFORM_H */ |
diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c index 393206b6aabc..868b54fce2ed 100644 --- a/arch/xtensa/kernel/setup.c +++ b/arch/xtensa/kernel/setup.c | |||
@@ -549,6 +549,29 @@ static int __init topology_init(void) | |||
549 | } | 549 | } |
550 | subsys_initcall(topology_init); | 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 | void machine_restart(char * cmd) | 575 | void machine_restart(char * cmd) |
553 | { | 576 | { |
554 | platform_restart(); | 577 | platform_restart(); |
diff --git a/arch/xtensa/platforms/iss/setup.c b/arch/xtensa/platforms/iss/setup.c index 391820539f0a..e29e1b41ef96 100644 --- a/arch/xtensa/platforms/iss/setup.c +++ b/arch/xtensa/platforms/iss/setup.c | |||
@@ -53,25 +53,7 @@ void platform_restart(void) | |||
53 | { | 53 | { |
54 | /* Flush and reset the mmu, simulate a processor reset, and | 54 | /* Flush and reset the mmu, simulate a processor reset, and |
55 | * jump to the reset vector. */ | 55 | * jump to the reset vector. */ |
56 | 56 | cpu_reset(); | |
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 | |||
75 | /* control never gets here */ | 57 | /* control never gets here */ |
76 | } | 58 | } |
77 | 59 | ||
diff --git a/arch/xtensa/platforms/xt2000/setup.c b/arch/xtensa/platforms/xt2000/setup.c index 5f4bd71971d6..11b91d6a3b82 100644 --- a/arch/xtensa/platforms/xt2000/setup.c +++ b/arch/xtensa/platforms/xt2000/setup.c | |||
@@ -64,26 +64,7 @@ void platform_restart(void) | |||
64 | { | 64 | { |
65 | /* Flush and reset the mmu, simulate a processor reset, and | 65 | /* Flush and reset the mmu, simulate a processor reset, and |
66 | * jump to the reset vector. */ | 66 | * jump to the reset vector. */ |
67 | 67 | cpu_reset(); | |
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 | |||
87 | /* control never gets here */ | 68 | /* control never gets here */ |
88 | } | 69 | } |
89 | 70 | ||
diff --git a/arch/xtensa/platforms/xtfpga/setup.c b/arch/xtensa/platforms/xtfpga/setup.c index b509d1f55ed5..f0b753f335d8 100644 --- a/arch/xtensa/platforms/xtfpga/setup.c +++ b/arch/xtensa/platforms/xtfpga/setup.c | |||
@@ -54,27 +54,7 @@ void platform_restart(void) | |||
54 | { | 54 | { |
55 | /* Flush and reset the mmu, simulate a processor reset, and | 55 | /* Flush and reset the mmu, simulate a processor reset, and |
56 | * jump to the reset vector. */ | 56 | * jump to the reset vector. */ |
57 | 57 | cpu_reset(); | |
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 | |||
78 | /* control never gets here */ | 58 | /* control never gets here */ |
79 | } | 59 | } |
80 | 60 | ||