]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/watchdog/pcwd.c
[PATCH] neofb: avoid resetting display config on unblank (v2)
[linux-2.6-omap-h63xx.git] / drivers / char / watchdog / pcwd.c
index 1112ec8e61f36449d44c593e08cfff544d1533b5..8d6b249ad66b8f44c12a4c5f21f421ba17db3f2f 100644 (file)
 #include <asm/io.h>            /* For inb/outb/... */
 
 /* Module and version information */
-#define WD_VER                  "1.16 (03/01/2006)"
-#define PFX                    "pcwd: "
+#define WATCHDOG_VERSION "1.16"
+#define WATCHDOG_DATE "03 Jan 2006"
+#define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog"
+#define WATCHDOG_NAME "pcwd"
+#define PFX WATCHDOG_NAME ": "
+#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION " (" WATCHDOG_DATE ")\n"
+#define WD_VER WATCHDOG_VERSION " (" WATCHDOG_DATE ")"
 
 /*
  * It should be noted that PCWD_REVISION_B was removed because A and B
 #define        PCWD_REVISION_C         2
 
 /*
- * These are the defines that describe the control status #1 bits for the
- * PC Watchdog card, revision A.
- */
+ * These are the defines that describe the control status bits for the
+ * PCI-PC Watchdog card.
+*/
+/* Port 1 : Control Status #1 for the PC Watchdog card, revision A. */
 #define WD_WDRST                0x01   /* Previously reset state */
 #define WD_T110                 0x02   /* Temperature overheat sense */
 #define WD_HRTBT                0x04   /* Heartbeat sense */
 #define WD_RLY2                 0x08   /* External relay triggered */
 #define WD_SRLY2                0x80   /* Software external relay triggered */
-
-/*
- * These are the defines that describe the control status #1 bits for the
- * PC Watchdog card, revision C.
- */
+/* Port 1 : Control Status #1 for the PC Watchdog card, revision C. */
 #define WD_REVC_WTRP            0x01   /* Watchdog Trip status */
 #define WD_REVC_HRBT            0x02   /* Watchdog Heartbeat */
 #define WD_REVC_TTRP            0x04   /* Temperature Trip status */
+/* Port 2 : Control Status #2 */
+#define WD_WDIS                        0x10    /* Watchdog Disabled */
+#define WD_ENTP                        0x20    /* Watchdog Enable Temperature Trip */
+#define WD_SSEL                        0x40    /* Watchdog Switch Select (1:SW1 <-> 0:SW2) */
+#define WD_WCMD                        0x80    /* Watchdog Command Mode */
 
 /* max. time we give an ISA watchdog card to process a command */
 /* 500ms for each 4 bit response (according to spec.) */
@@ -166,7 +173,7 @@ static int send_isa_command(int cmd)
        int port0, last_port0;  /* Double read for stabilising */
 
        /* The WCMD bit must be 1 and the command is only 4 bits in size */
-       control_status = (cmd & 0x0F) | 0x80;
+       control_status = (cmd & 0x0F) | WD_WCMD;
        outb_p(control_status, pcwd_private.io_addr + 2);
        udelay(ISA_COMMAND_TIMEOUT);
 
@@ -221,6 +228,89 @@ static void unset_command_mode(void)
        pcwd_private.command_mode = 0;
 }
 
