/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * HP PARISC soft power switch driver * * Copyright (c) 2001-2023 Helge Deller <deller@gmx.de> * * HINT: * Support of the soft power switch button may be enabled or disabled at * runtime through the "/proc/sys/kernel/power" procfs entry.
*/
#define MTCPU(dr, gr) MFCPU_X(dr, gr, 0, 0x12) /* move value of gr to dr[dr] */ #define MFCPU_C(dr, gr) MFCPU_X(dr, gr, 0, 0x30) /* for dr0 and dr8 only ! */ #define MFCPU_T(dr, gr) MFCPU_X(dr, 0, gr, 0xa0) /* all dr except dr0 and dr8 */
/* local shutdown counter */ staticint shutdown_timer __read_mostly;
/* check, give feedback and start shutdown after one second */ staticvoid process_shutdown(void)
{ if (shutdown_timer == 0)
printk(KERN_ALERT KTHREAD_NAME ": Shutdown requested...\n");
shutdown_timer++;
/* wait until the button was pressed for 1 second */ if (shutdown_timer == (POWERSWITCH_DOWN_SEC*POWERSWITCH_POLL_PER_SEC)) { staticconstchar msg[] = "Shutting down...";
printk(KERN_INFO KTHREAD_NAME ": %s\n", msg);
lcd_print(msg);
/* send kill signal */ if (kill_cad_pid(SIGINT, 1)) { /* just in case killing init process failed */
machine_power_off();
}
}
}
/* main power switch task struct */ staticstruct task_struct *power_task;
/* filename in /proc which can be used to enable/disable the power switch */ #define SYSCTL_FILENAME "sys/kernel/power"
if (soft_power_reg) { /* * Non-Gecko-style machines: * Check the power switch status which is read from the * real I/O location at soft_power_reg. * Bit 31 ("the lowest bit) is the status of the power switch. * This bit is "1" if the button is NOT pressed.
*/
button_not_pressed = (gsc_readl(soft_power_reg) & 0x1);
} else { /* * On gecko style machines (e.g. 712/xx and 715/xx) * the power switch status is stored in Bit 0 ("the highest bit") * of CPU diagnose register 25. * Warning: Some machines never reset the DIAG flag, even if * the button has been released again.
*/
button_not_pressed = (__getDIAG(25) & 0x80000000);
}
if (likely(button_not_pressed)) { if (unlikely(shutdown_timer && /* avoid writing if not necessary */
shutdown_timer < (POWERSWITCH_DOWN_SEC*POWERSWITCH_POLL_PER_SEC))) {
shutdown_timer = 0;
printk(KERN_INFO KTHREAD_NAME ": Shutdown request aborted.\n");
}
} else
process_shutdown();
/* * parisc_panic_event() is called by the panic handler. * * As soon as a panic occurs, our tasklets above will not * be executed any longer. This function then re-enables * the soft-power switch and allows the user to switch off * the system. We rely in pdc_soft_power_button_panic() * since this version spin_trylocks (instead of regular * spinlock), preventing deadlocks on panic path.
*/ staticint parisc_panic_event(struct notifier_block *this, unsignedlong event, void *ptr)
{ /* re-enable the soft-power switch */
pdc_soft_power_button_panic(0); return NOTIFY_DONE;
}
/* qemu soft power-off function */ staticint qemu_power_off(struct sys_off_data *data)
{ /* this turns the system off via SeaBIOS */
gsc_writel(0, (unsignedlong) data->cb_data);
pdc_soft_power_button(1); return NOTIFY_DONE;
}
/* enable the soft power switch if possible */
ret = pdc_soft_power_info(&soft_power_reg); if (ret == PDC_OK)
ret = pdc_soft_power_button(1); if (ret != PDC_OK)
soft_power_reg = -1UL;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.