1+ /* SPDX-License-Identifier: GPL-2.0-or-later */
12/*
2- * linux/drivers/parisc/power.c
3- * HP PARISC soft power switch support driver
4- *
5- * Copyright (c) 2001-2007 Helge Deller <deller@gmx.de>
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
304 *
5+ * Copyright (c) 2001-2023 Helge Deller <deller@gmx.de>
316 *
327 * HINT:
338 * Support of the soft power switch button may be enabled or disabled at
349 * runtime through the "/proc/sys/kernel/power" procfs entry.
35- */
10+ */
3611
3712#include <linux/module.h>
3813#include <linux/init.h>
6237
6338#define MFCPU_X (rDiagReg , t_ch , t_th , code ) \
6439 (DIAG_CODE(code) + ((rDiagReg)<<21) + ((t_ch)<<16) + ((t_th)<<0) )
65-
40+
6641#define MTCPU (dr , gr ) MFCPU_X(dr, gr, 0, 0x12) /* move value of gr to dr[dr] */
6742#define MFCPU_C (dr , gr ) MFCPU_X(dr, gr, 0, 0x30) /* for dr0 and dr8 only ! */
6843#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 ) ( { \
7146 register unsigned long __res asm("r28");\
7247 __asm__ __volatile__ ( \
7348 ".word %1" : "=&r" (__res) : "i" (MFCPU_T(dr,28) ) \
@@ -85,7 +60,7 @@ static void process_shutdown(void)
8560 printk (KERN_ALERT KTHREAD_NAME ": Shutdown requested...\n" );
8661
8762 shutdown_timer ++ ;
88-
63+
8964 /* wait until the button was pressed for 1 second */
9065 if (shutdown_timer == (POWERSWITCH_DOWN_SEC * POWERSWITCH_POLL_PER_SEC )) {
9166 static const char msg [] = "Shutting down..." ;
@@ -135,7 +110,7 @@ static int kpowerswd(void *param)
135110 button_not_pressed = (gsc_readl (soft_power_reg ) & 0x1 );
136111 } else {
137112 /*
138- * On gecko style machines (e.g. 712/xx and 715/xx)
113+ * On gecko style machines (e.g. 712/xx and 715/xx)
139114 * the power switch status is stored in Bit 0 ("the highest bit")
140115 * of CPU diagnose register 25.
141116 * Warning: Some machines never reset the DIAG flag, even if
@@ -161,7 +136,7 @@ static int kpowerswd(void *param)
161136
162137
163138/*
164- * powerfail interruption handler (irq IRQ_FROM_REGION(CPU_IRQ_REGION)+2)
139+ * powerfail interruption handler (irq IRQ_FROM_REGION(CPU_IRQ_REGION)+2)
165140 */
166141#if 0
167142static void powerfail_interrupt (int code , void * x )
@@ -222,14 +197,14 @@ static int __init power_init(void)
222197 ret = pdc_soft_power_button (1 );
223198 if (ret != PDC_OK )
224199 soft_power_reg = -1UL ;
225-
200+
226201 switch (soft_power_reg ) {
227202 case 0 : printk (KERN_INFO DRIVER_NAME ": Gecko-style soft power switch enabled.\n" );
228203 break ;
229-
204+
230205 case -1UL : printk (KERN_INFO DRIVER_NAME ": Soft power switch support not available.\n" );
231206 return - ENODEV ;
232-
207+
233208 default : printk (KERN_INFO DRIVER_NAME ": Soft power switch at 0x%08lx enabled.\n" ,
234209 soft_power_reg );
235210 }
0 commit comments