/*
- * interfaces to Chassis Codes via PDC (firmware)
+ * interfaces to log Chassis Codes via PDC (firmware)
*
* Copyright (C) 2002 Laurent Canet <canetl@esiee.fr>
- * Copyright (C) 2002-2006 Thibaut VARENE <varenet@parisc-linux.org>
+ * Copyright (C) 2002-2004 Thibaut VARENE <varenet@parisc-linux.org>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * TODO: poll chassis warns, trigger (configurable) machine shutdown when
- * needed.
- * Find out how to get Chassis warnings out of PAT boxes?
*/
#undef PDC_CHASSIS_DEBUG
#include <linux/reboot.h>
#include <linux/notifier.h>
#include <linux/cache.h>
-#include <linux/proc_fs.h>
#include <asm/pdc_chassis.h>
#include <asm/processor.h>
#include <asm/pdc.h>
#include <asm/pdcpat.h>
-#define PDC_CHASSIS_VER "0.05"
#ifdef CONFIG_PDC_CHASSIS
+static int pdc_chassis_old __read_mostly = 0;
static unsigned int pdc_chassis_enabled __read_mostly = 1;
* Currently, only E class and A180 are known to work with this.
* Inspired by Christoph Plattner
*/
-#if 0
+
static void __init pdc_chassis_checkold(void)
{
switch(CPU_HVERSION) {
case 0x482: /* E45 */
case 0x483: /* E55 */
case 0x516: /* A180 */
+ pdc_chassis_old = 1;
break;
default:
}
DPRINTK(KERN_DEBUG "%s: pdc_chassis_checkold(); pdc_chassis_old = %d\n", __FILE__, pdc_chassis_old);
}
-#endif
+
/**
* pdc_chassis_panic_event() - Called by the panic handler.
void __init parisc_pdc_chassis_init(void)
{
#ifdef CONFIG_PDC_CHASSIS
+ int handle = 0;
if (likely(pdc_chassis_enabled)) {
DPRINTK(KERN_DEBUG "%s: parisc_pdc_chassis_init()\n", __FILE__);
/* Let see if we have something to handle... */
- printk(KERN_INFO "Enabling %s chassis codes support v%s\n",
- is_pdc_pat() ? "PDC_PAT" : "regular",
- PDC_CHASSIS_VER);
-
- /* initialize panic notifier chain */
- atomic_notifier_chain_register(&panic_notifier_list,
- &pdc_chassis_panic_block);
-
- /* initialize reboot notifier chain */
- register_reboot_notifier(&pdc_chassis_reboot_block);
+ /* Check for PDC_PAT or old LED Panel */
+ pdc_chassis_checkold();
+ if (is_pdc_pat()) {
+ printk(KERN_INFO "Enabling PDC_PAT chassis codes support.\n");
+ handle = 1;
+ }
+ else if (unlikely(pdc_chassis_old)) {
+ printk(KERN_INFO "Enabling old style chassis LED panel support.\n");
+ handle = 1;
+ }
+
+ if (handle) {
+ /* initialize panic notifier chain */
+ notifier_chain_register(&panic_notifier_list, &pdc_chassis_panic_block);
+
+ /* initialize reboot notifier chain */
+ register_reboot_notifier(&pdc_chassis_reboot_block);
+ }
}
#endif /* CONFIG_PDC_CHASSIS */
}
}
} else retval = -1;
#else
- if (1) {
+ if (unlikely(pdc_chassis_old)) {
switch (message) {
case PDC_CHASSIS_DIRECT_BSTART:
- retval = pdc_chassis_disp(PDC_CHASSIS_DISP_DATA(OSTAT_INIT));
- break;
-
case PDC_CHASSIS_DIRECT_BCOMPLETE:
retval = pdc_chassis_disp(PDC_CHASSIS_DISP_DATA(OSTAT_RUN));
break;
#endif /* CONFIG_PDC_CHASSIS */
return retval;
}
-
-#ifdef CONFIG_PDC_CHASSIS_WARN
-#ifdef CONFIG_PROC_FS
-static int pdc_chassis_warn_pread(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- char *out = page;
- int len, ret;
- unsigned long warn;
- u32 warnreg;
-
- ret = pdc_chassis_warn(&warn);
- if (ret != PDC_OK)
- return -EIO;
-
- warnreg = (warn & 0xFFFFFFFF);
-
- if ((warnreg >> 24) & 0xFF)
- out += sprintf(out, "Chassis component failure! (eg fan or PSU): 0x%.2x\n", ((warnreg >> 24) & 0xFF));
-
- out += sprintf(out, "Battery: %s\n", (warnreg & 0x04) ? "Low!" : "OK");
- out += sprintf(out, "Temp low: %s\n", (warnreg & 0x02) ? "Exceeded!" : "OK");
- out += sprintf(out, "Temp mid: %s\n", (warnreg & 0x01) ? "Exceeded!" : "OK");
-
- len = out - page - off;
- if (len < count) {
- *eof = 1;
- if (len <= 0) return 0;
- } else {
- len = count;
- }
- *start = page + off;
- return len;
-}
-
-static int __init pdc_chassis_create_procfs(void)
-{
- unsigned long test;
- int ret;
-
- ret = pdc_chassis_warn(&test);
- if ((ret == PDC_BAD_PROC) || (ret == PDC_BAD_OPTION)) {
- /* seems that some boxes (eg L1000) do not implement this */
- printk(KERN_INFO "Chassis warnings not supported.\n");
- return 0;
- }
-
- printk(KERN_INFO "Enabling PDC chassis warnings support v%s\n",
- PDC_CHASSIS_VER);
- create_proc_read_entry("chassis", 0400, NULL, pdc_chassis_warn_pread,
- NULL);
- return 0;
-}
-
-__initcall(pdc_chassis_create_procfs);
-
-#endif /* CONFIG_PROC_FS */
-#endif /* CONFIG_PDC_CHASSIS_WARN */