]> err.no Git - linux-2.6/blob - arch/blackfin/kernel/reboot.c
06501a594ddadc3ff1485db06088041ea5e11bdf
[linux-2.6] / arch / blackfin / kernel / reboot.c
1 /*
2  * arch/blackfin/kernel/reboot.c - handle shutdown/reboot
3  *
4  * Copyright 2004-2007 Analog Devices Inc.
5  *
6  * Licensed under the GPL-2 or later.
7  */
8
9 #include <linux/interrupt.h>
10 #include <asm/bfin-global.h>
11 #include <asm/reboot.h>
12 #include <asm/system.h>
13
14 #if defined(BF537_FAMILY) || defined(BF533_FAMILY) || defined(BF527_FAMILY)
15 #define SYSCR_VAL       0x0
16 #elif defined(BF561_FAMILY)
17 #define SYSCR_VAL       0x20
18 #elif defined(BF548_FAMILY)
19 #define SYSCR_VAL       0x10
20 #endif
21
22 /* A system soft reset makes external memory unusable
23  * so force this function into L1.
24  */
25 __attribute__((l1_text))
26 void bfin_reset(void)
27 {
28         /* force BMODE and disable Core B (as needed) */
29         bfin_write_SYSCR(SYSCR_VAL);
30
31         /* we use asm ssync here because it's save and we save some L1 */
32         asm("ssync;");
33
34         while (1) {
35                 /* initiate system soft reset with magic 0x7 */
36                 bfin_write_SWRST(0x7);
37                 bfin_read_SWRST();
38                 asm("ssync;");
39                 /* clear system soft reset */
40                 bfin_write_SWRST(0);
41                 bfin_read_SWRST();
42                 asm("ssync;");
43                 /* issue core reset */
44                 asm("raise 1");
45         }
46 }
47
48 __attribute__((weak))
49 void native_machine_restart(char *cmd)
50 {
51 }
52
53 void machine_restart(char *cmd)
54 {
55         native_machine_restart(cmd);
56         local_irq_disable();
57         bfin_reset();
58 }
59
60 __attribute__((weak))
61 void native_machine_halt(void)
62 {
63         idle_with_irq_disabled();
64 }
65
66 void machine_halt(void)
67 {
68         native_machine_halt();
69 }
70
71 __attribute__((weak))
72 void native_machine_power_off(void)
73 {
74         idle_with_irq_disabled();
75 }
76
77 void machine_power_off(void)
78 {
79         native_machine_power_off();
80 }