^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * linux/drivers/parisc/power.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * HP PARISC soft power switch support driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2001-2007 Helge Deller <deller@gmx.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * 1. Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * notice, this list of conditions, and the following disclaimer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * without modification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * 2. The name of the author may not be used to endorse or promote products
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * derived from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Alternatively, this software may be distributed under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * GNU General Public License ("GPL").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * HINT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * Support of the soft power switch button may be enabled or disabled at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * runtime through the "/proc/sys/kernel/power" procfs entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <linux/reboot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <linux/kthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <asm/pdc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <asm/led.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define DRIVER_NAME "powersw"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define KTHREAD_NAME "kpowerswd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* how often should the power button be polled ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define POWERSWITCH_POLL_PER_SEC 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* how long does the power button needs to be down until we react ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define POWERSWITCH_DOWN_SEC 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /* assembly code to access special registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /* taken from PCXL ERS page 82 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define DIAG_CODE(code) (0x14000000 + ((code)<<5))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define MFCPU_X(rDiagReg, t_ch, t_th, code) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) (DIAG_CODE(code) + ((rDiagReg)<<21) + ((t_ch)<<16) + ((t_th)<<0) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define MTCPU(dr, gr) MFCPU_X(dr, gr, 0, 0x12) /* move value of gr to dr[dr] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define MFCPU_C(dr, gr) MFCPU_X(dr, gr, 0, 0x30) /* for dr0 and dr8 only ! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define MFCPU_T(dr, gr) MFCPU_X(dr, 0, gr, 0xa0) /* all dr except dr0 and dr8 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define __getDIAG(dr) ( { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) register unsigned long __res asm("r28");\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) __asm__ __volatile__ ( \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) ".word %1" : "=&r" (__res) : "i" (MFCPU_T(dr,28) ) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) ); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) __res; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) } )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* local shutdown counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static int shutdown_timer __read_mostly;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* check, give feedback and start shutdown after one second */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static void process_shutdown(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) if (shutdown_timer == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) printk(KERN_ALERT KTHREAD_NAME ": Shutdown requested...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) shutdown_timer++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* wait until the button was pressed for 1 second */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (shutdown_timer == (POWERSWITCH_DOWN_SEC*POWERSWITCH_POLL_PER_SEC)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static const char msg[] = "Shutting down...";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) printk(KERN_INFO KTHREAD_NAME ": %s\n", msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) lcd_print(msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* send kill signal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if (kill_cad_pid(SIGINT, 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* just in case killing init process failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) machine_power_off();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /* main power switch task struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static struct task_struct *power_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* filename in /proc which can be used to enable/disable the power switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define SYSCTL_FILENAME "sys/kernel/power"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /* soft power switch enabled/disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int pwrsw_enabled __read_mostly = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* main kernel thread worker. It polls the button state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static int kpowerswd(void *param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) __set_current_state(TASK_RUNNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) int button_not_pressed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) unsigned long soft_power_reg = (unsigned long) param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) schedule_timeout_interruptible(pwrsw_enabled ? HZ : HZ/POWERSWITCH_POLL_PER_SEC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (unlikely(!pwrsw_enabled))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if (soft_power_reg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * Non-Gecko-style machines:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * Check the power switch status which is read from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * real I/O location at soft_power_reg.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * Bit 31 ("the lowest bit) is the status of the power switch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * This bit is "1" if the button is NOT pressed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) button_not_pressed = (gsc_readl(soft_power_reg) & 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * On gecko style machines (e.g. 712/xx and 715/xx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * the power switch status is stored in Bit 0 ("the highest bit")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * of CPU diagnose register 25.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * Warning: Some machines never reset the DIAG flag, even if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * the button has been released again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) button_not_pressed = (__getDIAG(25) & 0x80000000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (likely(button_not_pressed)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (unlikely(shutdown_timer && /* avoid writing if not necessary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) shutdown_timer < (POWERSWITCH_DOWN_SEC*POWERSWITCH_POLL_PER_SEC))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) shutdown_timer = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) printk(KERN_INFO KTHREAD_NAME ": Shutdown request aborted.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) process_shutdown();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) } while (!kthread_should_stop());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * powerfail interruption handler (irq IRQ_FROM_REGION(CPU_IRQ_REGION)+2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static void powerfail_interrupt(int code, void *x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) printk(KERN_CRIT "POWERFAIL INTERRUPTION !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) poweroff();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /* parisc_panic_event() is called by the panic handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * As soon as a panic occurs, our tasklets above will not be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * executed any longer. This function then re-enables the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * soft-power switch and allows the user to switch off the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static int parisc_panic_event(struct notifier_block *this,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) unsigned long event, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /* re-enable the soft-power switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) pdc_soft_power_button(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static struct notifier_block parisc_panic_block = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) .notifier_call = parisc_panic_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) .priority = INT_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static int __init power_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) unsigned long ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) unsigned long soft_power_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) request_irq( IRQ_FROM_REGION(CPU_IRQ_REGION)+2, &powerfail_interrupt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 0, "powerfail", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /* enable the soft power switch if possible */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) ret = pdc_soft_power_info(&soft_power_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (ret == PDC_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) ret = pdc_soft_power_button(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (ret != PDC_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) soft_power_reg = -1UL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) switch (soft_power_reg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) case 0: printk(KERN_INFO DRIVER_NAME ": Gecko-style soft power switch enabled.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) case -1UL: printk(KERN_INFO DRIVER_NAME ": Soft power switch support not available.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) default: printk(KERN_INFO DRIVER_NAME ": Soft power switch at 0x%08lx enabled.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) soft_power_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) power_task = kthread_run(kpowerswd, (void*)soft_power_reg, KTHREAD_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (IS_ERR(power_task)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) printk(KERN_ERR DRIVER_NAME ": thread creation failed. Driver not loaded.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) pdc_soft_power_button(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /* Register a call for panic conditions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) atomic_notifier_chain_register(&panic_notifier_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) &parisc_panic_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static void __exit power_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) kthread_stop(power_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) atomic_notifier_chain_unregister(&panic_notifier_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) &parisc_panic_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) pdc_soft_power_button(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) arch_initcall(power_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) module_exit(power_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) MODULE_AUTHOR("Helge Deller <deller@gmx.de>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) MODULE_DESCRIPTION("Soft power switch driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) MODULE_LICENSE("Dual BSD/GPL");