hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/arch/microblaze/kernel/reset.c
....@@ -8,83 +8,9 @@
88 */
99
1010 #include <linux/init.h>
11
+#include <linux/delay.h>
1112 #include <linux/of_platform.h>
12
-
13
-/* Trigger specific functions */
14
-#ifdef CONFIG_GPIOLIB
15
-
16
-#include <linux/of_gpio.h>
17
-
18
-static int handle; /* reset pin handle */
19
-static unsigned int reset_val;
20
-
21
-static int of_platform_reset_gpio_probe(void)
22
-{
23
- int ret;
24
- handle = of_get_named_gpio(of_find_node_by_path("/"),
25
- "hard-reset-gpios", 0);
26
-
27
- if (!gpio_is_valid(handle)) {
28
- pr_info("Skipping unavailable RESET gpio %d (%s)\n",
29
- handle, "reset");
30
- return -ENODEV;
31
- }
32
-
33
- ret = gpio_request(handle, "reset");
34
- if (ret < 0) {
35
- pr_info("GPIO pin is already allocated\n");
36
- return ret;
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
- 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;
58
-}
59
-device_initcall(of_platform_reset_gpio_probe);
60
-
61
-
62
-static void gpio_system_reset(void)
63
-{
64
- if (gpio_is_valid(handle))
65
- gpio_set_value(handle, 1 - reset_val);
66
- else
67
- pr_notice("Reset GPIO unavailable - halting!\n");
68
-}
69
-#else
70
-static void gpio_system_reset(void)
71
-{
72
- pr_notice("No reset GPIO present - halting!\n");
73
-}
74
-
75
-void of_platform_reset_gpio_probe(void)
76
-{
77
- return;
78
-}
79
-#endif
80
-
81
-void machine_restart(char *cmd)
82
-{
83
- pr_notice("Machine restart...\n");
84
- gpio_system_reset();
85
- while (1)
86
- ;
87
-}
13
+#include <linux/reboot.h>
8814
8915 void machine_shutdown(void)
9016 {
....@@ -106,3 +32,12 @@
10632 while (1)
10733 ;
10834 }
35
+
36
+void machine_restart(char *cmd)
37
+{
38
+ do_kernel_restart(cmd);
39
+ /* Give the restart hook 1 s to take us down */
40
+ mdelay(1000);
41
+ pr_emerg("Reboot failed -- System halted\n");
42
+ while (1);
43
+}