]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/microblaze/kernel/reset.c
MIPS: Remove unneeded #ifdef __KERNEL__ from asm/processor.h
[mirror_ubuntu-artful-kernel.git] / arch / microblaze / kernel / reset.c
CommitLineData
42a2478b
MS
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
19static int handle; /* reset pin handle */
67bf8766 20static unsigned int reset_val;
42a2478b 21
42a2478b
MS
22void of_platform_reset_gpio_probe(void)
23{
24 int ret;
fe9f6844
GL
25 handle = of_get_named_gpio(of_find_node_by_path("/"),
26 "hard-reset-gpios", 0);
42a2478b
MS
27
28 if (!gpio_is_valid(handle)) {
aaa5241e 29 pr_info("Skipping unavailable RESET gpio %d (%s)\n",
42a2478b 30 handle, "reset");
191d5eca 31 return;
42a2478b
MS
32 }
33
34 ret = gpio_request(handle, "reset");
35 if (ret < 0) {
aaa5241e 36 pr_info("GPIO pin is already allocated\n");
42a2478b
MS
37 return;
38 }
39
40 /* get current setup value */
67bf8766 41 reset_val = gpio_get_value(handle);
42a2478b 42 /* FIXME maybe worth to perform any action */
67bf8766 43 pr_debug("Reset: Gpio output state: 0x%x\n", reset_val);
42a2478b
MS
44
45 /* Setup GPIO as output */
46 ret = gpio_direction_output(handle, 0);
47 if (ret < 0)
48 goto err;
49
50 /* Setup output direction */
51 gpio_set_value(handle, 0);
52
aaa5241e 53 pr_info("RESET: Registered gpio device: %d, current val: %d\n",
67bf8766 54 handle, reset_val);
42a2478b
MS
55 return;
56err:
57 gpio_free(handle);
58 return;
59}
60
61
62static void gpio_system_reset(void)
63{
191d5eca
SL
64 if (gpio_is_valid(handle))
65 gpio_set_value(handle, 1 - reset_val);
66 else
67 pr_notice("Reset GPIO unavailable - halting!\n");
42a2478b
MS
68}
69#else
54ea21f0
MS
70static void gpio_system_reset(void)
71{
72 pr_notice("No reset GPIO present - halting!\n");
73}
74
42a2478b
MS
75void of_platform_reset_gpio_probe(void)
76{
77 return;
78}
79#endif
80
81void machine_restart(char *cmd)
82{
aaa5241e 83 pr_notice("Machine restart...\n");
42a2478b 84 gpio_system_reset();
42a2478b
MS
85 while (1)
86 ;
87}
88
89void machine_shutdown(void)
90{
aaa5241e 91 pr_notice("Machine shutdown...\n");
42a2478b
MS
92 while (1)
93 ;
94}
95
96void machine_halt(void)
97{
aaa5241e 98 pr_notice("Machine halt...\n");
42a2478b
MS
99 while (1)
100 ;
101}
102
103void machine_power_off(void)
104{
aaa5241e 105 pr_notice("Machine power off...\n");
42a2478b
MS
106 while (1)
107 ;
108}