static int set_command_mode(void) { int i, found = 0, count = 0; /* Set the card into command mode */ spin_lock(&pcwd_private.io_lock); while ((!found) && (count < 3)) { i = send_isa_command(CMD_ISA_IDLE); if (i == 0x00) found = 1; else if (i == 0xF3) { /* Card does not like what we've done to it */ outb_p(0x00, pcwd_private.io_addr + 2); udelay(1200); /* Spec says wait 1ms */ outb_p(0x00, pcwd_private.io_addr + 2); udelay(ISA_COMMAND_TIMEOUT); } count++; } spin_unlock(&pcwd_private.io_lock); pcwd_private.command_mode = found; if (debug >= DEBUG) printk(KERN_DEBUG PFX "command_mode=%d\n", pcwd_private.command_mode); return found; }
static int set_command_mode(void) { int i, found=0, count=0; /* Set the card into command mode */ spin_lock(&io_lock); while ((!found) && (count < 3)) { i = send_isa_command(CMD_ISA_IDLE); if (i == 0x00) found = 1; else if (i == 0xF3) { /* Card does not like what we've done to it */ outb_p(0x00, current_readport + 2); udelay(1200); /* Spec says wait 1ms */ outb_p(0x00, current_readport + 2); udelay(ISA_COMMAND_TIMEOUT); } count++; } spin_unlock(&io_lock); command_mode = found; return(found); }
static int set_command_mode(void) { int i, found = 0, count = 0; spin_lock(&pcwd_private.io_lock); while ((!found) && (count < 3)) { i = send_isa_command(CMD_ISA_IDLE); if (i == 0x00) found = 1; else if (i == 0xF3) { outb_p(0x00, pcwd_private.io_addr + 2); udelay(1200); outb_p(0x00, pcwd_private.io_addr + 2); udelay(ISA_COMMAND_TIMEOUT); } count++; } spin_unlock(&pcwd_private.io_lock); pcwd_private.command_mode = found; if (debug >= DEBUG) printk(KERN_DEBUG PFX "command_mode=%d\n", pcwd_private.command_mode); return found; }
static inline void pcwd_get_firmware(void) { int one, ten, hund, minor; strcpy(pcwd_private.fw_ver_str, "ERROR"); 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(pcwd_private.fw_ver_str, "%c.%c%c%c", one, ten, hund, minor); } unset_command_mode(); return; }
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 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 void pcwd_show_card_info(void) { 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) { pcwd_get_firmware(); printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port " "0x%04x (Firmware version: %s)\n", pcwd_private.io_addr, pcwd_private.fw_ver_str); 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"); }