mtd: nand: omap: Fix comment in platform data using wrong Kconfig symbol
[linux/fpc-iii.git] / arch / microblaze / kernel / reset.c
blobfcbe1daf631662f8d45a580126f58d2090d90023
1 /*
2 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2009 PetaLogix
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 */
10 #include <linux/init.h>
11 #include <linux/of_platform.h>
13 /* Trigger specific functions */
14 #ifdef CONFIG_GPIOLIB
16 #include <linux/of_gpio.h>
18 static int handle; /* reset pin handle */
19 static unsigned int reset_val;
21 static int of_platform_reset_gpio_probe(void)
23 int ret;
24 handle = of_get_named_gpio(of_find_node_by_path("/"),
25 "hard-reset-gpios", 0);
27 if (!gpio_is_valid(handle)) {
28 pr_info("Skipping unavailable RESET gpio %d (%s)\n",
29 handle, "reset");
30 return -ENODEV;
33 ret = gpio_request(handle, "reset");
34 if (ret < 0) {
35 pr_info("GPIO pin is already allocated\n");
36 return ret;
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);
44 /* Setup GPIO as output */
45 ret = gpio_direction_output(handle, 0);
46 if (ret < 0)
47 goto err;
49 /* Setup output direction */
50 gpio_set_value(handle, 0);
52 pr_info("RESET: Registered gpio device: %d, current val: %d\n",
53 handle, reset_val);
54 return 0;
55 err:
56 gpio_free(handle);
57 return ret;
59 device_initcall(of_platform_reset_gpio_probe);
62 static void gpio_system_reset(void)
64 if (gpio_is_valid(handle))
65 gpio_set_value(handle, 1 - reset_val);
66 else
67 pr_notice("Reset GPIO unavailable - halting!\n");
69 #else
70 static void gpio_system_reset(void)
72 pr_notice("No reset GPIO present - halting!\n");
75 void of_platform_reset_gpio_probe(void)
77 return;
79 #endif
81 void machine_restart(char *cmd)
83 pr_notice("Machine restart...\n");
84 gpio_system_reset();
85 while (1)
89 void machine_shutdown(void)
91 pr_notice("Machine shutdown...\n");
92 while (1)
96 void machine_halt(void)
98 pr_notice("Machine halt...\n");
99 while (1)
103 void machine_power_off(void)
105 pr_notice("Machine power off...\n");
106 while (1)