1
+ /* SPDX-License-Identifier: GPL-2.0-or-later */
1
2
/*
2
- * linux/drivers/parisc/power.c
3
- * HP PARISC soft power switch support driver
4
- *
5
- * Copyright (c) 2001-2007 Helge Deller <[email protected] >
6
- * All rights reserved.
7
- *
8
- *
9
- * Redistribution and use in source and binary forms, with or without
10
- * modification, are permitted provided that the following conditions
11
- * are met:
12
- * 1. Redistributions of source code must retain the above copyright
13
- * notice, this list of conditions, and the following disclaimer,
14
- * without modification.
15
- * 2. The name of the author may not be used to endorse or promote products
16
- * derived from this software without specific prior written permission.
17
- *
18
- * Alternatively, this software may be distributed under the terms of the
19
- * GNU General Public License ("GPL").
20
- *
21
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
25
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3
+ * HP PARISC soft power switch driver
30
4
*
5
+ * Copyright (c) 2001-2023 Helge Deller <[email protected] >
31
6
*
32
7
* HINT:
33
8
* Support of the soft power switch button may be enabled or disabled at
34
9
* runtime through the "/proc/sys/kernel/power" procfs entry.
35
- */
10
+ */
36
11
37
12
#include <linux/module.h>
38
13
#include <linux/init.h>
62
37
63
38
#define MFCPU_X (rDiagReg , t_ch , t_th , code ) \
64
39
(DIAG_CODE(code) + ((rDiagReg)<<21) + ((t_ch)<<16) + ((t_th)<<0) )
65
-
40
+
66
41
#define MTCPU (dr , gr ) MFCPU_X(dr, gr, 0, 0x12) /* move value of gr to dr[dr] */
67
42
#define MFCPU_C (dr , gr ) MFCPU_X(dr, gr, 0, 0x30) /* for dr0 and dr8 only ! */
68
43
#define MFCPU_T (dr , gr ) MFCPU_X(dr, 0, gr, 0xa0) /* all dr except dr0 and dr8 */
69
-
70
- #define __getDIAG (dr ) ( { \
44
+
45
+ #define __getDIAG (dr ) ( { \
71
46
register unsigned long __res asm("r28");\
72
47
__asm__ __volatile__ ( \
73
48
".word %1" : "=&r" (__res) : "i" (MFCPU_T(dr,28) ) \
@@ -85,7 +60,7 @@ static void process_shutdown(void)
85
60
printk (KERN_ALERT KTHREAD_NAME ": Shutdown requested...\n" );
86
61
87
62
shutdown_timer ++ ;
88
-
63
+
89
64
/* wait until the button was pressed for 1 second */
90
65
if (shutdown_timer == (POWERSWITCH_DOWN_SEC * POWERSWITCH_POLL_PER_SEC )) {
91
66
static const char msg [] = "Shutting down..." ;
@@ -135,7 +110,7 @@ static int kpowerswd(void *param)
135
110
button_not_pressed = (gsc_readl (soft_power_reg ) & 0x1 );
136
111
} else {
137
112
/*
138
- * On gecko style machines (e.g. 712/xx and 715/xx)
113
+ * On gecko style machines (e.g. 712/xx and 715/xx)
139
114
* the power switch status is stored in Bit 0 ("the highest bit")
140
115
* of CPU diagnose register 25.
141
116
* Warning: Some machines never reset the DIAG flag, even if
@@ -161,7 +136,7 @@ static int kpowerswd(void *param)
161
136
162
137
163
138
/*
164
- * powerfail interruption handler (irq IRQ_FROM_REGION(CPU_IRQ_REGION)+2)
139
+ * powerfail interruption handler (irq IRQ_FROM_REGION(CPU_IRQ_REGION)+2)
165
140
*/
166
141
#if 0
167
142
static void powerfail_interrupt (int code , void * x )
@@ -222,14 +197,14 @@ static int __init power_init(void)
222
197
ret = pdc_soft_power_button (1 );
223
198
if (ret != PDC_OK )
224
199
soft_power_reg = -1UL ;
225
-
200
+
226
201
switch (soft_power_reg ) {
227
202
case 0 : printk (KERN_INFO DRIVER_NAME ": Gecko-style soft power switch enabled.\n" );
228
203
break ;
229
-
204
+
230
205
case -1UL : printk (KERN_INFO DRIVER_NAME ": Soft power switch support not available.\n" );
231
206
return - ENODEV ;
232
-
207
+
233
208
default : printk (KERN_INFO DRIVER_NAME ": Soft power switch at 0x%08lx enabled.\n" ,
234
209
soft_power_reg );
235
210
}
0 commit comments