+static inline void pcwd_check_temperature_support(void)
+{
+       if (inb(pcwd_private.io_addr) != 0xF0)
+               pcwd_private.supports_temp = 1;
+}
+
+static inline char *get_firmware(void)
+{
+       int one, ten, hund, minor;
+       char *ret;
+
+       ret = kmalloc(6, GFP_KERNEL);
+       if(ret == NULL)
+               return NULL;
+
+       if (set_command_mode()) {
+               one = send_isa_command(CMD_ISA_VERSION_INTEGER);
+               ten = send_isa_command(CMD_ISA_VERSION_TENTH);
+               hund = send_isa_command(CMD_ISA_VERSION_HUNDRETH);
+               minor = send_isa_command(CMD_ISA_VERSION_MINOR);
+               sprintf(ret, "%c.%c%c%c", one, ten, hund, minor);
+       }
+       else
+               sprintf(ret, "ERROR");
+
+       unset_command_mode();
+       return(ret);
+}
+
+static inline int pcwd_get_option_switches(void)
+{
+       int option_switches=0;
+
+       if (set_command_mode()) {
+               /* Get switch settings */
+               option_switches = send_isa_command(CMD_ISA_SWITCH_SETTINGS);
+       }
+
+       unset_command_mode();
+       return(option_switches);
+}
+
+static void pcwd_show_card_info(void)
+{
+       char *firmware;
+       int option_switches;
+
+       /* Get some extra info from the hardware (in command/debug/diag mode) */
+       if (pcwd_private.revision == PCWD_REVISION_A)
+               printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", pcwd_private.io_addr);
+       else if (pcwd_private.revision == PCWD_REVISION_C) {
+               firmware = get_firmware();
+               printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n",
+                       pcwd_private.io_addr, firmware);
+               kfree(firmware);
+               option_switches = pcwd_get_option_switches();
+               printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",
+                       option_switches,
+                       ((option_switches & 0x10) ? "ON" : "OFF"),
+                       ((option_switches & 0x08) ? "ON" : "OFF"));
+
+               /* Reprogram internal heartbeat to 2 seconds */
+               if (set_command_mode()) {
+                       send_isa_command(CMD_ISA_DELAY_TIME_2SECS);
+                       unset_command_mode();
+               }
+       }
+
+       if (pcwd_private.supports_temp)
+               printk(KERN_INFO PFX "Temperature Option Detected\n");
+
+       if (pcwd_private.boot_status & WDIOF_CARDRESET)
+               printk(KERN_INFO PFX "Previous reboot was caused by the card\n");
+
+       if (pcwd_private.boot_status & WDIOF_OVERHEAT) {
+               printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n");
+               printk(KERN_EMERG PFX "CPU Overheat\n");
+       }
+
+       if (pcwd_private.boot_status == 0)
+               printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n");
+}
+
 static void pcwd_timer_ping(unsigned long data)
 {
        int wdrst_stat;
@@ -267,7 +357,7 @@ static int pcwd_start(void)
                udelay(ISA_COMMAND_TIMEOUT);
                stat_reg = inb_p(pcwd_private.io_addr + 2);
                spin_unlock(&pcwd_private.io_lock);
-               if (stat_reg & 0x10) {
+               if (stat_reg & WD_WDIS) {
                        printk(KERN_INFO PFX "Could not start watchdog\n");
                        return -EIO;
                }
@@ -291,7 +381,7 @@ static int pcwd_stop(void)
                udelay(ISA_COMMAND_TIMEOUT);
                stat_reg = inb_p(pcwd_private.io_addr + 2);
                spin_unlock(&pcwd_private.io_lock);
-               if ((stat_reg & 0x10) == 0) {
+               if ((stat_reg & WD_WDIS) == 0) {
                        printk(KERN_INFO PFX "Could not stop watchdog\n");
                        return -EIO;
                }
@@ -621,12 +711,6 @@ static struct notifier_block pcwd_notifier = {
  *     Init & exit routines
  */
 
-static inline void get_support(void)
-{
-       if (inb(pcwd_private.io_addr) != 0xF0)
-               pcwd_private.supports_temp = 1;
-}
-
 static inline int get_revision(void)
 {
        int r = PCWD_REVISION_C;
@@ -642,47 +726,9 @@ static inline int get_revision(void)
        return r;
 }
 
-static inline char *get_firmware(void)
-{
-       int one, ten, hund, minor;
-       char *ret;
-
-       ret = kmalloc(6, GFP_KERNEL);
-       if(ret == NULL)
-               return NULL;
-
-       if (set_command_mode()) {
-               one = send_isa_command(CMD_ISA_VERSION_INTEGER);
-               ten = send_isa_command(CMD_ISA_VERSION_TENTH);
-               hund = send_isa_command(CMD_ISA_VERSION_HUNDRETH);
-               minor = send_isa_command(CMD_ISA_VERSION_MINOR);
-               sprintf(ret, "%c.%c%c%c", one, ten, hund, minor);
-       }
-       else
-               sprintf(ret, "ERROR");
-
-       unset_command_mode();
-       return(ret);
-}
-
-static inline int get_option_switches(void)
-{
-       int rv=0;
-
-       if (set_command_mode()) {
-               /* Get switch settings */
-               rv = send_isa_command(CMD_ISA_SWITCH_SETTINGS);
-       }
-
-       unset_command_mode();
-       return(rv);
-}
-
 static int __devinit pcwatchdog_init(int base_addr)
 {
        int ret;
-       char *firmware;
-       int option_switches;
 
        cards_found++;
        if (cards_found == 1)
@@ -728,48 +774,10 @@ static int __devinit pcwatchdog_init(int base_addr)
        pcwd_stop();
 
        /*  Check whether or not the card supports the temperature device */
-       get_support();
-
-       /* Get some extra info from the hardware (in command/debug/diag mode) */
-       if (pcwd_private.revision == PCWD_REVISION_A)
-               printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", pcwd_private.io_addr);
-       else if (pcwd_private.revision == PCWD_REVISION_C) {
-               firmware = get_firmware();
-               printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n",
-                       pcwd_private.io_addr, firmware);
-               kfree(firmware);
-               option_switches = get_option_switches();
-               printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",
-                       option_switches,
-                       ((option_switches & 0x10) ? "ON" : "OFF"),
-                       ((option_switches & 0x08) ? "ON" : "OFF"));
+       pcwd_check_temperature_support();
 
-               /* Reprogram internal heartbeat to 2 seconds */
-               if (set_command_mode()) {
-                       send_isa_command(CMD_ISA_DELAY_TIME_2SECS);
-                       unset_command_mode();
-               }
-       } else {
-               /* Should NEVER happen, unless get_revision() fails. */
-               printk(KERN_INFO PFX "Unable to get revision\n");
-               release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);
-               pcwd_private.io_addr = 0x0000;
-               return -1;
-       }
-
-       if (pcwd_private.supports_temp)
-               printk(KERN_INFO PFX "Temperature Option Detected\n");
-
-       if (pcwd_private.boot_status & WDIOF_CARDRESET)
-               printk(KERN_INFO PFX "Previous reboot was caused by the card\n");
-
-       if (pcwd_private.boot_status & WDIOF_OVERHEAT) {
-               printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n");
-               printk(KERN_EMERG PFX "CPU Overheat\n");
-       }
-
-       if (pcwd_private.boot_status == 0)
-               printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n");
+       /* Show info about the card itself */
+       pcwd_show_card_info();
 
        /* Check that the heartbeat value is within it's range ; if not reset to the default */
        if (pcwd_set_heartbeat(heartbeat)) {