~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/sgi-ip32/ip32-reset.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * This file is subject to the terms and conditions of the GNU General Public
  3  * License.  See the file "COPYING" in the main directory of this archive
  4  * for more details.
  5  *
  6  * Copyright (C) 2001 Keith M Wesolowski
  7  * Copyright (C) 2001 Paul Mundt
  8  * Copyright (C) 2003 Guido Guenther <agx@sigxcpu.org>
  9  */
 10 
 11 #include <linux/compiler.h>
 12 #include <linux/init.h>
 13 #include <linux/kernel.h>
 14 #include <linux/module.h>
 15 #include <linux/panic_notifier.h>
 16 #include <linux/sched.h>
 17 #include <linux/sched/signal.h>
 18 #include <linux/notifier.h>
 19 #include <linux/delay.h>
 20 #include <linux/rtc/ds1685.h>
 21 #include <linux/interrupt.h>
 22 #include <linux/pm.h>
 23 
 24 #include <asm/addrspace.h>
 25 #include <asm/irq.h>
 26 #include <asm/reboot.h>
 27 #include <asm/wbflush.h>
 28 #include <asm/ip32/mace.h>
 29 #include <asm/ip32/crime.h>
 30 #include <asm/ip32/ip32_ints.h>
 31 
 32 #include "ip32-common.h"
 33 
 34 #define POWERDOWN_TIMEOUT       120
 35 /*
 36  * Blink frequency during reboot grace period and when panicked.
 37  */
 38 #define POWERDOWN_FREQ          (HZ / 4)
 39 #define PANIC_FREQ              (HZ / 8)
 40 
 41 extern struct platform_device ip32_rtc_device;
 42 
 43 static struct timer_list power_timer, blink_timer;
 44 static unsigned long blink_timer_timeout;
 45 static int has_panicked, shutting_down;
 46 
 47 static __noreturn void ip32_poweroff(void *data)
 48 {
 49         void (*poweroff_func)(struct platform_device *) =
 50                 symbol_get(ds1685_rtc_poweroff);
 51 
 52 #ifdef CONFIG_MODULES
 53         /* If the first __symbol_get failed, our module wasn't loaded. */
 54         if (!poweroff_func) {
 55                 request_module("rtc-ds1685");
 56                 poweroff_func = symbol_get(ds1685_rtc_poweroff);
 57         }
 58 #endif
 59 
 60         if (!poweroff_func)
 61                 pr_emerg("RTC not available for power-off.  Spinning forever ...\n");
 62         else {
 63                 (*poweroff_func)((struct platform_device *)data);
 64                 symbol_put(ds1685_rtc_poweroff);
 65         }
 66 
 67         unreachable();
 68 }
 69 
 70 static void ip32_machine_restart(char *cmd) __noreturn;
 71 static void ip32_machine_restart(char *cmd)
 72 {
 73         msleep(20);
 74         crime->control = CRIME_CONTROL_HARD_RESET;
 75         unreachable();
 76 }
 77 
 78 static void blink_timeout(struct timer_list *unused)
 79 {
 80         unsigned long led = mace->perif.ctrl.misc ^ MACEISA_LED_RED;
 81         mace->perif.ctrl.misc = led;
 82         mod_timer(&blink_timer, jiffies + blink_timer_timeout);
 83 }
 84 
 85 static void ip32_machine_halt(void)
 86 {
 87         ip32_poweroff(&ip32_rtc_device);
 88 }
 89 
 90 static void power_timeout(struct timer_list *unused)
 91 {
 92         ip32_poweroff(&ip32_rtc_device);
 93 }
 94 
 95 void ip32_prepare_poweroff(void)
 96 {
 97         if (has_panicked)
 98                 return;
 99 
100         if (shutting_down || kill_cad_pid(SIGINT, 1)) {
101                 /* No init process or button pressed twice.  */
102                 ip32_poweroff(&ip32_rtc_device);
103         }
104 
105         shutting_down = 1;
106         blink_timer_timeout = POWERDOWN_FREQ;
107         blink_timeout(&blink_timer);
108 
109         timer_setup(&power_timer, power_timeout, 0);
110         power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ;
111         add_timer(&power_timer);
112 }
113 
114 static int panic_event(struct notifier_block *this, unsigned long event,
115                        void *ptr)
116 {
117         unsigned long led;
118 
119         if (has_panicked)
120                 return NOTIFY_DONE;
121         has_panicked = 1;
122 
123         /* turn off the green LED */
124         led = mace->perif.ctrl.misc | MACEISA_LED_GREEN;
125         mace->perif.ctrl.misc = led;
126 
127         blink_timer_timeout = PANIC_FREQ;
128         blink_timeout(&blink_timer);
129 
130         return NOTIFY_DONE;
131 }
132 
133 static struct notifier_block panic_block = {
134         .notifier_call = panic_event,
135 };
136 
137 static __init int ip32_reboot_setup(void)
138 {
139         /* turn on the green led only */
140         unsigned long led = mace->perif.ctrl.misc;
141         led |= MACEISA_LED_RED;
142         led &= ~MACEISA_LED_GREEN;
143         mace->perif.ctrl.misc = led;
144 
145         _machine_restart = ip32_machine_restart;
146         _machine_halt = ip32_machine_halt;
147         pm_power_off = ip32_machine_halt;
148 
149         timer_setup(&blink_timer, blink_timeout, 0);
150         atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
151 
152         return 0;
153 }
154 
155 subsys_initcall(ip32_reboot_setup);
156 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php