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

TOMOYO Linux Cross Reference
Linux/arch/mips/sgi-ip22/ip22-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 ] ~

Diff markup

Differences between /arch/mips/sgi-ip22/ip22-reset.c (Architecture m68k) and /arch/mips/sgi-ip22/ip22-reset.c (Architecture mips)


  1 /*                                                  1 /*
  2  * This file is subject to the terms and condi      2  * This file is subject to the terms and conditions of the GNU General Public
  3  * License.  See the file "COPYING" in the mai      3  * License.  See the file "COPYING" in the main directory of this archive
  4  * for more details.                                4  * for more details.
  5  *                                                  5  *
  6  * Copyright (C) 1997, 1998, 2001, 03, 05, 06       6  * Copyright (C) 1997, 1998, 2001, 03, 05, 06 by Ralf Baechle
  7  */                                                 7  */
  8 #include <linux/linkage.h>                          8 #include <linux/linkage.h>
  9 #include <linux/init.h>                             9 #include <linux/init.h>
 10 #include <linux/rtc/ds1286.h>                      10 #include <linux/rtc/ds1286.h>
 11 #include <linux/interrupt.h>                       11 #include <linux/interrupt.h>
 12 #include <linux/kernel.h>                          12 #include <linux/kernel.h>
 13 #include <linux/sched/signal.h>                    13 #include <linux/sched/signal.h>
 14 #include <linux/panic_notifier.h>                  14 #include <linux/panic_notifier.h>
 15 #include <linux/pm.h>                              15 #include <linux/pm.h>
 16 #include <linux/timer.h>                           16 #include <linux/timer.h>
 17                                                    17 
 18 #include <asm/io.h>                                18 #include <asm/io.h>
 19 #include <asm/irq.h>                               19 #include <asm/irq.h>
 20 #include <asm/reboot.h>                            20 #include <asm/reboot.h>
 21 #include <asm/sgialib.h>                           21 #include <asm/sgialib.h>
 22 #include <asm/sgi/ioc.h>                           22 #include <asm/sgi/ioc.h>
 23 #include <asm/sgi/hpc3.h>                          23 #include <asm/sgi/hpc3.h>
 24 #include <asm/sgi/mc.h>                            24 #include <asm/sgi/mc.h>
 25 #include <asm/sgi/ip22.h>                          25 #include <asm/sgi/ip22.h>
 26                                                    26 
 27 /*                                                 27 /*
 28  * Just powerdown if init hasn't done after PO     28  * Just powerdown if init hasn't done after POWERDOWN_TIMEOUT seconds.
 29  * I'm not sure if this feature is a good idea     29  * I'm not sure if this feature is a good idea, for now it's here just to
 30  * make the power button make behave just like     30  * make the power button make behave just like under IRIX.
 31  */                                                31  */
 32 #define POWERDOWN_TIMEOUT       120                32 #define POWERDOWN_TIMEOUT       120
 33                                                    33 
 34 /*                                                 34 /*
 35  * Blink frequency during reboot grace period      35  * Blink frequency during reboot grace period and when panicked.
 36  */                                                36  */
 37 #define POWERDOWN_FREQ          (HZ / 4)           37 #define POWERDOWN_FREQ          (HZ / 4)
 38 #define PANIC_FREQ              (HZ / 8)           38 #define PANIC_FREQ              (HZ / 8)
 39                                                    39 
 40 static struct timer_list power_timer, blink_ti     40 static struct timer_list power_timer, blink_timer, debounce_timer;
 41 static unsigned long blink_timer_timeout;          41 static unsigned long blink_timer_timeout;
 42                                                    42 
 43 #define MACHINE_PANICKED                1          43 #define MACHINE_PANICKED                1
 44 #define MACHINE_SHUTTING_DOWN   2                  44 #define MACHINE_SHUTTING_DOWN   2
 45                                                    45 
 46 static int machine_state;                          46 static int machine_state;
 47                                                    47 
 48 static void __noreturn sgi_machine_power_off(v     48 static void __noreturn sgi_machine_power_off(void)
 49 {                                                  49 {
 50         unsigned int tmp;                          50         unsigned int tmp;
 51                                                    51 
 52         local_irq_disable();                       52         local_irq_disable();
 53                                                    53 
 54         /* Disable watchdog */                     54         /* Disable watchdog */
 55         tmp = hpc3c0->rtcregs[RTC_CMD] & 0xff;     55         tmp = hpc3c0->rtcregs[RTC_CMD] & 0xff;
 56         hpc3c0->rtcregs[RTC_CMD] = tmp | RTC_W     56         hpc3c0->rtcregs[RTC_CMD] = tmp | RTC_WAM;
 57         hpc3c0->rtcregs[RTC_WSEC] = 0;             57         hpc3c0->rtcregs[RTC_WSEC] = 0;
 58         hpc3c0->rtcregs[RTC_WHSEC] = 0;            58         hpc3c0->rtcregs[RTC_WHSEC] = 0;
 59                                                    59 
 60         while (1) {                                60         while (1) {
 61                 sgioc->panel = ~SGIOC_PANEL_PO     61                 sgioc->panel = ~SGIOC_PANEL_POWERON;
 62                 /* Good bye cruel world ...  *     62                 /* Good bye cruel world ...  */
 63                                                    63 
 64                 /* If we're still running, we      64                 /* If we're still running, we probably got sent an alarm
 65                    interrupt.  Read the flag t     65                    interrupt.  Read the flag to clear it.  */
 66                 tmp = hpc3c0->rtcregs[RTC_HOUR     66                 tmp = hpc3c0->rtcregs[RTC_HOURS_ALARM];
 67         }                                          67         }
 68 }                                                  68 }
 69                                                    69 
 70 static void __noreturn sgi_machine_restart(cha     70 static void __noreturn sgi_machine_restart(char *command)
 71 {                                                  71 {
 72         if (machine_state & MACHINE_SHUTTING_D     72         if (machine_state & MACHINE_SHUTTING_DOWN)
 73                 sgi_machine_power_off();           73                 sgi_machine_power_off();
 74         sgimc->cpuctrl0 |= SGIMC_CCTRL0_SYSINI     74         sgimc->cpuctrl0 |= SGIMC_CCTRL0_SYSINIT;
 75         while (1);                                 75         while (1);
 76 }                                                  76 }
 77                                                    77 
 78 static void __noreturn sgi_machine_halt(void)      78 static void __noreturn sgi_machine_halt(void)
 79 {                                                  79 {
 80         if (machine_state & MACHINE_SHUTTING_D     80         if (machine_state & MACHINE_SHUTTING_DOWN)
 81                 sgi_machine_power_off();           81                 sgi_machine_power_off();
 82         ArcEnterInteractiveMode();                 82         ArcEnterInteractiveMode();
 83 }                                                  83 }
 84                                                    84 
 85 static void power_timeout(struct timer_list *u     85 static void power_timeout(struct timer_list *unused)
 86 {                                                  86 {
 87         sgi_machine_power_off();                   87         sgi_machine_power_off();
 88 }                                                  88 }
 89                                                    89 
 90 static void blink_timeout(struct timer_list *u     90 static void blink_timeout(struct timer_list *unused)
 91 {                                                  91 {
 92         /* XXX fix this for fullhouse  */          92         /* XXX fix this for fullhouse  */
 93         sgi_ioc_reset ^= (SGIOC_RESET_LC0OFF|S     93         sgi_ioc_reset ^= (SGIOC_RESET_LC0OFF|SGIOC_RESET_LC1OFF);
 94         sgioc->reset = sgi_ioc_reset;              94         sgioc->reset = sgi_ioc_reset;
 95                                                    95 
 96         mod_timer(&blink_timer, jiffies + blin     96         mod_timer(&blink_timer, jiffies + blink_timer_timeout);
 97 }                                                  97 }
 98                                                    98 
 99 static void debounce(struct timer_list *unused     99 static void debounce(struct timer_list *unused)
100 {                                                 100 {
101         del_timer(&debounce_timer);               101         del_timer(&debounce_timer);
102         if (sgint->istat1 & SGINT_ISTAT1_PWR)     102         if (sgint->istat1 & SGINT_ISTAT1_PWR) {
103                 /* Interrupt still being sent.    103                 /* Interrupt still being sent. */
104                 debounce_timer.expires = jiffi    104                 debounce_timer.expires = jiffies + (HZ / 20); /* 0.05s  */
105                 add_timer(&debounce_timer);       105                 add_timer(&debounce_timer);
106                                                   106 
107                 sgioc->panel = SGIOC_PANEL_POW    107                 sgioc->panel = SGIOC_PANEL_POWERON | SGIOC_PANEL_POWERINTR |
108                                SGIOC_PANEL_VOL    108                                SGIOC_PANEL_VOLDNINTR | SGIOC_PANEL_VOLDNHOLD |
109                                SGIOC_PANEL_VOL    109                                SGIOC_PANEL_VOLUPINTR | SGIOC_PANEL_VOLUPHOLD;
110                                                   110 
111                 return;                           111                 return;
112         }                                         112         }
113                                                   113 
114         if (machine_state & MACHINE_PANICKED)     114         if (machine_state & MACHINE_PANICKED)
115                 sgimc->cpuctrl0 |= SGIMC_CCTRL    115                 sgimc->cpuctrl0 |= SGIMC_CCTRL0_SYSINIT;
116                                                   116 
117         enable_irq(SGI_PANEL_IRQ);                117         enable_irq(SGI_PANEL_IRQ);
118 }                                                 118 }
119                                                   119 
120 static inline void power_button(void)             120 static inline void power_button(void)
121 {                                                 121 {
122         if (machine_state & MACHINE_PANICKED)     122         if (machine_state & MACHINE_PANICKED)
123                 return;                           123                 return;
124                                                   124 
125         if ((machine_state & MACHINE_SHUTTING_    125         if ((machine_state & MACHINE_SHUTTING_DOWN) ||
126                         kill_cad_pid(SIGINT, 1    126                         kill_cad_pid(SIGINT, 1)) {
127                 /* No init process or button p    127                 /* No init process or button pressed twice.  */
128                 sgi_machine_power_off();          128                 sgi_machine_power_off();
129         }                                         129         }
130                                                   130 
131         machine_state |= MACHINE_SHUTTING_DOWN    131         machine_state |= MACHINE_SHUTTING_DOWN;
132         blink_timer_timeout = POWERDOWN_FREQ;     132         blink_timer_timeout = POWERDOWN_FREQ;
133         blink_timeout(&blink_timer);              133         blink_timeout(&blink_timer);
134                                                   134 
135         timer_setup(&power_timer, power_timeou    135         timer_setup(&power_timer, power_timeout, 0);
136         power_timer.expires = jiffies + POWERD    136         power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ;
137         add_timer(&power_timer);                  137         add_timer(&power_timer);
138 }                                                 138 }
139                                                   139 
140 static irqreturn_t panel_int(int irq, void *de    140 static irqreturn_t panel_int(int irq, void *dev_id)
141 {                                                 141 {
142         unsigned int buttons;                     142         unsigned int buttons;
143                                                   143 
144         buttons = sgioc->panel;                   144         buttons = sgioc->panel;
145         sgioc->panel = SGIOC_PANEL_POWERON | S    145         sgioc->panel = SGIOC_PANEL_POWERON | SGIOC_PANEL_POWERINTR;
146                                                   146 
147         if (sgint->istat1 & SGINT_ISTAT1_PWR)     147         if (sgint->istat1 & SGINT_ISTAT1_PWR) {
148                 /* Wait until interrupt goes a    148                 /* Wait until interrupt goes away */
149                 disable_irq_nosync(SGI_PANEL_I    149                 disable_irq_nosync(SGI_PANEL_IRQ);
150                 timer_setup(&debounce_timer, d    150                 timer_setup(&debounce_timer, debounce, 0);
151                 debounce_timer.expires = jiffi    151                 debounce_timer.expires = jiffies + 5;
152                 add_timer(&debounce_timer);       152                 add_timer(&debounce_timer);
153         }                                         153         }
154                                                   154 
155         /* Power button was pressed               155         /* Power button was pressed
156          * ioc.ps page 22: "The Panel Register    156          * ioc.ps page 22: "The Panel Register is called Power Control by Full
157          * House. Only lowest 2 bits are used.    157          * House. Only lowest 2 bits are used. Guiness uses upper four bits
158          * for volume control". This is not tr    158          * for volume control". This is not true, all bits are pulled high
159          * on fullhouse */                        159          * on fullhouse */
160         if (!(buttons & SGIOC_PANEL_POWERINTR)    160         if (!(buttons & SGIOC_PANEL_POWERINTR))
161                 power_button();                   161                 power_button();
162                                                   162 
163         return IRQ_HANDLED;                       163         return IRQ_HANDLED;
164 }                                                 164 }
165                                                   165 
166 static int panic_event(struct notifier_block *    166 static int panic_event(struct notifier_block *this, unsigned long event,
167                       void *ptr)                  167                       void *ptr)
168 {                                                 168 {
169         if (machine_state & MACHINE_PANICKED)     169         if (machine_state & MACHINE_PANICKED)
170                 return NOTIFY_DONE;               170                 return NOTIFY_DONE;
171         machine_state |= MACHINE_PANICKED;        171         machine_state |= MACHINE_PANICKED;
172                                                   172 
173         blink_timer_timeout = PANIC_FREQ;         173         blink_timer_timeout = PANIC_FREQ;
174         blink_timeout(&blink_timer);              174         blink_timeout(&blink_timer);
175                                                   175 
176         return NOTIFY_DONE;                       176         return NOTIFY_DONE;
177 }                                                 177 }
178                                                   178 
179 static struct notifier_block panic_block = {      179 static struct notifier_block panic_block = {
180         .notifier_call  = panic_event,            180         .notifier_call  = panic_event,
181 };                                                181 };
182                                                   182 
183 static int __init reboot_setup(void)              183 static int __init reboot_setup(void)
184 {                                                 184 {
185         int res;                                  185         int res;
186                                                   186 
187         _machine_restart = sgi_machine_restart    187         _machine_restart = sgi_machine_restart;
188         _machine_halt = sgi_machine_halt;         188         _machine_halt = sgi_machine_halt;
189         pm_power_off = sgi_machine_power_off;     189         pm_power_off = sgi_machine_power_off;
190                                                   190 
191         res = request_irq(SGI_PANEL_IRQ, panel    191         res = request_irq(SGI_PANEL_IRQ, panel_int, 0, "Front Panel", NULL);
192         if (res) {                                192         if (res) {
193                 printk(KERN_ERR "Allocation of    193                 printk(KERN_ERR "Allocation of front panel IRQ failed\n");
194                 return res;                       194                 return res;
195         }                                         195         }
196                                                   196 
197         timer_setup(&blink_timer, blink_timeou    197         timer_setup(&blink_timer, blink_timeout, 0);
198         atomic_notifier_chain_register(&panic_    198         atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
199                                                   199 
200         return 0;                                 200         return 0;
201 }                                                 201 }
202                                                   202 
203 subsys_initcall(reboot_setup);                    203 subsys_initcall(reboot_setup);
204                                                   204 

~ [ 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