blob: 483f93dfc1b590a7ea6cdc582a40eadd3d17982e [file] [log] [blame]
Michael Hennerich2714d9a2007-10-11 00:29:49 +08001/*
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
Michael Hennerich59003142007-10-21 16:54:27 +080014#if defined(BF537_FAMILY) || defined(BF533_FAMILY) || defined(BF527_FAMILY)
Michael Hennerich2714d9a2007-10-11 00:29:49 +080015#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
Michael Hennerich444ad822008-01-22 18:38:02 +080022/*
23 * Delay min 5 SCLK cycles using worst case CCLK/SCLK ratio (15)
24 */
25#define SWRST_DELAY (5 * 15)
26
Michael Hennerich2714d9a2007-10-11 00:29:49 +080027/* A system soft reset makes external memory unusable
28 * so force this function into L1.
29 */
30__attribute__((l1_text))
31void bfin_reset(void)
32{
33 /* force BMODE and disable Core B (as needed) */
34 bfin_write_SYSCR(SYSCR_VAL);
35
36 /* we use asm ssync here because it's save and we save some L1 */
37 asm("ssync;");
38
39 while (1) {
40 /* initiate system soft reset with magic 0x7 */
41 bfin_write_SWRST(0x7);
Michael Hennerich444ad822008-01-22 18:38:02 +080042
43 /* Wait for System reset to actually reset, needs to be 5 SCLKs, */
44 /* Assume CCLK / SCLK ratio is worst case (15), and use 5*15 */
45
46 asm("LSETUP(.Lfoo,.Lfoo) LC0 = %0\n .Lfoo: NOP;\n"
47 : : "a" (SWRST_DELAY) : "LC0", "LT0", "LB0");
48
Michael Hennerich2714d9a2007-10-11 00:29:49 +080049 /* clear system soft reset */
50 bfin_write_SWRST(0);
Michael Hennerich2714d9a2007-10-11 00:29:49 +080051 asm("ssync;");
52 /* issue core reset */
53 asm("raise 1");
54 }
55}
56
57__attribute__((weak))
58void native_machine_restart(char *cmd)
59{
60}
61
62void machine_restart(char *cmd)
63{
64 native_machine_restart(cmd);
65 local_irq_disable();
66 bfin_reset();
67}
68
69__attribute__((weak))
70void native_machine_halt(void)
71{
72 idle_with_irq_disabled();
73}
74
75void machine_halt(void)
76{
77 native_machine_halt();
78}
79
80__attribute__((weak))
81void native_machine_power_off(void)
82{
83 idle_with_irq_disabled();
84}
85
86void machine_power_off(void)
87{
88 native_machine_power_off();
89}