]> Pileus Git - ~andy/linux/blob - arch/microblaze/kernel/reset.c
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[~andy/linux] / arch / microblaze / kernel / reset.c
1 /*
2  * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
3  * Copyright (C) 2009 PetaLogix
4  *
5  * This file is subject to the terms and conditions of the GNU General Public
6  * License. See the file "COPYING" in the main directory of this archive
7  * for more details.
8  */
9
10 #include <linux/init.h>
11 #include <linux/of_platform.h>
12 #include <asm/prom.h>
13
14 /* Trigger specific functions */
15 #ifdef CONFIG_GPIOLIB
16
17 #include <linux/of_gpio.h>
18
19 static int handle; /* reset pin handle */
20 static unsigned int reset_val;
21
22 void of_platform_reset_gpio_probe(void)
23 {
24         int ret;
25         handle = of_get_named_gpio(of_find_node_by_path("/"),
26                                    "hard-reset-gpios", 0);
27
28         if (!gpio_is_valid(handle)) {
29                 printk(KERN_INFO "Skipping unavailable RESET gpio %d (%s)\n",
30                                 handle, "reset");
31         }
32
33         ret = gpio_request(handle, "reset");
34         if (ret < 0) {
35                 printk(KERN_INFO "GPIO pin is already allocated\n");
36                 return;
37         }
38
39         /* get current setup value */
40         reset_val = gpio_get_value(handle);
41         /* FIXME maybe worth to perform any action */
42         pr_debug("Reset: Gpio output state: 0x%x\n", reset_val);
43
44         /* Setup GPIO as output */
45         ret = gpio_direction_output(handle, 0);
46         if (ret < 0)
47                 goto err;
48
49         /* Setup output direction */
50         gpio_set_value(handle, 0);
51
52         printk(KERN_INFO "RESET: Registered gpio device: %d, current val: %d\n",
53                                                         handle, reset_val);
54         return;
55 err:
56         gpio_free(handle);
57         return;
58 }
59
60
61 static void gpio_system_reset(void)
62 {
63         gpio_set_value(handle, 1 - reset_val);
64 }
65 #else
66 #define gpio_system_reset() do {} while (0)
67 void of_platform_reset_gpio_probe(void)
68 {
69         return;
70 }
71 #endif
72
73 void machine_restart(char *cmd)
74 {
75         printk(KERN_NOTICE "Machine restart...\n");
76         gpio_system_reset();
77         dump_stack();
78         while (1)
79                 ;
80 }
81
82 void machine_shutdown(void)
83 {
84         printk(KERN_NOTICE "Machine shutdown...\n");
85         while (1)
86                 ;
87 }
88
89 void machine_halt(void)
90 {
91         printk(KERN_NOTICE "Machine halt...\n");
92         while (1)
93                 ;
94 }
95
96 void machine_power_off(void)
97 {
98         printk(KERN_NOTICE "Machine power off...\n");
99         while (1)
100                 ;
101 }